joepasquariello / FlasherX

Over-the-air firmware updates for Teensy LC/3.x/4.x/MicroMod
52 stars 14 forks source link

systick needs to be disabled before calling flash_move? #6

Closed pschoppe closed 11 months ago

pschoppe commented 1 year ago

Hello,

I used FlasherX to implement flashing a Teensy 4.1. via Ethernet. When flashing, I open a new firmware buffer using firmware_buffer_init(), fill it with all the data chunks transferred via Ethernet (using flash_write_block()), then call check_flash_id() and finally flash_move().

This did not work initially and the software just crashed when executing flash_move() and I was left with a non-booting state. I had the CrashReport class active which showed a data access violation from within the systick isr (On the next reboot after re-flashing the old image using the conventional USB TeensyDuino method).

When I disabled the systick isr by setting SYST_CSR = 0 just before calling flash_move() everything worked as expected (maybe takes more time than expected? Directly flashing via TeensyDuino + USB is faster than only the flash_move() call) and the Teensy reboots and runs the new software.

edit: I digged a bit deeper into the issue and it looks like it probably is an issue on my end. I have a custom linker script and by default I put everything into flash. I noticed the systick_isr function is not marked explicitly to be put into RAM. When I change this, flash_move() works without disabling the isr.

joepasquariello commented 11 months ago

Thank you for letting me know you found the issue.