- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
对于我在 Atmel SAM4E16C 上的嵌入式应用程序,我需要在 .hex 文件的末尾放置一个包含固件信息的数组。我正在使用带有 GCC 的 Atmel Studio 7。
我已经为 Atmega168PB 完成了此操作,但不知何故它不适用于该项目。
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm)
SEARCH_DIR(.)
/* Memory Spaces Definitions */
MEMORY
{
rom (rx) : ORIGIN = 0x00420000, LENGTH = 0x000E0000 /* changed to leave space for 128KB Bootloader -> was ORIGIN = 0x00400000, LENGTH = 0x00100000 */
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00020000
}
/* The stack size used by the application. NOTE: you need to adjust according to your application. */
__stack_size__ = DEFINED(__stack_size__) ? __stack_size__ : 0x3000;
__ram_end__ = ORIGIN(ram) + LENGTH(ram) - 4;
/* Firmware Info - 8 Bytes long at the end of ROM */
__FWInfo_start__ = ORIGIN(rom) + LENGTH(rom) - 8;
SECTIONS
{
.text :
{
. = ALIGN(4);
_sfixed = .;
KEEP(*(.vectors .vectors.*))
*(.text .text.* .gnu.linkonce.t.*)
*(.glue_7t) *(.glue_7)
*(.rodata .rodata* .gnu.linkonce.r.*)
*(.ARM.extab* .gnu.linkonce.armextab.*)
/* Support C constructors, and C destructors in both user code
and the C library. This also provides support for C++ code. */
. = ALIGN(4);
KEEP(*(.init))
. = ALIGN(4);
__preinit_array_start = .;
KEEP (*(.preinit_array))
__preinit_array_end = .;
. = ALIGN(4);
__init_array_start = .;
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array))
__init_array_end = .;
. = ALIGN(0x4);
KEEP (*crtbegin.o(.ctors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*crtend.o(.ctors))
. = ALIGN(4);
KEEP(*(.fini))
. = ALIGN(4);
__fini_array_start = .;
KEEP (*(.fini_array))
KEEP (*(SORT(.fini_array.*)))
__fini_array_end = .;
KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*crtend.o(.dtors))
. = ALIGN(4);
_efixed = .; /* End of text section */
} > rom
/* .ARM.exidx is sorted, so has to go in its own output section. */
PROVIDE_HIDDEN (__exidx_start = .);
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
} > rom
PROVIDE_HIDDEN (__exidx_end = .);
. = ALIGN(4);
_etext = .;
.relocate : AT (_etext)
{
. = ALIGN(4);
_srelocate = .;
*(.ramfunc .ramfunc.*);
*(.data .data.*);
. = ALIGN(4);
_erelocate = .;
} > ram
/* .bss section which is used for uninitialized data */
.bss (NOLOAD) :
{
. = ALIGN(4);
_sbss = . ;
_szero = .;
*(.bss .bss.*)
*(COMMON)
. = ALIGN(4);
_ebss = . ;
_ezero = .;
} > ram
/* stack section */
.stack (NOLOAD):
{
. = ALIGN(8);
_sstack = .;
. = . + __stack_size__;
. = ALIGN(8);
_estack = .;
} > ram
. = ALIGN(4);
_end = . ;
/* 8 Byte Firmware Info Section */
.FWInfo : AT (__FWInfo_start__)
{
*(.FWInfo)
} > rom
}
这是我正在使用的链接描述文件。我添加了 __FWInfo_start__ 和 .FWInfo 部分。
在我的应用程序中,我尝试使用属性部分 .FWInfo 定义固件信息 block ,但我无法在我的 .hex 文件中找到数据。
#define SIZE_OF_FWINFO 8
const uint8_t nFirmwareInfoBlock[SIZE_OF_FWINFO] __attribute__((section(".FWInfo"))) = {
0xff, // reserved for future
0xff, // reserved for future
DEVICE_TYPE, // DeviceType
BUILD_NR, // BuildNr of Firmware
VERSION_MINOR, // VersionMinor of Firmware
VERSION_MAJOR, // VersionMajor of Firmware
0xFF, // Checksum
0xFF // Checksum
};
我希望有人能帮助我解决为什么这行不通的问题。提前致谢。
编辑:这是 .map 文件中的条目:
.data 0x00000000 0x0 src/main.o
.FWInfo 0x00000000 0x8 src/main.o
.debug_macro 0x00000000 0x8b0 src/main.o
和..
*fill* 0x200133b0 0x3000
0x200163b0 . = ALIGN (0x8)
0x200163b0 _estack = .
0x200163b0 . = ALIGN (0x4)
0x200163b0 _end = .
.FWInfo
*(.FWInfo)
OUTPUT(Dali4Net.elf elf32-littlearm)
据我从第二个 block 的上下文中读取,应该在 .FWInfo 或之后写入一个地址?
最佳答案
来自 GCC variable attribute documentation :
used
This attribute, attached to a variable with static storage, means that the variable must be emitted even if it appears that the variable is not referenced.
因此,为了防止链接器删除未使用的数据,请使用:
const uint8_t nFirmwareInfoBlock[SIZE_OF_FWINFO]
__attribute__((used,section(".FWInfo"))) =
{ ... } ;
另一种但可能不太吸引人的解决方案是声明数组 volatile
然后执行虚拟读取即:
const uint8_t nFirmwareInfoBlock[SIZE_OF_FWINFO]
__attribute__((section(".FWInfo"))) =
{ ... } ;
int main()
{
uint8_t dummy = nFirmwareInfoBlock[0] ;
...
}
第三种方法是完全避免工具链依赖并使用优秀但有些神秘的 SRecord作为 构建后 操作将数据直接修补到 hex 文件的实用程序。这具有独立于工具链的优势,但您可能需要一个步骤来生成要修补的数据,但为此编写一个生成器可能很简单。
关于c++ - 将数组写入 .hex 文件中的特定闪存位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40768934/
你好,我是 SMARTRF-05EB - 评估板的新手,我已经在 Linux 虚拟机中安装了 SDCC 和 Contiki-2.6。我能够构建此目录 contiki-2.6/contiki/examp
下面的简单代码会产生奇怪的输出: #include #include #include "/tmp/sha.h" #define DIGEST 64 //taken from coreutils
我不知道为什么 Hex 函数返回一个像 '0x41' 而不是 0x41 的字符串 我需要将 ASCII 值转换为十六进制。但我想要 0x INT 格式,而不是 '0x' 字符串。 ascii = 36
所以我试图从十六进制文件中读取,修改十六进制值,将新的十六进制值写入新文件。然后打开新文件,再次修改十六进制并重写到第三个文件。我正在对十六进制值进行非常简单的加密。 我用来阅读的函数是休闲的: ve
是否有一种惯用的方式将 Clojure 中的字符串编码和解码为十六进制?来自 Python 的示例: 'Clojure'.encode('hex') # ⇒ '436c6f6a757265' '436
下面的函数可以完美地将字符串转换为十六进制: function String2Hex(const Buffer: AnsiString): string; begin SetLength(Resu
我要做的是将 double 字符串转换为十六进制字符串,然后再转换回 double 。 以下代码将 double 字符串转换为十六进制字符串。 char * double2HexString(doub
我正在尝试将整数转换为十六进制。我找到了解决此问题的答案,例如 this ,尽管它们对我不起作用。我的意思是: 如果我拿这个: buf = "" buf += "\xda\xc7\xd9\x74\x
许多在线示例将哈希显示为十六进制表示,它们通常是自定义实现。改用 Apache Commons Base64 编码有什么问题或安全性降低吗?在阅读有关编码的内容时,通常是在如何将二进制表示为 XML
我需要存储这种类型的值 0xff0000或 0x00ff08 (十六进制颜色表示)在solidity智能合约中,并且能够在合约内将其转换为具有相同文本字符的字符串"ff0000" .我打算在 RSK
如果我有两种颜色: #ffcc00 和#334455 我如何获得这两种颜色之间的所有#hex 颜色,并逐渐排序? 最佳答案 你可以试试这个工具: http://www.colorhexa.com/ff
我的命令输出类似于 0x53 0x48 0x41 0x53 0x48 0x49。现在我需要将其存储在十六进制值中,然后将其转换为 ASCII 作为 SHASHI。 我试过的- 我尝试将十六进制值存储为
我正在使用计算 16 位 CRC 校验和的函数。 该函数生成一个包含校验和的 LONG(以 10 为基数的数字格式)。当然,这可以以十六进制等效形式打印到控制台,如下所示: printf("Check
我有一些以 INTEGER 形式提供给我的数字数据。我将它与其他数据一起插入到 SQLite 中,但当我将其写出时 INTEGER 数字需要为 8 位 Hex 数字,前导零。 例如 输入 400 80
在尝试附加数据对象转换为十六进制值后,我有如下代码,但它给了我以下错误: Unexpectedly found nil while unwrapping an Optional value let n
我有三个程序。程序A的代码如下: #include "stdafx.h" #include #include #include using namespace std; int _tmain(
我得到了这段代码,它从十六进制转换为 base64,反之亦然。我从另一个 SO 问题中得到了 to_base64,然后我通过一些猜测和反复试验编写了 to_hex。 class String de
我有一些关于控制建筑物访问的磁卡的信息,并且需要对软件在卡上存储数据的方式进行逆向工程,以制作具有更多功能的东西。 (我们已经和原来的程序员失去了联系。) 我不知道如何编写订单;我不是磁卡专家。 我知
我想在我拥有的 HEX 文件中找到模式并按出现次数对它们进行排序。 我不是在寻找某种特定的模式,只是为了对那里发生的事件进行一些统计并对其进行排序。 DB0DDAEEDAF7DAF5DB1FDB1DD
我在出示卡片时从 RFID 阅读器接收字节,但我无法弄清楚如何从这些字节中获取卡 ID。 例如,我有一张卡片,上面印有这些数字: 0007625328 116,23152 .我希望这是那张卡的 ID,
我是一名优秀的程序员,十分优秀!