Skip to content

Conversation

@MarkSwanson
Copy link

@MarkSwanson MarkSwanson commented Sep 16, 2025

I submitted this to be used as a reference to save someone some time for when they decide to do a full implementation.

pub static PICOTOOL_ENTRIES: [rp_binary_info::EntryAddr; 2] = [
rp_binary_info::pins_with_function!(
PICO_DEFAULT_I2C_SDA_PIN,
PICO_DEFAULT_I2C_SCL_PIN,
GPIO_FUNC_I2C),

rp_binary_info::pin_with_name!(
    25, // pin 25 is the LED
    c"The LED"
),

];

$ picotool info -a ./m.bin
Fixed Pin Information
4: I2C0 SDA
5: I2C0 SCL
25: The LED

I found constants in these places:
pico-sdk/src/boards/include/boards/pico2_w.h
pico-sdk/src/common/pico_binary_info/include/pico/binary_info/structure.h pico-sdk/src/rp2350/hardware_structs/include/hardware/structs/io_bank0.h

pub static PICOTOOL_ENTRIES: [rp_binary_info::EntryAddr; 7] = [
    rp_binary_info::pins_with_function!(
            PICO_DEFAULT_I2C_SDA_PIN,
            PICO_DEFAULT_I2C_SCL_PIN,
            GPIO_FUNC_I2C),

    rp_binary_info::pin_with_name!(
        25, // pin 25 is the LED
        c"The LED"
    ),
];

I found constants in these places:
pico-sdk/src/boards/include/boards/pico2_w.h
pico-sdk/src/common/pico_binary_info/include/pico/binary_info/structure.h
pico-sdk/src/rp2350/hardware_structs/include/hardware/structs/io_bank0.h
@thejpster
Copy link
Member

Can you reformat and squash?

data_type: DataType::PinsWithFunction,
tag: TAG_RASPBERRY_PI,
},
pin_encoding: BI_PINS_ENCODING_MULTI
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's worth noting that this is a value with multiple fields, and raspberry pi seem to indicate that there are no more pins by setting two consecutive fields to the same value.

You could also consider using bitbybit::bitfield to describe this 32-bit value, and avoid needing to do a bunch of shifts using magic numbers. I have examples you can refer to

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could then change this to take a slice of pins, rather than only two pins.

/// GPIO pins, with their function
PinsWithFunction = 8,
/// GPIO pins, with their name
/// GPIO pins, with their name pico-sdk: BINARY_INFO_TYPE_PINS_WITH_NAME
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// GPIO pins, with their name pico-sdk: BINARY_INFO_TYPE_PINS_WITH_NAME
/// GPIO pins, with their name
///
/// The Pico SDK calls this `BINARY_INFO_TYPE_PINS_WITH_NAME`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants