RTT startup. C code learning

Source: Internet
Author: User

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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.