How can a microcontroller be programmed wirelessly? How can a microcontroller be programmed wirelessly

How can a microcontroller be programmed wirelessly?

Is it possible for a microcontroller to be programmed wirelessly?

In this article, we will talk about how can a microcontroller be programmed wirelessly.

microcontroller be programmed wirelessly

The concept is actually pretty simple: you implement it in the exact same way that JTAG or USB firmware upgrade is implemented… well, at least at a high level. At the lower level of implementation, things are a little bit more complicated actually, and how you accomplish this is device-dependent. But here are some general considerations and techniques:

  1. Make sure your hardware supports it. Make sure to design your IoT electrical circuitry in a way that supports wireless firmware upload. To be able to do this, you have to look at the datasheet for your microcontroller. Specifically, go to the section of programming the microcontroller. Essentially, to program a microcontroller is nothing but copying some data (binary file) into a specific predetermined section of flash memory. In powering up the board, the microcontroller is preprogrammed to know to start executing code from that section of flash memory. But how do you write to the section of the flash memory? And this is a very important design consideration. Each microcontroller uses a specific set of pins that are capable of writing to this specific segment of flash. And these pins are associated with a specific protocol. For example, AVR microcontrollers support firmware typically upload over SPI only. This means that your board has to be designed in a specific way that your wireless module is hooked up to the SPI ports of the microcontroller. Always make sure your wireless modules (whether Bluetooth or Wifi) are connected to the ports of the microcontroller that support firmware programming. Even if you don’t intend to do OTA (over the air) programming now, you never know what requirements might arise in the future.
  2. Probably you need to write your own API at the application layer to interface to the bootloader on the microcontroller. When you program a microcontroller over JTAG, USB, or SWD, the IDE for that microcontroller will take care of all the API for you. But when you are sending binary files over the air, you need to create your own API at the application level (for example in the mobile app). The accurate API algorithm will depend on your target microcontroller. You will need to look at the datasheet for your microcontroller for the correct protocol and you will need to implement that protocol in your mobile application.
  3. Be sure to protect both your software and your hardware. When you start to write code to the sections of flash that the microcontroller executes on start, you begin to have a lot of power over things. And with great power comes great responsibility. If you’re not careful, you can mess up your entire software and worse yet, brick your board for good. You need to be sure you protect the critical portions of the code so that those portions do not change when doing over the air firmware update. In case of a wireless transmission error, you don’t want to end up with corrupted data in a critical section of your flash that could cause your hardware to be permanently damaged on the next boot.
  4. Decide on a deployment strategy. Are you going to have the users to download your latest firmware on their phones and use Bluetooth or Wifi to program the microcontroller? Or are you going to have the application fetch the firmware from an online database? This is depending on your application but generally speaking, the best method is the latter. Probably you should have the firmware reside on a server online and have the server broadcast the availability of a firmware update which will then be picked up by the app and uploaded wirelessly to the microcontroller. In this way, you (the developer) only need to upload the new firmware once (on the server) and be sure that all users get it.

So, make sure your hardware supports OTA programming and make sure you love (really) low-level programming. Make sure you program responsibly.

Here are comments about why you would want to program a microcontroller wirelessly:

Before a microcontroller can do anything useful, it needs to be programmed. The software engineer (in this context often called the firmware developer or the embedded software developer) writes code (typically in C) for the microcontroller. The code is then built into a binary file that is ready to be uploaded to the microcontroller. Traditionally, microcontrollers have been programmed through some kind of wired interface such as USB, JTAG, etc. However, as more embedded devices are becoming completely wireless, there is great interest in uploading firmware onto microcontrollers wirelessly. In short, this is called OTA (over the air) programming.

Some benefits of uploading firmware wirelessly are:

  1. It makes embedded devices to be smaller in size. Nowadays, embedded systems are getting very small and having a USB or JTAG interface just for programming is a waste of precious space. Since most of the embedded systems already have some kind of wireless capability for operation, it makes sense to program the microcontrollers on embedded systems using existing hardware.
  2. It makes easier for everyone to deploy the new firmware. Think when you (the developer of an IoT product) release a firmware update. In the traditional method, you’ll have to notify all your customers that there’s a firmware update and have them plug in their devices to a computer to get the latest hardware. The old GPS systems did that. Now think to able to announce the users about firmware upgrade on their phones and give them the ability to upgrade the device firmware with the push of a button from their phone wirelessly! Wouldn’t that be easier for the developer and the end-user? You bet!

The future is clear. Ultimately, all IoT and embedded devices will have wirelessly upgradeable firmware.

 

To read more articles like this visit Eduengteam.com

You can find more useful tutorials at Click Here