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§
- consts
- Constants for binary info
Macros§
- env
- Generate a static item containing the given environment variable,
and return its
EntryAddr
. - int
- Generate a static item containing the given string, and return its
EntryAddr
. - rp_
cargo_ bin_ name - Generate a static item containing the
CARGO_BIN_NAME
as the program name, and return itsEntryAddr
. - rp_
cargo_ homepage_ url - Generate a static item containing the
CARGO_PKG_HOMEPAGE
as the program URL, and return itsEntryAddr
. - rp_
cargo_ version - Generate a static item containing the
CARGO_PKG_VERSION
as the program version, and return itsEntryAddr
. - rp_
pico_ board - Generate a static item containing the specific board this program runs on,
and return its
EntryAddr
. - rp_
program_ build_ attribute - Generate a static item containing whether this is a debug or a release
build, and return its
EntryAddr
. - rp_
program_ description - Generate a static item containing the program description, and return its
EntryAddr
. - rp_
program_ name - Generate a static item containing the program name, and return its
EntryAddr
. - rp_
program_ url - Generate a static item containing the program URL, and return its
EntryAddr
. - rp_
program_ version - Generate a static item containing the program version, and return its
EntryAddr
. - str
- Generate a static item containing the given string, and return its
EntryAddr
.
Structs§
- Entry
Addr - 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. - Header
- 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. - Integer
Entry - An entry which contains both an ID (e.g.
ID_RP_BINARY_END
) and an integer. - Mapping
Table Entry - Allows us to tell picotool where values are in the UF2 given their run-time address.
- String
Entry - An entry which contains both an ID (e.g.
ID_RP_PROGRAM_NAME
) and a pointer to a null-terminated string.
Enums§
- Data
Type - This is the set of data types that
picotool
supports.
Statics§
- MAPPING_
TABLE - This tells picotool how to convert RAM addresses back into Flash addresses
Functions§
- make_
tag - Create a tag from two ASCII letters.
- rp_
binary_ end - Create a ‘Binary Info’ with the size of the binary
- rp_
boot2_ name - Create a ‘Binary Info’ with which
boot2
image this program uses - rp_
pico_ board - Create a ‘Binary Info’ with which board this program targets
- rp_
program_ build_ attribute - Create a ‘Binary Info’ with some whether this was a Debug or Release build
- rp_
program_ build_ date_ string - Create a ‘Binary Info’ with the program build date
- rp_
program_ description - Create a ‘Binary Info’ with a description of the program
- rp_
program_ feature - Create a ‘Binary Info’ with some feature of the program
- rp_
program_ name - Create a ‘Binary Info’ entry containing the program name
- rp_
program_ url - Create a ‘Binary Info’ entry with a URL
- rp_
program_ version - Create a ‘Binary Info’ entry containing the program version.
- rp_
sdk_ version - Create a ‘Binary Info’ with the Pico SDK version used