diff --git a/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-lhcbit/index.rst b/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-lhcbit/index.rst new file mode 100644 index 0000000000..8c8e5f012b --- /dev/null +++ b/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-lhcbit/index.rst @@ -0,0 +1,113 @@ +================= +esp32s3-lhcbit +================= + +This page discusses issues unique to NuttX configurations for the +ESP32S3-LHCBit board. + +.. figure:: lcb-bit-top.jpeg + :align: center + +.. figure:: lcb-bit-botton.jpeg + :align: center + +Board information +================= + +This board was release by Laboratório Hacker de Campinas (LHC) in 2024 and developed based on +ESP32-S3-WROOM-1 module. + +The board features: + - ESP32-S3-16R8 + - USB-to-UART bridge via micro USB port + - SPI FLASH (size varies according to model) + - Lora module RAK3172-SiP + - Adafruit Mini TFT - 0.96" 160x80 + +Board documentation: https://github.com/lhc/Hardware/tree/main/LHCbit + +BOARD-RGB LED +============== + +The LHCBit board has one LED RGB Addressable + + ======= ===== + LED PINS + ======= ===== + LED_RGB IO14 + ======= ===== + +BOARD BUTTONS +============== + +The LHCBit board has 2 buttons + + ======= ===== + BUTTON PINS + ======= ===== + SW1 IO13 + SW2 IO12 + ======= ===== + +BOARD LORA +========== + +The LHCBit board has a RAK3172-SiP lora module with AT command communication via UART + + ========= ===== + LORA PINS + ========= ===== + UART1_TX IO9 + UART1_RX IO11 + BOOT IO10 + ========= ===== + +BOARD DISPLAY +=============== + +The LHCBit board comes with a 0.96" TFT display with sdcard, both with SPI communication and individual CS pins. + + ========= ===== + SHIELD PINS + ========= ===== + SPI_MOSI IO15 + SPI_MISO IO16 + TFT_CS IO21 + TFT_RESET IO48 + TFT_DC IO37 + SD_CS IO39 + ========= ===== + +Configurations +============== + +All of the configurations presented below can be tested by running the following commands:: + + tools/configure.sh esp32s3-lhcbit: + + Where is one of the following: + +Configuration Directories +------------------------- + +usbnsh +------ + +Configures the NuttShell (nsh) located at apps/examples/nsh. This configuration enables a serial console over USB. + +After flasing and reboot your board you should see in your dmesg logs:: + + $ sudo dmesg | tail + [ 3315.687219] usb 3-1.1.1: new full-speed USB device number 10 using xhci_hcd + [ 3315.778666] usb 3-1.1.1: New USB device found, idVendor=0525, idProduct=a4a7, bcdDevice= 1.01 + [ 3315.778684] usb 3-1.1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3 + [ 3315.778689] usb 3-1.1.1: Product: CDC/ACM Serial + [ 3315.778694] usb 3-1.1.1: Manufacturer: NuttX + [ 3315.778697] usb 3-1.1.1: SerialNumber: 0 + [ 3315.829695] cdc_acm 3-1.1.1:1.0: ttyACM0: USB ACM device + [ 3315.829725] usbcore: registered new interface driver cdc_acm + [ 3315.829727] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters + + +You may need to press ENTER 3 times before the NSH show up. + diff --git a/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-lhcbit/lcb-bit-botton.jpeg b/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-lhcbit/lcb-bit-botton.jpeg new file mode 100644 index 0000000000..35c30fb825 Binary files /dev/null and b/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-lhcbit/lcb-bit-botton.jpeg differ diff --git a/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-lhcbit/lcb-bit-top.jpeg b/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-lhcbit/lcb-bit-top.jpeg new file mode 100644 index 0000000000..49021e8b95 Binary files /dev/null and b/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-lhcbit/lcb-bit-top.jpeg differ diff --git a/boards/Kconfig b/boards/Kconfig index 8d506d04e1..458150fa3b 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -463,6 +463,14 @@ config ARCH_BOARD_ESP32S3_LCD_EV 1. ESP32-S3-LCD-EV-Board with 480x480 LCD 2. ESP32-S3-LCD-EV-Board with 800x480 LCD +config ARCH_BOARD_ESP32S3_LHCBIT + bool "ESP32-S3 LHCBit" + depends on ARCH_CHIP_ESP32S3WROOM1N16R8 + select ARCH_HAVE_BUTTONS + select ARCH_HAVE_IRQBUTTONS if ESP32S3_GPIO_IRQ + ---help--- + The ESP32-S3 LHCBit features the ESP32-S3 CPU with dual Xtensa LX7 cores. + config ARCH_BOARD_ESP32S3_BOX bool "Espressif ESP32-S3-BOX" depends on ARCH_CHIP_ESP32S3WROOM2N16R8V || ARCH_CHIP_ESP32S3WROOM2N32R8V || ARCH_CHIP_ESP32S3CUSTOM @@ -3257,6 +3265,7 @@ config ARCH_BOARD default "esp32s3-eye" if ARCH_BOARD_ESP32S3_EYE default "esp32s3-meadow" if ARCH_BOARD_ESP32S3_MEADOW default "esp32s3-lcd-ev" if ARCH_BOARD_ESP32S3_LCD_EV + default "esp32s3-lhcbit" if ARCH_BOARD_ESP32S3_LHCBIT default "esp32s3-box" if ARCH_BOARD_ESP32S3_BOX default "esp32s3-korvo-2" if ARCH_BOARD_ESP32S3_KORVO_2 default "esp32c6-devkitc" if ARCH_BOARD_ESP32C6_DEVKITC @@ -4407,6 +4416,9 @@ endif if ARCH_BOARD_ESP32S3_LCD_EV source "boards/xtensa/esp32s3/esp32s3-lcd-ev/Kconfig" endif +if ARCH_BOARD_ESP32S3_LHCBIT +source "boards/xtensa/esp32s3/esp32s3-lhcbit/Kconfig" +endif if ARCH_BOARD_ESP32S3_BOX source "boards/xtensa/esp32s3/esp32s3-box/Kconfig" endif diff --git a/boards/xtensa/esp32s3/esp32s3-lhcbit/Kconfig b/boards/xtensa/esp32s3/esp32s3-lhcbit/Kconfig new file mode 100644 index 0000000000..ce94283119 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-lhcbit/Kconfig @@ -0,0 +1,84 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +if ARCH_BOARD_ESP32S3_LHCBIT + +config ESP32S3_STORAGE_MTD_OFFSET + hex "Storage MTD base address in SPI Flash" + default 0x180000 if !ESP32S3_HAVE_OTA_PARTITION + default 0x250000 if ESP32S3_HAVE_OTA_PARTITION + depends on ESP32S3_MTD + ---help--- + MTD base address in SPI Flash. + +config ESP32S3_STORAGE_MTD_SIZE + hex "Storage MTD size in SPI Flash" + default 0x100000 + range 0x0 0x400000 if ESP32S3_FLASH_4M + range 0x0 0x800000 if ESP32S3_FLASH_8M + range 0x0 0x1000000 if ESP32S3_FLASH_16M + range 0x0 0x2000000 if ESP32S3_FLASH_32M + depends on ESP32S3_MTD + ---help--- + MTD size in SPI Flash. + +choice ESP32S3_SPIFLASH_FS + prompt "Mount SPI Flash MTD on bring-up" + default ESP32S3_SPIFLASH_SMARTFS + depends on ESP32S3_MTD + optional + ---help--- + Mount the SPI Flash MTD with the selected File System format on board + bring-up. + If not selected, the MTD will be registered as a device node on /dev. + +config ESP32S3_SPIFLASH_SMARTFS + bool "SmartFS" + select FS_SMARTFS + select MTD_SMART + +config ESP32S3_SPIFLASH_NXFFS + bool "NXFFS" + select FS_NXFFS + +config ESP32S3_SPIFLASH_SPIFFS + bool "SPIFFS" + select FS_SPIFFS + +config ESP32S3_SPIFLASH_LITTLEFS + bool "LittleFS" + select FS_LITTLEFS + +endchoice # ESP32S3_SPIFLASH_FS + +if PM + +config PM_ALARM_SEC + int "PM_STANDBY delay (seconds)" + default 15 + ---help--- + Number of seconds to wait in PM_STANDBY before going to PM_STANDBY mode. + +config PM_ALARM_NSEC + int "PM_STANDBY delay (nanoseconds)" + default 0 + ---help--- + Number of additional nanoseconds to wait in PM_STANDBY before going to PM_STANDBY mode. + +config PM_SLEEP_WAKEUP_SEC + int "PM_SLEEP delay (seconds)" + default 20 + ---help--- + Number of seconds to wait in PM_SLEEP. + +config PM_SLEEP_WAKEUP_NSEC + int "PM_SLEEP delay (nanoseconds)" + default 0 + ---help--- + Number of additional nanoseconds to wait in PM_SLEEP. + +endif # PM + +endif # ARCH_BOARD_ESP32S3_LHCBIT diff --git a/boards/xtensa/esp32s3/esp32s3-lhcbit/configs/usbnsh/defconfig b/boards/xtensa/esp32s3/esp32s3-lhcbit/configs/usbnsh/defconfig new file mode 100644 index 0000000000..0c17be1260 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-lhcbit/configs/usbnsh/defconfig @@ -0,0 +1,50 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +CONFIG_ARCH="xtensa" +CONFIG_ARCH_BOARD="esp32s3-lhcbit" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_ESP32S3_LHCBIT=y +CONFIG_ARCH_CHIP="esp32s3" +CONFIG_ARCH_CHIP_ESP32S3=y +CONFIG_ARCH_CHIP_ESP32S3WROOM1N16R8=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_XTENSA=y +CONFIG_BOARDCTL_USBDEVCTRL=y +CONFIG_BOARD_LOOPSPERMSEC=16717 +CONFIG_BUILTIN=y +CONFIG_CDCACM=y +CONFIG_CDCACM_CONSOLE=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_ESP32S3_OTG=y +CONFIG_ESP32S3_UART0=y +CONFIG_FS_PROCFS=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_IDLETHREAD_STACKSIZE=3072 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INIT_STACKSIZE=4096 +CONFIG_INTELHEX_BINARY=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=114688 +CONFIG_RAM_START=0x20000000 +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=6 +CONFIG_START_MONTH=12 +CONFIG_START_YEAR=2011 +CONFIG_SYSLOG_BUFFER=y +CONFIG_SYSTEM_NSH=y diff --git a/boards/xtensa/esp32s3/esp32s3-lhcbit/include/board.h b/boards/xtensa/esp32s3/esp32s3-lhcbit/include/board.h new file mode 100644 index 0000000000..ffbc7bf3b1 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-lhcbit/include/board.h @@ -0,0 +1,52 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-lhcbit/include/board.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_XTENSA_ESP32S3_ESP32S3_LHCBIT_INCLUDE_BOARD_H +#define __BOARDS_XTENSA_ESP32S3_ESP32S3_LHCBIT_INCLUDE_BOARD_H + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Clocking *****************************************************************/ + +/* The ESP32-S3 DevKit board is fitted with a 40MHz crystal */ + +#define BOARD_XTAL_FREQUENCY 40000000 + +#ifdef CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ +# define BOARD_CLOCK_FREQUENCY (CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ * 1000000) +#else +# define BOARD_CLOCK_FREQUENCY 80000000 +#endif + +/* LED definitions **********************************************************/ + +/* Define how many LEDs this board has (needed by userleds) */ + +#define BOARD_NLEDS 0 + +/* GPIO pins used by the GPIO Subsystem */ + +#define BOARD_NGPIOOUT 1 /* Amount of GPIO Output pins */ +#define BOARD_NGPIOIN 1 /* Amount of GPIO Input without Interruption */ +#define BOARD_NGPIOINT 1 /* Amount of GPIO Input w/ Interruption pins */ + +#endif /* __BOARDS_XTENSA_ESP32S3_ESP32S3_LHCBIT_INCLUDE_BOARD_H */ diff --git a/boards/xtensa/esp32s3/esp32s3-lhcbit/include/board_memorymap.h b/boards/xtensa/esp32s3/esp32s3-lhcbit/include/board_memorymap.h new file mode 100644 index 0000000000..0811931a38 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-lhcbit/include/board_memorymap.h @@ -0,0 +1,116 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-lhcbit/include/board_memorymap.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_XTENSA_ESP32S3_ESP32S3_LHCBIT_INCLUDE_BOARD_MEMORYMAP_H +#define __BOARDS_XTENSA_ESP32S3_ESP32S3_LHCBIT_INCLUDE_BOARD_MEMORYMAP_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Kernel ROM */ + +#define KIROM_START (uintptr_t)__kirom_start +#define KIROM_SIZE (uintptr_t)__kirom_size +#define KDROM_START (uintptr_t)__kdrom_start +#define KDROM_SIZE (uintptr_t)__kdrom_size + +/* Kernel RAM */ + +#define KIRAM_START (uintptr_t)__kiram_start +#define KIRAM_SIZE (uintptr_t)__kiram_size +#define KIRAM_END (uintptr_t)__kiram_end +#define KDRAM_START (uintptr_t)__kdram_start +#define KDRAM_SIZE (uintptr_t)__kdram_size +#define KDRAM_END (uintptr_t)__kdram_end + +/* Exception vectors */ + +#define VECTORS_START (uintptr_t)__vectors_start +#define VECTORS_END (uintptr_t)__vectors_end + +/* User ROM */ + +#define UIROM_START (uintptr_t)__uirom_start +#define UIROM_SIZE (uintptr_t)__uirom_size +#define UIROM_END (uintptr_t)__uirom_end +#define UDROM_START (uintptr_t)__udrom_start +#define UDROM_SIZE (uintptr_t)__udrom_size +#define UDROM_END (uintptr_t)__udrom_end + +/* User RAM */ + +#define UIRAM_START (uintptr_t)__uiram_start +#define UIRAM_SIZE (uintptr_t)__uiram_size +#define UIRAM_END (uintptr_t)__uiram_end +#define UDRAM_START (uintptr_t)__udram_start +#define UDRAM_SIZE (uintptr_t)__udram_size +#define UDRAM_END (uintptr_t)__udram_end + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/* Kernel ROM (RX) */ + +extern uint8_t __kirom_start[]; +extern uint8_t __kirom_size[]; +extern uint8_t __kdrom_start[]; +extern uint8_t __kdrom_size[]; + +/* Kernel RAM (RW) */ + +extern uint8_t __kiram_start[]; +extern uint8_t __kiram_size[]; +extern uint8_t __kiram_end[]; +extern uint8_t __kdram_start[]; +extern uint8_t __kdram_size[]; +extern uint8_t __kdram_end[]; + +/* Exception vectors */ + +extern uint8_t __vectors_start[]; +extern uint8_t __vectors_end[]; + +/* User ROM (RX) */ + +extern uint8_t __uirom_start[]; +extern uint8_t __uirom_size[]; +extern uint8_t __uirom_end[]; +extern uint8_t __udrom_start[]; +extern uint8_t __udrom_size[]; +extern uint8_t __udrom_end[]; + +/* User RAM (RW) */ + +extern uint8_t __uiram_start[]; +extern uint8_t __uiram_size[]; +extern uint8_t __uiram_end[]; +extern uint8_t __udram_start[]; +extern uint8_t __udram_size[]; +extern uint8_t __udram_end[]; + +#endif /* __BOARDS_XTENSA_ESP32S3_ESP32S3_LHCBIT_INCLUDE_BOARD_MEMORYMAP_H */ diff --git a/boards/xtensa/esp32s3/esp32s3-lhcbit/scripts/Make.defs b/boards/xtensa/esp32s3/esp32s3-lhcbit/scripts/Make.defs new file mode 100644 index 0000000000..f8c6db352a --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-lhcbit/scripts/Make.defs @@ -0,0 +1,72 @@ +############################################################################ +# boards/xtensa/esp32s3/esp32s3-lhcbit/scripts/Make.defs +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(TOPDIR)/.config +include $(TOPDIR)/tools/Config.mk +include $(TOPDIR)/tools/esp32s3/Config.mk +include $(TOPDIR)/arch/xtensa/src/lx7/Toolchain.defs + +ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32s3_peripherals.ld +ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32s3_rom_aliases.ld + +# Pick the linker scripts from the board level if they exist, if not +# pick the common linker scripts. + +ifeq ($(CONFIG_BUILD_PROTECTED),y) + ARCHSCRIPT += $(call FINDSCRIPT,protected_memory.ld) + ARCHSCRIPT += $(call FINDSCRIPT,kernel-space.ld) +else + ARCHSCRIPT += $(call FINDSCRIPT,flat_memory.ld) + ifeq ($(CONFIG_ESP32S3_APP_FORMAT_MCUBOOT),y) + ARCHSCRIPT += $(call FINDSCRIPT,mcuboot_sections.ld) + else ifeq ($(CONFIG_ESPRESSIF_SIMPLE_BOOT),y) + ARCHSCRIPT += $(call FINDSCRIPT,simple_boot_sections.ld) + else + ARCHSCRIPT += $(call FINDSCRIPT,legacy_sections.ld) + endif +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += -fno-strength-reduce +endif + +ARCHPICFLAGS = -fpic + +CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +AFLAGS := $(CFLAGS) -D__ASSEMBLY__ + +# Loadable module definitions + +CMODULEFLAGS = $(CFLAGS) -mtext-section-literals + +LDMODULEFLAGS = -r -e module_initialize +LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) + +# ELF module definitions + +CELFFLAGS = $(CFLAGS) -mtext-section-literals +CXXELFFLAGS = $(CXXFLAGS) -mtext-section-literals + +LDELFFLAGS = -r -e main +LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld) diff --git a/boards/xtensa/esp32s3/esp32s3-lhcbit/src/Make.defs b/boards/xtensa/esp32s3/esp32s3-lhcbit/src/Make.defs new file mode 100644 index 0000000000..5684ac787d --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-lhcbit/src/Make.defs @@ -0,0 +1,35 @@ +############################################################################ +# boards/xtensa/esp32s3/esp32s3-lhcbit/src/Make.defs +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(TOPDIR)/Make.defs + +CSRCS = esp32s3_boot.c esp32s3_bringup.c + +ifeq ($(CONFIG_BOARDCTL),y) +CSRCS += esp32s3_appinit.c +ifeq ($(CONFIG_BOARDCTL_RESET),y) +CSRCS += esp32s3_reset.c +endif +endif + +DEPPATH += --dep-path board +VPATH += :board +CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board + diff --git a/boards/xtensa/esp32s3/esp32s3-lhcbit/src/esp32s3-lhcbit.h b/boards/xtensa/esp32s3/esp32s3-lhcbit/src/esp32s3-lhcbit.h new file mode 100644 index 0000000000..f32bb1e04f --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-lhcbit/src/esp32s3-lhcbit.h @@ -0,0 +1,67 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-lhcbit/src/esp32s3-lhcbit.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_XTENSA_ESP32S3_ESP32S3_LHCBIT_SRC_ESP32S3_LHCBIT_H +#define __BOARDS_XTENSA_ESP32S3_ESP32S3_LHCBIT_SRC_ESP32S3_LHCBIT_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: esp32s3_bringup + * + * Description: + * Perform architecture-specific initialization + * + * CONFIG_BOARD_LATE_INITIALIZE=y : + * Called from board_late_initialize(). + * + * CONFIG_BOARD_LATE_INITIALIZE=y && CONFIG_BOARDCTL=y : + * Called from the NSH library via board_app_initialize() + * + ****************************************************************************/ + +int esp32s3_bringup(void); + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_XTENSA_ESP32S3_ESP32S3_LHCBIT_SRC_ESP32S3_LHCBIT_H */ diff --git a/boards/xtensa/esp32s3/esp32s3-lhcbit/src/esp32s3_appinit.c b/boards/xtensa/esp32s3/esp32s3-lhcbit/src/esp32s3_appinit.c new file mode 100644 index 0000000000..4d10df7d3d --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-lhcbit/src/esp32s3_appinit.c @@ -0,0 +1,80 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-lhcbit/src/esp32s3_appinit.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include "esp32s3-lhcbit.h" + +#ifdef CONFIG_BOARDCTL + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_app_initialize + * + * Description: + * Perform application specific initialization. This function is never + * called directly from application code, but only indirectly via the + * (non-standard) boardctl() interface using the command BOARDIOC_INIT. + * + * Input Parameters: + * arg - The boardctl() argument is passed to the board_app_initialize() + * implementation without modification. The argument has no + * meaning to NuttX; the meaning of the argument is a contract + * between the board-specific initialization logic and the + * matching application logic. The value could be such things as a + * mode enumeration value, a set of DIP switch settings, a + * pointer to configuration data read from a file or serial FLASH, + * or whatever you would like to do with it. Every implementation + * should accept zero/NULL as a default configuration. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure to indicate the nature of the failure. + * + ****************************************************************************/ + +int board_app_initialize(uintptr_t arg) +{ +#ifdef CONFIG_BOARD_LATE_INITIALIZE + /* Board initialization already performed by board_late_initialize() */ + + return OK; +#else + /* Perform board-specific initialization */ + + return esp32s3_bringup(); +#endif +} + +#endif /* CONFIG_BOARDCTL */ diff --git a/boards/xtensa/esp32s3/esp32s3-lhcbit/src/esp32s3_boot.c b/boards/xtensa/esp32s3/esp32s3-lhcbit/src/esp32s3_boot.c new file mode 100644 index 0000000000..a7d4b52c6b --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-lhcbit/src/esp32s3_boot.c @@ -0,0 +1,83 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-lhcbit/src/esp32s3_boot.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include +#include +#include + +#include "esp32s3-lhcbit.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: esp32s3_board_initialize + * + * Description: + * All ESP32-S3 boards must provide the following entry point. + * This entry point is called early in the initialization -- after all + * memory has been configured and mapped but before any devices have been + * initialized. + * + ****************************************************************************/ + +void esp32s3_board_initialize(void) +{ +} + +/**************************************************************************** + * Name: board_late_initialize + * + * Description: + * If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional + * initialization call will be performed in the boot-up sequence to a + * function called board_late_initialize(). board_late_initialize() will + * be called immediately after up_initialize() is called and just before + * the initial application is started. This additional initialization + * phase may be used, for example, to initialize board-specific device + * drivers. + * + ****************************************************************************/ + +#ifdef CONFIG_BOARD_LATE_INITIALIZE +void board_late_initialize(void) +{ + /* Perform board-specific initialization */ + + esp32s3_bringup(); +} +#endif diff --git a/boards/xtensa/esp32s3/esp32s3-lhcbit/src/esp32s3_bringup.c b/boards/xtensa/esp32s3/esp32s3-lhcbit/src/esp32s3_bringup.c new file mode 100644 index 0000000000..3c4dbc0f76 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-lhcbit/src/esp32s3_bringup.c @@ -0,0 +1,95 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-lhcbit/src/esp32s3_bringup.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "esp32s3-lhcbit.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: esp32s3_bringup + * + * Description: + * Perform architecture-specific initialization + * + * CONFIG_BOARD_LATE_INITIALIZE=y : + * Called from board_late_initialize(). + * + * CONFIG_BOARD_LATE_INITIALIZE=n && CONFIG_BOARDCTL=y : + * Called from the NSH library + * + ****************************************************************************/ + +int esp32s3_bringup(void) +{ + int ret; + +#ifdef CONFIG_FS_PROCFS + /* Mount the procfs file system */ + + ret = nx_mount(NULL, "/proc", "procfs", 0, NULL); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret); + } +#endif + +#ifdef CONFIG_FS_TMPFS + /* Mount the tmpfs file system */ + + ret = nx_mount(NULL, CONFIG_LIBC_TMPDIR, "tmpfs", 0, NULL); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to mount tmpfs at %s: %d\n", + CONFIG_LIBC_TMPDIR, ret); + } +#endif + + /* If we got here then perhaps not all initialization was successful, but + * at least enough succeeded to bring-up NSH with perhaps reduced + * capabilities. + */ + + UNUSED(ret); + return OK; +} diff --git a/boards/xtensa/esp32s3/esp32s3-lhcbit/src/esp32s3_reset.c b/boards/xtensa/esp32s3/esp32s3-lhcbit/src/esp32s3_reset.c new file mode 100644 index 0000000000..1fd5eee4f9 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-lhcbit/src/esp32s3_reset.c @@ -0,0 +1,85 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-lhcbit/src/esp32s3_reset.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include + +#include "esp32s3_systemreset.h" + +#ifdef CONFIG_BOARDCTL_RESET + +#if CONFIG_BOARD_ASSERT_RESET_VALUE == EXIT_SUCCESS +# error "CONFIG_BOARD_ASSERT_RESET_VALUE must not be equal to EXIT_SUCCESS" +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_reset + * + * Description: + * Reset board. Support for this function is required by board-level + * logic if CONFIG_BOARDCTL_RESET is selected. + * + * Input Parameters: + * status - Status information provided with the reset event. This + * meaning of this status information is board-specific. If not + * used by a board, the value zero may be provided in calls to + * board_reset(). + * + * Returned Value: + * If this function returns, then it was not possible to power-off the + * board due to some constraints. The return value in this case is a + * board-specific reason for the failure to shutdown. + * + ****************************************************************************/ + +int board_reset(int status) +{ + syslog(LOG_INFO, "reboot status=%d\n", status); + + switch (status) + { + case EXIT_SUCCESS: + up_shutdown_handler(); + break; + case CONFIG_BOARD_ASSERT_RESET_VALUE: + break; + default: + break; + } + + up_systemreset(); + + return 0; +} + +#endif /* CONFIG_BOARDCTL_RESET */