Bootloader Flashing Instructions

STM32duino bootloader aka Maple bootloader
Post Reply
C_D
Posts: 62
Joined: Mon May 11, 2015 3:27 am
Location: New Zealand

Bootloader Flashing Instructions

Post by C_D » Wed Jul 08, 2015 2:21 am

Just as a quick test I had a bit of a google and a search around the forum and I can't find a place where the instructions for flashing the bootloader are stated. There are some mentions in threads, and a few hints in the youtube video, but there doesnt seem to be a 'go to' set of instructions.

I think the instructions for flashing the generic bootloader (or a link to them) probably should be on the main page of the git repo, or in the wiki (which looks like is under way). And there probably should be a link across from the Arduino_STM32 git repo as well depending on which bit a new user stumbles into first.

I'm not sure what the procedure is for other boards (I know there's a few variations) but for my 'blue pill' board and working under windows the instructions are something like:

Connect USB-Serial adapter as described here: https://www.youtube.com/watch?v=G_RF0a0hrak
Set BOOT0 high and BOOT1 low.
Press reset.
Open a command window and run:
Arduino_STM32\tools\win\stm32flash.exe -w [path\to\generic_boot20_pc13.bin] [COM_PORT]

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

Re: Bootloader Flashing Instructions

Post by RogerClark » Wed Jul 08, 2015 3:04 am

@C_D

There is already a page in the wiki about the stm32duino bootloader which includes how to flash it

https://github.com/rogerclarkmelbourne/ ... bootloader

I think the problem is that the forum is a forum and not necessarily a good way to present information.

I could put a start here section, but I can't guarantee that people will read it.

I probably need to do an accompanying website which just contains blog style postings, as part of the same domain and move this to forum.stm32duino.com but I don't really have time to do that at the moment, as there are still quite a few technical issues that need to be resolved e.g. STM32Flash doesnt work for FDTI adaptors on OSX, so I need to fix this so that those OSX users can flash the bootloader

Ideally, we could flash the bootloader via the menu in the IDE, but there is precious little documentation on how to set this up.
I think we need a file called programmers.txt, but I'm not sure what would go in it, in order for the burn bootloader to work, additionally, we'd need a way to select which bootloader to use, as there are lots of them.

I will email the IDE developers mailing list to see if anyone knows where I can find some docs about this

C_D
Posts: 62
Joined: Mon May 11, 2015 3:27 am
Location: New Zealand

Re: Bootloader Flashing Instructions

Post by C_D » Wed Jul 08, 2015 3:23 am

Hey, there it is!

Somehow I failed to find that page when I searched. Does google search inside the git wikis? I guess its not going to come up in search results anyway until people start finding it and getting some traffic there.

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

Re: Bootloader Flashing Instructions

Post by RogerClark » Wed Jul 08, 2015 3:28 am

@C_D

I honestly don't remember writing it, but it was there when I looked, so I must have written it ;-)

I also wrote quite a detailed readme in the stm32duino-bootloader repo, but that was for people who wanted to rebuild it or add new build targets eg. boards with LEDs and buttons on different pins

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

Re: Bootloader Flashing Instructions

Post by mrburnette » Wed Jul 08, 2015 12:52 pm

C_D wrote:Hey, there it is!

Somehow I failed to find that page when I searched. Does google search inside the git wikis? I guess its not going to come up in search results anyway until people start finding it and getting some traffic there.

YES, you can search directly from Google for the STM32 information, in this case Roger's github site:
https://www.google.com/#q=stm32%2Bflash ... kmelbourne
I probably need to do an accompanying website which just contains blog style postings, as part of the same domain and move this to forum.stm32duino.com but I don't really have time to do that at the moment, as there are still quite a few technical issues that need to be resolved e.g. STM32Flash doesnt work for FDTI adaptors on OSX, so I need to fix this so that those OSX users can flash the bootloader
Roger, I think this may be a poor use of your time. We have the forum, we have your github account, we have the Wiki. Another website, IMO, is only going to cause discourse in trying to keep sites coordinated with the same information.

Just a bit of recent history for everyone:
Sometime during the 9 months of life this project has lived, a statement was made about the numerous boards and the Arduino support of same. The summary of this discussion was that this STM32 initiative was a corroborative endeavor - a core set of boards would be built from those within the group and new boards would be introduced but that labor intensive tasks such as pin-mappings would require the purchaser of said new board(s) to work to complete the effort by modifying the closest working board pin-maps.

I know that many members here have dedicated a lots of time to get us where we are today. However, as the forum grows, we need to have everyone understand that the work effort must be shared among us all. While I personally believe Roger is a superhuman individual, he is still only one person and cannot undertake every need. If we need more documentation, then please feel free to author same; even if you are a newbie, your write-up and point of view may be just what is needed to keep the documentation simple and easy to understand. But, read on...

I think what most people really want are examples that run. Victor_pv, Strawberrymaker, madias and many others have posted within the forum excellent examples. I did a small series for beginners which found it way into the Examples of the ZIP download. We have examples for ILI9341, BMP180, OLED, etc. :mainstream stuff many can utilize. But there can never be too many examples, so for those members that have been reading and following along, feel free to add your projects - there is a Projects section in the Forum.

Ray
My stuff: http://www.hackster.io/rayburne

hmeijdam
Posts: 3
Joined: Tue Dec 01, 2015 9:54 pm

Re: Bootloader Flashing Instructions

Post by hmeijdam » Wed Dec 02, 2015 8:20 pm

It took me a couple of hours to figure this out as I have the STLink dongle hooked up to a generic STM32F103C...

I first attempted to use the STM32 STLINK UTility that comes with the STLink driver from STM. That tool connected to my STM32 just fine, and I could also load the binary bootloader file for my board in it (mine has the led on PC13).
https://github.com/rogerclarkmelbourne/ ... 1/binaries

But as soon as I tried to erase the chip or load something I got an error "The elf loader file is not accessible".
By accident I saw a post where stm32flash.exe was mentioned, and once I found that was stored in the ARDUINO_STM32-master\tools\win folder I also saw the "stlink_upload.bat" command file.
For some reason the dos box command "stlink_upload.bat generic_boot20_pc13.bin" did not work, but after I shortened the filename to bootl.bin and I just entered the command " stlink\ST-LINK_CLI.exe -c SWD -P bootl.bin 0x8000000 -Rst -Run "

Bingo !!

The DFU driver was installed and now I have a perfect working bootloader on my STM32F103C...

Loads sketches faster and I have serial communication.

Test sketch that I used

Code: Select all

void setup() {
//  Serial.begin(9600); // Uncomment if needed by boards using hardware serial via a USB to Serial adaptor
  pinMode(PC13, OUTPUT);
}

void loop() {
  digitalWrite(PC13, LOW); // set the LED on
  Serial.println("Hello from STM32F103C8T6, I am alive and kicking !!!");
  delay(25);
  digitalWrite(PC13, HIGH); // set the LED off
  delay(1000);
}
Very happy so far.

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

Re: Bootloader Flashing Instructions

Post by RogerClark » Wed Dec 02, 2015 9:00 pm

Hi

FYI.

Those Windows bat files are used by the IDE and expect to be passed various parameters, hence why it didnt work when you just passed the file name.


Btw

I have no idea why STMs Stlink program didnt work. But thats outside of our control.


Anyway, Im glad its now working for you

zmemw16
Posts: 1484
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: Bootloader Flashing Instructions

Post by zmemw16 » Wed Dec 02, 2015 9:58 pm

as an almost non-non-non-windows user i ain't doing this :D
what might be seriously useful would be an idiots guide to generating a PR and what you need in it.

thinking very hard as to what i actually do 'do' in XP, aaahhh - reading a book via kindle cloud, it's easier than flitting from kindle to screen and back.

anyone got a BSOD for no arguments on command line? defaults to a usage output line.

googling 'batch file argument count' yields

http://www.testdeveloper.com/2010/09/26 ... nt-page-1/

and it has this as code

Code: Select all

@echo off

set _exitStatus=0
set _argcActual=0
set _argcExpected=2

echo.

for %%i in (%*) do set /A _argcActual+=1

if %_argcActual% NEQ %_argcExpected% (

  call :_ShowUsage %0%, "Bad human...bad args."
  
  set _exitStatus=1
  
  goto:_EOF
)

REM Your code goes here

goto:_EOF

:_ShowUsage
  
  echo [USAGE]: %~1 arg1 arg2

  echo.
  
  if NOT "%~2" == "" (

    echo %~2
    
    echo.
  )
  
  goto:eof

:_EOF
 
echo The exit status is %_exitStatus%.

echo.

cmd /c exit %_exitStatus%


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

Re: Bootloader Flashing Instructions

Post by mrburnette » Thu Dec 03, 2015 1:59 pm

hmeijdam wrote:<...>I also saw the "stlink_upload.bat" command file.
For some reason the dos box command "stlink_upload.bat generic_boot20_pc13.bin" did not work, but after I shortened the filename to bootl.bin and I just entered the command " stlink\ST-LINK_CLI.exe -c SWD -P bootl.bin 0x8000000 -Rst -Run "

Bingo !!
Google is rich with result from searching the terms 'failure longfile name batch' ...
So, it is always best to work with 8.3 format filenames when in the command shell.

Ray

Post Reply