stm32启动时用到的systeminit、__main说明

embedded/2024/10/20 16:47:14/
  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.ppmy.cn/embedded/129036.html

相关文章

Flutter 中的 PopScope 小部件:全面指南

Flutter 中的 PopScope 小部件:全面指南 在 Flutter 应用开发中,导航和路由管理是构建复杂应用时必须面对的挑战之一。PopScope 小部件是 Flutter 2.0 版本引入的一个新功能,它提供了一种更灵活的方式来控制页面的弹出和返回行为。本文将带你…

JVM进阶调优系列(2)字节面试:JVM内存区域怎么划分,分别有什么用?

像字节、阿里、腾讯、美团、京东等大厂面试,JVM调优必问必答必会的问题,重要性不言而喻。 上篇文章详细分析了类加载器类型、双亲委派机制优缺点、以及如何打破双亲委派机制。末尾我们留了一个问题:类加载到内存过程具体会经过那些流程&#…

Python 如何处理大规模数据库表的迁移与数据迁移的高效执行

Python 如何处理大规模数据库表的迁移与数据迁移的高效执行 引言 在现代应用开发中,随着业务需求的增长,数据库表结构和数据往往需要进行迁移和更新。迁移(Migration)是指对数据库表的结构、数据类型、索引、约束等进行修改或更新…

【python_修改PPT中字体,run.font.name只对英文生效怎么办?】

python_修改PPT中字体,run.font.name只对英文生效怎么办? 参考:使用pptx_ea_font库设置中文字体 from pptx import Presentation from pptx.util import Pt from pptx_ea_font import set_font# 打开现有的 PPT 文件 prs Presentation(D:\…

LeetCode 19 - 删除链表的倒数第N个节点

题目描述 给你一个链表,删除链表的倒数第 N 个节点,并且返回链表的头结点。 例如: 输入:head [1,2,3,4,5], n 2 输出:[1,2,3,5]解题思路 我们可以使用双指针的方法来解决这个问题。主要思路是使用两个指针fsat和…

Substrate 网络层深度解读:libp2p 助力去中心化点对点高效通信

区块链中需要高效的通信工具来确保节点之间的顺畅交互。而 libp2p 正是开发者在点对点通信中不可或缺的框架,提供了强大的模块化功能,使得去中心化网络中的消息传递变得更加灵活且安全。在 Substrate 中,libp2p 的集成帮助开发者轻松实现各种…

定时发送邮件

1.先连接虚拟机进行挂载 2.编辑dnf配置文件 查看 3.使用dnf安装邮件客户端工具 4.配置文件里写入邮箱信息 [rootlocalhost ~]#vim /etc/s-nail.rc 5.测试邮件服务 6.最后设置定时任务 [rootlocalhost ~]# crontab -e 完成

Nature 正刊丨昼夜节律可塑性通过神经肽基因的调节变化而进化

01摘要 许多生物,包括世界性的果蝇,表现出昼夜节律的可塑性,它们的活动随着黎明-黄昏时间的变化而变化1。这种行为是如何演变的尚不清楚。在这里,我们将黑腹果蝇与经历最小光周期变化的赤道生态专家黑腹果蝇进行比较,以…