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

相关推荐
橘为己有4414 分钟前
STM32:SPI(1)
stm32·单片机·嵌入式硬件
en.en..38 分钟前
STM32 定时器 | 输入捕获单元与输出比较单元
单片机·嵌入式硬件
倔强的胡萝卜1 小时前
基于STM32F103C8T6的计算器设计(二)
stm32·单片机·嵌入式硬件
倔强的胡萝卜4 小时前
基于STM32F103C8T6的温湿度报警器设计
数据库·stm32·mongodb
仰望星空的凡人12 小时前
瑞萨RH850/U2A 时钟系统深度解析:从时钟源、PLL 到外设时钟树的架构与应用
单片机·嵌入式硬件
Zw-awa13 小时前
云台是什么?舵机、步进、无刷电机一篇讲透,从控制原理到选型避坑
stm32
2501_9226395817 小时前
率能半导体 SS8230 H桥驱动芯片:15V/1.8A,覆盖摄像机、玩具、机器人三大场景
stm32·单片机·嵌入式硬件·硬件工程
橘为己有44120 小时前
STM32:I2C(1)
stm32·单片机·嵌入式硬件
少司府21 小时前
嵌入式外设篇(三)GPIO·三:MCU系统结构、总线与统一编制
linux·python·stm32·单片机·嵌入式硬件·mcu·嵌入式软件
2501_922639581 天前
率能半导体 SS8812T双通道H桥驱动芯片:36V/1.6A,覆盖POS打印机、安防相机、办公自动化、游戏机、机器人五大应用场景
stm32·单片机·嵌入式硬件·硬件工程