aw / fiveforths

32-bit RISC-V Forth for microcontrollers
https://fiveforths.a1w.ca
MIT License
66 stars 3 forks source link

Flash with dfu-util #20

Closed vazhnov closed 1 year ago

vazhnov commented 1 year ago

I see dfu-util mentioned in TUTORIALS.md but not used in the code.

Here is example of successful flashing with the tool to "Sipeed Longan nano" board:

 % dfu-util -l                                      
dfu-util 0.11

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2021 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: [28e9:0189] ver=1000, devnum=12, cfg=1, intf=0, path="1-4.4", alt=1, name="@Option Bytes  /0x1FFFF800/01*016 g", serial="3CBJ"
Found DFU: [28e9:0189] ver=1000, devnum=12, cfg=1, intf=0, path="1-4.4", alt=0, name="@Internal Flash  /0x08000000/512*002Kg", serial="3CBJ"
 % dfu-util -d 28e9:0189 --alt 0 -s 0x08000000:leave -D fiveforths.bin
dfu-util 0.11

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2021 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: Warning: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release
Opening DFU capable USB device...
Device ID 28e9:0189
Device DFU version 011a
Claiming USB DFU Interface...
Setting Alternate Interface #0 ...
Determining device status...
DFU state(10) = dfuERROR, status(10) = Device's firmware is corrupt. It cannot return to run-time (non-DFU) operations
Clearing status
Determining device status...
DFU state(2) = dfuIDLE, status(0) = No error condition is present
DFU mode device DFU version 011a
Device returned transfer size 2048
DfuSe interface name: "Internal Flash  "
Found GD32VF103, which reports a bad page size and count for its internal memory.
Fixed layout based on part number: page size 1024, count 128.
Downloading element to address = 0x08000000, size = 2602
Erase       [=========================] 100%         2602 bytes
Erase    done.
Download    [=========================] 100%         2602 bytes
Download done.
File downloaded successfully
Submitting leave request...

P.S.: without --alt 0 it returns an error:

dfu-util: More than one DFU capable USB device found! Try `--list' and specify the serial number or disconnect all but one device

I can try to improve the documentation and Makefile when find how to automate arguments selection.

aw commented 1 year ago

Hi, thanks for this. There are many other methods for flashing as well, documented on various websites, so I will not add dfu-util process. The Makefile is already configured for using stm32loader if you type make flash.