grblHAL/iMXRT1062

Teensy crashes with LITTLEFS

BehemothTheKitten opened this issue · 6 comments

Dear All,

Teensy crashes immediately after booting up when either LITTLEFS_ENABLE or WEBUI_ENABLE is set. The controller becomes inaccessible over USB or Ethernet. I used Arduino 1.8.19 and Teensyduino 1.57 to build grblHAL. Everything seems to work normally when these two plugins are disabled.

Thank you.

Which version? Do the Teensy repeatedly reboot?
It could be due to littlefs failing to mount the drive due to "corrupted" flash.
Can you comment out this line to force a format before mounting?

Some related info in this thread.

Thank you for getting back to me.

It is VER:1.1f.20220914 on a Teensy 4.1 and yes, it does keep keep rebooting every ~10 seconds.

I've been able to replicate the problem on two additional bare Teensy boards, including a brand new one. Forcing a format, as you recommended, does resolve it. In fact, once I have flashed the modified firmware and formatted the file system, I can now use the original code without commenting out the IF statement.

  1. Build unmodified grblHAL 20220914 and upload it to a brand new Teensy.
  2. Teensy keeps rebooting
  3. Comment out the IF statement, build grblHAL, and upload it to Teensy
  4. grblHAL works normally
  5. Build unmodified grblHAL 20220914 and upload it to Teensy.
  6. grblHAL continues to work normally

I've been able to use these steps to "fix" the problem on 3 different boards (2 bare controllers and one installed on T41U5XBB). However, unmodified grblHAL 20220914 refuses to work on a "virgin" Teensy.

Great, I guess it is due to assert statements in the littlefs code that triggers the reset. Cant't remember now if this happened for me as well as I worked with several implementations at the same time - and I had similar problems with the RP2040 driver.

What could be tried is to erase the flash area used for littlefs and see if it still crashes on mount. If not the perhaps a workaround for this is to release the erase code and instruct users to run it before enabling littlefs/webui?

It looks like the fix is permanent and since I'm out of unused Teensy boards, I can no longer replicate the problem. I tried the 15 second reset, which did load the blinky program, but failed to overwrite the region used by littlefs.

Either that or check for a "file system formatted" flag in EEPROM (real or emulated) before attempting to mount the FS - if not set, format littlefs, and then set it. Since I have a deep appreciation of the Dunning-Kruger Effect and absolutely no understanding of your code, I will not bother with a useless pull request.

I will turn off littlefs assertions in the next commit and gamble on an error is returned instead causing a format.

I'll keep this issue open for now, if somebody else experience crashes please report.