bare-mental project based on RVDS

本文详细介绍了RVDS编译环境中系统的初始化流程,包括复位处理程序、__main及__scatterload的作用,并解释了如何实现堆栈初始化。同时,针对编写裸金属启动项目时可能遇到的错误进行了分析并提供了解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

----------------------------------------------------------------------------------------------------------

Author :tiger-john(冀博)
WebSite
:blog.youkuaiyun.com/tigerjb

Email jibo.tiger@gmail.com

Tiger声明:本人不排斥别人转载tiger-john的文章,只是请您注明出处3Q

---------------------------------------------------------------------------------------------------

.RVDS startup flow

In RVDS compiler environment, an initialization sequence executes to set up the system before the main task is executed.

The Figure 1[1] shows the default initialization sequence (use BL __main method)

Figure 1 the default initialization sequence

The reset handler executes immediately on system startup. The block of code labeled $$Sub$$main executes immediately before the main application.

First: The reset handler is a short module coded in assembler that is executed on system reset. As a minimum, we must reset handler initializes stack pointers for the modes that your application is running in by ourselves.

Second: the reset handler typically branches to __main to begin the C library initialization sequence. __main branches directly to __scatterload. __scatterload is responsible for setting the runtime image memory map, whereas __rt_entry (runtime entry) is responsible for initializing the C library.

(1) __scatterload carries out code and data copying, decompression of RW data if necessary, and zeroing of ZI data.

(2) __scatter load branches to __rt_entry. This sets up the application stack and heap. So we can must implementation __user_initial_stackheap. If we don’t implement __user_initial_stackheap function, or the system raise error message: undefined symbol Image$$Limit (refer from sys_stackheap.o). Then initializes library functions and their data, and calls any constructors of global declared objects (this is only use C++ only)

(3)__rt_entry then branches to main () that is entry to our application. When the main application has finished executing, __rt_entry shuts down the library, then hands control back to the debugger.

Note:

(1)If we use BL __main, the RVDS compiler auto realize to copy data to memory and initialize ZI data of zero ,not we implement by ourselves. And, if use BL __main, the function main () has a special significance. The presence of a main () function forces the linker to link in the initialization code in __main and __rt_entry. Without a function labeled main () the initialization sequence is not linker in, and as a result, some standard C library functionality is not supported.

(2) If we use BL main, we must implement copy data to memory and initialize ZI data of zero. In this method, the application code entry label is arbitrary character. Only BL Label the same is function Label.

(3) In the GUN compiler environment the system can’t auto copy data to memory and initialize ZI data of zero. This usage of it is more closed to the second, but they have some slight difference.

. RVDS startup project of Error message

In this section, during write startup project base on bare-metal using RVDS compiler environment I faced some errors message, analyzing the reasons and raising the method of avoiding and modifying these errors. For more details please check in startup project code.

1. Error message: startup.o (vectors) contains invalid call from ‘~PRES8’ function to ‘REQ8’ function serial_init.

(1) Error reason: This linker error is given where a stack alignment conflict is detected in object code. The “ABI for the ARM Architecture” demands that code maintains 8~bytes stack alignment at its interfaces. This allows efficient use of LDRD and STRD instructions (in ARM Architecture 5TE and later) to access 8-byte-aligned “double” and “long long” data types. Symbols like ‘~PRES8’ and ‘REQ8’ are “Build Attributes” of the objects. PRES8 means the object PRESERVES 8~byte alignment of the stack. ~PRES8 means the object REQuires 8-byte alignment of the stack. ~PRES8 means the object REQuires 8-byte alignment of the stack [2].

(2) Solution: Add ‘PRESERRVE8’ directive to the top of each assembler file.

PRESERVE8

AREA TEXT, CODE, READONLY

CODE32

2. Error message: Undefined symbol Image$$ZI$$Limit (referred from sys_stackheap.o)

(1) Error reason: Because the default implementation uses Image$$ZI$$Limit, you must re-implement __user_initial_stackheap (). The following error message is displayed from the linker: Undefined symbol Image&&ZI$$Limit (referred from sys_stackheap.o) [3]

(2)Solution: Re-implement the __user_initial_stackheap ()

EXPORT __user_initial_stackheap

__user_initial_stackheap

LDR r0, =bottom_of_heap

MOV pc, lr

AREA Heap, DATA, NOINIT

bottom_of_head SPACE 1

Reference:

1. RealView® Compilation Tools Version 2.2 Developer Guide

2. ARM Web Error link: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0437a/index.html

3. RealView® Compilation Tools Version 2.2 Linker and Utilities Guide

### 关于 npm install 资金支持的意义与细节 `npm install` 是 Node.js 生态系统中用于安装依赖的核心工具之一。然而,除了其基本的功能外,npm 提供了一个名为 **funding** 的特性,旨在帮助开发者和支持者通过资金赞助的方式促进开源软件的发展。 #### Funding 特性的背景与意义 Funding 功能允许包维护者声明他们的项目接受资助的方式。这使得用户可以通过简单的命令轻松找到并支持他们所使用的开源库的作者或团队。这种机制不仅有助于维持项目的持续发展,还能够激励更多高质量的开源贡献[^5]。 当运行 `npm install` 时,如果某个已安装的包在其 `package.json` 文件中定义了 funding 字段,则会显示一条提示消息,告知用户该项目正在寻求财务上的支持。例如: ```json { "name": "example-package", "version": "1.0.0", "funding": { "type": "individual", "url": "https://github.com/sponsors/example" } } ``` 上述配置表明该包接受个人形式的资金捐助,并提供了具体的链接地址让用户访问捐赠页面[^1]。 #### 如何启用和查看资金支持选项? 要利用此功能,首先需要确认目标仓库是否已经设置了 funding 属性。一旦设置完成,在执行如下操作之后就能看到相关信息: - 使用 `npm fund` 查看当前环境中所有可资助项目的列表及其对应的捐款渠道; - 或者在每次调用 `npm install` 后自动弹出相关提醒(需开启相应环境变量)[^2]。 对于希望回馈社区的企业和个人来说,这是一种非常便捷的方法去识别哪些重要的基础组件值得额外的投资关注。 另外值得注意的是,默认情况下这些通知不会强制中断正常的流程也不会增加任何负担给使用者;它们仅仅作为一个友好的建议存在而已[^3]。 最后提到一点关于全球范围内的影响:由于JavaScript以及围绕它的各种技术和框架变得越来越流行(比如前面提及过的Vue.js),越来越多的人参与到这个充满活力的大熔炉当中来共同创造价值——无论是技术层面还是经济层面上都如此[^4]。 ```bash # 示例展示如何检查是否有可用的资金支持机会 $ npm fund ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值