-
Notifications
You must be signed in to change notification settings - Fork 909
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
WIP: add initial support for ESP32-S3 #3937
base: release
Are you sure you want to change the base?
Conversation
9b45c6a
to
ebca644
Compare
FYI, the chip sort of works now (I get UART outputs with a simple Go program) :) |
FYI: I talked about the experience of porting TinyGo to the ESP32-S3 today at the Go Meetup @ AWS. |
Hello @denysvitali just looking at this PR thanks for working on it. There have been several changes since it was first created, including that we are now using the official versions of the SVD files in the submodule. You perhaps no longer need that file? Another suggestion would be to put the Hopefully you have some time to make some of these changes, as it would be great to get this into the next version of TinyGo. Thank you! |
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.
Generally looks good to me, just one extra test that's needed and a few code cleanliness comments.
Can you rebase this PR on top of the current dev branch, so we can see how well it works there?
// The following definitions were copied from: | ||
// esp-idf/components/xtensa/include/xtensa/corebits.h | ||
#define PS_WOE_MASK 0x00040000 | ||
#define PS_OWB_MASK 0x00000F01 |
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.
This file is exactly identical to src/device/esp/esp32.S, can you reuse that file but adjust this #define
using a preprocessor macro? Something like:
#ifdef ESP32S3
#define PS_OWB_MASK 0x00000F01
#else
#define PS_OWB_MASK 0x00000F00
#endif
And then you can add it as a define in the "cflags"
key in esp32s3.json ("-DESP32S3"
).
// // Change CPU frequency from 20MHz to 80MHz, by switching from the XTAL to | ||
// // the PLL clock source (see table "CPU Clock Frequency" in the reference | ||
// // manual). | ||
// esp.SYSTEM.SYSCLK_CONF.Set(1 << esp.SYSTEM_SYSCLK_CONF_SOC_CLK_SEL_Pos) | ||
|
||
// // Change CPU frequency from 80MHz to 160MHz by setting SYSTEM_CPUPERIOD_SEL | ||
// // to 1 (see table "CPU Clock Frequency" in the reference manual). | ||
// // Note: we might not want to set SYSTEM_CPU_WAIT_MODE_FORCE_ON to save | ||
// // power. It is set here to keep the default on reset. | ||
// esp.SYSTEM.CPU_PER_CONF.Set(esp.SYSTEM_CPU_PER_CONF_CPU_WAIT_MODE_FORCE_ON | esp.SYSTEM_CPU_PER_CONF_PLL_FREQ_SEL | 1<<esp.SYSTEM_CPU_PER_CONF_CPUPERIOD_SEL_Pos) |
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.
Suggestion: replace this with a TODO instead. There's not much to be gained from having this commented code here: the same code is already present in the runtime support for the esp32c3.
"cpu": "esp32s3", | ||
"features": "+atomctl,+bool,+coprocessor,+debug,+density,+dfpaccel,+div32,+exception,+fp,+highpriinterrupts,+interrupt,+loop,+mac16,+memctl,+miscsr,+mul32,+mul32high,+nsa,+prid,+regprotect,+rvector,+s32c1i,+sext,+threadptr,+timerint,+windowed", |
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.
Please add the esp32s3 to the list in builder/builder_test.go to ensure this list is correct.
These are the first steps towards fixing #3442.
At the moment, the following TinyGo program doesn't print anything to stdout, but at least it seems like the
main
is reached:Here is the full boot log:
I have based my changes on v0.29.0, because I can't run Tinygo with Xtensa and LLVM 16. For whatever reason I get some errors while running
tinygo build
when the target isesp32
(or like in my caseesp32s3
):Much of my work here is copy & paste from the ESP32 code base, with a few adaptations. Hopefully it's a good start for someone else to continue my work :)