ARMv8/AArch64

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
Tetraeder
Posts: 53
Joined: Thu Mar 05, 2015 1:12 pm
Location: Germany

ARMv8/AArch64

Post by Tetraeder » Wed Dec 20, 2017 7:54 pm

Hi,
I tried to port the "minimal" to AArch64 but the repl does not work properly.
I get the access to the REPL ">>>" but if I type a simple "print", the controller executes his whole ARMv8 register and get stucked
But if I enter the Paste-Mode and paste some lines, it works fine. If the lines increase it prints also the ARMv8 register and get stucked.

Is there a define to switch to 64bit?
or is the reason because the memory allocation of GC?

Thanks in advance!

jickster
Posts: 519
Joined: Thu Sep 07, 2017 8:57 pm

Re: ARMv8/AArch64

Post by jickster » Sat Dec 23, 2017 5:06 am

Tetraeder wrote:
Wed Dec 20, 2017 7:54 pm
Hi,
I tried to port the "minimal" to AArch64 but the repl does not work properly.
I get the access to the REPL ">>>" but if I type a simple "print", the controller executes his whole ARMv8 register and get stucked
But if I enter the Paste-Mode and paste some lines, it works fine. If the lines increase it prints also the ARMv8 register and get stucked.

Is there a define to switch to 64bit?
or is the reason because the memory allocation of GC?

Thanks in advance!

1. Turn off garbage collection and test again. The macro is MICROPY_ENABLE_GC. You will eventually run out of heap but at least you will eliminate that as a potential issue.
2. What happens if you test with correct expressions?
a = 3
b = a * 4
3. When you simply type “print” I think you may be triggering the Micro python error and exception handling mechanism which currently does not support ARM V8 unless you configure the build to use setjmp.h ( which you have to supply). Details are below:

This is the file that has assembly code which is architecture specific; This code is used for exceptions.
https://github.com/micropython/micropyt ... nlrthumb.c


Referencing the list of macros for architectures listed here
https://www.keil.com/pack/doc/CMSIS/Cor ... 6545ce59aa

You can see that technically there is no explicit support for armv8 so You need to supply the header file setjmp.h and set MICROPY_NLR_SETJMP 1 (see nlr.h) OR you need to supply your own implementation for nlr_push() and nlr_pop().

4. Can you please rephrase this? I am not sure exactly what you meant to say
the controller executes his whole ARMv8 register

Tetraeder
Posts: 53
Joined: Thu Mar 05, 2015 1:12 pm
Location: Germany

Re: ARMv8/AArch64

Post by Tetraeder » Wed Jan 03, 2018 4:54 pm

Hi jickster,

* I used the uPy version 1.9.3.

1. MICROPY_ENABLE_GC -> off: same problem and the controller get stucked in "mp_init()". Even no REPL start.

2. Same problem.
repl.png
repl.png (49.63 KiB) Viewed 718 times
3. Sorry, wrong statement. I wrote a simple "print("hello"):

Code: Select all

print("hello")
but it works in Paste-Mode:
paste_mode.png
paste_mode.png (42.19 KiB) Viewed 718 times
Thanks for the information about nlr_push and nlr_pop. Is will not work if I change the registers names to ARMv8 syntax, right? :)
For example AArch64 Register X0 instead of R0 of AArch32.
I've found some information to port AArch32 to AArch64 -> here http://infocenter.arm.com/help/index.js ... EGDHF.html
I keep trying....

4. I meant the ARM registers X0-X30 and special registers. (first picture)

Tetraeder
Posts: 53
Joined: Thu Mar 05, 2015 1:12 pm
Location: Germany

Re: ARMv8/AArch64

Post by Tetraeder » Fri Jan 05, 2018 9:13 am

I solved my problem but I'm not sure why this occures a problem. And if it can lead to further problems! I keep trying....

The REPL get stucked in readline.c https://github.com/micropython/micropyt ... ine.c#L436
At the this string-compare strcmp(MP_STATE_PORT(readline_hist)[0], line)
It works with no array index of readline_hist -> strcmp(MP_STATE_PORT(readline_hist), line)


And I did not write my own implementation of NLR I used -> #define MICROPY_NLR_SETJMP

Tetraeder
Posts: 53
Joined: Thu Mar 05, 2015 1:12 pm
Location: Germany

Re: ARMv8/AArch64

Post by Tetraeder » Fri Jan 05, 2018 3:23 pm

And finally calling "readline_init0" in main.c also solved the issue a post before :D

Tetraeder
Posts: 53
Joined: Thu Mar 05, 2015 1:12 pm
Location: Germany

Re: ARMv8/AArch64

Post by Tetraeder » Fri Jan 12, 2018 2:17 pm

further changes: set function failed "def test():",

solved with: in mpconfigport.h I changed the typedef's

typedef int64_t mp_int_t
typedef uint64_t mp_uint_t;
typedef long long mp_off_t;

and defined "#define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_D)"

Tetraeder
Posts: 53
Joined: Thu Mar 05, 2015 1:12 pm
Location: Germany

Re: ARMv8/AArch64

Post by Tetraeder » Tue Feb 27, 2018 1:29 pm

Update:
I had the problem with executing loops.
The program stucked in /py/vmc.c in MP_BC_JUMP by the macro DECODE_SLABEL.

The ISSUE-3201: https://github.com/micropython/micropython/issues/3201, helps to find the right keyword: unaligned access

AArch64/ARMv8 supports unaligned access out of box but I need opposite.
I used the build flag -mstrict-align, for "unaligned accesses" are forbidden.
Compiler: AArch64 from linaro

maybe also useful, from the ARM-Manual. But not known flags for linaro-gcc:
-munaligned-access
-mno-unaligned-access

Post Reply