Hi,
When I worked with MQX, the problem I had was not ROM (internal flash) that was not big enough, but RAM (internal RAM) because of RTCS and its servers.
I worked on an MCF52259 with 512KB ROM and 64KB RAM, with MQX3.7, but this should also be nearly the same for other processors and newer MQX versions.
My application was made of 19 tasks : 2 MQX shell on serial lines, 1 RTCS, 1 TELNET, 1 TELNET MQX shell, 1 HTTP server, 1 SNMP server, 1 SNMP trap/inform management, and 11 user defined tasks for management.
The drivers used were : interrupt driven UART (x2 for MQX shell), interrupt driven I2C (x2 busses), ADC (x4 channels), general purpose timers (x2 channels), GPIOs, PWM. However drivers have a very small impact on RAM usage.
All that used only 320KB out of 512KB of ROM
But form RAM, I had to tune the stack of each task to the minimum required (27KB total for all tasks) to leave enough memory for the heap that is used as said by Benjamin for the buffers allocated by RTCS and its services (telnet, http, snmp, ...) that need about 30KB of RAM in my application. And if you add few KB for read-write variables, you are at 64KB out of 64KB !!
To give you an idea of the minimum stack required, I found that for a "non debug" target (must be increased for a debug target) :
- MQX shell : 2048 bytes
- RTCS task : 3000 bytes
- Telnet server, Telnet shell, SNMP server : 2048 bytes
- HTTP server : 2500 bytes
- user tasks : 768 bytes
Now to know the amount of memory used (ROM and RAM) I used code below.
Please note that the "minimum free memory" is the minimum detected from the start of MQX (can only decrease with time) that is decreased when malloc() is used.
| uint_32 flash_base | = (uint_32)BSP_INTERNAL_FLASH_BASE; |
| uint_32 flash_size | = (uint_32)BSP_INTERNAL_FLASH_SIZE; |
/* Data from linker script only available for internal flash target */
extern uchar __VECTOR_TABLE_ROM_START[];
extern uchar flashx_start[];
| uint_32 flash_code_start | = (uint_32)__VECTOR_TABLE_ROM_START; |
| uint_32 flash_code_end | = (uint_32)flashx_start - 1; |
/* RAM */
| uint_32 sram_base | = (uint_32)BSP_INTERNAL_SRAM_BASE; |
| uint_32 sram_size | = (uint_32)BSP_INTERNAL_SRAM_SIZE; |
uint_32 sram_kernel_mem_start = (uint_32)BSP_DEFAULT_START_OF_KERNEL_MEMORY;
uint_32 sram_kernel_mem_end = (uint_32)BSP_DEFAULT_END_OF_KERNEL_MEMORY - 1;
uint_32 max_mem = (uint_32)_mem_get_highwater();
printf("FLASH : [0x%08x - 0x%08x] : %d bytes\n", flash_base, flash_base + flash_size - 1, flash_size);
printf(" software image : [0x%08x - 0x%08x] : %d bytes\n",
| flash_code_start, flash_code_end, flash_code_end - flash_code_start + 1); |
printf("SRAM : [0x%08x - 0x%08x] : %d bytes\n", sram_base, sram_base + sram_size - 1, sram_size);
printf(" runtime r/w data : [0x%08x - 0x%08x] : %d bytes\n",
| sram_base, sram_kernel_mem_start - 1, sram_kernel_mem_start - sram_base); |
printf(" kernel memory : [0x%08x - 0x%08x] (high water : 0x%08x)\n",
| sram_kernel_mem_start, sram_kernel_mem_end, max_mem); |
printf(" minimum free memory : %d bytes\n", sram_kernel_mem_end - max_mem);
I hope this will help.