[Open_electroporator] Timers, PWM, low-level MCU setup

Nathan McCorkle nmz787 at gmail.com
Sun Mar 12 21:45:12 UTC 2017


So in my hacking last night, I 'bricked' my G30TH based culture-shock
microcontroller. I wrote a special piece of memory, and unexpectedly
it completely stopped responding to the USB as far as appearing like a
storage-drive or serial port.

These were in the output of linux 'dmesg':
usb 1-1.2.3: device descriptor read/64, error -32
usb 1-1.2.3: device not accepting address 37, error -32


So I dug out my G30TH that I ordered last year for getting started
with micropython... and when I wrote the same piece of memory, it too
stopped working!

So I searched around for a while, and then checked my email for
instructions John and I sent to this mailing list. But they didn't
work. Then I realized they were for a different STM32 board, but not
the G30TH based that we are using now. Then I found the instructions
Dave Hylands (dhylands) provided for the G30TH:
http://blog.davehylands.com/2016/07/bringing-up-micropython-on-ghi.html

while that worked /more/ than the wrong instructions, it still didn't
solve my problem.

Then I figured out the issue. Flashing the compiled micropython
firmware while in DFU mode ONLY flashes the firmware area... so my
old, bad program, was still in program memory, and continuing to cause
problems. So I learned the "dfu-utils" command has a command to ERASE
ALL MEMORY. After doing that and flashing micropython, I was back on
both my boards.


So here are my STEPS TO UNBRICK:

connect a wire to 3.3V on G30TH
unplug USB connection, but be ready to plug it in (have it partially socketed)
touch 3.3V wire to pin "B0" (on the opposite side of the G30TH from
the USB connector, and NOT a through-hole)
while keeping the wire touched to "B0", plug in the USB
    * the microcontroller should now be in DFU mode, and you can
release the wire from "B0"

git clone https://github.com/micropython/micropython.git
cd micropython/stmhal/boards
git clone https://github.com/dhylands/G30TH.git
cd ..
make BOARD=G30TH
dfu-util -v -s :mass-erase:force -a 0 -d 0483:df11 -D build-G30TH/firmware.dfu
make BOARD=G30TH deploy



and in case you were using a brand-new G30TH (which comes with
proprietary .NET firmware), and were flashing micropython for the
first time, you would need to unprotect the memory (to allow writing
new firmware) like this, instead of the mass-erase step as above:
dfu-util -s :unprotect:force -a 0 -d 0483:df11 -D build-G30TH/firmware.dfu
    * Note: apparently these 'special' dfu-utils commands require the
-D and file-path, even though they aren't actually flashing, so we
always need to:
        * make BOARD=G30TH deploy
    * to actually flash the micropython firmware


More information about the open_electroporator mailing list