I started with the TWR-K60N512_Quick_Start_Demo. I added a thread to TASK_TEMPLATE_STRUCT MQX_template_list:
{ MC_TIME_TASK, time_task, 800, 12, "mcTime", 0, 0, 0 },
Doing this causes MQX to "blow up" and restart when _mqx() calls:
_mem_zero((pointer)kernel_data, (_mem_size)sizeof(KERNEL_DATA_STRUCT));
Investigation shows that before I add the thread to MQX_template_list, kernel_data is at address 0x1FFF0960-0x1FFF0C80. After I add the thread, kernel_data is at address 0x2000FEF0-0x20010210. There is no RAM past 0x2000FFFF.
Before adding thread:
MQX_init_struct -> START_OF_KERNEL 0x1FFF0960
MQX_init_struct -> END_OF_KERNEL 0x2000FFF0
After adding thread:
MQX_init_struct -> START_OF_KERNEL 0x2000FEF0
MQX_init_struct -> END_OF_KERNEL 0x00000411
What caused MQX_init_struct to have invalid addresses for the START_OF_KERNEL and END_OF_KERNEL?
thanks,
Kevin
Hi Kevin,
one explanation could be that your task uses a lot of RAM.
Could you check the RAM allocations in map-file.
~Mark
No, it's a small simple task. If I delete one of the tasks in the TWR-K60N512_Quick_Start_Demo which use more stack space than the task I wish to create (for example, sdcard_task) and replace it with my task everything is okay.
I have been doing embedded development for many years on other platforms using an RTOS. So, I have a good understanding of the process. The plan is for us to port all of our products to Kinetis. I just have to figure out Kinetis and MQX, .
My guess is that something is getting placed at an absolute address and when I add my task I am crossing a boundary or exceed an allocation. The question is what boundary or allocation? and, how do I fix it? I looked at the Lightweight Memory. It says I have 16K free at 0x1fffbe10 and 65k free at 0x20000004.
Do you have any other ideas?
thanks,
Kevin
Hi,
what values map file shows for these segments:
1FFF8000 00014C9C 00001210 .main_application_data ram
1FFF9210 1FFF9210 00001B10 .main_application_bss ram
1FFFAD20 1FFFAD20 00000000 .kernel_data ram
20007FE0 20007FE0 00000000 .end_of_kernel_data end_of_kd
(Those values are for K10, it has only 64k RAM)
There is a discontinuity in RAM at address 0x20000000, hidden in init_bsp.c:
uint_32 _bsp_enable_card(void)
...
/* Memory splitter - prevent accessing both ram banks in one instruction */
_mem_alloc_at(0, (void*)0x20000000);
~Mark
I am using the IAR Embedded Workbench compiler version 6.30.
I have traced the problem to the initialization of MQX_init_struct before main() is called.
int main(void)
{
/* Start MQX */
_mqx( (MQX_INITIALIZATION_STRUCT_PTR) &MQX_init_struct );
return 0;
}
__iar_data_init3 is an assembler function which appears to be initializing RAM constants. It is provided by IAR and there is no source code for it. When this function executes, MQX_init_struct gets set to values which are not correct. At this point I think I need to contact IAR.
thanks,
Kevin