How to build the bootloader?

navintiwari08
Sat Aug 22, 2015 4:34 pm
Hi!! this is Navin. I’ve worked with 8 bit micro controllers including PIC, 8051 and AVRs(with Arduino). I really wanted to start something with arm cortex m3. So I got a generic stm32f103x board and was looking for a way to use it with Arduino. In the description it says that stm32duino bootloader makes use of pin PC14(used for DFU if this pin goes high at boot time). The board that I have uses stm32f103c8t6 mcu and pin PC14 is the OSC i/p for 32768Hz resonator. Now, I know this can be changed in the bootloader so that the “button” can be made to use some other pin. I’m new to understanding bootloaders and their structure and if its not too much, could anybody please tell me how do I rebuild(compile) this bootloader with small changes in pin definitions and where to get the required files and tools. Basically, I want to know the steps to build the bootloader myself from its C and header files and where to get them. Thanks for your time!

keep it burning
-Navin


zmemw16
Sat Aug 22, 2015 6:06 pm
need to pull and install Arduino_STM32 first? nope it builds standalone, good idea though
https://github.com/rogerclarkmelbourne/Arduino_STM32

expand the zip under ~/sketchbook_stm32/hardware
i have separate sketchbook directories for avr and stm32; ./.arduino15 is another matter….

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

pull the zip & expand at the ~/sketchbook_stm32/hardware/Arduino_STM32/STM32duino-bootloader/ level
should give you a README.md file and a STM32F1 directory

cd ~/sketchbook/hardware/Arduino_STM32/STM32duino-bootloader/STM32F1
add a section into config.h as/if required, following the template in config.h

add a target into the Makefile again following the template in there

make clean && make generic-pz4 :-)

or for all on a linux platform
for i in a1 a9 b9 c13 d1 d2 e2 e5 g15;do make clean && make generic-p$i;done

no doubt this will corrected as required:-)

wiki?? has more details??

stephen


RogerClark
Sat Aug 22, 2015 9:42 pm
I tried to put a lot of detail in the readme of the stm32duino-bootloader, please take a look at that first.

On windows you need to install Make? I have WinAVR installed, which installed Make. This may be the easiest way to get Make.

For new targets you need to change the Makefile, there is a line you need to add for your new target and you also need a new rules section to tell Make how to build the new target.
But if you look at the Makefile, its pretty simple to see what you need to add, i.e just copy and change one line for the target and copy and change the last block of runs for another target.

Then you just need to add another ifdef block in config.

Note. Button is optional, and also note you ca configure if the button pressed state is Logic High or Low


navintiwari08
Sun Aug 23, 2015 3:07 pm
I’ll try it out as suggested by you guys. Will revert back in case I get stuck. Meanwhile, this is the generic board that I have. I also have stm nucleo L152RE board that I’m using with Keil to learn more about cortex m3 programming. Here is the generic board I mentioned.

Image

It has only one LED “D1” which is connected between Vcc and GND through a resistor. Just wanted to put it out. Any info regarding this is welcomed.


RogerClark
Sun Aug 23, 2015 8:52 pm
I have the same board, but it has many problems.

I think it does not have the 1.5k pullup resistor on USB D+, also it seems to have some startup issues.
Most of these boards, you can upload via serial and run the sketch, but if you change to boot link and try to run straight after powerup, it doesnt work.

Well, some boards run the code straight after booting, but most dont.

I suspect faulty manufacturing or bad hardware design


navintiwari08
Mon Aug 24, 2015 5:22 pm
I found a .pdf file containing the schematic of the stm32 mini board. Also checked with a multi-meter, the USB D+ has a 1.5k pull up. Look for jumper P2 and resistor R13. Here’s how USB D+ is pulled up.. Usbd+>R11>P2>R13>3.3V. Resistor R11 is around 22 ohms. I think its to limit the current from usb port on board. Here is the file. Hope it helps in some way. http://www.sunspot.co.uk/Projects/Ardui … iagram.pdf

ahull
Mon Aug 24, 2015 8:28 pm
navintiwari08 wrote:I found a .pdf file containing the schematic of the stm32 mini board. Also checked with a multi-meter, the USB D+ has a 1.5k pull up. Look for jumper P2 and resistor R13. Here’s how USB D+ is pulled up.. Usbd+>R11>P2>R13>3.3V. Resistor R11 is around 22 ohms. I think its to limit the current from usb port on board. Here is the file. Hope it helps in some way. http://www.sunspot.co.uk/Projects/Ardui … iagram.pdf

RogerClark
Mon Aug 24, 2015 9:34 pm
22 ohms on USB lines is normal.

Looking at the schematic, I cant see any obvious reasons why these boards dont seem to work.

Perhaps the crystals or the oscillator caps are defective.

All I know is that several people have these boards, but quite often they dont work correctly and seem to have startup problems, even after pressing reset


C_D
Thu Aug 31, 2017 2:35 am
I know this is a really old thread, but are these instructions still correct for building the bootloader? Is placing files in the Arduino folder necessary, it doesn’t seem that any part of the Arduino system is used to build it.

Can anyone give me a run down on setting up a minimal toolchain? From the bat scripts I assume the intention is that it builds under Windows. I have read the README on the github page but there isn’t any info I can see on actually getting the toolchain installed.

Currently I get:

The system cannot find the path specified.
mkdir -p build/stm32_lib
The syntax of the command is incorrect.
make: *** [begin] Error 1

EDIT:
As far as I can seen mkdir on windows does not support a -p flag, which implies the makefile has to be run under linux, but then the presence of the .bat files confuses me…


C_D
Mon Sep 04, 2017 3:13 am
For anyone who reads this thread in the future, the makefile only works under Linux, the .bat files don’t seem to be part of the build process any more. Also make sure you have the gcc-arm-none-eabi-4_8-2014q3 compiler in your path somewhere. To avoid putting the compiler in the path permanently I did this with the short script below:

export PATH=$PATH:~/opt/gcc-arm-none-eabi-4_8-2014q3/bin
make generic-pc13


RogerClark
Mon Sep 04, 2017 5:20 am
The makefile works OK under windows as long as you have make installed

You need to have gcc-arm installed and in your path.

The binaries that are in github were compiled using gcc 5.4 2016q2, but older versions of the compiled used to work OK (as I originally use the same compiler that the Arduino IDE uses i.e 4.8.4-2014q1


C_D
Mon Sep 04, 2017 8:01 pm
I had make installed in Windows, it was all the folder shuffling that failed for me. The makefile has mkdir with a -p flag which doesn’t work on my Windows and also rm for deleting files.

RogerClark
Mon Sep 04, 2017 9:43 pm
I normally use the github command line client as a shell when building.

You could try using the windows power shell


C_D
Mon Sep 04, 2017 10:27 pm
Ah, yeah that might do it.

No worries, I’m all set up to compile it under Linux now and it seems to work OK :)


RogerClark
Mon Sep 04, 2017 10:33 pm
BTW

I’ve not double checked, but your hex value looks wrong

The value I get is

0x0050400

How did you calculate the value you are using ?

Did you merge the bit pattern (0x1 << 18) so that no other bits apart from those from bits 18 to 22 were affected ?


seniman
Tue Nov 20, 2018 9:53 am
Hello everyone,

I plan to make custom bootloader for STM32 which will read winbond flash.
The starting problem is building STM32 bootloader.
I have long read for this https://github.com/rogerclarkmelbourne/ … bootloader and discussion here https://www.stm32duino.com/viewtopic.php?p=33961.

But I still can’t find out how to build the bootloader.
I am on Windows 10 OS.
Where I should download the GCC ? Maybe here https://launchpad.net/gcc-arm-embedded/ … -q2-update ? or maybe here https://gcc.gnu.org/releases.html ?
Or maybe the GCC is part of Eclipse MCU https://github.com/gnu-mcu-eclipse/arm- … c/releases ?

And then where also should download the Make ?
Or is it automatically exist when I install the GCC ?

I have downloaded GCC 4.8.1 from https://gcc.gnu.org/releases.html, but all of content is C code, I don’t know how to execute.
I also have downloaded the Eclipse and all of its build toolchain, but I think this is not the correct method used to compile the bootloader.
I am now downloading https://launchpad.net/gcc-arm-embedded/ … -q2-update, but not yet completed since my home internet connection is very poor.

Anyone please help me.

thank you.


mrburnette
Tue Nov 20, 2018 4:08 pm
Obviously, review this thread from start to end, then continue here:
http://wiki.stm32duino.com/index.php?title=Bootloader

Leave a Reply

Your email address will not be published. Required fields are marked *