Crate rp_binary_info
source ·Expand description
Code and types for creating Picotool compatible “Binary Info” metadata
§Example usage
Enable the Cargo feature binary-info
.
Add this to your linker script (usually named 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;
Then, add this to your Rust code:
#[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 features
The binary-info
Cargo feature enables emitting the main PICOTOOL_HEADER
static, which is what Picotool looks for to discover the binary info.
It is optional to allow you to emit the static yourself differently, for e.g. compatibility with different linker scripts, while still allowing using the rest of the utilities in the crate to format the info.
Modules§
- Constants for binary info
Macros§
- Generate a static item containing the given environment variable, and return its
EntryAddr
. - Generate a static item containing the given string, and return its
EntryAddr
. - Generate a static item containing the
CARGO_PKG_VERSION
as the program version, and return itsEntryAddr
. - Generate a static item containing the specific board this program runs on, and return its
EntryAddr
. - Generate a static item containing whether this is a debug or a release build, and return its
EntryAddr
. - Generate a static item containing the program description, and return its
EntryAddr
. - Generate a static item containing the program name, and return its
EntryAddr
. - Generate a static item containing the program url, and return its
EntryAddr
. - Generate a static item containing the program version, and return its
EntryAddr
. - Generate a static item containing the given string, and return its
EntryAddr
.
Structs§
- This is a reference to an entry. It’s like a
&dyn
ref to some typeT: Entry
, except that the run-time type information is encoded into the Entry itself in very specific way. - This is the ‘Binary Info’ header block that
picotool
looks for in your UF2 file/ELF file/Pico in Bootloader Mode to give you useful metadata about your program. - An entry which contains both an ID (e.g.
ID_RP_BINARY_END
) and an integer. - Allows us to tell picotool where values are in the UF2 given their run-time address.
- An entry which contains both an ID (e.g.
ID_RP_PROGRAM_NAME
) and a pointer to a null-terminated string.
Enums§
- This is the set of data types that
picotool
supports.
Statics§
- This tells picotool how to convert RAM addresses back into Flash addresses
Functions§
- Create a tag from two ASCII letters.
- Create a ‘Binary Info’ with the size of the binary
- Create a ‘Binary Info’ with which
boot2
image this program uses - Create a ‘Binary Info’ with which board this program targets
- Create a ‘Binary Info’ with some whether this was a Debug or Release build
- Create a ‘Binary Info’ with the program build date
- Create a ‘Binary Info’ with a description of the program
- Create a ‘Binary Info’ with some feature of the program
- Create a ‘Binary Info’ entry containing the program name
- Create a ‘Binary Info’ entry with a URL
- Create a ‘Binary Info’ entry containing the program version.
- Create a ‘Binary Info’ with the Pico SDK version used