Firmware Update (Bootloader) Example Project¶
This ISBootloaderExample project demonstrates firmware update with the InertialSense products (IMX, uAHRS, and uIMU) using the Inertial Sense SDK.
Files¶
Project Files¶
SDK Files¶
- data_sets.c
- data_sets.h
- inertialSenseBootLoader.c
- inertialSenseBootLoader.h
- ISComm.c
- ISComm.h
- serialPort.c
- serialPort.h
- serialPortPlatform.c
- serialPortPlatform.h
Implementation¶
Step 1: Add Includes¶
// Change these include paths to the correct paths for your project
#include "../../src/ISComm.h"
#include "../../src/serialPortPlatform.h"
#include "../../src/ISBootloaderThread.h"
#include "../../src/ISBootloaderBase.h"
#include "../../src/ISSerialPort.h"
Step 2: Initialize and open serial port¶
serial_port_t serialPort;
// initialize the serial port (Windows, MAC or Linux) - if using an embedded system like Arduino,
// you will need to either bootload from Windows, MAC or Linux, or implement your own code that
// implements all the function pointers on the serial_port_t struct.
serialPortPlatformInit(&serialPort);
// set the port - the bootloader uses this to open the port and enable bootload mode, etc.
serialPortSetPort(&serialPort, argv[1]);
Step 3: Set bootloader parameters¶
// bootloader parameters
bootload_params_t param;
// very important - initialize the bootloader params to zeros
memset(¶m, 0, sizeof(param));
// the serial port
param.port = &serialPort;
param.baudRate = atoi(argv[2]);
// the file to bootload, *.hex
param.fileName = argv[3];
// optional - bootloader file, *.bin
param.forceBootloaderUpdate = 0; //do not force update of bootloader
if (argc == 5)
param.bootName = argv[4];
else
param.bootName = 0;
Step 4: Run bootloader¶
if (bootloadFileEx(¶m)==0)
{
printf("Bootloader success on port %s with file %s\n", serialPort.port, param.fileName);
return 0;
}
else
{
printf("Bootloader failed! Error: %s\n", errorBuffer);
return -1;
}
Compile & Run (Linux/Mac)¶
- Create build directory
cd InertialSenseSDK/ExampleProjects/Bootloader mkdir build
- Run cmake from within build directory
cd build cmake ..
- Compile using make
make
- If necessary, add current user to the "dialout" group in order to read and write to the USB serial communication ports:
sudo usermod -a -G dialout $USER sudo usermod -a -G plugdev $USER (reboot computer)
- Run executable
./ISBootloaderExample /dev/ttyUSB0 IS_uINS-3.hex bootloader-SAMx70.bin
Compile & Run (Windows Powershell)¶
*Note - Install CMake for Windows natively, or install the CMake for Windows extension for Visual Studio
- Create build directory
cd InertialSenseSDK/ExampleProjects/IS_firmwareUpdate_v2 mkdir build
- Run cmake from within build directory
cd build cmake ..
-
Compile using make
cmake --build .
-
Run executable
C:\InertialSenseSDK\ExampleProjects\IS_firmwareUpdate_v2\build\Release\ISBootloaderExample.exe COM3 IS_uINS-3.hex bootloader-SAMx70.bin
Summary¶
This section has covered the basic functionality you need to set up and communicate with Inertial Sense products. If this doesn't cover everything you need, feel free to reach out to us on the Inertial Sense SDK GitHub repository, and we will be happy to help.