-
Notifications
You must be signed in to change notification settings - Fork 433
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
ESP32-C3 (RISC-V) port #564
Comments
interesting. it looks like they reuse peripherals from ESP32, which is good. |
Hi all, |
defintiely should do it, unfortunately it's a pretty big change and i don't have the time right now... |
We've been developing on Mongoose is various ways and based on our roadmap use of the -C3 is critical. Is support for the -C3 something that we can help to work towards? I don't really know how the hardware layer of MOS works to support different chips. If you can point me in the right direction I'll do some work to investigate how to support it. |
there isn't really a guide for adding a new platform, yet. we can also discuss contract work to add C3 support, reach out to me personally if interested. |
Thank you! I'll start taking a look at this - it will be good to get a better understanding of how MGOS and the ESP-IDF fit together. |
I've started working on the mos tool to get it flashing the device. The eFuse structure is different, so efuses.go needs to be different. I guess this means defining an entirely new --platform esp32c3 along with all the necessary bit & pieces? |
yes, i think c3 is a big enough change to warrant a new platform |
Where do I look for information about how the stub_flasher's work? |
code is the documentation :) |
there's also a script i used to build the stubs when working on them: this is dead code right now and needs to be revived. |
i dug up the sources and checked them into the repo - mongoose-os/mos@7ec8632 you can now develop C stub code, then rebuild and test it with a single command. |
How do the mgos docker containers work? I see, for example, that https://hub.docker.com/r/mgos/esp32-build/tags contains what I assume is ESP-IDF v4.2 (with various releases). ESP32-C3 requires ESP-IDF v4.3, but I assume the docker container specifically needs to sets up all the necessary flags/etc. to build for ESP32-C3 (e.g. to use the riscv32-esp-elf-gcc compiler). I haven't worked with Docker (other than using it blindly) so it is a bit of a mystery as to how the build system works. I think I understand it conceptually, but not in an practical way that allows me to configure a new docker container for esp32c3 builds. Maybe the esp32 container is sufficient as long as it has ESP-IDF v4.3? |
cesanta/mongoose-os/#584 is my first step towards this - a docker container for ESP32-C3 builds with the riscv32-elf-gcc compiler. I'm busy working on getting the bootloader stubs compiled - there are some things to resolve around the SPI flash API in the stubs. |
@rojer I'm busy trying to get the bootloader stub (in the mos tool) to compile for ESP32-C3. I think I've made some decent progress but I'm stumbling a bit with regards to the assembler in main(). I've pushed code to duncandrennan/mos@1aefe5b I've worked around the ccount() calls to use the correct assembler for the riscv processor, but I'm not quite sure what is actually happening in main() with regards to the __asm volatile("movi a1, stack_end\n"); - are you able to give me a kick in the right direction? |
assuming you refer to this. so, bootom line is: you need to figure out how stack works on RISC-V and what it takes to relocate it to the location of the |
this is the more correct variant. |
With regards to cesanta/mongoose-os/#584 what are the rom.bin/elf files and where do they come from (or how are they generated)? |
rom.bin is the dump of ROM. |
Espressif offers an ELF format file here, https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/api-guides/core_dump.html#rom-functions-in-backtraces but that .elf file is significantly bigger than the ESP32 rom.elf, and if I convert that to a BIN file with riscv32-esp-elf-objcopy it is 3.5MB versus the 0.5MB of the ESP32 rom.bin |
as i said, don't worry about it for now. |
mongoose-os/mos#70 is the initial draft of the bootloader stub. It compiles, but definitely needs some checking |
I've made progress on getting this to read and write the flash correctly. Reading is working but I've struggled quite a bit with the writing. When I try to write to flash the device stops communicating. I've been able to hard code it to flash some data, but something with regards to the UART ISR for receiving the flash data is going wrong. I've had inconsistent behaviour over recompiles, so we're also double checking the placement in memory and stack requirements. Working on getting this resolved so that we can start working on getting the actual OS code compiled. I haven't had a proper debugging environment set up, so that is the next step for me. Hopefully I can do a PR with something that actually works shortly. |
@rojer Are you able to give me some pointers as to how to debug the bootloader code? I'm not quite sure whether to load the bootloader via gdb and then skip the mos stub loading steps, or let mos load the stub, then try to attach to it from gdb. If you have some guidance, that would be very helpful. Thank you! |
hey Duncan, i plan to work on C3 port myself soon, i'll have a look myself at that point. |
@rojer got the flash reading & writing working on the ESP32-C3's |
yes, and i intend to continue working on the port from here |
A prerequisite for supporting targets other than the original ESP32. #564
Rename `esp32_*` to `esp32xx_*`. cesanta/mongoose-os#564
initial support is done. still TBD: eFuse and flash encryption support |
Wow! Thanks @rojer |
@rojer I tried to build our firmware using this with the "latest" mos and libraries, but it fails complaining that it doens't know about the esp32c3, only
|
Ok, figured out the issue in my particular case was the mongoose-os-libs/i2c library which does not yet support the -C3. I tried adding it, but see there are currently compile issues with the code. |
yeah, that message is about lib compatibility. god point about i2c, it needs to be updated |
Noting the following also need updates (after trying some of our other code and bumping up against them):
|
New RISC-V based wifi SoC called ESP32-C3 was announced https://www.espressif.com/en/news/ESP32_C3
Unlike the Bouffalo Lab MCUs ( #559 ) this might actually be easier to support, since it is expected to be supported by ESP-IDF just like the classic ESP32. Biggest change is that RISC-V toolchain will have to be used rather than Xtensa compiler. But that should not affect the C code too much.
I guess this will be nice match for Mongoose OS. As well as ticket to the RISC-V future for all of us.
https://www.espressif.com/sites/default/files/documentation/esp32-c3_datasheet_en.pdf
The text was updated successfully, but these errors were encountered: