Loads of general and MIMXRT-specific test fixes (#412)

* Update MIMXRT105x linker script to use memory banks

* Disable SRAM for now :/

* Add split heap support

* Loads of general and MIMXRT-specific test fixes

* Style fix

* Remove include guard from mbed_config.tmpl so that it can be re-included by the build system

* Oops left that line there
pull/15531/head
Jamie Smith 2025-01-02 09:51:46 -08:00 committed by GitHub
parent d255e11152
commit 5887f9e97e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 57 additions and 77 deletions

View File

@ -4,6 +4,11 @@
"platform.all-stats-enabled": 1,
// Enable auto reboot on error, required for crash reporting test
"platform.fatal-error-auto-reboot-enabled": true
"platform.fatal-error-auto-reboot-enabled": true,
// Allow lots of reboots so that we don't get in a situation where the MCU refuses to boot
// after crashing and being reflashed (since some MCUs/flash tools don't reset the
// crash data RAM)
"platform.error-reboot-max": 99999
}
}

View File

@ -60,9 +60,9 @@ Configure the firewall to allow this traffic to access the test server.
These services are available on many operating systems, and installing them is out of scope of this document. Below is an example of how to install these services into a Debian/Ubuntu based Linux distribution using standard Inet Daemon:
```.sh
```shell
$ sudo apt install inetutils-inetd
$ nano /etc/inetd.conf
$ sudo nano /etc/inetd.conf
```
Enable following services from /etc/inetd.conf:
@ -79,6 +79,13 @@ daytime stream tcp6 nowait root internal
time stream tcp6 nowait root internal
```
Then run:
```shell
$ sudo systemctl enable inetutils-inetd.service
$ sudo systemctl start inetutils-inetd.service
```
Below is an example of how to install these services in TLS version into a Debian/Ubuntu based Linux distribution using Stunnel4 Daemon:
```.sh

View File

@ -5,11 +5,6 @@ if(NOT "DEVICE_RESET_REASON=1" IN_LIST MBED_TARGET_DEFINITIONS)
set(TEST_SKIPPED "Reset Reason is not supported for this target")
endif()
if("TARGET_MIMXRT105X" IN_LIST MBED_TARGET_DEFINITIONS)
# This test causes this target to die. See https://github.com/mbed-ce/mbed-os/issues/83
set(TEST_SKIPPED "Temporarily disabled for this target, see #83")
endif()
mbed_greentea_add_test(
TEST_NAME
mbed-drivers-reset-reason

View File

@ -5,11 +5,6 @@ if(NOT "DEVICE_WATCHDOG=1" IN_LIST MBED_TARGET_DEFINITIONS)
set(TEST_SKIPPED "Watchdog is not supported for this target")
endif()
if("TARGET_MIMXRT105X" IN_LIST MBED_TARGET_DEFINITIONS)
# This test causes this target to die. See https://github.com/mbed-ce/mbed-os/issues/83
set(TEST_SKIPPED "Temporarily disabled for this target, see #83")
endif()
mbed_greentea_add_test(
TEST_NAME
mbed-drivers-watchdog-reset

View File

@ -22,6 +22,7 @@ import threading
import uuid
import sys
import mbed_host_tests
import hid
import usb.core
from usb.util import (
CTRL_IN,
@ -42,13 +43,6 @@ else:
# Use a default backend on other platforms.
USB_BACKEND = None
try:
import hid
except ImportError:
CYTHON_HIDAPI_PRESENT = False
else:
CYTHON_HIDAPI_PRESENT = True
# USB device -- device classes
USB_CLASS_HID = 0x03
@ -112,8 +106,6 @@ def build_get_desc_value(desc_type, desc_index):
def usb_hid_path(serial_number):
"""Get a USB HID device system path based on the serial number."""
if not CYTHON_HIDAPI_PRESENT:
return None
for device_info in hid.enumerate(): # pylint: disable=no-member
if device_info.get('serial_number') == serial_number: # pylint: disable=not-callable
return device_info['path']
@ -563,9 +555,6 @@ class USBHIDTest(mbed_host_tests.BaseHostTest):
def cb_test_raw_io(self, key, value, timestamp):
"""Receive HID reports and send them back to the device."""
if not CYTHON_HIDAPI_PRESENT:
self.send_kv(MSG_KEY_HOST_READY, MSG_VALUE_NOT_SUPPORTED)
return
try:
# The size of input and output reports used in test.
report_size = int(value)

View File

@ -165,9 +165,11 @@ bool Harness::run(const Specification& specification)
void Harness::raise_failure(const failure_reason_t reason)
{
UTEST_LOG_FUNCTION();
// ignore a failure, if the Harness has not been initialized.
// this allows using unity assertion macros without setting up utest.
if (test_cases == NULL) return;
// If not currently in a test case and code does a unity assertion that fails, it will end up
// at this assert. This will stop execution of the program.
// This allows using unity assertion macros without setting up utest.
assert(test_cases != nullptr);
utest::v1::status_t fail_status = STATUS_ABORT;
if (handlers->test_failure) handlers->test_failure(failure_t(reason, location));

View File

@ -5,11 +5,6 @@ if(NOT "DEVICE_RESET_REASON=1" IN_LIST MBED_TARGET_DEFINITIONS)
set(TEST_SKIPPED "Reset Reason is not supported for this target")
endif()
if("TARGET_MIMXRT105X" IN_LIST MBED_TARGET_DEFINITIONS)
# This test causes this target to die. See https://github.com/mbed-ce/mbed-os/issues/83
set(TEST_SKIPPED "Temporarily disabled for this target, see #83")
endif()
mbed_greentea_add_test(
TEST_NAME
mbed-hal-reset-reason

View File

@ -5,11 +5,6 @@ if(NOT "DEVICE_RTC=1" IN_LIST MBED_TARGET_DEFINITIONS)
set(TEST_SKIPPED "RTC is not supported for this target")
endif()
if("TARGET_MIMXRT105X" IN_LIST MBED_TARGET_DEFINITIONS)
# This test causes this target to die. See https://github.com/mbed-ce/mbed-os/issues/83
set(TEST_SKIPPED "Temporarily disabled for this target, see #83")
endif()
mbed_greentea_add_test(
TEST_NAME
mbed-hal-rtc-reset

View File

@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0
if(NOT "MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED=1" IN_LIST MBED_CONFIG_DEFINITIONS)
set(TEST_SKIPPED "CRC is not supported for this target")
set(TEST_SKIPPED "MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED is not enabled for this target")
endif()
mbed_greentea_add_test(

View File

@ -35,8 +35,6 @@ static mbed_error_ctx saved_error_ctx = {0};
void mbed_error_reboot_callback(mbed_error_ctx *error_context)
{
TEST_ASSERT_EQUAL_PTR(error_context, &MBED_CRASH_DATA);
memcpy(&saved_error_ctx, error_context, sizeof(mbed_error_ctx));
mbed_reset_reboot_error_info();

View File

@ -22,6 +22,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cinttypes>
#include "mbed.h"
#include "cmsis.h"
@ -107,12 +108,16 @@ static bool rangeinrange(uint32_t addr, uint32_t size, uint32_t start, uint32_t
*/
static bool valid_fill(uint8_t *data, uint32_t size, uint8_t fill)
{
bool valid = true;
for (uint32_t i = 0; i < size; i++) {
if (data[i] != fill) {
return false;
printf("Address 0x%" PRIx32 ": expected value 0x%" PRIx8 ", got 0x%" PRIx8,
reinterpret_cast<uint32_t>(&data[i]), fill, data[i]);
valid = false;
wait_us(1000);
}
}
return true;
return valid;
}
static void allocate_and_fill_heap(linked_list *&head)
@ -158,17 +163,20 @@ static void check_and_free_heap(linked_list *head, uint32_t &max_allocation_size
uint32_t total_size = 0;
linked_list *current = head;
bool success = true;
while (current != NULL) {
total_size += sizeof(linked_list);
bool result = valid_fill(current->data, sizeof(current->data), MALLOC_FILL);
TEST_ASSERT_TRUE_MESSAGE(result, "Memory fill check failed");
success = success && valid_fill(current->data, sizeof(current->data), MALLOC_FILL);
linked_list *next = current->next;
free(current);
current = next;
}
TEST_ASSERT_TRUE_MESSAGE(success, "Memory fill check failed");
max_allocation_size = total_size;
}

View File

@ -206,9 +206,8 @@ typedef enum {
NC = (int)0xFFFFFFFF
} PinName;
// Standardized LED and button names
#define LED1 GPIO_AD_B0_09 // USER LED (green)
#define USER_LED LED1
// MIMXRT EVKs do not have a usable LED, because the LED shares important pins with the
// debugging interface, so trying to use the LED can interrupt flashing and debugging code!
typedef enum {
PullNone = 0,

View File

@ -38,28 +38,11 @@ const flexspi_nor_config_t qspiflash_config = {
.sflashA1Size = MBED_ROM_BANK_EXT_FLASH_SIZE,
.lookupTable =
{
// Read LUTs
// Read LUT. Always index 0.
// All that the bootrom needs to know is how to read the flash. The rest of the
// flash configuration is stored in flash_defines.h.
[0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB, RADDR_SDR, FLEXSPI_4PAD, 0x18),
[1] = FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 0x06, READ_SDR, FLEXSPI_4PAD, 0x04),
// Read Status LUTs
[4 * 1 + 0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x05, READ_SDR, FLEXSPI_1PAD, 0x04),
// Write Enable LUTs
[4 * 3 + 0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x06, STOP, FLEXSPI_1PAD, 0x0),
// Erase Sector LUTs
[4 * 5 + 0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x20, RADDR_SDR, FLEXSPI_1PAD, 0x18),
// Erase Block LUTs
[4 * 8 + 0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xD8, RADDR_SDR, FLEXSPI_1PAD, 0x18),
// Pape Program LUTs
[4 * 9 + 0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x02, RADDR_SDR, FLEXSPI_1PAD, 0x18),
[4 * 9 + 1] = FLEXSPI_LUT_SEQ(WRITE_SDR, FLEXSPI_1PAD, 0x04, STOP, FLEXSPI_1PAD, 0x0),
// Erase Chip LUTs
[4 * 11 + 0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x60, STOP, FLEXSPI_1PAD, 0x0),
[1] = FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 0x06, READ_SDR, FLEXSPI_4PAD, 0x04)
},
},
.pageSize = 256u,

View File

@ -188,6 +188,9 @@ void mbed_sdk_init()
BOARD_ClockFullSpeed();
#endif
// Enable non-HardFault exceptions
SCB->SHCSR |= SCB_SHCSR_USGFAULTENA_Msk | SCB_SHCSR_BUSFAULTENA_Msk | SCB_SHCSR_MEMFAULTENA_Msk;
// Switch to using an application-owned flexspi config instead of what the bootloader sets up
#if DEVICE_FLASH
mimxrt_flash_setup();

View File

@ -2,6 +2,9 @@
# To change any of these parameters from their default values, set them in your build script between where you
# include app.cmake and where you add mbed os as a subdirectory.
# 1. Most debuggers cannot connect to this CPU after it does an NVIC system reset. See Mbed CE bug #83.
# However, a workaround has been implemented for PyOCD.
# General config parameters
# -------------------------------------------------------------
set(UPLOAD_METHOD_DEFAULT MBED)
@ -16,6 +19,7 @@ set(MBED_RESET_BAUDRATE 115200)
set(PYOCD_UPLOAD_ENABLED TRUE)
set(PYOCD_TARGET_NAME mimxrt1050_hyperflash) # Note: change to "mimxrt1050_quadspi" if onboard QSPI flash is used
set(PYOCD_CLOCK_SPEED 4000k)
set(PYOCD_EXTRA_OPTIONS -Oconnect_mode=pre-reset)
# Config options for LINKSERVER
# -------------------------------------------------------------

View File

@ -7,8 +7,9 @@
# connecting an external J-Link probe. See here for conversion instructions: https://www.segger.com/products/debug-probes/j-link/models/other-j-links/lpc-link-2/
# Also, a relatively new version of the J-Link software is needed (7.82 confirmed working), so try updating
# it if you get any errors.
# 2. pyocd seems glitchy for this device. Sometimes it works great, sometimes you get 'no ACK received.'
# Might be related to pyOCD#861?
# 2. Most debuggers cannot connect to this CPU after it does an NVIC system reset. See Mbed CE bug #83.
# However, a workaround has been implemented for PyOCD.
#
# General config parameters
# -------------------------------------------------------------
@ -26,6 +27,7 @@ set(JLINK_CLOCK_SPEED 4000)
set(PYOCD_UPLOAD_ENABLED TRUE)
set(PYOCD_TARGET_NAME mimxrt1060) # Note: This seems to use QSPI. There does not seem to be a pyocd equivalent for hyperflash.
set(PYOCD_CLOCK_SPEED 4000k)
set(PYOCD_EXTRA_OPTIONS -Oconnect_mode=pre-reset)
# Config options for LINKSERVER
# -------------------------------------------------------------

View File

@ -5,6 +5,7 @@
# This method needs the following parameters:
# PYOCD_TARGET_NAME - Name of your processor as passed to the -t option of pyOCD. This is usually the full or partial model number.
# PYOCD_CLOCK_SPEED - Clock speed of the JTAG or SWD connection. Default is in Hz, but can use k and M suffixes for MHz and GHz
# PYOCD_EXTRA_OPTIONS - Extra options to pass to the pyocd 'flash' and 'gdbserver' commands.
set(UPLOAD_SUPPORTS_DEBUG TRUE)
@ -32,6 +33,7 @@ function(gen_upload_target TARGET_NAME BINARY_FILE)
-t ${PYOCD_TARGET_NAME}
${PYOCD_PROBE_ARGS}
--base-address ${MBED_UPLOAD_BASE_ADDR}
${PYOCD_EXTRA_OPTIONS}
${BINARY_FILE})
endfunction(gen_upload_target)
@ -45,7 +47,8 @@ set(UPLOAD_GDBSERVER_DEBUG_COMMAND
-t ${PYOCD_TARGET_NAME}
${PYOCD_PROBE_ARGS}
-f ${PYOCD_CLOCK_SPEED}
-p ${MBED_GDB_PORT})
-p ${MBED_GDB_PORT}
${PYOCD_EXTRA_OPTIONS})
# Reference: https://github.com/Marus/cortex-debug/blob/056c03f01e008828e6527c571ef5c9adaf64083f/src/pyocd.ts#L40
set(UPLOAD_LAUNCH_COMMANDS

View File

@ -22,7 +22,7 @@ from functools import partial
class HtrunLogger(object):
"""! Yet another logger flavour """
def __init__(self, name):
logging.basicConfig(stream=sys.stdout,format='[%(created).2f][%(name)s]%(message)s', level=logging.DEBUG)
logging.basicConfig(stream=sys.stdout,format='[+%(relativeCreated)dms][%(name)s]%(message)s', level=logging.DEBUG)
self.logger = logging.getLogger(name)
self.format_str = '[%(logger_level)s] %(message)s'

View File

@ -59,7 +59,7 @@ def assemble_config(target_attributes: dict, program: MbedProgram) -> Config:
except ValueError:
return path
config.json_sources = [make_relative_if_possible(program.root) for json_source in config.json_sources]
config.json_sources = [make_relative_if_possible(json_source) for json_source in config.json_sources]
return config

View File

@ -4,8 +4,6 @@
# Automatically generated configuration file.
# DO NOT EDIT. Content may be overwritten.
include_guard(GLOBAL)
set(MBED_TOOLCHAIN "{{toolchain_name}}")
set(MBED_CPU_CORE "{{core}}")
set(MBED_C_LIB "{{c_lib}}")
@ -69,7 +67,6 @@ set(MBED_TARGET_DEFINITIONS{% for component in components %}
# config
set(MBED_CONFIG_DEFINITIONS
# Config settings
{% for setting in config %}
{%- if setting.macro_name -%}