Skip to content

hal_rpi_pico: flash: Move partial write support for RP2040 and add support for RP2350 #11

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

Merged
merged 1 commit into from
Jun 15, 2025

Conversation

hanan619
Copy link

Partial flash write support for RP2040 was previously implemented in Zephyr, but due to license incompatibility, it has now been moved to the hal_rpi_pico module.

This commit removes the in-tree implementation from Zephyr and integrates partial write support from hal_rpi_pico for RP2040 devices.

Additionally, partial write support has been added for the RP2350 (used in Raspberry Pi Pico W 2 and Pico 2) in hal_rpi_pico. Zephyr now correctly enables and utilizes this functionality for both RP2040 and RP2350.

@hanan619 hanan619 force-pushed the zephyr branch 11 times, most recently from ffdc8b9 to f7cde54 Compare May 28, 2025 08:12
@hanan619 hanan619 requested a review from soburi May 28, 2025 08:14
@hanan619 hanan619 force-pushed the zephyr branch 2 times, most recently from 410c418 to 5b76fb7 Compare May 28, 2025 14:41
…pport for RP2350

Partial flash write support for RP2040 was previously implemented in Zephyr,
but due to license incompatibility, it has now been moved to the hal_rpi_pico
module.

This commit removes the in-tree implementation from Zephyr and integrates
partial write support from hal_rpi_pico for RP2040 devices.

Additionally, partial write support has been added for the RP2350 (used in
Raspberry Pi Pico W 2 and Pico 2) in hal_rpi_pico. Zephyr now correctly
enables and utilizes this functionality for both RP2040 and RP2350.

Signed-off-by: Hanan Arshad <hananarshad619@gmail.com>
/**
* Low level flash functions are based on:
* github.com/raspberrypi/pico-bootrom-rp2040/blob/master/bootrom/program_flash_generic.c,
* github.com/raspberrypi/pico-bootrom-rp2350/blob/master/src/main/arm/varm_generic_flash.c
Copy link
Member

Choose a reason for hiding this comment

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

@kartben

I just want to confirm.

The code referenced here is the same BSD-3 as this code
and was created by Raspberry Pi (Trading) Ltd., the same author as the original of this code.

Since they're both BSD-3, I think this description is sufficient, but what do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is OK. There's enough willing here to show attribution.

@hanan619
Copy link
Author

hanan619 commented Jun 4, 2025

Any update on this?

@soburi soburi requested a review from kartben June 4, 2025 08:38
@hanan619
Copy link
Author

hanan619 commented Jun 5, 2025

@kartben @ajf58 @yonsch
Kindly review

#include "hardware/structs/io_qspi.h"
#if PICO_RP2040
Copy link
Member

Choose a reason for hiding this comment

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

From the perspective of source management, it is easy to maintain only add
than adding and deleting, so add

#include "hardware/structs/io_qspi.h"

under #else on line 13 without changing the position of #if PICO_RP2040.

@soburi
Copy link
Member

soburi commented Jun 13, 2025

@ajf58
Could you take a look, please?

@@ -24,6 +24,8 @@
#define FLASH_RUID_DATA_BYTES FLASH_UNIQUE_ID_SIZE_BYTES
#define FLASH_RUID_TOTAL_BYTES (1 + FLASH_RUID_DUMMY_BYTES + FLASH_RUID_DATA_BYTES)

void __no_inline_not_in_flash_func(flash_write_partial_internal)(uint32_t addr, const uint8_t *data, size_t size);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I understand that this is a direct copy from the bootrom codebase, but if the declaration is here it should be declared as static.

Copy link
Collaborator

@ajf58 ajf58 left a comment

Choose a reason for hiding this comment

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

I think this will work OK. A couple of notes:

  1. When we bump the SDK (I've been waiting on a 2.1.2, but maybe just need to make the relevant fix directly), they'll be some changes e.g. raspberrypi@7b07b0b .
  2. I wonder whether this would be better achieved using the SDK's bootrom API: e.g. rom_flash_range_program .

@soburi soburi merged commit 5a981c7 into zephyrproject-rtos:zephyr Jun 15, 2025
4 checks passed
@soburi
Copy link
Member

soburi commented Jun 16, 2025

@hanan619

I forgot to mention one thing. Please update ChangeLog.zephyr.md too.

@hanan619
Copy link
Author

@soburi This PR is merged. Should I create another PR for ChangeLog.zephyr.md?

@soburi
Copy link
Member

soburi commented Jun 16, 2025

@soburi This PR is merged. Should I create another PR for ChangeLog.zephyr.md?

Yes it is, this PR has been merged. This is can't edit any more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants