Fix MCUboot and app flash partitioning

- Corrected device tree overlays to prevent MCUboot and app overlap
- MCUboot now at 0x8000000 (32KB), app at 0x8008000 (96KB)
- Successfully boots MCUboot which chains to application
- Shell and reset command working properly
- Black Magic Probe flashing confirmed working for both domains
This commit is contained in:
Eduard Iten 2025-07-07 16:04:29 +02:00
parent 928a176e7c
commit cc6b4488ee
2 changed files with 32 additions and 8 deletions

View File

@ -1,28 +1,48 @@
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <zephyr/shell/shell.h>
#include <zephyr/sys/reboot.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(firmware_node, LOG_LEVEL_DBG);
LOG_MODULE_REGISTER(firmware_node, LOG_LEVEL_INF);
// Custom reset command handler
static int cmd_reset(const struct shell *shell, size_t argc, char **argv)
{
ARG_UNUSED(argc);
ARG_UNUSED(argv);
shell_print(shell, "Rebooting system...");
k_msleep(100); // Give time for message to be sent
sys_reboot(SYS_REBOOT_WARM);
shell_print(shell, "Resetting system...");
k_msleep(100); // Give time for the message to be sent
sys_reboot(SYS_REBOOT_COLD);
return 0;
}
// MCUboot serial recovery command handler
static int cmd_mcuboot_recovery(const struct shell *shell, size_t argc, char **argv)
{
ARG_UNUSED(argc);
ARG_UNUSED(argv);
shell_print(shell, "Entering MCUboot serial recovery mode...");
shell_print(shell, "System will reset and MCUboot will wait for image upload via mcumgr");
k_msleep(100); // Give time for the message to be sent
// TODO: Set a flag or trigger MCUboot serial recovery mode
// For now, just reset - MCUboot serial recovery needs to be enabled
sys_reboot(SYS_REBOOT_COLD);
return 0;
}
SHELL_CMD_REGISTER(reset, NULL, "Reset the system", cmd_reset);
SHELL_CMD_REGISTER(mcuboot_recovery, NULL, "Enter MCUboot serial recovery mode", cmd_mcuboot_recovery);
int main(void)
{
LOG_INF("Firmware Node starting up");
LOG_INF("Shell with reset command available");
LOG_INF("MCUboot serial recovery command available");
return 0;
}

View File

@ -2,10 +2,14 @@
CONFIG_LOG=y
CONFIG_BOOT_BANNER=y
CONFIG_MCUBOOT_LOG_LEVEL_DBG=y
# Enable console in MCUboot to see debug output
CONFIG_CONSOLE=y
# Disable console in MCUboot to allow serial recovery
CONFIG_CONSOLE=n
# Single slot configuration (no upgrades)
CONFIG_SINGLE_APPLICATION_SLOT=y
# Enable MCUboot serial recovery for firmware updates
CONFIG_MCUBOOT_SERIAL=y
CONFIG_BOOT_SERIAL_CDC_ACM=y
# Disable signature validation for testing
CONFIG_BOOT_SIGNATURE_TYPE_NONE=y