Skip to content

Commit 1292bf1

Browse files
rosterlohclaude
andcommitted
data_collection: new esp32p4_nano app with ethernet + SMP/UDP OTA
Add a minimal data_collection application targeting esp32p4_nano/esp32p4/hpcore: - Ethernet (RMII EMAC) with DHCPv4 addressing - sysbuild + MCUboot (swap-using-move, dev signing) - OTA over SMP/UDP (MCUmgr IMG + OS groups) - UART shell on the console Register the app in poe.toml's app task (single allowed board). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 4207b8e commit 1292bf1

7 files changed

Lines changed: 117 additions & 1 deletion

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cmake_minimum_required(VERSION 3.20.0)
2+
3+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
4+
5+
project(data_collection)
6+
7+
# We always want colored gcc output
8+
zephyr_compile_options(-fdiagnostics-color=always)
9+
10+
target_sources(app PRIVATE src/main.c)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
VERSION_MAJOR = 0
2+
VERSION_MINOR = 1
3+
PATCHLEVEL = 0
4+
VERSION_TWEAK = 0
5+
EXTRAVERSION =
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Application
2+
CONFIG_MAIN_STACK_SIZE=2560
3+
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2304
4+
CONFIG_SHELL=y
5+
CONFIG_REBOOT=y
6+
CONFIG_LOG=y
7+
8+
# Networking: Ethernet (RMII EMAC) + DHCPv4
9+
CONFIG_NETWORKING=y
10+
CONFIG_NET_IPV4=y
11+
CONFIG_NET_UDP=y
12+
CONFIG_NET_DHCPV4=y
13+
CONFIG_NET_L2_ETHERNET=y
14+
CONFIG_ETH_ESP32=y
15+
CONFIG_NET_SOCKETS=y
16+
CONFIG_NET_MGMT=y
17+
CONFIG_NET_MGMT_EVENT=y
18+
CONFIG_NET_CONFIG_SETTINGS=y
19+
CONFIG_NET_CONFIG_NEED_IPV4=y
20+
21+
# Flash and image management (MCUboot OTA receiver)
22+
CONFIG_BOOTLOADER_MCUBOOT=y
23+
CONFIG_FLASH=y
24+
CONFIG_FLASH_MAP=y
25+
CONFIG_STREAM_FLASH=y
26+
CONFIG_IMG_MANAGER=y
27+
CONFIG_IMG_ERASE_PROGRESSIVELY=y
28+
CONFIG_MCUBOOT_IMG_MANAGER=y
29+
30+
# MCUmgr: SMP protocol for OTA image upload and OS management
31+
CONFIG_NET_BUF=y
32+
CONFIG_ZCBOR=y
33+
CONFIG_CRC=y
34+
CONFIG_MCUMGR=y
35+
CONFIG_MCUMGR_GRP_IMG=y
36+
CONFIG_MCUMGR_GRP_OS=y
37+
38+
# OTA over SMP/UDP (IPv4) - upload with `mcumgr --conntype udp ...`
39+
CONFIG_MCUMGR_TRANSPORT_UDP=y
40+
CONFIG_MCUMGR_TRANSPORT_UDP_IPV4=y
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) 2026 Richard Osterloh
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#include <zephyr/kernel.h>
7+
#include <zephyr/logging/log.h>
8+
#include <zephyr/net/net_if.h>
9+
#include <zephyr/net/net_mgmt.h>
10+
#include <zephyr/net/net_event.h>
11+
12+
LOG_MODULE_REGISTER(main, LOG_LEVEL_INF);
13+
14+
static struct net_mgmt_event_callback ipv4_cb;
15+
16+
static void on_ipv4_addr_add(struct net_mgmt_event_callback *cb, uint64_t mgmt_event,
17+
struct net_if *iface)
18+
{
19+
if (mgmt_event != NET_EVENT_IPV4_ADDR_ADD) {
20+
return;
21+
}
22+
23+
for (int i = 0; i < NET_IF_MAX_IPV4_ADDR; i++) {
24+
struct net_if_addr *if_addr = &iface->config.ip.ipv4->unicast[i].ipv4;
25+
char buf[NET_IPV4_ADDR_LEN];
26+
27+
if (!if_addr->is_used || if_addr->addr_type != NET_ADDR_DHCP) {
28+
continue;
29+
}
30+
31+
LOG_INF("IPv4 address: %s",
32+
net_addr_ntop(AF_INET, &if_addr->address.in_addr, buf, sizeof(buf)));
33+
}
34+
}
35+
36+
int main(void)
37+
{
38+
LOG_INF("data_collection starting (SMP/UDP OTA ready)");
39+
40+
net_mgmt_init_event_callback(&ipv4_cb, on_ipv4_addr_add, NET_EVENT_IPV4_ADDR_ADD);
41+
net_mgmt_add_event_callback(&ipv4_cb);
42+
43+
return 0;
44+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SB_CONFIG_BOOTLOADER_MCUBOOT=y
2+
SB_CONFIG_MCUBOOT_MODE_SWAP_USING_MOVE=y
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# MCUboot configuration for the ESP32-P4-Nano (esp32p4_nano board).
2+
3+
# Image signing: none for development.
4+
# Switch to CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256 before production and
5+
# generate a key pair with: west sign --tool imgtool --key <key.pem>
6+
CONFIG_BOOT_SIGNATURE_TYPE_NONE=y
7+
CONFIG_BOOT_VALIDATE_SLOT0=n
8+
9+
# Silent bootloader - no serial output to avoid interfering with app console
10+
CONFIG_BOOT_BANNER=n
11+
CONFIG_UART_CONSOLE=n
12+
CONFIG_CONSOLE=n
13+
CONFIG_SERIAL=n
14+
CONFIG_MCUBOOT_LOG_LEVEL_OFF=y

poe.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ case "${app}" in
278278
pico_fw) ALLOWED="rpi_pico/rp2040/w"; DEFAULT="rpi_pico/rp2040/w" ;;
279279
pt_mcp) ALLOWED="xiao_esp32c5/esp32c5/hpcore"; DEFAULT="xiao_esp32c5/esp32c5/hpcore" ;;
280280
rasprover) ALLOWED="ros_driver/esp32/procpu native_sim/native/64"; DEFAULT="ros_driver/esp32/procpu" ;;
281+
data_collection) ALLOWED="esp32p4_nano/esp32p4/hpcore"; DEFAULT="esp32p4_nano/esp32p4/hpcore" ;;
281282
*) echo "unknown app: ${app}" >&2; exit 2 ;;
282283
esac
283284
@@ -294,7 +295,7 @@ case "${sysbuild}" in true|True|1|yes) EXTRA="--sysbuild" ;; esac
294295
west build -b "$BOARD" -p always $EXTRA --build-dir builds/${app} applications/${app}
295296
"""
296297
args = [
297-
{ name = "app", positional = true, help = "App name (motor_controller, joystick_controller, embedded_vision, force_sensor, pico_fw, pt_mcp, rasprover)" },
298+
{ name = "app", positional = true, help = "App name (motor_controller, joystick_controller, embedded_vision, force_sensor, pico_fw, pt_mcp, rasprover, data_collection)" },
298299
{ name = "board", options = ["-b", "--board"], help = "Override target board (must be in app's allowed list)" },
299300
{ name = "sysbuild", type = "boolean", help = "Build with sysbuild (e.g. for MCUboot integration)" },
300301
]

0 commit comments

Comments
 (0)