RTT learning is concentrated at the application layer, and the underlying code will be involved when necessary.
Startup is the startup code of RTT, similar to UCOS.
void rtthread_startup(void){ /* init board */ rt_hw_board_init(); /* show version */ rt_show_version(); /* init tick */ rt_system_tick_init(); /* init kernel object */ rt_system_object_init(); /* init timer system */ rt_system_timer_init(); /* init scheduler system */ rt_system_scheduler_init(); /* init all device */ rt_device_init_all(); /* init application */ rt_application_init(); /* init idle thread */ rt_thread_idle_init(); /* start scheduler */ rt_system_scheduler_start(); /* never reach here */ return ;}
After reading it, rt_hw_board_init (); and rt_application_init (); are the codes that I need to pay attention.
The first is board-level initialization, and the second is the initialization of each thread.
Certificate -----------------------------------------------------------------------------------------------------------------------------------
#ifdef RT_USING_HEAP#if STM32_EXT_SRAM rt_system_heap_init((void*)STM32_EXT_SRAM_BEGIN, (void*)STM32_EXT_SRAM_END);#else#ifdef __CC_ARM rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)STM32_SRAM_END);#elif __ICCARM__ rt_system_heap_init(__segment_end("HEAP"), (void*)STM32_SRAM_END);#else /* init memory system */ rt_system_heap_init((void*)&__bss_end, (void*)STM32_SRAM_END);#endif#endif#endif
This code is related to the initialization of the runtime heap. Corresponds to external Ram, MDK, IAR, and GCC respectively. The strange MDK writing is described in another blog. Simply put, the uninitialized Ram is used as the start until the end. Heap is mainly used to create dynamic threads and allocate memory. The stack of static threads is known, so the initialization Ram has. The strange symbol is unique to the linker and used to obtain the end address of the used Ram.