Why to use bootloader for firmware update

11 reading_minutes

The goal for firmware development is evident – to create a programme which works and is debugged and lacking errors at the same time. The development work should not end even after an electronic product is placed on the market.
It is important to carry on working on the updates, which will help to add new functions and to flexibly solve identified shortcomings. How is it possible to implement an option to remotely upgrade the firmware? You can use the bootloader. Thanks to it the firmware upgrade can be smooth, secure and user friendly.
 

Remote update brings cost savings

The option to remotely update the firmware of electronic devices is increasingly in demand among our customers. It brings significant cost savings to the producers and distributors. They do not have to physically deal with the reclamations problems associated with firmware and they do not have to recall the product from the market.

You can avoid the risk of reputation damage and simultaneously gain an edge over the competition thanks to the remote update. You are able to simply add the new functions and improvements by using the remote upgrade so you will be able to flexibly react to user requirements and comments. 

We have a lot of experiences with remote updates and we are fully aware of its importance. We would like to introduce to you the specific solution for firmware upgrade using bootloader, which we used by the way in the development of device Leviathan.

Bootloader = programme for firmware update

There are several ways how to deal with firmware update of an electronic device. We have approached the method of using two separate programmes during device Leviathan development. Main programme does the hardware management, its update does the bootloader (it is also called boot manager). It includes the information about the main programme position and manages its turn on and upgrade at the same time. You can easily update the main programme via the bootloader from the hard disk and from cloud as well.

Possible bulk update of more devices is thus smooth. It is up to the electronic device user whether he chooses to start the upgrade or not. The solution principle is similar to the mobile phone system, where it is at the user's discretion whether the device will be upgraded or will carry on using the previous version. The bootloader is consistent and is not subject to update. It is only a tool for the main programme to upgrade. 

Benefits of remote update

Are you asking yourself whether it is worth investing your time and money to implement a bootloader for remote update? We are definitely sure it is worth it. This functionality can offer to you, electronics producers, many benefits:  

  • Simple and smooth update of many devices – Bootloader implementation has a huge impact on electronics production in bigger series. It would be simply impossible to do the remote update without it.

  • Error fixing without the need to recall devices from the market – In case some critical firmware error on an electronic device occurs, you are able to fix it without recalling the device from the market.  

  • User friendly solution – Even a layman is able to process an update. The user interface is intuitive. It is at the user's discretion whether he updates the device or he will carry on using the previous version of the programme.

  • Edge over the competition – The electronic device can be continuously improved including adding new functions thanks to the bootloader. You can easily gain the edge over the competition without needing to create a brand new product.

Bootloader in Leviathan device

We will describe to you the way of bootloader implementation in a real product, Leviathan device, to make it easier to understand it. We have this device for Jefftron company, which is focused on selling the electronics for airsoft guns. 

Leviathan manages the connection between airsoft gun and mobile app and brings the option to monitor the shooting statistics. 

The Leviathan allows setting of various parameters such as cadence, virtual magazine, preload and optical sensor calibration at the same time. The airsoft gun control unit is produced in big series and is used by many users, that’s why the option of smooth and fast remote firmware upgrade was one of the development priorities.

Firmware upgrade via mobile app

Leviathan firmware has two parts - main programme and bootloader. Once our developers finish a new version of the main programme, which brings errors fixes or new functions, they upload it on the server. There is a check of the current firmware version and comparison to one available on the server after every turning on of the mobile app and pairing the device. If an app finds a new version, it informs the user. The user can either accept the upgrade or refuse it. 

If the user accepts the upgrade, the app starts to download a data file with the new version of the main programme into mobile phone memory. App then sends information about incoming upgrade to the main programme via bluetooth. Main programme recognizes this and turns off and starts the bootloader (in case it is not turned on, more information below). 

App then manages data transfer via bluetooth. Bootloader data receives gradually and writes it down in the place of the previous main programme.  Once the transfer is finished, the bootloader checks the function. If the data is not corrupted, the bootloader jumps to the main programme and turns off.

The bootloader is prepared even for possibility of update failure

Not every time everything goes according to the plan. Sometimes some error or update failure occurs due to signal loss, gun voltage drop or data corruption. If the main programme was substituted by not working new version, the airsoft gun would not work as well. We have taken this risk into account, so we have prepared a solution which eliminates this risk. 

We have integrated CRC code into the main programme, which enables it to detect malfunction and prevents corrupted programme to run. Bootloader does not turn off, but it stays turned on and enables another update.  

The mobile app checks main programme version and if it detects corrupted data, bootloader responds that main programme does not work. User will be offered any version available on the server. After upgrade is successfully finished, the airsoft gun is working again with new firmware version in memory. Users do not have to be afraid that the upgrade failure would put a gun out of service. 

Various firmware types for different hardware types

The Leviathan device is produced in different variants. Some of them are determined for models with optical switches, others for models with mechanical switches. Every type of hardware must have an individual. To make an upgrade via bootloader successful, there has to be a file with a new version for a particular type of device on the server.   

That’s why the app checks the hardware version in the first instance. In the second step, it checks the main programme version and compares it with the one available on the server. Firmware is easy to be updated or upgraded for various device types separately, or you can focus just on one individual hardware type innovation.

Even bootloader update has its meaning

As we have mentioned, the main goal of the bootloader is to run and upgrade the main programme. Yet even a boot programme can directly affect device function. We have used this knowledge during firmware development of Leviathan in ASN. We have met the requirement for units functionality limitation, which are dedicated for selling in particular states. Some of the states legislation does not allow automatic or burst shooting.   

In the matter of firmware and hardware, all the units are identical. There is a blocked option of automatic shooting for the ones dedicated to selected countries through bootloader. The restriction is hereby not possible to be evaded even by downloading the new version for full open units or by programme edit.

Blocked function is set during manufacturing

Both bootloader types work identically.  However some units have limited (“semi only”) bootloader. When the update is finished, the unit writes down information that automatic shooting is blocked into the memory. Main programme reads this information after turning on and though automatic shooting option is not proceed. Automatic shooting restriction is strictly set during manufacturing, respectively when the first version of firmware is implemented. This setting cannot be avoided.  

If you are a develeper or electronics manufacturer, the option of remote firmware update via bootloader is worth considering. We will be happy to help you with the implementation. In our company, ASN Plus, we have overcome several obstacles and specific demands. We will be glad to help you with complex firmware development and PCB design.


Share article