From c8df9b3f20ade49bcacaeb14ed42a3c8e5b97315 Mon Sep 17 00:00:00 2001 From: Artemis Tosini Date: Sun, 19 Nov 2023 05:33:59 +0000 Subject: [PATCH] Start adding custom board --- CMakeLists.txt | 7 ++- boards/xtensa/minico2/Kconfig.board | 7 +++ boards/xtensa/minico2/Kconfig.defconfig | 12 ++++ boards/xtensa/minico2/Kconfig.sysbuild | 10 ++++ boards/xtensa/minico2/board.cmake | 11 ++++ boards/xtensa/minico2/minico2-pinctrl.dtsi | 16 +++++ boards/xtensa/minico2/minico2.dts | 70 ++++++++++++++++++++++ boards/xtensa/minico2/minico2_defconfig | 13 ++++ flake.lock | 8 +-- src/main.c | 40 ------------- 10 files changed, 149 insertions(+), 45 deletions(-) create mode 100644 boards/xtensa/minico2/Kconfig.board create mode 100644 boards/xtensa/minico2/Kconfig.defconfig create mode 100644 boards/xtensa/minico2/Kconfig.sysbuild create mode 100644 boards/xtensa/minico2/board.cmake create mode 100644 boards/xtensa/minico2/minico2-pinctrl.dtsi create mode 100644 boards/xtensa/minico2/minico2.dts create mode 100644 boards/xtensa/minico2/minico2_defconfig diff --git a/CMakeLists.txt b/CMakeLists.txt index be8ebaa..8d8ae89 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,10 @@ cmake_minimum_required(VERSION 3.20.0) + +list(APPEND DTS_ROOT ${CMAKE_CURRENT_LIST_DIR}) +list(APPEND BOARD_ROOT ${CMAKE_CURRENT_LIST_DIR}) +set(BOARD minico2) + find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) -project(blink) +project(minico2) target_sources(app PRIVATE src/main.c) diff --git a/boards/xtensa/minico2/Kconfig.board b/boards/xtensa/minico2/Kconfig.board new file mode 100644 index 0000000..aa76db2 --- /dev/null +++ b/boards/xtensa/minico2/Kconfig.board @@ -0,0 +1,7 @@ +config BOARD_MINICO2 + bool "MiniCO2 Carbon Dioxide Monitor" + depends on SOC_SERIES_ESP32 + +choice SOC_PART_NUMBER + default SOC_ESP32_WROOM_32UE_N4 +endchoice diff --git a/boards/xtensa/minico2/Kconfig.defconfig b/boards/xtensa/minico2/Kconfig.defconfig new file mode 100644 index 0000000..0b8f23a --- /dev/null +++ b/boards/xtensa/minico2/Kconfig.defconfig @@ -0,0 +1,12 @@ +# Copyright (c) 2023 Espressif Systems (Shanghai) Co., Ltd. +# SPDX-License-Identifier: Apache-2.0 + +config BOARD + default "minico2" + depends on BOARD_MINICO2 + +config ENTROPY_GENERATOR + default y + +config HEAP_MEM_POOL_SIZE + default 98304 diff --git a/boards/xtensa/minico2/Kconfig.sysbuild b/boards/xtensa/minico2/Kconfig.sysbuild new file mode 100644 index 0000000..3a2d17a --- /dev/null +++ b/boards/xtensa/minico2/Kconfig.sysbuild @@ -0,0 +1,10 @@ +# Copyright (c) 2023 Espressif Systems (Shanghai) Co., Ltd. +# SPDX-License-Identifier: Apache-2.0 + +choice BOOTLOADER + default BOOTLOADER_MCUBOOT +endchoice + +choice BOOT_SIGNATURE_TYPE + default BOOT_SIGNATURE_TYPE_NONE +endchoice diff --git a/boards/xtensa/minico2/board.cmake b/boards/xtensa/minico2/board.cmake new file mode 100644 index 0000000..ad53de1 --- /dev/null +++ b/boards/xtensa/minico2/board.cmake @@ -0,0 +1,11 @@ +# Copyright (c) 2023 Espressif Systems (Shanghai) Co., Ltd. +# SPDX-License-Identifier: Apache-2.0 + +if(NOT "${OPENOCD}" MATCHES "^${ESPRESSIF_TOOLCHAIN_PATH}/.*") + set(OPENOCD OPENOCD-NOTFOUND) +endif() + +find_program(OPENOCD openocd PATHS ${ESPRESSIF_TOOLCHAIN_PATH}/openocd-esp32/bin NO_DEFAULT_PATH) + +include(${ZEPHYR_BASE}/boards/common/esp32.board.cmake) +include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) diff --git a/boards/xtensa/minico2/minico2-pinctrl.dtsi b/boards/xtensa/minico2/minico2-pinctrl.dtsi new file mode 100644 index 0000000..8d2c14c --- /dev/null +++ b/boards/xtensa/minico2/minico2-pinctrl.dtsi @@ -0,0 +1,16 @@ +#include +#include +#include + +&pinctrl { + uart0_default: uart0_default { + group1 { + pinmux = ; + output-high; + }; + group2 { + pinmux = ; + bias-pull-up; + }; + }; +}; diff --git a/boards/xtensa/minico2/minico2.dts b/boards/xtensa/minico2/minico2.dts new file mode 100644 index 0000000..907aa91 --- /dev/null +++ b/boards/xtensa/minico2/minico2.dts @@ -0,0 +1,70 @@ +/dts-v1/; +#include +#include "minico2-pinctrl.dtsi" + +/ { + model = "MiniCO2 Revision 0"; + compatible = "espressif,esp32"; + + chosen { + zephyr,sram = &sram0; + zephyr,console = &uart0; + zephyr,shell-uart = &uart0; + zephyr,flash = &flash0; + }; +}; + +&cpu0 { + clock-frequency = ; +}; + +&cpu1 { + clock-frequency = ; +}; + +&uart0 { + status = "okay"; + current-speed = <115200>; + pinctrl-0 = <&uart0_default>; + pinctrl-names = "default"; +}; + +/* Stolen from an Espressif devkit's dts, thanks Espressif */ +&flash0 { + status = "okay"; + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + /* Reserve 60kB for the bootloader */ + boot_partition: partition@1000 { + label = "mcuboot"; + reg = <0x00001000 0x0000F000>; + read-only; + }; + + /* Reserve 1024kB for the application in slot 0 */ + slot0_partition: partition@10000 { + label = "image-0"; + reg = <0x00010000 0x00100000>; + }; + + /* Reserve 1024kB for the application in slot 1 */ + slot1_partition: partition@110000 { + label = "image-1"; + reg = <0x00110000 0x00100000>; + }; + + /* Reserve 256kB for the scratch partition */ + scratch_partition: partition@210000 { + label = "image-scratch"; + reg = <0x00210000 0x00040000>; + }; + + storage_partition: partition@250000 { + label = "storage"; + reg = <0x00250000 0x00006000>; + }; + }; +}; diff --git a/boards/xtensa/minico2/minico2_defconfig b/boards/xtensa/minico2/minico2_defconfig new file mode 100644 index 0000000..2dec024 --- /dev/null +++ b/boards/xtensa/minico2/minico2_defconfig @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Espressif Systems (Shanghai) Co., Ltd. +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_BOARD_MINICO2=y +CONFIG_SOC_SERIES_ESP32=y + +CONFIG_MAIN_STACK_SIZE=2048 + +CONFIG_CONSOLE=y +CONFIG_SERIAL=y +CONFIG_UART_CONSOLE=y + +CONFIG_GPIO=y diff --git a/flake.lock b/flake.lock index 16bbe4e..34ed778 100644 --- a/flake.lock +++ b/flake.lock @@ -10,11 +10,11 @@ ] }, "locked": { - "lastModified": 1699858083, - "narHash": "sha256-EXmVoYDYszdWlaxRzedQ3Q7ehbqIGfbe9EaHSBD4cgQ=", + "lastModified": 1700363859, + "narHash": "sha256-zT0vd5Vhd9dR3bTJpFCwtiBRkjY0+iYhvXVifIQ7vSo=", "ref": "refs/heads/canon", - "rev": "453af715eebd7102131d2cc6846dd23d49f853ac", - "revCount": 12, + "rev": "6400d73e5f103f15550beb8bfb0315a98121dfef", + "revCount": 13, "type": "git", "url": "https://git.mildlyfunctional.gay/artemist/packages.git" }, diff --git a/src/main.c b/src/main.c index a6d0954..2d46a11 100644 --- a/src/main.c +++ b/src/main.c @@ -1,44 +1,4 @@ -/* - * Copyright (c) 2016 Intel Corporation - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include - -/* 1000 msec = 1 sec */ -#define SLEEP_TIME_MS 1000 - -/* The devicetree node identifier for the "led0" alias. */ -#define LED0_NODE DT_ALIAS(led0) - -/* - * A build error on this line means your board is unsupported. - * See the sample documentation for information on how to fix this. - */ -static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED0_NODE, gpios); - int main(void) { - int ret; - - if (!gpio_is_ready_dt(&led)) { - return 0; - } - - ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE); - if (ret < 0) { - return 0; - } - - while (1) { - ret = gpio_pin_toggle_dt(&led); - if (ret < 0) { - return 0; - } - k_msleep(SLEEP_TIME_MS); - } - return 0; }