diff --git a/software/apps/gateway/CMakeLists.txt b/software/apps/gateway/CMakeLists.txt index 555e999..ab24797 100644 --- a/software/apps/gateway/CMakeLists.txt +++ b/software/apps/gateway/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.20) - -# Include the main 'software' directory as a module to find boards, libs, etc. -list(APPEND ZEPHYR_EXTRA_MODULES ${CMAKE_CURRENT_SOURCE_DIR}/../..) +cmake_minimum_required(VERSION 3.20.5) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) -project(gateway) +project(gateway) target_sources(app PRIVATE src/main.c) + +target_include_directories(app PRIVATE include) diff --git a/software/apps/gateway/README.md b/software/apps/gateway/README.md new file mode 100644 index 0000000..a07bec0 --- /dev/null +++ b/software/apps/gateway/README.md @@ -0,0 +1,44 @@ +# README for the Hello World Zephyr Application + +## Overview + +This is a minimal Hello World application built using the Zephyr RTOS. The application demonstrates basic logging functionality by printing a message every 5 seconds, including the version number of the application. + +## Project Structure + +The project consists of the following files: + +- `src/main.c`: The entry point of the application that initializes logging and sets up a timer. +- `include/app_version.h`: Header file that defines the application version. +- `VERSION`: A text file containing the version number of the application. +- `prj.conf`: Configuration file for the Zephyr project, specifying necessary options. +- `CMakeLists.txt`: Build configuration file for CMake. +- `README.md`: Documentation for the project. + +## Building the Application + +To build the application, follow these steps: + +1. Ensure you have the Zephyr development environment set up. +2. Navigate to the `apps/gateway` directory. +3. Run the following command to build the application: + + ``` + west build -b . + ``` + + Replace `` with the appropriate board name. + +## Running the Application + +After building the application, you can flash it to your board using: + +``` +west flash +``` + +Once the application is running, you will see log messages printed every 5 seconds, including the version number. + +## Version + +The version of this application can be found in the `VERSION` file and is also included in the log messages. \ No newline at end of file diff --git a/software/apps/gateway/VERSION b/software/apps/gateway/VERSION new file mode 100644 index 0000000..fee45d7 --- /dev/null +++ b/software/apps/gateway/VERSION @@ -0,0 +1,5 @@ +VERSION_MAJOR = 0 +VERSION_MINOR = 0 +PATCHLEVEL = 1 +VERSION_TWEAK = 0 +EXTRAVERSION = devel \ No newline at end of file diff --git a/software/apps/gateway/boards/common_4MB.dtsi b/software/apps/gateway/boards/common_4MB.dtsi new file mode 100644 index 0000000..bc13fb4 --- /dev/null +++ b/software/apps/gateway/boards/common_4MB.dtsi @@ -0,0 +1,16 @@ +&flash0 { + reg = <0x0 0x400000>; /* 4MB flash */ +}; + +#include "espressif/partitions_0x0_default_4M.dtsi" + +/ { + chosen { + zephyr,shell-uart = &uart0; + zephyr,uart-mcumgr = &usb_serial; + }; +}; + +&usb_serial { + status = "okay"; +}; \ No newline at end of file diff --git a/software/apps/gateway/boards/esp32c6_devkitc_hpcore.overlay b/software/apps/gateway/boards/esp32c6_devkitc_hpcore.overlay new file mode 100644 index 0000000..ae6a26e --- /dev/null +++ b/software/apps/gateway/boards/esp32c6_devkitc_hpcore.overlay @@ -0,0 +1 @@ +#include "common_4MB.dtsi" \ No newline at end of file diff --git a/software/apps/gateway/prj.conf b/software/apps/gateway/prj.conf index 9142e42..a210902 100644 --- a/software/apps/gateway/prj.conf +++ b/software/apps/gateway/prj.conf @@ -1,2 +1,23 @@ -# Gateway Configuration -CONFIG_NETWORKING=y +# Enable logging +CONFIG_LOG=y +CONFIG_UART_CONSOLE=y + +# Enable shell +CONFIG_SHELL=y +CONFIG_KERNEL_SHELL=y +CONFIG_REBOOT=y + +# Enable MCUMGR +CONFIG_MCUMGR=y + +# Enable MCUMGR OS management group only +CONFIG_MCUMGR_GRP_OS=y + +# Configure MCUMGR transport to UART +CONFIG_MCUMGR_TRANSPORT_UART=y + +# Dependencies +CONFIG_NET_BUF=y +CONFIG_ZCBOR=y +CONFIG_CRC=y +CONFIG_BASE64=y diff --git a/software/apps/gateway/src/main.c b/software/apps/gateway/src/main.c index 1707ef4..875d168 100644 --- a/software/apps/gateway/src/main.c +++ b/software/apps/gateway/src/main.c @@ -1,13 +1,11 @@ -/* - * Copyright (c) 2025 Eduard Iten - * - * SPDX-License-Identifier: Apache-2.0 - */ - #include +#include +#include + +LOG_MODULE_REGISTER(hello_world); int main(void) { - printk("Hello from Gateway!\n"); + LOG_INF("Hello World! Version: %s", APP_VERSION_EXTENDED_STRING); return 0; -} +} \ No newline at end of file diff --git a/software/apps/gateway/sysbuild.conf b/software/apps/gateway/sysbuild.conf new file mode 100644 index 0000000..1e134e9 --- /dev/null +++ b/software/apps/gateway/sysbuild.conf @@ -0,0 +1,2 @@ +SB_CONFIG_BOOTLOADER_MCUBOOT=y +SB_CONFIG_MCUBOOT_MODE_SINGLE_APP=y diff --git a/software/apps/gateway/sysbuild/gateway.overlay b/software/apps/gateway/sysbuild/gateway.overlay new file mode 100644 index 0000000..60bc405 --- /dev/null +++ b/software/apps/gateway/sysbuild/gateway.overlay @@ -0,0 +1,12 @@ +#include "../boards/common_4MB.dtsi" + +/* Application Configuration - Firmware goes to slot0_partition (0x20000) */ +/ { + chosen { + zephyr,code-partition = &slot0_partition; + }; +}; + +&usb_serial { + status = "okay"; +}; \ No newline at end of file diff --git a/software/apps/gateway/sysbuild/mcuboot.conf b/software/apps/gateway/sysbuild/mcuboot.conf new file mode 100644 index 0000000..93f8020 --- /dev/null +++ b/software/apps/gateway/sysbuild/mcuboot.conf @@ -0,0 +1,3 @@ +CONFIG_LOG=y +CONFIG_MCUBOOT_LOG_LEVEL_INF=y +CONFIG_UART_CONSOLE=n diff --git a/software/apps/gateway/sysbuild/mcuboot.overlay b/software/apps/gateway/sysbuild/mcuboot.overlay new file mode 100644 index 0000000..3e122df --- /dev/null +++ b/software/apps/gateway/sysbuild/mcuboot.overlay @@ -0,0 +1,12 @@ +#include "../boards/common_4MB.dtsi" + +/* MCUboot Configuration - Bootloader goes to boot_partition (0x0) */ +/ { + chosen { + zephyr,code-partition = &boot_partition; + }; + aliases { + mcuboot-button0 = &user_button1; + }; + +}; \ No newline at end of file