[TM4C123] Assertion failed
Re: [TM4C123] Assertion failed
Is your compiler producing 64-bit code?
Sent from my iPhone using Tapatalk Pro
Sent from my iPhone using Tapatalk Pro
Re: [TM4C123] Assertion failed
Update: after insterting the changes into version 1.9.4 it looks like this:
and then the controller had a hard fault and stopped
Code: Select all
MicroPython v1.9.4-1-gea2acac46 on 2018-12-16; Tiva Launch Pad with TM4C123G6HPM
>>> a = 5
>>> a = 5
>>> a = 5
>>> a = 5
>>> a = 5
>>> a = 5
>>> a = 5
>>> a = 5
>>> a = 5
>>> a = 5
>>> a = 5
>>> a = 5
>>> a = 5
>>> a = 5
GC: total: 1984, used: 960, free: 1024
No. of 1-blocks: 3, 2-blocks: 4, max blk sz: 32, max free sz: 42
>>> a = 5
>>> a = 5
>>> a = 5
>>> a = 5
>>> a = 5
>>> a = 5
>>> a = 5
>>> a = 5
>>> a = 5
>>> a = 5
>>> a = 5
>>> a = 5
>>> a = 5
My fork/port: https://github.com/rk-exxec/micropython ... ts/tm4c123
Re: [TM4C123] Assertion failed
I don't know
My compiler options are:
Code: Select all
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mabi=aapcs-linux -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fsingle-precision-constant -Wdouble-promotion
CFLAGS = $(INC) -Wall -Werror -std=c99 -nostdlib $(CFLAGS_CORTEX_M4) $(COPT)
My fork/port: https://github.com/rk-exxec/micropython ... ts/tm4c123
Re: [TM4C123] Assertion failed
And I just noticed, that my gc_collect() function is still the basic one from the minimal port.
do I just replace the dummy pointer with something?
Code: Select all
void gc_collect(void) {
// WARNING: This gc_collect implementation doesn't try to get root
// pointers from CPU registers, and thus may function incorrectly.
void *dummy;
gc_collect_start();
gc_collect_root(&dummy, ((mp_uint_t)stack_top - (mp_uint_t)&dummy) / sizeof(mp_uint_t));
gc_collect_end();
gc_dump_info();
}
My fork/port: https://github.com/rk-exxec/micropython ... ts/tm4c123
Re: [TM4C123] Assertion failed
I always look at the stm32 port functions to decide what to do.
The intention is to look thru the active portion of the stack, which for most ports goes from the stack pointer to the end of RAM.
Note that the stm32 code stores the current registers into the stack:
https://github.com/micropython/micropyt ... lect.c#L48
which means that the contents of the registers are also scanned as a side-effect of that. The gc_helper_get_regs_and_sp function can be found in the gchelper.s
The TM4C123 is a Cortex-M4 which is the same as the STM32F4 series so you should be able to use the gchelper.s file as-is.
The intention is to look thru the active portion of the stack, which for most ports goes from the stack pointer to the end of RAM.
Note that the stm32 code stores the current registers into the stack:
https://github.com/micropython/micropyt ... lect.c#L48
which means that the contents of the registers are also scanned as a side-effect of that. The gc_helper_get_regs_and_sp function can be found in the gchelper.s
The TM4C123 is a Cortex-M4 which is the same as the STM32F4 series so you should be able to use the gchelper.s file as-is.
Re: [TM4C123] Assertion failed
Thank you for the advice.
I added the assembly source to my project, now I have a problem with this line:
It says, that _ram_end is not defined.
Do I replace that with the last address of ram ( 0x2000.7FFF ) or the address following that one (0x2000.8000) or something different?
(RAM: 0x2000.0000 - 0x2000.7FFF)
Like this:
EDIT:
I tired 0x20008000 as replacement and it doesn't immedeately crash so i guess thats good.
It looks like the GC runs once and the second time it crashes before entering the gc_collect function.
I added the assembly source to my project, now I have a problem with this line:
Code: Select all
gc_collect_root((void**)sp, ((uint32_t)&_ram_end - sp) / sizeof(uint32_t));
Do I replace that with the last address of ram ( 0x2000.7FFF ) or the address following that one (0x2000.8000) or something different?
(RAM: 0x2000.0000 - 0x2000.7FFF)
Like this:
Code: Select all
gc_collect_root((void**)sp, ((uint32_t)0x20007FFF - sp) / sizeof(uint32_t));
I tired 0x20008000 as replacement and it doesn't immedeately crash so i guess thats good.
It looks like the GC runs once and the second time it crashes before entering the gc_collect function.
My fork/port: https://github.com/rk-exxec/micropython ... ts/tm4c123
Re: [TM4C123] Assertion failed
That’s wrong.
You need to use MP_STATE_THREAD(stack_top) like in ports/stm32/gccollect.c
But to do that, you must call mp_stack_ctrl_init() before you run any micropython functions.
Sent from my iPhone using Tapatalk Pro
You need to use MP_STATE_THREAD(stack_top) like in ports/stm32/gccollect.c
But to do that, you must call mp_stack_ctrl_init() before you run any micropython functions.
Sent from my iPhone using Tapatalk Pro
Re: [TM4C123] Assertion failed
I added the mp_stack_ctrl_init() call to my main and defined _ram_end and other missing constants in the linker file and now it seems to work
in my main():
in the gccollect.c:
I didn't change the call of gc_collect_root, because I have not implemented the thread module, and it doesn't seem to impact the functionality.
Thanks for your help, I very much appreciate it
in my main():
Code: Select all
mp_stack_ctrl_init();
mp_stack_set_top(&__StackTop);
//mp_stack_set_limit((char*)&_estack - (char*)&_heap_end - 1024);
#if MICROPY_ENABLE_GC
gc_init(&_heap_start, &_heap_end);
#endif
Code: Select all
gc_collect_root((void**)sp, ((uint32_t)&_ram_end - sp) / sizeof(uint32_t));
Thanks for your help, I very much appreciate it
My fork/port: https://github.com/rk-exxec/micropython ... ts/tm4c123