tinygo icon indicating copy to clipboard operation
tinygo copied to clipboard

Board Support: ESP32-C6

Open johanvandeweerd opened this issue 1 year ago • 2 comments

Hi

Just started to get into the ESP32 rabbit hole and bought myself a ESP32-C6 development board. Given that my experience in C/C++ is limited and I have quite some experience in Go, I would prefer to program the board using Tinygo.

After installing Tinygo, creating a simple HelloWorld main and flashing it to the board using Tinygo, I get following output:

# tinygo flash --target=esp32 --port=/dev/cu.usbmodem21401 main.go      
esptool.py v4.6.2
Serial port /dev/cu.usbmodem21401
Connecting...

A fatal error occurred: This chip is ESP32-C6 not ESP32. Wrong --chip argument?
error: failed to flash /var/folders/0s/snyz0vdx62s099y165bsy1wh0000gn/T/tinygo4172958918/main.bin: exit status 2

This is my main.go file

package main

import "fmt"

func main() {
	fmt.Println("Hello world!")
}

I assume it means that the ESP32-C6 boards are not yet supported? I looked at the Adding a new board page but got very lost very fast.

Do I need to wait for Tinygo to support this board (or can I help in any shape or form)?

johanvandeweerd avatar Dec 06 '23 12:12 johanvandeweerd

The first step would be getting an SVD file for that processor into https://github.com/cmsis-svd/cmsis-svd-data

Perhaps open an issue on that repo to see if anyone is working on that part yet?

Once there is an SVD files we can start on integration for TinyGo.

deadprogram avatar Dec 07 '23 11:12 deadprogram

Official Espressif SVD files can be found here: https://github.com/espressif/svd/tree/main/svd

I suspect the ESP32-C6 will be similar to the ESP32-C3. You can grep for esp32c3 to see where the build tag is defined. It might be as easy as copy-pasting the esp32c3.json file and modifying it to use esp32c6 instead, but there is a good chance some parts need to be modified.

One small difference I found is that the ESP32-C6 has an RV32IMAC CPU, whereas the ESP32-C3 has an RV32IMC CPU. This means that the ESP32-C6 also supports atomic instructions. This just means you need to add the 'a' (atomic) extension to the target JSON file.

aykevl avatar Dec 07 '23 12:12 aykevl