From cdbb670e5dfd02e1eb45d2101d35052f7421c45e Mon Sep 17 00:00:00 2001 From: halyssonJr Date: Sun, 18 Dec 2022 11:47:54 -0300 Subject: [PATCH] Add support to Franzininho board rename files ESP32S2-Franzininho to Franzininho-WiFi and remove some scripts previously tested --- boards/Kconfig | 15 +- .../esp32s2/common/scripts/flat_memory.ld | 8 +- .../xtensa/esp32s2/franzininho-wifi/Kconfig | 8 + .../franzininho-wifi/configs/nsh/defconfig | 44 +++++ .../esp32s2/franzininho-wifi/include/board.h | 58 ++++++ .../franzininho-wifi/scripts/Make.defs | 62 ++++++ .../esp32s2/franzininho-wifi/src/Make.defs | 39 ++++ .../franzininho-wifi/src/esp32s2_appinit.c | 80 ++++++++ .../franzininho-wifi/src/esp32s2_boot.c | 83 ++++++++ .../franzininho-wifi/src/esp32s2_bringup.c | 184 ++++++++++++++++++ .../franzininho-wifi/src/esp32s2_oneshot.c | 83 ++++++++ .../franzininho-wifi/src/esp32s2_reset.c | 63 ++++++ .../franzininho-wifi/src/franzininho-wifi.h | 103 ++++++++++ 13 files changed, 825 insertions(+), 5 deletions(-) create mode 100644 boards/xtensa/esp32s2/franzininho-wifi/Kconfig create mode 100644 boards/xtensa/esp32s2/franzininho-wifi/configs/nsh/defconfig create mode 100644 boards/xtensa/esp32s2/franzininho-wifi/include/board.h create mode 100644 boards/xtensa/esp32s2/franzininho-wifi/scripts/Make.defs create mode 100644 boards/xtensa/esp32s2/franzininho-wifi/src/Make.defs create mode 100644 boards/xtensa/esp32s2/franzininho-wifi/src/esp32s2_appinit.c create mode 100644 boards/xtensa/esp32s2/franzininho-wifi/src/esp32s2_boot.c create mode 100644 boards/xtensa/esp32s2/franzininho-wifi/src/esp32s2_bringup.c create mode 100644 boards/xtensa/esp32s2/franzininho-wifi/src/esp32s2_oneshot.c create mode 100644 boards/xtensa/esp32s2/franzininho-wifi/src/esp32s2_reset.c create mode 100644 boards/xtensa/esp32s2/franzininho-wifi/src/franzininho-wifi.h diff --git a/boards/Kconfig b/boards/Kconfig index d97ab045b2..6bfde5647a 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -370,7 +370,16 @@ config ARCH_BOARD_ESP32S2_SAOLA_1 select ARCH_HAVE_IRQBUTTONS if ESP32S2_GPIO_IRQ ---help--- This is the ESP32-S2-Saola-1 board - + +config ARCH_BOARD_FRANZININHO_WIFI + bool "FRANZININHO WI-FI" + depends on ARCH_CHIP_ESP32S2WROVER + select ARCH_HAVE_LEDS + select ARCH_HAVE_BUTTONS + select ARCH_HAVE_IRQBUTTONS if ESP32S2_GPIO_IRQ + ---help--- + Franzininho Wi-Fi is a development board to evaluate the ESP32-S2 SoC + config ARCH_BOARD_ESP32S3_DEVKIT bool "Espressif ESP32-S3 DevKit" depends on ARCH_CHIP_ESP32S3WROOM1 || ARCH_CHIP_ESP32S3MINI1 @@ -2708,6 +2717,7 @@ config ARCH_BOARD default "esp32c3-devkit-rust-1" if ARCH_BOARD_ESP32C3_DEVKIT_RUST1 default "esp32s2-kaluga-1" if ARCH_BOARD_ESP32S2_KALUGA_1 default "esp32s2-saola-1" if ARCH_BOARD_ESP32S2_SAOLA_1 + default "franzininho-wifi" if ARCH_BOARD_FRANZININHO_WIFI default "esp32s3-devkit" if ARCH_BOARD_ESP32S3_DEVKIT default "esp32s3-eye" if ARCH_BOARD_ESP32S3_EYE default "et-stm32-stamp" if ARCH_BOARD_ET_STM32_STAMP @@ -3672,6 +3682,9 @@ endif if ARCH_BOARD_ESP32S2_SAOLA_1 source "boards/xtensa/esp32s2/esp32s2-saola-1/Kconfig" endif +if ARCH_BOARD_FRANZININHO_WIFI +source "boards/xtensa/esp32s2/franzininho-wifi/Kconfig" +endif if ARCH_BOARD_ESP32S3_DEVKIT source "boards/xtensa/esp32s3/esp32s3-devkit/Kconfig" endif diff --git a/boards/xtensa/esp32s2/common/scripts/flat_memory.ld b/boards/xtensa/esp32s2/common/scripts/flat_memory.ld index 4dc6efecf2..75d6da2c18 100644 --- a/boards/xtensa/esp32s2/common/scripts/flat_memory.ld +++ b/boards/xtensa/esp32s2/common/scripts/flat_memory.ld @@ -51,8 +51,8 @@ MEMORY */ metadata (RX) : org = CONFIG_ESP32S2_APP_MCUBOOT_HEADER_SIZE, len = 0x20 - ROM (RX) : org = CONFIG_ESP32S2_APP_MCUBOOT_HEADER_SIZE + 0x20, - len = FLASH_SIZE - (CONFIG_ESP32S2_APP_MCUBOOT_HEADER_SIZE + 0x20) + ROM (RX) : org = ORIGIN(metadata) + LENGTH(metadata), + len = FLASH_SIZE - ORIGIN(ROM) #endif /* Below values assume the flash cache is on, and have the blocks this @@ -102,8 +102,8 @@ MEMORY * be equal. */ - drom0_0_seg (R) : org = 0x3f000000 + (CONFIG_ESP32S2_APP_MCUBOOT_HEADER_SIZE + 0x20), - len = FLASH_SIZE - (CONFIG_ESP32S2_APP_MCUBOOT_HEADER_SIZE + 0x20) + drom0_0_seg (R) : org = 0x3f000000 + ORIGIN(ROM), + len = FLASH_SIZE - ORIGIN(ROM) #else /* The 0x20 offset is a convenience for the app binary image generation. * Flash cache has 64KB pages. The .bin file which is flashed to the chip diff --git a/boards/xtensa/esp32s2/franzininho-wifi/Kconfig b/boards/xtensa/esp32s2/franzininho-wifi/Kconfig new file mode 100644 index 0000000000..f9013738b6 --- /dev/null +++ b/boards/xtensa/esp32s2/franzininho-wifi/Kconfig @@ -0,0 +1,8 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +if ARCH_BOARD_FRANZININHO_WIFI + +endif # ARCH_BOARD_FRANZININHO_WIFI diff --git a/boards/xtensa/esp32s2/franzininho-wifi/configs/nsh/defconfig b/boards/xtensa/esp32s2/franzininho-wifi/configs/nsh/defconfig new file mode 100644 index 0000000000..c677ef3cb4 --- /dev/null +++ b/boards/xtensa/esp32s2/franzininho-wifi/configs/nsh/defconfig @@ -0,0 +1,44 @@ +# +# 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_ARCH_LEDS is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_CMDPARMS is not set +CONFIG_ARCH="xtensa" +CONFIG_ARCH_BOARD="franzininho-wifi" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_FRANZININHO_WIFI=y +CONFIG_ARCH_CHIP="esp32s2" +CONFIG_ARCH_CHIP_ESP32S2=y +CONFIG_ARCH_CHIP_ESP32S2WROVER=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_XTENSA=y +CONFIG_BOARD_LOOPSPERMSEC=16717 +CONFIG_BUILTIN=y +CONFIG_ESP32S2_UART0=y +CONFIG_FS_PROCFS=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_IDLETHREAD_STACKSIZE=3072 +CONFIG_INIT_ENTRYPOINT="nsh_main" +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_SYSTEM_NSH=y +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/xtensa/esp32s2/franzininho-wifi/include/board.h b/boards/xtensa/esp32s2/franzininho-wifi/include/board.h new file mode 100644 index 0000000000..5aac53f9d3 --- /dev/null +++ b/boards/xtensa/esp32s2/franzininho-wifi/include/board.h @@ -0,0 +1,58 @@ +/**************************************************************************** + * boards/xtensa/esp32s2/franzininho-wifi/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_ESP32S2_FRANZININHO_WIFI_INCLUDE_BOARD_H +#define __BOARDS_XTENSA_ESP32S2_FRANZININHO_WIFI_INCLUDE_BOARD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Clocking *****************************************************************/ + +/* The Franzininho WiFi is fitted with a 40MHz crystal */ + +#define BOARD_XTAL_FREQUENCY 40000000 + +#ifdef CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ +# define BOARD_CLOCK_FREQUENCY (CONFIG_ESP32S2_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 1 + +/* GPIO pins used by the GPIO Subsystem */ + +#define BOARD_NGPIOOUT 2 /* 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_ESP32S2_FRANZININHO_WIFI_INCLUDE_BOARD_H */ diff --git a/boards/xtensa/esp32s2/franzininho-wifi/scripts/Make.defs b/boards/xtensa/esp32s2/franzininho-wifi/scripts/Make.defs new file mode 100644 index 0000000000..f285b29490 --- /dev/null +++ b/boards/xtensa/esp32s2/franzininho-wifi/scripts/Make.defs @@ -0,0 +1,62 @@ +############################################################################ +# boards/xtensa/esp32s2/franzininho-wifi/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/esp32s2/Config.mk +include $(TOPDIR)/arch/xtensa/src/lx7/Toolchain.defs + +ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32s2_rom.ld +ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32s2_peripherals.ld + +# Pick the linker scripts from the board level if they exist, if not +# pick the common linker scripts. + +ARCHSCRIPT += $(call FINDSCRIPT,flat_memory.ld) + +ifeq ($(CONFIG_ESP32S2_APP_FORMAT_MCUBOOT),y) + ARCHSCRIPT += $(call FINDSCRIPT,mcuboot_sections.ld) +else + ARCHSCRIPT += $(call FINDSCRIPT,legacy_sections.ld) +endif + +ARCHPICFLAGS = -fpic + +CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe +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/esp32s2/franzininho-wifi/src/Make.defs b/boards/xtensa/esp32s2/franzininho-wifi/src/Make.defs new file mode 100644 index 0000000000..96d7b3b7b2 --- /dev/null +++ b/boards/xtensa/esp32s2/franzininho-wifi/src/Make.defs @@ -0,0 +1,39 @@ +############################################################################ +# boards/xtensa/esp32s2/franzininho-wifi/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 = esp32s2_boot.c esp32s2_bringup.c + +ifeq ($(CONFIG_BOARDCTL),y) +CSRCS += esp32s2_appinit.c +ifeq ($(CONFIG_BOARDCTL_RESET),y) +CSRCS += esp32s2_reset.c +endif +endif + +ifeq ($(CONFIG_ONESHOT),y) +CSRCS += esp32s2_oneshot.c +endif + +DEPPATH += --dep-path board +VPATH += :board +CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board) + diff --git a/boards/xtensa/esp32s2/franzininho-wifi/src/esp32s2_appinit.c b/boards/xtensa/esp32s2/franzininho-wifi/src/esp32s2_appinit.c new file mode 100644 index 0000000000..368b2601ff --- /dev/null +++ b/boards/xtensa/esp32s2/franzininho-wifi/src/esp32s2_appinit.c @@ -0,0 +1,80 @@ +/**************************************************************************** + * boards/xtensa/esp32s2/franzininho-wifi/src/esp32s2_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 "franzininho-wifi.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 esp32s2_bringup(); +#endif +} + +#endif /* CONFIG_BOARDCTL */ diff --git a/boards/xtensa/esp32s2/franzininho-wifi/src/esp32s2_boot.c b/boards/xtensa/esp32s2/franzininho-wifi/src/esp32s2_boot.c new file mode 100644 index 0000000000..0134b6a698 --- /dev/null +++ b/boards/xtensa/esp32s2/franzininho-wifi/src/esp32s2_boot.c @@ -0,0 +1,83 @@ +/**************************************************************************** + * boards/xtensa/esp32s2/franzininho-wifi/src/esp32s2_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 "franzininho-wifi.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: esp32s2_board_initialize + * + * Description: + * All ESP32-S2 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 esp32s2_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 */ + + esp32s2_bringup(); +} +#endif diff --git a/boards/xtensa/esp32s2/franzininho-wifi/src/esp32s2_bringup.c b/boards/xtensa/esp32s2/franzininho-wifi/src/esp32s2_bringup.c new file mode 100644 index 0000000000..4e8813d9e6 --- /dev/null +++ b/boards/xtensa/esp32s2/franzininho-wifi/src/esp32s2_bringup.c @@ -0,0 +1,184 @@ +/**************************************************************************** + * boards/xtensa/esp32s2/franzininho-wifi/src/esp32s2_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 + +#ifdef CONFIG_TIMER +# include "esp32s2_tim_lowerhalf.h" +#endif + +#ifdef CONFIG_ESP32S2_RT_TIMER +# include "esp32s2_rt_timer.h" +#endif + +#ifdef CONFIG_WATCHDOG +# include "esp32s2_board_wdt.h" +#endif + +#include "franzininho-wifi.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: esp32s2_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 esp32s2_bringup(void) +{ + int ret = OK; + +#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 + +#ifdef CONFIG_WATCHDOG + /* Configure watchdog timer */ + + ret = board_wdt_init(); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize watchdog timer: %d\n", ret); + } +#endif + + /* Register the timer drivers */ + +#ifdef CONFIG_TIMER + +#if defined(CONFIG_ESP32S2_TIMER0) && !defined(CONFIG_ONESHOT) + ret = esp32s2_timer_initialize("/dev/timer0", TIMER0); + if (ret < 0) + { + syslog(LOG_ERR, + "ERROR: Failed to initialize timer driver: %d\n", + ret); + return ret; + } +#endif + +#ifdef CONFIG_ESP32S2_TIMER1 + ret = esp32s2_timer_initialize("/dev/timer1", TIMER1); + if (ret < 0) + { + syslog(LOG_ERR, + "ERROR: Failed to initialize timer driver: %d\n", + ret); + return ret; + } +#endif + +#ifdef CONFIG_ESP32S2_TIMER2 + ret = esp32s2_timer_initialize("/dev/timer2", TIMER2); + if (ret < 0) + { + syslog(LOG_ERR, + "ERROR: Failed to initialize timer driver: %d\n", + ret); + return ret; + } +#endif + +#ifdef CONFIG_ESP32S2_TIMER3 + ret = esp32s2_timer_initialize("/dev/timer3", TIMER3); + if (ret < 0) + { + syslog(LOG_ERR, + "ERROR: Failed to initialize timer driver: %d\n", + ret); + return ret; + } +#endif + +#endif /* CONFIG_TIMER */ + +#ifdef CONFIG_ESP32S2_RT_TIMER + ret = esp32s2_rt_timer_init(); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize RT timer: %d\n", ret); + } + +#endif + /* Now register one oneshot driver */ + +#if defined(CONFIG_ONESHOT) && defined(CONFIG_ESP32S2_TIMER0) + + ret = board_oneshot_init(ONESHOT_TIMER, ONESHOT_RESOLUTION_US); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: board_oneshot_init() failed: %d\n", ret); + } + +#endif /* CONFIG_ONESHOT */ + + /* If we got here then perhaps not all initialization was successful, but + * at least enough succeeded to bring-up NSH with perhaps reduced + * capabilities. + */ + + return ret; +} diff --git a/boards/xtensa/esp32s2/franzininho-wifi/src/esp32s2_oneshot.c b/boards/xtensa/esp32s2/franzininho-wifi/src/esp32s2_oneshot.c new file mode 100644 index 0000000000..268f3e8d58 --- /dev/null +++ b/boards/xtensa/esp32s2/franzininho-wifi/src/esp32s2_oneshot.c @@ -0,0 +1,83 @@ +/**************************************************************************** + * boards/xtensa/esp32s2/franzininho-wifi/src/esp32s2_oneshot.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 "franzininho-wifi.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_oneshot_init + * + * Description: + * Configure the oneshot timer driver. + * + * Returned Value: + * Zero (OK) is returned on success; A negated errno value is returned + * to indicate the nature of any failure. + * + ****************************************************************************/ + +int board_oneshot_init(int timer, uint16_t resolution) +{ + int ret = OK; + struct oneshot_lowerhalf_s *os_lower = NULL; + + os_lower = oneshot_initialize(timer, resolution); + if (os_lower != NULL) + { +#if defined(CONFIG_CPULOAD_ONESHOT) + /* Configure the oneshot timer to support CPU load measurement */ + + nxsched_oneshot_extclk(os_lower); + +#else + ret = oneshot_register("/dev/oneshot", os_lower); + if (ret < 0) + { + syslog(LOG_ERR, + "ERROR: Failed to register oneshot at /dev/oneshot: %d\n", ret); + } +#endif /* CONFIG_CPULOAD_ONESHOT */ + } + else + { + syslog(LOG_ERR, "ERROR: oneshot_initialize failed\n"); + ret = -EBUSY; + } + + return ret; +} diff --git a/boards/xtensa/esp32s2/franzininho-wifi/src/esp32s2_reset.c b/boards/xtensa/esp32s2/franzininho-wifi/src/esp32s2_reset.c new file mode 100644 index 0000000000..0e0abe25aa --- /dev/null +++ b/boards/xtensa/esp32s2/franzininho-wifi/src/esp32s2_reset.c @@ -0,0 +1,63 @@ +/**************************************************************************** + * boards/xtensa/esp32s2/franzininho-wifi/src/esp32s2_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 + +#ifdef CONFIG_BOARDCTL_RESET + +/**************************************************************************** + * 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) +{ + up_systemreset(); + + return 0; +} + +#endif /* CONFIG_BOARDCTL_RESET */ diff --git a/boards/xtensa/esp32s2/franzininho-wifi/src/franzininho-wifi.h b/boards/xtensa/esp32s2/franzininho-wifi/src/franzininho-wifi.h new file mode 100644 index 0000000000..ec4eb86226 --- /dev/null +++ b/boards/xtensa/esp32s2/franzininho-wifi/src/franzininho-wifi.h @@ -0,0 +1,103 @@ +/**************************************************************************** + * boards/xtensa/esp32s2/franzininho-wifi/src/franzininho-wifi.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_ESP32S2_FRANZININHO_WIFI_SRC_FRANZININHO_WIFI_H +#define __BOARDS_XTENSA_ESP32S2_FRANZININHO_WIFI_SRC_FRANZININHO_WIFI_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* BOOT Button */ + +#define BUTTON_BOOT 0 + +/* TIMERS */ + +#define TIMER0 0 +#define TIMER1 1 +#define TIMER2 2 +#define TIMER3 3 + +/* ONESHOT */ + +#define ONESHOT_TIMER TIMER0 +#define ONESHOT_RESOLUTION_US 1 + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: esp32s2_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 esp32s2_bringup(void); + +/**************************************************************************** + * Name: board_oneshot_init + * + * Description: + * Configure the oneshot timer driver. + * + * Input Parameters: + * timer - Timer instance to be used as oneshot timer. + * resolution - Oneshot timer resolution. + * + * Returned Value: + * Zero (OK) is returned on success; A negated errno value is returned + * to indicate the nature of any failure. + * + ****************************************************************************/ + +#ifdef CONFIG_ONESHOT +int board_oneshot_init(int timer, uint16_t resolution); +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_XTENSA_ESP32S2_FRANZININHO_WIFI_SRC_FRANZININHO_WIFI_H */