Skip to content

Commit

Permalink
Rename CYW43_USE_PARTITION_FIRMWARE->CYW43_USE_FIRMWARE_PARTITION and…
Browse files Browse the repository at this point in the history
… CYW43_WIFI_FW_PARTITION_ID->CYW43_FIRMWARE_PARTITION_ID
  • Loading branch information
will-v-pi committed Nov 22, 2024
1 parent 1e7e0c7 commit 1792796
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/rp2_common/pico_cyw43_driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ if (EXISTS ${PICO_CYW43_DRIVER_PATH}/${CYW43_DRIVER_TEST_FILE})
if (PICO_PLATFORM STREQUAL "rp2040")
message(FATAL_ERROR "RP2040 does not support storing wi-fi firmware in partitions")
endif()
target_compile_definitions(${TARGET} PRIVATE CYW43_USE_PARTITION_FIRMWARE=1)
target_compile_definitions(${TARGET} PRIVATE CYW43_USE_FIRMWARE_PARTITION=1)
pico_embed_pt_in_binary(${TARGET} ${PICO_CYW43_DRIVER_CURRENT_PATH}/wifi_pt.json)

find_package (Python3 REQUIRED COMPONENTS Interpreter)
Expand Down
11 changes: 3 additions & 8 deletions src/rp2_common/pico_cyw43_driver/cyw43_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,12 @@

static async_context_t *cyw43_async_context = NULL;

#if CYW43_USE_PARTITION_FIRMWARE
#if CYW43_USE_FIRMWARE_PARTITION
#include "pico/bootrom.h"
#include "hardware/flash.h"
#include "boot/picobin.h"
#include <stdlib.h>

// PICO_CONFIG: CYW43_WIFI_FW_PARTITION_ID, ID of Wi-Fi firmware partition, type=int, default=0x776966696669726d (wififirm), group=pico_cyw43_driver
#ifndef CYW43_WIFI_FW_PARTITION_ID
#define CYW43_WIFI_FW_PARTITION_ID 0x776966696669726d // wififirm
#endif

int32_t cyw43_wifi_fw_len;
int32_t cyw43_clm_len;
uintptr_t fw_data;
Expand Down Expand Up @@ -120,7 +115,7 @@ 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
#if CYW43_USE_FIRMWARE_PARTITION
uint32_t buffer[(16 * 4) + 1] = {}; // maximum of 16 partitions, each with maximum of 4 words returned, plus 1
int ret = rom_get_partition_table_info(buffer, count_of(buffer), PT_INFO_PARTITION_LOCATION_AND_FLAGS | PT_INFO_PARTITION_ID);

Expand All @@ -138,7 +133,7 @@ bool cyw43_driver_init(async_context_t *context) {
uint64_t id = 0;
id |= buffer[i++];
id |= ((uint64_t)(buffer[i++]) << 32ull);
if (id == CYW43_WIFI_FW_PARTITION_ID) {
if (id == CYW43_FIRMWARE_PARTITION_ID) {
picked_p = p;
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ extern "C" {
#endif

#ifndef CYW43_CHIPSET_FIRMWARE_INCLUDE_FILE
#if CYW43_USE_PARTITION_FIRMWARE
#if CYW43_USE_FIRMWARE_PARTITION
#define CYW43_CHIPSET_FIRMWARE_INCLUDE_FILE "cyw43_partition_firmware.h"
#else
#if CYW43_ENABLE_BLUETOOTH
Expand Down
7 changes: 7 additions & 0 deletions src/rp2_common/pico_cyw43_driver/include/pico/cyw43_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
#include "cyw43_configport.h"
#endif

#if CYW43_USE_FIRMWARE_PARTITION
// PICO_CONFIG: CYW43_FIRMWARE_PARTITION_ID, ID of Wi-Fi firmware partition, type=int, default=0x776966696669726d (wififirm), group=pico_cyw43_driver
#ifndef CYW43_FIRMWARE_PARTITION_ID
#define CYW43_FIRMWARE_PARTITION_ID 0x776966696669726d // wififirm
#endif
#endif

#ifdef __cplusplus
extern "C" {
#endif
Expand Down
14 changes: 14 additions & 0 deletions tmp.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--- a/src/rp2_common/pico_crt0/rp2350/memmap_no_flash.ld
+++ b/src/rp2_common/pico_crt0/rp2350/memmap_no_flash.ld
@@ -70,10 +70,10 @@ SECTIONS
*(.dtors)

*(.eh_frame*)
+ . = ALIGN(8);
} > RAM

.rodata : {
- . = ALIGN(4);
*(.rodata*)
*(.srodata*)
. = ALIGN(4);
93 changes: 93 additions & 0 deletions tools/bh.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
diff --git a/tools/check_board_header.py b/tools/check_board_header.py
index 3849e14..c259c81 100755
--- a/tools/check_board_header.py
+++ b/tools/check_board_header.py
@@ -29,6 +29,11 @@ chip_interfaces = {
'RP2350B': "src/rp2350/rp2350b_interface_pins.json",
}

+compulsory_cmake_settings = set(['PICO_PLATFORM'])
+compulsory_cmake_default_settings = set(['PICO_FLASH_SIZE_BYTES'])
+matching_cmake_default_settings = set(['PICO_FLASH_SIZE_BYTES', 'PICO_RP2350_A2_SUPPORTED'])
+compulsory_defines = set(['PICO_FLASH_SIZE_BYTES'])
+
DefineType = namedtuple("DefineType", ["name", "value", "resolved_value", "lineno"])

def list_to_string_with(lst, joiner):
@@ -230,7 +235,13 @@ with open(board_header) as header_fh:
if name in cmake_settings:
raise Exception("{}:{} Multiple values for pico_cmake_set {} ({} and {})".format(board_header, lineno, name, cmake_settings[name].value, value))
else:
- cmake_settings[name] = DefineType(name, value, None, lineno)
+ if value:
+ try:
+ # most cmake settings are integer values
+ value = int(value, 0)
+ except ValueError:
+ pass
+ cmake_settings[name] = DefineType(name, value, None, lineno)
continue

# look for "// pico_cmake_set_default BLAH_BLAH=42"
@@ -246,7 +257,13 @@ with open(board_header) as header_fh:
if name in cmake_default_settings:
raise Exception("{}:{} Multiple values for pico_cmake_set_default {} ({} and {})".format(board_header, lineno, name, cmake_default_settings[name].value, value))
else:
- cmake_default_settings[name] = DefineType(name, value, None, lineno)
+ if value:
+ try:
+ # most cmake settings are integer values
+ value = int(value, 0)
+ except ValueError:
+ pass
+ cmake_default_settings[name] = DefineType(name, value, None, lineno)
continue

# look for "#else"
@@ -362,8 +379,9 @@ if board_header_basename == "none.h":
chip = 'RP2040'
other_chip = 'RP2350'
else:
- if 'PICO_PLATFORM' not in cmake_settings:
- raise Exception("{} is missing a pico_cmake_set {} comment".format(board_header, 'PICO_PLATFORM'))
+ for setting in compulsory_cmake_settings:
+ if setting not in cmake_settings:
+ raise Exception("{} is missing a pico_cmake_set {} comment".format(board_header, setting))
if cmake_settings['PICO_PLATFORM'].value == "rp2040":
chip = 'RP2040'
other_chip = 'RP2350'
@@ -375,19 +393,25 @@ else:
chip = 'RP2350B'
if not board_header.endswith("amethyst_fpga.h"):
if 'PICO_RP2350_A2_SUPPORTED' not in cmake_default_settings:
- raise Exception("{} uses chip {} but is missing a pico_cmake_set_default {}".format(board_header, chip, 'PICO_RP2350_A2_SUPPORTED'))
+ raise Exception("{} uses chip {} but is missing a pico_cmake_set_default {} comment".format(board_header, chip, 'PICO_RP2350_A2_SUPPORTED'))
if 'PICO_RP2350_A2_SUPPORTED' not in defines:
raise Exception("{} uses chip {} but is missing a #define {}".format(board_header, chip, 'PICO_RP2350_A2_SUPPORTED'))
- if int(cmake_default_settings['PICO_RP2350_A2_SUPPORTED'].value) != defines['PICO_RP2350_A2_SUPPORTED'].resolved_value:
- raise Exception("{} has mismatched pico_cmake_set_default and #define values for {}".format(board_header, 'PICO_RP2350_A2_SUPPORTED'))
if defines['PICO_RP2350_A2_SUPPORTED'].resolved_value != 1:
raise Exception("{} sets #define {} {} (should be 1)".format(board_header, chip, 'PICO_RP2350_A2_SUPPORTED', defines['PICO_RP2350_A2_SUPPORTED'].resolved_value))
- if 'PICO_FLASH_SIZE_BYTES' not in cmake_default_settings:
- raise Exception("{} is missing a pico_cmake_set_default {} comment".format(board_header, 'PICO_FLASH_SIZE_BYTES'))
- if 'PICO_FLASH_SIZE_BYTES' not in defines:
- raise Exception("{} is missing a #define {}".format(board_header, 'PICO_FLASH_SIZE_BYTES'))
- if cmake_default_settings['PICO_FLASH_SIZE_BYTES'].value != defines['PICO_FLASH_SIZE_BYTES'].resolved_value:
- raise Exception("{} has mismatched pico_cmake_set_default and #define values for {}".format(board_header, 'PICO_FLASH_SIZE_BYTES'))
+ for setting in compulsory_cmake_default_settings:
+ if setting not in cmake_default_settings:
+ raise Exception("{} is missing a pico_cmake_set_default {} comment".format(board_header, setting))
+ for setting in matching_cmake_default_settings:
+ if setting in cmake_default_settings and setting not in defines:
+ raise Exception("{} has pico_cmake_set_default {} but is missing a matching #define".format(board_header, setting))
+ elif setting in defines and setting not in cmake_default_settings:
+ raise Exception("{} has #define {} but is missing a matching pico_cmake_set_default comment".format(board_header, setting))
+ elif setting in defines and setting in cmake_default_settings:
+ if cmake_default_settings[setting].value != defines[setting].resolved_value:
+ raise Exception("{} has mismatched pico_cmake_set_default and #define values for {}".format(board_header, setting))
+ for setting in compulsory_defines:
+ if setting not in defines:
+ raise Exception("{} is missing a #define {}".format(board_header, setting))

if chip is None:
raise Exception("Couldn't determine chip for {}".format(board_header))

0 comments on commit 1792796

Please sign in to comment.