NB: Le support du ESP32-S3 pour TinyGo est encore en phase de développement.
Vous trouverez une branche TinyGo qui le supporte partiellement ici:
GitHub - ofauchon/tinygo at esp32-s3
Go compiler for small places. Microcontrollers, WebAssembly, and command-line tools. Based on LLVM. - GitHub - ofauchon/tinygo at esp32-s3
- Le code source de notre application
Commençons pas un exemple simple, qui va utiliser un timer et l'uart:
package main
import (
"time"
)
func main() {
c := uint32(0)
for {
println("TinyGo ESP32-S3 Count:", c, "seconds")
c++
time.Sleep(time.Millisecond * 1000)
}
}
- Compilation
$ tinygo build -o helloworld/hello.bin -target=esp32s3 helloworld/esp32-hello.go
- Flash
$ esptool.py --chip=esp32s3 --port /dev/ttyACM1 write_flash 0x0000 helloworld/hello.bin -ff 80m -fm dout --verify
- Lecture de l'UART
SP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x15 (USB_UART_CHIP_RESET),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x40378d03
SPIWP:0xee
mode:DOUT, clock div:1
load:0x3fc89000,len:0xc0
load:0x40378000,len:0x4c
load:0x4037804c,len:0xde8
entry 0x4037800c
TinyGo ESP32-S3 Count: 0 seconds
TinyGo ESP32-S3 Count: 1 seconds
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DOUT, clock div:1
load:0x3fc89000,len:0xc0
load:0x40378000,len:0x4c
load:0x4037804c,len:0xde8
entry 0x4037800c
TinyGo ESP32-S3 Count: 0 seconds
TinyGo ESP32-S3 Count: 1 seconds
TinyGo ESP32-S3 Count: 2 seconds
TinyGo ESP32-S3 Count: 3 seconds
TinyGo ESP32-S3 Count: 4 seconds
TinyGo ESP32-S3 Count: 5 seconds
Conclusion
Vous savez maintenant compiler un premier bout de code TinyGo pour l'ESP32-S3.