Trends

Bootloader firmware update: Benefits and description of implementation in practice

Creating a well-tuned firmware is the goal of every developer. Unfortunately, however, flaws and bugs are often only discovered when the device is already on the market. The possibility of correcting them is then very complicated and often costly. The solution is a remote upgrade using a bootloader, which enables a fast and user-friendly upgrade. It also brings the possibility to continuously improve the device and get ahead of the competition.

Easy remote firmware updates save manufacturers and suppliers a lot of money in the end. It eliminates the need for customer recalls and warranty issues. This helps to avoid potential damage to the manufacturer's reputation in the marketplace. In addition, it allows new features and enhancements to be added remotely, giving a competitive advantage. Using the example of the Leviathan device, developed by ASN Plus, let's see a concrete bootloader implementation process in practice.

Bootloader - a standalone program for firmware updates

One way to enable easy firmware updates of electronic devices is to use two separate programs. The first is the main program that provides hardware management, and the second is the bootloader or boot manager. The latter carries information about the location of the main program, takes care of starting it and updating it if necessary.

Thanks to the bootloader, the main program can be easily updated, not only from fixed storage, but also from the cloud. This brings the possibility of mass upgrading even a large number of devices. However, an update is not necessarily required - as with mobile phones, the decision is up to the user. It is also worth mentioning that the firmware update does not upgrade both programs, but only the main one. The bootloader remains unchanged after the initial programming and is not updated.

Benefits of remote update via bootloader

Whether you are a developer or a manufacturer of electronics or other electronics-equipped devices, you should definitely consider the option of easy updating. Are you wondering if it's worth the time and money to implement a bootloader? A review of the benefits will make your decision easier:

● A bootloader allows you to easily update even a large number of electronic devices. This makes it particularly important when producing electronics in large series. Without the bootloader, remote updating would not be possible.

● In the event of a critical firmware error, it eliminates the need to download the entire production batch from users as part of a warranty claim. This also saves electronics manufacturers additional costs.

● Provides a user-friendly solution. Remote updates are intuitive and fast. In addition, the user is free to decide whether to download a new firmware version or to keep the existing one.

● Allows for very fast troubleshooting of critical problems and flexible response to user needs.

● Creates room for continuous improvement. In addition to removing bugs, it also allows the addition of new features. This gives the manufacturer or supplier a head start over the competition.

Bootloader in practice: implementation in Leviathan

To understand all the possibilities of the bootloader and its specifics, let's move from theory to practice. The solution for easy remote firmware updates was developed by ASN Plus, a company that has long been involved in complete electronics development, from PCB design to firmware and mobile application development. For JeffTron, a company focused on selling electronics for airsoft guns, it developed the Leviathan device, which allows the gun to be linked to a mobile app.

Image
asn+

The user can monitor shooting statistics or set various parameters (cadence, virtual magazine, preload, optical sensor calibration, etc.). As the airsoft gun controller is produced in large series and used by many users, the feature of easy and quick firmware upgrade was one of the core requirements

Easy update via mobile app

The firmware includes the main program and bootloader. If the ASN Plus development team creates a new version of the main program with corrections or new features, it is uploaded to the server. Once the mobile app is powered on and paired with the Leviathan unit, it verifies the current firmware version and compares it to the version available on the server. If an upgrade to the main program is available, the user is prompted to confirm or reject the upgrade.

When the upgrade is confirmed, a data file is downloaded from the server to the phone's memory. The application will send information about the upcoming upgrade to the main program via Bluetooth. The latter responds to the message by exiting and launching the bootloader (if it is not already running, see below). The application starts the data transfer, the bootloader receives it and writes it in place of the original main program. When the bootloader finishes loading the new firmware, it checks and if the data is not corrupted, it exits and starts the main (already updated) program.

What happens if the update fails?

It may happen that the firmware update does not proceed as planned and fails. There can be a number of reasons for this - voltage drop in the weapon, loss of signal between the phone and the weapon, damage to the main program data, etc. After switching to a broken program, the airsoft gun would be unusable. However, these risks were not forgotten during the development at ASN Plus.

Part of the main program is a CRC code, thanks to which the boot program can detect its malfunction and prevent it from possibly running. The bootloader will not terminate, so the update process can be repeated. The mobile app will recheck the version of the main program and the bootloader will respond that the program is broken. Any version available on the server will be offered to the user for installation. Upon successful completion of the upgrade, the airsoft gun will be back in a fully functional state with the latest firmware version.

Different hardware requires its own firmware type

When developing electronics, a common requirement of the customer is to create several types of hardware. This is also the case with Leviathan, which exists in different variants (for different types of weapons, for models with an optical switch instead of a mechanical switch, etc.). Each type of hardware then requires its own individually designed firmware.

For a successful bootloader update, a data file adapted to the device type must exist on the server. Therefore, after pairing with the device, the application first determines which hardware variant it is. Only in the next step does it verify the version of the main program and compare it with the compatible version available on the server. This makes it possible to upgrade the firmware only for certain types of devices, other users will not be offered the option to upgrade.

By modifying the bootloader, you can restrict selected hardware functions even after the update

Although the bootloader is primarily used to run and update the main program, it can also affect the functionality of the device. Specifically, in the case of the Leviathan airsoft unit, ASN Plus developers have had to deal with the requirement to limit the functionality of units intended for sale in certain states. The laws there prohibit automatic firing, or firing in bursts.

In terms of hardware and firmware, the units are identical, but the automatic firing function is blocked on models intended for a part of the market. The firmware had to be designed in such a way that the required restriction could not be circumvented by downloading a version of the main program for countries with more benevolent rules. For this reason, on selected models the functionality limitation is included directly in the bootloader, which cannot be updated.

Both types of bootloader work identically. However, units that have a restricted ("semi only") bootloader will write information to memory after the update is complete, indicating that automatic fire is disabled. The main program reads this information after startup and does not fire automatically.

The enabling or disabling of automatic firing is determined at the time of manufacture or initial firmware upload. The user has no possibility to influence this functionality - the main program remains the same for all hardware variants, the limitation is in the bootloader, which cannot be changed by the user. At the same time, this eliminates the need to develop different firmware versions that would have to be designed for the restricted device.

The ability to remotely update firmware using the bootloader is user-friendly and brings a number of benefits to the electronics manufacturers themselves. However, there are a number of hurdles to overcome when developing firmware, whether it is different hardware variants, failure to load data, or the requirement to restrict functionality. If you need to provide electronics development with the ability to upgrade seamlessly, turn to developers who have experience in this area.

Marek Poborský, Senior Programmer

Care to know more on the subject?
Connect with our specialists
Pavel Schiller
CEO