当前位置: 首页 > news >正文

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


http://www.mrgr.cn/news/51630.html

相关文章:

  • 使用IMX6UL实现UART串口通信
  • 网络编程(21)——通过beast库快速实现http服务器
  • Shiro认证
  • 2. MySQL数据库基础
  • 本地typora编辑的.md文件上传到【语雀】->【CSDN】
  • Java-IO流使用场景
  • 4、CSS3笔记
  • 【Web前端概述】
  • mybatis-plus的Iservice接口的save方法,返回true,但是数据库表里却没有看到新记录
  • torchserve在转转GPU推理服务架构下的实践
  • 教学资料管理|基于springBoot的教学资料管理系统设计与实现(附项目源码+论文+数据库)
  • 设置静置情况下getCurrentCalls方法为何一直打印?
  • 25届计算机保研经验贴(中末九保清北及华五人、自动化所、北邮、港中文)
  • 【推导过程】常用连续分布的数学期望、方差、特征函数
  • Python--plt.errorbar学习笔记
  • 多场景多任务建模(三): M2M(Multi-Scenario Multi-Task Meta Learning)
  • H5 Canvas 举牌小人
  • DeepFM模型代码详解
  • rom定制系列------小米6x_澎湃os1.0.28安卓13定制固件修改 刷写过程与界面预览
  • cuda编程模型