Skip to content
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

Added esp32c6 support #917

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Conversation

Wassasin
Copy link

@Wassasin Wassasin commented Apr 9, 2024

Quickly ported the ESP32C3 support and example to the ESP32C6 HP core.

TODO

  • Restructure & deduplicate this code with the ESPC3 code.
  • The GPIO button does not seem to work.
  • LP core support.
  • Add CI support.

@Wassasin Wassasin changed the title WIP: Added esp32c6 support Added esp32c6 support Apr 10, 2024
@Wassasin
Copy link
Author

I would love to hear some recommendations or ideas on how to properly deduplicate the code with regards to the existing unstable support for the ESPC3.

I am leaving LP core support out of this MR for a separate MR later on.

@AfoHT
Copy link
Contributor

AfoHT commented Apr 16, 2024

Really neat, seems that went quite smoothly :)

I'm not too familiar with the differences C3 and C6, are they close enough that sharing examples is expected to work throughout?

Looks like how you've done it in xtask is quite clean as is 👍

Could you please re-sync C6 support with C3 (latest master branch)? Then it should be possible to also run examples on C6 in QEMU :)

@Wassasin
Copy link
Author

@AfoHT While the ESP32C3 and ESP32C6 are very similar, they differ in RISCV instruction set with atomics, peripheral layout, and chip ID. Still to give it a go I replicated the CI QEMU setup and ran the example image on the ESP32C3 ROM but it fails when checking the image chip ID, as expected.

$ cargo run --example sw_and_hw --features=riscv-esp32c6-backend
    Finished dev [unoptimized + debuginfo] target(s) in 0.03s
     Running `/home/wouter/tmp/rtic/examples/esp32c6/./runner.sh target/riscv32imac-unknown-none-elf/debug/examples/sw_and_hw`
Chip type:         esp32c6
Merge:             true
Skip padding:      false
App/part. size:    241,088/4,128,768 bytes, 5.84%
[2024-04-17T09:05:31Z INFO ] Image successfully saved!
esptool.py v4.7.0
File size: 4194304 (bytes)
Detected image type: ESP32-C6

ESP32-C6 image header
=====================
Image version: 1
Entry point: 0x4086c410
Segments: 3
Flash size: 4MB
Flash freq: 80m
Flash mode: DIO

ESP32-C6 extended image header
==============================
WP pin: 0xee (disabled)
Flash pins drive settings: clk_drv: 0x0, q_drv: 0x0, d_drv: 0x0, cs0_drv: 0x0, hd_drv: 0x0, wp_drv: 0x0
Chip ID: 13 (ESP32-C6)
Minimal chip revision: v0.0, (legacy min_rev = 0)
Maximal chip revision: v0.99

Segments information
====================
Segment   Length   Load addr   File offs  Memory types
-------  -------  ----------  ----------  ------------
      1  0x00d48  0x4086c410  0x00000018  DRAM, BYTE_ACCESSIBLE, IRAM
      2  0x02d68  0x4086e610  0x00000d68  DRAM, BYTE_ACCESSIBLE, IRAM
      3  0x01800  0x40875720  0x00003ad8  DRAM, BYTE_ACCESSIBLE, IRAM

ESP32-C6 image footer
=====================
Checksum: 0x21 (valid)
Validation hash: aff89878a96cbff57c66c38aa6d1a422b7785040b5efea582babef6c357427c2 (valid)
Adding SPI flash device
QEMU 8.2.0 monitor - type 'help' for more information
(qemu) q
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
Invalid chip id. Expected 5 read 13. Bootloader for wrong chip?
ets_main.c 333

@snorkman88
Copy link
Contributor

Looks good, thanks for adding this. Would it be possible to add example that shows how to connect to a WiFi network?

@dlaw
Copy link

dlaw commented Apr 28, 2024

I am very excited to see RTIC esp32c6 support in progress!

I tried running the esp32c6 example from this PR on my esp32c6 hardware. Unfortunately, the hardware task does not appear to work. I trimmed it down to a minimal broken example:

Source code:
https://github.com/dlaw/esp32c6/blob/rtic/src/main.rs

Entire project including all cargo configurations:
https://github.com/dlaw/esp32c6/tree/rtic

I build and run this code by using cargo run --release, which launches espflash flash --monitor.

Expected behavior:
When pressing the button, Button! prints in between Tick prints.

Actual behavior:
When pressing the button, the Tick printing halts and no further output is observed until the chip is reset. Furthermore, when I set a breakpoint in gpio_handler(), the breakpoint never triggers.

Further debugging:

  • When I change binds=GPIO to binds=XXX for gpio_handler(), where XXX is any other interrupt, the behavior is unchanged.
  • When the button.listen() call is removed, pressing the button does not stop the Tick printing. So, it's a problem which is specific to the GPIO interrupt being enabled.

@dlaw
Copy link

dlaw commented Apr 29, 2024

Wassasin pointed out that my example was not working because I was using esp-hal 0.17. It works fine with esp-hal 0.16. However, there is a snag which currently prevents the use of esp-wifi with RTIC:

  • esp-hal 0.16 has an optional direct-vectoring feature
  • this PR requires esp-hal 0.16 with direct-vectoring enabled
  • esp-wifi 0.4 requires esp-hal 0.16 with direct-vectoring disabled

The issue would be solved by supporting esp-hal 0.17, because:

  • direct-vectoring is enabled by default (no longer an optional feature) in esp-hal 0.17
  • esp-wifi 0.5 works with esp-hal 0.17

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants