Hi,
I'm trying to port MicroPython to PIC24 (PIC24FJ1024GB606), a 16-bit micro from Microchip.
I'm using MicroPython version 1.9.2, the same version used for MicroBit.
Compiler: XC16 v1.35
The experiment project compiles and run the REPL on UART.
Here's some brief result:
Very simple math works like:
>>> 1+1
2
>>> 24*34
816
Others fails:
>>> 256*256
assertion "emit->stack_size == 0" failed: file "source/py/emitbc.c", line 406, function: mp_emit_bc_end_pass
>>> a=1
assertion "exc_sp == exc_stack - 1" failed: file "source/py/vm.c", line 1095, function: mp_execute_bytecode
>>> dir()
assertion "tok == MP_TOKEN_ELLIPSIS" failed: file "source/py/emitbc.c", line 525, function: mp_emit_bc_load_const_tok
Can anyone kindly tell me what I'm missing?
[PIC24]REPL error of assertion"emit->stack_zise == 0"
Re: [PIC24]REPL error of assertion"emit->stack_zise == 0"
Hi,
Are you using the existing pic16bit port in the main codebase? i.e. https://github.com/micropython/micropyt ... s/pic16bit
Any particular reason to use 1.9.2 rather than the latest release (1.11) or master?
The difference between the two is that the first example works entirely using small ints (i.e. the inline representation in mp_obj_t) where the second needs to allocate an object. I'm guessing that something's going wrong leading to something like stack corruption.
Re: [PIC24]REPL error of assertion"emit->stack_zise == 0"
Hi Jimmo,
Thank you for the reply.
This afternoon I just tried the latest version (1.11.0) from https://github.com/micropython/micropyt ... s/pic16bit
It compiled as well and gave me the same result. The REPL works on UART and small number math works.
The errors for the others are the same.
I did not use the Makefile from here(https://github.com/micropython/micropyt ... t/Makefile).
Instead I used MPLAB X IDE and created a new project and it generated its own Makefile
I did take care of all of the compiler (XC16 v1.35) flags like: -std=gnu99 -mlarge-code -nostdlib, otherwise it won't compile.
In the project I included the whole "py" folder and
a few necessary "lib" ("mp-readline" and some "utils") and
a few necessary extmod(virtpin.h and virtpin.c, utime_mphal.h and utime_mphal.c)
It compiles with a few warnings and the generated hex file works.
I uploaded the zipped project files to here: https://github.com/jacklinquan/PIC24FJ1024GB606_test2
To open it, MPLAB X IDE v5.10 or above is needed. XC16 v1.35 is needed.
Thank you for the reply.
This afternoon I just tried the latest version (1.11.0) from https://github.com/micropython/micropyt ... s/pic16bit
It compiled as well and gave me the same result. The REPL works on UART and small number math works.
The errors for the others are the same.
I did not use the Makefile from here(https://github.com/micropython/micropyt ... t/Makefile).
Instead I used MPLAB X IDE and created a new project and it generated its own Makefile
I did take care of all of the compiler (XC16 v1.35) flags like: -std=gnu99 -mlarge-code -nostdlib, otherwise it won't compile.
In the project I included the whole "py" folder and
a few necessary "lib" ("mp-readline" and some "utils") and
a few necessary extmod(virtpin.h and virtpin.c, utime_mphal.h and utime_mphal.c)
It compiles with a few warnings and the generated hex file works.
I uploaded the zipped project files to here: https://github.com/jacklinquan/PIC24FJ1024GB606_test2
To open it, MPLAB X IDE v5.10 or above is needed. XC16 v1.35 is needed.
Re: [PIC24]REPL error of assertion"emit->stack_zise == 0"
@jimmo
@Damien
I've confirmed my findings with the micropython port for pic16 from https://github.com/micropython/micropyt ... s/pic16bit
I built this port with PIC24FJ1024GB606 and the same Makefile(the path of XC16 changed).
You can find it here: https://github.com/jacklinquan/micropyt ... j1024gb606
Here's some brief test result:
When NDEBUG is defined in the Makefile:
##################
>>> 1+1
2
>>> a=1
>>> a
1
>>> b=2
>>> c=a+b
>>> c
Traceback (most recent call last):
File "<stdin>", in <module>
NameError: name not defined
>>> 256*256
Traceback (most recent call last):
File "<stdin>", in <module>
TypeError: unsupported type for operator
>>> 25*25
625
##################
When NDEBUG is NOT defined in the Makefile:
##################
>>> 1+1
2
>>> a=1
assertion "exc_sp == exc_stack - 1" failed: file "../../py/vm.c", line 1143, function: mp_execute_bytecode
MicroPython v1.11 on 2019-10-03; EXPERIMENT with PIC24FJ1024GB606 (Note: It rebooted here.)
>>> 25*25
625
>>> 256*256
assertion "emit->stack_size == 0" failed: file "../../py/emitbc.c", line 426, function: mp_emit_bc_end_pass
MicroPython v1.11 on 2019-10-03; EXPERIMENT with PIC24FJ1024GB606 (Note: It rebooted here.)
>>> dir
<function>
>>> dir()
assertion "emit->stack_size == 0" failed: file "../../py/emitbc.c", line 426, function: mp_emit_bc_end_pass
MicroPython v1.11 on 2019-10-03; EXPERIMENT with PIC24FJ1024GB606 (Note: It rebooted here.)
>>> int
<class 'int'>
>>> int('1')
assertion "emit->stack_size == 0" failed: file "../../py/emitbc.c", line 426, function: mp_emit_bc_end_pass
MicroPython v1.11 on 2019-10-03; EXPERIMENT with PIC24FJ1024GB606 (Note: It rebooted here.)
>>> s='hello'
assertion "exc_sp == exc_stack - 1" failed: file "../../py/vm.c", line 1143, function: mp_execute_bytecode
MicroPython v1.11 on 2019-10-03; EXPERIMENT with PIC24FJ1024GB606 (Note: It rebooted here.)
>>> l=[1,2,3]
assertion "emit->stack_size == 0" failed: file "../../py/emitbc.c", line 426, function: mp_emit_bc_end_pass
MicroPython v1.11 on 2019-10-03; EXPERIMENT with PIC24FJ1024GB606 (Note: It rebooted here.)
##################
For the moment I just have PIC24FJ1024GB606 at hand. Could you confirm my findings with your boards?
It looks like the port for pic16bit is broken.
I'm opening an issue on github.
Thanks!
@Damien
I've confirmed my findings with the micropython port for pic16 from https://github.com/micropython/micropyt ... s/pic16bit
I built this port with PIC24FJ1024GB606 and the same Makefile(the path of XC16 changed).
You can find it here: https://github.com/jacklinquan/micropyt ... j1024gb606
Here's some brief test result:
When NDEBUG is defined in the Makefile:
##################
>>> 1+1
2
>>> a=1
>>> a
1
>>> b=2
>>> c=a+b
>>> c
Traceback (most recent call last):
File "<stdin>", in <module>
NameError: name not defined
>>> 256*256
Traceback (most recent call last):
File "<stdin>", in <module>
TypeError: unsupported type for operator
>>> 25*25
625
##################
When NDEBUG is NOT defined in the Makefile:
##################
>>> 1+1
2
>>> a=1
assertion "exc_sp == exc_stack - 1" failed: file "../../py/vm.c", line 1143, function: mp_execute_bytecode
MicroPython v1.11 on 2019-10-03; EXPERIMENT with PIC24FJ1024GB606 (Note: It rebooted here.)
>>> 25*25
625
>>> 256*256
assertion "emit->stack_size == 0" failed: file "../../py/emitbc.c", line 426, function: mp_emit_bc_end_pass
MicroPython v1.11 on 2019-10-03; EXPERIMENT with PIC24FJ1024GB606 (Note: It rebooted here.)
>>> dir
<function>
>>> dir()
assertion "emit->stack_size == 0" failed: file "../../py/emitbc.c", line 426, function: mp_emit_bc_end_pass
MicroPython v1.11 on 2019-10-03; EXPERIMENT with PIC24FJ1024GB606 (Note: It rebooted here.)
>>> int
<class 'int'>
>>> int('1')
assertion "emit->stack_size == 0" failed: file "../../py/emitbc.c", line 426, function: mp_emit_bc_end_pass
MicroPython v1.11 on 2019-10-03; EXPERIMENT with PIC24FJ1024GB606 (Note: It rebooted here.)
>>> s='hello'
assertion "exc_sp == exc_stack - 1" failed: file "../../py/vm.c", line 1143, function: mp_execute_bytecode
MicroPython v1.11 on 2019-10-03; EXPERIMENT with PIC24FJ1024GB606 (Note: It rebooted here.)
>>> l=[1,2,3]
assertion "emit->stack_size == 0" failed: file "../../py/emitbc.c", line 426, function: mp_emit_bc_end_pass
MicroPython v1.11 on 2019-10-03; EXPERIMENT with PIC24FJ1024GB606 (Note: It rebooted here.)
##################
For the moment I just have PIC24FJ1024GB606 at hand. Could you confirm my findings with your boards?
It looks like the port for pic16bit is broken.
I'm opening an issue on github.
Thanks!