-
Notifications
You must be signed in to change notification settings - Fork 8.2k
rpi_pico: Added flash support #47806
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
Conversation
|
@yonsch, why don't you use a write block size of 256 byte. This will limit the possibilities of using the flash but it will be correct and avoid unnecessary erases when trying to emulate 1 byte writing support. If you do wish to support 1 byte writing it should be required to read whatever is on the flash (instead of setting it to the erase value), apply the changes, and write to flash. |
|
@yonsch, is it safe to write to flash when executing from the same flash? |
dts/arm/rpi_pico/rp2040.dtsi
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove label, its no longer needed.
drivers/flash/flash_rpi_pico.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe KB(CONFIG_FLASH_SIZE)?
https://github.com/zephyrproject-rtos/zephyr/blob/main/include/zephyr/sys/util.h#L447
drivers/flash/flash_rpi_pico.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make the precedence explicit:
(offset + size) > FLASH_SIZE;
drivers/flash/flash_rpi_pico.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MISRA C:2004, 13.2 - Tests of a value against zero should be made explicit, unless the operand is effectively Boolean.
drivers/flash/flash_rpi_pico.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
drivers/flash/flash_rpi_pico.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be made into one line, the col limit is 100
drivers/flash/flash_rpi_pico.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be better to test if size > 0 as well:
MISRA C:2004, 13.2 - Tests of a value against zero should be made explicit, unless the operand is effectively Boolean.
I wanted this to be future compatible for when this feature will be available, but it turns out that the flash works with page writes, so there is no way around a write size of 256.
Yes, because the relevant functions are executed from RAM. Disabling interrupts was also added to prevent hard faults when ISRs are called during flash operations. |
85f9239 to
f36b2a9
Compare
drivers/flash/Kconfig.rpi_pico
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
depends on DT_HAS_RASPBERRYPI_PICO_FLASH_CONTROLLER_ENABLED should replace the 'depends on FLASH && SOC_SERIES_RP2XXXX`
098a647 to
d888f3c
Compare
|
Added "real" byte-aligned writes. The low level functions were taken from the SDK and bootrom, and adapted to Zephyr (functionally and stylistically). I suppose this is fine in terms of licensing (the sdk is BSD-3 Clause), but would like someone to verify this. |
@yonsch, regarding the "real" byte-aligned writes: it is strange that the write-block-size is set to the page size while the routines allow smaller writes, is this intended ? I didn't find the |
drivers/flash/flash_rpi_pico.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Write block size is given as 1 in the devicetree but as 256 here?
|
@soburi Thank you for your review. I replaced |
c298b34 to
ff5aec5
Compare
|
@soburi please approve if happy |
de-nordic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look OK. Thank you for the contribution.
Note on the PAGE_WRITE_SIZE and SECTOR_ERASE_SIZE: although I prefer the verb WRITE/ERASE within the name of the identifier, to clarify what the identifier is supposed to do rather than magic interpretation of sector as erase unit and page as write unit, I understand that this is this is how the device specification names them. If it will be desired by you or other reviewers to revert the names to original, I will approve the code anyway.
|
@yonsch, the usage of |
Add a flash driver for the rpi_pico Signed-off-by: Yonatan Schachter <[email protected]>
Add flash controller support for Raspberry Pi's RP2040 SoC Signed-off-by: Yonatan Schachter <[email protected]>
Add flash support for the rpi_pico board Signed-off-by: Yonatan Schachter <[email protected]>
Laczen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
Add support for flash read/write/erase on rpi_pico. Tested with the
flash_shellsample.Note: Writes are currently inefficient, as they are performed on a page basis. This is because
pico-sdkdoes not currently provide an API for writing smaller ranges.