Skip to content

esp32: support for native code generation - #5082

Merged
dpgeorge merged 7 commits into
micropython:masterfrom
dpgeorge:esp32-native-mpy
Oct 5, 2019
Merged

dpgeorge merged 7 commits into
micropython:masterfrom
dpgeorge:esp32-native-mpy

Conversation

@dpgeorge

@dpgeorge dpgeorge commented Sep 9, 2019

Copy link
Copy Markdown
Member

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
Copy Markdown

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

@maludwig

Copy link
Copy Markdown

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

@jimmo

jimmo commented Sep 20, 2019

Copy link
Copy Markdown
Member

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

@maludwig

Copy link
Copy Markdown

@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
Copy Markdown
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

dpgeorge commented Oct 4, 2019

Copy link
Copy Markdown
Member Author

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

dpgeorge commented Oct 5, 2019

Copy link
Copy Markdown
Member Author

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