我已经更新了我的arm-none-eabi GCC 和相关工具,并重建了我开发的嵌入式项目。
$ arm-none-eabi-ld --version
GNU ld (GNU Binutils) 2.39
Run Code Online (Sandbox Code Playgroud)
突然,我收到警告
/usr/lib/gcc/arm-none-eabi/12.1.0/../../../../arm-none-eabi/bin/ld: warning: my_elf_file.elf has a LOAD segment with RWX permissions。
这个警告似乎是新引入的。我最近没有更改源/链接描述文件。(编辑:我检查了使用先前版本创建的旧 ELF 文件。它在链接过程中没有打印警告,但有相同的问题)。我为 STM32F407 微控制器进行开发。我的链接器脚本中的内存配置如下:
MEMORY
{
FLASH (xr) : ORIGIN = 0x08000000, LENGTH = 512K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
CCM (rw) : ORIGIN = 0x10000000, LENGTH = 64K
}
Run Code Online (Sandbox Code Playgroud)
查看链接的 ELF 我看到:
$ readelf -l my_elf_file.elf
Elf file type is EXEC (Executable file)
Entry point 0x800b1f1
There are 5 program headers, …Run Code Online (Sandbox Code Playgroud) 我在使用嵌入式arm gcc编译器的链接器时遇到了问题,我在网上找到了一个教程,说我可以通过arm-none-eabi-gcc包含参数来修复我的链接器错误-specs=nosys.specs,这对我有用,并且它能够编译我的代码。
我的芯片是 ATSAM7SE256 微控制器,据我了解,它是一个arm7tdmi使用armv4t和thumb指令集的处理器,我一直在使用以下代码编译我的代码:
arm-none-eabi-gcc -march=armv4t -mtune=arm7tdmi -specs=nosys.specs -o <exe_name>.elf <input_files>
Run Code Online (Sandbox Code Playgroud)
代码编译没有问题,但我不知道它是否做了我认为它正在做的事情。
规格文件的意义是什么?您还可以使用 来设置哪些其他值-specs=,以及在什么情况下您希望这样做?nosys.specs我想要的完全嵌入式 Arm 微控制器的价值是什么?
我编写了“轻量级”时间库,并且有如下所示的 struct 和 typedef:
struct tmt {
uint16_t year;
uint8_t month;
uint8_t day;
uint8_t hour;
uint8_t minute;
uint8_t second;
uint8_t weekday;
uint8_t is_dst;
};
typedef struct tmt tm_t;
Run Code Online (Sandbox Code Playgroud)
我有一个返回的函数tm_t:
tm_t rtc_get_current_time(void){
tm_t tm;
xSemaphoreTake(rtc_mutex, RTC_MUTEX_MAX_WAIT);
tm = rtc.current_time;
xSemaphoreGive(rtc_mutex);
return tm;
}
Run Code Online (Sandbox Code Playgroud)
我想这样使用它:
tm_t s;
s = rtc_get_current_time(); // error is here
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
从类型“int”分配给类型“tm_t”{aka“struct tmt”}时不兼容的类型
我也尝试过像这样更改函数和变量:
struct tmt rtc_get_current_time(void){
tm_t tm;
xSemaphoreTake(rtc_mutex, RTC_MUTEX_MAX_WAIT);
tm = rtc.current_time;
xSemaphoreGive(rtc_mutex);
return tm;
}
struct tmt tm = rtc_get_current_time();
Run Code Online (Sandbox Code Playgroud)
我做错了什么?