Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions boards/teco/openearable_v2/board_init.c
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
#include <zephyr/init.h>
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/pm/device.h> // ✅ Correct Power Management API
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(board_init, LOG_LEVEL_DBG);

//#include "nrf5340_audio_common.h"

#include <zephyr/drivers/gpio.h>

#include <zephyr/pm/device.h>
#include <zephyr/pm/device_runtime.h>

#define load_switch_sd_id DT_NODELABEL(load_switch_sd)
#define load_switch_1_8_id DT_NODELABEL(load_switch)
#define load_switch_3_3_id DT_CHILD(DT_NODELABEL(bq25120a), load_switch)
//#define load_switch_3_3_id DT_NODELABEL(lsctrl)
#include "openearable_common.h"

const struct device *const cons = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
const struct device *const ls_1_8 = DEVICE_DT_GET(load_switch_1_8_id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ properties:
default: 1000
description: |
Delay in microseconds before enabling the load switch.
"#power-domain-cells":
const: 0
71 changes: 49 additions & 22 deletions boards/teco/openearable_v2/mcuboot_hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include <zephyr/kernel.h>
#include <zephyr/device.h>

//#include "bootutil/bootutil.h"
#include "bootutil/boot_hooks.h"
#include "bootutil/mcuboot_status.h"

Expand All @@ -22,63 +21,94 @@ void mcuboot_status_change(mcuboot_status_type_t status)
{
static bool led_initialized = false;

// Initialisiere LED beim ersten Aufruf
// Initialize LED on first call
if (!led_initialized) {
if (device_is_ready(led.port)) {
gpio_pin_configure_dt(&led, GPIO_OUTPUT_INACTIVE);
led_initialized = true;
}
k_timer_init(&blink_timer, blink_timer_handler, NULL);
}

/*
* The printk() calls below are kept (commented out) for future debugging.
*
* NOTE ON MCUBOOT CONSOLE LOGGING (RTT & USB CDC ACM):
* MCUboot executes extremely fast. By default, you will NOT see printk logs
* in RTT or USB UART, because of a timing race condition with the host PC:
*
* 1. RTT: MCUboot and the App have separate RTT control blocks in RAM. The
* J-Link Viewer searches RAM for the block, but MCUboot usually jumps to
* the App before J-Link can find and connect to MCUboot's RTT block.
* 2. USB UART (CDC ACM): Enumerable USB takes ~1-2 seconds. MCUboot finishes
* executing long before the PC creates /dev/ttyACM0.
*
* HOW TO VIEW THESE PRINTS:
* - RTT / USB CDC ACM: You must configure the backend in sysbuild/mcuboot/prj.conf,
* AND you must add a blocking delay (e.g., k_msleep(3000);) right here at
* the STARTUP case to give your PC/Viewer time to connect before MCUboot exits.
* - Hardware UART: The most reliable method. Route CONFIG_UART_CONSOLE=y to
* physical TTL pins. It is stateless and does not require artificial delays.
*/
// printk("mcuboot_status_change: %d\n", status);

switch (status) {
case MCUBOOT_STATUS_STARTUP:
//state_indicator.set_state(STARTUP);
// printk(" STARTUP\n");
k_timer_start(&blink_timer, K_MSEC(50), K_MSEC(50));
break;
case MCUBOOT_STATUS_UPGRADING:
k_timer_init(&blink_timer, blink_timer_handler, NULL);
// printk(" UPGRADING\n");
k_timer_start(&blink_timer, K_MSEC(250), K_MSEC(250));
break;
case MCUBOOT_STATUS_BOOTABLE_IMAGE_FOUND:
// printk(" BOOTABLE_IMAGE_FOUND\n");
k_timer_stop(&blink_timer);
gpio_pin_set_dt(&led, 0);
break;
case MCUBOOT_STATUS_NO_BOOTABLE_IMAGE_FOUND:
// printk(" NO_BOOTABLE_IMAGE_FOUND\n");
k_timer_stop(&blink_timer);
gpio_pin_set_dt(&led, 1);
break;
case MCUBOOT_STATUS_BOOT_FAILED:
//state_indicator.set_state(BOOT_FAILED);
// printk(" BOOT_FAILED\n");
k_timer_stop(&blink_timer);
gpio_pin_set_dt(&led, 1);
break;
case MCUBOOT_STATUS_USB_DFU_WAITING:
//state_indicator.set_state(USB_DFU_WAITING);
// printk(" USB_DFU_WAITING\n");
break;
case MCUBOOT_STATUS_USB_DFU_ENTERED:
//state_indicator.set_state(USB_DFU_ENTERED);
// printk(" USB_DFU_ENTERED\n");
break;
case MCUBOOT_STATUS_USB_DFU_TIMED_OUT:
//state_indicator.set_state(USB_DFU_TIMED_OUT);
// printk(" USB_DFU_TIMED_OUT\n");
break;
case MCUBOOT_STATUS_SERIAL_DFU_ENTERED:
//state_indicator.set_state(SERIAL_DFU_ENTERED);
// printk(" SERIAL_DFU_ENTERED\n");
break;
}
}

int init_load_switch()
{
int ret;

// V_LS 1.8v is required for flash.
static const struct gpio_dt_spec load_switch_pin = {
.port = DEVICE_DT_GET(DT_NODELABEL(gpio1)),
.pin = 11,
.dt_flags = GPIO_ACTIVE_HIGH
};

// LS 3.3v is required for the Error LED.
static const struct gpio_dt_spec ls_3_3_pin = {
.port = DEVICE_DT_GET(DT_NODELABEL(gpio0)),
.pin = 14,
.dt_flags = GPIO_ACTIVE_HIGH
};

ret = device_is_ready(load_switch_pin.port);
if (!ret) {
printk("Pins not ready.\n");
Expand All @@ -87,26 +117,23 @@ int init_load_switch()

ret = gpio_pin_configure_dt(&load_switch_pin, GPIO_OUTPUT_ACTIVE);
if (ret != 0) {
printk("Failed to setup Load Switch.\n");
printk("Failed to setup 1.8V load switch.\n");
return ret;
}

ret = device_is_ready(ls_3_3_pin.port);
if (!ret) {
printk("Pins not ready.\n");
return -1;
}

ret = gpio_pin_configure_dt(&ls_3_3_pin, GPIO_OUTPUT_ACTIVE);
if (ret != 0) {
printk("Failed to setup 3.3V.\n");
printk("Failed to setup 3.3V load switch.\n");
return ret;
}

return 0;
}

SYS_INIT(init_load_switch, PRE_KERNEL_2, 80);

/*
int wait() {
k_msleep(1);

return 0;
}

SYS_INIT(wait, POST_KERNEL, 80);*/
SYS_INIT(init_load_switch, PRE_KERNEL_2, 80);
35 changes: 21 additions & 14 deletions boards/teco/openearable_v2/openearable_v2_nrf5340_cpuapp_common.dts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@
status = "okay";
default-on;
};

load_switch_sd: load_switch_sd {
compatible = "load-switch";
enable-gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>;
power-delay-us = <300>; // 250us per datasheet
status = "okay";
default-on;
};

gpio_fwd: nrf-gpio-forwarder {
Expand Down Expand Up @@ -119,15 +120,15 @@
load-switch {
compatible = "load-switch";
enable-gpios = <&gpio0 14 GPIO_ACTIVE_HIGH>;
power-delay-us = <600>; // 250us per datasheet
power-delay-us = <600>;
status = "okay";
zephyr,pm-device-runtime-auto;
};
};

adau1860: adau1860@64 {
compatible = "analog,adau1860";
reg = <0x64>;
enable-gpios = <&gpio0 4 GPIO_ACTIVE_HIGH>;

ktd2026: ktd2026@30 {
compatible = "i2c-device";
reg = <0x30>;
};
};

Expand All @@ -146,21 +147,22 @@
reg = <0x62>;
};

mlx90632: mlx90632@3A {
compatible = "i2c-device";
reg = <0x3A>;
};
adau1860: adau1860@64 {
compatible = "adi,adau1860";
reg = <0x64>;
enable-gpios = <&gpio0 4 GPIO_ACTIVE_HIGH>;
};
};

&i2c3 {
compatible = "nordic,nrf-twim";
status = "okay";
pinctrl-0 = <&i2c3_default>;
pinctrl-1 = <&i2c3_sleep>;
pinctrl-names = "default", "sleep";
clock-frequency = <I2C_BITRATE_FAST_PLUS>; // 1000 kHz
zephyr,concat-buf-size = <512>;
zephyr,flash-buf-max-size = <512>;
zephyr,concat-buf-size = <1088>;
zephyr,flash-buf-max-size = <1088>;

bmp388: bmp388@76 {
compatible = "i2c-device";
Expand All @@ -175,6 +177,11 @@
bmx160: bmx160@68 {
compatible = "i2c-device";
reg = <0x68>;
};

mlx90632: mlx90632@3a {
compatible = "i2c-device";
reg = <0x3a>;
};
};

Expand Down
Loading
Loading