I am integrating the FlasherX code into my own project to be able to flash over CANbus.
For a small blinker application, this works reliably, but in my final application weird things start to happen.
As test, I try to flash the blinker firmware when the larger application is running. After the new firmware is transferred into the buffer, flash_move() is called and the Teensy seems to hang. Serial connection is dropped within platformio monitor, and the builtin LED is dim (inbetween on and off). Pressing the program button makes the red LED blink extremely fast (almost dim).
On top of that, I cannot reprogram the Teensy until restoring to the built-in example, left it a few minutes without power *and* rebooted the host pc. Otherwise it is not detected by TeensyLoader.
To track the issue, I have added crude print statements inside flash_move(). Basically, inside FlashTxx.c I have:
Eventually, flash_move() seems to stop with these messages:
It is clearly related to the larger firmware that is hosting the FlasherX code, since a minimal example works. Why does it hang on that address? Is there something else I can test?
Edit: another time it went up to "eepromemu_flash_erase_sector addr = 6003F000". So it's not specific to that address.
For a small blinker application, this works reliably, but in my final application weird things start to happen.
As test, I try to flash the blinker firmware when the larger application is running. After the new firmware is transferred into the buffer, flash_move() is called and the Teensy seems to hang. Serial connection is dropped within platformio monitor, and the builtin LED is dim (inbetween on and off). Pressing the program button makes the red LED blink extremely fast (almost dim).
On top of that, I cannot reprogram the Teensy until restoring to the built-in example, left it a few minutes without power *and* rebooted the host pc. Otherwise it is not detected by TeensyLoader.
To track the issue, I have added crude print statements inside flash_move(). Basically, inside FlashTxx.c I have:
C:
// move is complete. if the source buffer (src) is in FLASH, erase the buffer
// by erasing all sectors from top of new program to bottom of FLASH_RESERVE,
// which leaves FLASH in same state as if code was loaded using TeensyDuino.
// For KINETIS, this erase cannot include FSEC, so erase uses aFSEC=0.
if (IN_FLASH(src)) {
sSerialPrint("2 ");
while (offset < (FLASH_SIZE - FLASH_RESERVE) && error == 0) {
addr = dst + offset;
if ((addr & (FLASH_SECTOR_SIZE - 1)) == 0) {
if (flash_sector_not_erased( addr )) {
#if defined(__IMXRT1062__)
sSerialPrint("eepromemu_flash_erase_sector addr = ");
sSerialPrintNb(addr);
sSerialPrint("\n");
eepromemu_flash_erase_sector( (void*)addr );
#else
error |= flash_erase_s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3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 eepromemu_flash_erase_sector addr = 6003E000
It is clearly related to the larger firmware that is hosting the FlasherX code, since a minimal example works. Why does it hang on that address? Is there something else I can test?
Edit: another time it went up to "eepromemu_flash_erase_sector addr = 6003F000". So it's not specific to that address.
Last edited: