STM32F103C8 and Fast Bootloader

STM32duino bootloader aka Maple bootloader
GeorgeIoak
Posts: 39
Joined: Sun Jun 07, 2020 2:01 am

Re: STM32F103C8 and Fast Bootloader

Post by GeorgeIoak »

OK, update. I just tried to flash again using the Arduino IDE and somehow it was able to do something this time:

Code: Select all

Sketch uses 50664 bytes (77%) of program storage space. Maximum is 65536 bytes.
Global variables use 1496 bytes (7%) of dynamic memory, leaving 18984 bytes for local variables. Maximum is 20480 bytes.
maple_loader v0.1
Resetting to bootloader via DTR pulse
Reset via USB Serial Failed! Did you select the right serial port?
Searching for DFU device [1EAF:0003]...
Assuming the board is in perpetual bootloader mode and continuing to attempt dfu programming...

Found it!

Opening USB Device 0x1eaf:0x0003...
Found Runtime: [0x1eaf:0x0003] devnum=1, cfg=0, intf=0, alt=2, name="STM32duino bootloader v1.0  Upload to Flash 0x8002000"
Setting Configuration 1...
Claiming USB DFU Interface...
Setting Alternate Setting ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
Transfer Size = 0x0400
bytes_per_hash=1019
Starting download: [##################################################] finished!
error resetting after download: usb_reset: could not reset device, win error: A device which does not exist was specified.


state(8) = dfuMANIFEST-WAIT-RESET, status(0) = No error condition is present
Done!
Resetting USB to switch back to runtime mode
timeout waiting for COM7 serial
I believe this is what I was getting before I tried the fastboot bootloader. The COM port drops out, from the console window it appears that the board was flashed with the sketch properly but instead of coming back as the COM port I get "Unknown USB Device (Device Descriptor Request Failed) and if I look at the details of the problem device I see that it has "USB\VID_0000&PID_0002\5&17411534&0&5"
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: STM32F103C8 and Fast Bootloader

Post by ag123 »

GeorgeIoak wrote: Thu Jul 16, 2020 3:17 pm I assume that if I don't see DFU device in Device Manager then any DFU utility isn't going to be able to access the device, right?
yup
GeorgeIoak wrote: Thu Jul 16, 2020 3:17 pm So how can I get this board into DFU mode knowing that I've flashed the fastboot bootloader and I'm only seeing the COM port device?
in libmaple core i think this is how it is done
https://github.com/rogerclarkmelbourne/ ... l.cpp#L307
you may like to adapt those codes if you use the STM core, e.g. to create your own 'magic' trigger from within the sketch.
i think the STM core has probably adapted it, it'd take some effort to find that code and select the appropriate defines e.g. usb-serial

Code: Select all

Opening USB Device 0x1eaf:0x0003...
Found Runtime: [0x1eaf:0x0003] devnum=1, cfg=0, intf=0, alt=2, name="STM32duino bootloader v1.0  Upload to Flash 0x8002000"
Setting Configuration 1...
Claiming USB DFU Interface...
Setting Alternate Setting ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
Transfer Size = 0x0400
bytes_per_hash=1019
Starting download: [##################################################] finished!
error resetting after download: usb_reset: could not reset device, win error: A device which does not exist was specified.
^this is likely the output of dfu-util the command given pior, you can ignore the reset error message, simply press reset after that
this is a successful install, the sketch is installed at 0x8002000
GeorgeIoak
Posts: 39
Joined: Sun Jun 07, 2020 2:01 am

Re: STM32F103C8 and Fast Bootloader

Post by GeorgeIoak »

I tried a manual reset, and assuming that I've am bringing nRST high with my jumpers this isn't resetting the board, or I should say that the device doesn't drop out of the Device Manager and re-enumerate as the COM port again.

I could probably pull the USB cable and issue a hard reset to bring it back but I'm trying to understand this process and implement it my program so I can flash over USB.

Is there some document that goes through this process? I haven't seen anything that says you need to add code to your program in order to flash over USB.
GeorgeIoak
Posts: 39
Joined: Sun Jun 07, 2020 2:01 am

Re: STM32F103C8 and Fast Bootloader

Post by GeorgeIoak »

OK, sorry, not enough coffee yet this morning I guess. I need to pull nRST low to reset the device and I was trying to pull it high. Now when I pull nRST low the board does drop out of the Device Manager but it comes back with that unknown device. That even happens when I pull the USB cable and do a hard reset to the board.
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: STM32F103C8 and Fast Bootloader

Post by ag123 »

you need to use the usb-serial device (not sure what is that same term in STM core - i think it is USB-CDC)
and maybe issue Serial.begin() in setup().
in libmaple core SERIAL_USB needs to be one of the defines at built time, probably driven by platform.txt or boards.txt
this is normally default
if you are using STM core it is probably found somewhere in the wiki
https://github.com/stm32duino/wiki/wiki
GeorgeIoak
Posts: 39
Joined: Sun Jun 07, 2020 2:01 am

Re: STM32F103C8 and Fast Bootloader

Post by GeorgeIoak »

Yes, I do have STM32 Core installed, version 1.9.0, I just checked in the Board Manager.

Before this last successful program flashing the board was always coming up as a Maple COM port. Now it is showing up as an unknown device so that sounds like a driver issue in Windows, not a program problem.

I do have "Serial.begin(115200);" in the setup of my sketch.

So I'm confused why before it came up as a COM port but I couldn't communicate to the board. Now that I've flashed my program to the board it does not come up in Windows as a known device.

I looked at the stm32duino wiki and I didn't see anything that I need to do to use DFU but perhaps I missed it?
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: STM32F103C8 and Fast Bootloader

Post by ag123 »

not just that you need to select USB-CDC as yourr Serial device. it'd probably take some effort to dig through codes and wiki on how to use the USB-CDC in STM core. e.g. do you need to issue Serial.begin()?
btw USB-CDC can go much faster than the rates of the conventional usb-uart like 115200. for stm32f4 with libmaple core i've got speed in excess of 1 mbps
i think it'd be the same for STM core as the code base is the same for USB-CDC but the API from the sketch may be different
viewtopic.php?f=24&t=452
and the baud rate can be omitted, it is irrelevant it is a virtual com port
but you'd need to review docs, examples, codes etc to see how to use the USB-CDC in STM core
https://github.com/stm32duino/wiki/wiki/Upload-methods
Last edited by ag123 on Thu Jul 16, 2020 4:37 pm, edited 1 time in total.
GeorgeIoak
Posts: 39
Joined: Sun Jun 07, 2020 2:01 am

Re: STM32F103C8 and Fast Bootloader

Post by GeorgeIoak »

I was/am using the serial port for debug messages.

Isn't the CDC a completely different bootloader? Don't you think my current issue is a problem with the bootloader or perhaps the drivers I installed? I wouldn't expect the drivers to be an issue since I have seen both the COM port and the DFU device show up in the Device Manager.

I was expecting that once I loaded the bootloader nothing changes in how I program other than selecting the Maple DFU Bootloader fo r the upload method.

Is it expected that if I use this bootloader that I need to change the core too? Do you also have to add some code to your program for this system to work?
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: STM32F103C8 and Fast Bootloader

Post by ag123 »

found an addition link in STM core wiki, check out the upload methods section.
https://github.com/stm32duino/wiki/wiki/Upload-methods

i think you'd need to select USB-CDC from the Arduino IDE menu prior to build
GeorgeIoak
Posts: 39
Joined: Sun Jun 07, 2020 2:01 am

Re: STM32F103C8 and Fast Bootloader

Post by GeorgeIoak »

At the bottom of that page you linked in is what I'm doing. I have flashed the fastboot bootloader and the IDE was configured to use the Maple DFU bootloader which did work as it flashed my program but I don't see anything about setting the USB Support mode. However I just tried changing that to CDC as you mentioned and I got an error:

Code: Select all

c:/users/george/appdata/local/arduino15/packages/stm32/tools/xpack-arm-none-eabi-gcc/9.2.1-1.1/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\george\AppData\Local\Temp\arduino_build_191901/STM32F103C8_ILI9341_TFT_eSPI.ino.elf section `.rodata' will not fit in region `FLASH'
Looking back at the last successful flash I see this:

Code: Select all

Sketch uses 50664 bytes (77%) of program storage space. Maximum is 65536 bytes.
So I had available flash but perhaps not enough for this USB driver which maybe I now need? Does anyone have any ideas about this?

I just tried flashing a simple blink sketch and I get this:

Code: Select all

Sketch uses 20868 bytes (31%) of program storage space. Maximum is 65536 bytes.
Global variables use 3804 bytes (18%) of dynamic memory, leaving 16676 bytes for local variables. Maximum is 20480 bytes.
maple_loader v0.1
Resetting to bootloader via DTR pulse
Reset via USB Serial Failed! Did you select the right serial port?
Searching for DFU device [1EAF:0003]...
Assuming the board is in perpetual bootloader mode and continuing to attempt dfu programming...

dfu-util - (C) 2007-2008 by OpenMoko Inc.
Couldn't find the DFU device: [1EAF:0003]
This program is Free Software and has ABSOLUTELY NO WARRANTY


timeout waiting for COM7 serial
So even if I need the CDC USB I'm still not able to talk to my board since it isn't loaded properly in Windows (I think that's the case)
Post Reply

Return to “USB bootloader”