From 48e6049ca7616f3eeb07beca757e14f20a47394a Mon Sep 17 00:00:00 2001 From: Jamie Smith Date: Mon, 30 Sep 2024 00:10:29 -0700 Subject: [PATCH 1/6] Start on fixing some unintentionally skipped tests --- TESTS/integration/COMMON/common_defines_fs_test.h | 2 +- drivers/device_key/include/device_key/DeviceKey.h | 2 +- .../TESTS/device_key/functionality/CMakeLists.txt | 2 +- .../TARGET_MBED_PSA_SRV/TESTS/its_ps/test/main.cpp | 2 +- .../mbed_platform/crash_reporting/CMakeLists.txt | 6 ++---- .../TESTS/mbed_platform/stats_cpu/CMakeLists.txt | 7 +++++-- .../TESTS/mbed_platform/stats_heap/CMakeLists.txt | 5 +++-- .../TESTS/mbed_platform/stats_sys/CMakeLists.txt | 4 ++-- .../tests/TESTS/direct_access_devicekey/tdb/main.cpp | 4 ++-- storage/kvstore/kv_config/CMakeLists.txt | 4 ++++ storage/kvstore/kv_config/source/kv_config.cpp | 12 ++++++------ storage/kvstore/tdbstore/source/TDBStore.cpp | 1 - .../TESTS/kvstore/general_tests_phase_1/main.cpp | 2 +- .../TESTS/kvstore/general_tests_phase_2/main.cpp | 2 +- storage/platform/CMakeLists.txt | 12 ++++++------ storage/platform/source/PlatformStorage.cpp | 6 +++--- 16 files changed, 39 insertions(+), 34 deletions(-) diff --git a/TESTS/integration/COMMON/common_defines_fs_test.h b/TESTS/integration/COMMON/common_defines_fs_test.h index 0deba95028f..80fdcbffdc9 100644 --- a/TESTS/integration/COMMON/common_defines_fs_test.h +++ b/TESTS/integration/COMMON/common_defines_fs_test.h @@ -34,7 +34,7 @@ #elif COMPONENT_NUSD #define TEST_BLOCK_DEVICE_TYPE "NUSD" #define TEST_USE_FILESYSTEM FS_FAT -#elif COMPONENT_FLASHIAP && MBED_CONF_FLASHIAP_BLOCK_DEVICE_SIZE +#elif DEVICE_FLASH && MBED_CONF_FLASHIAP_BLOCK_DEVICE_SIZE #define TEST_BLOCK_DEVICE_TYPE "FLASHIAP" #else #define TEST_BLOCK_DEVICE_TYPE "UNKNOWN" diff --git a/drivers/device_key/include/device_key/DeviceKey.h b/drivers/device_key/include/device_key/DeviceKey.h index 1bcabfa432b..0a7909dab54 100644 --- a/drivers/device_key/include/device_key/DeviceKey.h +++ b/drivers/device_key/include/device_key/DeviceKey.h @@ -25,7 +25,7 @@ // Whole class is not supported if entropy is not enabled // Flash device is required as Device Key is currently depending on it -#if !DEVICE_FLASH || !defined(COMPONENT_FLASHIAP) +#if !DEVICE_FLASH #undef DEVICEKEY_ENABLED #define DEVICEKEY_ENABLED 0 #endif diff --git a/drivers/device_key/tests/TESTS/device_key/functionality/CMakeLists.txt b/drivers/device_key/tests/TESTS/device_key/functionality/CMakeLists.txt index 52fbc1b9795..ecd5d0007c3 100644 --- a/drivers/device_key/tests/TESTS/device_key/functionality/CMakeLists.txt +++ b/drivers/device_key/tests/TESTS/device_key/functionality/CMakeLists.txt @@ -5,7 +5,7 @@ if(NOT "DEVICE_TRNG=1" IN_LIST MBED_TARGET_DEFINITIONS) set(TEST_SKIPPED "True RNG is not supported for this target so device key cannot be used") endif() -if(NOT ("DEVICE_FLASH=1" IN_LIST MBED_TARGET_DEFINITIONS AND "COMPONENT_FLASHIAP=1" IN_LIST MBED_TARGET_DEFINITIONS)) +if(NOT "DEVICE_FLASH=1" IN_LIST MBED_TARGET_DEFINITIONS) set(TEST_SKIPPED "Flash IAP is not supported for this target so device key cannot be used") endif() diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/its_ps/test/main.cpp b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/its_ps/test/main.cpp index 1282fb27fe1..b3f956dec7c 100644 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/its_ps/test/main.cpp +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/its_ps/test/main.cpp @@ -220,7 +220,7 @@ utest::v1::status_t case_its_setup_handler(const Case *const source, const size_ Case cases[] = { Case("PSA prot internal storage - Basic", case_its_setup_handler, pits_ps_test, case_its_teardown_handler), Case("PSA prot internal storage - Write-once", case_its_setup_handler, pits_ps_write_once_test, case_its_teardown_handler), -#if COMPONENT_FLASHIAP +#if DEVICE_FLASH Case("PSA protected storage - Basic", case_its_setup_handler, pits_ps_test), Case("PSA protected storage - Write-once", case_its_setup_handler, pits_ps_write_once_test) #endif diff --git a/platform/tests/TESTS/mbed_platform/crash_reporting/CMakeLists.txt b/platform/tests/TESTS/mbed_platform/crash_reporting/CMakeLists.txt index 0647c800607..ffdfc932d52 100644 --- a/platform/tests/TESTS/mbed_platform/crash_reporting/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_platform/crash_reporting/CMakeLists.txt @@ -1,10 +1,8 @@ # Copyright (c) 2020-2021 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -include(mbed_greentea) - -if(NOT DEFINED MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED) - set(TEST_SKIPPED "crash_reporting test not supported.") +if(NOT "MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED=1" IN_LIST MBED_CONFIG_DEFINITIONS) + set(TEST_SKIPPED "CRC is not supported for this target") endif() mbed_greentea_add_test( diff --git a/platform/tests/TESTS/mbed_platform/stats_cpu/CMakeLists.txt b/platform/tests/TESTS/mbed_platform/stats_cpu/CMakeLists.txt index e0b456e2f52..30a96dd0c63 100644 --- a/platform/tests/TESTS/mbed_platform/stats_cpu/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_platform/stats_cpu/CMakeLists.txt @@ -3,11 +3,14 @@ include(mbed_greentea) -if(NOT DEFINED MBED_CPU_STATS_ENABLED OR NOT "DEVICE_LPTICKER=1" IN_LIST MBED_TARGET_DEFINITIONS - OR NOT "DEVICE_SLEEP=1" IN_LIST MBED_TARGET_DEFINITIONS) +if(NOT "DEVICE_LPTICKER=1" IN_LIST MBED_TARGET_DEFINITIONS OR NOT "DEVICE_SLEEP=1" IN_LIST MBED_TARGET_DEFINITIONS) set(TEST_SKIPPED "Stats cpu test not supported.") endif() +if(NOT "MBED_CPU_STATS_ENABLED=1" IN_LIST MBED_CONFIG_DEFINITIONS) + set(TEST_SKIPPED "CPU stats not enabled") +endif() + mbed_greentea_add_test( TEST_NAME mbed-platform-stats-cpu diff --git a/platform/tests/TESTS/mbed_platform/stats_heap/CMakeLists.txt b/platform/tests/TESTS/mbed_platform/stats_heap/CMakeLists.txt index 1ca4a9c0f54..9d59e0dd4be 100644 --- a/platform/tests/TESTS/mbed_platform/stats_heap/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_platform/stats_heap/CMakeLists.txt @@ -3,10 +3,11 @@ include(mbed_greentea) -if(NOT DEFINED MBED_HEAP_STATS_ENABLED) - set(TEST_SKIPPED "Stats heap test not supported.") +if(NOT "MBED_HEAP_STATS_ENABLED=1" IN_LIST MBED_CONFIG_DEFINITIONS) + set(TEST_SKIPPED "heap stats not enabled") endif() + mbed_greentea_add_test( TEST_NAME mbed-platform-stats-heap diff --git a/platform/tests/TESTS/mbed_platform/stats_sys/CMakeLists.txt b/platform/tests/TESTS/mbed_platform/stats_sys/CMakeLists.txt index 0c94d801392..84ea39c2cbe 100644 --- a/platform/tests/TESTS/mbed_platform/stats_sys/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_platform/stats_sys/CMakeLists.txt @@ -3,8 +3,8 @@ include(mbed_greentea) -if(NOT DEFINED MBED_SYS_STATS_ENABLED) - set(TEST_SKIPPED "System stats test not supported.") +if(NOT "MBED_SYS_STATS_ENABLED=1" IN_LIST MBED_CONFIG_DEFINITIONS) + set(TEST_SKIPPED "System stats not enabled") endif() mbed_greentea_add_test( diff --git a/storage/kvstore/direct_access_devicekey/tests/TESTS/direct_access_devicekey/tdb/main.cpp b/storage/kvstore/direct_access_devicekey/tests/TESTS/direct_access_devicekey/tdb/main.cpp index eb9a3c1a0f3..9698b521a8c 100644 --- a/storage/kvstore/direct_access_devicekey/tests/TESTS/direct_access_devicekey/tdb/main.cpp +++ b/storage/kvstore/direct_access_devicekey/tests/TESTS/direct_access_devicekey/tdb/main.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#ifndef COMPONENT_FLASHIAP +#ifndef DEVICE_FLASH #error [NOT_SUPPORTED] Target must have internal FlashIAP for this test #else @@ -323,4 +323,4 @@ int main() return !Harness::run(specification); } -#endif // COMPONENT_FLASHIAP +#endif // DEVICE_FLASH diff --git a/storage/kvstore/kv_config/CMakeLists.txt b/storage/kvstore/kv_config/CMakeLists.txt index a8b296dc2fa..1e203875f31 100644 --- a/storage/kvstore/kv_config/CMakeLists.txt +++ b/storage/kvstore/kv_config/CMakeLists.txt @@ -26,3 +26,7 @@ target_link_libraries(mbed-storage-kv-config mbed-storage-littlefs-v2 mbed-storage-fat ) + +if("DEVICE_FLASH=1" IN_LIST MBED_TARGET_DEFINITIONS) + target_link_libraries(mbed-storage-kv-config PUBLIC mbed-storage-flashiap) +endif() \ No newline at end of file diff --git a/storage/kvstore/kv_config/source/kv_config.cpp b/storage/kvstore/kv_config/source/kv_config.cpp index 8f39a99e528..4891d225586 100644 --- a/storage/kvstore/kv_config/source/kv_config.cpp +++ b/storage/kvstore/kv_config/source/kv_config.cpp @@ -30,7 +30,7 @@ #include "securestore/SecureStore.h" #define TRACE_GROUP "KVCFG" -#if COMPONENT_FLASHIAP +#if DEVICE_FLASH #include "FlashIAPBlockDevice.h" #endif @@ -284,7 +284,7 @@ FileSystem *_get_filesystem_default(const char *mount) BlockDevice *_get_blockdevice_FLASHIAP(bd_addr_t start_address, bd_size_t size) { -#if COMPONENT_FLASHIAP +#if DEVICE_FLASH int ret = kv_get_flash_bounds_from_config(&start_address, &size); if (ret != 0) { tr_error("KV Config: Determination of internal block device bounds failed. The configured start address/size is likely invalid."); @@ -677,7 +677,7 @@ int _create_internal_tdb(BlockDevice **internal_bd, KVStore **internal_tdb, bd_s int _storage_config_TDB_INTERNAL() { -#if COMPONENT_FLASHIAP +#if DEVICE_FLASH bd_size_t internal_size = MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_SIZE; bd_addr_t internal_start_address = MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_BASE_ADDRESS; @@ -999,7 +999,7 @@ MBED_WEAK int kv_init_storage_config() int ret = MBED_SUCCESS; // We currently have no supported configuration without internal storage -#ifndef COMPONENT_FLASHIAP +#ifndef DEVICE_FLASH return MBED_ERROR_UNSUPPORTED; #endif @@ -1026,7 +1026,7 @@ int kv_get_default_flash_addresses(bd_addr_t *start_address, bd_size_t *size) { int ret = MBED_SUCCESS; -#if COMPONENT_FLASHIAP +#if DEVICE_FLASH FlashIAP flash; if (flash.init() != 0) { return MBED_ERROR_INITIALIZATION_FAILED; @@ -1072,7 +1072,7 @@ int kv_get_default_flash_addresses(bd_addr_t *start_address, bd_size_t *size) int kv_get_flash_bounds_from_config(bd_addr_t *start_address, bd_size_t *size) { -#if COMPONENT_FLASHIAP +#if DEVICE_FLASH bd_addr_t flash_end_address; bd_addr_t flash_start_address; diff --git a/storage/kvstore/tdbstore/source/TDBStore.cpp b/storage/kvstore/tdbstore/source/TDBStore.cpp index 50f490cf370..8522ffbbdc7 100644 --- a/storage/kvstore/tdbstore/source/TDBStore.cpp +++ b/storage/kvstore/tdbstore/source/TDBStore.cpp @@ -1490,7 +1490,6 @@ int TDBStore::check_erase_before_write(uint8_t area, uint32_t offset, uint32_t s uint32_t end_offset; while (size) { uint32_t dist, offset_from_start; - int ret; offset_in_erase_unit(area, offset, offset_from_start, dist); uint32_t chunk = std::min(size, dist); diff --git a/storage/kvstore/tests/TESTS/kvstore/general_tests_phase_1/main.cpp b/storage/kvstore/tests/TESTS/kvstore/general_tests_phase_1/main.cpp index 9d0cee060ed..f25a0643b4a 100644 --- a/storage/kvstore/tests/TESTS/kvstore/general_tests_phase_1/main.cpp +++ b/storage/kvstore/tests/TESTS/kvstore/general_tests_phase_1/main.cpp @@ -99,7 +99,7 @@ static void kvstore_init() TEST_ASSERT_EQUAL_ERROR_CODE(0, res); if (kv_setup == TDBStoreSet) { -#if COMPONENT_FLASHIAP && !COMPONENT_SPIF && !COMPONENT_QSPIF && !COMPONENT_DATAFLASH && !COMPONENT_SD +#if DEVICE_FLASH && !COMPONENT_SPIF && !COMPONENT_QSPIF && !COMPONENT_DATAFLASH && !COMPONENT_SD // TDBStore requires two areas of equal size, do the check for FlashIAP TEST_SKIP_UNLESS(MBED_CONF_TARGET_INTERNAL_FLASH_UNIFORM_SECTORS || (MBED_CONF_FLASHIAP_BLOCK_DEVICE_SIZE != 0) && (MBED_CONF_FLASHIAP_BLOCK_DEVICE_BASE_ADDRESS != 0xFFFFFFFF)) diff --git a/storage/kvstore/tests/TESTS/kvstore/general_tests_phase_2/main.cpp b/storage/kvstore/tests/TESTS/kvstore/general_tests_phase_2/main.cpp index e6a407fd946..be99771f6c4 100644 --- a/storage/kvstore/tests/TESTS/kvstore/general_tests_phase_2/main.cpp +++ b/storage/kvstore/tests/TESTS/kvstore/general_tests_phase_2/main.cpp @@ -95,7 +95,7 @@ static void kvstore_init() TEST_ASSERT_EQUAL_ERROR_CODE(0, res); if (kv_setup == TDBStoreSet) { -#if COMPONENT_FLASHIAP && !COMPONENT_SPIF && !COMPONENT_QSPIF && !COMPONENT_DATAFLASH && !COMPONENT_SD +#if DEVICE_FLASH && !COMPONENT_SPIF && !COMPONENT_QSPIF && !COMPONENT_DATAFLASH && !COMPONENT_SD // TDBStore requires two areas of equal size TEST_SKIP_UNLESS(MBED_CONF_TARGET_INTERNAL_FLASH_UNIFORM_SECTORS || (MBED_CONF_FLASHIAP_BLOCK_DEVICE_SIZE != 0) && (MBED_CONF_FLASHIAP_BLOCK_DEVICE_BASE_ADDRESS != 0xFFFFFFFF)) diff --git a/storage/platform/CMakeLists.txt b/storage/platform/CMakeLists.txt index 128e17729fe..3987e88b757 100644 --- a/storage/platform/CMakeLists.txt +++ b/storage/platform/CMakeLists.txt @@ -14,27 +14,27 @@ list(APPEND mbed-storage-libs mbed-storage-littlefs-v2 ) -if("DATAFLASH" IN_LIST MBED_TARGET_LABELS) +if("COMPONENT_DATAFLASH=1" IN_LIST MBED_TARGET_DEFINITIONS) list(APPEND mbed-storage-libs mbed-storage-dataflash) endif() -if("FLASHIAP" IN_LIST MBED_TARGET_LABELS) +if("DEVICE_FLASH=1" IN_LIST MBED_TARGET_DEFINITIONS) list(APPEND mbed-storage-libs mbed-storage-flashiap) endif() -if("QSPIF" IN_LIST MBED_TARGET_LABELS) +if("COMPONENT_QSPIF=1" IN_LIST MBED_TARGET_DEFINITIONS) list(APPEND mbed-storage-libs mbed-storage-qspif) endif() -if("OSPIF" IN_LIST MBED_TARGET_LABELS) +if("COMPONENT_OSPIF=1" IN_LIST MBED_TARGET_DEFINITIONS) list(APPEND mbed-storage-libs mbed-storage-ospif) endif() -if("SD" IN_LIST MBED_TARGET_LABELS) +if("COMPONENT_SD=1" IN_LIST MBED_TARGET_DEFINITIONS) list(APPEND mbed-storage-libs mbed-storage-sd) endif() -if("SPIF" IN_LIST MBED_TARGET_LABELS) +if("COMPONENT_SPIF=1" IN_LIST MBED_TARGET_DEFINITIONS) list(APPEND mbed-storage-libs mbed-storage-spif) endif() diff --git a/storage/platform/source/PlatformStorage.cpp b/storage/platform/source/PlatformStorage.cpp index 2371dafc638..ba10a4f2d7f 100644 --- a/storage/platform/source/PlatformStorage.cpp +++ b/storage/platform/source/PlatformStorage.cpp @@ -44,7 +44,7 @@ const spi_pinmap_t static_spi_pinmap = get_spi_pinmap(MBED_CONF_SD_SPI_MOSI, MBE #endif #endif -#if COMPONENT_FLASHIAP +#if DEVICE_FLASH #include "FlashIAPBlockDevice.h" #endif @@ -104,7 +104,7 @@ MBED_WEAK BlockDevice *BlockDevice::get_default_instance() return &default_bd; -#elif COMPONENT_FLASHIAP +#elif DEVICE_FLASH #if (MBED_CONF_FLASHIAP_BLOCK_DEVICE_SIZE == 0) && (MBED_CONF_FLASHIAP_BLOCK_DEVICE_BASE_ADDRESS == 0xFFFFFFFF) @@ -164,7 +164,7 @@ MBED_WEAK FileSystem *FileSystem::get_default_instance() return &sdcard; -#elif COMPONENT_FLASHIAP +#elif DEVICE_FLASH // To avoid alignment issues, initialize a filesystem if all sectors have the same size // OR the user has specified an address range From c54d1f50d706294f5f336bfc2f3a9787fc800f8f Mon Sep 17 00:00:00 2001 From: Jamie Smith Date: Thu, 3 Oct 2024 20:51:12 -0700 Subject: [PATCH 2/6] Add standard upload method variables --- tools/cmake/UploadMethodManager.cmake | 66 +++++++++++++++---- .../upload_methods/UploadMethodJLINK.cmake | 15 +++-- .../UploadMethodLINKSERVER.cmake | 10 ++- .../upload_methods/UploadMethodMBED.cmake | 5 +- .../upload_methods/UploadMethodOPENOCD.cmake | 12 ++-- .../upload_methods/UploadMethodPYOCD.cmake | 10 +-- .../upload_methods/UploadMethodSTLINK.cmake | 6 +- .../UploadMethodSTM32CUBE.cmake | 12 ++-- 8 files changed, 81 insertions(+), 55 deletions(-) diff --git a/tools/cmake/UploadMethodManager.cmake b/tools/cmake/UploadMethodManager.cmake index 4e92db5d3b7..09d00f3d9d1 100644 --- a/tools/cmake/UploadMethodManager.cmake +++ b/tools/cmake/UploadMethodManager.cmake @@ -2,34 +2,74 @@ # SPDX-License-Identifier: Apache-2.0 # ---------------------------------------------- -# Load the upload method that the user selects +# Common upload method options # This variable should have been set in app.cmake or by the upload method cfg file, sanity check here if(NOT DEFINED UPLOAD_METHOD_DEFAULT) message(FATAL_ERROR "UPLOAD_METHOD_DEFAULT not found.") endif() +## Upload method set(UPLOAD_METHOD "${UPLOAD_METHOD_DEFAULT}" CACHE STRING "Method for uploading programs to the mbed") -# use a higher numbered port to allow use without root on Linux/Mac -set(GDB_PORT 23331 CACHE STRING "Port that the GDB server will be started on.") - -# Upload methods must be uppercase, guard against the user making a mistake (since Windows will allow opening -# an include file with the wrong case, the error message gets confusing) +# Upload methods must be uppercase, guard against the user making a mistake (since Windows and Mac will allow including +# an include file with the wrong case, the error that happens later gets confusing) string(TOUPPER "${UPLOAD_METHOD}" UPLOAD_METHOD_UCASE) if(NOT "${UPLOAD_METHOD_UCASE}" STREQUAL "${UPLOAD_METHOD}") message(WARNING "UPLOAD_METHOD value should be uppercase. It has been automatically changed to \"${UPLOAD_METHOD_UCASE}\".") set(UPLOAD_METHOD "${UPLOAD_METHOD_UCASE}" CACHE STRING "" FORCE) endif() -# Load the upload method. This is expected to set the following variables: -# UPLOAD_${UPLOAD_METHOD}_FOUND - True iff the dependencies for this upload method were found -# UPLOAD_SUPPORTS_DEBUG - True iff this upload method supports debugging -# UPLOAD_GDBSERVER_DEBUG_COMMAND - Command to start a new GDB server -# UPLOAD_WANTS_EXTENDED_REMOTE - True iff GDB should use "target extended-remote" to connect to the GDB server -# UPLOAD_LAUNCH_COMMANDS - List of GDB commands to run after launching GDB. -# UPLOAD_RESTART_COMMANDS - List of GDB commands to run when the "restart chip" function is used. +## GDB port +# use a higher numbered port to allow use without root on Linux/Mac +set(MBED_GDB_PORT 23331 CACHE STRING "Port that the GDB server will be started on.") + +## Upload tool serial number +set(MBED_UPLOAD_SERIAL_NUMBER "" CACHE STRING "Serial number of the Mbed board or the programming tool, for upload methods that select by serial number.") + +# Handle legacy per-upload-method aliases for the upload serial number +foreach(LEGACY_VAR_NAME JLINK_USB_SERIAL_NUMBER LINKSERVER_PROBE_SN MBED_TARGET_UID OPENOCD_ADAPTER_SERIAL PYOCD_PROBE_UID STLINK_SERIAL_ARGUMENT STM32CUBE_PROBE_SN) + if(DEFINED ${LEGACY_VAR_NAME}) + if(NOT "${${LEGACY_VAR_NAME}}" STREQUAL "") + message(WARNING "${LEGACY_VAR_NAME} is deprecated, set the MBED_UPLOAD_SERIAL_NUMBER variable instead. MBED_UPLOAD_SERIAL_NUMBER will be set to the value of ${LEGACY_VAR_NAME}.") + set(MBED_UPLOAD_SERIAL_NUMBER ${${LEGACY_VAR_NAME}} CACHE STRING "" FORCE) + endif() + endif() +endforeach() + +## Upload base address +if(NOT DEFINED MBED_UPLOAD_BASE_ADDR OR "${MBED_UPLOAD_BASE_ADDR}" STREQUAL "") + set(BASE_ADDR_DESCRIPTION "Base address for uploading code, i.e. the memory address where the first byte of the bin/hex file will get loaded to (with 0x prefix). Generally should point to the start of the desired flash bank and defaults to the configured start of the primary ROM bank (MBED_CONFIGURED_ROM_START).") + if(MBED_CONFIG_DEFINITIONS MATCHES "MBED_CONFIGURED_ROM_START=(0x[0-9a-zA-Z]+)") + set(MBED_UPLOAD_BASE_ADDR ${CMAKE_MATCH_1} CACHE STRING ${BASE_ADDR_DESCRIPTION}) + else() + set(MBED_UPLOAD_BASE_ADDR "" CACHE STRING ${BASE_ADDR_DESCRIPTION}) + message(FATAL_ERROR "Since no ROM banks have been defined, you need to set the MBED_UPLOAD_BASE_ADDR option so we know where to upload code. NOTE: If you upgraded from an old version of Mbed CE and are getting this error, delete and reconfigure your CMake build directory.") + endif() +endif() + + +set(MBED_UPLOAD_SERIAL_NUMBER "" CACHE STRING "Serial number of the Mbed board or the programming tool, for upload methods that select by serial number.") + + +# ---------------------------------------------- +# Load the upload method. +# Upload methods are expected to refer to the following variables: +# - MBED_UPLOAD_SERIAL_NUMBER - USB serial number of the mbed board or of the programmer +# - MBED_UPLOAD_BASE_ADDR - Base address of the flash where the bin file will be updated +# +# Upload methods are expected to set the following variables: +# - UPLOAD_${UPLOAD_METHOD}_FOUND - True iff the dependencies for this upload method were found +# - UPLOAD_SUPPORTS_DEBUG - True iff this upload method supports debugging +# - UPLOAD_GDBSERVER_DEBUG_COMMAND - Command to start a new GDB server +# - UPLOAD_WANTS_EXTENDED_REMOTE - True iff GDB should use "target extended-remote" to connect to the GDB server +# - UPLOAD_LAUNCH_COMMANDS - List of GDB commands to run after launching GDB. +# - UPLOAD_RESTART_COMMANDS - List of GDB commands to run when the "restart chip" function is used. # See here for more info: https://github.com/mbed-ce/mbed-os/wiki/Debugger-Commands-and-State-in-Upload-Methods +# +# WARNING: Upload method files are included during the add_subdirectory(mbed-os) call in the top-level CMakeLists.txt. This means that +# if you declare variables in an upload method script, you have to save them as CACHE INTERNAL (or PARENT_SCOPE) so that they are accessible +# to code running outside of the mbed-os subdirectory. include(UploadMethod${UPLOAD_METHOD}) if(NOT "${UPLOAD_${UPLOAD_METHOD}_FOUND}") diff --git a/tools/cmake/upload_methods/UploadMethodJLINK.cmake b/tools/cmake/upload_methods/UploadMethodJLINK.cmake index f18c56d4875..cdfa86ccf68 100644 --- a/tools/cmake/upload_methods/UploadMethodJLINK.cmake +++ b/tools/cmake/upload_methods/UploadMethodJLINK.cmake @@ -7,7 +7,6 @@ # JLINK_CLOCK_SPEED - Speed to run the J-Link at, in KHz. # JLINK_CPU_NAME - Name of CPU to pass to J-Link # This method has the following options: -# JLINK_USB_SERIAL_NUMBER - Use a J-Link connected over USB with the specified serial number. # JLINK_NETWORK_ADDRESS - Use a J-Link connected over the network with the given [:port] # JLINK_NO_GUI - If set to true, suppress GUI dialog boxes from the J-Link software. # @@ -19,14 +18,13 @@ find_package(JLINK) set(UPLOAD_JLINK_FOUND ${JLINK_FOUND}) ### Setup options -set(JLINK_USB_SERIAL_NUMBER "" CACHE STRING "Use a J-Link connected over USB with the specified serial number.") set(JLINK_NETWORK_ADDRESS "" CACHE STRING "Use a J-Link connected over the network with the given [:port]") # Figure out -select option. See here: https://wiki.segger.com/J-Link_GDB_Server#-select -if((NOT "${JLINK_USB_SERIAL_NUMBER}" STREQUAL "") AND (NOT "${JLINK_NETWORK_ADDRESS}" STREQUAL "")) - message(FATAL_ERROR "Cannot use both JLINK_USB_SERIAL_NUMBER and JLINK_NETWORK_ADDRESS at the same time!") -elseif(NOT "${JLINK_USB_SERIAL_NUMBER}" STREQUAL "") - set(JLINK_SELECT_ARG -Select usb=${JLINK_USB_SERIAL_NUMBER} CACHE INTERNAL "" FORCE) +if((NOT "${MBED_UPLOAD_SERIAL_NUMBER}" STREQUAL "") AND (NOT "${JLINK_NETWORK_ADDRESS}" STREQUAL "")) + message(FATAL_ERROR "Cannot use both MBED_UPLOAD_SERIAL_NUMBER and JLINK_NETWORK_ADDRESS at the same time!") +elseif(NOT "${MBED_UPLOAD_SERIAL_NUMBER}" STREQUAL "") + set(JLINK_SELECT_ARG -Select usb=${MBED_UPLOAD_SERIAL_NUMBER} CACHE INTERNAL "" FORCE) elseif(NOT "${JLINK_NETWORK_ADDRESS}" STREQUAL "") set(JLINK_SELECT_ARG -Select ip=${JLINK_NETWORK_ADDRESS} CACHE INTERNAL "" FORCE) else() @@ -51,8 +49,11 @@ function(gen_upload_target TARGET_NAME BINARY_FILE) # create command file for j-link set(COMMAND_FILE_PATH ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/flash-${TARGET_NAME}.jlink) + + # Note: loadfile currently only honors the base address for .bin files. For hex files it uses the offset read + # from the hex file. Unsure if that will be an issue or not... file(GENERATE OUTPUT ${COMMAND_FILE_PATH} CONTENT -"loadfile ${BINARY_FILE} +"loadfile ${BINARY_FILE} ${MBED_UPLOAD_BASE_ADDR} r go exit diff --git a/tools/cmake/upload_methods/UploadMethodLINKSERVER.cmake b/tools/cmake/upload_methods/UploadMethodLINKSERVER.cmake index 751c17032d2..2f28b90c968 100644 --- a/tools/cmake/upload_methods/UploadMethodLINKSERVER.cmake +++ b/tools/cmake/upload_methods/UploadMethodLINKSERVER.cmake @@ -4,18 +4,15 @@ ### NXP LinkServer Upload Method # This method needs the following parameters: # LINKSERVER_DEVICE - Chip name and board to connect to, separated by a colon. -# LINKSERVER_PROBE_SN - Serial number, or serial number substring, of the debug probe to connect to. If blank, will connect to any probe. set(UPLOAD_SUPPORTS_DEBUG TRUE) ### Handle options -set(LINKSERVER_PROBE_SN "" CACHE STRING "Serial number, or serial number substring, of the debug probe to connect to. If blank, will connect to any probe.") - -if("${LINKSERVER_PROBE_SN}" STREQUAL "") +if("${MBED_UPLOAD_SERIAL_NUMBER}" STREQUAL "") # This argument causes Redlink to connect to the first available debug probe set(LINKSERVER_PROBE_ARGS "" CACHE INTERNAL "" FORCE) else() - set(LINKSERVER_PROBE_ARGS --probe ${LINKSERVER_PROBE_SN} CACHE INTERNAL "" FORCE) + set(LINKSERVER_PROBE_ARGS --probe ${MBED_UPLOAD_SERIAL_NUMBER} CACHE INTERNAL "" FORCE) endif() if("${LINKSERVER_DEVICE}" STREQUAL "") @@ -37,7 +34,8 @@ function(gen_upload_target TARGET_NAME BINARY_FILE) ${LINKSERVER_PROBE_ARGS} ${LINKSERVER_DEVICE} load - $) + --addr ${MBED_UPLOAD_BASE_ADDR} + ${BINARY_FILE}) add_dependencies(flash-${TARGET_NAME} ${TARGET_NAME}) diff --git a/tools/cmake/upload_methods/UploadMethodMBED.cmake b/tools/cmake/upload_methods/UploadMethodMBED.cmake index 00bcbd774ec..654a6c26705 100644 --- a/tools/cmake/upload_methods/UploadMethodMBED.cmake +++ b/tools/cmake/upload_methods/UploadMethodMBED.cmake @@ -2,7 +2,6 @@ # This method needs the following parameters: # MBED_RESET_BAUDRATE - Serial baudrate to connect to the target at when resetting it. # This method creates the following options: -# MBED_TARGET_UID - Probe UID to pass to commands. You can get the UIDs from `python -m pyocd list`. set(UPLOAD_SUPPORTS_DEBUG FALSE) @@ -13,8 +12,6 @@ if(NOT DEFINED MBED_RESET_BAUDRATE) set(MBED_RESET_BAUDRATE 9600) endif() -set(MBED_TARGET_UID "" CACHE STRING "UID of mbed target to upload to if there are multiple connected. You can get the UIDs from `python -m pyocd list`") - ### Function to generate upload target function(gen_upload_target TARGET_NAME BINARY_FILE) @@ -23,7 +20,7 @@ function(gen_upload_target TARGET_NAME BINARY_FILE) ${BINARY_FILE} ${MBED_TARGET} ${MBED_RESET_BAUDRATE} - ${MBED_TARGET_UID} + ${MBED_UPLOAD_SERIAL_NUMBER} WORKING_DIRECTORY ${mbed-os_SOURCE_DIR}/tools/python VERBATIM) diff --git a/tools/cmake/upload_methods/UploadMethodOPENOCD.cmake b/tools/cmake/upload_methods/UploadMethodOPENOCD.cmake index 15f9edf1b63..db7733ec653 100644 --- a/tools/cmake/upload_methods/UploadMethodOPENOCD.cmake +++ b/tools/cmake/upload_methods/UploadMethodOPENOCD.cmake @@ -4,8 +4,9 @@ ### OpenOCD Upload Method # This method needs the following parameters: # OPENOCD_CHIP_CONFIG_COMMANDS - Specifies all OpenOCD commands needed to configure openocd for your target processor. +# OPENOCD_LOAD_ADDRESS - Address where the bin or hex file will be loaded to memory, e.g. 0x8000000. If not set, will default to +# the configured address of the first ROM bank (MBED_CONFIGURED_ROM_START) # This method creates the following options: -# OPENOCD_ADAPTER_SERIAL - Serial number of the debug adapter to select for OpenOCD. Set to empty to detect any matching adapter. # OPENOCD_VERSION_RANGE - Acceptable version range of OpenOCD. This may be a single version, in which case it is treated as # a minimum, or a versionMin..." + -w ${BINARY_FILE} ${MBED_UPLOAD_BASE_ADDR} -rst) add_dependencies(flash-${TARGET_NAME} ${TARGET_NAME}) From ee92753f9c373b1f773fb127a5a267d73a9beb34 Mon Sep 17 00:00:00 2001 From: Jamie Smith Date: Thu, 3 Oct 2024 22:27:05 -0700 Subject: [PATCH 3/6] pyocd works now!! --- targets/upload_method_cfg/K64F.cmake | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/targets/upload_method_cfg/K64F.cmake b/targets/upload_method_cfg/K64F.cmake index e91e120f336..8723b494155 100644 --- a/targets/upload_method_cfg/K64F.cmake +++ b/targets/upload_method_cfg/K64F.cmake @@ -3,11 +3,10 @@ # include app.cmake and where you add mbed os as a subdirectory. # # Notes: -# 1. PyOCD did not actually work in my testing as of Apr 2024, though this device is supposed to be supported -# 2. Be sure to update the DAPLink firmware on the board via these instructions: https://os.mbed.com/blog/entry/DAPLink-bootloader-update/ -# 3. OpenOCD 0.12 flashes this device perfectly and can enter a debug session, but cannot hit breakpoints -# 4. LinkServer can both flash and debug, so it's the recommended upload method for this device. -# 5. LinkServer does appear to have a bug where it doesn't map the peripheral registers as valid memory, so you can't +# 1. Be sure to update the DAPLink firmware on the board via these instructions: https://os.mbed.com/blog/entry/DAPLink-bootloader-update/ +# 2. OpenOCD 0.12 flashes this device perfectly and can enter a debug session, but cannot hit breakpoints +# 3. LinkServer can both flash and debug, so it's the recommended upload method for this device. +# 4. LinkServer does appear to have a bug where it doesn't map the peripheral registers as valid memory, so you can't # inspect them. I was able to work around this by inserting a block like this into /devices/FRDM-K64F.json: # # "name": "MK64FN1M0xxx12", From 3ffd18260316c87dd8576b37265948c255c20652 Mon Sep 17 00:00:00 2001 From: Jamie Smith Date: Thu, 3 Oct 2024 22:56:34 -0700 Subject: [PATCH 4/6] Revert "Start on fixing some unintentionally skipped tests" --- TESTS/integration/COMMON/common_defines_fs_test.h | 2 +- drivers/device_key/include/device_key/DeviceKey.h | 2 +- .../TESTS/device_key/functionality/CMakeLists.txt | 2 +- .../TARGET_MBED_PSA_SRV/TESTS/its_ps/test/main.cpp | 2 +- .../mbed_platform/crash_reporting/CMakeLists.txt | 6 ++++-- .../TESTS/mbed_platform/stats_cpu/CMakeLists.txt | 7 ++----- .../TESTS/mbed_platform/stats_heap/CMakeLists.txt | 5 ++--- .../TESTS/mbed_platform/stats_sys/CMakeLists.txt | 4 ++-- .../tests/TESTS/direct_access_devicekey/tdb/main.cpp | 4 ++-- storage/kvstore/kv_config/CMakeLists.txt | 4 ---- storage/kvstore/kv_config/source/kv_config.cpp | 12 ++++++------ storage/kvstore/tdbstore/source/TDBStore.cpp | 1 + .../TESTS/kvstore/general_tests_phase_1/main.cpp | 2 +- .../TESTS/kvstore/general_tests_phase_2/main.cpp | 2 +- storage/platform/CMakeLists.txt | 12 ++++++------ storage/platform/source/PlatformStorage.cpp | 6 +++--- 16 files changed, 34 insertions(+), 39 deletions(-) diff --git a/TESTS/integration/COMMON/common_defines_fs_test.h b/TESTS/integration/COMMON/common_defines_fs_test.h index 80fdcbffdc9..0deba95028f 100644 --- a/TESTS/integration/COMMON/common_defines_fs_test.h +++ b/TESTS/integration/COMMON/common_defines_fs_test.h @@ -34,7 +34,7 @@ #elif COMPONENT_NUSD #define TEST_BLOCK_DEVICE_TYPE "NUSD" #define TEST_USE_FILESYSTEM FS_FAT -#elif DEVICE_FLASH && MBED_CONF_FLASHIAP_BLOCK_DEVICE_SIZE +#elif COMPONENT_FLASHIAP && MBED_CONF_FLASHIAP_BLOCK_DEVICE_SIZE #define TEST_BLOCK_DEVICE_TYPE "FLASHIAP" #else #define TEST_BLOCK_DEVICE_TYPE "UNKNOWN" diff --git a/drivers/device_key/include/device_key/DeviceKey.h b/drivers/device_key/include/device_key/DeviceKey.h index 0a7909dab54..1bcabfa432b 100644 --- a/drivers/device_key/include/device_key/DeviceKey.h +++ b/drivers/device_key/include/device_key/DeviceKey.h @@ -25,7 +25,7 @@ // Whole class is not supported if entropy is not enabled // Flash device is required as Device Key is currently depending on it -#if !DEVICE_FLASH +#if !DEVICE_FLASH || !defined(COMPONENT_FLASHIAP) #undef DEVICEKEY_ENABLED #define DEVICEKEY_ENABLED 0 #endif diff --git a/drivers/device_key/tests/TESTS/device_key/functionality/CMakeLists.txt b/drivers/device_key/tests/TESTS/device_key/functionality/CMakeLists.txt index ecd5d0007c3..52fbc1b9795 100644 --- a/drivers/device_key/tests/TESTS/device_key/functionality/CMakeLists.txt +++ b/drivers/device_key/tests/TESTS/device_key/functionality/CMakeLists.txt @@ -5,7 +5,7 @@ if(NOT "DEVICE_TRNG=1" IN_LIST MBED_TARGET_DEFINITIONS) set(TEST_SKIPPED "True RNG is not supported for this target so device key cannot be used") endif() -if(NOT "DEVICE_FLASH=1" IN_LIST MBED_TARGET_DEFINITIONS) +if(NOT ("DEVICE_FLASH=1" IN_LIST MBED_TARGET_DEFINITIONS AND "COMPONENT_FLASHIAP=1" IN_LIST MBED_TARGET_DEFINITIONS)) set(TEST_SKIPPED "Flash IAP is not supported for this target so device key cannot be used") endif() diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/its_ps/test/main.cpp b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/its_ps/test/main.cpp index b3f956dec7c..1282fb27fe1 100644 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/its_ps/test/main.cpp +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/its_ps/test/main.cpp @@ -220,7 +220,7 @@ utest::v1::status_t case_its_setup_handler(const Case *const source, const size_ Case cases[] = { Case("PSA prot internal storage - Basic", case_its_setup_handler, pits_ps_test, case_its_teardown_handler), Case("PSA prot internal storage - Write-once", case_its_setup_handler, pits_ps_write_once_test, case_its_teardown_handler), -#if DEVICE_FLASH +#if COMPONENT_FLASHIAP Case("PSA protected storage - Basic", case_its_setup_handler, pits_ps_test), Case("PSA protected storage - Write-once", case_its_setup_handler, pits_ps_write_once_test) #endif diff --git a/platform/tests/TESTS/mbed_platform/crash_reporting/CMakeLists.txt b/platform/tests/TESTS/mbed_platform/crash_reporting/CMakeLists.txt index ffdfc932d52..0647c800607 100644 --- a/platform/tests/TESTS/mbed_platform/crash_reporting/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_platform/crash_reporting/CMakeLists.txt @@ -1,8 +1,10 @@ # Copyright (c) 2020-2021 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -if(NOT "MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED=1" IN_LIST MBED_CONFIG_DEFINITIONS) - set(TEST_SKIPPED "CRC is not supported for this target") +include(mbed_greentea) + +if(NOT DEFINED MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED) + set(TEST_SKIPPED "crash_reporting test not supported.") endif() mbed_greentea_add_test( diff --git a/platform/tests/TESTS/mbed_platform/stats_cpu/CMakeLists.txt b/platform/tests/TESTS/mbed_platform/stats_cpu/CMakeLists.txt index 30a96dd0c63..e0b456e2f52 100644 --- a/platform/tests/TESTS/mbed_platform/stats_cpu/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_platform/stats_cpu/CMakeLists.txt @@ -3,14 +3,11 @@ include(mbed_greentea) -if(NOT "DEVICE_LPTICKER=1" IN_LIST MBED_TARGET_DEFINITIONS OR NOT "DEVICE_SLEEP=1" IN_LIST MBED_TARGET_DEFINITIONS) +if(NOT DEFINED MBED_CPU_STATS_ENABLED OR NOT "DEVICE_LPTICKER=1" IN_LIST MBED_TARGET_DEFINITIONS + OR NOT "DEVICE_SLEEP=1" IN_LIST MBED_TARGET_DEFINITIONS) set(TEST_SKIPPED "Stats cpu test not supported.") endif() -if(NOT "MBED_CPU_STATS_ENABLED=1" IN_LIST MBED_CONFIG_DEFINITIONS) - set(TEST_SKIPPED "CPU stats not enabled") -endif() - mbed_greentea_add_test( TEST_NAME mbed-platform-stats-cpu diff --git a/platform/tests/TESTS/mbed_platform/stats_heap/CMakeLists.txt b/platform/tests/TESTS/mbed_platform/stats_heap/CMakeLists.txt index 9d59e0dd4be..1ca4a9c0f54 100644 --- a/platform/tests/TESTS/mbed_platform/stats_heap/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_platform/stats_heap/CMakeLists.txt @@ -3,11 +3,10 @@ include(mbed_greentea) -if(NOT "MBED_HEAP_STATS_ENABLED=1" IN_LIST MBED_CONFIG_DEFINITIONS) - set(TEST_SKIPPED "heap stats not enabled") +if(NOT DEFINED MBED_HEAP_STATS_ENABLED) + set(TEST_SKIPPED "Stats heap test not supported.") endif() - mbed_greentea_add_test( TEST_NAME mbed-platform-stats-heap diff --git a/platform/tests/TESTS/mbed_platform/stats_sys/CMakeLists.txt b/platform/tests/TESTS/mbed_platform/stats_sys/CMakeLists.txt index 84ea39c2cbe..0c94d801392 100644 --- a/platform/tests/TESTS/mbed_platform/stats_sys/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_platform/stats_sys/CMakeLists.txt @@ -3,8 +3,8 @@ include(mbed_greentea) -if(NOT "MBED_SYS_STATS_ENABLED=1" IN_LIST MBED_CONFIG_DEFINITIONS) - set(TEST_SKIPPED "System stats not enabled") +if(NOT DEFINED MBED_SYS_STATS_ENABLED) + set(TEST_SKIPPED "System stats test not supported.") endif() mbed_greentea_add_test( diff --git a/storage/kvstore/direct_access_devicekey/tests/TESTS/direct_access_devicekey/tdb/main.cpp b/storage/kvstore/direct_access_devicekey/tests/TESTS/direct_access_devicekey/tdb/main.cpp index 9698b521a8c..eb9a3c1a0f3 100644 --- a/storage/kvstore/direct_access_devicekey/tests/TESTS/direct_access_devicekey/tdb/main.cpp +++ b/storage/kvstore/direct_access_devicekey/tests/TESTS/direct_access_devicekey/tdb/main.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#ifndef DEVICE_FLASH +#ifndef COMPONENT_FLASHIAP #error [NOT_SUPPORTED] Target must have internal FlashIAP for this test #else @@ -323,4 +323,4 @@ int main() return !Harness::run(specification); } -#endif // DEVICE_FLASH +#endif // COMPONENT_FLASHIAP diff --git a/storage/kvstore/kv_config/CMakeLists.txt b/storage/kvstore/kv_config/CMakeLists.txt index 1e203875f31..a8b296dc2fa 100644 --- a/storage/kvstore/kv_config/CMakeLists.txt +++ b/storage/kvstore/kv_config/CMakeLists.txt @@ -26,7 +26,3 @@ target_link_libraries(mbed-storage-kv-config mbed-storage-littlefs-v2 mbed-storage-fat ) - -if("DEVICE_FLASH=1" IN_LIST MBED_TARGET_DEFINITIONS) - target_link_libraries(mbed-storage-kv-config PUBLIC mbed-storage-flashiap) -endif() \ No newline at end of file diff --git a/storage/kvstore/kv_config/source/kv_config.cpp b/storage/kvstore/kv_config/source/kv_config.cpp index 4891d225586..8f39a99e528 100644 --- a/storage/kvstore/kv_config/source/kv_config.cpp +++ b/storage/kvstore/kv_config/source/kv_config.cpp @@ -30,7 +30,7 @@ #include "securestore/SecureStore.h" #define TRACE_GROUP "KVCFG" -#if DEVICE_FLASH +#if COMPONENT_FLASHIAP #include "FlashIAPBlockDevice.h" #endif @@ -284,7 +284,7 @@ FileSystem *_get_filesystem_default(const char *mount) BlockDevice *_get_blockdevice_FLASHIAP(bd_addr_t start_address, bd_size_t size) { -#if DEVICE_FLASH +#if COMPONENT_FLASHIAP int ret = kv_get_flash_bounds_from_config(&start_address, &size); if (ret != 0) { tr_error("KV Config: Determination of internal block device bounds failed. The configured start address/size is likely invalid."); @@ -677,7 +677,7 @@ int _create_internal_tdb(BlockDevice **internal_bd, KVStore **internal_tdb, bd_s int _storage_config_TDB_INTERNAL() { -#if DEVICE_FLASH +#if COMPONENT_FLASHIAP bd_size_t internal_size = MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_SIZE; bd_addr_t internal_start_address = MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_BASE_ADDRESS; @@ -999,7 +999,7 @@ MBED_WEAK int kv_init_storage_config() int ret = MBED_SUCCESS; // We currently have no supported configuration without internal storage -#ifndef DEVICE_FLASH +#ifndef COMPONENT_FLASHIAP return MBED_ERROR_UNSUPPORTED; #endif @@ -1026,7 +1026,7 @@ int kv_get_default_flash_addresses(bd_addr_t *start_address, bd_size_t *size) { int ret = MBED_SUCCESS; -#if DEVICE_FLASH +#if COMPONENT_FLASHIAP FlashIAP flash; if (flash.init() != 0) { return MBED_ERROR_INITIALIZATION_FAILED; @@ -1072,7 +1072,7 @@ int kv_get_default_flash_addresses(bd_addr_t *start_address, bd_size_t *size) int kv_get_flash_bounds_from_config(bd_addr_t *start_address, bd_size_t *size) { -#if DEVICE_FLASH +#if COMPONENT_FLASHIAP bd_addr_t flash_end_address; bd_addr_t flash_start_address; diff --git a/storage/kvstore/tdbstore/source/TDBStore.cpp b/storage/kvstore/tdbstore/source/TDBStore.cpp index 8522ffbbdc7..50f490cf370 100644 --- a/storage/kvstore/tdbstore/source/TDBStore.cpp +++ b/storage/kvstore/tdbstore/source/TDBStore.cpp @@ -1490,6 +1490,7 @@ int TDBStore::check_erase_before_write(uint8_t area, uint32_t offset, uint32_t s uint32_t end_offset; while (size) { uint32_t dist, offset_from_start; + int ret; offset_in_erase_unit(area, offset, offset_from_start, dist); uint32_t chunk = std::min(size, dist); diff --git a/storage/kvstore/tests/TESTS/kvstore/general_tests_phase_1/main.cpp b/storage/kvstore/tests/TESTS/kvstore/general_tests_phase_1/main.cpp index f25a0643b4a..9d0cee060ed 100644 --- a/storage/kvstore/tests/TESTS/kvstore/general_tests_phase_1/main.cpp +++ b/storage/kvstore/tests/TESTS/kvstore/general_tests_phase_1/main.cpp @@ -99,7 +99,7 @@ static void kvstore_init() TEST_ASSERT_EQUAL_ERROR_CODE(0, res); if (kv_setup == TDBStoreSet) { -#if DEVICE_FLASH && !COMPONENT_SPIF && !COMPONENT_QSPIF && !COMPONENT_DATAFLASH && !COMPONENT_SD +#if COMPONENT_FLASHIAP && !COMPONENT_SPIF && !COMPONENT_QSPIF && !COMPONENT_DATAFLASH && !COMPONENT_SD // TDBStore requires two areas of equal size, do the check for FlashIAP TEST_SKIP_UNLESS(MBED_CONF_TARGET_INTERNAL_FLASH_UNIFORM_SECTORS || (MBED_CONF_FLASHIAP_BLOCK_DEVICE_SIZE != 0) && (MBED_CONF_FLASHIAP_BLOCK_DEVICE_BASE_ADDRESS != 0xFFFFFFFF)) diff --git a/storage/kvstore/tests/TESTS/kvstore/general_tests_phase_2/main.cpp b/storage/kvstore/tests/TESTS/kvstore/general_tests_phase_2/main.cpp index be99771f6c4..e6a407fd946 100644 --- a/storage/kvstore/tests/TESTS/kvstore/general_tests_phase_2/main.cpp +++ b/storage/kvstore/tests/TESTS/kvstore/general_tests_phase_2/main.cpp @@ -95,7 +95,7 @@ static void kvstore_init() TEST_ASSERT_EQUAL_ERROR_CODE(0, res); if (kv_setup == TDBStoreSet) { -#if DEVICE_FLASH && !COMPONENT_SPIF && !COMPONENT_QSPIF && !COMPONENT_DATAFLASH && !COMPONENT_SD +#if COMPONENT_FLASHIAP && !COMPONENT_SPIF && !COMPONENT_QSPIF && !COMPONENT_DATAFLASH && !COMPONENT_SD // TDBStore requires two areas of equal size TEST_SKIP_UNLESS(MBED_CONF_TARGET_INTERNAL_FLASH_UNIFORM_SECTORS || (MBED_CONF_FLASHIAP_BLOCK_DEVICE_SIZE != 0) && (MBED_CONF_FLASHIAP_BLOCK_DEVICE_BASE_ADDRESS != 0xFFFFFFFF)) diff --git a/storage/platform/CMakeLists.txt b/storage/platform/CMakeLists.txt index 3987e88b757..128e17729fe 100644 --- a/storage/platform/CMakeLists.txt +++ b/storage/platform/CMakeLists.txt @@ -14,27 +14,27 @@ list(APPEND mbed-storage-libs mbed-storage-littlefs-v2 ) -if("COMPONENT_DATAFLASH=1" IN_LIST MBED_TARGET_DEFINITIONS) +if("DATAFLASH" IN_LIST MBED_TARGET_LABELS) list(APPEND mbed-storage-libs mbed-storage-dataflash) endif() -if("DEVICE_FLASH=1" IN_LIST MBED_TARGET_DEFINITIONS) +if("FLASHIAP" IN_LIST MBED_TARGET_LABELS) list(APPEND mbed-storage-libs mbed-storage-flashiap) endif() -if("COMPONENT_QSPIF=1" IN_LIST MBED_TARGET_DEFINITIONS) +if("QSPIF" IN_LIST MBED_TARGET_LABELS) list(APPEND mbed-storage-libs mbed-storage-qspif) endif() -if("COMPONENT_OSPIF=1" IN_LIST MBED_TARGET_DEFINITIONS) +if("OSPIF" IN_LIST MBED_TARGET_LABELS) list(APPEND mbed-storage-libs mbed-storage-ospif) endif() -if("COMPONENT_SD=1" IN_LIST MBED_TARGET_DEFINITIONS) +if("SD" IN_LIST MBED_TARGET_LABELS) list(APPEND mbed-storage-libs mbed-storage-sd) endif() -if("COMPONENT_SPIF=1" IN_LIST MBED_TARGET_DEFINITIONS) +if("SPIF" IN_LIST MBED_TARGET_LABELS) list(APPEND mbed-storage-libs mbed-storage-spif) endif() diff --git a/storage/platform/source/PlatformStorage.cpp b/storage/platform/source/PlatformStorage.cpp index ba10a4f2d7f..2371dafc638 100644 --- a/storage/platform/source/PlatformStorage.cpp +++ b/storage/platform/source/PlatformStorage.cpp @@ -44,7 +44,7 @@ const spi_pinmap_t static_spi_pinmap = get_spi_pinmap(MBED_CONF_SD_SPI_MOSI, MBE #endif #endif -#if DEVICE_FLASH +#if COMPONENT_FLASHIAP #include "FlashIAPBlockDevice.h" #endif @@ -104,7 +104,7 @@ MBED_WEAK BlockDevice *BlockDevice::get_default_instance() return &default_bd; -#elif DEVICE_FLASH +#elif COMPONENT_FLASHIAP #if (MBED_CONF_FLASHIAP_BLOCK_DEVICE_SIZE == 0) && (MBED_CONF_FLASHIAP_BLOCK_DEVICE_BASE_ADDRESS == 0xFFFFFFFF) @@ -164,7 +164,7 @@ MBED_WEAK FileSystem *FileSystem::get_default_instance() return &sdcard; -#elif DEVICE_FLASH +#elif COMPONENT_FLASHIAP // To avoid alignment issues, initialize a filesystem if all sectors have the same size // OR the user has specified an address range From f07c588cf44b956e229066a33a0264416169f637 Mon Sep 17 00:00:00 2001 From: Jamie Smith Date: Fri, 4 Oct 2024 00:24:07 -0700 Subject: [PATCH 5/6] Don't require memory banks if not using an upload method --- tools/cmake/UploadMethodManager.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/cmake/UploadMethodManager.cmake b/tools/cmake/UploadMethodManager.cmake index 09d00f3d9d1..a52093b6d2c 100644 --- a/tools/cmake/UploadMethodManager.cmake +++ b/tools/cmake/UploadMethodManager.cmake @@ -43,8 +43,9 @@ if(NOT DEFINED MBED_UPLOAD_BASE_ADDR OR "${MBED_UPLOAD_BASE_ADDR}" STREQUAL "") if(MBED_CONFIG_DEFINITIONS MATCHES "MBED_CONFIGURED_ROM_START=(0x[0-9a-zA-Z]+)") set(MBED_UPLOAD_BASE_ADDR ${CMAKE_MATCH_1} CACHE STRING ${BASE_ADDR_DESCRIPTION}) else() - set(MBED_UPLOAD_BASE_ADDR "" CACHE STRING ${BASE_ADDR_DESCRIPTION}) - message(FATAL_ERROR "Since no ROM banks have been defined, you need to set the MBED_UPLOAD_BASE_ADDR option so we know where to upload code. NOTE: If you upgraded from an old version of Mbed CE and are getting this error, delete and reconfigure your CMake build directory.") + if(NOT ${UPLOAD_METHOD} STREQUAL "NONE") + message(FATAL_ERROR "Since no ROM banks have been defined, you need to set the MBED_UPLOAD_BASE_ADDR option so we know where to upload code. NOTE: If you upgraded from an old version of Mbed CE and are getting this error, delete and reconfigure your CMake build directory.") + endif() endif() endif() From 3fb87f874b3eed57ce8d1cb5f404e735cd65a625 Mon Sep 17 00:00:00 2001 From: Jamie Smith Date: Tue, 8 Oct 2024 09:01:16 -0700 Subject: [PATCH 6/6] Oops remove duplicate serial number --- tools/cmake/UploadMethodManager.cmake | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tools/cmake/UploadMethodManager.cmake b/tools/cmake/UploadMethodManager.cmake index a52093b6d2c..839c52814eb 100644 --- a/tools/cmake/UploadMethodManager.cmake +++ b/tools/cmake/UploadMethodManager.cmake @@ -49,10 +49,6 @@ if(NOT DEFINED MBED_UPLOAD_BASE_ADDR OR "${MBED_UPLOAD_BASE_ADDR}" STREQUAL "") endif() endif() - -set(MBED_UPLOAD_SERIAL_NUMBER "" CACHE STRING "Serial number of the Mbed board or the programming tool, for upload methods that select by serial number.") - - # ---------------------------------------------- # Load the upload method. # Upload methods are expected to refer to the following variables: