dfu/upload not perfectly working

All distros
aster
Posts: 55
Joined: Thu Mar 30, 2017 2:41 pm

dfu/upload not perfectly working

Postby aster » Thu Apr 06, 2017 11:05 pm

So fist of all thank to bring such a powerful mcu to hobbyst use :D
then, I know this is not a "product" in the meaning that it must be perfect. anyway i am having some boring issues uploading sketches on my maple mini
usually to upload a new one i need to press the reset and then the user button 32, i read somewhere that in this way it goes in another bootloader mode (led blinking quite fast), correct?
another problem is that if i am not wrong everytime that i open the serial port the board should reset, it doesn't happen

hardware/software:
maple mini (aliexpress clone)
linux ubuntu 16.04 64bit
booatloader 2.0
dfu-util package installed
rules as described in the wiki added

lsusb output:
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 04f2:b404 Chicony Electronics Co., Ltd
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 047: ID 1eaf:0004
Bus 003 Device 002: ID 1d57:fa20 Xenta
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub


dmesg:
[ 7575.010217] usb 3-2: USB disconnect, device number 47
[ 7579.950074] usb 3-2: new full-speed USB device number 48 using xhci_hcd
[ 7580.091227] usb 3-2: New USB device found, idVendor=1eaf, idProduct=0003
[ 7580.091232] usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 7580.091234] usb 3-2: Product: Maple 003
[ 7580.091237] usb 3-2: Manufacturer: LeafLabs
[ 7580.091239] usb 3-2: SerialNumber: LLM 003
[ 7581.453636] usb 3-2: USB disconnect, device number 48
[ 7581.750083] usb 3-2: new full-speed USB device number 49 using xhci_hcd
[ 7581.891284] usb 3-2: New USB device found, idVendor=1eaf, idProduct=0004
[ 7581.891287] usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 7581.891300] usb 3-2: Product: Maple
[ 7581.891301] usb 3-2: Manufacturer: LeafLabs
[ 7581.891720] cdc_acm 3-2:1.0: ttyACM0: USB ACM device


ide output when it doesn't upload the sketch:
Archiving built core (caching) in: /tmp/arduino_cache_492532/core/core_Arduino_STM32_STM32F1_mapleMini_bootloader_version_bootloader20,cpu_speed_speed_48mhz_8ad891375d27bd2b96fe3dd8f4606ea0.a
Lo sketch usa 13084 byte (10%) dello spazio disponibile per i programmi. Il massimo è 122880 byte.
Le variabili globali usano 2816 byte di memoria dinamica.
/media/vincenzo/HardDisk/Storage/Programmi/Arduino/hardware/Arduino_STM32/tools/linux/maple_upload: riga 29: /media/vincenzo/HardDisk/Storage/Programmi/Arduino/hardware/Arduino_STM32/tools/linux/upload-reset: File o directory non esistente
dfu-util 0.8

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2014 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org

dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
dfu-util: No DFU capable USB device available
Errore durante il caricamento dello sketch


IDE output when i go in the other mode so i am able to upload the sketch:
Lo sketch usa 13084 byte (10%) dello spazio disponibile per i programmi. Il massimo è 122880 byte.
Le variabili globali usano 2816 byte di memoria dinamica.
/media/vincenzo/HardDisk/Storage/Programmi/Arduino/hardware/Arduino_STM32/tools/linux/maple_upload: riga 29: /media/vincenzo/HardDisk/Storage/Programmi/Arduino/hardware/Arduino_STM32/tools/linux/upload-reset: File o directory non esistente
dfu-util 0.8

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2014 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org

Opening DFU capable USB device...
ID 1eaf:0003
Run-time device DFU version 0110
Claiming USB DFU Interface...
Setting Alternate Setting #2 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 0110
Device returned transfer size 1024
Copying data from PC to DFU device
dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!

Download [ ] 0% 0 bytes
Download [= ] 7% 1024 bytes
Download [=== ] 14% 2048 bytes
Download [===== ] 21% 3072 bytes
Download [======= ] 29% 4096 bytes
Download [========= ] 36% 5120 bytes
Download [========== ] 43% 6144 bytes
Download [============ ] 50% 7168 bytes
Download [============== ] 58% 8192 bytes
Download [================ ] 65% 9216 bytes
Download [================== ] 72% 10240 bytes
Download [=================== ] 79% 11264 bytes
Download [===================== ] 87% 12288 bytes
Download [======================= ] 94% 13084 bytes
Download [=========================] 100% 13084 bytes
Download done.
state(8) = dfuMANIFEST-WAIT-RESET, status(0) = No error condition is present
Done!
Resetting USB to switch back to runtime mode


i have to clarify that i am a hobbyist on my first tests with linux (installed yesterday) even if i try to study as much as i can sometimes i am not able to solve this kind of problems on my own... i think i wrote all i know, any help would be very appreciated!
Last edited by aster on Fri Apr 07, 2017 4:31 pm, edited 1 time in total.

zmemw16
Posts: 1097
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: dfu/upload not perfectly working

Postby zmemw16 » Fri Apr 07, 2017 2:47 am

yep, press reset, if you only have just a single device plugged in, check the port is selected.

i usually have more than one serial port connected, the port will need selecting correctly only if its not the last serial interface connected.
i plug in, in sequence
open logic sniffer on /dev/ttyACM0
usb-serial1 on /dev/ttyUSB0, connect uart1 pa9/pa10, & gnd almost always
usb-serial2 on /dev/ttyUSB1, connect is a maybe on uart2
then i connect the board, which is usually /dev/ttyACM1or /dev/ttyUSB2, if i connect it before the usb-serials then it will need to be selected again between ttyUSB0 and ttyUSB2/3 as ttyUSB1 ( and ttyUSB2? ) is / are in use
stlink is usual but it's not mapped to /dev/tty*

this mainly because i also use bare metal with unicore-mx library. i always upload via stlink on either one.
btw istr that /dev/ttyACMn increments on a reset?? or is it power sequence, limit is ttyACM31

stephen

ag123
Posts: 490
Joined: Thu Jul 21, 2016 4:24 pm

Re: dfu/upload not perfectly working

Postby ag123 » Fri Apr 07, 2017 1:36 pm

the usual 'hello world' is to blink a led
for the maple mini (clones) the led is normally on board and i'd think the arduino 'hello world' blinky sketch pretty much works out-of-the-box
https://www.arduino.cc/en/tutorial/blink

if things didn't work, lookup the board layouts and schematics to see where those pins are routed
good sources of info are in the wiki
http://wiki.stm32duino.com/index.php?ti ... 103_boards
http://wiki.stm32duino.com/index.php?title=Maple_Mini
http://wiki.stm32duino.com/index.php?title=Blue_Pill

aster
Posts: 55
Joined: Thu Mar 30, 2017 2:41 pm

Re: dfu/upload not perfectly working

Postby aster » Fri Apr 07, 2017 4:27 pm

Thanks stephen for your answer
To be honest I wouldn t say it is a plug and play :?
the port will need selecting correctly only if its not the last serial interface connected.

interesting i didn t know it, now i understood the reason why it didn t worked!
I think that your approach of using ACM0 for programming and the pa9/10 for serial is the best one. To be honest i didn t understood all your message

Somewhere i read that the maple mini changes the indexing of the serial ports, could someone confirm it?

Ag123 the board is a maple mini as in the link you posted

zmemw16
Posts: 1097
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: dfu/upload not perfectly working

Postby zmemw16 » Fri Apr 07, 2017 7:21 pm

it's a openbench logic sniffer on ACM0, connect up to 16 digitals and capture at up to 200MHz. yeah, i believe that too :)
buffer is only 24k, so a short time at rate.
also anything connecting to the target, it's signals and ground except for things you power from it.
if the boards usb is the last thing connected, it'll stay last
rest will arrive with age :D not seeing a tongue in cheek smiley

stephen

ag123
Posts: 490
Joined: Thu Jul 21, 2016 4:24 pm

Re: dfu/upload not perfectly working

Postby ag123 » Fri Apr 07, 2017 10:28 pm

try putting the maple mini in perpetual boot loader mode:
http://docs.leaflabs.com/static.leaflab ... oader-mode
viewtopic.php?f=32&p=25537#p25537
https://www.youtube.com/watch?v=rvNIeKuXsxM

perpetual boot loader mode keeps the maple mini in the dfu mode, which is needed to install the sketch
i've documented my initial novice struggles in the 2nd link above

aster
Posts: 55
Joined: Thu Mar 30, 2017 2:41 pm

Re: dfu/upload not perfectly working

Postby aster » Mon Apr 10, 2017 10:04 pm

Thank ag the post and video you posted helped me understand how to correctly put in in dfu mode (before i just used to press them randomly)

I would like to ask you some questions since looks like you had my identical problems/question using this board. I would like to say that i already use it and it works but i love to understand "things"
The dfu mode = perpetual boot loader mode = boot0 1 & boot1 0 (sistem memory)?
What is by the way the ram memory? I remember that the first time i plugged the maple in my pc the led started blinking superfast, it was that mode? Or it was the original bootloader?
Why i could choose the cpu speed of 72 and 48? There is a particular reason? Not considering current saving projects

stevestrong
Posts: 993
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: dfu/upload not perfectly working

Postby stevestrong » Tue Apr 11, 2017 7:35 am

aster wrote:Why i could choose the cpu speed of 72 and 48? There is a particular reason? Not considering current saving projects

Because 48MHz CPU clock allows you to set the SPI1 clock to 24MHz, which otherwise (having 72MHz CPU clock) wouldn't be possible.

ag123
Posts: 490
Joined: Thu Jul 21, 2016 4:24 pm

Re: dfu/upload not perfectly working

Postby ag123 » Tue Apr 11, 2017 2:23 pm

aster wrote:Thank ag the post and video you posted helped me understand how to correctly put in in dfu mode (before i just used to press them randomly)

I would like to ask you some questions since looks like you had my identical problems/question using this board. I would like to say that i already use it and it works but i love to understand "things"
The dfu mode = perpetual boot loader mode = boot0 1 & boot1 0 (sistem memory)?
What is by the way the ram memory? I remember that the first time i plugged the maple in my pc the led started blinking superfast, it was that mode? Or it was the original bootloader?
Why i could choose the cpu speed of 72 and 48? There is a particular reason? Not considering current saving projects


those fast blinks after you press reset comes from the software bootloader installed on board e.g. the maple boot loader or stm32duino boot loader
(i think the vendors installed the default maple bootloader as the stock boot loader)

the fast blinks (i.e. maple boot loader or stm32duino boot loader) set in 'perpetual boot loader mode' is neither of those related to boot 0, boot 1 etc. the 'perpetual boot loader' is an app that's installed at the default flash memory address 0x8000000

normally if you want to program a stm32f103 device , you need to use a usb-uart(serial) dongle
https://github.com/rogerclarkmelbourne/ ... /Uploading
https://stm32f4-discovery.net/2014/09/p ... with-uart/
or use a jtag/swd programmer
e.g. https://github.com/rogerclarkmelbourne/ ... from-Linux
programming in this manner write the program/app directly at address 0x8000000 - start of flash memory

hence leaflabs (https://www.leaflabs.com/maple/) created an arduino style board 'leaflabs maple' and created a *bootloader* (the maple bootloader) and puts that at 0x8000000), this is further improved into the 'stm32duino bootloader' and you can download that here https://github.com/rogerclarkmelbourne/ ... bootloader. this 'maple boot loader' or 'stm32duino boot loader' is an app, it creates a DFU link enumerating as usb device 1eaf:0003.
And it installs your sketch or app at an address after the boot loader e.g. 0x8005000 (the original maple bootloader) or 0x8002000 stm32duino bootloader

with this software boot loader, you can program the board without an external serial or jtag/swd dongle
and this DFU install is the main mode in which Arduino IDE downloads the sketch / app into the device/soc

the leaflabs maple documentation web site http://docs.leaflabs.com/docs.leaflabs.com/index.html
is a good (original) source of docs on this stm32 based arduino implementation

to go further than that there are a lot of detailed info on ST micro web site e.g.
(in the datasheet itself)
http://www.st.com/content/st_com/en/pro ... 103cb.html
http://www.st.com/content/ccc/resource/ ... 164185.pdf
http://www.st.com/content/ccc/resource/ ... 171190.pdf
as well as in many web sites, this forum etc

some additional info: dfu-util
after you compile your sketch in the arduino ide select Sketch > Verify and compile
on my system i can find it in folder /tmp/arduino_build_nnnnnn where nnnnn is a number
over there you would find among the files sketch_xxxx.ino.bin
this bin file is the binary file that can be installed on the device, you can copy that out and put it in a separate folder

you can install this binary file using dfu-util
http://dfu-util.sourceforge.net/
i found it in the arduino IDE folder at
arduino-1.8.2/hardware/Arduino_STM32/tools/linux64/dfu-util/dfu-util
and
arduino-1.8.2/hardware/Arduino_STM32/tools/linux/dfu-util/dfu-util
(you may want to copy that out and put it in a folder in your path)
or dependent on your distribution you can normally find the install package e.g. on ubuntu, debian etc apt-get install dfu-util
or find the install package e.g. rpm for that from the distribution's webs etc

first put the maple in 'perpetual boot loader' mode
next the command is
dfu-util -l <- list the available dfu devices

Code: Select all

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: [1eaf:0003] ver=0201, devnum=9, cfg=1, intf=0, path="3-4", alt=2, name="STM32duino bootloader v1.0  Upload to Flash 0x8002000", serial="LLM 003"
Found DFU: [1eaf:0003] ver=0201, devnum=9, cfg=1, intf=0, path="3-4", alt=1, name="STM32duino bootloader v1.0  Upload to Flash 0x8005000", serial="LLM 003"
Found DFU: [1eaf:0003] ver=0201, devnum=9, cfg=1, intf=0, path="3-4", alt=0, name="STM32duino bootloader v1.0  ERROR. Upload to RAM not supported.", serial="LLM 003"

dfu-util -a 1 -D sketch_xxxx.ino.bin <- install/download the binary into the device
^^^^ note that -a n < where n is that alt=n in the dfu-util -l listing,
if it is the stock maple boot loader u'd normally see alt=0 and alt=1 where alt=1 is install to flash

aster
Posts: 55
Joined: Thu Mar 30, 2017 2:41 pm

Re: dfu/upload not perfectly working

Postby aster » Sat Apr 15, 2017 3:59 pm

very helpfull post ag123, I am answering only now since i wanted to test the upload with dfu-util and these holidays gave me the time
if i didn't understand wrong with the -a command i can choose where i want to put my sketch
so i can't choose -a 0 since it is the start of the ram memory where there is the bootloader
-a 1/2 i will upload the .bin using the board bootloader

there is something weird that i don't understand, why i could choose to upload the sketch in position 0x8005000 or 0x8002000? usually someone want to upload at the end of the bootloader so i should set -a 2 (0x8002000) indeed when i tried with -a 1 it didn't worked!

Anyway just for your fun i would tell you that I thought that i was able to upload a sketch using any usb-serial converter wrapped on the serial1 :roll: i will buy a st-link clone since they are cheap and if i will ever mess with the bootloader i will be able to upload it again


Return to “Linux”

Who is online

Users browsing this forum: No registered users and 1 guest