cancel
Showing results for 
Search instead for 
Did you mean: 

Usefulness of a bootloader

matic
Associate III
Posted on September 06, 2016 at 19:35

Hi.

I would really like to understand why bootloader is useful for? I read the document below, but still didn't get the point.

http://www.st.com/content/ccc/resource/technical/document/application_note/b9/9b/16/3a/12/1e/40/0c/CD00167594.pdf/files/CD00167594.pdf/jcr:content/translations/en.CD00167594.pdf

Could anyone please explain in which cases bootloader is useful and briefly describe how to use it. I would be very grateful...

Matic
13 REPLIES 13
Posted on September 06, 2016 at 19:55

Quoting from that appnote:

 Its main task is to download the application program to the internal Flash memory through one of the available serial peripherals (USART, CAN, USB, I 2 C, SPI, etc.).

 

 

In other words, you can burn the mcu through USART, CAN, USB etc., e.g. from a ''master'' mcu.

JW
Posted on September 06, 2016 at 20:10

I can program blank chips on fully built boards with hardware that costs less the $5

I don't have to buy parts preprogrammed and solder them to the board. Or manage such in inventory, which helps if I use the same part in multiple designs.

I can change the software up until the time of final test.

I can program serialization and calibration data in during test.

I don't need several hundred dollars of JTAG gear, libraries, and significantly more complex software.

I can replicate the programming set up easily to scale as required.

I'm imaginative and can think through problems and solutions..

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
matic
Associate III
Posted on September 06, 2016 at 20:29

Thank you both.

If I am correct, it is also possible to read Flash memory in that mode (via UART, USB,... depends on a part). But is it possible to read Flash also if RDP Level 1 protection is set?

christoph2399
Associate II
Posted on September 06, 2016 at 21:36

--- delete me ---

christoph2399
Associate II
Posted on September 06, 2016 at 21:39

yes you can read and write flash. level one denies access via jtag and/or sw.

it's a backdoor, so you have to take security in your hands.

i rather use my own bootloader because i can encrypt the firmware and give it to the costumer to program in the development phase. so i don't have to exchange all the time a hardware with the latest firmware.

if you don't care about encryption you could use the rom-bootloader which is already on some stm32 devices
Posted on September 06, 2016 at 22:09

> yes you can read and write flash. level one denies access via jtag and/or sw.

>

> it's a backdoor, so you have to take security in your hands.

Can you please be more specific? In which device, which interface/protocol and which version of BL were you able to read out a Level1-RDP'd device?

JW

christoph2399
Associate II
Posted on September 07, 2016 at 08:14

i would advice you to read the flash-programming manual of your device. quote out of ''mine''

When the read protection Level 1 is set:

 

– No access (read, erase, program) to Flash memory or backup SRAM can beperformed while the debug feature is connected or while booting from RAM orsystem memory bootloader. A bus error is generated in case of read request.

 

– When booting from Flash memory, accesses (read, erase, program) to Flashmemory and backup SRAM from user code are allowed.
matic
Associate III
Posted on September 08, 2016 at 10:01

Ok, I am not sure, if I understand this right.

When booting from System memory, those embedded protocols like UART, USB,... are ''automatically'' available and configured. But it is not possible to read Flash over these protocols with  Level 1 protection.

Booting from Flash is actually a normal type of booting. There, those embedded protocols are not configured (unless user application configures them). Although, when booting from Flash, it is possible to read Flash with Level 1 protection, I have to configure a protocol for that by myself.

jpeacock23
Associate II
Posted on September 08, 2016 at 15:31

Bootloaders have a place but aren't always necessary.  We've had this debate where I work.  Our solution is to put as much as possible into the application, and only use a custom bootloader if necessary.

We use 'L152 and 'L475 parts.  All our boards have a JTAG, so we don't need to use the system bootloader to load code.  We do over-the-air firmware updates through radios, so the system bootloader doesn't help at all there either. 

For the 'L475, which has a dual flash bank with hardware address remapping we don't use a bootloader.  Firmware updates load into the alternate bank, address is remapped and booted to new image.  All the download and verification logic is in the app, so the update process shares the code needed for data transfers, no extra work on our part to handle image downloads.  That reduces development costs.

For the 'L152 we do have a small, 1KB bootloader that transfers flash bank 2 to flash bank 1 if EEPROM flags are set.  The image is downloaded as part of the app, which keeps the bootloader very simple.  The 'L152 also has dual flash banks but doesn't have the address remap option, so we have to transfer the image to the first bank in order to start it.

For hobbyist, yeah, the system bootloader saves the cost of a JTAG, but how do you debug the code if you don't have a JTAG pod?  There are very cheap JTAGs, saving a few dollars by using the loader wastes a lot of time and guarantees programmer frustration at guessing what went wrong without a clue where to start.

For commercial use we prefer to download the initial firmware image on the production line through JTAG, faster and more reliable.  We disable the system bootloader in hardware, though we do keep a jumper option just in case.  We have stringent requirements to verify the integrity of downloaded images in the field and can't rely on the system bootloader protocol.  Our equipment is at remote locations and very expensive to service; we can't risk bricking it with a bad or incomplete update.

  Jack Peacock