upload sketch only once

All distros
Post Reply
pitch
Posts: 5
Joined: Thu Jan 26, 2017 4:53 pm

upload sketch only once

Post by pitch » Thu Jan 26, 2017 5:41 pm

I have successfully installed Arduino_STM32 and also succeeded install the generic_boot20_pc13.bin on my blue-pill as the instruction here, told me to do it.
Then, when I'm going to upload a sketch to the blue-pill via usb with Arduino ide it first doen't find any usb port even though I've chosen "STMduino bootloader". I think I've tried every possible way to boot it but no success finding any usb port. So finally I just tried to upload anyway the Blink.ino sketch and it worked. This is the last part of the output from that upload:

Code: Select all

Sketch uses 14,120 bytes (21%) of program storage space. Maximum is 65,536 bytes.
Global variables use 2,816 bytes of dynamic memory.
/home/patric/.arduino15/packages/stm32duino/tools/stm32tools/2017.1.16/linux/maple_upload ttyACM0 2 1EAF:0003 /tmp/arduino_build_993163/Blink.ino.bin 
Failed to open serial device.
No valid DFU suffix signature
Warning: File has no DFU suffix
dfu-util 0.7

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

Filter on vendor = 0x1eaf product = 0x0003
Opening DFU capable USB device... ID 1eaf:0003
Run-time device DFU version 0110
Found DFU: [1eaf:0003] devnum=0, cfg=1, intf=0, alt=2, name="STM32duino bootloader v1.0  Upload to Flash 0x8002000"
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
bytes_per_hash=282
Copying data from PC to DFU device
Starting download: [##################################################] finished!
state(8) = dfuMANIFEST-WAIT-RESET, status(0) = No error condition is present
Done!
That was odd but I can live with that :-)
Then I noticed that I suddenly was having a new port, "/dev/ttyACM0 (Maple Mini)"
Fantastic, even better,
Let's test upload the sketch again but change the delay so I know it actually did upload something different.
But no ... Not this time. The upload failed and never worked again.
This time the tail output looks like this:

Code: Select all

Sketch uses 8,056 bytes (12%) of program storage space. Maximum is 65,536 bytes.
Global variables use 1,984 bytes of dynamic memory.
/home/patric/.arduino15/packages/stm32duino/tools/stm32tools/2017.1.16/linux/serial_upload ttyACM0 {upload.altID} {upload.usbID} /tmp/arduino_build_993163/Blink.ino.bin 
Failed to init device.
stm32flash Arduino_STM32_0.9

http://github.com/rogerclarkmelbourne/arduino_stm32

Using Parser : Raw BINARY
Interface serial_posix: 230400 8E1

An error occurred while uploading the sketch
The only way to make it work as the first upload is to do the load of the generic_boot20_pc13.bin with the st-link again.
I'm obviously missing some important step but I can't find it in the great instructions.
What am I missing?

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

Re: upload sketch only once

Post by stevestrong » Fri Jan 27, 2017 12:58 am

To upload over USB you have to select "Stm32duino bootloader" method in Arduino IDE menu, not "serial".

pitch
Posts: 5
Joined: Thu Jan 26, 2017 4:53 pm

Re: upload sketch only once

Post by pitch » Fri Jan 27, 2017 3:03 am

I did that, but I missed the 32 in "STM32duino bootloader".
even though I've chosen "STMduino bootloader"

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

Re: upload sketch only once

Post by stevestrong » Fri Jan 27, 2017 9:29 am

Well, according to your log you tried the serial upload instead of the DFU upload method:

Code: Select all

/home/patric/.arduino15/packages/stm32duino/tools/stm32tools/2017.1.16/linux/serial_upload ttyACM0 {upload.altID} {upload.usbID} /tmp/arduino_build_993163/Blink.ino.bin 
For the USB (DFU) bootloader you should have called "maple_upload".

pitch
Posts: 5
Joined: Thu Jan 26, 2017 4:53 pm

Re: upload sketch only once

Post by pitch » Fri Jan 27, 2017 3:17 pm

Oh, I see.
I thought the pasted log was from another part of all my different tries. Sorry.
Obviously it's working whatever I choose, this is a log with the "STM32duino bootloader"

Code: Select all

Sketch uses 14,120 bytes (21%) of program storage space. Maximum is 65,536 bytes.
Global variables use 2,816 bytes of dynamic memory.
/home/patric/.arduino15/packages/stm32duino/tools/stm32tools/2017.1.16/linux/maple_upload ttyACM0 2 1EAF:0003 /tmp/arduino_build_926864/Blink.ino.bin 
Failed to open serial device.
No valid DFU suffix signature
Warning: File has no DFU suffix
dfu-util 0.7

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

Filter on vendor = 0x1eaf product = 0x0003
Opening DFU capable USB device... ID 1eaf:0003
Run-time device DFU version 0110
Found DFU: [1eaf:0003] devnum=0, cfg=1, intf=0, alt=2, name="STM32duino bootloader v1.0  Upload to Flash 0x8002000"
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
bytes_per_hash=282
Copying data from PC to DFU device
Starting download: [##################################################] finished!
state(8) = dfuMANIFEST-WAIT-RESET, status(0) = No error condition is present
Done!
Resetting USB to switch back to runtime mode
It's always complaining that it can't open serial device.
And then a couple of lines down it's happy to connect to the usb device. But only once.

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

Re: upload sketch only once

Post by stevestrong » Sat Jan 28, 2017 8:15 pm

Have you set the BOOT0 jumper back to its original position after flashing the bootloader?

pitch
Posts: 5
Joined: Thu Jan 26, 2017 4:53 pm

Re: upload sketch only once

Post by pitch » Sun Jan 29, 2017 7:19 pm

I never touched the BOOT0 jumper.
It's been in 0 position all the time.

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

Re: upload sketch only once

Post by stevestrong » Mon Jan 30, 2017 7:33 am

Have you read the wiki?
Also, to reset some boards for uploading over DFU (USB) one have to push the reset button after the compilation finished and just before uploading is started. Search the forum for "R10"...
On some machines the serial port of the F103 board appears enumerated only couple of seconds after reset.

pitch
Posts: 5
Joined: Thu Jan 26, 2017 4:53 pm

Re: upload sketch only once

Post by pitch » Tue Jan 31, 2017 7:38 pm

No, I haven't found that page earlier...I realise that my reading condition failed me to see the "Show 10 more pages" until now. :oops:
When reading that page I realize that it is not meant to upload via the usb port on a blue-pill. Or is there a guide for that some where else?

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

Re: upload sketch only once

Post by stevestrong » Tue Jan 31, 2017 10:04 pm

Funnyly i use original blue pills with 10k on USB+ and it resets automatically if i connect the pill over an USB hub.
Otherwise i have to push reset each time before upload. But USB DFU upload certainly works this way, so is usable.

Post Reply