From 1792796529525670caab1ef362c6c2de50041b18 Mon Sep 17 00:00:00 2001 From: William Vinnicombe Date: Fri, 22 Nov 2024 11:10:20 +0000 Subject: [PATCH] Rename CYW43_USE_PARTITION_FIRMWARE->CYW43_USE_FIRMWARE_PARTITION and CYW43_WIFI_FW_PARTITION_ID->CYW43_FIRMWARE_PARTITION_ID --- .../pico_cyw43_driver/CMakeLists.txt | 2 +- .../pico_cyw43_driver/cyw43_driver.c | 11 +-- .../include/cyw43_configport.h | 2 +- .../include/pico/cyw43_driver.h | 7 ++ tmp.diff | 14 +++ tools/bh.diff | 93 +++++++++++++++++++ 6 files changed, 119 insertions(+), 10 deletions(-) create mode 100644 tmp.diff create mode 100644 tools/bh.diff diff --git a/src/rp2_common/pico_cyw43_driver/CMakeLists.txt b/src/rp2_common/pico_cyw43_driver/CMakeLists.txt index 31b309f25..af05fafca 100644 --- a/src/rp2_common/pico_cyw43_driver/CMakeLists.txt +++ b/src/rp2_common/pico_cyw43_driver/CMakeLists.txt @@ -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) diff --git a/src/rp2_common/pico_cyw43_driver/cyw43_driver.c b/src/rp2_common/pico_cyw43_driver/cyw43_driver.c index edd6d87f3..b5cc72609 100644 --- a/src/rp2_common/pico_cyw43_driver/cyw43_driver.c +++ b/src/rp2_common/pico_cyw43_driver/cyw43_driver.c @@ -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 - // 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; @@ -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); @@ -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; } diff --git a/src/rp2_common/pico_cyw43_driver/include/cyw43_configport.h b/src/rp2_common/pico_cyw43_driver/include/cyw43_configport.h index cb1cbaeb8..0590e7a5e 100644 --- a/src/rp2_common/pico_cyw43_driver/include/cyw43_configport.h +++ b/src/rp2_common/pico_cyw43_driver/include/cyw43_configport.h @@ -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 diff --git a/src/rp2_common/pico_cyw43_driver/include/pico/cyw43_driver.h b/src/rp2_common/pico_cyw43_driver/include/pico/cyw43_driver.h index 4d17c4b32..4cf4c4219 100644 --- a/src/rp2_common/pico_cyw43_driver/include/pico/cyw43_driver.h +++ b/src/rp2_common/pico_cyw43_driver/include/pico/cyw43_driver.h @@ -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 diff --git a/tmp.diff b/tmp.diff new file mode 100644 index 000000000..6efeccfa7 --- /dev/null +++ b/tmp.diff @@ -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); diff --git a/tools/bh.diff b/tools/bh.diff new file mode 100644 index 000000000..de9b352d4 --- /dev/null +++ b/tools/bh.diff @@ -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))