Micronucleus (Digispark) support needs update to fix flash erase error -71, -32, etc. on Linux

Can someone repackage the micronucleus tool package with latest upstream, or help me make a PR to do it if that’s something I can help with?

I’ve been experiencing the pervasive micronucleus “flash erase error” -71, -32, etc. (see Digispark gets "Flash erase error -71 has occured" - #5 by Paul3492) with the micronucleus upload method. It looks like for most people this is happening because the flash erase takes long enough for the USB hardware to timeout and disconnect. This problem is described accurately here:

http://digistump.com/board/index.php/topic,464.msg2088.html#msg2088

That workaround in the micronucleus upload tool, which reconnects and retries when it detects a disconnect during flash erase, has existed forever and works properly in the latest upstream source. I suspect the reason I’m seeing this with the PlatformIO package is that more different error codes became associated with the disconnection, and the PlatformIO package is a little out-of-date with respect to upstream (-84 is what’s described in that patch from 2013, but I see -71 and -32 now – -84 might still be returned by libusb but obviously that particular one is handled).

Building latest upstream fixes the problem for me, but the shipped micronucleus binary seems to be modified to take an extra “-c” parameter (I made a wrapper script to strip it out), and I can’t figure out where that patch or any of the package source comes from.

Little help? I want others to be able to benefit from these updates to the uploader. Love PlatformIO.

Can you get that tracked in GitHub - platformio/platform-atmelavr: Atmel AVR: development platform for PlatformIO for the devs?

1 Like

Alright, I made this issue: tool-micronucleus package (Digispark support) needs update to fix "flash erase error" -71, -32, etc. on Linux · Issue #303 · platformio/platform-atmelavr · GitHub
But I discovered in writing that issue that Outdated micronucleus tool (mac) · Issue #101 · platformio/platform-atmelavr · GitHub makes the same request for an update to the tool and has been open since 2018. Actually, that’s a little confusing, because as far as I can tell the source used to build the tool package is dated from 2020? Maybe there are two (upstream) version lines for the micronucleus upload tool being maintained in parallel? I’m confused.

Anyway, is there a way I can self-help here? I know I can override files in a package, but where does the source for the “micronucleus” binary in tool-micronucleus come from? Unless I’m just not finding the right version, the linked upstream repository seems to contain source code which doesn’t correspond to the observed behaviour of the shipped binary (the binary takes a “-c” parameter which isn’t recognized by vanilla upstream). I am hacking it for now, but I’m uncomfortable about just ignoring a parameter I don’t fully understand.