Blue pill shows up as "Unrecognized device" even after installing drivers...

Windows XP,Vista,7,8 and 8.1 etc
User avatar
Pito
Posts: 1593
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Blue pill shows up as "Unrecognized device" even after installing drivers...

Post by Pito » Tue Nov 07, 2017 1:16 pm

Try to erase the stm32 before flashing the bootloader in..

PS: it shall go via MapleDFU to the Serial upon pressing reset, afaik.. Mine COM appears only after an upload. After pressing reset it ends up in MapleDFU.. :?
Pukao Hats Cleaning Services Ltd.

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

Re: Blue pill shows up as "Unrecognized device" even after installing drivers...

Post by ag123 » Tue Nov 07, 2017 3:18 pm

i think steve has a good point about faulty devices, i had a baite MM that has a short on VBAT
viewtopic.php?f=3&t=2602

then i concur with roger's point as well usb cables don't always work as well as they look

i happened to have one of those usb voltage current meter dongles
https://www.ebay.com/sch/i.html?_nkw=us ... er&_sop=15
for once i connected it in series with a MM, only to realise that 5v expected from usb does an erratic bungee jump, it gives me 3v, 2.9v, 4.5v, 1.5v, 0.8v depending on how that plug interface is shifted ever so slightly, switched a usb cable, things get more stable

vdeconinck
Posts: 10
Joined: Sun Nov 05, 2017 10:04 pm

Re: Blue pill shows up as "Unrecognized device" even after installing drivers...

Post by vdeconinck » Tue Nov 07, 2017 9:19 pm

Hi,

OK, here's a report of the tests I made this evening:

1) I resoldered the USB connector on the first board (damn, those traces are thin), checked continuity and checked there was no short. It didn't change anything (but I admit I had little hope as there was no 6 quick flashes anyway).

2) I unpacked the second board I had (same seller, same order) and tried the same procedure : moved the jumper + reseted + connected serial to the serial/USB converter + burned bootloader with python script. Again, no error... but again, no 6 flashes after restoring the jumper and a new reset.

3) I fired the Arduino IDE and uploaded a blink sketch through Serial: upload suceeded and sketch started.

4) I tried again to burn the bootloader, to no avail. No error, but after reboot, the blink sketch restarts and no 6 flashes

5) Just to be sure, I retried the burn procedure with the ST Demonstrator as explained on the wiki. It terminated successfully and... BINGO ! 6 quick flashes !!

6) I replugged the board using the micro USB and yoo-hoo, it got recognized as "Maple Serial (COM14)" in the device manager :-)

7) I then restarted the IDE, chose the STM32duino bootloader as upload method and could flash a blink sketch (with other delays to make sure a new version was really flashed): success.


So my conclusion is that somehow, there is something wrong when using the python bootloader burning procedure on these boards, although it returns with no error. I'm using Python 2.7 btw. I guess it should have worked with that version, right ?


What still puzzles me is that I'm pretty sure I had already tried the ST Demonstrator with the first board, but it didn't work. I admit maybe the jumpers were not placed correctly at that time or some other error on my part...

Anyway, I have the second board ready for my tests. Thanks to all for your help.

@Roger, are you interested in getting one of those weird "non-python-burnable" boards ? The first one is still as-is, with the script showing no error but unable to burn the bootloader it seems. I can send it to you at no cost if it helps, just tell me.

Kind regards,

Vincent

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

Re: Blue pill shows up as "Unrecognized device" even after installing drivers...

Post by RogerClark » Tue Nov 07, 2017 10:26 pm

I've heard of some boards where the flash is locked.

Perhaps in this case the python flasher is not able to unlock

However its strange that you get some flashes.

Apart from trying on a Windows machine using ST's own tools...

The only other similar problem was where someone had a faulty oscillator crystal, and the built in Serial bootloader does not use the crystal, hence its possible to flash but then things don't work correctly.

BTW. I presume the crystal is 8Mhz ?

vdeconinck
Posts: 10
Joined: Sun Nov 05, 2017 10:04 pm

Re: Blue pill shows up as "Unrecognized device" even after installing drivers...

Post by vdeconinck » Tue Nov 07, 2017 11:22 pm

Hi, Roger,
RogerClark wrote:
Tue Nov 07, 2017 10:26 pm
I've heard of some boards where the flash is locked.
Perhaps in this case the python flasher is not able to unlock
However its strange that you get some flashes.
Apart from trying on a Windows machine using ST's own tools...
Well, ST's tool can seemingly flash through serial indeed, but so does the Arduino IDE with sample sketches...
The only other similar problem was where someone had a faulty oscillator crystal, and the built in Serial bootloader does not use the crystal, hence its possible to flash but then things don't work correctly.
BTW. I presume the crystal is 8Mhz ?
Yes, it's marked 8.000.
I didn't check it with a scope but the blink delays are roughly correct (well, I probably wouldn't detect a 5% drift but we're not an order of magnitude out).

That being said, the duration of flashing through python felt shorter than with the ST tool.
How long should the burning take ? Less than 1 second ? 1-2 seconds ? 3-5 seconds ? More ?

I might try to take a look at the flash script... Any way to enable debugging or any hint where to look ?

Kind regards,

Vincent

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

Re: Blue pill shows up as "Unrecognized device" even after installing drivers...

Post by RogerClark » Tue Nov 07, 2017 11:42 pm

It normally takes a few seconds to flash the bootloader (as it now includes a dummy sketch and its 28 in total I think)

You could try reading back the flash, if the python tool supports that.

PS. Why are you using Python ? there is a binary stm32flash for most platforms, including the source if you are on a OS that we didnt compile a binary for

Most people either use STM's own free Windows GUI tool for this or use the stm32flash binary

Note.
Someone reported the the upload speed used in my scripts for stm32flash of 230400 was not supported by their USB to Serial adaptor.

So I'm going to need to change all the scripts to use 115200 as all adaptors seem to support that speed.

vdeconinck
Posts: 10
Joined: Sun Nov 05, 2017 10:04 pm

Re: Blue pill shows up as "Unrecognized device" even after installing drivers...

Post by vdeconinck » Thu Nov 09, 2017 12:33 am

RogerClark wrote:
Tue Nov 07, 2017 11:42 pm
It normally takes a few seconds to flash the bootloader (as it now includes a dummy sketch and its 28 in total I think)
You could try reading back the flash, if the python tool supports that.
Mmmh, it looked shorter than that. I'll see what I can find...
PS. Why are you using Python ? there is a binary stm32flash for most platforms, including the source if you are on a OS that we didnt compile a binary for.
Most people either use STM's own free Windows GUI tool for this or use the stm32flash binary
?
Err, sorry, I looked on your github https://github.com/rogerclarkmelbourne/ ... bootloader and the only flash tool I could find (in the "flash" subfolder) is a python script.
Google returns many "stm32flash". Can you point me to the version you use ?
Note.
Someone reported the the upload speed used in my scripts for stm32flash of 230400 was not supported by their USB to Serial adaptor.
So I'm going to need to change all the scripts to use 115200 as all adaptors seem to support that speed.
That is a possibility indeed...
I'm using a CP210x-based USB to serial converter. Never had issues with it but I don't know for sure if I ever used it above 115200...

Kind regards,

Vincent

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

Re: Blue pill shows up as "Unrecognized device" even after installing drivers...

Post by RogerClark » Thu Nov 09, 2017 12:54 am

Look in https://github.com/rogerclarkmelbourne/ ... /tools/win

there is stm32flash.exe

I forget the exact syntax but the uploader uses

stm32flash -g 0x8000000 -b 115200 -w %str% %1

I suspect %str% %1% is the file to write to the board

vdeconinck
Posts: 10
Joined: Sun Nov 05, 2017 10:04 pm

Re: Blue pill shows up as "Unrecognized device" even after installing drivers...

Post by vdeconinck » Fri Nov 10, 2017 12:46 am

RogerClark wrote:
Thu Nov 09, 2017 12:54 am
Look in https://github.com/rogerclarkmelbourne/ ... /tools/win
there is stm32flash.exe
Got it, thanks.
I forget the exact syntax but the uploader uses
stm32flash -g 0x8000000 -b 115200 -w %str% %1
I suspect %str% %1% is the file to write to the board
To be precise, %str% is the file and %1% is the serial port, so I used

Code: Select all

stm32flash -g 0x8000000 -b 115200 -w generic_boot20_pc13.bin COM4
And it worked ! :-)

So my take on this is that it seems the python script just... does not work.

The very short time it takes was an indication, plus (I wonder why it only strikes me now) the log says it only writes 2x256 bytes while the FW is about 20k:
D:\temp>python ./stm32loader.py -p COM4 -w generic_boot20_pc13.bin
Bootloader version 22
Chip id `['0x4', '0x10']'
Write 256 bytes at 0x8000000
Write 256 bytes at 0x8000100
I played more with the Python params, switching output to verbose (-V), performing full erase/write/verify cycle (-e -w -v), and everything looks perfectly OK, but it seems to only take into account the first few bytes of the file.

Adding a bit of debug, I quickly traced the problem to the file read logic which is line 408:

Code: Select all

data = map(lambda c: ord(c), file(args[0]).read())
This only reads the 328 first byte, and after a bit of Googling, I discovered that this file() function opens the file in text mode and stops at the first EOF char.
After switching to opening explicitely in binary with:

Code: Select all

data = map(lambda c: ord(c), file(args[0], "rb").read())
Then burning magically worked and I was greeted with the 6 flashes :-)

So I think there is an outstanding issue and this is a quick and easy fix.

@Roger, it seems the original link to the author's site (from the sketch header) is now 404. I found the file stm32loader.py in many Git repos, and most of them included the above fix, so I guess you have an early version... Unfortunately, most versions have been modified one way or another so I could not tell you the best version to upgrade yours from, but I think the above one-line fix is a must because I cannot understand how it could work without it...

Now the question could be whether it make sense to keep (only) that old Python version in your bootloaders' repo while the native versions are distributed with the STM32duino package... I think it can be misleading (learned it the hard way :-)), but maybe it would suffice to add a readme stating that it's not the advised way but can be used in case no native version is available for exotic OSes...

Btw, I'd gladly document the "right" (native) procedure for "Blue-Pill" boards on the Wiki. Do you think it helps, or was it just me that didn't find it ?

Kind regards,


Vincent

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

Re: Blue pill shows up as "Unrecognized device" even after installing drivers...

Post by RogerClark » Fri Nov 10, 2017 1:08 am

OK.

Needs to be updated

Which line needs to be changed (line number)

Post Reply