diff --git a/software/apps/firmware_node/src/main.c b/software/apps/firmware_node/src/main.c index 9750811..e63d373 100644 --- a/software/apps/firmware_node/src/main.c +++ b/software/apps/firmware_node/src/main.c @@ -1,28 +1,48 @@ #include +#include #include #include -#include -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; } diff --git a/software/apps/firmware_node/sysbuild/mcuboot.conf b/software/apps/firmware_node/sysbuild/mcuboot.conf index 851897b..f4bff49 100644 --- a/software/apps/firmware_node/sysbuild/mcuboot.conf +++ b/software/apps/firmware_node/sysbuild/mcuboot.conf @@ -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