-
Notifications
You must be signed in to change notification settings - Fork 995
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enabled using the pico_use_partition_firmware(exe_name) cmake function
- Loading branch information
Showing
7 changed files
with
348 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import sys | ||
|
||
with open(sys.argv[1], "r") as f: | ||
data = f.read() | ||
lines = data.split(";") | ||
for line in lines[1].split("\n"): | ||
if "#define CYW43_WIFI_FW_LEN" in line: | ||
cyw43_wifi_fw_len = int(line.split(")")[0].split("(")[-1]) | ||
if "#define CYW43_CLM_LEN" in line: | ||
cyw43_clm_len = int(line.split(")")[0].split("(")[-1]) | ||
data = lines[0] | ||
bits = data.split(",") | ||
bits[0] = bits[0].split("{")[-1] | ||
bits[-1] = bits[-1].split("}")[0] | ||
for i in range(len(bits)): | ||
bits[i] = bits[i].strip() | ||
bits[i] = bits[i].strip(',') | ||
bits[i] = int(bits[i], base=0) | ||
print(f"Start {bits[4]}, end {bits[-1]}, num {len(bits)}") | ||
print(bits[:10]) | ||
|
||
print(f"Wifi {cyw43_wifi_fw_len}, clm {cyw43_clm_len}") | ||
|
||
data = ( | ||
cyw43_wifi_fw_len.to_bytes(4, 'little', signed=True) + | ||
cyw43_clm_len.to_bytes(4, 'little', signed=True) + | ||
bytearray(bits) | ||
) | ||
|
||
with open(sys.argv[2], "w") as f: | ||
for b in data: | ||
f.write(f".byte 0x{b:02x}\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/rp2_common/pico_cyw43_driver/include/cyw43_partition_firmware.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
extern int cyw43_wifi_fw_len; | ||
extern int cyw43_clm_len; | ||
|
||
#define CYW43_WIFI_FW_LEN (cyw43_wifi_fw_len) | ||
#define CYW43_CLM_LEN (cyw43_clm_len) | ||
extern uintptr_t fw_data; | ||
|
||
#include "boot/picobin.h" | ||
#include "pico/bootrom.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#include "boot/picobin.h" | ||
|
||
#if PICO_CRT0_IMAGE_TYPE_TBYB | ||
#define CRT0_TBYB_FLAG PICOBIN_IMAGE_TYPE_EXE_TBYB_BITS | ||
#else | ||
#define CRT0_TBYB_FLAG 0 | ||
#endif | ||
|
||
.section .text | ||
.global _start | ||
_start: | ||
.word 0 | ||
.word 0 | ||
.word 0 | ||
.word 0 | ||
|
||
.p2align 2 | ||
embedded_block: | ||
.word PICOBIN_BLOCK_MARKER_START | ||
|
||
.byte PICOBIN_BLOCK_ITEM_1BS_IMAGE_TYPE | ||
.byte 0x1 // 1 word | ||
.hword PICOBIN_IMAGE_TYPE_IMAGE_TYPE_AS_BITS(EXE) | \ | ||
PICOBIN_IMAGE_TYPE_EXE_CPU_AS_BITS(RISCV) | \ | ||
PICOBIN_IMAGE_TYPE_EXE_CHIP_AS_BITS(RP2350) | \ | ||
CRT0_TBYB_FLAG | ||
|
||
// Entry point into SRAM | ||
.byte PICOBIN_BLOCK_ITEM_1BS_ENTRY_POINT | ||
.byte 0x3 // word size to next item | ||
.byte 0 // pad | ||
.byte 0 // pad | ||
.word _start | ||
.word 0x20082000 // stack pointer | ||
|
||
_lm_item: | ||
.byte PICOBIN_BLOCK_ITEM_LOAD_MAP | ||
.byte 7 | ||
.byte 0 // pad | ||
.byte 2 // 2 entries | ||
// To sign the firmware | ||
.word (_start - _lm_item) | ||
.word _start | ||
.word (firmware_end - _start) | ||
// But clear SRAM if actually running this, so it doesn't boot | ||
.word 0 | ||
.word _start | ||
.word 0x00082000 | ||
|
||
.byte PICOBIN_BLOCK_ITEM_2BS_LAST | ||
.hword (embedded_block_end - embedded_block - 16 ) / 4 // total size of all | ||
.byte 0 | ||
.word 0 | ||
.word PICOBIN_BLOCK_MARKER_END | ||
embedded_block_end: | ||
|
||
#if WB_FIRMWARE | ||
#include "firmware_wb_blob.S" | ||
#else | ||
#include "firmware_w_blob.S" | ||
#endif | ||
|
||
firmware_end: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"version": [1, 0], | ||
"unpartitioned": { | ||
"families": ["absolute"], | ||
"permissions": { | ||
"secure": "rw", | ||
"nonsecure": "rw", | ||
"bootloader": "rw" | ||
} | ||
}, | ||
"partitions": [ | ||
{ | ||
"name": "Main", | ||
"id": 0, | ||
"start": 0, | ||
"size": "3500K", | ||
"families": ["rp2350-arm-s", "rp2350-riscv"], | ||
"permissions": { | ||
"secure": "rw", | ||
"nonsecure": "rw", | ||
"bootloader": "rw" | ||
} | ||
}, | ||
{ | ||
"name": "Wi-Fi Firmware", | ||
"id": "0x123456789abcdef0", | ||
"start": "3500k", | ||
"size": "240K", | ||
"families": ["0x12345678"], | ||
"permissions": { | ||
"secure": "rw", | ||
"nonsecure": "rw", | ||
"bootloader": "rw" | ||
}, | ||
"ignored_during_riscv_boot": true, | ||
"no_reboot_on_uf2_download": true | ||
}, | ||
{ | ||
"start": "3500k", | ||
"size": "240k", | ||
"families": ["0x12345678"], | ||
"permissions": { | ||
"secure": "rw", | ||
"nonsecure": "rw", | ||
"bootloader": "rw" | ||
}, | ||
"link": ["a", 1], | ||
"ignored_during_riscv_boot": true, | ||
"no_reboot_on_uf2_download": true | ||
} | ||
] | ||
} |