Skip to content

Commit

Permalink
fix: Zephyr example
Browse files Browse the repository at this point in the history
Update Zephyr example for latest Zephyr version.
- replace board with the socs specific config
- fix warnings and cmake formatting

Signed-off-by: Marek Matej <marek.matej@espressif.com>
  • Loading branch information
Marek Matej committed Aug 16, 2024
1 parent d76cf6d commit 07f1bbe
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 60 deletions.
34 changes: 0 additions & 34 deletions examples/zephyr_example/boards/esp32_devkitc_wrover.overlay

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
/*
* Copyright (c) 2022 Espressif Systems (Shanghai) Co., Ltd.
* Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/dt-bindings/pinctrl/esp-pinctrl-common.h>
#include <dt-bindings/pinctrl/esp32-pinctrl.h>
#include <zephyr/dt-bindings/pinctrl/esp32-gpio-sigmap.h>

/ {
aliases {
en = &en_button;
Expand All @@ -28,7 +24,4 @@

&uart1 {
status = "okay";
current-speed = <115200>;
pinctrl-0 = <&uart1_default>;
pinctrl-names = "default";
};
10 changes: 5 additions & 5 deletions examples/zephyr_example/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,25 @@ int main(void)

if (!device_is_ready(esp_uart_dev)) {
printk("ESP UART not ready");
return;
return -ENODEV;
}

if (!device_is_ready(esp_boot_spec.port)) {
printk("ESP boot GPIO not ready");
return;
return -ENODEV;
}

if (!device_is_ready(esp_enable_spec.port)) {
printk("Bluetooth Enable GPIO not ready");
return;
printk("ESP enable GPIO not ready");
return -ENODEV;
}

gpio_pin_configure_dt(&esp_boot_spec, GPIO_OUTPUT_ACTIVE);
gpio_pin_configure_dt(&esp_enable_spec, GPIO_OUTPUT_INACTIVE);

if (loader_port_zephyr_init(&config) != ESP_LOADER_SUCCESS) {
printk("ESP loader init failed");
return;
return -EIO;
}

if (connect_to_target(HIGHER_BAUDRATE) == ESP_LOADER_SUCCESS) {
Expand Down
28 changes: 15 additions & 13 deletions zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
cmake_minimum_required(VERSION 3.5)

if (CONFIG_ESP_SERIAL_FLASHER)
zephyr_include_directories(
"${ZEPHYR_CURRENT_MODULE_DIR}/include"
"${ZEPHYR_CURRENT_MODULE_DIR}/port"
"${ZEPHYR_CURRENT_MODULE_DIR}/private_include"
)

zephyr_interface_library_named(esp_flasher)

zephyr_library()

zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/src/esp_loader.c
${ZEPHYR_CURRENT_MODULE_DIR}/src/esp_targets.c
${ZEPHYR_CURRENT_MODULE_DIR}/src/esp_stubs.c
${ZEPHYR_CURRENT_MODULE_DIR}/src/protocol_common.c
${ZEPHYR_CURRENT_MODULE_DIR}/src/protocol_uart.c
${ZEPHYR_CURRENT_MODULE_DIR}/src/slip.c
${ZEPHYR_CURRENT_MODULE_DIR}/src/md5_hash.c
${ZEPHYR_CURRENT_MODULE_DIR}/port/zephyr_port.c
zephyr_include_directories(
${ZEPHYR_CURRENT_MODULE_DIR}/private_include
${ZEPHYR_CURRENT_MODULE_DIR}/include
${ZEPHYR_CURRENT_MODULE_DIR}/port
)

zephyr_library_sources(
${ZEPHYR_CURRENT_MODULE_DIR}/src/esp_loader.c
${ZEPHYR_CURRENT_MODULE_DIR}/port/zephyr_port.c
${ZEPHYR_CURRENT_MODULE_DIR}/src/esp_targets.c
${ZEPHYR_CURRENT_MODULE_DIR}/src/esp_stubs.c
${ZEPHYR_CURRENT_MODULE_DIR}/src/protocol_common.c
${ZEPHYR_CURRENT_MODULE_DIR}/src/protocol_uart.c
${ZEPHYR_CURRENT_MODULE_DIR}/src/slip.c
${ZEPHYR_CURRENT_MODULE_DIR}/src/md5_hash.c
)

target_compile_definitions(esp_flasher INTERFACE SERIAL_FLASHER_INTERFACE_UART)
Expand Down

0 comments on commit 07f1bbe

Please sign in to comment.