Author Topic: Bootloader  (Read 2149 times)

0 Members and 1 Guest are viewing this topic.

Offline Kittu20Topic starter

  • Regular Contributor
  • *
  • Posts: 96
  • Country: in
Bootloader
« on: December 28, 2023, 01:11:46 pm »
Has anyone here had experience into the development of bootloaders for microcontrollers? I am intrested to understand generic process

I find myself in a bit of a puzzle when it comes to bootloader for microcontrollers with no operating system. I know one traditional method of dumping code to memory. In this process I use programmer.  It seems bootloader is program that update or dump code into memory of microcontroller and we don't required programmer for this process
 


Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: Bootloader
« Reply #2 on: December 28, 2023, 11:30:22 pm »
A microcontroller bootloader is a short program that knows how to write the program memory of the microcontroller, and manipulate a communications channel to another device that provides the program to be written.  It then starts up the bootloaded program with the processor in a state that makes it (hopefully) undetectable that the bootloader was ever there.

This can involve special features of the micro.  For instance, for AVRs, only code specifically tagged as "bootloader" (by fuses) can write to the flash memory.

The "communications channel" can vary - Serial and USB are popular, but some bootloaders will do things like copy from an SPI flash chip into executable RAM.
 

Offline GromBeestje

  • Frequent Contributor
  • **
  • Posts: 280
  • Country: nl
Re: Bootloader
« Reply #3 on: December 29, 2023, 11:35:51 am »
What are your desired features?
One thing, of course, it to load the firmware. It might check the validity of the firmware.
Basic checks whether the data appears to be firmware data, checking CRC, or even cryptographic signatures.

Otherwise, updating said firmware. One question is where the updates come from.
Are you updating over UART, I²C, SPI? Perhaps something like USB, Bluetooth or downloading it from the internet for WiFi or cellular capable devices.
Are you using a single bank, overwriting the existing firmware, or a dual bank solution, first writing it to a different flash region prior to overwriting the firmware.
A dual bank solution would be more robust to update interruptions/failures, at the cost of requiring double the flash.

Also, in case of dual bank, who is responsible of getting the firmware into the update region of flash. Does the bootloader do this task, or is it the task of the application, and then handing it over to the bootloader. Or both, in the usual flow the application prepares the update, but the bootloader has a recovery mode.

Also, consider the features of the target microcontroller architecture. An ARM Cortex M3 (usually)  has a relocatable vector table, meaning you can set the location of the firmware's vector table in the bootloader. However, a ARM Cortex M0 has not. This means you'll have to do interrupt redirection inside your bootloader. (Note: some manufacturers have custom redirection in their M0 implementation).

Many microcontrollers start executing from the beginning of flash, meaning, once a bootloader is used, the firmware has to be placed on a different location is flash. This also means, the firmware cannot run without the bootloader being present. On some architectures, such as Atmel Microchip AVR, therre is a fuse (their name for persistent settings register), where a location for the bootloader can be set, such that the location of the firmware does not change.

 

Offline Kittu20Topic starter

  • Regular Contributor
  • *
  • Posts: 96
  • Country: in
Re: Bootloader
« Reply #4 on: December 29, 2023, 03:10:14 pm »
I've been working with the PIC microcontroller without a bootloader, using an ICSP programmer (PK3) connected to the host PC and plugged into the ICSP header pins on the microcontroller PCB board.

I'm now interested in transitioning to using a bootloader. Could you please provide guidance on what is needed and the process for developing a bootloader for the PIC microcontroller?
 

Offline Lindley

  • Regular Contributor
  • *
  • Posts: 195
  • Country: gb
Re: Bootloader
« Reply #5 on: December 29, 2023, 03:48:03 pm »
For Pic have a look here  and Search for the many other pages of bootloader details that can be found on Microchips site.
https://www.microchip.com/en-us/tools-resources/develop/libraries/microchip-bootloaders/8-bit

Not something we ever used on our Pic projects, but consider that the are only a small number of such Pic bootloaders around or in use,  why ?   when most folk use Pickit or similar programmers  ??

Yet for many for other micros like Arduino, ESPs, Teensy they all typically use Bootloaders programmed in by the board /chip manufacturers, again lots of info of how that can be done yourself.
https://docs.arduino.cc/built-in-examples/arduino-isp/ArduinoISP

 

Offline peter-h

  • Super Contributor
  • ***
  • Posts: 3698
  • Country: gb
  • Doing electronics since the 1960s...
Re: Bootloader
« Reply #6 on: December 29, 2023, 04:41:01 pm »
What are you trying to do? Take in serial data and program the CPU flash?
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Offline coromonadalix

  • Super Contributor
  • ***
  • Posts: 5906
  • Country: ca
Re: Bootloader
« Reply #7 on: December 29, 2023, 06:37:48 pm »
the bootloader on some avr mcu etc ... will act if you set it to activate, in some case dip switch or jumpers,  it may or will help programming and mostly do the interfacing

but normally once the chip is programmed, the bootloader  is "put aside"  and your program should work

some mcu goes over that, and the program is directly written and done in them with icsp, jtag, swd   ...  no bootloader required, ever

are you thinking, it act as an primary "os" ?  and your program is executed ?? are you confusing it with linux boot processes in some of them

i think you have mis conception of a few things,  even i could have some


 

Offline pickle9000

  • Super Contributor
  • ***
  • Posts: 2439
  • Country: ca
Re: Bootloader
« Reply #8 on: December 29, 2023, 07:04:40 pm »
You may also want to read up on how to use a watchdog timer.
 

Offline Kittu20Topic starter

  • Regular Contributor
  • *
  • Posts: 96
  • Country: in
Re: Bootloader
« Reply #9 on: December 29, 2023, 11:34:10 pm »
You may also want to read up on how to use a watchdog timer.

Bootloader and watchdog timer are different  topics. May I know the reasons why you suggested watchdog timer when I am asking help for bootloader
 

Offline ejeffrey

  • Super Contributor
  • ***
  • Posts: 3719
  • Country: us
Re: Bootloader
« Reply #10 on: December 30, 2023, 01:02:40 am »
Normally a bootloader checks some condition at startup -- perhaps a GPIO, or waits for serial data within X seconds.  It may check other things such as a CRC or successful boot flag.  If the signal is present, it enters "program update" mode, if not it jumps to the target program.  It might also select between multiple programs such as a known good vs new image.

What those signals are, and how program update mode work depend on your application.

This is the normal use of bootloaders in flash based microcontrollers.  In processors that execute from RAM, the bootloader might actually copy the executable image from storage to RAM.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: Bootloader
« Reply #11 on: December 30, 2023, 01:04:16 am »


Quote
please provide guidance on what is needed and the process for developing a bootloader for the PIC microcontroller?




WHICH PIC microontroller?
It's likely to make a big difference.  Some PICs will not support a bootloader at all.


 

Offline Kittu20Topic starter

  • Regular Contributor
  • *
  • Posts: 96
  • Country: in
Re: Bootloader
« Reply #12 on: December 30, 2023, 03:10:29 am »


WHICH PIC microontroller?
It's likely to make a big difference.  Some PICs will not support a bootloader at all.

I work with PIC18F45K80
 

Offline eTobey

  • Frequent Contributor
  • **
  • Posts: 557
  • Country: de
Re: Bootloader
« Reply #13 on: January 03, 2024, 06:57:01 am »
"Sometimes, after talking with a person, you want to pet a dog, wave at a monkey, and take off your hat to an elephant." (Maxim Gorki)
 

Offline fchk

  • Regular Contributor
  • *
  • Posts: 245
  • Country: de
Re: Bootloader
« Reply #14 on: January 03, 2024, 10:26:22 am »
Has anyone here had experience into the development of bootloaders for microcontrollers? I am intrested to understand generic process

Microchip has you covered:
https://ww1.microchip.com/downloads/en/Appnotes/00851b.pdf

And work has been done:
https://tinypicbootload.sourceforge.net/
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf