Repository navigation
Add ESP32-H2 and the ESP32-H2-DevKitM-1 board - #5750
Conversation
IMG_4473.movIMG_4472.mov |
|
@zombieleet please rebase this PR against |
Yah, I actually wanted to do that, but stacked pr only works on branches that are in the tinygo repo itself |
Add the ESP32-H2 chip ID (0x0010) and the flash speed/size byte to the ESP image header. For the ESP32-H2, the flash clock code 0xF is 48 MHz, which is the maximum. The flasher changes the flash size to the real value. See esptool targets/esp32h2.py (IMAGE_CHIP_ID, FLASH_FREQUENCY).
Add the esp32h2 chip target. The ESP32-H2 uses the same RISC-V core, PLIC and USB Serial/JTAG block as the ESP32-C6, so it uses the ESP32-C6 startup assembly and the shared PLIC, interrupt and USB files with a build tag. Differences from the ESP32-C6: - 320 KB SRAM and different ROM function addresses in the linker script. - The CPU runs at 32 MHz from the XTAL. TIMG0 uses the XTAL divided by 4, which gives 125 ns for each tick. - The UART uses the 32 MHz XTAL (PCR SCLK_SEL 3). The default UART0 pins are GPIO24 (TX) and GPIO23 (RX). - The UART interrupt uses CPU interrupt 13. Interrupts 3, 4 and 7 are bound to the CLINT and cannot be used. The linker script also pads the end of .text so that .rodata is at a 16-byte aligned flash offset, and it checks with ASSERT that .text and .rodata have the same address as their flash offset. References: ESP-IDF components/soc/esp32h2, components/esp_rom/esp32h2, components/esp_hal_uart/esp32h2, components/esp_hal_timg/esp32h2 and components/esp_hw_support/port/esp32h2/esp_cpu_intr.c.
Add the Espressif ESP32-H2-DevKitM-1 board. The board target uses the port printed UART, which is a CP2102N USB to UART bridge on UART0. So it uses esp32flash with the classic reset, and machine.Serial uses the UART. The onboard LED is a WS2812 on GPIO8, not a plain LED. The board file defines WS2812 and BUTTON (the BOOT button on GPIO9), but not LED, the same as other boards that have only an addressable LED. The smoke test builds examples/machinetest and examples/serial. See the user guide: https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32h2/esp32-h2-devkitm-1/user_guide.html
|
@deadprogram rebased. Thanks |
|
Thanks for the rebase and for this port @zombieleet. The following is edited from an automated review:
|
|
@zombieleet please see #5755 for some C6 fixes discovered while testing this PR. |
deadprogram
left a comment
There was a problem hiding this comment.
Thanks again @zombieleet for working on this. I addressed one of my comments in a new PR, and the other one can wait for a future moment. Now merging.
This PR adds the ESP32-H2 chip and the Espressif ESP32-H2-DevKitM-1 board.
The ESP32-H2 is close to the ESP32-C6
The ESP32-H2 is not very different from the ESP32-C6. Both chips use the same RISC-V core, the same PLIC interrupt controller, the same PCR clock and reset block, the same interrupt matrix, the same USB Serial/JTAG block and the same memory map. So this port uses the existing ESP32-C6 code where it can:
src/device/esp/esp32c6.S). The H2 ROM has the same cache functions, at different addresses.runtime_esp32xx_plic.go, added in runtime/esp32: prepare the shared runtime for more RISC-V chips #5749).interrupt_esp32c6.go) and USB Serial/JTAG driver (machine_esp32c6_usb.go), with a build tag.machine_esp32h2.gostarted as a copy ofmachine_esp32c6.go. It changes only the parts in the table below.esp32h2.rom.ld)SCLK_SEL3)CLK_CONFfieldsSCLK_SEL,SCLK_DIV_*in the UART blockTX_SCLK_ENandSCLK_ENonlyCommits
builder: add the esp32h2 firmware image format. Chip ID 0x0010 and flash code 0xF (48 MHz, the H2 maximum), from esptooltargets/esp32h2.py.runtime,machine,targets: add ESP32-H2 support. Theesp32h2chip target, the linker script, the H2 clock setup, the machine package and the build tags on the shared files.machine,targets: add the ESP32-H2-DevKitM-1 board. The board uses the port printed UART (a CP2102N on UART0), so it usesesp32flashandserial: uart. The onboard LED is a WS2812 on GPIO8, so the board file definesWS2812andBUTTON(GPIO9) but notLED, the same as other boards with only an addressable LED. The smoke test buildsexamples/machinetestandexamples/serial.Tested on an ESP32-H2-DevKitM-1 (N4)
esp32flashon the UART portexamples/serialexamples/echo(UART RX interrupt)make smoketest-esppasses. The ESP32-C6 binaries do not change with this PR.