Bootloader - Page 1
Forum section: electronics / general

author: Kittu20
author_rank: Regular Contributor
timestamp: December 28, 2023, 01:11:46 pm
content: Has anyone here had experience into the development of bootloaders for microcontrollers? I am intrested to understand generic processI 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

author: coromonadalix
author_rank: Super Contributor
timestamp: December 28, 2023, 01:29:37 pm
content: https://electronics.stackexchange.com/questions/446389/why-do-we-need-a-bootloader-separate-from-our-application-program-in-microcontro

author: westfw
author_rank: Super Contributor
timestamp: December 28, 2023, 11:30:22 pm
content: 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.

author: GromBeestje
author_rank: Frequent Contributor
timestamp: December 29, 2023, 11:35:51 am
content: 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 asAtmelMicrochip 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.

author: Kittu20
author_rank: Regular Contributor
timestamp: December 29, 2023, 03:10:14 pm
content: 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?

author: Lindley
author_rank: Regular Contributor
timestamp: December 29, 2023, 03:48:03 pm
content: 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-bitNot 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

author: peter-h
author_rank: Super Contributor
timestamp: December 29, 2023, 04:41:01 pm
content: What are you trying to do? Take in serial data and program the CPU flash?

author: coromonadalix
author_rank: Super Contributor
timestamp: December 29, 2023, 06:37:48 pm
content: 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 interfacingbut normally once the chip is programmed, the bootloader is "put aside" and your program should worksome mcu goes over that, and the program is directly written and done in them with icsp, jtag, swd ... no bootloader required, everare you thinking, it act as an primary "os" ? and your program is executed ?? are you confusing it with linux boot processes in some of themi think you have mis conception of a few things, even i could have some

author: pickle9000
author_rank: Super Contributor
timestamp: December 29, 2023, 07:04:40 pm
content: You may also want to read up on how to use a watchdog timer.

author: Kittu20
author_rank: Regular Contributor
timestamp: December 29, 2023, 11:34:10 pm
content: Quote from: pickle9000 on December 29, 2023, 07:04:40 pmBootloader and watchdog timer are different topics. May I know the reasons why you suggested watchdog timer when I am asking help for bootloader

author: ejeffrey
author_rank: Super Contributor
timestamp: December 30, 2023, 01:02:40 am
content: 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.

author: westfw
author_rank: Super Contributor
timestamp: December 30, 2023, 01:04:16 am
content: QuoteWHICHPIC microontroller?It's likely to make a big difference. Some PICs will not support a bootloader at all.

author: Kittu20
author_rank: Regular Contributor
timestamp: December 30, 2023, 03:10:29 am
content: Quote from: westfw on December 30, 2023, 01:04:16 amI work with PIC18F45K80

author: eTobey
author_rank: Super Contributor
timestamp: January 03, 2024, 06:57:01 am
content: Here some Links, that helped me:https://developer.arm.com/documentation/ka002218/latest/https://akospasztor.github.io/stm32-bootloader/

author: fchk
author_rank: Frequent Contributor
timestamp: January 03, 2024, 10:26:22 am
content: Quote from: Kittu20 on December 28, 2023, 01:11:46 pmMicrochip has you covered:https://ww1.microchip.com/downloads/en/Appnotes/00851b.pdfAnd work has been done:https://tinypicbootload.sourceforge.net/