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

相关推荐
我先去打把游戏先21 小时前
ESP32开发指南(基于IDF):连接AWS,乐鑫官方esp-aws-iot-master例程实验、跑通
开发语言·笔记·单片机·物联网·学习·云计算·aws
hazy1k1 天前
51单片机基础-继电器实验
stm32·单片机·嵌入式硬件·51单片机·1024程序员节
美好的事情总会发生1 天前
FPGA的LVDS接口电压
嵌入式硬件·fpga开发·硬件工程·智能硬件
kaka❷❷1 天前
STM32中 ESP8266 MQTT ModBus RS482 介绍
stm32·嵌入式硬件·智能路由器
hazy1k1 天前
51单片机基础-TFT LCD 显示(ILI9341,SPI 4线)
c语言·stm32·单片机·嵌入式硬件·51单片机
brave and determined1 天前
硬件-内存学习DAY14——3DXPoint:存储技术的革命与终结
嵌入式硬件·intel·3d xpoint·内存创新·内存设计·内存应用·内存新技术
D.....l1 天前
STM32学习(MCU控制)(RS485 and ModBus)
stm32·单片机·学习
Jie_jiejiayou1 天前
按键防抖 — 工业级标准实现总结(STM32)
c语言·stm32·按键消抖
物联网牛七七1 天前
单片机中的中断
单片机·嵌入式硬件
小鱼儿电子1 天前
46-基于STM32的智能宠物屋设计与实现
stm32·腾讯云·宠物屋·智能宠物屋