From 2da06bf32170ca6754191fce7e2525e5c8949cd8 Mon Sep 17 00:00:00 2001 From: Timo Date: Sun, 15 Feb 2026 20:23:39 +0100 Subject: [PATCH] minimal working example, still fails shutdown --- .gitignore | 3 +++ CMakeLists.txt | 10 ++++++++ boards/beagleplay_am6254_m4.overlay | 11 +++++++++ config.yaml | 17 +++++++++++++ prj.conf | 37 +++++++++++++++++++++++++++++ src/CMakeLists.txt | 7 ++++++ src/main.cpp | 26 ++++++++++++++++++++ 7 files changed, 111 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 boards/beagleplay_am6254_m4.overlay create mode 100644 config.yaml create mode 100644 prj.conf create mode 100644 src/CMakeLists.txt create mode 100644 src/main.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..559e449 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.cache +.vscode +build \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..76d9498 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.20.0) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) + +project(beagle-mcu-hello-world C CXX) + +set(CMAKE_BUILD_TYPE Debug) +target_compile_options(app PRIVATE -O0 -g) + +add_subdirectory(src) \ No newline at end of file diff --git a/boards/beagleplay_am6254_m4.overlay b/boards/beagleplay_am6254_m4.overlay new file mode 100644 index 0000000..2512a85 --- /dev/null +++ b/boards/beagleplay_am6254_m4.overlay @@ -0,0 +1,11 @@ +/ { + chosen { + mikrobus,uart = &main_uart5; + zephyr,console = ""; + }; +}; + +&main_uart5 { + status = "okay"; + current-speed = <115200>; +}; \ No newline at end of file diff --git a/config.yaml b/config.yaml new file mode 100644 index 0000000..8e1173e --- /dev/null +++ b/config.yaml @@ -0,0 +1,17 @@ +sample: + description: Hello World + name: beagleplay_mcu_hello_world +common: + min_ram: 1 + min_flash: 4 + tags: rproc + integration_platforms: + - beagleplay/am6254/m4 + harness: console + harness_config: + type: one_line + regex: + - "Hello World! (.*)" +tests: + sample.basic.helloworld: + tags: introduction \ No newline at end of file diff --git a/prj.conf b/prj.conf new file mode 100644 index 0000000..47c9bd6 --- /dev/null +++ b/prj.conf @@ -0,0 +1,37 @@ +# c version +CONFIG_MAIN_STACK_SIZE=8192 + +# logging +CONFIG_LOG=n +CONFIG_CONSOLE=n +CONFIG_EARLY_CONSOLE=n +CONFIG_PRINTK=n + +# gpio support +CONFIG_GPIO=y + +# uart +CONFIG_SERIAL=y +CONFIG_UART_INTERRUPT_DRIVEN=n +CONFIG_UART_NS16550=y + +# i2c +CONFIG_I2C=y + +# OpenAMP support +CONFIG_OPENAMP=y +CONFIG_OPENAMP_RSC_TABLE=y + +# IPC/Mailbox +CONFIG_IPM=y +CONFIG_MBOX=y + +# Optional: RPMsg for communication +CONFIG_RPMSG_SERVICE=y + +# build +CONFIG_NO_OPTIMIZATIONS=n +CONFIG_SIZE_OPTIMIZATIONS=n +CONFIG_SPEED_OPTIMIZATIONS=n +CONFIG_DEBUG_OPTIMIZATIONS=y +CONFIG_DEBUG_THREAD_INFO=y \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..eca4539 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.20.0) + +target_include_directories(app PRIVATE ./) + +target_sources(app PRIVATE + main.cpp +) \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..385addb --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,26 @@ +#include +#include +#include +#include +#include + +const struct device *uart_dev = DEVICE_DT_GET(DT_CHOSEN(mikrobus_uart)); + +int main(void) { + const char *message = "Hello World from mikroBUS UART!\r\n"; + int msg_len = strlen(message); + + if (!device_is_ready(uart_dev)) { + return -1; + } + + while (1) { + k_sleep(K_SECONDS(1)); + + for (int i = 0; i < msg_len; i++) { + uart_poll_out(uart_dev, message[i]); + } + } + + return 0; +} \ No newline at end of file