Skip to content

Add Support for Adafruit ESP32-S3 and ESP32-S2 Feather Boards #68512

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

Open
zpm1066 opened this issue Feb 4, 2024 · 11 comments
Open

Add Support for Adafruit ESP32-S3 and ESP32-S2 Feather Boards #68512

zpm1066 opened this issue Feb 4, 2024 · 11 comments
Assignees
Labels
Feature Request A request for a new feature platform: ESP32 Espressif ESP32

Comments

@zpm1066
Copy link

zpm1066 commented Feb 4, 2024

Is your feature request related to a problem? Please describe.
This is a request to add support for the very popular family of Adafruit ESP32-S3 Feather and ESP32-S2 Feather boards.

As we already have support for the Xtensa ESP32-S3 and ESP32-S2 SoCs, I'm hoping it would be relatively less effort to add support for the Adafruit ESP32-S3 & ESP32-S2 Feather boards.

Describe the solution you'd like
I'd like to see a common board definition to support these Adafruit ESP32-S3 & ESP32-S2 Feather boards. Folks can then add their own overlays to support the board variants that come with on-board TFT, fuel gauge, sensors, or Flash/PSRAM.

Describe alternatives you've considered
Currently there isn't any support for the Adafruit ESP32-S3 & ESP32-S2 Feather boards.

Additional context
Here is a list of the current Adafruit ESP3-S3 & ESP32-S2 Feather boards that this request will be able to support.

@zpm1066 zpm1066 added the Feature Request A request for a new feature label Feb 4, 2024
@henrikbrixandersen henrikbrixandersen added the platform: ESP32 Espressif ESP32 label Feb 5, 2024
@zpm1066
Copy link
Author

zpm1066 commented Feb 9, 2024

Hello,

I’ve been looking to see if I can leverage board xiao_esp32s3 or esp32s3_devkitm, as the Adafruit esp32s3 Feather also uses ESP32-S3-Mini-1 SoC.

If so, I expect the changes to add support for the Adafruit esp32s3 boards may be relatively small.

I’ll be available for any testing if needed.

@zpm1066
Copy link
Author

zpm1066 commented Feb 9, 2024

Just ran a few quick tests. It looks like I’ll be able use board xiao_esp32s3 for some initial tests with the Adafruit ESP32S3 Feather boards.

I expected esp32s3_devkitm boards to work with the Adafruit esp32s3 boards as both are ESP32-S3-Mini-1 but no. Perhaps some mismatch flash in the Flash partitions.

Anyway, for now I’ll override GPIOs and I2C in an overlay to conduct some tests using xiao_esp32s3 and provide some updates.

@sylvioalves
Copy link
Collaborator

You should be able to get that working adding overlays and necessary configs. You are welcome to submit a PR to bring support to this boards.

@zpm1066
Copy link
Author

zpm1066 commented Feb 9, 2024

Yes - xiao_esp32s3 board works!
Build using esp32s3_ devkitm did’t work though it is ESP32-S3-Mini-1.

@sylvioalves - Any reason why esp32s3_ devkitm didn’t work? The esp32s3 TFT Feather is 4MB Flash and 2MB PSRAM.

@zpm1066
Copy link
Author

zpm1066 commented Feb 14, 2024

I've setup a new board Adafruit_esp32s3_tft_feather locally.

Added and tested:

  • onboard GPIOs - builtin led, user button
  • I2C with SSD1306 and a sensor
  • SPI with ST7789 135x240 (same as the onboard display)
  • feather_header connector
  • on-board MAX17048

Items remaining to configure & test

  • regulator control via GPIO to control power to the I2C STEMMA connector and onboard ST7789 display via GPIO 21
  • I2C device connected to STEMMA connector (e.g. SSD1306, sensor)
  • On-board ST7789 135x240 display
  • Neopixel (Zephyr GPIO "bit-banging" is only supported for couple of boards, not sure what options exist)

I've run some test with the regulator binding, see below.

There is 3.26V at the I2C STEMMA connector, SDA and SCK pins also have valid signal levels. This means that the firmware is sending I2C data correctly continuously to the display, as expected.

Given that the first 2 errors are I2C transfer error and ssd1306: Failed to initialize device! before the “*** Booting Zephyr …”, it appears that I2C and SSD1306 initialization occurs before the regulator power comes on.

How do I check and modify the order of I2C, SSD1306, Regulator priorities in Zephyr? I think once this is done, the display will work.

Thanks.

Regulator binding in adafruit_esp32s3_tft_feather.overlay:

	reg_tft_power: reg-tft-power {
		compatible = "regulator-fixed";
		regulator-name = "reg-adafruit";
		enable-gpios = <&gpio0 21 GPIO_ACTIVE_HIGH>;
		regulator-boot-on;
	};

Code snippet for output below:

void oled_display(void)
{    
	char os_ver[32];
	int err;
	
	uint32_t ver = sys_kernel_version_get();
    snprintf(os_ver,sizeof(os_ver),"Zephyr v%d.%d.%d",SYS_KERNEL_VER_MAJOR(ver), \
    	SYS_KERNEL_VER_MINOR(ver),SYS_KERNEL_VER_PATCHLEVEL(ver));
    	
    LOG_INF("%s\n",os_ver);
    LOG_INF(CONFIG_BOARD);
    while (1) {
        cfb_print(dev,CONFIG_BOARD, 0, 2*ppt);
        cfb_print(dev, "", 0, 1*ppt);
        cfb_print(dev, "OLED SSD1306 128x64", 0, 0);
        cfb_print(dev, "", 0, 3*ppt);
        cfb_print(dev, "", 0, 4*ppt);
        cfb_print(dev, "", 0, 5*ppt);
        cfb_print(dev, os_ver, 0, 6*ppt);
        
        err = cfb_framebuffer_finalize(dev);
		if (err) {
			printk("Could not finalize framebuffer (err %d)\n", err);
		}
        k_sleep(K_MSEC(500));
    }
}

espressif monitor output:

[00:00:00.228,000] <err> i2c_esp32: I2C transfer error: -14
[00:00:00.228,000] <err> ssd1306: Failed to initialize device!
*** Booting Zephyr OS build zephyr-v3.5.0-4872-gcf14d4f1fd6d ***
[00:00:00.228,000] <inf> main: main_thread
Display device not ready
[00:00:00.228,000] <dbg> cfb: cfb_framebuffer_init: number of fonts 2
[00:00:00.317,000] <inf> display: Index[0] font dimensions  5x8
[00:00:00.317,000] <inf> display: Index[1] font dimensions  8x8
[00:00:00.317,000] <inf> display: Selected font: index[3]
[00:00:00.317,000] <inf> display: x_res 128, y_res 64, ppt 8, rows 8, cols 128
[00:00:00.317,000] <inf> display: Zephyr v3.5.99

[00:00:00.317,000] <inf> display: adafruit_esp32s3_tft_feather
uart:~$ device list
devices:
- rtc@60021000 (READY)
- gpio@60004800 (READY)
- gpio@60004000 (READY)
- trng@6003507c (READY)
- uart@60000000 (READY)
- uart@60038000 (READY)
- i2c@60013000 (READY)
- reg-tft-power (READY)
- ssd1306@3c (DISABLED)
uart:~$ 

Output on regulator disable. Re-enabling the regulator stops the the I2C transfer errors.

uart:~$ regulator disable reg-tft-power
[00:26:06.518,000] <err> i2c_esp32: I2C transfer error: -116
[00:26:06.518,000] <err> ssd1306: Failed to write command
Could not finalize framebuffer (err -1)
[00:26:07.519,000] <err> i2c_esp32: I2C transfer error: -116
[00:26:07.519,000] <err> ssd1306: Failed to write command
Could not finalize framebuffer (err -1)
[00:26:08.519,000] <err> i2c_esp32: I2C transfer error: -116
[00:26:08.519,000] <err> ssd1306: Failed to write command
Could not finalize framebuffer (err -1)
uart:~$ 

@zpm1066
Copy link
Author

zpm1066 commented Feb 14, 2024

The I2C STEMMA connector on the ESP32-S3 TFT Feather already has pull-up resistors.

With Arduino, only I2C and SSD1306 requires initialization as Arduino already raises GPIO 21 HIGH prior to Arduino setup().

Screen Shot 2024-02-13 at 11 39 39 PM

@DBS06
Copy link
Contributor

DBS06 commented Feb 3, 2025

Hi, I started last week to port the Adafruit ESP32-S2 TFT Feather because it was laying around at work and I was curious if I am able to get it work and today I stumbled over this thread.

At present I was able to successfully add and test (btw: I was really lucky as I saw the LED blinking and the NeoPixel running 😊, so I think I am on the right path to success):

  • on-board LED
  • NeoPixel

For the rest of the on-board peripherals I almost have everything together but not yet commited and pushed, because I am unsure if it is working, because I have a little bit of a show stopper which is the Serial-Out over USB.

No matter what I do or try, I am not getting it to work, or to show up as a Serial on my System (WSL2 Ubuntu)
I am not 100% sure, but I think the USB will work only directly and not over USB-to-UART and it seems USB-OTG is not yet supported, see here: #29394
Does anyone can verify it?

Furthermore I am not sure if I got all the pins and corresponding functions correctly.
Actually the pin-out and schematics from Adafruit could be better described, but I can deal with it.

My branch can be viewed here:
https://github.com/DBS06/zephyr/tree/esp32s2_tft_feather/boards/adafruit/feather_esp32s2_tft

Thanks for @leonrinkel I "stole" the feather_connector.dtsi because it seems to be the same for the Adafruit ESP32-S2 TFT Feather.

@DBS06
Copy link
Contributor

DBS06 commented Feb 3, 2025

Thanks to the awesome work done by @leonrinkel I was able to get the display working.

List of working and tested features/peripherals for Adafruit ESP32-S2 TFT Feather:

  • On-Board_LED
  • On-Board-Button
  • NeoPixel
  • TFT-Display
  • Add STEMMA QT Connector -> shares the same power pin as the display.
  • UART -> tested with an FTDI USB to RS232
  • Battery Monitor (I have a board with the Adafruit LC709203F, but there is also a version out there MAX17048)
  • Write Documentation
  • USB-OTG-> Support needed Not Available
  • Add Adafruit ESP32-S2 Feather | Rev B | LC709203 | I2C Power GPIO0 7 -> LOW
  • Add Adafruit ESP32-S2 Feather | Rev C | LC709203 | I2C Power GPIO0 7 -> HIGH
  • Add Adafruit ESP32-S2 Feather | Rev C | MAX17048 | I2C Power GPIO0 7 -> HIGH
  • Add Adafruit ESP32-S2 Feather | Rev B | LC709203 | BME280 | I2C Power GPIO0 7 -> LOW
  • Add Adafruit ESP32-S2 Feather | Rev C | LC709203 | BME280 | I2C Power GPIO0 7 -> HIGH
  • Add Adafruit ESP32-S2 Feather | Rev C | MAX17048 | BME280 | I2C Power GPIO0 7 -> HIGH
  • Add Adafruit ESP32-S2 TFT Feather | LC709203
  • Add Adafruit ESP32-S2 TFT Feather | MAX17048
  • Add Adafruit ESP32-S2 Reverse TFT Feather | MAX17048

No matter what I do or try, I am not getting it to work, or to show up as a Serial on my System (WSL2 Ubuntu)
I am not 100% sure, but I think the USB will work only directly and not over USB-to-UART and it seems USB-OTG is not yet supported, see here: #29394

If I am able to get the UART and/or USB working over USB I will create a PR. Most likely and from what I already read, I would need to wait if it will be added to the SoC, if thats the case, it is what it is.
Would be nice if somebody could verify that.

If I will find my FTDI USB to UART adapter, I could test if the UART works at all. Works

Regarding the Battery Monitor I actually don't know how I should proceed, because there are two versions out there, a driver for the MAX17048 already exists in zephyr, but not for the Adafruit LC709203F. Because of this, I think I will add this feature after writing the driver. Should I add two boards with the only difference that one has the LC709203F and the other the MAX17048 battery monitor, or should I add both senors in the same target, and keep them disabled. I am open for recommendations. But most likely I will add this later after the PR is merged.

@rftafas
Copy link

rftafas commented Feb 3, 2025

I am not 100% sure, but I think the USB will work only directly and not over USB-to-UART and it seems USB-OTG is not yet supported, see here: #29394
Does anyone can verify it?

The usage of USB on ESP32-S2 for flashing and console depends on some running code. It is NOT a hardware thing, like ESP32-C3. While implemented on ESP-IDF, it is missing in Zephyr. Yes, USB-OTG would be needed and yes, it is missing.

@DBS06
Copy link
Contributor

DBS06 commented Feb 3, 2025

The usage of USB on ESP32-S2 for flashing and console depends on some running code. It is NOT a hardware thing, like ESP32-C3. While implemented on ESP-IDF, it is missing in Zephyr. Yes, USB-OTG would be needed and yes, it is missing.

Thanks a lot! So it seems at least I am not stupid or overlooked something. So therefore as long as USB-OTG is not supported we are not able to use it. At least it seems that somebody will add it, or is willing to -> #29394 (comment)

Btw: I started to implement a driver for the on-semi LC709203F.

@DBS06
Copy link
Contributor

DBS06 commented Feb 5, 2025

So I am glad to inform you guys that I added Support for All Adafruit ESP32-S2 Feather XXX Dev-Boards, I only need to write the README.rst and the PR can be created.

If someone has access to the following boards and could test them it would be very helpful:

  • Adafruit ESP32-S2 Feather | Rev B | with LC709203
  • Adafruit ESP32-S2 Feather | Rev C | with LC709203
  • Adafruit ESP32-S2 Feather | Rev C | with MAX17048
  • Adafruit ESP32-S2 Feather | Rev B | with LC709203 & BME280
  • Adafruit ESP32-S2 Feather | Rev C | with LC709203 & BME280
  • Adafruit ESP32-S2 Feather | Rev C | with MAX17048 & BME280
  • Adafruit ESP32-S2 TFT Feather | with MAX17048
  • Adafruit ESP32-S2 Reverse TFT Feather | with MAX17048

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request A request for a new feature platform: ESP32 Espressif ESP32
Projects
None yet
Development

No branches or pull requests

5 participants