embedded

Total size of the contents of all the files in a directory [closed]

喜欢而已 提交于 2019-12-04 07:27:20
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . When I use ls or du , I get the amount of disk space each file is occupying. I need the sum total of all the data in files and subdirectories I would get if I opened each file and counted the bytes. Bonus points if I can get this without opening each file and counting. 回答1: If you want the 'apparent size' (that is

A good serial communications protocol/stack for embedded devices? [closed]

China☆狼群 提交于 2019-12-04 07:26:57
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . After writing several different custom serial protocols for various projects, I've started to become frustrated with re-inventing the wheel every time. In lieu of continuing to develop custom solutions for every project, I've been searching for a more general solution. I was wondering if anyone knows of a serial

How do I capture and view ITM trace information on a Cortex-M4 MCU?

梦想的初衷 提交于 2019-12-04 06:51:18
I would like to capture, decode, and view ITM trace information for a Cortex-M4 MCU (in my case, an Atmel SAM4S). In particular, I want to capture exceptions and user trace data relative to other signals on my board (i.e. show all signals and trace information on same timeline). This can be done using the following steps: Place debugger in SWD mode. If using J-Link Segger on Linux, this can be done with JLinkGDBServer -if swd Add code to the MCU to enable trace. Set the bit rate to a value suitable for your needs (I used 8 MHz). Example Ada code is below. Use logic analyzer to capture trace

C global anonymous struct / union

南楼画角 提交于 2019-12-04 06:41:40
问题 I have a uint64 variable which often only requires high or low 32 bit access. I am using a 32-bit ARM Cortex M0, and to help with speed and I am trying to overlap the uint64 variable with two uint32 variables in C, using anonymous structures in the hope of avoiding pointer arithmetic to access members. Is what I am trying to do possible? It could be that using a named union is just as fast, but now I'm just intrigued if it can be done without. The following does not compile successfully: http

Detect Stack overflows

扶醉桌前 提交于 2019-12-04 06:39:50
How do operating systems detect stack overflows of user-space programs [and then send SIGTERM or SIGSEGV to those userspace programs] ? The answer will depend on the target architecture and the particular OS. Since the question is tagged Linux, you have rather biased the question which on the face of it seems more general. In a sophisticated OS or RTOS such as Linux or QNX Neutrino, with MMU protection support, memory protection mechanisms may be used such as the guard pages already mentioned. Such OSs require a target with an MMU of course. Simpler OSs and typical RTOS scheduling kernels

snprintf() prints garbage floats with newlib nano

醉酒当歌 提交于 2019-12-04 06:25:20
I am running a bare metal embedded system with an ARM Cortex-M3 (STM32F205). When I try to use snprintf() with float numbers, e.g.: float f; f = 1.23; snprintf(s, 20, "%5.2f", f); I get garbage into s . The format seems to be honored, i.e. the garbage is a well-formed string with digits, decimal point, and two trailing digits. However, if I repeat the snprintf , the string may change between two calls. Floating point mathematics seems to work otherwise, and snprintf works with integers, e.g.: snprintf(s, 20, "%10d", 1234567); I use the newlib-nano implementation with the -u _printf_float

#define vs. enums for addressing peripherals

末鹿安然 提交于 2019-12-04 06:24:37
I have to program peripheral registers in an ARM9-based microcontroller. For instance, for the USART, I store the relevant memory addresses in an enum : enum USART { US_BASE = (int) 0xFFFC4000, US_BRGR = US_BASE + 0x16, //... }; Then, I use pointers in a function to initialize the registers: void init_usart (void) { vuint* pBRGR = (vuint*) US_BRGR; *pBRGR = 0x030C; //... } But my teacher says I'd better use #define s, such as: #define US_BASE (0xFFFC4000) #define US_BRGR (US_BASE + 0x16) #define pBRGR ((vuint*) US_BRGR) void init_usart (void) { *pBRGR = 0x030C; } Like so, he says, you don't

What is overalignment of execution regions and input sections?

懵懂的女人 提交于 2019-12-04 05:53:58
I came across code similar to the following today and I am curious as to what is actually happening: #pragma pack(1) __align(2) static unsigned char multi_array[7][24] = { 0 }; __align(2) static unsigned char another_multi_array[7][24] = { 0 }; #pragma pack() When searching for a reference to the __align keyword in the Keil compiler, I came across this: Overalignment of execution regions and input sections There are situations when you want to overalign code and data sections... If you have access to the original source code, you can do this at compile time with the __align(n) keyword... I do

Ultra-portable, small complex config file library in ANSI C?

落花浮王杯 提交于 2019-12-04 05:46:00
I'm looking for a very portable, minimalistic/small XML/configuration language library in ANSI C with no external dependencies (or very few), compiling down to less than 100K. I need it for a moderately complex configuration file, and it must support Unicode. Some more requirements: OK to use/embed/statically link into proprietary code . Credit will always will be given where credit is due. Not necessarily XML. Really, clean code /no weird or inconsistent string handling. UTF-8 . Thank you fellas. karlphillip This is somehow similar to this question: Is there a good tiny XML parser for an

malloc in embedded systems [duplicate]

自作多情 提交于 2019-12-04 05:23:24
This question already has answers here : Closed 3 years ago . Dynamic memory allocation in embedded C (3 answers) I am working with an embedded system. The application is running on AT91SAMxxxx and cortex m3 lpc17xxx. I am looking into dynamic memory allocation as it would dramatically change the face of the application (and give me more Power). I think the my only real route is to set out an area of memory for a heap and design a tailored malloc that best fits (pun) my purpose. When looking at different algorithms for memory allocation you cant not stumble upon Doug Lea's malloc. I take it