stm32启动时用到的systeminit、__main说明

  1. 先运行systeminit函数,其功能:初始化时钟(SYSCLK, HCLK, PCLK2 and PCLK1 prescalers)、配置中断向量表(中断向量表的定位是在flash还是SRAM)
  2. 再运行__main函数:
  • 作用:Initialization of the execution environment and execution of the application
  • You can customize execution intialization by defining your own __main that branches to __rt_entry.
  • The entry point of a program is at __main in the C library where library code:
  • Copies non-root (RO(不会拷贝,官方提供和实际实践有出入) and RW) execution regions from their load addresses to their execution addresses. Also, if any data sections are compressed, they are decompressed from the load address to the execution address.
  • Zeroes ZI regions.
  • Branches to __rt_entry.
  • If you do not want the library to perform these actions, you can define your own __main that branches to __rt_entry。
  1. 再运行The library function __rt_entry() runs the program as follows:
  • Sets up the stack and the heap by one of a number of means that include calling __user_setup_stackheap(), calling __rt_stackheap_init(), or loading the absolute addresses of scatter-loaded regions.
  • Calls __rt_lib_init() to initialize referenced library functions, initialize the locale and, if necessary, set up argc and argv for main().This function is called immediately after__rt_stackheap_init() and is passed an initial chunk of memory to use as a heap. This function is the standard ARM C library initialization function and it must not be reimplemented.
  • Calls main(), the user-level root of the application.
  • From main(), your program might call, among other things, library functions.
  • Calls exit() with the value returned by main().

因为库函数里面的 ___main函数 和 ____rt_entry函数是弱函数,所有我们可以自己编写__main和__rt_entry

相关推荐
azwsm7 小时前
驱动第一阶段——启动流程
单片机·嵌入式硬件
单片机杂货铺9 小时前
基于单片机的自动开窗器设计
stm32·嵌入式硬件·51单片机·硬件工程
天天爱吃肉821810 小时前
商用车多体动力学实战笔记|第6篇:动力传动系统(发动机、变速箱、分动器、TCS、LSD限滑差速)
大数据·人工智能·笔记·python·嵌入式硬件·汽车
别催小唐敲代码11 小时前
STM32 I2C协议详解:从原理到实战
stm32·网络协议·协议
lhbweilai11 小时前
STM32 I2C(hal库)
stm32·单片机·嵌入式硬件
单片机杂货铺14 小时前
基于STM32的智能市政清洁小车系统设计
stm32·单片机·嵌入式硬件·物联网·硬件工程
单片机杂货铺14 小时前
基于STM32的智能书房系统的设计
stm32·单片机·嵌入式硬件·51单片机·硬件工程
&Hello Code15 小时前
3.解决STM32工程混乱:一套可复用六层架构,GPIO 、LED 实战演示
stm32·嵌入式硬件·架构
普科PRBTEK15 小时前
电流探头的常见应用场景
单片机·嵌入式硬件
qq_4017004115 小时前
3个常用的单片机实现隔离控制大电流负载例子
单片机·嵌入式硬件