diff --git a/hal/tests/TESTS/mbed_hal/sleep/main.cpp b/hal/tests/TESTS/mbed_hal/sleep/main.cpp index c0a21d8985..6e745f3e94 100644 --- a/hal/tests/TESTS/mbed_hal/sleep/main.cpp +++ b/hal/tests/TESTS/mbed_hal/sleep/main.cpp @@ -227,6 +227,12 @@ utest::v1::status_t greentea_test_setup(const size_t number_of_cases) #endif ticker_suspend(get_us_ticker_data()); +#ifdef DEVICE_SEMIHOST + // Disconnect semihosting now, because otherwise it will get disconnected on the first sleep call and + // cause said call to take several milliseconds, leading to a test failure. + mbed_interface_disconnect(); +#endif + us_ticker_init(); #if DEVICE_LPTICKER lp_ticker_init(); diff --git a/rtos/tests/TESTS/mbed_rtos/MemoryPool/main.cpp b/rtos/tests/TESTS/mbed_rtos/MemoryPool/main.cpp index 58fdf1dbb8..aef54dc9f7 100644 --- a/rtos/tests/TESTS/mbed_rtos/MemoryPool/main.cpp +++ b/rtos/tests/TESTS/mbed_rtos/MemoryPool/main.cpp @@ -675,6 +675,13 @@ Case cases[] = { utest::v1::status_t greentea_test_setup(const size_t number_of_cases) { GREENTEA_SETUP(20, "default_auto"); + +#ifdef DEVICE_SEMIHOST + // Disconnect semihosting now, because otherwise it will get disconnected on the first sleep call and + // cause said call to take several milliseconds, leading to a test failure. + mbed_interface_disconnect(); +#endif + return greentea_test_setup_handler(number_of_cases); } diff --git a/rtos/tests/TESTS/mbed_rtos/mail/main.cpp b/rtos/tests/TESTS/mbed_rtos/mail/main.cpp index 1c22f61ba5..d7ba68f3df 100644 --- a/rtos/tests/TESTS/mbed_rtos/mail/main.cpp +++ b/rtos/tests/TESTS/mbed_rtos/mail/main.cpp @@ -478,6 +478,13 @@ void test_mail_full() utest::v1::status_t test_setup(const size_t number_of_cases) { GREENTEA_SETUP(10, "default_auto"); + +#ifdef DEVICE_SEMIHOST + // Disconnect semihosting now, because otherwise it will get disconnected on the first sleep call and + // cause said call to take several milliseconds, leading to a test failure. + mbed_interface_disconnect(); +#endif + return verbose_test_setup_handler(number_of_cases); } diff --git a/rtos/tests/TESTS/mbed_rtos/queue/main.cpp b/rtos/tests/TESTS/mbed_rtos/queue/main.cpp index 822fa48a73..6be21e1880 100644 --- a/rtos/tests/TESTS/mbed_rtos/queue/main.cpp +++ b/rtos/tests/TESTS/mbed_rtos/queue/main.cpp @@ -318,6 +318,13 @@ void test_queue_full() utest::v1::status_t test_setup(const size_t number_of_cases) { GREENTEA_SETUP(5, "default_auto"); + +#ifdef DEVICE_SEMIHOST + // Disconnect semihosting now, because otherwise it will get disconnected on the first sleep call and + // cause said call to take several milliseconds, leading to a test failure. + mbed_interface_disconnect(); +#endif + return verbose_test_setup_handler(number_of_cases); } diff --git a/targets/upload_method_cfg/LPC1768.cmake b/targets/upload_method_cfg/LPC1768.cmake index 5e96e9a60f..aa675ce264 100644 --- a/targets/upload_method_cfg/LPC1768.cmake +++ b/targets/upload_method_cfg/LPC1768.cmake @@ -26,8 +26,13 @@ set(MBED_RESET_BAUDRATE 115200) # Config options for OPENOCD # ------------------------------------------------------------- +# One note about OpenOCD for LPC1768: +# If you issue a "monitor reset" command, GDB will think that the program is halted, but it actually will have +# resumed. So, issue a "c" command after "monitor reset" to get things synchronized again. + set(OPENOCD_UPLOAD_ENABLED TRUE) set(OPENOCD_CHIP_CONFIG_COMMANDS -f ${CMAKE_CURRENT_LIST_DIR}/openocd_cfgs/lpc1768.cfg -c "gdb_memory_map disable" # prevents OpenOCD crash on GDB connect + -c "gdb_breakpoint_override hard" # Make sure GDB uses HW breakpoints )