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

相关推荐
盈创力和200723 分钟前
以太网多参量传感器:构筑工业安全与环境稳定的“数据堡垒”
嵌入式硬件·安全·以太网温湿度传感器·多参量传感器
python百炼成钢3 小时前
10.串口
linux·stm32·单片机·嵌入式硬件
腾飞的信仰7 小时前
为什么有的mcu烧录的时候是用hex,有的是用bin
单片机
Rotion_深8 小时前
单片机 看门狗的作用
单片机·嵌入式硬件
Jason_zhao_MR9 小时前
RK3576机器人核心:三屏异显+八路摄像头,重塑机器人交互与感知
linux·人工智能·嵌入式硬件·计算机视觉·机器人·嵌入式·交互
San_a dreamer fish10 小时前
韦东山嵌入式入门笔记之——应用开发基础篇(七)电阻屏和电容屏
嵌入式硬件
【云轩】10 小时前
RS-485稳定通信的三大基石:接地、线序与终端电阻
单片机·嵌入式硬件
电鱼智能的电小鱼11 小时前
基于电鱼 ARM 工控机的AI视频智能分析方案:让传统监控变得更聪明
网络·arm开发·人工智能·嵌入式硬件·算法·音视频
充哥单片机设计11 小时前
【STM32项目开源】基于STM32的智能水质检测系统
stm32·单片机·嵌入式硬件
wuk99811 小时前
基于STM32平台的ADS1292心电采集驱动程序
stm32·单片机·嵌入式硬件