-
Notifications
You must be signed in to change notification settings - Fork 991
Add support for the ESP8266 #900
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
Conversation
While this obviously doesn't work with the current builds, I think it would be nice to merge this. It allows interested people to experiment with this chip. Afterwards, we may want to switch to the Espressif fork of LLVM (forked to the TinyGo org to be sure) so that this chip is fully supported in release builds. |
Got a bunch of excess 8266 around. It would be nice to try it, so +1 to this PR. |
Interested to test it out, gj @aykevl |
For those wanting to try this out, the following steps should work (on macOS and Linux, also on Windows inside WSL). Mostly untested.
|
So I understand that we still need esptool for the flashing part. |
Correct.
No. This branch only works when built with LLVM from Espressif. Therefore it won't work for release builds yet. Line 134 in 1d913a6
What do you think? Stick to upstream and require manually building LLVM, or switch to the Espressif fork? |
Not sure we want to be completely dependent on the espressif fork of llvm. Perhaps we could have our own build process for a separate espressif specific tinygo release build with the espressif fork of lvvm, until their changes get upstreamed. What do you think? Just seems like it is better to stay close to the mainline LLVM. |
Yes, because you're comparing against master (the development tree). This is the actual diff: llvm/llvm-project@release/9.x...espressif:xtensa_release_9.0.1 EDIT: I checked and their branch is fully rebased on top of the 9.x release branch.
That is possible... but I don't really like that either. We currently have 6 binary releases for 3 OSes. Having special Xtensa releases would multiply that by 2, leading to 12 build artifacts (or fewer, but then not everyone has a prebuild binary).
Yeah I agree, I don't really want to use a fork either. But their fork seems relatively clean and we might be able to rebase that on top of LLVM 10 once it gets released (effectively making a third fork ourself). What about this: we switch to the Espressif fork now, but if it slows TinyGo down (Espressif doesn't update and we can't trivially rebase) then we switch back to upstream LLVM 10. If that happens, we can tell people that want to use the ESP chips to use an older TinyGo release and request Espressif to update their fork. |
That is an encouraging sign. Since we do not require LLVM install for our own release build, seems like your points about being able to switch back if needed are legit. And we all really want this functionality. So now I am more in favor of merging this. Anyone else have an opinion? |
+1 |
+1 Am really anxious to see this moved into release so we can push go on this beautiful little wifi devices! |
+1 for merge |
They do not seem to have rebased on LLVM 10, so I don't think we can switch over to espressif's LLVM yet. espressif/llvm-project#18 |
No, I was hoping that they'd quickly provide an updated fork, which would have allowed people willing to put in the effort to use the ESP8266 with TinyGo. Right now, that seems unlikely. And with all the work I've put in AVR support (to be included in LLVM 11) I would like to switch over quickly once it is released, further reducing the chance of having proper ESP8266 support. |
I've rebased the Xtensa fork on LLVM 10, pushed it to a new I've converted this to a draft because I want to use the SVD files produced by the esp-rs project to share work. Right now it manually defines all registers, which is of course a lot of work to maintain. |
Updated to use the SVD file created by the esp-rs project. It depends on one patch to the SVD file: MabezDev/idf2svd#17 Next steps:
Afterwards, adding support for the esp32 should be very similar, with most of the work already done. |
Update: first patch got merged, now I have another patch to update the base SVD file: esp-rs/esp8266#2 |
Reported two issues with the LLVM 10 branch of Xtensa to Espressif: espressif/llvm-project#33 Both are required for full Xtensa support, although simple stuff (blinking LED etc) would be possible without it. |
Also see: cmsis-svd/cmsis-svd#110 I have a local branch that adds ESP32 support, perhaps it's better to get that up and running first as there seems to be more interest in the ESP32 than in the ESP8266. Also, the ESP32 is much more powerful. |
Here is a PR for ESP32 support: #1289 |
This PR is almost ready, it depends on cmsis-svd/cmsis-svd#112. |
This is now ready for review (if all CI tests pass). I have chosen to use the same linker as is used for the ESP32 ( |
Many thanks to cnlohr for the nosdk8266 project: https://github.com/cnlohr/nosdk8266
Wow, congratulations @aykevl this is a real achievement, so many months in the making. Now merging with great pleasure! |
I need to add, you can flash a board with a command like the following:
|
To use this, use LLVM with Xtensa support:
https://github.com/espressif/llvm-project
Make sure you modify the CMake command (in the Makefile) to include the Xtensa backend:
You will also need to install the esp8266 GCC toolchain for the
xtensa-lx106-elf-ld
linker (lld doesn't yet support Xtensa).I have used a NodeMCU dev board (clone?) to test this PR. Unfortunately, you can't yet flash it directly using
tinygo flash
, instead you have to use someesptool.py
commands:Many thanks to @cnlohr for the nosdk8266 project. That project helped me a lot to put together this minimal PR that avoids the SDK entirely.