-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Add ESP32-C6 support #5248
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
gandarez
wants to merge
8
commits into
tinygo-org:dev
Choose a base branch
from
gandarez:feat/esp32-c6
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add ESP32-C6 support #5248
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e955418
Add support for esp32-c6
gandarez 0bfb03e
feat: Add esp32c6 to smoke test
gandarez 6f18e1e
fix: correct ESP32-C6 SWD key and clock dividers to prevent reset and…
gandarez 603d5ca
fix: format
gandarez 87b11f8
fix: move sarEnable to separate file to fix m5stamp_c3 build tag mism…
gandarez 61183a5
fix: enable atomic extension features for ESP32-C6 target
gandarez a3fa14a
fix: fix llvm features ordering
gandarez ae68d6d
fix: Add missing ROM functions
gandarez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| // This is a very minimal bootloader for the ESP32-C6. It only initializes the | ||
| // flash and then continues with the generic RISC-V initialization code, which | ||
| // in turn will call runtime.main. | ||
| // It is written in assembly (and not in a higher level language) to make sure | ||
| // it is entirely loaded into IRAM and doesn't accidentally call functions | ||
| // stored in IROM. | ||
| // | ||
| // The ESP32-C6 has a unified IRAM/DRAM address space at 0x40800000, and | ||
| // separate DROM (0x42800000) / IROM (0x42000000) flash-mapped regions. | ||
|
|
||
| .section .init | ||
| .global call_start_cpu0 | ||
| .type call_start_cpu0,@function | ||
| call_start_cpu0: | ||
| // At this point: | ||
| // - The ROM bootloader is finished and has jumped to here. | ||
| // - We're running from IRAM: both IRAM and DRAM segments have been loaded | ||
| // by the ROM bootloader. | ||
| // - We have a usable stack (but not the one we would like to use). | ||
| // - No flash mappings (MMU) are set up yet. | ||
|
|
||
| // Reset MMU, see bootloader_reset_mmu in the ESP-IDF. | ||
| call Cache_Suspend_ICache | ||
| mv s0, a0 // autoload value | ||
| call Cache_Invalidate_ICache_All | ||
| call Cache_MMU_Init | ||
|
|
||
| // Set up flash mapping (both IROM and DROM). | ||
| // On ESP32-C6, Cache_Dbus_MMU_Set is replaced by Cache_MSPI_MMU_Set | ||
| // which has an extra "sensitive" parameter. | ||
| // C equivalent: | ||
| // Cache_MSPI_MMU_Set(0, 0, 0x42000000, 0, 64, 256, 0) | ||
| // Maps 16MB starting at 0x42000000, covering both IROM and DROM. | ||
| li a0, 0 // sensitive: no flash encryption | ||
| li a1, 0 // ext_ram: MMU_ACCESS_FLASH | ||
| li a2, 0x42000000 // vaddr: start of flash-mapped region | ||
| li a3, 0 // paddr: physical address in the flash chip | ||
| li a4, 64 // psize: always 64 (kilobytes) | ||
| li a5, 256 // num: pages (16MB / 64K = 256, covers IROM+DROM) | ||
| li a6, 0 // fixed | ||
| call Cache_MSPI_MMU_Set | ||
|
|
||
| // Enable the flash cache. | ||
| mv a0, s0 // restore autoload value from Cache_Suspend_ICache call | ||
| call Cache_Resume_ICache | ||
|
|
||
| // Jump to generic RISC-V initialization, which initializes the stack | ||
| // pointer and globals register. It should not return. | ||
| j _start | ||
|
|
||
| .section .text.exception_vectors | ||
| .global _vector_table | ||
| .type _vector_table,@function | ||
|
|
||
| _vector_table: | ||
|
|
||
| .option push | ||
| .option norvc | ||
|
|
||
| .rept 32 | ||
| j handleInterruptASM /* interrupt handler */ | ||
| .endr | ||
|
|
||
| .option pop | ||
|
|
||
| .size _vector_table, .-_vector_table |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| //go:build esp32c6 | ||
|
|
||
| // This file contains the default pin mappings for the ESP32-C6 generic target. | ||
|
|
||
| package machine | ||
|
|
||
| // Digital Pins | ||
| const ( | ||
| IO0 = GPIO0 | ||
| IO1 = GPIO1 | ||
| IO2 = GPIO2 | ||
| IO3 = GPIO3 | ||
| IO4 = GPIO4 | ||
| IO5 = GPIO5 | ||
| IO6 = GPIO6 | ||
| IO7 = GPIO7 | ||
| IO8 = GPIO8 | ||
| IO9 = GPIO9 | ||
| IO10 = GPIO10 | ||
| IO11 = GPIO11 | ||
| IO12 = GPIO12 | ||
| IO13 = GPIO13 | ||
| IO14 = GPIO14 | ||
| IO15 = GPIO15 | ||
| IO16 = GPIO16 | ||
| IO17 = GPIO17 | ||
| IO18 = GPIO18 | ||
| IO19 = GPIO19 | ||
| IO20 = GPIO20 | ||
| IO21 = GPIO21 | ||
| IO22 = GPIO22 | ||
| IO23 = GPIO23 | ||
| IO24 = GPIO24 | ||
| IO25 = GPIO25 | ||
| IO26 = GPIO26 | ||
| IO27 = GPIO27 | ||
| IO28 = GPIO28 | ||
| IO29 = GPIO29 | ||
| IO30 = GPIO30 | ||
| ) | ||
|
|
||
| // Built-in WS2812 (NeoPixel) addressable RGB LED on the ESP32-C6-DevKitC. | ||
| // Use tinygo.org/x/drivers/ws2812 to control it. | ||
| const ( | ||
| LED = WS2812 | ||
| WS2812 = GPIO8 | ||
| NEOPIXEL = GPIO8 | ||
| ) | ||
|
|
||
| // Analog pins | ||
| const ( | ||
| A0 = GPIO0 | ||
| A1 = GPIO1 | ||
| A2 = GPIO2 | ||
| A3 = GPIO3 | ||
| A4 = GPIO4 | ||
| A5 = GPIO5 | ||
| A6 = GPIO6 | ||
| ) | ||
|
|
||
| // UART pins | ||
| const ( | ||
| UART_RX_PIN = GPIO17 | ||
| UART_TX_PIN = GPIO16 | ||
| ) | ||
|
|
||
| // I2C pins | ||
| const ( | ||
| SDA_PIN = GPIO6 | ||
| SCL_PIN = GPIO7 | ||
| ) | ||
|
|
||
| // SPI pins | ||
| const ( | ||
| SPI_MISO_PIN = GPIO2 | ||
| SPI_MOSI_PIN = GPIO7 | ||
| SPI_SS_PIN = GPIO10 | ||
| SPI_SCK_PIN = GPIO6 | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| //go:build (esp32c3 && !m5stamp_c3) || esp32s3 | ||
|
|
||
| package machine | ||
|
|
||
| import ( | ||
| "device/esp" | ||
| "runtime/volatile" | ||
| "unsafe" | ||
| ) | ||
|
|
||
| // sarEnable enables the analog SAR I2C domain before any regI2C access, | ||
| // matching the prologue in adc_ll_calibration_prepare(). | ||
| func (r regI2C) sarEnable() { | ||
| cfg := (*volatile.Register32)(unsafe.Pointer(anaConfigReg)) | ||
| cfg2 := (*volatile.Register32)(unsafe.Pointer(anaConfig2Reg)) | ||
| esp.RTC_CNTL.SetANA_CONF_SAR_I2C_PU(1) | ||
| cfg.Set(cfg.Get() &^ i2cSarEnMask) | ||
| cfg2.Set(cfg2.Get() | anaSarCfg2En) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| //go:build esp32c3 || esp32s3 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps naming like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe not merge, but copy? |
||
|
|
||
| package machine | ||
|
|
||
| import "device/esp" | ||
|
|
||
| // enableI2C0PeriphClock enables the I2C0 peripheral clock via SYSTEM. | ||
| func enableI2C0PeriphClock() { | ||
| esp.SYSTEM.SetPERIP_RST_EN0_I2C_EXT0_RST(1) | ||
| esp.SYSTEM.SetPERIP_CLK_EN0_I2C_EXT0_CLK_EN(1) | ||
| esp.SYSTEM.SetPERIP_RST_EN0_I2C_EXT0_RST(0) | ||
| } | ||
|
|
||
| // enableLEDCPeriphClock enables the LEDC peripheral clock via SYSTEM. | ||
| func enableLEDCPeriphClock() { | ||
| esp.SYSTEM.SetPERIP_RST_EN0_LEDC_RST(1) | ||
| esp.SYSTEM.SetPERIP_CLK_EN0_LEDC_CLK_EN(1) | ||
| esp.SYSTEM.SetPERIP_RST_EN0_LEDC_RST(0) | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is not really such a thing as "generic" target. From the comments below, shouldn't this be
board_esp32c6_devkitc?