8000 esp32: support for native code generation by dpgeorge · Pull Request #5082 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

esp32: support for native code generation #5082

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

Merged
merged 7 commits into from
Oct 5, 2019

Conversation

dpgeorge
Copy link
Member
@dpgeorge dpgeorge commented Sep 9, 2019

This PR adds initial support for native code generation on esp32. This was quite difficult to do because of a few major differences with the esp32 architecture:

  • windowed registers
  • esp32 can only do 32-bit loads from executable memory
  • esp32 uses setjmp for NLR

Native and viper functions work, and the native/viper tests in tests/micropython all pass. But I didn't do thorough testing and I'm sure there are still some bugs here and there.

The code here requires some conditional compilation to switch behaviour for esp8266 vs esp32 when doing native code generation, along with some general clean up.

Also, a new native architecture will need to be defined to distinguish between esp8266 and esp32 in .mpy files.

@maludwig
Copy link

YES YES PLZ, I NEED IT! YES. YOU'RE MY HERO! I APPROVE!

@maludwig
Copy link

So...what happens now? How can I help you get this merged?

@jimmo
Copy link
Member
jimmo commented Sep 20, 2019

@maludwig I think testing is likely to to be the most helpful thing here.

@maludwig
Copy link

@jimmo is there a formal process? I have many ESP32s kicking about, I could try it out and just see if its awesome? And then just write here how awesome it is?

@dpgeorge
Copy link
Member Author

How can I help you get this merged?

There are still some WIP and TODO comments in some of the commits here, so they need to be addressed. But also, yes, feel free to test it and give feedback. There's no formal process (apart from running the test suite), just see if you can crash it :)

@dpgeorge dpgeorge force-pushed the esp32-native-mpy branch 2 times, most recently from 4868f24 to ee10125 Compare October 4, 2019 15:21
@dpgeorge
Copy link
Member Author
dpgeorge commented Oct 4, 2019

I've now finished this off and it should be good to merge. Just needs some final testing that it didn't break esp8266 (or stm32) native code generation.

Such that args/return regs for the parent are different to args/return regs
for child calls.  For an architecture to use this feature it should define
the REG_PARENT_xxx macros before including py/emitnative.c.
To enable this feature the N_NLR_SETJMP macro should be set to 1 before
including py/emitnative.c.
In which case place the native function prelude in a bytes object, linked
from the const_table of that function.  An architecture should define
N_PRELUDE_AS_BYTES_OBJ to 1 before including py/emitnative.c to emit
correct machine code, then enable MICROPY_EMIT_NATIVE_PRELUDE_AS_BYTES_OBJ
so the runtime can correctly handle the prelude being in a bytes object.
Window-specific asm emit functions are added, along with a new macro option
GENERIC_ASM_API_WIN.
Enabled via the configuration MICROPY_EMIT_XTENSAWIN.
Selectable via the command line: -march=xtensawin.
@dpgeorge dpgeorge merged commit 1d21b4e into micropython:master Oct 5, 2019
@dpgeorge
Copy link
Member Author
dpgeorge commented Oct 5, 2019

This was merged!

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

Successfully merging this pull request may close these issues.

3 participants
0