Is there any specification about the memory usage (ROM and RAM) of all components in MQX (including RTCS, file system, USB host/device)?
I am targeting a Kinetis K6xF processor.
Than you,
Adrian
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.
Hi Adrian
Freescale MQX RTOS includes a project that helps to determinate the timing and code sizing of any project. You can find this in the path <MQX install_path>\mqx\examples\benchmrk\codesize\reports The code sizing depends on the kind of functions used in the final application. The benchmark project includes almost all the main components in MQX. This will provide the code size of these components.
In addition I had checked TWR-K60N512 Quick Start Demo project with following USB stack memory map:
Module ro code ro data rw data
------ ------- ------- -------
usb_ddk_twrk60n512_d.a: [12]
callback_usbfs.o 29 64
dev_cncl.o 76 60
dev_main.o 704 364
dev_recv.o 176 44
dev_send.o 180 124
dev_utl.o 608 500
usb_class.o 658 124 4
usb_framework.o 1 316 271 212
usb_hid.o 1 236 40 20
usbfs_dev_main.o 6 472 378 516
usbinst.o 80 40
--------------------------------------------
Total: 11 506 1 974 816
It shows MQX USB stack is using 11.5K bytes code size and 2K bytes SRAM size.
Regards
Sol
Hi Sol,
Thank you for your answer.
What I actually want is to have an approximate code size estimate for a project containing all those components above (plus SSL client/server), BEFORE starting the project (which may take several months). We need to see, if it will fit in 512K Flash or need more. Of course we want just an estimate. By having MQX components size we can add something for our application and end with some quick estimate, without having to write the code.
All other TCP/IP stacks give that information (how much code will take each component), but I cannot find anything for MQX (other than it can fit into 30KB. I assume this is just very minimal tcp/ip).
So, let me know, if such an information exists, please.
Thank you,
Adrian
Hi
Basically we can talk about 4 scenarios:
a) Freescale MQX RTOS alone. It can be configured to take as little as 6 KB of ROM, including kernel, interrupts, semaphores, queues and memory manager.
b) Freescale MQX RTOS with 2 tasks. It can be configured to take as little as 12 KB of ROM and 2.5K RAM on CFV2, including kernel, 2 task applications,1 LW Semaphore, interrupt stack, queues, and memory manager.
c) Freescale MQX RTCS. It includes RTOS and TCPIP stack. It can be configured to take as little as 30Kb of ROM.
d) Freescale MQX USB. It includes RTOS and USB stack. It is designed to fit in a small footprint of 10Kb RAM and with code size of 32Kb.
In addition please check the reports attached.
Regards
Sol