Serial port errors using Arduino IDE and WeAct STM32F411 board

Bootloader for STM32F103 and STM32F4xx micro-controllers
No special driver is required. Support for Windows, Linux and Mac Operating System
Post Reply
helicron
Posts: 4
Joined: Sat Oct 17, 2020 11:15 am

Serial port errors using Arduino IDE and WeAct STM32F411 board

Post by helicron »

hi

I used the samveen derivative of the serasidis bootloader so that it will run on the WeAct STM32F411 BlackPill:

https://github.com/samveen/STM32_HID_Bootloader

I flashed that to the WeAct STM32F411 board, set up the Arduino IDE for "HID Bootloader 2.2" and the appropriate board settings.

The application code uploads, the board resets and the application runs. All good - except:

What is going on with the serial port?

For what are no doubt historically valid reasons - probably to do with the Maple, hid-flash must be getting invoked from the Arduino IDE with the name of a serial port to use. That is true even if no port is given in the Arduino IDE settings. hid-flash is called with the name of a port regardless and, looking a the sources, assumes the port will be there and is connected to the target.

Usage: hid-flash <bin_firmware_file> <comport> <delay (optional)>

The only reason to have a serial port seems to be so that DTR can be toggled to reset the processor and then send the magic string "1EAF".

This 'F4 bootloader never listens for that so I just see a bunch of errors even though everything does actually upload and function.

How is the serial port expected to be connected?
Other than building my own version of hid-flash, what is the best/easiest way of avoiding these serial port errors?
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Serial port errors using Arduino IDE and WeAct STM32F411 board

Post by fpiSTM »

Serial port error is reported by the hid-flash binary so it should be fixed in is code.
I guess it should only report a warning. IIRW it exists some related issue in the original GitHub?
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 27
Location: Prudnik, Poland

Re: Serial port errors using Arduino IDE and WeAct STM32F411 board

Post by GonzoG »

I use this bootloader and there are no errors.
I got .bin file from this link:
https://github.com/Serasidis/STM32_HID_ ... -670308140
helicron
Posts: 4
Joined: Sat Oct 17, 2020 11:15 am

Re: Serial port errors using Arduino IDE and WeAct STM32F411 board

Post by helicron »

My problem is not with the bootloader on the STM32F411, it is with the hid-flash utility.

It is that which expects to find a serial port.

fpiSTM is correct in that the utility should handle the error better.

I think that the real issue lies further up the chain somewhere in the Arduino setup.

Why might hid-flash want to make use of a serial port?
How is it that I don't see lots of people worrying about the error message?
Is it all just carried over from some anticipated setup for STM32F1 boards?

If no port is given in the Arduino IDE, a serial port name is still provided to the hid-flash utility. It might be better to detect that no serial port is given and have hid-flash notice that and simply carry on.
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: Serial port errors using Arduino IDE and WeAct STM32F411 board

Post by stevestrong »

Can you please post the message you get from the utility?
If used by Arduino, the IDE will automatically put a recognized serial port number if USB serial was used in the user application.
But you can set any COMx port you want, I assume the flasher should go and check for specific VID:PID after it detects that the given serial port does not exists.
helicron
Posts: 4
Joined: Sat Oct 17, 2020 11:15 am

Re: Serial port errors using Arduino IDE and WeAct STM32F411 board

Post by helicron »

If, in the Arduino IDE, I select an attached serial device - here an FTDI adaptor not connected to the target - then I get this output while updating:

Code: Select all

+-----------------------------------------------------------------------+
|         HID-Flash v2.2.1 - STM32 HID Bootloader Flash Tool            |
|     (c)      2018 - Bruno Freitas       http://www.brunofreitas.com   |
|     (c) 2018-2019 - Vassilis Serasidis  https://www.serasidis.gr      |
|   Customized for STM32duino ecosystem   https://www.stm32duino.com    |
+-----------------------------------------------------------------------+

> Trying to open the [cu.usbserial-AM0218G5]...
> Toggling DTR...
> Searching for [1209:BEBA] device...
#
> [1209:BEBA] device is found !
> Sending <reset pages> command...
> Flashing firmware...
. 1024 Bytes
. 2048 Bytes
. 3072 Bytes
. 4096 Bytes
. 5120 Bytes
. 6144 Bytes
. 7168 Bytes
. 8192 Bytes
. 9216 Bytes

> Done!
> Sending <reboot mcu> command...
> Searching for [cu.usbserial-AM0218G5] ...
> [cu.usbserial-AM0218G5] is found !
> Finish
If instead, the serial device is not currently connected to the computer, I see this output when flashing code:

Code: Select all

+-----------------------------------------------------------------------+
|         HID-Flash v2.2.1 - STM32 HID Bootloader Flash Tool            |
|     (c)      2018 - Bruno Freitas       http://www.brunofreitas.com   |
|     (c) 2018-2019 - Vassilis Serasidis  https://www.serasidis.gr      |
|   Customized for STM32duino ecosystem   https://www.stm32duino.com    |
+-----------------------------------------------------------------------+

> Trying to open the [cu.usbserial-AM0218G5]...
error, counldn't open [/dev/cu.usbserial-AM0218G5]
> Unable to open the [cu.usbserial-AM0218G5]
> Searching for [1209:BEBA] device...
#
> [1209:BEBA] device is found !
> Sending <reset pages> command...
> Flashing firmware...
. 1024 Bytes
. 2048 Bytes
. 3072 Bytes
. 4096 Bytes
. 5120 Bytes
. 6144 Bytes
. 7168 Bytes
error, counldn't open [/dev/cu.usbserial-AM0218G5]
. 8192 Bytes
. 9216 Bytes

> Done!
> Sending <reboot mcu> command...
> Searching for [cu.usbserial-AM0218G5] ...
error, counldn't open [/dev/cu.usbserial-AM0218G5]
error, counldn't open [/dev/cu.usbserial-AM0218G5]
error, counldn't open [/dev/cu.usbserial-AM0218G5]
error, counldn't open [/dev/cu.usbserial-AM0218G5]
> Finish
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: Serial port errors using Arduino IDE and WeAct STM32F411 board

Post by stevestrong »

As I can see, your upload finished with success, so you you are all done.
Don't bother about the available or missing serial device.
Btw, the serial port what the flasher looks for is the USB serial.
helicron
Posts: 4
Joined: Sat Oct 17, 2020 11:15 am

Re: Serial port errors using Arduino IDE and WeAct STM32F411 board

Post by helicron »

I understand that it works - I just cant like the error message :)

When you say "Btw, the serial port what the flasher looks for is the USB serial.", what USB serial do you mean?

Is this about compatibility with other HID bootloaders beside the STM32F1 and STM32F4?

Sorry to bang on about this - I am just trying to understand how the bootload process (HID particularly) is supposed to work with the Arduino system. I cannot see to find any definitive description.
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: Serial port errors using Arduino IDE and WeAct STM32F411 board

Post by mrburnette »

helicron wrote: Sat Oct 17, 2020 9:49 pm I understand that it works - I just cant like the error message :)
...
Sorry to bang on about this - I am just trying to understand how the bootload process (HID particularly) is supposed to work with the Arduino system. I cannot see to find any definitive description.
Arduino as a brand never distributed a HID bootloader (to my knowledge and 5 minutes of Googling)
https://baldwisdom.com/bootloading/

That puts HID bootloaders into a double-hack as STM32 microcontrollers were never officially offered in the Arduino family. The first STM32 core for Arduino use was from LeafLabs: https://www.leaflabs.com/maple

The HID bootloaders used for STM32 uC's are all user provided code, not supported beyond github.com authors. Putting things in prospective: you are using ArduinoIDE against a non-Arduino.cc board and non-Arduino written core library and using a user created bootloader.

If the warning/error message distresses you, the code base for all layers is open source and can be freely modified and tailored to your liking. Sometimes little hiccups in the fabric of multiple products is best left as-is. I'm simply too lazy to care about such idiosyncrasies.


Ray
Post Reply

Return to “STM32 HID bootloader”