Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

soc: arm: rpi_pico: Add basic support for binary info feature #54290

Draft
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

soburi
Copy link
Member

@soburi soburi commented Feb 1, 2023

Enable embedding binary info to flash.
As a default, information collects from the build configuration.

It can override by the Kconfig configurations, such as

CONFIG_RP2_BINARY_INFO_PROGRAM_NAME_OVERRIDE=y
CONFIG_RP2_BINARY_INFO_PROGRAM_NAME="my program name"

Signed-off-by: TOKITA Hiroshi [email protected]


This PR support basic feature of pico's binary info.
It works with picotool (https://github.com/raspberrypi/picotool) to show configuration information.
(by picotool show -a)
Other feature supporting is not yet.

@soburi soburi requested review from nashif and yonsch as code owners February 1, 2023 03:59
@soburi soburi force-pushed the pico_binary_info branch 3 times, most recently from 463304d to 93e30d2 Compare February 1, 2023 04:55
@soburi soburi changed the title soc: arm: rpi_pico: Add basic support for binary info feature soc: arm: rpi_pico: Add basic support for binary info feature Feb 1, 2023
@soburi soburi force-pushed the pico_binary_info branch 2 times, most recently from cdbad46 to 71495bb Compare February 1, 2023 09:26
@soburi soburi added the platform: Raspberry Pi Pico Raspberry Pi Pico (RPi Pico) label Feb 1, 2023
Copy link
Contributor

@mbolivar-nordic mbolivar-nordic left a comment

Choose a reason for hiding this comment

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

Thank you for your work!

I am not sure about the CMake variable changes here. I'd like @tejlmand to confirm it is OK.

soc/arm/rpi_pico/rp2/binary_info.c Outdated Show resolved Hide resolved
@yonsch
Copy link
Contributor

yonsch commented Feb 2, 2023

Before I comment on the changes themselves - I think this feature would be beneficial for all Zephyr users, not only for the pico. Being able to embed strings in a binary where they're accessable outside of the image is very useful. The main use case I can think of is a bootloader and an app being able to read each other's versions. Since this would require some more work I'm not sure it should block this PR for the meantime, but that is something to keep in mind.
I should also note that pico's binary_info can be used to store pin configurations, but I can't think of a use case for that.

@soburi soburi force-pushed the pico_binary_info branch 2 times, most recently from d0736a3 to 480ff02 Compare February 2, 2023 09:31
@soburi
Copy link
Member Author

soburi commented Feb 4, 2023

@yonsch

Before I comment on the changes themselves - I think this feature would be beneficial for all Zephyr users, not only for the pico. Being able to embed strings in a binary where they're accessable outside of the image is very useful. The main use case I can think of is a bootloader and an app being able to read each other's versions. Since this would require some more work I'm not sure it should block this PR for the meantime, but that is something to keep in mind. I should also note that pico's binary_info can be used to store pin configurations, but I can't think of a use case for that.

The 'self-reference'-ish feature is interresting suggestion.
But I also think there are some difficult point.
In the Pico's scope, the information mainly read it by BOOTSEL mode.
This is probably the same for other MCUs, and I think this function is strongly related to the "recovery mode" specification.
If there are other MCUs with similar functions, it may be possible to define an abstract interface.
If I can draw a big picture, I think it would wonderful if it could define as uf2 meta information. (Create a .uf2meta section with a linker and have the same information there. It can handle with common specification by recovery program and firmware itself!)

@yonsch
Copy link
Contributor

yonsch commented Feb 5, 2023

@soburi I've created a quick demonstration of what I was thinking of: #54464

@MaureenHelm
Copy link
Member

dev-review: depends on #54464

@github-actions
Copy link

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions
Copy link

github-actions bot commented Aug 2, 2023

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Aug 2, 2023
@cfriedt
Copy link
Member

cfriedt commented Aug 3, 2023

@soburi - I assume that once #54464 is merged, work on this will continue

@soburi
Copy link
Member Author

soburi commented Aug 3, 2023

@cfriedt

I assume that once #54464 is merged, work on this will continue

That's right. Perhaps I will have to rethink the design accordingly.

@github-actions github-actions bot removed the Stale label Aug 4, 2023
@yonsch
Copy link
Contributor

yonsch commented Aug 4, 2023

@soburi Why does this depend on #54464?
Bindesc was supposed to be a standard Zephyr replacement for binary info.
Binary info would still be useful for someone who needs to specifically use the pico format, e.g. if a bootloader expects binary info descriptors.
I think we can treat them as if they are mutually exclusive, as they serve the same purpose, and proceed with this PR regardless of bindesc.
Unless, you somehow see them coexisting somehow, which would require more planning.

@zephyrbot zephyrbot added the DNM This PR should not be merged (Do Not Merge) label Sep 25, 2024
soburi and others added 25 commits October 4, 2024 23:29
Update RaspberryPi Pico hal to 2.0.0 release

Signed-off-by: TOKITA Hiroshi <[email protected]>
The directory structure has changed in 2.0.0,
so we update it accordingly.

Signed-off-by: TOKITA Hiroshi <[email protected]>
Following the GPIO interface changes in pico-sdk 2.0.0.

Signed-off-by: TOKITA Hiroshi <[email protected]>
Some symbol names have been conflicted with introducing pico-sdk 2.0.0.
Rename these.

Signed-off-by: TOKITA Hiroshi <[email protected]>
Follow the wider directory convention of dts/<arch>/<vendor>/<family>.

This is foundation work ahead of introducing support for the RP2350.

Signed-off-by: Andrew Featherstone <[email protected]>
Rename rpi_pico_common.dtsi to rp2040_reset.h . This is more consistent
with the wider Zephyr source tree, and is foundation work ahead of
introducing the RP2350 SoC.

Signed-off-by: Andrew Featherstone <[email protected]>
RESETS_RESET_PLL_USB_BITS was logically or'd twice and 'unreset'ting
PWM doesn't seem to be required, based on the contents of the SDK.

Signed-off-by: Andrew Featherstone <[email protected]>
No in-tree board uses this driver's pinctrl functionality, and every
RP2040-based board was configuring this to be an empty node in the
device tree, so remove them.

Signed-off-by: Andrew Featherstone <[email protected]>
RP2350 is Raspberry Pi's newest SoC. From the datasheet:

"RP2350 is a new family of microcontrollers from Raspberry Pi that
offers significant enhancements over RP2040. Key features include:
• Dual Cortex-M33 or Hazard3 processors at 150 MHz
• 520 kB on-chip SRAM, in 10 independent banks
• 8 kB of one-time-programmable storage (OTP)
• Up to 16 MB of external QSPI flash/PSRAM via dedicated QSPI bus
...
"

This commit introduces some changes to support the existing RP2040 and
what is describe by Raspberry Pi as the "RP2350 family". Currently there
are 4 published products in the family: RP2350A, RP2350B, RP2354A, and
RP2354A. Within Zephyr's taxonomy, split the configuration as follows:
Family: Raspberry Pi Pico. This contains all RP2XXX SoCs,
SoC Series: RP2040 and RP2350.
SoC: RP2040 and, for now, just the RP2350A, which is present on the Pico
2, where the A suffix indicates  QFN-60 package type. This structure is
reflected in `soc/raspberrypi/soc.yml`, and somewhat assumes that there
won't be a RP2050, for example, as a RP2040 with more RAM.

This is foundation work ahead of introducing support for Raspberry Pi's
Pico 2 board, which is fitted with a RP2350A and 4MB of flash.

Signed-off-by: Andrew Featherstone <[email protected]>
Add support for SoC-specific clock ids and update the initialization
function to support the existing RP2040 and add support for the RP2350.

clock_control_rpi_pico.c uses numerical values for clock ids taken from
rpi_pico_clock.h which are the "clock generator". For the RP2350 these
values are different for some of the same logical clock sources, as well
as the RP2040 and RP2350 having different clock sources available.

Signed-off-by: Andrew Featherstone <[email protected]>
Extend the existing driver to add some initial support for the new SoC,
whilst maintaining compatibility with the RP2040.

Signed-off-by: Andrew Featherstone <[email protected]>
Unlike the RP2040, the RP2350 has multiple tick generators that need to
be started. Start TIMER0 and TIMER1 tick generators during
clock_control_init.

Signed-off-by: Andrew Featherstone <[email protected]>
The watchdog register configuration of RP2350 differs from that
of RP2040, so we make fit that.

Signed-off-by: TOKITA Hiroshi <[email protected]>
Signed-off-by: Andrew Featherstone <[email protected]>
The RP2350 SoC series contain two timer peripherals. Extend the driver
to support using the second timer (`TIMER1`).

N.b. this requires a fix from the Pico SDK to be patched into
hal_rpi_pico. See raspberrypi/pico-sdk#1949 .

Signed-off-by: Andrew Featherstone <[email protected]>
A significant amount of the pin muxing is duplicated between the RP2040,
the RP2350A, and RP2350B. Reflect this in the file structure, with a
`-common` suffix used to to indicate this.

Macros are defined in ascending order of the function index in the
relevant table in the datasheet. SoC/SoC-series specific macros are
defined in their respective tables. Functions that are not currently
used (e.g. the new HSTX) are intentionally not defined here as they do
not (currently) have any use in the Zephyr tree (i.e. there's no drivers
that make use of this functionality).

clang-format has been run over the existing definitions to reduce the
noise generated by CI. These are cosmetic changes; I've tried to retain
attribution to the relevant authors where applicable.

Signed-off-by: Andrew Featherstone <[email protected]>
The Raspberry Pi Pico 2 is Raspberry Pi's first board fitted with their
RP2350A SoC.

This adds a minimal board definition, sufficient to build and run
`samples/hello_world` and `samples/basic/blinky` on the board. Images
can be run on the target using OpenOCD. Raspberry Pi's `picotool` can
create a UF2 binary, which ensures that errata RP2350-E10 is avoided
e.g.

```
> picotool uf2 convert build\rpi_pico2\hello_world\zephyr\zephyr.elf \
    build\rpi_pico2\hello_world\zephyr\zephyr.uf2 \
    --family rp2350-arm-s --abs-block`
```

Raspberry Pi Pico 2 is a low-cost, high-performance microcontroller
board with flexible digital interfaces. Key features include:

- RP2350A microcontroller chip designed by Raspberry Pi in the United
  Kingdom
- Dual Cortex-M33 or Hazard3 processors at up to 150MHz
- 520KB of SRAM, and 4MB of on-board flash memory
- USB 1.1 with device and host support
- Low-power sleep and dormant modes
- Drag-and-drop programming using mass storage over USB
- 26x multi-function GPIO pins including 3 that can be used for ADC
- 2x SPI, 2x I2C, 2x UART, 3x 12-bit 500ksps Analogue to Digital
  Converter (ADC), 24x controllable PWM channels
- 2x Timer with 4 alarms, 1x AON Timer
- Temperature sensor
- 3x Programmable IO (PIO) blocks, 12 state machines total for custom
  peripheral support
    - Flexible, user-programmable high-speed IO
    - Can emulate interfaces such as SD Card and VGA

The Raspberry Pi Pico 2 comes as a castellated module which allows
soldering direct to carrier boards.

Signed-off-by: Andrew Featherstone <[email protected]>
Add UF2 Family ID for Raspberry Pi 2350 and build
UF2 image by default for Pico 2 board

Signed-off-by: Ryan Grachek <[email protected]>
Signed-off-by: Andrew Featherstone <[email protected]>
The Raspberry Pi Pico 2's device is compatible with the existing Pico 1.
The build system requires a `<board>.overlay` file, but these use the
pre-processing to #include the sibling rpi_pico.overlay files rather
than duplicating the contents as an attempt to keep things DRY.

Tested locally.

Signed-off-by: Andrew Featherstone <[email protected]>
For these tests' needs, the RP2350 on the Pico 2 is compatible with the
RP2040 on the Pico 1. #include the latter's overlay in preference to
duplicating the content.

Signed-off-by: Andrew Featherstone <[email protected]>
…ico 2

Only enable timer 0 for testing. Timer 1 won't work correctly until the
rpi_pico HAL has picked up the fix for `hardware_alarm_irq_handler`. See
raspberrypi/pico-sdk#1949 .

Signed-off-by: Andrew Featherstone <[email protected]>
Add some documentation for the board itself (mostly aiming to refer to
canonical sources of information rather duplicate). Add entries in the
release notes where applicable.

boards/raspberrypi/rpi_pico2/doc/img/pico-2.jpg is a cropped and
compressed version of https://www.raspberrypi.com/documentation/microcontrollers/images/pico-2.png
which is released under the CC-BY-SA-4.0 license. See https://github.com/raspberrypi/documentation/blob/develop/LICENSE.md

Signed-off-by: Andrew Featherstone <[email protected]>
Add OpenOCD debugger support.
For now we will need a RaspberryPi forked version of OpenOCD.

https://github.com/raspberrypi/openocd

Signed-off-by: TOKITA Hiroshi <[email protected]>
Signed-off-by: Andrew Featherstone <[email protected]>
- Remove redundant `transport select swd`. This is already done in
  `interface/rp2350.cfg`
- Set the adapter speed to match Raspberry Pi's documentation.

Signed-off-by: Andrew Featherstone <[email protected]>
Extend gpio_api_1pin so that tests can require a test fixture to provide
an external pulldown resistor to the board under test. Use the new
test-gpio-external-pulldown device tree binding to define where that
GPIO is, and, finally, add a device tree overlay for the Raspberry Pi
Pico 2 board that defines where the pulldown provided by the fixture
will be.

Tested locally using `--fixture gpio_external_pull_down` when running
Twister on the command line, or by creating and using a Hardware Map
file, in combination with a modified Pico 2.

Signed-off-by: Andrew Featherstone <[email protected]>
Enable embedding binary info to flash.
As a default, information collects from the build configuration.

It can override by the Kconfig configurations, such as

```
CONFIG_RP2_BINARY_INFO_PROGRAM_NAME_OVERRIDE=y
CONFIG_RP2_BINARY_INFO_PROGRAM_NAME="my program name"
```

Signed-off-by: TOKITA Hiroshi <[email protected]>
Copy link

github-actions bot commented Dec 6, 2024

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DNM This PR should not be merged (Do Not Merge) manifest manifest-hal_rpi_pico platform: Raspberry Pi Pico Raspberry Pi Pico (RPi Pico) Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants