8000 trying to build mpy with dynamic libs for esp32 with xtensa-gcc · Issue #4916 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content
8000

trying to build mpy with dynamic libs for esp32 with xtensa-gcc #4916

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

Closed
eminarcissus opened this issue Jul 10, 2019 · 5 comments
Closed

trying to build mpy with dynamic libs for esp32 with xtensa-gcc #4916

eminarcissus opened this issue Jul 10, 2019 · 5 comments

Comments

@eminarcissus
Copy link

Hi,

I'm trying to adapt micropython dynamic lib for esp32 xtensa specific ports, everything went well except for when I trying to create the modx.elf file.

I'm getting a error like this

modx.o: In function `init':
modx.c:(.mpytext+0x5): dangerous relocation: l32r: literal placed after use: .mpytext.literal
modx.c:(.mpytext+0x24): dangerous relocation: l32r: literal placed after use: (.mpytext.literal+0x4)
modx.c:(.mpytext+0x38): dangerous relocation: l32r: literal placed after use: (.mpytext.literal+0x8)
modx.c:(.mpytext+0x55): dangerous relocation: l32r: literal placed after use: (.mpytext.literal+0xc)
Makefile:52: recipe for target 'modx.elf' failed
make: *** [modx.elf] Error 1

Any hints on what might be the cause of the problem? looks like the error is strongly related to mpextern.ld, if I do remove -T mpextern.ld it links but ofcourse objcopy will create nothing to output here. May I know what's behind the scene to create the mpy file?

@dpgeorge
Copy link
Member

I'm trying to adapt micropython dynamic lib for esp32 xtensa specific ports,

I guess you are referring to #1627 ? That PR is quite dated and pretty much superseded by #4535, which was merged. Eventually (hopefully soon) there will be support to build .mpy files from C code, of which there is a simple example in #4535 (those bits were not merged).

@eminarcissus
Copy link
Author

thx 👍 , just noticed that from PR list, the old version finally builds, and it crashed when imported, I will try this one instead.

@eminarcissus
Copy link
Author
eminarcissus commented Jul 10, 2019

Tried with the latest code, after compile and import native_ex I got "ValueError: incompatible .mpy file", any ways to debug on failures like this?

I've noticed some quite interesting codes in native_ex.c

//'M', 4, 3 | 2 << 2, 31, 32, // x64
//'M', 4, 2 | 5 << 2, 31, 32, // thumb
'M', 4, 2 | 9 << 2, 31, 32, // xtensa

But xtensa looks like using xtensa-l32 which is different with esp32.

Currently I built with xtensa setting and it showed like this

ValueError: incompatible .mpy arch

Looks more likely to be this header's problem?

@robert-hh
Copy link
Contributor

Did you also rebuild mpy-cross?

@eminarcissus
Copy link
Author

yes, I did finally get it built but failed to work.
Building problem seems like esp32 ports doesn't have emit xtensa set to 1 as default.
Also it did came with a lot of problem except for that,
MICROPY_NLR_SETJMP setting seems like have some problem with emitglue.c's nlr_push/nlr_pop.
Also when it compiles and starts, the native_ex module loads but failed to call, which crashes immediately.

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

No branches or pull requests

3 participants
0