Skip to content

Commit

Permalink
Fault & crash data RAM working on STM32H7!
Browse files Browse the repository at this point in the history
  • Loading branch information
multiplemonomials committed Oct 13, 2024
1 parent 9612f75 commit f7251f7
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/greentea_cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }} -DMBED_APP_JSON_PATH=TESTS/configs/greentea_full.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_SERIAL_PORT=/dev/ttyDUMMY -DMBED_TARGET=${{ matrix.target }} -DMBED_APP_JSON_PATH=TESTS/configs/greentea_full.json5
cmake --build __build
14 changes: 14 additions & 0 deletions TESTS/configs/greentea_baremetal.json5
Original file line number Diff line number Diff line change
@@ -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
}
}
5 changes: 0 additions & 5 deletions TESTS/configs/greentea_full.json

This file was deleted.

9 changes: 9 additions & 0 deletions TESTS/configs/greentea_full.json5
Original file line number Diff line number Diff line change
@@ -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
}
}
7 changes: 7 additions & 0 deletions platform/source/mbed_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion platform/tests/TESTS/mbed_platform/stats_cpu/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::chrono::milliseconds>(SAMPLE_TIME).count());
prev_idle_time = stats.idle_time;
TEST_ASSERT_NOT_EQUAL(0, usage);
ThisThread::sleep_for(SAMPLE_TIME);
Expand Down

0 comments on commit f7251f7

Please sign in to comment.