#raspberry-pi #rp2040 #no-alloc #picotool #rp2350

无std rp-binary-info

为创建与Picotool兼容的Binary Info元数据提供代码和类型

1个不稳定版本

新版本 0.1.0 2024年8月17日

#601 in 嵌入式开发

MIT/Apache

23KB
306

rp-binary-info

为创建Picotool兼容的"Binary Info"元数据提供代码和类型。

许可证

本存储库的内容根据MIT或Apache 2.0许可证双许可。这意味着在重新使用此代码时,您可以选择MIT许可证或Apache 2.0许可证。有关每个特定许可证的更多信息,请参阅LICENSE-MITLICENSE-APACHE。我们的Apache 2.0声明可以在NOTICE中找到。

除非您明确声明,否则您提交的任何贡献(根据Apache-2.0许可证定义),将根据上述条款双许可,不附加任何其他条款或条件。


lib.rs:

为创建与Picotool兼容的"Binary Info"元数据提供代码和类型

示例用法

启用Cargo功能binary-info

将其添加到您的链接脚本中(通常命名为memory.x

SECTIONS {
    /* ### Boot ROM info
     *
     * Goes after .vector_table, to keep it in the first 512 bytes of flash,
     * where picotool can find it
     */
    .boot_info : ALIGN(4)
    {
        KEEP(*(.boot_info));
    } > FLASH

} INSERT AFTER .vector_table;

/* move .text to start /after/ the boot info */
_stext = ADDR(.boot_info) + SIZEOF(.boot_info);

SECTIONS {
    /* ### Picotool 'Binary Info' Entries
     *
     * Picotool looks through this block (as we have pointers to it in our
     * header) to find interesting information.
     */
    .bi_entries : ALIGN(4)
    {
        /* We put this in the header */
        __bi_entries_start = .;
        /* Here are the entries */
        KEEP(*(.bi_entries));
        /* Keep this block a nice round size */
        . = ALIGN(4);
        /* We put this in the header */
        __bi_entries_end = .;
    } > FLASH
} INSERT AFTER .text;

然后,将其添加到您的Rust代码中

#[link_section = ".bi_entries"]
#[used]
pub static PICOTOOL_ENTRIES: [rp_binary_info::EntryAddr; 3] = [
    rp_binary_info::rp_program_name!(c"Program Name Here"),
    rp_binary_info::rp_cargo_version!(),
    rp_binary_info::int!(
        rp_binary_info::make_tag(b"JP"),
        0x0000_0001,
        0x12345678
    ),
];

Cargo功能

binary-info Cargo功能启用输出主PICOTOOL_HEADER静态,这是Picotool查找以发现二进制信息的内容。

这是可选的,允许您以不同的方式输出静态,例如与不同的链接脚本兼容,同时仍然可以使用该存储库中其余的实用工具格式化信息。

无运行时依赖项

功能