How to build the bootloader?

STM32duino bootloader aka Maple bootloader
navintiwari08
Posts: 16
Joined: Sat Aug 22, 2015 3:54 pm

How to build the bootloader?

Post by 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
Posts: 1449
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: How to build the bootloader?

Post by 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

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

Re: How to build the bootloader?

Post by 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
Posts: 16
Joined: Sat Aug 22, 2015 3:54 pm

Re: How to build the bootloader?

Post by 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.

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

Re: How to build the bootloader?

Post by 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
Posts: 16
Joined: Sat Aug 22, 2015 3:54 pm

Re: How to build the bootloader?

Post by 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

User avatar
ahull
Posts: 1627
Joined: Mon Apr 27, 2015 11:04 pm
Location: Sunny Scotland
Contact:

Re: How to build the bootloader?

Post by 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
Thanks navintiwari08, that's very useful. We now have a schematic for the "Ugly board". It even shows the zero ohm resistor between VBat and 3v3. If only I had found that *before* I fitted the battery to that board, I could have saved myself some pyrotechnics. :oops:
- Andy Hull -

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

Re: How to build the bootloader?

Post by 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
Posts: 62
Joined: Mon May 11, 2015 3:27 am
Location: New Zealand

Re: How to build the bootloader?

Post by 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
Posts: 62
Joined: Mon May 11, 2015 3:27 am
Location: New Zealand

Re: How to build the bootloader?

Post by 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:

Code: Select all

export PATH=$PATH:~/opt/gcc-arm-none-eabi-4_8-2014q3/bin
make generic-pc13
The references to performing the build in your Arduino sketch folder may allow you to use the compiler already installed along with the Arduino software, however this didn't apply to me as I was building on a Linux machine which did not have the Arduino software installed.

Note that there is active discussion about changing the build process so this will almost certainly change in the future:
https://github.com/rogerclarkmelbourne/ ... /issues/17

Post Reply