Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boards/esp32s2-mini: add definition for ESP32 S2 Mini #18863

Merged
merged 6 commits into from
Feb 2, 2023

Conversation

benpicco
Copy link
Contributor

@benpicco benpicco commented Nov 9, 2022

Contribution description

This adds support for the ESP32-S2 Mini, an inexpensive board based on the ESP32S2-FN4R2.

There is no additional USB <-> Serial converter, so stdio is provided by tinyUSB.

The board comes with a serial bootloader in mask ROM and can be flashed just like any other ESP32 based board.

Testing procedure

Issues/PRs references

@github-actions github-actions bot added Area: boards Area: Board ports Area: build system Area: Build system Area: doc Area: Documentation Area: Kconfig Area: Kconfig integration Area: pkg Area: External package ports labels Nov 9, 2022
@benpicco benpicco added the State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet label Nov 9, 2022
@gschorcht
Copy link
Contributor

@benpicco Is this PR still WIP or ready for review?

@benpicco
Copy link
Contributor Author

I still didn't get around to map the pins / peripherals, but that can be done rather quickly.

@gschorcht
Copy link
Contributor

This adds support for the ESP32-S2 Mini, an inexpensive board based on the ESP32S2-FN4R2.

This board seems just to be a clone of the Wemos S2 mini which in turn seems to be pin compatible with the ESP8266 LOLIN D1 mini board and its shields that we also support with (ESP-12x based boards).

IMHO, we should refer the official Wemos S2 mini product and should think about to call it esp32s2-wemos-mini or something like that. BTW, Wemos has oalso a C3 mini product.

The pins should be defined to be compatible with the Wemos Mini Shields.

Copy link
Contributor

@gschorcht gschorcht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

board.h, gpio_params.h and periph_conf.h still require some work.

boards/common/makefiles/stdio_tinyusb_cdc_acm.dep.mk Outdated Show resolved Hide resolved
boards/esp32s2-mini/Makefile.dep Outdated Show resolved Hide resolved
boards/esp32s2-mini/Makefile.features Outdated Show resolved Hide resolved
boards/esp32s2-mini/doc.txt Outdated Show resolved Hide resolved
@benpicco
Copy link
Contributor Author

Ok, UART, I2C (untested) and SPI are now on the same pins as the Wemos S2 mini.

Not sure what do do about ADC, DAC and PWM - can they be on arbitrary pins?

Doc still needs an update.

@gschorcht
Copy link
Contributor

gschorcht commented Jan 1, 2023

Not sure what do do about ADC, DAC and PWM - can they be on arbitrary pins?

The ESP32-S2 does not have a DAC device. It allows the use of 20 GPIOs as ADC channels (ADC1 10 channels: GPIO1 - GPIO10 and ADC2 10 channels: GPIO11 - GPIO20). ADC1 channels should be preferred as ADC2 is also used by the WiFi module and may not always be available when esp_wifi_any is used. GPIO3 is a strapping pin and should not be used as an ADC channel.

ESP32-S2 LEDC device has one channel group device that allows up to 8 PWM channels. PWM channels can be routed to all GPIOs with the exception of GPIO46 which is is an input-only pin.

@gschorcht
Copy link
Contributor

The ESP32-S2 does not have a DAC device.

I must revise myself, the ESP32-C3 is missing the DAC device. The ESP32-S2 has a DAC device with 2 channels that are connected to GPIO17 and GPIO18.

boards/esp32s2-wemos-mini/include/board.h Show resolved Hide resolved
boards/esp32s2-wemos-mini/include/board.h Outdated Show resolved Hide resolved
boards/esp32s2-wemos-mini/include/periph_conf.h Outdated Show resolved Hide resolved
boards/esp32s2-wemos-mini/include/periph_conf.h Outdated Show resolved Hide resolved
boards/esp32s2-wemos-mini/include/periph_conf.h Outdated Show resolved Hide resolved
boards/esp32s2-wemos-mini/include/periph_conf.h Outdated Show resolved Hide resolved
pkg/tinyusb/hw/hw_esp32.c Outdated Show resolved Hide resolved
boards/esp32s2-wemos-mini/include/periph_conf.h Outdated Show resolved Hide resolved
@benpicco benpicco force-pushed the boards/esp32s2-mini branch from 01e79b5 to 6ac2b24 Compare January 6, 2023 00:02
@benpicco benpicco marked this pull request as ready for review January 6, 2023 00:02
@benpicco benpicco removed the State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet label Jan 6, 2023
@benpicco benpicco force-pushed the boards/esp32s2-mini branch from 6ac2b24 to 0e56a47 Compare January 6, 2023 00:09
@github-actions github-actions bot removed the Area: pkg Area: External package ports label Jan 6, 2023
@benpicco benpicco force-pushed the boards/esp32s2-mini branch from 0e56a47 to d9b36ed Compare January 6, 2023 00:10
@github-actions github-actions bot added Area: cpu Area: CPU/MCU ports Platform: ESP Platform: This PR/issue effects ESP-based platforms labels Jan 6, 2023
boards/esp32s2-wemos-mini/include/board.h Outdated Show resolved Hide resolved
cpu/esp32/esp-bootloader-reset/reset.c Outdated Show resolved Hide resolved
cpu/esp32/Makefile Outdated Show resolved Hide resolved
boards/common/esp_common/Makefile.dep Outdated Show resolved Hide resolved
boards/common/esp_common/Makefile.dep Outdated Show resolved Hide resolved
boards/common/esp_common/Makefile.dep Outdated Show resolved Hide resolved
boards/esp32s2-wemos-mini/doc.txt Show resolved Hide resolved
boards/esp32s2-wemos-mini/include/periph_conf.h Outdated Show resolved Hide resolved
@gschorcht
Copy link
Contributor

What about the arduino feature and pin map?

bors bot added a commit that referenced this pull request Jan 6, 2023
18752: nanocoap_sock: deprecate nanocoap_get() r=benpicco a=benpicco





19100: cpu/esp_common: allow configuration of UART0 r=benpicco a=gschorcht

### Contribution description

This PR
- fixes the issue for ESP32 SoCs that UART0 signals can't be routed to arbitrary GPIOs and
- allows the configuration of the UART device used by the bootloader.

The UART interface and its configuration used by the STDIO are defined in RIOT using the define `STDIO_UART_DEV` and the configuration of the corresponding UART device in `periph_conf.h`. 

However, the bootloader compiled directly in ESP-IDF uses its own definitions `CONFIG_ESP_CONSOLE_UART_*` for the UART configuration. To be able to use a consistent UART configuration in RIOT and the bootloader, e.g. to see the output of the 2nd stage bootloader, these `CONFIG_ESP_CONSOLE_UART_*` can be defined via a set of KConfig variables in RIOT (not yet implemented in Kconfig):
- `CONSOLE_CONFIG_UART_NUM` defines the UART device to be used by the bootloader and by `STDIO_UART_DEV`
- `CONSOLE_CONFIG_UART_RX` and `CONSOLE_CONFIG_UART_TX` define the GPIOs to be used by the bootloader and should be the GPIOs as defined in `periph_conf.h` for the corresponding UART device.

### Testing procedure

Any ESP32 node should still work with `stdio_uart` and the default configuration. To test an alternative configuration, use
```
CFLAGS='-DUART1_TXD=5 -DUART1_RXD=4 -DCONFIG_CONSOLE_UART_NUM=1 -DCONFIG_CONSOLE_UART_TX=5 -DCONFIG_CONSOLE_UART_RX=4' USEMODULE=esp_log_startup BOARD=esp32-wroom-32 make -C tests/shell flash
```
The bootloader output and the STDIO should be routed to UART1 at GPIO4 and GPIO5.

### Issues/PRs references

Prerequisite for PR ##18863

19104: tests/periph_uart: only exclude STDIO_UART_DEV if stdio_uart is used r=benpicco a=benpicco



Co-authored-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
Co-authored-by: Benjamin Valentin <benjamin.valentin@bht-berlin.de>
@gschorcht
Copy link
Contributor

Regarding the problem with USB OTG and the WiFi interface seems to be indeed a problem also for the ESP32-S3. It works, but very unstable. Unfortunatly, it is not easy to debug it because the USB interface is occupied by the USB OTG controller. I will try to have a JTAG adapter connected directly to the JTAG pins tomorrow.

@gschorcht
Copy link
Contributor

bors merge

@bors
Copy link
Contributor

bors bot commented Feb 2, 2023

🕐 Waiting for PR status (GitHub check) to be set, probably by CI. Bors will automatically try to run when all required PR statuses are set.

@benpicco benpicco force-pushed the boards/esp32s2-mini branch from 94b253f to ed5bfb7 Compare February 2, 2023 09:56
@benpicco
Copy link
Contributor Author

benpicco commented Feb 2, 2023

bors merge

bors bot added a commit that referenced this pull request Feb 2, 2023
18863: boards/esp32s2-mini: add definition for ESP32 S2 Mini r=benpicco a=benpicco



Co-authored-by: Benjamin Valentin <benjamin.valentin@bht-berlin.de>
Co-authored-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
@bors
Copy link
Contributor

bors bot commented Feb 2, 2023

Build failed:

@github-actions github-actions bot added the Area: tests Area: tests and testing framework label Feb 2, 2023
@@ -7,6 +7,7 @@ DISABLE_MODULE += auto_init_xtimer

# Boards that can't run only on xtimer or that always select ztimer
BOARD_BLACKLIST += \
esp32s2-wemos-mini \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😕 What is different on this board than on other ESP32-S2 boards?

Copy link
Contributor Author

@benpicco benpicco Feb 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the USB implementations always pull in ZTimer, so these tests that rely on xtimer internals don't work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, it is using stdio_tinyusb_cdc_acm which in turn depends on ztimer_msec.

@gschorcht
Copy link
Contributor

bors merge

@bors
Copy link
Contributor

bors bot commented Feb 2, 2023

🕐 Waiting for PR status (GitHub check) to be set, probably by CI. Bors will automatically try to run when all required PR statuses are set.

@bors
Copy link
Contributor

bors bot commented Feb 2, 2023

Already running a review

@bors
Copy link
Contributor

bors bot commented Feb 2, 2023

Build succeeded:

@bors bors bot merged commit 7d1ef9d into RIOT-OS:master Feb 2, 2023
@benpicco benpicco deleted the boards/esp32s2-mini branch February 2, 2023 16:50
@benpicco
Copy link
Contributor Author

benpicco commented Feb 2, 2023

Thank you for the review!

@gschorcht
Copy link
Contributor

gschorcht commented Feb 3, 2023

Without it everything expect the networking examples work.

What exactly did you mean? Did you mean that the WiFi station interface simply can't connect to the AP and you just get the constant message WiFi disconnected from ssid xxxxx, reason 201 (NO_AP_FOUND) or did it crash for you?

@benpicco
Copy link
Contributor Author

benpicco commented Feb 3, 2023

I mean that USB would not work (nothing in dmesg) - but this does work now with ed5bfb7 so I don't know what went wrong there.

@MrKevinWeiss MrKevinWeiss added this to the Release 2023.04 milestone Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: boards Area: Board ports Area: build system Area: Build system Area: cpu Area: CPU/MCU ports Area: doc Area: Documentation Area: Kconfig Area: Kconfig integration Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ESP Platform: This PR/issue effects ESP-based platforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants