diff --git a/software/apps/firmware_node/CMakeLists.txt b/software/apps/firmware_node/CMakeLists.txt new file mode 100644 index 0000000..bf7491b --- /dev/null +++ b/software/apps/firmware_node/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.20) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) + +project(firmware_node LANGUAGES C) +zephyr_include_directories(../../include) +add_subdirectory(../../lib lib) +target_sources(app PRIVATE src/main.c) diff --git a/software/apps/firmware_node/README.md b/software/apps/firmware_node/README.md new file mode 100644 index 0000000..acc6bb2 --- /dev/null +++ b/software/apps/firmware_node/README.md @@ -0,0 +1,34 @@ +# Firmware Node Application + +This Zephyr application provides firmware management capabilities for the irrigation system. + +**Tested on Zephyr 4.1.99** + +## Features + +### Step 1: Shell with Reset Command +- Shell interface with custom "reset" command +- Warm reboot functionality + +### Planned Features +- MCUboot support with partition manager +- Firmware version display +- MCUmgr support for OTA updates + +## Building + +```bash +west build -p auto -b weact_stm32g431_core apps/firmware_node -- -DBOARD_FLASH_RUNNER=blackmagicprobe +``` + +## Flashing + +```bash +west flash +``` + +## Usage + +Connect to the device via serial console and use the shell: +- `reset` - Reboot the system +- `help` - Show available commands diff --git a/software/apps/firmware_node/boards/weact_stm32g431_core.conf b/software/apps/firmware_node/boards/weact_stm32g431_core.conf new file mode 100644 index 0000000..790634b --- /dev/null +++ b/software/apps/firmware_node/boards/weact_stm32g431_core.conf @@ -0,0 +1,2 @@ +# Board specific configuration for weact_stm32g431_core +# This file can be used for board-specific overrides if needed diff --git a/software/apps/firmware_node/prj.conf b/software/apps/firmware_node/prj.conf new file mode 100644 index 0000000..7609528 --- /dev/null +++ b/software/apps/firmware_node/prj.conf @@ -0,0 +1,10 @@ +# Enable Console and printk for logging +CONFIG_CONSOLE=y +CONFIG_LOG=y + +# Enable Shell +CONFIG_SHELL=y +CONFIG_REBOOT=y + +# Enable the reset command +CONFIG_KERNEL_SHELL=y diff --git a/software/apps/firmware_node/src/main.c b/software/apps/firmware_node/src/main.c new file mode 100644 index 0000000..9750811 --- /dev/null +++ b/software/apps/firmware_node/src/main.c @@ -0,0 +1,28 @@ +#include +#include +#include +#include + +LOG_MODULE_REGISTER(firmware_node, LOG_LEVEL_DBG); + +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); + + return 0; +} + +SHELL_CMD_REGISTER(reset, NULL, "Reset the system", cmd_reset); + +int main(void) +{ + LOG_INF("Firmware Node starting up"); + LOG_INF("Shell with reset command available"); + + return 0; +} diff --git a/software/apps/firmware_node/sysbuild.cmake b/software/apps/firmware_node/sysbuild.cmake new file mode 100644 index 0000000..53e3311 --- /dev/null +++ b/software/apps/firmware_node/sysbuild.cmake @@ -0,0 +1,12 @@ +# Enable MCUboot +set(SB_CONFIG_BOOTLOADER_MCUBOOT y) + +# MCUboot configuration +set(SB_CONFIG_MCUBOOT_BOOTLOADER_MODE_OVERWRITE_ONLY y) +set(SB_CONFIG_MCUBOOT_SIGNATURE_KEY_FILE "bootloader/mcuboot/root-rsa-2048.pem") +set(SB_CONFIG_MCUBOOT_GENERATE_UNSIGNED_IMAGE y) +set(SB_CONFIG_MCUBOOT_GENERATE_CONFIRMED_IMAGE y) + +# Enable USB CDC ACM for MCUboot console +set(SB_CONFIG_MCUBOOT_USB_SUPPORT y) +set(SB_CONFIG_MCUBOOT_SERIAL y)