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

相关推荐
半杯咖啡半行码7 小时前
STM32之ARM通用汇编指令详解:从指令格式到寻址方式
汇编·arm开发·stm32
创界工坊工作室8 小时前
22-基于STM32的汽车防盗系统设计
stm32·单片机·嵌入式硬件·proteus
雨田言炎10 小时前
STM32之RCC系统时钟控制(芯片的心脏控制器)
stm32·单片机·嵌入式硬件
李永奉10 小时前
日常使用的锂电池上,新、旧锂电池的差异分析
单片机·嵌入式硬件·物联网·智能手机·电脑
额额额对了11 小时前
IMX6ULL 杂项设备 LED 驱动
stm32·单片机·嵌入式硬件
长春的KAKA12 小时前
Proxmark3 Iceman分支CLI命令总表
嵌入式硬件
半杯咖啡半行码12 小时前
STM32开发之IIC通信详解:从协议基础到FM24CL04实战
stm32·单片机·嵌入式硬件
硅基手札13 小时前
【I2C 技术系列 05】I2C 多主仲裁与时钟同步
驱动开发·stm32·单片机·嵌入式硬件·mcu·计算机外设
szxinmai主板定制专家13 小时前
面向虚拟电厂协调控制:RK3588+FPGA+AI边缘控制器设计思路与算力评估
人工智能·嵌入式硬件·fpga开发·机器人·jetson·zynq·振动采集
Zw-awa13 小时前
DO 和 AO 到底怎么选:比较器替你决定了什么
stm32