Closed royragsdale closed 2 years ago
FYI - @xobs
Can you please see if v2.0.4 (https://github.com/im-tomu/foboot/tree/master/releases/v2.0.4) solves the issue?
looks like only the .h
files were pushed. want me to build locally and test?
My mistake. Normally .elf
and .dfu
files aren't included, and I forgot to add them with -f
. Please try again.
Note that I needed to manually patch the SPI bus for the Hacker version of the board, due to a refactor in the spi_core
that assumes all SPI devices have four wires even if they are only dual SPI. I believe this was fixed later on, but litex has made many changes since foboot was released, and updating it might be involved.
Thank you! Tested on a pvt board (I don't have a hacker version). Works like a charm. I really appreciate you jumping on this.
Notes on what I tested:
flash
$ dfu-util -D pvt-updater-v2.0.4.dfu
dfu-util 0.9
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/
Match vendor ID from file: 1209
Match product ID from file: 70b1
Opening DFU capable USB device...
ID 1209:5bf0
Run-time device DFU version 0101
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 0101
Device returned transfer size 4096
Copying data from PC to DFU device
Download [=========================] 100% 112916 bytes
Download done.
state(7) = dfuMANIFEST, status(0) = No error condition is present
state(8) = dfuMANIFEST-WAIT-RESET, status(0) = No error condition is present
Done!
confirm
$ dfu-util -l
dfu-util 0.9
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/
Found DFU: [1209:5bf0] ver=0101, devnum=31, cfg=1, intf=0, path="2-1", alt=0, name="Fomu PVT running DFU Bootloader v2.0.4", serial="UNKNOWN"
flashing micropython from fomu-workshop works.
It properly rejects files that are too large.
$ dfu-util -D BAD.flash-pattern.dfu
dfu-util 0.9
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/
dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
Opening DFU capable USB device...
ID 1209:5bf0
Run-time device DFU version 0101
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 0101
Device returned transfer size 4096
Copying data from PC to DFU device
Download [======= ] 30% 1290240 bytes failed!
state(10) = dfuERROR, status(8) = Cannot program memory due to received address that is out of range
Thanks for the very detailed reports!
Absolutely, happy to add. Fomu has been fantastic for learning. I really appreciate the project. Thank you also for the super responsive feedback.
For what it's worth, I see the v2.0.4
tag, but not a release under https://github.com/im-tomu/foboot/releases. I'm not sure how Github handles/generates those.
It's manual currently. I just released it there.
Summary
Issue: Flashing a large file (4MB) with
dfu-util
will brick fomu.Recommendation: Cut a new release of foboot.
This issue has already been fixed in master (e76d5f96c4cb7766b344168f342ac9c93960a6eb), but the fix is not included in the current release (v2.0.3).
Details
I encountered this when I built a version of micropython with a different toolchain that resulted in an erroneously large binary. Upon flashing my fomu became unresponsive (e.g. no lights, no dfu).
The following describes reproducing the issue to confirm:
Before
Tested using fomu-pvt running foboot v2.0.2 (v2.0.3 does not have any changes that would impact this behavior).
Build and flash a BAD binary (too large)
script to create a patterned flash image, to allow easy identification of offsets.
produces a 4MB file
WARNING running this commands will BRICK your fomu. You will NOT be able to recover over usb.
fomu flashes red and is non-responsive to
dfu-util
.After unplugging and replugging still non-responsive
When connecting directly to the SPI and using fomu flash, you can confirm that the flash "wrapped" around and clobbered the low bytes of the SPI. The resulting overwrite corresponds to offset
0x003c0000
inBAD.flash-pattern.dfu
Expected Behavior
When using a foboot build from 882ce04da8b97084ef95f5a967a0e2b7312b19c2 the expected behavior occurs and you are prevented from flashing (using
dfu-util
) a payload that is too largefomu continues to operate as usual.