From 4c7e5bc179001cdb2c22977348b0b7d4450466a7 Mon Sep 17 00:00:00 2001 From: Piotr Dymacz Date: Tue, 5 Dec 2023 13:41:59 +0100 Subject: [PATCH 1/3] zephyr: rename 'led_init()' to 'io_led_init()' This fixes below warning when building with 'MCUBOOT_INDICATION_LED' enabled: mcuboot/boot/zephyr/main.c:410:5: warning: implicit declaration of function 'led_init'; did you mean 'io_led_init'? [-Wimplicit-function-declaration] 410 | led_init(); | ^~~~~~~~ | io_led_init Fixes: 433b8480 ("zephyr: Move IO functions out of main to separate file") Signed-off-by: Piotr Dymacz --- boot/zephyr/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot/zephyr/main.c b/boot/zephyr/main.c index abd2fe6eb..91c9b9b9d 100644 --- a/boot/zephyr/main.c +++ b/boot/zephyr/main.c @@ -407,7 +407,7 @@ int main(void) #ifdef CONFIG_MCUBOOT_INDICATION_LED /* LED init */ - led_init(); + io_led_init(); #endif os_heap_init(); From b07b84a46186aa241e14800d6a544370f5b4982f Mon Sep 17 00:00:00 2001 From: Piotr Dymacz Date: Tue, 5 Dec 2023 14:05:38 +0100 Subject: [PATCH 2/3] zephyr: io: include 'bootutil_log.h' and declare log module membership This fixes below error when building with 'MCUBOOT_INDICATION_LED' and 'LOG' enabled: In file included from zephyr/include/zephyr/logging/log.h:11, from zephyr/include/zephyr/usb/usb_device.h:43, from bootloader/mcuboot/boot/zephyr/io.c:26: mcuboot/boot/zephyr/io.c: In function 'io_led_init': zephyr/include/zephyr/logging/log_core.h:151:20: error: '__log_level' undeclared (first use in this function) 151 | (_level <= __log_level) && \ | ^~~~~~~~~~~ Fixes: 433b8480 ("zephyr: Move IO functions out of main to separate file") Signed-off-by: Piotr Dymacz --- boot/zephyr/io.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/boot/zephyr/io.c b/boot/zephyr/io.c index fc1966d7f..e6d54d3c7 100644 --- a/boot/zephyr/io.c +++ b/boot/zephyr/io.c @@ -28,6 +28,7 @@ #include #include "target.h" +#include "bootutil/bootutil_log.h" #if defined(CONFIG_BOOT_SERIAL_PIN_RESET) || defined(CONFIG_BOOT_FIRMWARE_LOADER_PIN_RESET) #include @@ -78,6 +79,8 @@ static const struct gpio_dt_spec led0 = GPIO_DT_SPEC_GET(LED0_NODE, gpios); #error "Unsupported board: led0 devicetree alias is not defined" #endif +BOOT_LOG_MODULE_DECLARE(mcuboot); + void io_led_init(void) { if (!device_is_ready(led0.port)) { From 1f3b103dbfc35aa88c91f6a4283d0c829a611fbc Mon Sep 17 00:00:00 2001 From: Piotr Dymacz Date: Tue, 5 Dec 2023 14:26:22 +0100 Subject: [PATCH 3/3] zephyr: io: add 'io_led_set()' The static declaration of 'led0' was moved to 'io.c' which broke building with the 'MCUBOOT_INDICATION_LED' enabled: mcuboot/boot/zephyr/main.c:380:22: error: 'led0' undeclared (first use in this function) 380 | gpio_pin_set_dt(&led0, 1); | ^~~~ This adds simple function 'io_led_set()' for changing LED's value. Fixes: 433b8480 ("zephyr: Move IO functions out of main to separate file") Signed-off-by: Piotr Dymacz --- boot/zephyr/include/io/io.h | 5 +++++ boot/zephyr/io.c | 5 +++++ boot/zephyr/main.c | 8 ++++---- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/boot/zephyr/include/io/io.h b/boot/zephyr/include/io/io.h index 332eefbd8..145530bb8 100644 --- a/boot/zephyr/include/io/io.h +++ b/boot/zephyr/include/io/io.h @@ -34,6 +34,11 @@ extern "C" { */ void io_led_init(void); +/* + * Sets value of the configured LED. + */ +void io_led_set(int value); + /* * Checks if GPIO is set in the required way to remain in serial recovery mode * diff --git a/boot/zephyr/io.c b/boot/zephyr/io.c index e6d54d3c7..309f1ab94 100644 --- a/boot/zephyr/io.c +++ b/boot/zephyr/io.c @@ -91,6 +91,11 @@ void io_led_init(void) gpio_pin_configure_dt(&led0, GPIO_OUTPUT); gpio_pin_set_dt(&led0, 0); } + +void io_led_set(int value) +{ + gpio_pin_set_dt(&led0, value); +} #endif /* CONFIG_MCUBOOT_INDICATION_LED */ #if defined(CONFIG_BOOT_SERIAL_ENTRANCE_GPIO) || defined(CONFIG_BOOT_USB_DFU_GPIO) || \ diff --git a/boot/zephyr/main.c b/boot/zephyr/main.c index 91c9b9b9d..c6a0f74ae 100644 --- a/boot/zephyr/main.c +++ b/boot/zephyr/main.c @@ -377,7 +377,7 @@ static void boot_serial_enter() int rc; #ifdef CONFIG_MCUBOOT_INDICATION_LED - gpio_pin_set_dt(&led0, 1); + io_led_set(1); #endif mcuboot_status_change(MCUBOOT_STATUS_SERIAL_DFU_ENTERED); @@ -434,7 +434,7 @@ int main(void) #if defined(CONFIG_BOOT_USB_DFU_GPIO) if (io_detect_pin()) { #ifdef CONFIG_MCUBOOT_INDICATION_LED - gpio_pin_set_dt(&led0, 1); + io_led_set(1); #endif mcuboot_status_change(MCUBOOT_STATUS_USB_DFU_ENTERED); @@ -475,7 +475,7 @@ int main(void) uint32_t start = k_uptime_get_32(); #ifdef CONFIG_MCUBOOT_INDICATION_LED - gpio_pin_set_dt(&led0, 1); + io_led_set(1); #endif #endif @@ -499,7 +499,7 @@ int main(void) boot_serial_check_start(&boot_funcs,timeout_in_ms); #ifdef CONFIG_MCUBOOT_INDICATION_LED - gpio_pin_set_dt(&led0, 0); + io_led_set(0); #endif #endif