Merge pull request #7122 from ARMmbed/5.9-release-candidate

Release candidate 2 for mbed-os-5.9.0
pull/7517/head mbed-os-5.9.0-rc2
Martin Kojtal 2018-06-06 17:18:02 +02:00 committed by GitHub
commit 4aa2bf6aec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 143 additions and 129 deletions

View File

@ -45,9 +45,15 @@ extern uint32_t SystemCoreClock;
* 1000 ms delay: tolerance = 20500 us * 1000 ms delay: tolerance = 20500 us
* *
* */ * */
#define DELTA_US(delay_ms) (500 + (delay_ms) * US_PER_MSEC / 50) #ifdef NO_SYSTICK
#define DELTA_MS(delay_ms) (1 + ((delay_ms) * US_PER_MSEC / 50 / US_PER_MSEC)) #define TOLERANCE 5
#define DELTA_S(delay_ms) (0.000500f + (((float)(delay_ms)) / MSEC_PER_SEC / 50)) #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_FREQ_1MHZ 1000000
#define TICKER_BITS 32 #define TICKER_BITS 32

View File

@ -344,20 +344,34 @@ void ticker_increment_test(void)
} else { // high frequency tickers } else { // high frequency tickers
uint32_t num_of_cycles = NUM_OF_CYCLES; 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 base_tick_count = count_ticks(num_of_cycles, 1);
uint32_t next_tick_count = base_tick_count; uint32_t next_tick_count = base_tick_count;
uint32_t inc_val = 0; 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); next_tick_count = count_ticks(num_of_cycles + inc_val, 1);
if (next_tick_count == base_tick_count) { if (next_tick_count == base_tick_count) {
/* Same tick count, so increase num of cycles. */ /* Same tick count, so repeat 20 times and than
inc_val++; * increase num of cycles by 1.
*/
if (repeat_cnt == repeat_count) {
inc_val++;
repeat_cnt = 0;
}
repeat_cnt++;
} else { } 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 /* It is possible that the difference between base and next
* tick count on some platforms is greater that 1, in this case we need * 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; num_of_cycles /= 2;
inc_val = 0; inc_val = 0;
repeat_cnt = 0;
base_tick_count = count_ticks(num_of_cycles, 1); 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;
}
} }
} }

View File

@ -32,10 +32,6 @@ void test_sys_info()
mbed_stats_sys_t stats; mbed_stats_sys_t stats;
mbed_stats_sys_get(&stats); mbed_stats_sys_get(&stats);
#if defined(MBED_VERSION)
TEST_ASSERT_NOT_EQUAL(0, stats.os_version);
#endif
#if defined(__CORTEX_M) #if defined(__CORTEX_M)
TEST_ASSERT_NOT_EQUAL(0, stats.cpu_id); TEST_ASSERT_NOT_EQUAL(0, stats.cpu_id);
#endif #endif

View File

@ -18,7 +18,9 @@
#define CMSIS_device_header <cmsis.h> #define CMSIS_device_header <cmsis.h>
#if defined(MBED_CONF_RTOS_PRESENT)
#include "mbed_rtx_conf.h" #include "mbed_rtx_conf.h"
#endif
#include "mbed_cmsis_conf.h" #include "mbed_cmsis_conf.h"
#endif #endif

View File

@ -584,7 +584,7 @@ public:
WhitelistDbCb_t cb, WhitelistDbCb_t cb,
::Gap::Whitelist_t *whitelist ::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); entry_handle_t db_handle = get_entry_handle_by_index(i);
SecurityDistributionFlags_t* flags = get_distribution_flags(db_handle); SecurityDistributionFlags_t* flags = get_distribution_flags(db_handle);
@ -592,20 +592,24 @@ public:
continue; continue;
} }
if (flags->peer_address_is_public) { SecurityEntryIdentity_t* identity = read_in_entry_peer_identity(db_handle);
whitelist->addresses[i].type = BLEProtocol::AddressType::PUBLIC; if (!identity) {
} else { continue;
whitelist->addresses[i].type = BLEProtocol::AddressType::RANDOM_STATIC;
} }
SecurityEntryIdentity_t* identity = read_in_entry_peer_identity(db_handle); memcpy(
if (identity) { whitelist->addresses[whitelist->size].address,
memcpy( identity->identity_address.data(),
whitelist->addresses[i].address, sizeof(BLEProtocol::AddressBytes_t)
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); cb(whitelist);

View File

@ -142,6 +142,9 @@ ble_error_t GenericSecurityManager::purgeAllBondingState(void) {
ble_error_t GenericSecurityManager::generateWhitelistFromBondTable(Gap::Whitelist_t *whitelist) const { ble_error_t GenericSecurityManager::generateWhitelistFromBondTable(Gap::Whitelist_t *whitelist) const {
if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE; if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE;
if (eventHandler) { if (eventHandler) {
if (!whitelist) {
return BLE_ERROR_INVALID_PARAM;
}
_db->generate_whitelist_from_bond_table( _db->generate_whitelist_from_bond_table(
mbed::callback(eventHandler, &::SecurityManager::EventHandler::whitelistFromBondTable), mbed::callback(eventHandler, &::SecurityManager::EventHandler::whitelistFromBondTable),
whitelist whitelist

View File

@ -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( const resolving_list_entry_t* entry = get_sm().resolve_address(
evt.peer_addr.addr evt.peer_addr.addr
); );
MBED_ASSERT(entry == NULL); MBED_ASSERT(entry != NULL);
peer_addr_type = convert_identity_address(entry->peer_identity_address_type); peer_addr_type = convert_identity_address(entry->peer_identity_address_type);
peer_address = entry->peer_identity_address.data(); peer_address = entry->peer_identity_address.data();

View File

@ -47,6 +47,7 @@ namespace vendor {
namespace nordic { namespace nordic {
CryptoToolbox::CryptoToolbox() : _initialized(false) { CryptoToolbox::CryptoToolbox() : _initialized(false) {
mbedtls_platform_setup(&_platform_context);
mbedtls_entropy_init(&_entropy_context); mbedtls_entropy_init(&_entropy_context);
mbedtls_ecp_group_init(&_group); mbedtls_ecp_group_init(&_group);
int err = mbedtls_ecp_group_load( int err = mbedtls_ecp_group_load(
@ -59,6 +60,7 @@ CryptoToolbox::CryptoToolbox() : _initialized(false) {
CryptoToolbox::~CryptoToolbox() { CryptoToolbox::~CryptoToolbox() {
mbedtls_ecp_group_free(&_group); mbedtls_ecp_group_free(&_group);
mbedtls_entropy_free(&_entropy_context); mbedtls_entropy_free(&_entropy_context);
mbedtls_platform_teardown(&_platform_context);
} }
bool CryptoToolbox::generate_keys( bool CryptoToolbox::generate_keys(

View File

@ -132,6 +132,7 @@ private:
void swap_endian(uint8_t* buf, size_t len); void swap_endian(uint8_t* buf, size_t len);
bool _initialized; bool _initialized;
mbedtls_platform_context _platform_context;
mbedtls_entropy_context _entropy_context; mbedtls_entropy_context _entropy_context;
mbedtls_ecp_group _group; mbedtls_ecp_group _group;
}; };

View File

@ -18,7 +18,8 @@
#define __UVISOR_DEPRECATION_H__ #define __UVISOR_DEPRECATION_H__
#if defined(UVISOR_PRESENT) && UVISOR_PRESENT == 1 #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
#endif // __UVISOR_DEPRECATION_H__ #endif // __UVISOR_DEPRECATION_H__

View File

@ -51,6 +51,7 @@ static mbed_error_ctx first_error_ctx = {0};
static mbed_error_ctx last_error_ctx = {0}; static mbed_error_ctx last_error_ctx = {0};
static mbed_error_hook_t error_hook = NULL; static mbed_error_hook_t error_hook = NULL;
static void print_error_report(mbed_error_ctx *ctx, const char *); 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 //Helper function to halt the system
static void mbed_halt_system(void) static void mbed_halt_system(void)
@ -72,20 +73,23 @@ WEAK void error(const char* format, ...) {
if (error_in_progress) { if (error_in_progress) {
return; 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; error_in_progress = 1;
#ifndef NDEBUG #ifndef NDEBUG
va_list arg; va_list arg;
va_start(arg, format); va_start(arg, format);
mbed_error_vfprintf(format, arg); mbed_error_vfprintf(format, arg);
MBED_ERROR(MBED_ERROR_UNKNOWN, "Fatal Run-time Error");
va_end(arg); va_end(arg);
#endif #endif
exit(1); exit(1);
} }
//Set an error status with the error handling system //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; 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 #ifdef MBED_CONF_ERROR_FILENAME_CAPTURE_ENABLED
//Capture filename/linenumber if provided //Capture filename/linenumber if provided
//Index for tracking error_filename //Index for tracking error_filename
int idx = 0; memset(&current_error_ctx.error_filename, 0, MBED_CONF_MAX_ERROR_FILENAME_LEN);
strncpy(current_error_ctx.error_filename, filename, MBED_CONF_MAX_ERROR_FILENAME_LEN);
if(NULL != filename) { current_error_ctx.error_line_number = line_number;
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;
}
#endif #endif
//Capture the fist system error and store it //Capture the fist system error and store it
@ -188,14 +186,14 @@ int mbed_get_error_count(void)
//Sets a fatal error //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) 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 //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) 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 //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; return MBED_ERROR_FAILED_OPERATION;
//On fatal errors print the error context/report //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_code = MBED_GET_ERROR_CODE(ctx->error_status);
uint32_t error_module = MBED_GET_ERROR_MODULE(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 //Report error info based on error code, some errors require different
//error_vals[1] contains the error code //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(error_msg, NULL);
mbed_error_printf("\nLocation: 0x%x", ctx->error_address); mbed_error_printf("\nLocation: 0x%x", ctx->error_address);
#ifdef MBED_CONF_ERROR_FILENAME_CAPTURE_ENABLED #if defined(MBED_CONF_ERROR_FILENAME_CAPTURE_ENABLED) && !defined(NDEBUG)
if(NULL != error_ctx->error_filename) { if(NULL != ctx->error_filename) {
//for string, we must pass address of a ptr which has the address of the string //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+%d", ctx->error_filename, ctx->error_line_number);
mbed_error_printf("\nFile:%s", &file_name);
mbed_error_printf("+0x%x", ctx->error_line_number);
} }
#endif #endif
@ -429,7 +425,7 @@ static void print_error_report(mbed_error_ctx *ctx, const char *error_msg)
#endif //TARGET_CORTEX_M #endif //TARGET_CORTEX_M
} }
mbed_error_printf("\n-- MbedOS Error Info --"); mbed_error_printf("\n-- MbedOS Error Info --\n");
} }

View File

@ -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. * 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 #ifdef NDEBUG
#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_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 *)error_msg, (uint32_t)0 , (const char *)MBED_FILENAME, __LINE__ ) #define MBED_WARNING( error_status, error_msg ) mbed_warning( error_status, (const char *)NULL, (uint32_t)0, NULL, 0 )
#else #else
#define MBED_WARNING1( error_status, error_msg, error_value ) mbed_warning( error_status, (const char *)error_msg, (uint32_t)error_value, NULL, 0 ) #if defined(MBED_CONF_ERROR_FILENAME_CAPTURE_ENABLED)
#define MBED_WARNING( error_status, error_msg ) mbed_warning( error_status, (const char *)error_msg, (uint32_t)0, NULL, 0 ) #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 #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. * 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 #ifdef NDEBUG
#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_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 *)error_msg, (uint32_t)0 , (const char *)MBED_FILENAME, __LINE__ ) #define MBED_ERROR( error_status, error_msg ) mbed_error( error_status, (const char *)NULL, (uint32_t)0 , NULL, 0 )
#else #else
#define MBED_ERROR1( error_status, error_msg, error_value ) mbed_error( error_status, (const char *)error_msg, (uint32_t)error_value, NULL, 0 ) #if defined(MBED_CONF_ERROR_FILENAME_CAPTURE_ENABLED)
#define MBED_ERROR( error_status, error_msg ) mbed_error( error_status, (const char *)error_msg, (uint32_t)0 , NULL, 0 ) #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__ )
#endif #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 //Error Type definition
/** mbed_error_type_t definition /** mbed_error_type_t definition

View File

@ -123,9 +123,6 @@ void mbed_stats_sys_get(mbed_stats_sys_t *stats)
memset(stats, 0, sizeof(mbed_stats_sys_t)); memset(stats, 0, sizeof(mbed_stats_sys_t));
#if defined(MBED_SYS_STATS_ENABLED) #if defined(MBED_SYS_STATS_ENABLED)
#if defined(MBED_VERSION)
stats->os_version = MBED_VERSION;
#endif
#if defined(__CORTEX_M) #if defined(__CORTEX_M)
stats->cpu_id = SCB->CPUID; stats->cpu_id = SCB->CPUID;
#endif #endif

View File

@ -27,6 +27,11 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE {
ER_IROM1 MBED_APP_START MBED_APP_SIZE { ER_IROM1 MBED_APP_START MBED_APP_SIZE {
*.o (RESET, +First) *.o (RESET, +First)
*(InRoot$$Sections) *(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) .ANY (+RO)
} }
RW_IRAM0 MBED_RAM0_START UNINIT MBED_RAM0_SIZE { ;no init section RW_IRAM0 MBED_RAM0_START UNINIT MBED_RAM0_SIZE { ;no init section

View File

@ -27,6 +27,11 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE {
ER_IROM1 MBED_APP_START MBED_APP_SIZE { ER_IROM1 MBED_APP_START MBED_APP_SIZE {
*.o (RESET, +First) *.o (RESET, +First)
*(InRoot$$Sections) *(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) .ANY (+RO)
} }
RW_IRAM0 MBED_RAM0_START UNINIT MBED_RAM0_SIZE { ;no init section RW_IRAM0 MBED_RAM0_START UNINIT MBED_RAM0_SIZE { ;no init section

View File

@ -42,6 +42,7 @@ void ublox_mdm_init(void)
// Can't use wait_ms() as RTOS isn't initialised yet // Can't use wait_ms() as RTOS isn't initialised yet
//wait_ms(50); // when USB cable is inserted the interface chip issues //wait_ms(50); // when USB cable is inserted the interface chip issues
// Here's the code from the non-RTOS version // Here's the code from the non-RTOS version
us_ticker_init();
uint32_t start = us_ticker_read(); uint32_t start = us_ticker_read();
while ((us_ticker_read() - start) < 50000); while ((us_ticker_read() - start) < 50000);
} }

View File

@ -184,7 +184,7 @@ if __name__ == '__main__':
skipped.append(tt_id) skipped.append(tt_id)
else: else:
try: try:
notify = TerminalNotifer(options.verbose, options.silent) notifier = TerminalNotifier(options.verbose, options.silent)
mcu = TARGET_MAP[target] mcu = TARGET_MAP[target]
profile = extract_profile(parser, options, toolchain) profile = extract_profile(parser, options, toolchain)
if options.source_dir: if options.source_dir:
@ -197,6 +197,7 @@ if __name__ == '__main__':
name=options.artifact_name, name=options.artifact_name,
build_profile=profile, build_profile=profile,
ignore=options.ignore, ignore=options.ignore,
notify = notifier,
) )
else: else:
lib_build_res = build_mbed_libs( lib_build_res = build_mbed_libs(
@ -206,6 +207,7 @@ if __name__ == '__main__':
macros=options.macros, macros=options.macros,
build_profile=profile, build_profile=profile,
ignore=options.ignore, ignore=options.ignore,
notify=notifier,
) )
for lib_id in libraries: for lib_id in libraries:

View File

@ -458,8 +458,7 @@ def merge_region_list(region_list, destination, notify, padding=b'\xFF'):
makedirs(dirname(destination)) makedirs(dirname(destination))
notify.info("Space used after regions merged: 0x%x" % notify.info("Space used after regions merged: 0x%x" %
(merged.maxaddr() - merged.minaddr() + 1)) (merged.maxaddr() - merged.minaddr() + 1))
with open(destination, "wb+") as output: merged.tofile(destination, format=format.strip("."))
merged.tofile(output, format=format.strip("."))
def scan_resources(src_paths, toolchain, dependencies_paths=None, def scan_resources(src_paths, toolchain, dependencies_paths=None,
inc_dirs=None, base_path=None, collect_ignores=False): inc_dirs=None, base_path=None, collect_ignores=False):

View File

@ -36,6 +36,7 @@ from tools.test_api import SingleTestRunner
from tools.test_api import singletest_in_cli_mode from tools.test_api import singletest_in_cli_mode
from tools.paths import TEST_DIR, MBED_LIBRARIES from tools.paths import TEST_DIR, MBED_LIBRARIES
from tools.tests import TEST_MAP from tools.tests import TEST_MAP
from tools.notifier.term import TerminalNotifier
OFFICIAL_MBED_LIBRARY_BUILD = get_mbed_official_release('2') OFFICIAL_MBED_LIBRARY_BUILD = get_mbed_official_release('2')
@ -168,11 +169,12 @@ if __name__ == '__main__':
id = "%s::%s" % (target_name, toolchain) id = "%s::%s" % (target_name, toolchain)
profile = extract_profile(parser, options, toolchain) profile = extract_profile(parser, options, toolchain)
notify = TerminalNotifier(options.verbose)
try: try:
built_mbed_lib = build_mbed_libs(TARGET_MAP[target_name], built_mbed_lib = build_mbed_libs(TARGET_MAP[target_name],
toolchain, toolchain,
verbose=options.verbose, notify=notify,
jobs=options.jobs, jobs=options.jobs,
report=build_report, report=build_report,
properties=build_properties, properties=build_properties,

View File

@ -79,7 +79,7 @@ class _Parser(object):
class _GccParser(_Parser): class _GccParser(_Parser):
RE_OBJECT_FILE = re.compile(r'^(.+\/.+\.o)$') 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_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+).*$') RE_FILL_SECTION = re.compile(r'^\s*\*fill\*\s+0x(\w{8,16})\s+0x(\w+).*$')

View File

@ -14,6 +14,7 @@
# limitations under the License. # limitations under the License.
from __future__ import print_function, division, absolute_import from __future__ import print_function, division, absolute_import
from past.builtins import basestring
import re import re
import sys import sys

View File

@ -10,7 +10,6 @@ import os.path
import sys import sys
import subprocess import subprocess
from shutil import rmtree from shutil import rmtree
from sets import Set
ROOT = abspath(dirname(dirname(dirname(dirname(__file__))))) ROOT = abspath(dirname(dirname(dirname(dirname(__file__)))))
sys.path.insert(0, ROOT) sys.path.insert(0, ROOT)
@ -254,11 +253,11 @@ def export_repos(config, ides, targets, examples):
ides - List of IDES to export to ides - List of IDES to export to
""" """
results = {} results = {}
valid_examples = Set(examples) valid_examples = set(examples)
print("\nExporting example repos....\n") print("\nExporting example repos....\n")
for example in config['examples']: for example in config['examples']:
example_names = [basename(x['repo']) for x in get_repo_list(example)] 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: if not common_examples:
continue continue
export_failures = [] export_failures = []
@ -337,11 +336,11 @@ def compile_repos(config, toolchains, targets, profile, examples):
""" """
results = {} results = {}
valid_examples = Set(examples) valid_examples = set(examples)
print("\nCompiling example repos....\n") print("\nCompiling example repos....\n")
for example in config['examples']: for example in config['examples']:
example_names = [basename(x['repo']) for x in get_repo_list(example)] 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: if not common_examples:
continue continue
failures = [] failures = []

View File

@ -1,5 +1,6 @@
import sys import sys
from io import open from io import open
from os import sep
from os.path import isfile, join, dirname from os.path import isfile, join, dirname
import json import json
@ -20,9 +21,12 @@ PARSED_ARM_DATA = {
def test_parse_armcc(): def test_parse_armcc():
memap = MemapParser() memap = MemapParser()
memap.parse(join(dirname(__file__), "arm.map"), "ARM") memap.parse(join(dirname(__file__), "arm.map"), "ARM")
assert memap.modules == PARSED_ARM_DATA
memap.parse(join(dirname(__file__), "arm.map"), "UARM") parsed_data_os_agnostic = dict()
assert memap.modules == PARSED_ARM_DATA 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 = { PARSED_IAR_DATA = {
"startup/startup.o": {".text": 0xc0}, "startup/startup.o": {".text": 0xc0},
@ -35,7 +39,12 @@ PARSED_IAR_DATA = {
def test_parse_iar(): def test_parse_iar():
memap = MemapParser() memap = MemapParser()
memap.parse(join(dirname(__file__), "iar.map"), "IAR") 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 = { PARSED_GCC_DATA = {
"startup/startup.o": {".text": 0xc0}, "startup/startup.o": {".text": 0xc0},
@ -49,9 +58,12 @@ PARSED_GCC_DATA = {
def test_parse_gcc(): def test_parse_gcc():
memap = MemapParser() memap = MemapParser()
memap.parse(join(dirname(__file__), "gcc.map"), "GCC_ARM") memap.parse(join(dirname(__file__), "gcc.map"), "GCC_ARM")
assert memap.modules == PARSED_GCC_DATA
memap.parse(join(dirname(__file__), "gcc.map"), "GCC_CR") parsed_data_os_agnostic = dict()
assert memap.modules == PARSED_GCC_DATA 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(): def test_add_empty_module():

View File

@ -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" "prepare_toolchain was not called with app_config"
assert args[1]['app_config'] == app_config,\ assert args[1]['app_config'] == app_config,\
"prepare_toolchain was called with an incorrect 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)

View File

@ -16,7 +16,7 @@ from tools.toolchains import TOOLCHAIN_CLASSES, LEGACY_TOOLCHAIN_NAMES,\
from tools.targets import TARGET_MAP from tools.targets import TARGET_MAP
from tools.notifier.mock import MockNotifier 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({ @given(fixed_dictionaries({
'common': lists(text()), 'common': lists(text()),
@ -175,7 +175,7 @@ def test_detect_duplicates(filenames):
assert "dupe.c" in notification["message"] assert "dupe.c" in notification["message"]
assert "dupe.cpp" 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())
@given(booleans()) @given(booleans())
@settings(max_examples=20) @settings(max_examples=20)

View File

@ -383,7 +383,6 @@ class SingleTestRunner(object):
build_mbed_libs_result = build_mbed_libs( build_mbed_libs_result = build_mbed_libs(
T, toolchain, T, toolchain,
clean=clean_mbed_libs_options, clean=clean_mbed_libs_options,
verbose=self.opts_verbose,
jobs=self.opts_jobs, jobs=self.opts_jobs,
report=build_report, report=build_report,
properties=build_properties, properties=build_properties,
@ -463,7 +462,6 @@ class SingleTestRunner(object):
build_lib(lib_id, build_lib(lib_id,
T, T,
toolchain, toolchain,
verbose=self.opts_verbose,
clean=clean_mbed_libs_options, clean=clean_mbed_libs_options,
jobs=self.opts_jobs, jobs=self.opts_jobs,
report=build_report, report=build_report,
@ -509,7 +507,7 @@ class SingleTestRunner(object):
try: try:
path = build_project(test.source_dir, join(build_dir, test_id), T, path = build_project(test.source_dir, join(build_dir, test_id), T,
toolchain, test.dependencies, clean=clean_project_options, 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, inc_dirs=INC_DIRS, jobs=self.opts_jobs, report=build_report,
properties=build_properties, project_id=test_id, properties=build_properties, project_id=test_id,
project_description=test.get_description(), project_description=test.get_description(),

View File

@ -45,7 +45,7 @@ from ..memap import MemapParser
CPU_COUNT_MIN = 1 CPU_COUNT_MIN = 1
CPU_COEF = 1 CPU_COEF = 1
class LazyDict(dict): class LazyDict(object):
def __init__(self): def __init__(self):
self.eager = {} self.eager = {}
self.lazy = {} self.lazy = {}
@ -252,8 +252,6 @@ class Resources:
headername = basename(filename) headername = basename(filename)
dupe_headers.setdefault(headername, set()) dupe_headers.setdefault(headername, set())
dupe_headers[headername] |= set([headername]) dupe_headers[headername] |= set([headername])
for res in self.features.values():
res._collect_duplicates(dupe_dict, dupe_headers)
return dupe_dict, dupe_headers return dupe_dict, dupe_headers
def detect_duplicates(self, toolchain): def detect_duplicates(self, toolchain):
@ -733,7 +731,7 @@ class mbedToolchain:
elif ext == self.LINKER_EXT: elif ext == self.LINKER_EXT:
if resources.linker_script is not None: 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 resources.linker_script = file_path
elif ext == '.lib': elif ext == '.lib':
@ -1085,7 +1083,7 @@ class mbedToolchain:
lib = self.STD_LIB_NAME % name lib = self.STD_LIB_NAME % name
fout = join(dir, lib) fout = join(dir, lib)
if self.need_update(fout, objects): if self.need_update(fout, objects):
self.info("Library: %s" % lib) self.notify.info("Library: %s" % lib)
self.archive(objects, fout) self.archive(objects, fout)
needed_update = True needed_update = True
@ -1175,7 +1173,7 @@ class mbedToolchain:
# Parse and decode a map file # Parse and decode a map file
if memap.parse(abspath(map), toolchain) is False: 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 return None
# Store the memap instance for later use # Store the memap instance for later use