Serial and USB DFU download fails

Windows XP,Vista,7,8 and 8.1 etc
Post Reply
User avatar
mankan
Posts: 18
Joined: Tue Oct 13, 2015 7:57 pm

Serial and USB DFU download fails

Post by mankan » Tue Oct 13, 2015 9:50 pm

Hi all,

first post here: newbie on STM32 but worked with PIC, AVR, Arduino, TI DSP and embedded Linux for a long time.

I can build, upload and run code properly on my STM32F103RBT6 board, schematics bought on ebay using my STLink/V2 and building for the Generic STM32F10RB. Using STM Nucleo also seems to work.

However once the program is uploaded I can use the serial monitor and I have a Maple Serial (COM15) device in the "Device manager" but I cannot upload using "Upload method Serial" on COM15. The error message just says: "Failed to init device".

Am I supposed to be able to upload code via COM15 port?

I have also tried the STM32duino bootloader without success. It manages to reset the board but then it says "Couldn't find the DFU device: [1EAF:0003]"

Any advise?

I already tested to lower the baud rate to 115200. I'll try some other USB ports next.
/Marcus

stevech
Posts: 441
Joined: Thu Aug 27, 2015 6:32 am

Re: Serial and USB DFU download fails

Post by stevech » Tue Oct 13, 2015 10:37 pm

F1xx have a bootloader for UART only in ROM. (not serial on USB). The BOOT0, BOOT1 pins enable it.

Some people flash their own bootloader into the 1xx boards to use USB HID rather than than the UART/ROM option. They disable the ROM boot.

User avatar
mankan
Posts: 18
Joined: Tue Oct 13, 2015 7:57 pm

Re: Serial and USB DFU download fails

Post by mankan » Tue Oct 13, 2015 11:23 pm

I'm aware of the UART boot in ROM. I got the impression that the STM32duino sketches contains code for the USB over serial code upload due to the menu options available for the Generic STM32F103RB boards.
/Marcus

User avatar
mrburnette
Posts: 1829
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: Serial and USB DFU download fails

Post by mrburnette » Tue Oct 13, 2015 11:37 pm

mankan wrote:I'm aware of the UART boot in ROM. I got the impression that the STM32duino sketches contains code for the USB over serial code upload due to the menu options available for the Generic STM32F103RB boards.

Here:
viewtopic.php?t=66

The utility under Windows is not 100%.


Ray

User avatar
RogerClark
Posts: 7156
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Serial and USB DFU download fails

Post by RogerClark » Wed Oct 14, 2015 6:44 am

I'm a bit confused about what you are trying to achieve.

The different upload methods, dictate which device is mapped to the Arduino "Serial" class

For uploads using the bootloader, Serial is mapped to the USB Serial.

For STLink uploads, Serial is also mapped to USB Serial (because most STlink dongles don't have virtual serial. Only the Nucleo range of boards includes a virtual serial connection as part of its STLink chip)

For Serial (UART) uploads, its presumed that as you are already using a USB to Serial adaptor to upload, that you don't want to use the USB port on the board (as your board may not have working USB on it ).

For Black Magic probe, it uses UART Serial, because the BMP has virtual serial. So if you are using BMP you should wire up not only the SWD pins but also connect USART 1 (PA9 and PA10) to the BMP's UART input pins.


If you want something different to happen, you can change the board.txt, as there is a define for -DSERIAL_USB which causes the serial code to be compiled into the sketch

Note, if you don't have maple hardware, you'll also need to use -DGENERIC_BOOTLOADER

This define doesn't quite do what it implies, it actually tells the code whether you want to use the special Maple USB reset hardware, or whether you want to reset the GPIO based USB reset technique used in conjunction with the generic bootloader (hence the define's name)

User avatar
mankan
Posts: 18
Joined: Tue Oct 13, 2015 7:57 pm

Re: Serial and USB DFU download fails

Post by mankan » Wed Oct 14, 2015 4:30 pm

@mrburnette That explains some parts. Thank you.

@RogerClark

Achieve: To get my STM32F board behave like an Arduino where the USB connection is used for code upload and when the sketch is running it is a serial port. Can this be achieved?

From your answer I get the impression that code upload selection actually affects the binary code itself. Is that really the case?

Do I need to add the -DGENERIC_BOOTLOADER even when I have selected Generic board?
My board seems to have the GPIO reset according to the schematics.
/Marcus

User avatar
RogerClark
Posts: 7156
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Serial and USB DFU download fails

Post by RogerClark » Wed Oct 14, 2015 8:48 pm

Yes.

In our case the upload method effects the code.

This is why its on a sub menu for each board and not on the separate Programmers menu.

There are various things which are different depending on upload method.

Firstly the start address is different when using a bootloader, so there is a difference in the code's Vector Table.
Also the mapping of the Arduino Serial class changes ( this is for Serial and Serial1 and Serial2 etc)
There are also changes to manage the USB reset, because if you are not using USB to upload or USB for Serial, it does not need to toggle the USB line using GPIO to force re enumeration

Post Reply