Generally, when you want to program a microcontroller, you need a programmer for that particular microcontroller. Apart from being expensive, it might have other disadvantages, like long programming times or too many interconnections between the micro and the programmer itself; some programmers are not capable of programming in circuit. Sometimes the micro is not available while mounted in the end product, as it might be inside a metal or plastic housing, with only some standard communications interfaces being available on a connector.
Many of these problems are addressed by a bootloader. For a hobby, sometimes it seems quite expensive to spend tens of euros (and sometimes hundreds of euros) for such a device. In university laboratories, it might not be practical to get a programmer for each working bench, and the best solution is to provide the students with microcontroller samples which have already been programmed once and which have the Bootloader in the program memory. In the automotive industry, many Electronic Control Units are encapsulated in housings leaving very few pins accessible, but among these pins there generally is a CAN interface available, making CAN based Bootloaders very popular in this environment.
So, the Bootloader has to be programmed in the program memory of the microcontroller just once, using a conventional programmer. After this, the microcontroller can be programmed without a programmer. Once in the microcontroller, the bootloader is such programmed that each time after reset it starts running like any conventional program. What it does however is different from a regular program. First of all, depending on what type of bootloader it is, it starts “listening” for incoming bytes via a specific interface. For instance, a UART bootloader will listen to the UART buffer of the micro, checking for incoming bytes. If the bytes start arriving, the bootloader will grab them and write them in the program memory in the sequence it receives them and at predefined locations. Once all bytes have been received, the bootloader executes a jump at the start of the memory zone it has received and then the “normal” program starts running.
This is how a normal program would be programmed in the 8 Kbyte memory of a micro:
So the general steps in a working bootloader are:
- Step 1 – right after reset, the bootloader takes over and executes a jump to the memory area where its own code exists. The code existing there starts to listen the chosen external interface for incoming data.
- Step 2 – the incoming data is written in the program memory as it would be written by a programmer, except for the first few bytes, which would normally be burned at the reset vector.
- Step 3 – once the entire incoming data has been written, the bootloader executes a jump at the first instructions of the regular program.
Now let’s say a word about the type of bootloaders.
The most common one used to be the UART bootloader. This meant that after each reset the micro would start to listen to the UART interface for the incoming data. They are still widely used today as it is a common interface for many microcontrollers. This type of bootloader basically removes the need for a programmer. You only need a PC software (cheap and easy to make/find) and a serial cable, provided the UART interface is used by the micro anyway. Gradually, after the appearance of USB interfaces on micros, the USB bootloader came into existence. It performs the same functions and is pretty handy to use.
Another more special type of bootloader is the SPI/I2C bootloader. Basically, the way it works is similar to any bootloader, but instead of listening to UART/USB it tries to read data from an attached EEPROM memory with an I2C or SPI interface. This bootloader is designed for allowing easy upgrade of software in the field. You could attach the SPI memory in a socket, and a firmware change might mean as little as changing an IC in a socket. Of course in order to do this, you need to have physical access to the EEPROM in question.
The CAN bootloader is extensively used in the automotive industry. Most of the devices to be found in a car have a CAN port nowadays, which is accessible at two pins on a connector. Due to this fact, bootloaders that work with the CAN interface of the micro have been developed, and therefore you may upgrade the firmware of such a device without even opening its housing or without even taking it out of the circuit, due to the networking prone nature of CAN. Thus, it allows in field upgrades of software for cars and even small corrections to cover bugs on the cars that have been sold like that. So next time you take your car to an “authorized” garage think twice about it when you see the technician plugging a “tester” into your car. He might actually be rewriting the software fixing bugs you never even knew existed…
Its a wonderful post and very helpful, thanks for all this information.
ReplyDeleteMicrocontroller Training in Delhi
I am so happy after reading your blog. It’s very useful blog for us.
ReplyDeleteCorporate training in Machine learning
Thank you for sharing such a nice and interesting blog with us. I have seen that all will say the same thing repeatedly. But in your blog, I had a chance to get some useful and unique information.
ReplyDeleteAngular 7 Corporate training in Nigeria
hbar coin hangi borsada
ReplyDeletebtcst coin hangi borsada
vet coin hangi borsada
via coin hangi borsada
tron hangi borsada
juventus coin hangi borsada
beta coin hangi borsada
auto coin hangi borsada
mtl coin hangi borsada
Mmorpg Oyunlar
ReplyDeleteinstagram takipçi satın al
TİKTOK JETON HİLESİ
tiktok jeton hilesi
Sac Ekim Antalya
referans kimliği nedir
ınstagram takipci
instagram takipçi satın al
MT2 PVP
SMM PANEL
ReplyDeleteSmm panel
İş ilanları blog
instagram takipçi satın al
hirdavatciburada.com
beyazesyateknikservisi.com.tr
SERVİS
tiktok jeton hilesi