diff --git a/boards/m5stack/m5stack_atom_lite/Kconfig.defconfig b/boards/m5stack/m5stack_atom_lite/Kconfig.defconfig new file mode 100644 index 0000000000..d56d34b22d --- /dev/null +++ b/boards/m5stack/m5stack_atom_lite/Kconfig.defconfig @@ -0,0 +1,26 @@ +# M5Stack ATOM Lite board configuration +# Copyright (c) 2023 Benjamin Cabé +# Copyright (c) 2022 AVSystem Sławomir Wolf Sp.j. (AVSystem) +# SPDX-License-Identifier: Apache-2.0 + +if BOARD_M5STACK_ATOM_LITE_ESP32_PROCPU + +config HEAP_MEM_POOL_ADD_SIZE_BOARD + int + default 65535 if WIFI && BT + default 51200 if WIFI + default 40960 if BT + default 4096 + +choice BT_HCI_BUS_TYPE + default BT_ESP32 if BT +endchoice + +endif # BOARD_M5STACK_ATOM_LITE_ESP32_PROCPU + +if BOARD_M5STACK_ATOM_LITE_ESP32_APPCPU + +config HEAP_MEM_POOL_ADD_SIZE_BOARD + default 256 + +endif # BOARD_M5STACK_ATOM_LITE_ESP32_APPCPU diff --git a/boards/m5stack/m5stack_atom_lite/Kconfig.m5stack_atom_lite b/boards/m5stack/m5stack_atom_lite/Kconfig.m5stack_atom_lite new file mode 100644 index 0000000000..2150b48e32 --- /dev/null +++ b/boards/m5stack/m5stack_atom_lite/Kconfig.m5stack_atom_lite @@ -0,0 +1,10 @@ +# M5Stack Atom Lite board configuration + +# Copyright (c) 2024 Nikola Trifunovic +# Copyright (c) 2022 AVSystem Sławomir Wolf Sp.j. (AVSystem) +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_M5STACK_ATOM_LITE + select SOC_ESP32_PICO_D4 + select SOC_ESP32_PROCPU if BOARD_M5STACK_ATOM_LITE_ESP32_PROCPU + select SOC_ESP32_APPCPU if BOARD_M5STACK_ATOM_LITE_ESP32_APPCPU diff --git a/boards/m5stack/m5stack_atom_lite/board.cmake b/boards/m5stack/m5stack_atom_lite/board.cmake new file mode 100644 index 0000000000..91b3caa2c7 --- /dev/null +++ b/boards/m5stack/m5stack_atom_lite/board.cmake @@ -0,0 +1,12 @@ +# 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) + +# the default ESP32 baud rate is not supported +board_runner_args(esp32 "--esp-baud-rate=1500000") diff --git a/boards/m5stack/m5stack_atom_lite/board.yaml b/boards/m5stack/m5stack_atom_lite/board.yaml new file mode 100644 index 0000000000..d7202eda26 --- /dev/null +++ b/boards/m5stack/m5stack_atom_lite/board.yaml @@ -0,0 +1,5 @@ +board: + name: m5stack_atom_lite + vendor: m5stack + socs: + - name: esp32 diff --git a/boards/m5stack/m5stack_atom_lite/doc/img/m5stack_atom_lite.webp b/boards/m5stack/m5stack_atom_lite/doc/img/m5stack_atom_lite.webp new file mode 100644 index 0000000000..532b73af8f Binary files /dev/null and b/boards/m5stack/m5stack_atom_lite/doc/img/m5stack_atom_lite.webp differ diff --git a/boards/m5stack/m5stack_atom_lite/doc/index.rst b/boards/m5stack/m5stack_atom_lite/doc/index.rst new file mode 100644 index 0000000000..2e8c1fade4 --- /dev/null +++ b/boards/m5stack/m5stack_atom_lite/doc/index.rst @@ -0,0 +1,134 @@ +.. _m5stack_atom_lite: + +M5Stack ATOM Lite +################# + +Overview +******** + +M5Stack ATOM Lite is an ESP32-based development board from M5Stack. + +It features the following integrated components: + +- ESP32-PICO-D4 chip (240MHz dual core, Wi-Fi/BLE 5.0) +- 520KB SRAM +- SK6812 RGB LED +- Infrared LED +- 1x Grove extension port + + +.. figure:: img/m5stack_atom_lite.webp + :align: center + :alt: M5Stack ATOM Lite + + M5Stack ATOM Lite + + +Supported Features +================== + +The Zephyr m5stack_atom_lite board configuration supports the following hardware features: + ++-----------+------------+-------------------------------------+ +| Interface | Controller | Driver/Component | ++===========+============+=====================================+ +| NVIC | on-chip | nested vector interrupt controller | ++-----------+------------+-------------------------------------+ +| UART | on-chip | serial port-polling; | +| | | serial port-interrupt | ++-----------+------------+-------------------------------------+ +| PINMUX | on-chip | pinmux | ++-----------+------------+-------------------------------------+ +| GPIO | on-chip | gpio | ++-----------+------------+-------------------------------------+ +| I2C | on-chip | i2c | ++-----------+------------+-------------------------------------+ +| SPI | on-chip | spi | ++-----------+------------+-------------------------------------+ +| CLOCK | on-chip | reset and clock control | ++-----------+------------+-------------------------------------+ +| COUNTER | on-chip | rtc | ++-----------+------------+-------------------------------------+ +| WATCHDOG | on-chip | independent watchdog | ++-----------+------------+-------------------------------------+ +| PWM | on-chip | pwm | ++-----------+------------+-------------------------------------+ +| ADC | on-chip | adc | ++-----------+------------+-------------------------------------+ +| DAC | on-chip | dac | ++-----------+------------+-------------------------------------+ +| die-temp | on-chip | die temperature sensor | ++-----------+------------+-------------------------------------+ + + +Start Application Development +***************************** + +Before powering up your M5Stack ATOM Lite, please make sure that the board is in good +condition with no obvious signs of damage. + +System requirements +=================== + +Prerequisites +------------- + +Espressif HAL requires WiFi and Bluetooth binary blobs in order work. Run the command +below to retrieve those files. + +.. code-block:: shell + + west blobs fetch hal_espressif + +.. note:: + + It is recommended running the command above after :file:`west update`. + +Building & Flashing +------------------- + +Build and flash applications as usual (see :ref:`build_an_application` and +:ref:`application_run` for more details). + +.. zephyr-app-commands:: + :zephyr-app: samples/hello_world + :board: m5stack_atom_lite/esp32/procpu + :goals: build + +The usual ``flash`` target will work with the ``m5stack_atom_lite`` board +configuration. Here is an example for the :ref:`hello_world` +application. + +.. zephyr-app-commands:: + :zephyr-app: samples/hello_world + :board: m5stack_atom_lite/esp32/procpu + :goals: flash + +The baud rate of 921600bps is set by default. If experiencing issues when flashing, +try using different values by using ``--esp-baud-rate `` option during +``west flash`` (e.g. ``west flash --esp-baud-rate 115200``). + +You can also open the serial monitor using the following command: + +.. code-block:: shell + + west espressif monitor + +After the board has automatically reset and booted, you should see the following +message in the monitor: + +.. code-block:: console + + ***** Booting Zephyr OS vx.x.x-xxx-gxxxxxxxxxxxx ***** + Hello World! m5stack_atom_lite + +Debugging +--------- + +M5Stack ATOM Lite debugging is not supported due to pinout limitations. + +Related Documents +***************** +- `M5Stack ATOM Lite docs `_ +- `M5Stack ATOM Lite schematic `_ +- `ESP32-PICO-D4 Datasheet `_ (PDF) diff --git a/boards/m5stack/m5stack_atom_lite/grove_connectors.dtsi b/boards/m5stack/m5stack_atom_lite/grove_connectors.dtsi new file mode 100644 index 0000000000..a2926d68eb --- /dev/null +++ b/boards/m5stack/m5stack_atom_lite/grove_connectors.dtsi @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2024 Nikola Trifunovic + * Copyright (c) 2023 Benjamin Cabé + * SPDX-License-Identifier: Apache-2.0 + */ + +/ { + grove_header: grove_header { + compatible = "grove-header"; + #gpio-cells = <2>; + gpio-map-mask = <0xffffffff 0xffffffc0>; + gpio-map-pass-thru = <0 0x3f>; + gpio-map = <0 0 &gpio0 26 0>, + <1 0 &gpio1 0 0>; + }; +}; + +grove_i2c1: &i2c1 {}; diff --git a/boards/m5stack/m5stack_atom_lite/m5stack_atom_lite-pinctrl.dtsi b/boards/m5stack/m5stack_atom_lite/m5stack_atom_lite-pinctrl.dtsi new file mode 100644 index 0000000000..8db8fd6cd3 --- /dev/null +++ b/boards/m5stack/m5stack_atom_lite/m5stack_atom_lite-pinctrl.dtsi @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2024 Nikola Trifunovic + * Copyright (c) 2023 Benjamin Cabé + * Copyright (c) 2023 Martin Kiepfer + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include + +&pinctrl { + uart0_default: uart0_default { + group1 { + pinmux = ; + output-high; + }; + group2 { + pinmux = ; + bias-pull-up; + }; + }; + + i2c0_default: i2c0_default { + group1 { + pinmux = , + ; + bias-pull-up; + drive-open-drain; + output-high; + }; + }; + + i2c1_default: i2c1_default { + group1 { + pinmux = , + ; + bias-pull-up; + drive-open-drain; + output-high; + }; + }; + + spim2_default: spim2_default { + group1 { + pinmux = , + , + ; + }; + group2 { + pinmux = ; + output-low; + }; + + }; + + /* used for SK6812 */ + spim3_ws2812_led: spim3_ws2812_led { + group1 { + pinmux = ; + output-low; + }; + }; +}; diff --git a/boards/m5stack/m5stack_atom_lite/m5stack_atom_lite_esp32_appcpu.dts b/boards/m5stack/m5stack_atom_lite/m5stack_atom_lite_esp32_appcpu.dts new file mode 100644 index 0000000000..59a908a3fe --- /dev/null +++ b/boards/m5stack/m5stack_atom_lite/m5stack_atom_lite_esp32_appcpu.dts @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2023 Espressif Systems (Shanghai) Co., Ltd. + * + * SPDX-License-Identifier: Apache-2.0 + */ +/dts-v1/; + +#include + +/ { + model = "M5Stack Atom Lite APPCPU"; + compatible = "espressif,esp32"; + + chosen { + zephyr,sram = &sram0; + zephyr,ipc_shm = &shm0; + zephyr,ipc = &ipm0; + }; +}; + +&cpu0 { + clock-frequency = ; +}; + +&cpu1 { + clock-frequency = ; +}; + +&ipm0 { + status = "okay"; +}; + +&trng0 { + status = "okay"; +}; + +&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/m5stack/m5stack_atom_lite/m5stack_atom_lite_esp32_appcpu.yaml b/boards/m5stack/m5stack_atom_lite/m5stack_atom_lite_esp32_appcpu.yaml new file mode 100644 index 0000000000..0880b2f798 --- /dev/null +++ b/boards/m5stack/m5stack_atom_lite/m5stack_atom_lite_esp32_appcpu.yaml @@ -0,0 +1,27 @@ +identifier: m5stack_atom_lite/esp32/appcpu +name: M5Stack ATOM Lite +type: mcu +arch: xtensa +toolchain: + - zephyr +supported: + - uart +testing: + ignore_tags: + - net + - bluetooth + - flash + - cpp + - posix + - watchdog + - logging + - kernel + - pm + - gpio + - crypto + - eeprom + - heap + - cmsis_rtos + - jwt + - zdsp +vendor: m5stack diff --git a/boards/m5stack/m5stack_atom_lite/m5stack_atom_lite_esp32_appcpu_defconfig b/boards/m5stack/m5stack_atom_lite/m5stack_atom_lite_esp32_appcpu_defconfig new file mode 100644 index 0000000000..9abf2ff043 --- /dev/null +++ b/boards/m5stack/m5stack_atom_lite/m5stack_atom_lite_esp32_appcpu_defconfig @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_MAIN_STACK_SIZE=2048 +CONFIG_CLOCK_CONTROL=y diff --git a/boards/m5stack/m5stack_atom_lite/m5stack_atom_lite_esp32_procpu.dts b/boards/m5stack/m5stack_atom_lite/m5stack_atom_lite_esp32_procpu.dts new file mode 100644 index 0000000000..53f6175e4d --- /dev/null +++ b/boards/m5stack/m5stack_atom_lite/m5stack_atom_lite_esp32_procpu.dts @@ -0,0 +1,190 @@ +/* + * Copyright (c) 2024 Nikola Trifunovic + * Copyright (c) 2023 Benjamin Cabé + * Copyright (c) 2023 Martin Kiepfer + * + * SPDX-License-Identifier: Apache-2.0 + */ +/dts-v1/; + +#include +#include "m5stack_atom_lite-pinctrl.dtsi" +#include "grove_connectors.dtsi" +#include +#include +#include + +/ { + model = "M5Stack ATOM Lite PROCPU"; + compatible = "m5stack,m5stack-atom-lite"; + + chosen { + zephyr,sram = &sram0; + zephyr,console = &uart0; + zephyr,shell-uart = &uart0; + zephyr,flash = &flash0; + zephyr,code-partition = &slot0_partition; + }; + + aliases { + sw0 = &user_button_0; + watchdog0 = &wdt0; + i2c-0 = &i2c0; + led-strip = &status_rgb_led; + }; + + leds { + compatible = "gpio-leds"; + + ir_led: led_0 { + gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>; + label = "Infrared LED"; + }; + }; + + gpio_keys { + compatible = "gpio-keys"; + + user_button_0: button_0 { + label = "User button 0"; + gpios = <&gpio1 7 GPIO_ACTIVE_LOW>; // G39 + zephyr,code = ; + }; + }; +}; + +&cpu0 { + clock-frequency = ; +}; + +&cpu1 { + clock-frequency = ; +}; + +&uart0 { + status = "okay"; + current-speed = <115200>; + pinctrl-0 = <&uart0_default>; + pinctrl-names = "default"; +}; + +&i2c0 { + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c0_default>; + pinctrl-names = "default"; + sda-gpios = <&gpio0 25 GPIO_OPEN_DRAIN>; + scl-gpios = <&gpio0 21 GPIO_OPEN_DRAIN>; + +}; + +&i2c1 { + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c1_default>; + pinctrl-names = "default"; + sda-gpios = <&gpio0 26 GPIO_OPEN_DRAIN>; + scl-gpios = <&gpio1 0 GPIO_OPEN_DRAIN>; +}; + + +&timer0 { + status = "okay"; +}; + +&timer1 { + status = "okay"; +}; + +&timer2 { + status = "okay"; +}; + +&timer3 { + status = "okay"; +}; + +&trng0 { + status = "okay"; +}; + +&spi2 { + #address-cells = <1>; + #size-cells = <0>; + pinctrl-0 = <&spim2_default>; + pinctrl-names = "default"; +}; + +/* used for SK6812 */ +&spi3 { + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + line-idle-low; + pinctrl-0 = <&spim3_ws2812_led>; + pinctrl-names = "default"; + + status_rgb_led: ws2812@0 { + compatible = "worldsemi,ws2812-spi"; + reg = <0>; + spi-max-frequency = ; + + chain-length = <1>; + color-mapping = , + , + ; + spi-one-frame = ; + spi-zero-frame = ; + }; +}; + +&gpio0 { + status = "okay"; +}; + +&gpio1 { + status = "okay"; +}; + +&wdt0 { + status = "okay"; +}; + +&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/m5stack/m5stack_atom_lite/m5stack_atom_lite_esp32_procpu.yaml b/boards/m5stack/m5stack_atom_lite/m5stack_atom_lite_esp32_procpu.yaml new file mode 100644 index 0000000000..14462ac58f --- /dev/null +++ b/boards/m5stack/m5stack_atom_lite/m5stack_atom_lite_esp32_procpu.yaml @@ -0,0 +1,19 @@ +identifier: m5stack_atom_lite/esp32/procpu +name: M5Stack ATOM Lite +type: mcu +arch: xtensa +toolchain: + - zephyr +supported: + - gpio + - i2c + - spi + - watchdog + - uart + - pinmux + - nvs +testing: + ignore_tags: + - net + - bluetooth +vendor: m5stack diff --git a/boards/m5stack/m5stack_atom_lite/m5stack_atom_lite_esp32_procpu_defconfig b/boards/m5stack/m5stack_atom_lite/m5stack_atom_lite_esp32_procpu_defconfig new file mode 100644 index 0000000000..0ec9d05366 --- /dev/null +++ b/boards/m5stack/m5stack_atom_lite/m5stack_atom_lite_esp32_procpu_defconfig @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_MAIN_STACK_SIZE=2048 + +CONFIG_GPIO=y + +CONFIG_CONSOLE=y +CONFIG_SERIAL=y +CONFIG_UART_CONSOLE=y