-
Notifications
You must be signed in to change notification settings - Fork 935
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
Add Wi-Fi firmware partition support for Pico 2 W #1969
base: develop
Are you sure you want to change the base?
Conversation
Enabled using the pico_use_partition_firmware(exe_name) cmake function
pinging @peterharperuk as he did a lot of the Wifi-related stuff for Pico 1. |
…ifi only firmware variants
@@ -104,6 +114,73 @@ static void cyw43_sleep_timeout_reached(async_context_t *context, __unused async | |||
} | |||
|
|||
bool cyw43_driver_init(async_context_t *context) { | |||
#if CYW43_USE_PARTITION_FIRMWARE | |||
const int buf_words = (16 * 4) + 1; // maximum of 16 partitions, each with maximum of 4 words returned, plus 1 | |||
uint32_t* buffer = malloc(buf_words * 4); |
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.
malloc is best avoided for Micropython (we use some for BT but we need to fix that). You could use cyw43_state as a temp buffer it's not needed yet?
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.
Should I switch this one to use cyw43_state and leave the other one with malloc, or just leave them both as malloc?
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.
Leave it as it is for now. I can't immediately spot the code in Micropython which controls the heap space we have available.
} | ||
|
||
if (picked_p >= 0) { | ||
uint32_t* workarea = malloc(0x1000); |
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.
Ah. That's too big for cyw43_state
d6121e9
to
508071f
Compare
This adds the ability to store and load the Wi-Fi firmware for Pico 2 W in a partition. It can be enabled by adding
pico_use_partition_firmware(<exe_name>)
to your CMakeLists.txt, which will embed a compatible partition table in the binary, and output lots of firmware UF2s to use (all called<exe_name>_firmware_..._.uf2
, eg..._firmware_w
for Wi-Fi only,..._firmware_wb
for Wi-Fi and Bluetooth,..._firmware_w_tbyb
for TBYB). You can also create your own partition table and use that.A Wi-Fi firmware partition is detected as having the ID
0x123456789abcdef0
, and the UF2 family_is for Wi-Fi firmware blobs is0x12345678
- these should probably both be changed to something else before merging? The default firmware partition starts at 3500K into the flash - should this be changed to depend on PICO_FLASH_SIZE_BYTES? The default firmware partition is also duplicated with A/B partitions in the same location in flash - this is required to ensure a signature check is performed before loading the Wi-Fi firmware, as there's no way to call the bootrom to check the signature of a single partition (unless chaining into it), you can only callpick_ab_partition
.The Wi-Fi firmware blob is marked in it's image_def as an RP2350 Risc-V executable, and the partition is marked as
ignored_during_riscv_boot
- this ensures that it can work with TBYB (as TBYB only works for executable image_defs), and that signature checks are performed before loading the firmware when Secure Boot is enabled (because signature checks are performed for all executable image_defs in a partition that is not markedignored_during_arm_boot
). This is slightly clunky, but seems to work robustly.Supercedes #1850, as it now includes that function in this PR, and shows a use for it.