Blue Pill - STM32F103 - Programmers and Boot Loaders #bluepill #stm32 #arm #morsecodetutor


Tom, wb6b
 
Edited

Hi,

I've been using STM32 development boards with built-in STLink programmers/debuggers so the Blue Pill loading-a-Boot-Loader process has not been an issue. However, I have some Blue Pill boards so I started looking into how to add a boot loader to them. 

I have an STLink, but was especially interested if it was possible to program the Blue Pill without one.

First of all, many STM32 chips come from the factory with a built-in boot loader using a protocol called DFU. I believe it can work over the chip's serial ports as well as the USB port. That is what those BOOT0, BOOT1 jumpers are all about, they put the chip in the factory boot loader mode, and user boot loader modes. 

You can Google "stm32 dfu protocol" if you care to know more about DFU.

It looks like, from what I've read, the STM32F103 chips have a simpler built-in boot loader that only works over the serial (USART) I/O. But, this would allow the chip to be programmed with the USB to serial adaptors many folks have, rather than needing an STlink or other (such as J-Link) programmer. 

Here are a couple of articles I found covering the topic of programming the Blue Pill, STM32F103, chips.

https://medium.com/@paramaggarwal/programming-an-stm32f103-board-using-usb-port-blue-pill-953cec0dbc86
https://coytbarringer.com/programming-stm32f103-blue-pill-using-usb-bootloader-platformio/

I'd be interested what others are doing in this area.

Tom, wb6b


Faisal Akber (VA3SFA)
 

Tom,

I have been playing around with this board for the past month or so.

It is a great board.

Since I want others to participate in what I am working on later I have decided to use the arduino stm32 libraries.

I have tried the USB bootloader and the default serial DFU.  I found the serial DFU to be more reliable.

Check out stm32duino.com and Great Scott's video on YouTube.

I personally prefer manually writing code instead of using the arduino libraries but since I am sharing code with people who are more familiar with arduino I am using that instead.

72 DE Faisal VA3SFA


Tom, wb6b
 
Edited

Hi Faisal,

Thanks for the additional information.

The Great Scott video was very good. I wonder where these YouTube folks get the time to do all these projects. He has a lot of interesting videos.

So to summarize, it looks like you don't mind moving the boot jumper every time you want to program the Blue Pill using the factory DFU loader along with an external USB to serial board is a good way to go. And it looks like the Arduino IDE supports this as one of the default methods. So no need to burn a USB boot loader. Although burning a USB boot loader would provide the convenience on using the on-board USB connecter to do the program uploads. 

I'm using the STM32 Arduino tool chain that best I can tell is the "official" STM tool chain. At least it is being maintained by STM employees. It is basically the same tool chain as the one I use with their official STM32Cube IDE. Like you, I agree the Arduino platform is a great platform to be able to share projects with others. So while I may user other platforms for work, I really like the Arduino platform for play.

Here are links to the items referenced here.

Great Scott video:

https://www.youtube.com/watch?v=EaZuKRSvwdo

The tool chain I'm using:

To install this STM32 board tool chain, go to the Arduino preferences and add the following URL to the "Additional Board Manager URL's" box:

https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json

As pointed out in one of Jack's early posts regarding the Morse Code Tutor, there are a number of tool chains available for the Blue Pill (STM32F103) for the Arduino IDE. Each may have different implementations and advantages.

Tom,
wb6b


 


Guy <sgbridge@...>
 

Hey Tom,
what do you do when you go to Arduino preferences and enter the URL, and it says
”error in downloading https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/packages_stm_index.json”
and it also shows an error for the “Dan.drown.org url ? And no choices show up under board manager for the stm32 board. 
this happened running on win xp and win 7 using Arduino IDE v 1.8.8,1.8.9, and 1.8.5. 
Kinda at my wits end. 
Thanks for any help. 

Guy WB7SZI


Tom, wb6b
 

Hi,

It looks like the URL should end with package_stm_index.json rather than packages_stm_index.json”. Hope that helps.

I googled the dan.drown.org url and see he has a "Boards Manager package", also. I don't know much about this one, but I was able to see the json file when I clicked on the link. 

Tom, wb6b


Guy <sgbridge@...>
 

Thanks Tom. I’ll check to see if I had the right url. 
Regards,

Guy WB7SZI 


Guy <sgbridge@...>
 

Tom,
got the STM32 url to work under Win10 and Arduino IDE 1.8.3!  Go figure.....
thanks again,

Guy WB7SZI 


Tom, wb6b
 

Hi Guy,

Great... Glad you were able to get it to install.

I had a little more time to work on my porting of Jack's code. Because I'm interested in using some of the STM official development boards (By the way the prices are very reasonable for these boards, although not as cheap an the popular Blue Pill), I'm interested in using the official STM32 Arduino from STM. 

As I work through some of the porting issues, I think I now know which STM32 library for Arduino Jack is using. When I got to the point of resolving the eeprom library issues and discovered another library called "wirish" (which commenting out seems to fix) I was able to do a Google search and come up with this library:

https://github.com/rogerclarkmelbourne/Arduino_STM32

Roger's library concentrates on support a wide array of popular boards that you can buy on eBay and Amazon, and that includes the Blue Pill. Roger seems to be the point person of the now read-only forum:
http://www.stm32duino.com/viewtopic.php?f=16&t=4671
and here
http://wiki.stm32duino.com/index.php?title=Main_Page

So, up until recently, it looks like Roger's tool chain was the best (or next best) tool chain. And still looks like a good tool chain.

The "official" STM32 Arduino tool chain concentrates on STM official development boards, supports a larger array of chip families, and supports a number of popular boards and controllers (like 3D printer controllers) that you would find on eBay or Amazon. By the way, if you decide to purchase an STM development board, buy it from a distributor. The sellers on eBay and Amazon are inflating the prices for the STM boards.

So if you are not a die hard like me, with the desire to stay compatible with the tool chain I use with STM32Cube and the HAL layer it provides (which makes it more likely for me to be able to move projects back and forth between Arduino and STM32cube, and possibly Mbed as well) You may want to try Roger's toolchain, or what toolchain Jack used if it wasn't Roger's. 

When I finish my port, I'll list the changes needed to make the Morse Code Tutor work with the "official" STM32_Arduino tool chain.

One other thing, possibility, even if you install Roger's tool chain, you may find some conflicts if you Arduino IDE has been around the block a few times.

There were "Multiple libraries were found for "Rotary.h". But, through some kind of built in magic in the Arduino IDE it determined which one it was going to use, and made the correct choice.

I have another EEPROM library from working with ESP32 boards. Arduino tries to use that one and causes problems. I copied Roger's eeprom library into the Morse Code Tutor code and that seems to help. If you haven't been messing with other boards/processors you shouldn't running unto this. 

This is kind of a blow by blow report. The finale is yet to come. 

Tom, wb6b


jjpurdum
 

Tom:

My guess is that Roger Clark has forgotten more about the STM32 than I'll ever know, and I do find his tool chain very effective. EEPROM is nettlesome for both the STM32 and ESP32 families because they really don't have any EEPROM. Instead, they dedicate chunks of flash memory to emulate EEPROM. I like the STM32 approach because it allows you to register the address page(s) you want to set aside as EEPROM. I haven't done as much with the ESP32 EEPROM, but it appears to be a fixed flash memory chunk.

While I haven't research this yet, it appears that both the STM32 and the ESP32 have their own cores, which you can find on path below the hardware directory of the Arduino IDE install. The (GNU C++) code generator within the IDE must use the proper instruction set which depends upon the µC board being used for the current project. When you do a #include with angle brackets ("<", ">"), the IDE knows to look first in the board's core directory. While I'm not sure at this point, I think if it doesn't find the library in the associated core set of libraries, it then looks in the default Arduino libraries subdirectory. If there are no inline assembler directives or processor-specific statements (e.g., bitwise operations on port addresses) in the library, the compiler can use the library source to generate the code suitable for the board being used. If the #include preprocessor directive surrounds the library name in double quotes, it first looks in your project's directory for the library source code and, not finding it, then searches the default (i.e., angle bracket) path. For the STM32 and the ESP32, it seems to me that if it can't find the library on the "core path", the compiler then looks in the default Arduino IDE path.

My software company wrote and marketed the Eco-C88 C compiler for MSDOS back in the 80's for the Intel family of processors. All I can say is that there are some very talented people who developed the Arduino IDE, and they keep making it better. Each time I download a new version, I make a small contribution to their efforts and hope others do likewise. Now, if we could just get them to integrate a symbolic debugger...

Jack, W8TEE

On Sunday, June 2, 2019, 2:50:33 AM EDT, Tom, wb6b <wb6b@...> wrote:


Hi Guy,

Great... Glad you were able to get it to install.

I had a little more time to work on my porting of Jack's code. Because I'm interested in using some of the STM official development boards (By the way the prices are very reasonable for these boards, although not as cheap an the popular Blue Pill), I'm interested in using the official STM32 Arduino from STM. 

As I work through some of the porting issues, I think I now know which STM32 library for Arduino Jack is using. When I got to the point of resolving the eeprom library issues and discovered another library called "wirish" (which commenting out seems to fix) I was able to do a Google search and come up with this library:

https://github.com/rogerclarkmelbourne/Arduino_STM32

Roger's library concentrates on support a wide array of popular boards that you can buy on eBay and Amazon, and that includes the Blue Pill. Roger seems to be the point person of the now read-only forum:
http://www.stm32duino.com/viewtopic.php?f=16&t=4671
and here
http://wiki.stm32duino.com/index.php?title=Main_Page

So, up until recently, it looks like Roger's tool chain was the best (or next best) tool chain. And still looks like a good tool chain.

The "official" STM32 Arduino tool chain concentrates on STM official development boards, supports a larger array of chip families, and supports a number of popular boards and controllers (like 3D printer controllers) that you would find on eBay or Amazon. By the way, if you decide to purchase an STM development board, buy it from a distributor. The sellers on eBay and Amazon are inflating the prices for the STM boards.

So if you are not a die hard like me, with the desire to stay compatible with the tool chain I use with STM32Cube and the HAL layer it provides (which makes it more likely for me to be able to move projects back and forth between Arduino and STM32cube, and possibly Mbed as well) You may want to try Roger's toolchain, or what toolchain Jack used if it wasn't Roger's. 

When I finish my port, I'll list the changes needed to make the Morse Code Tutor work with the "official" STM32_Arduino tool chain.

One other thing, possibility, even if you install Roger's tool chain, you may find some conflicts if you Arduino IDE has been around the block a few times.

There were "Multiple libraries were found for "Rotary.h". But, through some kind of built in magic in the Arduino IDE it determined which one it was going to use, and made the correct choice.

I have another EEPROM library from working with ESP32 boards. Arduino tries to use that one and causes problems. I copied Roger's eeprom library into the Morse Code Tutor code and that seems to help. If you haven't been messing with other boards/processors you shouldn't running unto this. 

This is kind of a blow by blow report. The finale is yet to come. 

Tom, wb6b


Tom, wb6b
 

On Sun, Jun 2, 2019 at 04:10 AM, jjpurdum wrote:
My guess is that Roger Clark has forgotten more about the STM32 than I'll ever know
Hi Jack,

Thanks for the addition information. Yes, it looks like Roger is a smart person. To be the force behind the STM32 chips on the Arduino platform as well as running his forum is quite an accomplishment. So, It definitely looks like Rogers's toolchain is solid and has a community of users behind it. I'm trying to be careful in how many toolchains I install in the Arduino IDE, but Roger's looks to be a worthwhile addition. 

Thanks for the information on the search paths for headers. What was interesting about the "Rotary.h" header was the Arduino IDE found both and specifically stated which one it choose to use and which it choose to ignore (rather than invisibility like you would expect if it was a pure search path mechanism). Suggesting some helpful extra magic in the Arduino IDE. For the eeprom library taking advantage of the search path and double quoting the header name should be the solution. 

I've been working with LoRa radios and IoT devices and just recently shifted to the STM32cube IDE for building with STM ARM chips. Had been using the Nordic chips, which I still like, but at the moment the platform seems to have become a cacophony of documentation and some tools bolted together in unclear ways. But, is is a really good chip set with built in Bluetooth and I'm not abandoning those chips, just expanding the number of chips I'm learning about.

Besides being an intriguing, fun project your Morse Code Tutor is came along as a perfect sized project to port to a different toolchain. In porting it I'm digging deeper into the workings of the Arduino IDE and the workings of the other STM32 toolchains than I would otherwise. With STM taking over Roger's work, I wonder if there will be some work at combing the best of the toolchains or providing a path from Roger's to the STM32Cube version of the Arduino toolchain. Roger's forum mentioned something about a version of his Arduino toolchain based on STM32CubeMX (which seems to have evolved into the current STM32Cube IDE). 

So besides helping me learn Morse code your Morse Code Tutor is helping me dig deeper into computer code. Which I believe is the idea of your project.

Tom, wb6b


jjpurdum
 

We're doing work with the Teensy 3.6, STM32F103, Arduino Nano family, and the ESP32. All of these work fine in the Arduino IDE, but there are some quirks. For example, with the ESP32 after a compile, but before the upload, I have to press the Reset button. However, using the same board, Al doesn't! We're both running the same IDE under Win 10. I don't understand...

Also, both the STM32 and the ESP32 have pins that "can't be used" for certain I/O functions. It appears that most STM boards don't even bring those pins out. However, the ESP32 does. I spent over a day figuring that one out. Still, the ESP32 brings A LOT to the resource table and it's becoming my goto board.

Yep, I really do hope to drag more hams into the programming realm of our hobby. Many are surprised at how much fun it is to get something...anything!....to do your bidding!

Jack, W8TEE

On Sunday, June 2, 2019, 6:56:22 PM EDT, Tom, wb6b <wb6b@...> wrote:


On Sun, Jun 2, 2019 at 04:10 AM, jjpurdum wrote:
My guess is that Roger Clark has forgotten more about the STM32 than I'll ever know
Hi Jack,

Thanks for the addition information. Yes, it looks like Roger is a smart person. To be the force behind the STM32 chips on the Arduino platform as well as running his forum is quite an accomplishment. So, It definitely looks like Rogers's toolchain is solid and has a community of users behind it. I'm trying to be careful in how many toolchains I install in the Arduino IDE, but Roger's looks to be a worthwhile addition. 

Thanks for the information on the search paths for headers. What was interesting about the "Rotary.h" header was the Arduino IDE found both and specifically stated which one it choose to use and which it choose to ignore (rather than invisibility like you would expect if it was a pure search path mechanism). Suggesting some helpful extra magic in the Arduino IDE. For the eeprom library taking advantage of the search path and double quoting the header name should be the solution. 

I've been working with LoRa radios and IoT devices and just recently shifted to the STM32cube IDE for building with STM ARM chips. Had been using the Nordic chips, which I still like, but at the moment the platform seems to have become a cacophony of documentation and some tools bolted together in unclear ways. But, is is a really good chip set with built in Bluetooth and I'm not abandoning those chips, just expanding the number of chips I'm learning about.

Besides being an intriguing, fun project your Morse Code Tutor is came along as a perfect sized project to port to a different toolchain. In porting it I'm digging deeper into the workings of the Arduino IDE and the workings of the other STM32 toolchains than I would otherwise. With STM taking over Roger's work, I wonder if there will be some work at combing the best of the toolchains or providing a path from Roger's to the STM32Cube version of the Arduino toolchain. Roger's forum mentioned something about a version of his Arduino toolchain based on STM32CubeMX (which seems to have evolved into the current STM32Cube IDE). 

So besides helping me learn Morse code your Morse Code Tutor is helping me dig deeper into computer code. Which I believe is the idea of your project.

Tom, wb6b


John P
 

A 10uF cap between EN and ground should eliminate the need to push the button. 
--
John P.
WA2FZW


Tom, wb6b
 

Yes the popular ESP32 chips are very good. When I first became interested in LoRa I bough some inexpensive LoRa boards based on that chip. I'm running a test LoRa gateway on one of those boards. This little inexpensive board has LoRa and WiFi because the ESP32 has WiFi (as well as Bluetooth) built in. That is cool. Also has Blue Tooth Low Energy which would allow iPhones to access/control the devices made with the chip.

In a past life I was an embedded microprocessor system programmer, before switching to designing and programming large systems that live in racks in dimly lit server farms. So I have that advantage in coming back to embedded processors, but still a learning curve catching up with the new devices and tools. But, learning is fun. I sure don't miss that smelly UV light for erasing eproms. Or the tedium of hand generating make files. 

Finally on your comments on eeprom to flash emulation libraries. I see, if done right, there is more than meets the eye to doing it. I'm happy the libraries have already been created by others. 

As per this App Note:
https://www.st.com/content/ccc/resource/technical/document/application_note/ee/ef/d7/87/cb/b7/48/52/CD00165693.pdf/files/CD00165693.pdf/jcr:content/translations/en.CD00165693.pdf

Tom, wb6b


Ken Bell
 

Hi Tom
I followed the medium.com link above and found issues with it.  Granted, I'm not a Python expert, but my system throws quite a few errors on the program stm32loader.py   I suspect that it was written in an earlier version of python. I was able to correct several of the print errors as these are quite simple, but some other function calls are beyond the scope fo what I'm doing. I may drop back and try something else while someone with more python experience tries to sort out the issues. ken


David Leckie
 

Running V1.8.9 of the Arduino IDE under Linux (Ubuntu 19.04).

All seems fine when using an Arduino Uno so IDE and USB port seem fine.

 

My STM32F103C8T6 has arrived, the header pins now soldered in place.

 

I started off with something pretty simple just to see if I could get “blink” to upload and run.

 

https://circuitdigest.com/microcontroller-projects/getting-started-with-stm32-development-board-stm32f103c8-using-arduino-ide

 

I am using this USB-TTL UART

https://www.ebay.co.uk/itm/USB-to-TTL-UART-Serial-Convertor-Module-CP2102-based-5Pin-5v-3-3v-UK-STOCK/333014805451?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2057872.m2749.l2649

 

I followed the instructions in the link above.

Generic STM32F103 series appears and is selected in boards manager – so far so good.

 

In “Port” /dev/ttyUSB1” appears and disappears when I power up/down the UART so I think I have the correct port in any case the other ports do nothing.

 

The above instructions do not say which upload method to select but after some research “Serial” seemed the obvious choice·

 

First problem:- Get Board Info gives

BN: Unknown board

VID: 10C4

PID: EA60

SN: Upload any sketch to obtain it

 

 

What should I get?

 

I then compiled the demo sketch from above tutorial.

It compiled fine.

 

Boot Jumper 0 in Programming mode. Green LED is Off.

 

When I try to upload I get the following error message.

 

Arduino: 1.8.9 (Linux), Board: "Generic STM32F103C series, STM32F103C8 (20k RAM. 64k Flash), Serial, 72Mhz (Normal), Smallest (default)"

 

Sketch uses 13160 bytes (20%) of program storage space. Maximum is 65536 bytes.

Global variables use 2456 bytes (11%) of dynamic memory, leaving 18024 bytes for local variables. Maximum is 20480 bytes.

Failed to init device.

stm32flash Arduino_STM32_0.9

 

http://github.com/rogerclarkmelbourne/arduino_stm32

 

Using Parser : Raw BINARY

An error occurred while uploading the sketch

Interface serial_posix: 115200 8E1

 

This report would have more information with

"Show verbose output during compilation"

option enabled in File -> Preferences.

 

Selecting verbose does not give any further information

 

I have been at this for several hours, wiring double checked. No progress.

 

Any suggestions appreciated.

 

73

Dave

GM4NFI


jjpurdum
 

Thanks, John! That did the trick. Does it work because of part of the message streams at startup?

Jack, W8TEE

On Sunday, June 2, 2019, 10:26:48 PM EDT, John P <j.m.price@...> wrote:


A 10uF cap between EN and ground should eliminate the need to push the button. 
--
John P.
WA2FZW


David Nelson
 

DAVE i HAVE THE SAME ERRORS ON MINT 19. i HAVE ALSO AN STLINKv2 AND CANNOT GET IT TO EVEN SEE THE PILL.
i HAVE BEEN FIGHTING THIS FOE THREE DAYS NOW AND HAVE JUST ABOUT WORE GOOGLE OUT. i SHURE HOPE 
SOMEONE KNOWS WHAT THE PROBLEM IS AND TAKES PITTY ON US.   dAVE  KC2IPX

On Mon, Jun 3, 2019 at 3:17 PM David Leckie <djcleckie@...> wrote:

Running V1.8.9 of the Arduino IDE under Linux (Ubuntu 19.04).

All seems fine when using an Arduino Uno so IDE and USB port seem fine.

 

My STM32F103C8T6 has arrived, the header pins now soldered in place.

 

I started off with something pretty simple just to see if I could get “blink” to upload and run.

 

https://circuitdigest.com/microcontroller-projects/getting-started-with-stm32-development-board-stm32f103c8-using-arduino-ide

 

I am using this USB-TTL UART

https://www.ebay.co.uk/itm/USB-to-TTL-UART-Serial-Convertor-Module-CP2102-based-5Pin-5v-3-3v-UK-STOCK/333014805451?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2057872.m2749.l2649

 

I followed the instructions in the link above.

Generic STM32F103 series appears and is selected in boards manager – so far so good.

 

In “Port” /dev/ttyUSB1” appears and disappears when I power up/down the UART so I think I have the correct port in any case the other ports do nothing.

 

The above instructions do not say which upload method to select but after some research “Serial” seemed the obvious choice·

 

First problem:- Get Board Info gives

BN: Unknown board

VID: 10C4

PID: EA60

SN: Upload any sketch to obtain it

 

 

What should I get?

 

I then compiled the demo sketch from above tutorial.

It compiled fine.

 

Boot Jumper 0 in Programming mode. Green LED is Off.

 

When I try to upload I get the following error message.

 

Arduino: 1.8.9 (Linux), Board: "Generic STM32F103C series, STM32F103C8 (20k RAM. 64k Flash), Serial, 72Mhz (Normal), Smallest (default)"

 

Sketch uses 13160 bytes (20%) of program storage space. Maximum is 65536 bytes.

Global variables use 2456 bytes (11%) of dynamic memory, leaving 18024 bytes for local variables. Maximum is 20480 bytes.

Failed to init device.

stm32flash Arduino_STM32_0.9

 

http://github.com/rogerclarkmelbourne/arduino_stm32

 

Using Parser : Raw BINARY

An error occurred while uploading the sketch

Interface serial_posix: 115200 8E1

 

This report would have more information with

"Show verbose output during compilation"

option enabled in File -> Preferences.

 

Selecting verbose does not give any further information

 

I have been at this for several hours, wiring double checked. No progress.

 

Any suggestions appreciated.

 

73

Dave

GM4NFI


David Nelson
 

Sorry about the caps. Damn caplock is in the wrong place.  Dave


On Mon, Jun 3, 2019 at 8:57 PM David Nelson <kc2ipx@...> wrote:
DAVE i HAVE THE SAME ERRORS ON MINT 19. i HAVE ALSO AN STLINKv2 AND CANNOT GET IT TO EVEN SEE THE PILL.
i HAVE BEEN FIGHTING THIS FOE THREE DAYS NOW AND HAVE JUST ABOUT WORE GOOGLE OUT. i SHURE HOPE 
SOMEONE KNOWS WHAT THE PROBLEM IS AND TAKES PITTY ON US.   dAVE  KC2IPX

On Mon, Jun 3, 2019 at 3:17 PM David Leckie <djcleckie@...> wrote:

Running V1.8.9 of the Arduino IDE under Linux (Ubuntu 19.04).

All seems fine when using an Arduino Uno so IDE and USB port seem fine.

 

My STM32F103C8T6 has arrived, the header pins now soldered in place.

 

I started off with something pretty simple just to see if I could get “blink” to upload and run.

 

https://circuitdigest.com/microcontroller-projects/getting-started-with-stm32-development-board-stm32f103c8-using-arduino-ide

 

I am using this USB-TTL UART

https://www.ebay.co.uk/itm/USB-to-TTL-UART-Serial-Convertor-Module-CP2102-based-5Pin-5v-3-3v-UK-STOCK/333014805451?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2057872.m2749.l2649

 

I followed the instructions in the link above.

Generic STM32F103 series appears and is selected in boards manager – so far so good.

 

In “Port” /dev/ttyUSB1” appears and disappears when I power up/down the UART so I think I have the correct port in any case the other ports do nothing.

 

The above instructions do not say which upload method to select but after some research “Serial” seemed the obvious choice·

 

First problem:- Get Board Info gives

BN: Unknown board

VID: 10C4

PID: EA60

SN: Upload any sketch to obtain it

 

 

What should I get?

 

I then compiled the demo sketch from above tutorial.

It compiled fine.

 

Boot Jumper 0 in Programming mode. Green LED is Off.

 

When I try to upload I get the following error message.

 

Arduino: 1.8.9 (Linux), Board: "Generic STM32F103C series, STM32F103C8 (20k RAM. 64k Flash), Serial, 72Mhz (Normal), Smallest (default)"

 

Sketch uses 13160 bytes (20%) of program storage space. Maximum is 65536 bytes.

Global variables use 2456 bytes (11%) of dynamic memory, leaving 18024 bytes for local variables. Maximum is 20480 bytes.

Failed to init device.

stm32flash Arduino_STM32_0.9

 

http://github.com/rogerclarkmelbourne/arduino_stm32

 

Using Parser : Raw BINARY

An error occurred while uploading the sketch

Interface serial_posix: 115200 8E1

 

This report would have more information with

"Show verbose output during compilation"

option enabled in File -> Preferences.

 

Selecting verbose does not give any further information

 

I have been at this for several hours, wiring double checked. No progress.

 

Any suggestions appreciated.

 

73

Dave

GM4NFI


Tom, wb6b
 

On Mon, Jun 3, 2019 at 11:21 AM, Ken Bell wrote:
I followed the medium.com link above and found issues with it
Hi, 

I just went through the process and was able to upload a blink sketch to a Blue Pill board. I'll describe what I did:
I did this on a Mac, so Linux should be similar. Windows should close enough to follow this instructions.

First I installed the "Arduino SAM Boards (Arduino Due board)"  from the "Boards Manager" under the Arduino IDE tools tab. 
Per these instructions: http://wiki.stm32duino.com/index.php?title=Installation

Then I downloaded Roger's additional set of board files from this link:
https://github.com/rogerclarkmelbourne/Arduino_STM32/archive/master.zip
NOTE: The above link will start the download of the zip file.

I unzipped the file and moved the directory to:
~/Documents/Arduino/hardware
I renamed the directory so the final name and part to the folder was:
~/Documents/Arduino/hardware/Arduino_STM32/

It took awhile for the Arduino SAM Boards package to install itself. Even after Arduino announced it was installed. So, be patient. 

I wired the Blue Pill board to a USB to serial adaptor board following these wiring instructions:
https://medium.com/@paramaggarwal/programming-an-stm32f103-board-using-usb-port-blue-pill-953cec0dbc86
I moved the "Boot 0" jumper on the Blue Pill board to the "1" position.
* See the attached photo of my setup to see my wiring and Boot jumper settings for programming. I used the same wire colors as in the above link.

I opened the standard Arduino Blink test sketch. Then I selected the following for the board:
Board: "Generic STM32F103C series"
Optimize: "Smallest (default)"
Upload method: "Serial"
Variant: "STM32F103C8 (20k RAM. 64k Flash)"
Port: "/dev/cu.SLAB_USBtoUART"

I did a "Verify" compile and that worked.

I plugged in the USB to Serial board, selected the USB serial port (as shown above) and clicked on the "Upload" button and the blink sketch loaded and ran.

After running I unplugged the USB connection from my laptop, I plugged it back in and the blink program did bot run. You need to move the "Boot 0" jumper back to the "0" position for the blink program to run after the first power cycle or pressing the reset button on the Blue Pill board.

OK, I hope that helps and I did not forget some important part of the process I went through.

Finally the USB to Serial board I used had a Silabs 2102 chip on it. Most other popular USB to Serial adaptors should work as well. For windows, the adaptor will likely show up as a COM port, rather than the UNIX like /dev/ device.

Tom, wb6b

-----

-----








Tom, wb6b
 

On Mon, Jun 3, 2019 at 05:57 PM, David Nelson wrote:
i HAVE ALSO AN STLINKv2 AND CANNOT GET IT TO EVEN SEE THE PILL
The ST-Link V2 creates a real USB device, rather than using a USB to Serial adaptor chip. So the ST-Link software should automatically connect to the ST-Link device. It will not show up as a serial port.

However, if you have a STM development board with a ST-Link V2-1 programmer/debugger built in, on the development board, that version of the ST-Link hardware will, in addition to the USB (not a serial port) channel to the ST-Link programming software, will create an additional USB to Serial port that is solely used for connection to one of the serial ports on the STM32F103 (or whatever other chip is being developed with) so you can send and receive print statements and get statement in your code through a terminal, such as the Arduino serial terminal.

Tom, wb6b