#define bi_program_url(url) bi_string(BINARY_INFO_TAG_RASPBERRY_PI, BINARY_INFO_ID_RP_PROGRAM_URL,
url)
You then either use bi_decl(bi_blah(…)) for unconditional inclusion of the binary info blah, or
bi_decl_if_func_used(bi_blah(…)) for binary information that may be stripped if the enclosing function is not included in
the binary by the linker (think
--gc-sections).
For example,
Ê1 #include <stdio.h>
Ê2 #include "pico/stdlib.h"
Ê3 #include "hardware/gpio.h"
Ê4 #include "pico/binary_info.h"
Ê5
Ê6
const uint LED_PIN = 25;
Ê7
Ê8
int main() {
Ê9
10 bi_decl(bi_program_description(
"This is a test binary."));
11 bi_decl(bi_1pin_with_name(LED_PIN,
"On-board LED"));
12
13 setup_default_uart();
14 gpio_set_function(LED_PIN, GPIO_FUNC_PROC);
15 gpio_set_dir(LED_PIN, GPIO_OUT);
16
while (1) {
17 gpio_put(LED_PIN,
0);
18 sleep_ms(
250);
19 gpio_put(LED_PIN,
1);
20 puts(
"Hello World\n");
21 sleep_ms(
1000);
22 }
23 }
when queried with
picotool,
$ sudo picotool info -a test.uf2
File test.uf2:
Program Information
Êname: test
Êdescription: This is a test binary.
Êfeatures: stdout to UART
Êbinary start: 0x10000000
Êbinary end: 0x100031f8
Fixed Pin Information
Ê0: UART0 TX
Ê1: UART0 RX
Ê25: On-board LED
Build Information
Êbuild date: Jan 4 2021
shows our information strings in the output.
Getting started with Raspberry Pi Pico
Binary Information 72