From b2d11fcf6ef229313a3233dfda66d3b598fb1b77 Mon Sep 17 00:00:00 2001 From: Jamie Smith Date: Mon, 14 Oct 2024 09:56:11 -0700 Subject: [PATCH] Reactivate some tests and functionality that had accidentally been disabled due to incorrect checks (#372) * Start on fixing some unintentionally skipped tests * Reactivate stats tests * CI fixes * Include cinttypes * Fault & crash data RAM working on STM32H7! --- .github/workflows/greentea_cmake.yml | 4 ++-- TESTS/configs/greentea_baremetal.json5 | 14 ++++++++++++++ TESTS/configs/greentea_full.json5 | 9 +++++++++ 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 +- platform/source/mbed_error.c | 7 +++++++ .../mbed_platform/crash_reporting/CMakeLists.txt | 6 ++---- .../TESTS/mbed_platform/stats_cpu/CMakeLists.txt | 7 +++++-- .../tests/TESTS/mbed_platform/stats_cpu/main.cpp | 8 ++++---- .../TESTS/mbed_platform/stats_heap/CMakeLists.txt | 5 +++-- .../TESTS/mbed_platform/stats_sys/CMakeLists.txt | 4 ++-- .../tests/TESTS/mbed_platform/stats_sys/main.cpp | 11 +++++++++++ .../mbed_platform/stats_thread/CMakeLists.txt | 4 ++-- .../TESTS/mbed_platform/stats_thread/main.cpp | 4 ++-- .../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 +++--- 24 files changed, 90 insertions(+), 44 deletions(-) create mode 100644 TESTS/configs/greentea_baremetal.json5 create mode 100644 TESTS/configs/greentea_full.json5 diff --git a/.github/workflows/greentea_cmake.yml b/.github/workflows/greentea_cmake.yml index 2866adeaa21..40d3c4aa8c2 100644 --- a/.github/workflows/greentea_cmake.yml +++ b/.github/workflows/greentea_cmake.yml @@ -146,12 +146,12 @@ jobs: # Note: We have to set a wifi network name and password so that the test will compile on devices that use wifi run: | rm -rf __build - cmake -S . -B __build -GNinja -DUPLOAD_METHOD=NONE -DMBED_GREENTEA_WIFI_SECURE_SSID=SomeNetwork -DMBED_GREENTEA_WIFI_SECURE_PASSWORD=SomePassword -DCMAKE_CTEST_ARGUMENTS="--output-on-failure;-V" -DMBED_BUILD_GREENTEA_TESTS=ON -DMBED_GREENTEA_TEST_BAREMETAL=ON -DMBED_GREENTEA_SERIAL_PORT=/dev/ttyDUMMY -DMBED_TARGET=${{ matrix.target }} -DMBED_APP_JSON_PATH=TESTS/configs/baremetal.json + cmake -S . -B __build -GNinja -DUPLOAD_METHOD=NONE -DMBED_GREENTEA_WIFI_SECURE_SSID=SomeNetwork -DMBED_GREENTEA_WIFI_SECURE_PASSWORD=SomePassword -DCMAKE_CTEST_ARGUMENTS="--output-on-failure;-V" -DMBED_BUILD_GREENTEA_TESTS=ON -DMBED_GREENTEA_TEST_BAREMETAL=ON -DMBED_GREENTEA_SERIAL_PORT=/dev/ttyDUMMY -DMBED_TARGET=${{ matrix.target }} -DMBED_APP_JSON_PATH=TESTS/configs/greentea_baremetal.json5 cmake --build __build - name: Build ${{ matrix.target }} with full profile if: ${{ matrix.profile == 'full' }} run: | rm -rf __build - cmake -S . -B __build -GNinja -DUPLOAD_METHOD=NONE -DMBED_GREENTEA_WIFI_SECURE_SSID=SomeNetwork -DMBED_GREENTEA_WIFI_SECURE_PASSWORD=SomePassword -DCMAKE_CTEST_ARGUMENTS="--output-on-failure;-V" -DMBED_BUILD_GREENTEA_TESTS=ON -DMBED_GREENTEA_SERIAL_PORT=/dev/ttyDUMMY -DMBED_TARGET=${{ matrix.target }} + cmake -S . -B __build -GNinja -DUPLOAD_METHOD=NONE -DMBED_GREENTEA_WIFI_SECURE_SSID=SomeNetwork -DMBED_GREENTEA_WIFI_SECURE_PASSWORD=SomePassword -DCMAKE_CTEST_ARGUMENTS="--output-on-failure;-V" -DMBED_BUILD_GREENTEA_TESTS=ON -DMBED_GREENTEA_SERIAL_PORT=/dev/ttyDUMMY -DMBED_TARGET=${{ matrix.target }} -DMBED_APP_JSON_PATH=TESTS/configs/greentea_full.json5 cmake --build __build diff --git a/TESTS/configs/greentea_baremetal.json5 b/TESTS/configs/greentea_baremetal.json5 new file mode 100644 index 00000000000..bae8f4d04c1 --- /dev/null +++ b/TESTS/configs/greentea_baremetal.json5 @@ -0,0 +1,14 @@ +{ + "target_overrides": { + "*": { + "target.c_lib": "small" + } + }, + "overrides": { + // Enable Mbed Stats tests + "platform.all-stats-enabled": 1, + + // Enable auto reboot on error, required for crash reporting test + "platform.fatal-error-auto-reboot-enabled": true + } +} diff --git a/TESTS/configs/greentea_full.json5 b/TESTS/configs/greentea_full.json5 new file mode 100644 index 00000000000..4d628da38cb --- /dev/null +++ b/TESTS/configs/greentea_full.json5 @@ -0,0 +1,9 @@ +{ + "overrides": { + // Enable Mbed Stats tests + "platform.all-stats-enabled": 1, + + // Enable auto reboot on error, required for crash reporting test + "platform.fatal-error-auto-reboot-enabled": true + } +} 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/source/mbed_error.c b/platform/source/mbed_error.c index af888012c7f..c26c5ead80a 100644 --- a/platform/source/mbed_error.c +++ b/platform/source/mbed_error.c @@ -320,6 +320,13 @@ WEAK MBED_NORETURN mbed_error_status_t mbed_error(mbed_error_status_t error_stat //Protect report_error_ctx while we update it core_util_critical_section_enter(); report_error_ctx = last_error_ctx; + + // If the MCU has a data cache, ensure that the fault data is flushed to main memory + // before reboot +#if __DCACHE_PRESENT + SCB_CleanDCache_by_Addr(&report_error_ctx, sizeof(mbed_crash_data_t)); +#endif + core_util_critical_section_exit(); //We need not call delete_mbed_crc(crc_obj) here as we are going to reset the system anyway, and calling delete while handling a fatal error may cause nested exception #if MBED_CONF_PLATFORM_FATAL_ERROR_AUTO_REBOOT_ENABLED && (MBED_CONF_PLATFORM_ERROR_REBOOT_MAX > 0) 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..89c3a9a0376 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) AND (NOT "MBED_ALL_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_cpu/main.cpp b/platform/tests/TESTS/mbed_platform/stats_cpu/main.cpp index 1af55048970..847022f0962 100644 --- a/platform/tests/TESTS/mbed_platform/stats_cpu/main.cpp +++ b/platform/tests/TESTS/mbed_platform/stats_cpu/main.cpp @@ -39,8 +39,8 @@ DigitalOut led1(LED1); #define MAX_THREAD_STACK 384 #endif -#define SAMPLE_TIME 1000 // msec -#define LOOP_TIME 2000 // msec +#define SAMPLE_TIME 1s +#define LOOP_TIME 2s static int32_t wait_time = 5000; @@ -64,7 +64,7 @@ void get_cpu_usage() while (1) { mbed_stats_cpu_get(&stats); uint64_t diff = (stats.idle_time - prev_idle_time); - uint8_t usage = 100 - ((diff * 100) / (SAMPLE_TIME * 1000)); + uint8_t usage = 100 - ((diff * 100) / std::chrono::duration_cast(SAMPLE_TIME).count()); prev_idle_time = stats.idle_time; TEST_ASSERT_NOT_EQUAL(0, usage); ThisThread::sleep_for(SAMPLE_TIME); @@ -76,7 +76,7 @@ void test_cpu_info(void) mbed_stats_cpu_t stats; // Additional read to make sure timer is initialized mbed_stats_cpu_get(&stats); - ThisThread::sleep_for(3); + ThisThread::sleep_for(3ms); mbed_stats_cpu_get(&stats); TEST_ASSERT_NOT_EQUAL(0, stats.uptime); TEST_ASSERT_NOT_EQUAL(0, stats.idle_time); diff --git a/platform/tests/TESTS/mbed_platform/stats_heap/CMakeLists.txt b/platform/tests/TESTS/mbed_platform/stats_heap/CMakeLists.txt index 1ca4a9c0f54..543dbfb6347 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) AND (NOT "MBED_ALL_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..fe5f0f566f5 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) AND (NOT "MBED_ALL_STATS_ENABLED=1" IN_LIST MBED_CONFIG_DEFINITIONS)) + set(TEST_SKIPPED "System stats not enabled") endif() mbed_greentea_add_test( diff --git a/platform/tests/TESTS/mbed_platform/stats_sys/main.cpp b/platform/tests/TESTS/mbed_platform/stats_sys/main.cpp index 2ed7424e281..23429b8b523 100644 --- a/platform/tests/TESTS/mbed_platform/stats_sys/main.cpp +++ b/platform/tests/TESTS/mbed_platform/stats_sys/main.cpp @@ -22,6 +22,8 @@ #include "mbed.h" +#include + #if !defined(MBED_SYS_STATS_ENABLED) #error [NOT_SUPPORTED] test not supported #else @@ -33,6 +35,15 @@ void test_sys_info() mbed_stats_sys_t stats; mbed_stats_sys_get(&stats); + // Print a summary of the stats, just for debug purposes + printf("Dump of Mbed System Stats: -------------------------------------\n"); + printf("- OS Version: %" PRIu32 ".%" PRIu32 ".%" PRIu32 "\n", + stats.os_version / 10000, + (stats.os_version % 10000) / 100, + ((stats.os_version % 10000) % 100)); + printf("- CPUID Register: 0x%" PRIx32 "\n", stats.cpu_id); + printf("- Compiler Version: %" PRIu32 "\n", stats.compiler_version); + TEST_ASSERT_NOT_EQUAL(0, stats.os_version); #if defined(__CORTEX_M) TEST_ASSERT_NOT_EQUAL(0, stats.cpu_id); diff --git a/platform/tests/TESTS/mbed_platform/stats_thread/CMakeLists.txt b/platform/tests/TESTS/mbed_platform/stats_thread/CMakeLists.txt index 4a830ed41bc..c5d7d09b9c4 100644 --- a/platform/tests/TESTS/mbed_platform/stats_thread/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_platform/stats_thread/CMakeLists.txt @@ -3,8 +3,8 @@ include(mbed_greentea) -if(NOT DEFINED MBED_THREAD_STATS_ENABLED) - set(TEST_SKIPPED "Thread stats test not supported.") +if((NOT "MBED_THREAD_STATS_ENABLED=1" IN_LIST MBED_CONFIG_DEFINITIONS) AND (NOT "MBED_ALL_STATS_ENABLED=1" IN_LIST MBED_CONFIG_DEFINITIONS)) + set(TEST_SKIPPED "Thread stats not enabled") endif() mbed_greentea_add_test( diff --git a/platform/tests/TESTS/mbed_platform/stats_thread/main.cpp b/platform/tests/TESTS/mbed_platform/stats_thread/main.cpp index f1e386a9e27..742c78438e8 100644 --- a/platform/tests/TESTS/mbed_platform/stats_thread/main.cpp +++ b/platform/tests/TESTS/mbed_platform/stats_thread/main.cpp @@ -47,7 +47,7 @@ void increment_with_delay() { while (1) { counter++; - ThisThread::sleep_for(500); + ThisThread::sleep_for(500ms); } } @@ -112,7 +112,7 @@ void test_case_multi_threads_blocked() uint32_t ret = ef.set(FLAG_SIGNAL_DEC); TEST_ASSERT_FALSE(ret & osFlagsError); - ThisThread::sleep_for(100); + ThisThread::sleep_for(100ms); count = mbed_stats_thread_get_each(stats, MAX_THREAD_STATS); TEST_ASSERT_EQUAL(1, (count - old_count)); 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