diff --git a/TESTS/mbed_drivers/timer/main.cpp b/TESTS/mbed_drivers/timer/main.cpp index 76f2842256..d94ef6b686 100644 --- a/TESTS/mbed_drivers/timer/main.cpp +++ b/TESTS/mbed_drivers/timer/main.cpp @@ -45,9 +45,15 @@ extern uint32_t SystemCoreClock; * 1000 ms delay: tolerance = 20500 us * * */ -#define DELTA_US(delay_ms) (500 + (delay_ms) * US_PER_MSEC / 50) -#define DELTA_MS(delay_ms) (1 + ((delay_ms) * US_PER_MSEC / 50 / US_PER_MSEC)) -#define DELTA_S(delay_ms) (0.000500f + (((float)(delay_ms)) / MSEC_PER_SEC / 50)) +#ifdef NO_SYSTICK +#define TOLERANCE 5 +#else +#define TOLERANCE 2 +#endif + +#define DELTA_US(delay_ms) (500 + (delay_ms) * US_PER_MSEC * TOLERANCE / 100) +#define DELTA_MS(delay_ms) (1 + (delay_ms) * TOLERANCE / 100) +#define DELTA_S(delay_ms) (0.000500f + ((float)(delay_ms)) * ((float)(TOLERANCE) / 100.f) / MSEC_PER_SEC) #define TICKER_FREQ_1MHZ 1000000 #define TICKER_BITS 32 diff --git a/TESTS/mbed_hal/common_tickers/main.cpp b/TESTS/mbed_hal/common_tickers/main.cpp index 007f74de04..b63df92c0c 100644 --- a/TESTS/mbed_hal/common_tickers/main.cpp +++ b/TESTS/mbed_hal/common_tickers/main.cpp @@ -344,20 +344,34 @@ void ticker_increment_test(void) } else { // high frequency tickers uint32_t num_of_cycles = NUM_OF_CYCLES; + const uint32_t repeat_count = 20; + const uint32_t max_inc_val = 100; uint32_t base_tick_count = count_ticks(num_of_cycles, 1); uint32_t next_tick_count = base_tick_count; uint32_t inc_val = 0; + uint32_t repeat_cnt = 0; - while (inc_val < 100) { - + while (inc_val < max_inc_val) { next_tick_count = count_ticks(num_of_cycles + inc_val, 1); if (next_tick_count == base_tick_count) { - /* Same tick count, so increase num of cycles. */ - inc_val++; + /* Same tick count, so repeat 20 times and than + * increase num of cycles by 1. + */ + if (repeat_cnt == repeat_count) { + inc_val++; + repeat_cnt = 0; + } + + repeat_cnt++; } else { + /* Check if we got 1 tick diff. */ + if (next_tick_count - base_tick_count == 1 || + base_tick_count - next_tick_count == 1) { + break; + } /* It is possible that the difference between base and next * tick count on some platforms is greater that 1, in this case we need @@ -366,12 +380,8 @@ void ticker_increment_test(void) */ num_of_cycles /= 2; inc_val = 0; + repeat_cnt = 0; base_tick_count = count_ticks(num_of_cycles, 1); - - if (next_tick_count - base_tick_count == 1 || - base_tick_count - next_tick_count == 1) { - break; - } } } diff --git a/TESTS/mbed_platform/stats_sys/main.cpp b/TESTS/mbed_platform/stats_sys/main.cpp index 3915499b28..a9949d67db 100644 --- a/TESTS/mbed_platform/stats_sys/main.cpp +++ b/TESTS/mbed_platform/stats_sys/main.cpp @@ -32,10 +32,6 @@ void test_sys_info() mbed_stats_sys_t stats; mbed_stats_sys_get(&stats); -#if defined(MBED_VERSION) - TEST_ASSERT_NOT_EQUAL(0, stats.os_version); -#endif - #if defined(__CORTEX_M) TEST_ASSERT_NOT_EQUAL(0, stats.cpu_id); #endif diff --git a/cmsis/RTE_Components.h b/cmsis/RTE_Components.h index 4f377cf671..f29a772109 100644 --- a/cmsis/RTE_Components.h +++ b/cmsis/RTE_Components.h @@ -18,7 +18,9 @@ #define CMSIS_device_header +#if defined(MBED_CONF_RTOS_PRESENT) #include "mbed_rtx_conf.h" +#endif #include "mbed_cmsis_conf.h" #endif diff --git a/features/FEATURE_BLE/ble/generic/SecurityDb.h b/features/FEATURE_BLE/ble/generic/SecurityDb.h index b8c2ea25c8..2f75def80f 100644 --- a/features/FEATURE_BLE/ble/generic/SecurityDb.h +++ b/features/FEATURE_BLE/ble/generic/SecurityDb.h @@ -584,7 +584,7 @@ public: WhitelistDbCb_t cb, ::Gap::Whitelist_t *whitelist ) { - for (size_t i = 0; i < get_entry_count() && i < whitelist->capacity; i++) { + for (size_t i = 0; i < get_entry_count() && whitelist->size < whitelist->capacity; i++) { entry_handle_t db_handle = get_entry_handle_by_index(i); SecurityDistributionFlags_t* flags = get_distribution_flags(db_handle); @@ -592,20 +592,24 @@ public: continue; } - if (flags->peer_address_is_public) { - whitelist->addresses[i].type = BLEProtocol::AddressType::PUBLIC; - } else { - whitelist->addresses[i].type = BLEProtocol::AddressType::RANDOM_STATIC; + SecurityEntryIdentity_t* identity = read_in_entry_peer_identity(db_handle); + if (!identity) { + continue; } - SecurityEntryIdentity_t* identity = read_in_entry_peer_identity(db_handle); - if (identity) { - memcpy( - whitelist->addresses[i].address, - identity->identity_address.data(), - sizeof(BLEProtocol::AddressBytes_t) - ); + memcpy( + whitelist->addresses[whitelist->size].address, + identity->identity_address.data(), + sizeof(BLEProtocol::AddressBytes_t) + ); + + if (flags->peer_address_is_public) { + whitelist->addresses[whitelist->size].type = BLEProtocol::AddressType::PUBLIC; + } else { + whitelist->addresses[whitelist->size].type = BLEProtocol::AddressType::RANDOM_STATIC; } + + whitelist->size++; } cb(whitelist); diff --git a/features/FEATURE_BLE/source/generic/GenericSecurityManager.cpp b/features/FEATURE_BLE/source/generic/GenericSecurityManager.cpp index 7a12d12fa6..d05b6f68b9 100644 --- a/features/FEATURE_BLE/source/generic/GenericSecurityManager.cpp +++ b/features/FEATURE_BLE/source/generic/GenericSecurityManager.cpp @@ -142,6 +142,9 @@ ble_error_t GenericSecurityManager::purgeAllBondingState(void) { ble_error_t GenericSecurityManager::generateWhitelistFromBondTable(Gap::Whitelist_t *whitelist) const { if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE; if (eventHandler) { + if (!whitelist) { + return BLE_ERROR_INVALID_PARAM; + } _db->generate_whitelist_from_bond_table( mbed::callback(eventHandler, &::SecurityManager::EventHandler::whitelistFromBondTable), whitelist diff --git a/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF51/source/nRF5xGap.cpp b/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF51/source/nRF5xGap.cpp index a80744df11..ac5b5404c5 100644 --- a/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF51/source/nRF5xGap.cpp +++ b/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF51/source/nRF5xGap.cpp @@ -1266,7 +1266,7 @@ void nRF5xGap::on_connection(Gap::Handle_t handle, const ble_gap_evt_connected_t const resolving_list_entry_t* entry = get_sm().resolve_address( evt.peer_addr.addr ); - MBED_ASSERT(entry == NULL); + MBED_ASSERT(entry != NULL); peer_addr_type = convert_identity_address(entry->peer_identity_address_type); peer_address = entry->peer_identity_address.data(); diff --git a/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF52/source/nRF5xCrypto.cpp b/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF52/source/nRF5xCrypto.cpp index b555b0dc33..8b8c57474e 100644 --- a/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF52/source/nRF5xCrypto.cpp +++ b/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF52/source/nRF5xCrypto.cpp @@ -47,6 +47,7 @@ namespace vendor { namespace nordic { CryptoToolbox::CryptoToolbox() : _initialized(false) { + mbedtls_platform_setup(&_platform_context); mbedtls_entropy_init(&_entropy_context); mbedtls_ecp_group_init(&_group); int err = mbedtls_ecp_group_load( @@ -59,6 +60,7 @@ CryptoToolbox::CryptoToolbox() : _initialized(false) { CryptoToolbox::~CryptoToolbox() { mbedtls_ecp_group_free(&_group); mbedtls_entropy_free(&_entropy_context); + mbedtls_platform_teardown(&_platform_context); } bool CryptoToolbox::generate_keys( diff --git a/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF52/source/nRF5xCrypto.h b/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF52/source/nRF5xCrypto.h index 35c56a875e..7a522e2222 100644 --- a/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF52/source/nRF5xCrypto.h +++ b/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF52/source/nRF5xCrypto.h @@ -132,6 +132,7 @@ private: void swap_endian(uint8_t* buf, size_t len); bool _initialized; + mbedtls_platform_context _platform_context; mbedtls_entropy_context _entropy_context; mbedtls_ecp_group _group; }; diff --git a/features/FEATURE_UVISOR/includes/uvisor/api/inc/uvisor_deprecation.h b/features/FEATURE_UVISOR/includes/uvisor/api/inc/uvisor_deprecation.h index d13d9e06c6..901d977da9 100644 --- a/features/FEATURE_UVISOR/includes/uvisor/api/inc/uvisor_deprecation.h +++ b/features/FEATURE_UVISOR/includes/uvisor/api/inc/uvisor_deprecation.h @@ -18,7 +18,8 @@ #define __UVISOR_DEPRECATION_H__ #if defined(UVISOR_PRESENT) && UVISOR_PRESENT == 1 -#warning "Warning: You are using FEATURE_UVISOR, which is unsupported as of Mbed OS 5.9." +#warning "Warning: uVisor is superseded by the Secure Partition Manager (SPM) defined in the ARM Platform Security Architecture (PSA). \ + uVisor is deprecated as of Mbed OS 5.10, and being replaced by a native PSA-compliant implementation of SPM." #endif #endif // __UVISOR_DEPRECATION_H__ diff --git a/features/cryptocell/FEATURE_CRYPTOCELL310/TARGET_MCU_NRF52840/TOOLCHAIN_ARM/libnrf_cc310_ext_softfp_0.9.9.a b/features/cryptocell/FEATURE_CRYPTOCELL310/TARGET_MCU_NRF52840/TOOLCHAIN_ARM/libnrf_cc310_ext_softfp_0.9.9.a deleted file mode 100644 index c1e7d82cb8..0000000000 Binary files a/features/cryptocell/FEATURE_CRYPTOCELL310/TARGET_MCU_NRF52840/TOOLCHAIN_ARM/libnrf_cc310_ext_softfp_0.9.9.a and /dev/null differ diff --git a/features/cryptocell/FEATURE_CRYPTOCELL310/TARGET_MCU_NRF52840/TOOLCHAIN_ARM/libnrf_cc310_trng_softfp_0.9.9.a b/features/cryptocell/FEATURE_CRYPTOCELL310/TARGET_MCU_NRF52840/TOOLCHAIN_ARM/libnrf_cc310_trng_softfp_0.9.9.a deleted file mode 100644 index 33f394b89a..0000000000 Binary files a/features/cryptocell/FEATURE_CRYPTOCELL310/TARGET_MCU_NRF52840/TOOLCHAIN_ARM/libnrf_cc310_trng_softfp_0.9.9.a and /dev/null differ diff --git a/features/cryptocell/FEATURE_CRYPTOCELL310/binaries/TOOLCHAIN_ARM/libnrf_cc310_core_softfp_0.9.9.a b/features/cryptocell/FEATURE_CRYPTOCELL310/binaries/TOOLCHAIN_ARM/libnrf_cc310_core_softfp_0.9.9.a deleted file mode 100644 index 69020fe855..0000000000 Binary files a/features/cryptocell/FEATURE_CRYPTOCELL310/binaries/TOOLCHAIN_ARM/libnrf_cc310_core_softfp_0.9.9.a and /dev/null differ diff --git a/features/cryptocell/FEATURE_CRYPTOCELL310/binaries/TOOLCHAIN_GCC_ARM/libcc_310_core.a.mod b/features/cryptocell/FEATURE_CRYPTOCELL310/binaries/TOOLCHAIN_GCC_ARM/libcc_310_core.a.mod deleted file mode 100644 index a644c59f6a..0000000000 Binary files a/features/cryptocell/FEATURE_CRYPTOCELL310/binaries/TOOLCHAIN_GCC_ARM/libcc_310_core.a.mod and /dev/null differ diff --git a/features/cryptocell/FEATURE_CRYPTOCELL310/binaries/TOOLCHAIN_GCC_ARM/libcc_310_core.a~31bb423e11968b6c6cfbd1735561b06af3862622 b/features/cryptocell/FEATURE_CRYPTOCELL310/binaries/TOOLCHAIN_GCC_ARM/libcc_310_core.a~31bb423e11968b6c6cfbd1735561b06af3862622 deleted file mode 100644 index 4d0d895777..0000000000 Binary files a/features/cryptocell/FEATURE_CRYPTOCELL310/binaries/TOOLCHAIN_GCC_ARM/libcc_310_core.a~31bb423e11968b6c6cfbd1735561b06af3862622 and /dev/null differ diff --git a/platform/mbed_error.c b/platform/mbed_error.c index 712a1e8d25..935290e8c4 100644 --- a/platform/mbed_error.c +++ b/platform/mbed_error.c @@ -51,6 +51,7 @@ static mbed_error_ctx first_error_ctx = {0}; static mbed_error_ctx last_error_ctx = {0}; static mbed_error_hook_t error_hook = NULL; static void print_error_report(mbed_error_ctx *ctx, const char *); +static mbed_error_status_t handle_error(mbed_error_status_t error_status, unsigned int error_value, const char *filename, int line_number); //Helper function to halt the system static void mbed_halt_system(void) @@ -72,20 +73,23 @@ WEAK void error(const char* format, ...) { if (error_in_progress) { return; } + + //Call handle_error/print_error_report permanently setting error_in_progress flag + handle_error(MBED_ERROR_UNKNOWN, 0, NULL, 0); + print_error_report(&last_error_ctx, "Fatal Run-time error"); error_in_progress = 1; #ifndef NDEBUG va_list arg; va_start(arg, format); mbed_error_vfprintf(format, arg); - MBED_ERROR(MBED_ERROR_UNKNOWN, "Fatal Run-time Error"); va_end(arg); #endif exit(1); } //Set an error status with the error handling system -mbed_error_status_t handle_error(mbed_error_status_t error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number) +static mbed_error_status_t handle_error(mbed_error_status_t error_status, unsigned int error_value, const char *filename, int line_number) { mbed_error_ctx current_error_ctx; @@ -129,16 +133,10 @@ mbed_error_status_t handle_error(mbed_error_status_t error_status, const char *e #ifdef MBED_CONF_ERROR_FILENAME_CAPTURE_ENABLED //Capture filename/linenumber if provided - //Index for tracking error_filename - int idx = 0; - - if(NULL != filename) { - while(idx < MBED_CONF_MAX_ERROR_FILENAME_LEN && (filename[idx] != '\0')) { - current_error_ctx.error_filename[idx] = filename[idx]; - idx++; - } - current_error_ctx.error_line_number = line_number; - } + //Index for tracking error_filename + memset(¤t_error_ctx.error_filename, 0, MBED_CONF_MAX_ERROR_FILENAME_LEN); + strncpy(current_error_ctx.error_filename, filename, MBED_CONF_MAX_ERROR_FILENAME_LEN); + current_error_ctx.error_line_number = line_number; #endif //Capture the fist system error and store it @@ -188,14 +186,14 @@ int mbed_get_error_count(void) //Sets a fatal error mbed_error_status_t mbed_warning(mbed_error_status_t error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number) { - return handle_error(error_status, error_msg, error_value, filename, line_number); + return handle_error(error_status, error_value, filename, line_number); } //Sets a fatal error WEAK mbed_error_status_t mbed_error(mbed_error_status_t error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number) { //set the error reported and then halt the system - if( MBED_SUCCESS != handle_error(error_status, error_msg, error_value, filename, line_number) ) + if( MBED_SUCCESS != handle_error(error_status, error_value, filename, line_number) ) return MBED_ERROR_FAILED_OPERATION; //On fatal errors print the error context/report @@ -359,7 +357,7 @@ static void print_error_report(mbed_error_ctx *ctx, const char *error_msg) uint32_t error_code = MBED_GET_ERROR_CODE(ctx->error_status); uint32_t error_module = MBED_GET_ERROR_MODULE(ctx->error_status); - mbed_error_printf("\n\n++ MbedOS Error Info ++\nError Status: 0x%x Code: %d Entity: %d\nError Message: ", ctx->error_status, error_code, error_module); + mbed_error_printf("\n\n++ MbedOS Error Info ++\nError Status: 0x%x Code: %d Module: %d\nError Message: ", ctx->error_status, error_code, error_module); //Report error info based on error code, some errors require different //error_vals[1] contains the error code @@ -410,12 +408,10 @@ static void print_error_report(mbed_error_ctx *ctx, const char *error_msg) } mbed_error_printf(error_msg, NULL); mbed_error_printf("\nLocation: 0x%x", ctx->error_address); -#ifdef MBED_CONF_ERROR_FILENAME_CAPTURE_ENABLED - if(NULL != error_ctx->error_filename) { +#if defined(MBED_CONF_ERROR_FILENAME_CAPTURE_ENABLED) && !defined(NDEBUG) + if(NULL != ctx->error_filename) { //for string, we must pass address of a ptr which has the address of the string - uint32_t *file_name = (uint32_t *)&error_ctx->error_filename[0]; - mbed_error_printf("\nFile:%s", &file_name); - mbed_error_printf("+0x%x", ctx->error_line_number); + mbed_error_printf("\nFile:%s+%d", ctx->error_filename, ctx->error_line_number); } #endif @@ -429,7 +425,7 @@ static void print_error_report(mbed_error_ctx *ctx, const char *error_msg) #endif //TARGET_CORTEX_M } - mbed_error_printf("\n-- MbedOS Error Info --"); + mbed_error_printf("\n-- MbedOS Error Info --\n"); } diff --git a/platform/mbed_error.h b/platform/mbed_error.h index 203c89b14c..b266baf03b 100644 --- a/platform/mbed_error.h +++ b/platform/mbed_error.h @@ -143,12 +143,17 @@ typedef int mbed_error_status_t; * Since this macro is a wrapper for mbed_warning API callers should process the return value from this macro which is the return value from calling mbed_error API. * */ -#ifdef MBED_CONF_ERROR_FILENAME_CAPTURE_ENABLED - #define MBED_WARNING1( error_status, error_msg, error_value ) mbed_warning( error_status, (const char *)error_msg, (uint32_t)error_value, (const char *)MBED_FILENAME, __LINE__ ) - #define MBED_WARNING( error_status, error_msg ) mbed_warning( error_status, (const char *)error_msg, (uint32_t)0 , (const char *)MBED_FILENAME, __LINE__ ) +#ifdef NDEBUG + #define MBED_WARNING1( error_status, error_msg, error_value ) mbed_warning( error_status, (const char *)NULL, (uint32_t)error_value, NULL, 0 ) + #define MBED_WARNING( error_status, error_msg ) mbed_warning( error_status, (const char *)NULL, (uint32_t)0, NULL, 0 ) #else - #define MBED_WARNING1( error_status, error_msg, error_value ) mbed_warning( error_status, (const char *)error_msg, (uint32_t)error_value, NULL, 0 ) - #define MBED_WARNING( error_status, error_msg ) mbed_warning( error_status, (const char *)error_msg, (uint32_t)0, NULL, 0 ) + #if defined(MBED_CONF_ERROR_FILENAME_CAPTURE_ENABLED) + #define MBED_WARNING1( error_status, error_msg, error_value ) mbed_warning( error_status, (const char *)error_msg, (uint32_t)error_value, (const char *)MBED_FILENAME, __LINE__ ) + #define MBED_WARNING( error_status, error_msg ) mbed_warning( error_status, (const char *)error_msg, (uint32_t)0 , (const char *)MBED_FILENAME, __LINE__ ) + #else + #define MBED_WARNING1( error_status, error_msg, error_value ) mbed_warning( error_status, (const char *)error_msg, (uint32_t)error_value, NULL, 0 ) + #define MBED_WARNING( error_status, error_msg ) mbed_warning( error_status, (const char *)error_msg, (uint32_t)0, NULL, 0 ) + #endif #endif /** @@ -170,13 +175,18 @@ typedef int mbed_error_status_t; * Since this macro is a wrapper for mbed_error API callers should process the return value from this macro which is the return value from calling mbed_error API. * */ -#ifdef MBED_CONF_ERROR_FILENAME_CAPTURE_ENABLED - #define MBED_ERROR1( error_status, error_msg, error_value ) mbed_error( error_status, (const char *)error_msg, (uint32_t)error_value, (const char *)MBED_FILENAME, __LINE__ ) - #define MBED_ERROR( error_status, error_msg ) mbed_error( error_status, (const char *)error_msg, (uint32_t)0 , (const char *)MBED_FILENAME, __LINE__ ) +#ifdef NDEBUG + #define MBED_ERROR1( error_status, error_msg, error_value ) mbed_error( error_status, (const char *)NULL, (uint32_t)error_value, NULL, 0 ) + #define MBED_ERROR( error_status, error_msg ) mbed_error( error_status, (const char *)NULL, (uint32_t)0 , NULL, 0 ) #else - #define MBED_ERROR1( error_status, error_msg, error_value ) mbed_error( error_status, (const char *)error_msg, (uint32_t)error_value, NULL, 0 ) - #define MBED_ERROR( error_status, error_msg ) mbed_error( error_status, (const char *)error_msg, (uint32_t)0 , NULL, 0 ) -#endif + #if defined(MBED_CONF_ERROR_FILENAME_CAPTURE_ENABLED) + #define MBED_ERROR1( error_status, error_msg, error_value ) mbed_error( error_status, (const char *)error_msg, (uint32_t)error_value, (const char *)MBED_FILENAME, __LINE__ ) + #define MBED_ERROR( error_status, error_msg ) mbed_error( error_status, (const char *)error_msg, (uint32_t)0 , (const char *)MBED_FILENAME, __LINE__ ) + #else + #define MBED_ERROR1( error_status, error_msg, error_value ) mbed_error( error_status, (const char *)error_msg, (uint32_t)error_value, NULL, 0 ) + #define MBED_ERROR( error_status, error_msg ) mbed_error( error_status, (const char *)error_msg, (uint32_t)0 , NULL, 0 ) + #endif +#endif //Error Type definition /** mbed_error_type_t definition diff --git a/platform/mbed_stats.c b/platform/mbed_stats.c index beaac014ce..6886ed30d2 100644 --- a/platform/mbed_stats.c +++ b/platform/mbed_stats.c @@ -123,9 +123,6 @@ void mbed_stats_sys_get(mbed_stats_sys_t *stats) memset(stats, 0, sizeof(mbed_stats_sys_t)); #if defined(MBED_SYS_STATS_ENABLED) -#if defined(MBED_VERSION) - stats->os_version = MBED_VERSION; -#endif #if defined(__CORTEX_M) stats->cpu_id = SCB->CPUID; #endif diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/device/TOOLCHAIN_ARM_STD/nRF52832.sct b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/device/TOOLCHAIN_ARM_STD/nRF52832.sct index 2bdba912a1..79b56745a3 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/device/TOOLCHAIN_ARM_STD/nRF52832.sct +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/device/TOOLCHAIN_ARM_STD/nRF52832.sct @@ -27,6 +27,11 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE { ER_IROM1 MBED_APP_START MBED_APP_SIZE { *.o (RESET, +First) *(InRoot$$Sections) + __start_sdh_soc_observers *(sdh_soc_observers) __stop_sdh_soc_observers + __start_sdh_stack_observers *(sdh_stack_observers) __stop_sdh_stack_observers + __start_sdh_req_observers *(sdh_req_observers) __stop_sdh_req_observers + __start_sdh_state_observers *(sdh_state_observers) __stop_sdh_state_observers + __start_sdh_ble_observers *(sdh_ble_observers) __stop_sdh_ble_observers .ANY (+RO) } RW_IRAM0 MBED_RAM0_START UNINIT MBED_RAM0_SIZE { ;no init section diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/device/TOOLCHAIN_ARM_STD/nRF52840.sct b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/device/TOOLCHAIN_ARM_STD/nRF52840.sct index 8aaa8a42ba..769b9212e4 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/device/TOOLCHAIN_ARM_STD/nRF52840.sct +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/device/TOOLCHAIN_ARM_STD/nRF52840.sct @@ -27,6 +27,11 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE { ER_IROM1 MBED_APP_START MBED_APP_SIZE { *.o (RESET, +First) *(InRoot$$Sections) + __start_sdh_soc_observers *(sdh_soc_observers) __stop_sdh_soc_observers + __start_sdh_stack_observers *(sdh_stack_observers) __stop_sdh_stack_observers + __start_sdh_req_observers *(sdh_req_observers) __stop_sdh_req_observers + __start_sdh_state_observers *(sdh_state_observers) __stop_sdh_state_observers + __start_sdh_ble_observers *(sdh_ble_observers) __stop_sdh_ble_observers .ANY (+RO) } RW_IRAM0 MBED_RAM0_START UNINIT MBED_RAM0_SIZE { ;no init section diff --git a/targets/TARGET_NXP/TARGET_LPC176X/TARGET_UBLOX_C027/ublox_low_level_api.c b/targets/TARGET_NXP/TARGET_LPC176X/TARGET_UBLOX_C027/ublox_low_level_api.c index b033d29e1e..dae2ccfb80 100644 --- a/targets/TARGET_NXP/TARGET_LPC176X/TARGET_UBLOX_C027/ublox_low_level_api.c +++ b/targets/TARGET_NXP/TARGET_LPC176X/TARGET_UBLOX_C027/ublox_low_level_api.c @@ -42,6 +42,7 @@ void ublox_mdm_init(void) // Can't use wait_ms() as RTOS isn't initialised yet //wait_ms(50); // when USB cable is inserted the interface chip issues // Here's the code from the non-RTOS version + us_ticker_init(); uint32_t start = us_ticker_read(); while ((us_ticker_read() - start) < 50000); } diff --git a/tools/build.py b/tools/build.py index f88bf339b9..52d8810eff 100644 --- a/tools/build.py +++ b/tools/build.py @@ -184,7 +184,7 @@ if __name__ == '__main__': skipped.append(tt_id) else: try: - notify = TerminalNotifer(options.verbose, options.silent) + notifier = TerminalNotifier(options.verbose, options.silent) mcu = TARGET_MAP[target] profile = extract_profile(parser, options, toolchain) if options.source_dir: @@ -197,6 +197,7 @@ if __name__ == '__main__': name=options.artifact_name, build_profile=profile, ignore=options.ignore, + notify = notifier, ) else: lib_build_res = build_mbed_libs( @@ -206,6 +207,7 @@ if __name__ == '__main__': macros=options.macros, build_profile=profile, ignore=options.ignore, + notify=notifier, ) for lib_id in libraries: diff --git a/tools/build_api.py b/tools/build_api.py index b2247fe264..cb2c0eaa76 100644 --- a/tools/build_api.py +++ b/tools/build_api.py @@ -458,8 +458,7 @@ def merge_region_list(region_list, destination, notify, padding=b'\xFF'): makedirs(dirname(destination)) notify.info("Space used after regions merged: 0x%x" % (merged.maxaddr() - merged.minaddr() + 1)) - with open(destination, "wb+") as output: - merged.tofile(output, format=format.strip(".")) + merged.tofile(destination, format=format.strip(".")) def scan_resources(src_paths, toolchain, dependencies_paths=None, inc_dirs=None, base_path=None, collect_ignores=False): diff --git a/tools/build_release.py b/tools/build_release.py index bb24eea3a3..dc03f45c90 100644 --- a/tools/build_release.py +++ b/tools/build_release.py @@ -36,6 +36,7 @@ from tools.test_api import SingleTestRunner from tools.test_api import singletest_in_cli_mode from tools.paths import TEST_DIR, MBED_LIBRARIES from tools.tests import TEST_MAP +from tools.notifier.term import TerminalNotifier OFFICIAL_MBED_LIBRARY_BUILD = get_mbed_official_release('2') @@ -168,11 +169,12 @@ if __name__ == '__main__': id = "%s::%s" % (target_name, toolchain) profile = extract_profile(parser, options, toolchain) + notify = TerminalNotifier(options.verbose) try: built_mbed_lib = build_mbed_libs(TARGET_MAP[target_name], toolchain, - verbose=options.verbose, + notify=notify, jobs=options.jobs, report=build_report, properties=build_properties, diff --git a/tools/memap.py b/tools/memap.py index 83201745ba..3e419e8eb7 100644 --- a/tools/memap.py +++ b/tools/memap.py @@ -79,7 +79,7 @@ class _Parser(object): class _GccParser(_Parser): RE_OBJECT_FILE = re.compile(r'^(.+\/.+\.o)$') - RE_LIBRARY_OBJECT = re.compile(r'^.+' + sep + r'lib((.+\.a)\((.+\.o)\))$') + RE_LIBRARY_OBJECT = re.compile(r'^.+' + r''.format(sep) + r'lib((.+\.a)\((.+\.o)\))$') RE_STD_SECTION = re.compile(r'^\s+.*0x(\w{8,16})\s+0x(\w+)\s(.+)$') RE_FILL_SECTION = re.compile(r'^\s*\*fill\*\s+0x(\w{8,16})\s+0x(\w+).*$') diff --git a/tools/notifier/term.py b/tools/notifier/term.py index 55f49409bc..e8bb352d25 100644 --- a/tools/notifier/term.py +++ b/tools/notifier/term.py @@ -14,6 +14,7 @@ # limitations under the License. from __future__ import print_function, division, absolute_import +from past.builtins import basestring import re import sys diff --git a/tools/test/examples/examples_lib.py b/tools/test/examples/examples_lib.py index 8fda2d3f55..9b064cadc7 100644 --- a/tools/test/examples/examples_lib.py +++ b/tools/test/examples/examples_lib.py @@ -10,7 +10,6 @@ import os.path import sys import subprocess from shutil import rmtree -from sets import Set ROOT = abspath(dirname(dirname(dirname(dirname(__file__))))) sys.path.insert(0, ROOT) @@ -254,11 +253,11 @@ def export_repos(config, ides, targets, examples): ides - List of IDES to export to """ results = {} - valid_examples = Set(examples) + valid_examples = set(examples) print("\nExporting example repos....\n") for example in config['examples']: example_names = [basename(x['repo']) for x in get_repo_list(example)] - common_examples = valid_examples.intersection(Set(example_names)) + common_examples = valid_examples.intersection(set(example_names)) if not common_examples: continue export_failures = [] @@ -337,11 +336,11 @@ def compile_repos(config, toolchains, targets, profile, examples): """ results = {} - valid_examples = Set(examples) + valid_examples = set(examples) print("\nCompiling example repos....\n") for example in config['examples']: example_names = [basename(x['repo']) for x in get_repo_list(example)] - common_examples = valid_examples.intersection(Set(example_names)) + common_examples = valid_examples.intersection(set(example_names)) if not common_examples: continue failures = [] diff --git a/tools/test/memap/parse_test.py b/tools/test/memap/parse_test.py index 210a6fa9e2..6ed7ecd7e5 100644 --- a/tools/test/memap/parse_test.py +++ b/tools/test/memap/parse_test.py @@ -1,5 +1,6 @@ import sys from io import open +from os import sep from os.path import isfile, join, dirname import json @@ -20,9 +21,12 @@ PARSED_ARM_DATA = { def test_parse_armcc(): memap = MemapParser() memap.parse(join(dirname(__file__), "arm.map"), "ARM") - assert memap.modules == PARSED_ARM_DATA - memap.parse(join(dirname(__file__), "arm.map"), "UARM") - assert memap.modules == PARSED_ARM_DATA + + parsed_data_os_agnostic = dict() + for k in PARSED_ARM_DATA: + parsed_data_os_agnostic[k.replace('/', sep)] = PARSED_ARM_DATA[k] + + assert memap.modules == parsed_data_os_agnostic PARSED_IAR_DATA = { "startup/startup.o": {".text": 0xc0}, @@ -35,7 +39,12 @@ PARSED_IAR_DATA = { def test_parse_iar(): memap = MemapParser() memap.parse(join(dirname(__file__), "iar.map"), "IAR") - assert memap.modules == PARSED_IAR_DATA + + parsed_data_os_agnostic = dict() + for k in PARSED_IAR_DATA: + parsed_data_os_agnostic[k.replace('/', sep)] = PARSED_IAR_DATA[k] + + assert memap.modules == parsed_data_os_agnostic PARSED_GCC_DATA = { "startup/startup.o": {".text": 0xc0}, @@ -49,9 +58,12 @@ PARSED_GCC_DATA = { def test_parse_gcc(): memap = MemapParser() memap.parse(join(dirname(__file__), "gcc.map"), "GCC_ARM") - assert memap.modules == PARSED_GCC_DATA - memap.parse(join(dirname(__file__), "gcc.map"), "GCC_CR") - assert memap.modules == PARSED_GCC_DATA + + parsed_data_os_agnostic = dict() + for k in PARSED_GCC_DATA: + parsed_data_os_agnostic[k.replace('/', sep)] = PARSED_GCC_DATA[k] + + assert memap.modules == parsed_data_os_agnostic def test_add_empty_module(): diff --git a/tools/test/test_api/test_api_test.py b/tools/test/test_api/test_api_test.py index 3a5a61fe32..255081cfe4 100644 --- a/tools/test/test_api/test_api_test.py +++ b/tools/test/test_api/test_api_test.py @@ -59,39 +59,3 @@ def test_find_tests_app_config(base_dir, target, toolchain_name, app_config): "prepare_toolchain was not called with app_config" assert args[1]['app_config'] == app_config,\ "prepare_toolchain was called with an incorrect app_config" - - -@pytest.mark.parametrize("build_path", ["build_path"]) -@pytest.mark.parametrize("target", ["K64F"]) -@pytest.mark.parametrize("toolchain_name", ["ARM"]) -@pytest.mark.parametrize("app_config", ["app_config", None]) -def test_find_tests_app_config(build_path, target, toolchain_name, app_config): - """ - Test find_tests for correct use of app_config - - :param base_dir: dummy value for the test base directory - :param target: the target to "test" for - :param toolchain_name: the toolchain to use for "testing" - :param app_config: Application configuration parameter to find tests - """ - tests = {'test1': 'test1_path','test2': 'test2_path'} - src_paths = ['.'] - set_targets_json_location() - with patch('tools.test_api.scan_resources') as mock_scan_resources,\ - patch('tools.test_api.build_project') as mock_build_project,\ - patch('tools.test_api.get_config') as mock_get_config: - mock_build_project.return_value = "build_project" - mock_scan_resources().inc_dirs.return_value = [] - mock_get_config.return_value = ({}, "", "") - - build_tests(tests, src_paths, build_path, target, toolchain_name, - app_config=app_config) - - arg_list = mock_build_project.call_args_list - for args in arg_list: - assert 'app_config' in args[1],\ - "build_tests was not called with app_config" - assert args[1]['app_config'] == app_config,\ - "build_tests was called with an incorrect app_config" - mock_get_config.called_with(src_paths, target, - toolchain_name, app_conifg=app_config) diff --git a/tools/test/toolchains/api_test.py b/tools/test/toolchains/api_test.py index 74199adaa4..f8ddf08e01 100644 --- a/tools/test/toolchains/api_test.py +++ b/tools/test/toolchains/api_test.py @@ -16,7 +16,7 @@ from tools.toolchains import TOOLCHAIN_CLASSES, LEGACY_TOOLCHAIN_NAMES,\ from tools.targets import TARGET_MAP from tools.notifier.mock import MockNotifier -ALPHABET = [char for char in printable if char not in [u'.', u'/']] +ALPHABET = [char for char in printable if char not in [u'.', u'/', u'\\']] @given(fixed_dictionaries({ 'common': lists(text()), @@ -175,7 +175,7 @@ def test_detect_duplicates(filenames): assert "dupe.c" in notification["message"] assert "dupe.cpp" in notification["message"] -@given(text(alphabet=ALPHABET + ["/"], min_size=1)) +@given(text(alphabet=ALPHABET + [os.sep], min_size=1)) @given(booleans()) @given(booleans()) @settings(max_examples=20) diff --git a/tools/test_api.py b/tools/test_api.py index 53edbd2f11..ef5ff36567 100644 --- a/tools/test_api.py +++ b/tools/test_api.py @@ -383,7 +383,6 @@ class SingleTestRunner(object): build_mbed_libs_result = build_mbed_libs( T, toolchain, clean=clean_mbed_libs_options, - verbose=self.opts_verbose, jobs=self.opts_jobs, report=build_report, properties=build_properties, @@ -463,7 +462,6 @@ class SingleTestRunner(object): build_lib(lib_id, T, toolchain, - verbose=self.opts_verbose, clean=clean_mbed_libs_options, jobs=self.opts_jobs, report=build_report, @@ -509,7 +507,7 @@ class SingleTestRunner(object): try: path = build_project(test.source_dir, join(build_dir, test_id), T, toolchain, test.dependencies, clean=clean_project_options, - verbose=self.opts_verbose, name=project_name, macros=MACROS, + name=project_name, macros=MACROS, inc_dirs=INC_DIRS, jobs=self.opts_jobs, report=build_report, properties=build_properties, project_id=test_id, project_description=test.get_description(), diff --git a/tools/toolchains/__init__.py b/tools/toolchains/__init__.py index ef4b3974f7..29bec74106 100644 --- a/tools/toolchains/__init__.py +++ b/tools/toolchains/__init__.py @@ -45,7 +45,7 @@ from ..memap import MemapParser CPU_COUNT_MIN = 1 CPU_COEF = 1 -class LazyDict(dict): +class LazyDict(object): def __init__(self): self.eager = {} self.lazy = {} @@ -252,8 +252,6 @@ class Resources: headername = basename(filename) dupe_headers.setdefault(headername, set()) dupe_headers[headername] |= set([headername]) - for res in self.features.values(): - res._collect_duplicates(dupe_dict, dupe_headers) return dupe_dict, dupe_headers def detect_duplicates(self, toolchain): @@ -733,7 +731,7 @@ class mbedToolchain: elif ext == self.LINKER_EXT: if resources.linker_script is not None: - self.info("Warning: Multiple linker scripts detected: %s -> %s" % (resources.linker_script, file_path)) + self.notify.info("Warning: Multiple linker scripts detected: %s -> %s" % (resources.linker_script, file_path)) resources.linker_script = file_path elif ext == '.lib': @@ -1085,7 +1083,7 @@ class mbedToolchain: lib = self.STD_LIB_NAME % name fout = join(dir, lib) if self.need_update(fout, objects): - self.info("Library: %s" % lib) + self.notify.info("Library: %s" % lib) self.archive(objects, fout) needed_update = True @@ -1175,7 +1173,7 @@ class mbedToolchain: # Parse and decode a map file if memap.parse(abspath(map), toolchain) is False: - self.info("Unknown toolchain for memory statistics %s" % toolchain) + self.notify.info("Unknown toolchain for memory statistics %s" % toolchain) return None # Store the memap instance for later use