-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Espressif ESP Architecture Support #3471
Comments
by Siwei Xu: Good idea! I have a ESP32 DevKitC board, and I also want to porting zephyr to it. |
by Siwei Xu: BTW, support for ESP8266 is also a good idea I think. |
by Robert Beatty: Siwei Xu , added GH-3500 for ESP8266. I'd like to see ESP32 in v1.9. |
by Linh Nguyen: I'd like to see ESP family soon also. I will try to provide some code. Hopefully. Thanks. |
by Siwei Xu: Leandro Pereira , There are already has xtensa-toolchain under the zephyr SDK, but I don't sure it's fully support ESP32/ESP8266 SoC. So, should we need to add the espressif released toolchain to zephyr SDK ? |
by Robert Beatty: Current Xtensa-toolchain does not fully support ESP32/ESP8266. When talking with Cadence, they pointed us to Espressif's open source toolchain and suggested that we look into those tools. |
by Siwei Xu: Leandro Pereira , I compared xtensa context related code under zephyr and esp-idf(espressif released SDK). I found some differences that, esp-idf's xtensa context implemented as multi-processor supported. and from the esp32 technical reference manual, we know that esp32 has dual CPU cores and a series of CPU specific interrupts. so I think we can not use the existed xtensa code under arch/xtensa for esp32 directly. |
by Leandro Pereira: We were able to build Zephyr using the Espressif SDK, and we're working on getting Zephyr to boot using it. |
by Robert Beatty: Leandro Pereira Awesome job. Great progress. |
by Siwei Xu: good job! |
by Ivan Grokhotkov: Hi all, we (Espressif) are going to run the current code and see if we can help with the bringup of Zephyr on ESP32. Seeing that SMP is not supported in Zephyr yet, we could possibly stick with the single-core version of context switching code. That would allow, for example, to run Zephyr on one core, and the low-level (non-opensource) part of our WiFi stack on the other one. |
by Anas Nashif: Ivan Grokhotkov Thank you for commenting here. We are planning to use the ESP-32 for enabling SMP support in Zephyr once we have the basic architecture support and the board booting our kernel. |
by Robert Beatty: Ivan Grokhotkov , Good to see Espressif here. Leandro Pereira and Rajavardhan Gundi have been investigating ESP32 support--be great to get in touch with them. |
by Leandro Pereira: Ivan Grokhotkov , there's an [experimental branch on my GitHub|https://github.com/lpereira/zephyr/tree/esp32-hack]. It builds Zephyr with Espressif's toolchain and relies on some things from esp-idf. It almost boots, but crashes right after jumping into Zephyr's kernel entry point (_Cstart). Some guidance or insight to have a basic version running on this board would be appreciated. |
by Ivan Grokhotkov: Leandro Pereira Thanks for pointing to your experimental branch. I had some progress with it today. First, a few notes about the startup flow on the ESP32. At reset, ESP32 starts executing from _ResetVector located in ROM code (at 0x40000400). Execution proceeds to the ROM startup code, where depending on the state of the bootstrapping pins, either the application is loaded from flash, or the bootloader enters UART "download mode". This download mode allows the host to program new application into the flash memory over UART, and is the usual way of loading programs into the ESP32. You may find the description of the startup flow here: If you use gdb to load program into RAM, you need to consider what initialization steps have been performed by the ROM code and which still need to be performed by the program. If the ROM code has not run at all, i.e. you have done (in gdb)
then _ResetVector has not had a chance to run yet, so some initialization has not been performed yet. This could be fixed by setting $pc=_ResetVector, but for some reason the generated elf file doesn't include the reset vector... although it does include other vectors. Because _ResetVector was not available in the generated elf file, I tried doing the initialization another way — let the ROM code do all the initialization, then perform a break, load Zephyr into RAM, and set PC to _start. In other words,
This almost works, the only remaining problem is that the VECBASE still points to 0x40000000 (i.e. vectors in ROM). As a quick hack I have modified arch/xtensa/core/crt1.S a bit, and added
before the "CALL _Cstart". With this change, the program doesn't crash, and if I break it after some time, the PC is in k_cpu_idle, which sounds reasonable. Now, obviously the above procedure is very much a hack and we should consider something different, going forward. For the initial tests, when the program is loaded via gdb into RAM, I suggest adding _ResetVector into the generated elf file, and marking it as the entry point. Eventually, once we start running code from flash (which is needed for any non-trivial program), we will have to let the ROM bootloader perform initialization. We also need to generate the binary in the format which ESP32's ROM bootloader can recognize. We have a python tool which does that (https://github.com/espressif/esptool), but I don't know enough about Zephyr yet to understand what is the right way to integrate such vendor tools into the build process. |
by Ivan Grokhotkov: Another note: I see that the current tree is introducing a SoC called "LX6" and a board called "esp32". |
by Anas Nashif:
Agree on that. In xtensa things are different from other architectures. |
by Paul Sokolovsky: How it's different? Xtensa LX6 is conceptually about the same notion as ARM Cortex-M0, well, maybe Cortex-M0+. Nothing's new under the sun ;-). |
by Anas Nashif:
For starters... https://ip.cadence.com/ipportfolio/tensilica-ip/xtensa-customizable |
by Steve Williams: LX6 is a processor generator platform, each processor is customized by the SoC developer. LX6 spans ARM Cortex M0 to R4/5 in capability, depending on caches and local memories and pipeline configuration. There are also DSP instruction set modules for imaging, audio, radar, neural net, and vector floating point, plus users can add their own instructions and customer register sets and datatypes. Anyway that's enough marketing. The point is that "LX6" can mean a lot of different things, the name "LX6" is not a unique identifier, best not to use it in SoC or Board naming. ESP32 is an IC with processors and I/Os inside, wouldn't that make it an SoC System on Chip? Boards made using the SoC have other names. I have one called "Feather HUZZAH" from Adafruit. ESP32 . |
by Paul Sokolovsky: Anas Nashif
Nice marketing read, so what? Every CPU architecture is "customizable", but it's usually a headache to manage and support those "customizations", the more kudos goes to Tensilica for marketizing the opposite and to Cadence for not killing off the idea. But back to Zephyr. It has support for x86, ARC, ARM, Nios, RISC-V, and suddenly... Xtensa... is... different? Umm, maybe no. In Linux, ARM arch was "different" for a long time: https://www.gadgetdaily.xyz/linus-torvalds-threatens-to-cut-off-arm/ . Hope Xtensa won't take that place in Zephyr ;-). |
by Anas Nashif: Paul Sokolovsky In Zephyr Cortex-M0+ is not defined as an SoC, cortex-m0+ is a core that is part of an SoC that is vendor specific, an SoC in Zephyr is part of a SoC series that is part of an SoC family, so ESP32 fits just find as an SoC under the LX6 family or if LX6 is the core, an SoC with LX6 core. Not sure what issue exactly. This is just the same thing we have it for all other architectures unless I am missing something. I guess the way things are done with Xtensa are slightly different and that is completely fine, we should be able to fit this in Zephyr. There is no expectation that all architectures be the same in how things are organised or structured. X86 is different, so is ARC. |
by Leandro Pereira: Could someone (maybe Robert Beatty ?) please clarify what "Latest Zephyr boots and is fully functional" (from the acceptance criteria) actually means in terms of hardware support? This will help me prioritize the driver implementation. |
by Robert Beatty: Leandro Pereira , Discussed today with Christopher Turner . We are going to add in driver-related stories to flesh this out better. These will help define the epic in terms of functionality and prioritization. |
What about Bluetooth? |
Bluetooth and WiFi are on the roadmap, yes, but the hardware isn't documented publicly (and it's very unlikely it'll ever be; there are some reverse engineering efforts for ESP8266 but not much for ESP32 last time I checked). Espressif provides a binary blob to support them but they're heavily tied into FreeRTOS; it's possible to provide some shims implementing some FreeRTOS structs and functions on top of primitives Zephyr offers, but we would still need support for flash cache because their binary stacks are quite big. Also, their Bluetooth blob is a complete Bluetooth stack; we have our own, as we talk directly to the radio. We would need some cooperation with them in order to implement this properly in Zephyr. So far, there has been no pressure to actually implement support for these radios in Zephyr, but I heard from Espressif engineers that they're working on an operating system agnostic stack for the radio devices. |
I contacted Espressif support about it, they told me:
So it sounds to me like they might be willing to help? |
Please share the branch that supports esp32 ..the tag number or something .the one in the zephyr website is Brocken or something |
@BOBRAPHTONE ESP32 is supported on the master branch. Building it requires the SDK and toolchain provided by Espressif; please refer to the board documentation for specific steps to install and set them up. Also, keep note that not all peripherals are supported yet; the port isn't very mature. |
collection bug, no need for that as the other features are being dealt with individually. |
Reported by Robert Beatty:
As a developer I would like to be able to develop using ESP32 chips so that Zephyr can be run on LX6 CPUs.
ESP32 is a dual-core system with two Harvard Architecture Xtensa LX6 CPUs from Espressif
+Acceptance Criteria+
(Imported from Jira ZEP-2030)
The text was updated successfully, but these errors were encountered: