casaroli commented on code in PR #21480: URL: https://github.com/apache/nuttx/pull/21480#discussion_r4587413892
########## boards/xtensa/esp32s3/esp32s3-r8/src/esp32s3_board_lcd.c: ########## @@ -0,0 +1,155 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-r8/src/esp32s3_board_lcd.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * 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 <nuttx/config.h> + +#include <stdio.h> +#include <stdbool.h> +#include <debug.h> +#include <errno.h> + +#include <nuttx/arch.h> +#include <nuttx/board.h> +#include <nuttx/signal.h> +#include <nuttx/spi/spi.h> +#include <nuttx/lcd/lcd.h> +#include <nuttx/lcd/st7789.h> + +#include <arch/board/board.h> + +#include "espressif/esp_gpio.h" +#include "esp32s3_spi.h" +#include "hardware/esp32s3_gpio_sigmap.h" + +#include "esp32s3-r8.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static struct spi_dev_s *g_spidev; +static struct lcd_dev_s *g_lcd; + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_lcd_initialize + * + * Description: + * Initialize the LCD video hardware. The initial state of the LCD is + * fully initialized, display memory cleared, and the LCD ready to use, but + * with the power setting at 0 (full off). + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int board_lcd_initialize(void) +{ + /* Initialize non-SPI GPIOs */ + + esp32s3_configgpio(ESP32S3_R8_DISPLAY_DC, OUTPUT); Review Comment: This is still not fixed: `esp32s3_configgpio()` and `esp32s3_gpiowrite()` do not exist on master, so `esp32s3-r8:lcd` does not build: `esp32s3_board_lcd.c:81:3: error: implicit declaration of function 'esp32s3_configgpio'; did you mean 'esp_configgpio'?`. Lines 82 and 86, and esp32s3_touchscreen.c lines 66, 83, 84 and 86, have the same calls. Fix: use `esp_configgpio()` and `esp_gpiowrite()` in both files, as master's esp32s3-eye esp32s3_board_lcd.c does. ########## boards/xtensa/esp32s3/esp32s3-r8/src/esp32s3_bringup.c: ########## @@ -0,0 +1,255 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-r8/src/esp32s3_bringup.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * 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 <nuttx/config.h> + +#include <stdio.h> +#include <fcntl.h> +#include <unistd.h> +#include <syslog.h> +#include <sys/stat.h> +#include <sys/ioctl.h> +#include <sys/types.h> +#include <syslog.h> +#include <debug.h> +#include <stdio.h> + +#include <errno.h> +#include <nuttx/fs/fs.h> + +#ifdef CONFIG_ESP32S3_TIMER +# include "esp32s3_board_tim.h" +#endif + +#ifdef CONFIG_ESP32S3_WIFI +# include "esp32s3_board_wlan.h" +#endif + +#ifdef CONFIG_ESP32S3_BLE +# include "esp32s3_ble.h" +#endif + +#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +# include "esp32s3_wifi_adapter.h" +#endif + +#ifdef CONFIG_ESP32S3_I2C +# include "esp32s3_i2c.h" +#endif + +#ifdef CONFIG_WATCHDOG +# include "esp32s3_board_wdt.h" +#endif + +#ifdef CONFIG_INPUT_BUTTONS +# include <nuttx/input/buttons.h> +#endif + +#ifdef CONFIG_ESP32S3_SPI +# include "esp32s3_spi.h" +#endif + +#ifdef CONFIG_LCD_DEV +# include <nuttx/board.h> +# include <nuttx/lcd/lcd_dev.h> +#endif + +#ifdef CONFIG_ESP32S3_SDMMC +#include "esp32s3_board_sdmmc.h" +#endif + +#include "esp32s3-r8.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 + +#ifdef CONFIG_ESP32S3_TIMER + /* Configure general purpose timers */ + + ret = board_tim_init(); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize timers: %d\n", 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 + +#ifdef CONFIG_I2C_DRIVER + /* Configure I2C peripheral interfaces */ + + ret = board_i2c_init(); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize I2C driver: %d\n", ret); + } +#endif + +#ifdef CONFIG_INPUT_BUTTONS + /* Register the BUTTON driver */ + + ret = btn_lower_initialize("/dev/buttons"); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize button driver: %d\n", ret); + } +#endif + +#ifdef CONFIG_ESP32S3_SPIFLASH + ret = board_spiflash_init(); + if (ret) + { + syslog(LOG_ERR, "ERROR: Failed to initialize SPI Flash\n"); + } +#endif + +#ifdef CONFIG_ESP32S3_WIRELESS Review Comment: `CONFIG_ESP32S3_WIRELESS`, `CONFIG_ESP32S3_WIFI`, `CONFIG_ESP32S3_BLE` and `CONFIG_ESP32S3_WIFI_BT_COEXIST` do not exist on master; they are now `CONFIG_ESPRESSIF_*`. configs/wifi/defconfig sets `CONFIG_ESPRESSIF_WIFI=y`, so `board_wlan_init()` is never built in and `esp32s3-r8:wifi` has no Wi-Fi device. The `esp_hr_timer_init()` call that every other esp32s3 board makes is also missing. Fix: start from master's boards/xtensa/esp32s3/esp32s3-eye/src/esp32s3_bringup.c and change only the board names. ########## boards/xtensa/esp32s3/esp32s3-r8/configs/lcd/defconfig: ########## @@ -0,0 +1,70 @@ +# +# 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_ARCH="xtensa" +CONFIG_ARCH_BOARD="esp32s3-r8" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_ESP32S3_R8=y +CONFIG_ARCH_CHIP="esp32s3" +CONFIG_ARCH_CHIP_ESP32S3=y +CONFIG_ARCH_CHIP_ESP32S3WROOM1N4=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_IRQ_TO_NDX=y +CONFIG_ARCH_MINIMAL_VECTORTABLE_DYNAMIC=y +CONFIG_ARCH_NUSER_INTERRUPTS=2 +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_XTENSA=y +CONFIG_BOARD_LOOPSPERMSEC=16717 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DRIVERS_VIDEO=y +CONFIG_ESP32S3_R8_LCD=y Review Comment: This file is not normalized: `make savedefconfig` puts `CONFIG_ESP32S3_R8_LCD=y` after `CONFIG_ESP32S3_GPIO_IRQ=y`. Fix: regenerate the file with `make savedefconfig`. ########## boards/xtensa/esp32s3/esp32s3-r8/src/esp32s3_board_lcd.c: ########## @@ -0,0 +1,155 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-r8/src/esp32s3_board_lcd.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * 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 <nuttx/config.h> + +#include <stdio.h> +#include <stdbool.h> +#include <debug.h> +#include <errno.h> + +#include <nuttx/arch.h> +#include <nuttx/board.h> +#include <nuttx/signal.h> +#include <nuttx/spi/spi.h> +#include <nuttx/lcd/lcd.h> +#include <nuttx/lcd/st7789.h> + +#include <arch/board/board.h> + +#include "espressif/esp_gpio.h" +#include "esp32s3_spi.h" +#include "hardware/esp32s3_gpio_sigmap.h" + +#include "esp32s3-r8.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static struct spi_dev_s *g_spidev; +static struct lcd_dev_s *g_lcd; + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_lcd_initialize + * + * Description: + * Initialize the LCD video hardware. The initial state of the LCD is + * fully initialized, display memory cleared, and the LCD ready to use, but + * with the power setting at 0 (full off). + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int board_lcd_initialize(void) +{ + /* Initialize non-SPI GPIOs */ + + esp32s3_configgpio(ESP32S3_R8_DISPLAY_DC, OUTPUT); + esp32s3_configgpio(ESP32S3_R8_DISPLAY_BCKL, OUTPUT); + + /* Turn on LCD backlight */ + + esp32s3_gpiowrite(ESP32S3_R8_DISPLAY_BCKL, false); + + g_spidev = esp32s3_spibus_initialize(ESP32S3_R8_DISPLAY_SPI); + if (!g_spidev) + { + lcderr("ERROR: Failed to initialize SPI port %d\n", + ESP32S3_R8_DISPLAY_SPI); + return -ENODEV; + } + + g_lcd = st7789_lcdinitialize(g_spidev); + if (!g_lcd) + { + lcderr("ERROR: st7789_lcdinitialize() failed\n"); + return -ENODEV; + } + + return OK; +} + +/**************************************************************************** + * Name: board_lcd_getdev + * + * Description: + * Return a a reference to the LCD object for the specified LCD. This + * allows support for multiple LCD devices. + * + * Input Parameters: + * devno - LCD device nmber Review Comment: checkpatch fails on this line: `nmber ==> number`. Fix: write "number". ########## boards/xtensa/esp32s3/esp32s3-r8/src/esp32s3_touchscreen.c: ########## @@ -0,0 +1,104 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-r8/src/esp32s3_touchscreen.c + * + * SPDX-License-Identifier: Apache-2.0 Review Comment: The header has only the SPDX line; the other new files have the full Apache license text. Fix: use the same header as esp32s3_board_lcd.c (if the file stays, see the comment on Kconfig). ########## boards/xtensa/esp32s3/esp32s3-r8/configs/openvela/defconfig: ########## @@ -0,0 +1,66 @@ +# +# 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_ESP32S3_RTC is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +CONFIG_ARCH="xtensa" +CONFIG_ARCH_BOARD="esp32s3-r8" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_ESP32S3_R8=y +CONFIG_ARCH_CHIP="esp32s3" +CONFIG_ARCH_CHIP_ESP32S3=y +CONFIG_ARCH_CHIP_ESP32S3WROOM2N32R8V=y Review Comment: This config still does not build: `esp_irq.c:127:4: error: #error "CONFIG_ARCH_MINIMAL_VECTORTABLE_DYNAMIC must be enabled for Xtensa-based Espressif SoCs..."`. Also `CONFIG_NSH_ARCHINIT`, `CONFIG_NSH_LINELEN` and `CONFIG_LCD_ST7789_SWAP_BYTES` do not exist in nuttx or nuttx-apps master, so `make savedefconfig` drops them. Fix: add `CONFIG_ARCH_MINIMAL_VECTORTABLE_DYNAMIC=y`, `CONFIG_ARCH_IRQ_TO_NDX=y` and `CONFIG_ARCH_NUSER_INTERRUPTS=2`, remove the three unknown options, and regenerate the file with `make savedefconfig`. ########## boards/xtensa/esp32s3/esp32s3-r8/Kconfig: ########## @@ -0,0 +1,99 @@ +# +# 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_R8 + +config ESP32S3_STORAGE_MTD_OFFSET + hex "Storage MTD base address in SPI Flash" + default 0x180000 + 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 + +config ESP32S3_R8_LCD + bool "Enable ESP32-S3-R8 LCD" + default n + select ESP32S3_SPI2 + select SPI_CMDDATA + select LCD + select LCD_DEV + select LCD_ST7789 + ---help--- + Enable board LCD support, IC is LCD_ST7789V. + +config ESP32S3_R8_TOUCHSCREEN Review Comment: `ESP32S3_R8_TOUCHSCREEN=y` does not build: `ft5x06.h:65:4: error: #error "Work queue support required. CONFIG_SCHED_WORKQUEUE must be selected."`, and with a work queue `'ESP32S3_R8_TOUCH_RST' undeclared` (esp32s3_touchscreen.c:66, 83) and `'ESP32S3_R8_TOUCH_I2C' undeclared` (:89). No code calls `board_touchscreen_initialize()`. `ESP32S3_R8_QMI8658` and `ESP32S3_R8_AUDIO` only select drivers; no board code registers the IMU or the codecs. Fix: complete these three features (pins in esp32s3-r8.h, select a work queue, declare and call the init functions from esp32s3_bringup.c) and build each one, or remove them, esp32s3_touchscreen.c and the codec defines in board.h, and the sentence about them in the commit message. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
