Windows - flashing
Follow this guide to flash firmware to your board on Windows.
For the Linux set up skip to the next page: Linux - Flashing
J-Link Software setup
Follow each step, in order. If something is not clear, try contacting someone in the Contacts list for help or use the FAQ.
Step 1 - Installing J-Link software.
First step you will need the J-Link Commander program, which is part of the J-Link Software pack. Installers for different operating systems are available at Segger's website. Link below leads to the Segger's website. Follow the instructions of the installer until you are finished with the install.
Step 2 - Connect you J-Link debugger.
Now you will have to connect the debugger to your PC as well as the FMU. The debugger should be connected to the "DEBUG" input pin on the FMUK66 through the 7-pin JST GH connector (indicated below). And a USB cable needs to be plugged into the side of the FMU (micro-USB to USB).
Then you can connect both the USB cables displayed below to your computer. The connection should look a bit like the photo below:
Step 3 - Establishing a connection.
After everything is connected properly, search for J-Link Commander under the program menu after installation. It can be found in a directory similar to this:
You can also browse to the installation folder and run the program from there. Usually, the J-Link Software pack is installed to a location similar to C:\Program Files\SEGGER\JLink
. Note that the name of the J-Link Commander executable is actually JLink.exe.
Connecting the board
After running the JLink.exe the command prompt pops up. When prompted, type connect
to establish a connection with the debugger.
You might have a pop up saying to update the firmware, just accept the update.
Set the target device.
The next step is to specify the target device. To find your target device, follow the table shown below. Copy the name of the Device/Core you are using into the command window. In this case we are using XXXXXXXXXXXXXXX
as an example, fill in the Device/Core you are using instead.
Board Name
Device / Core
RDDRONE-FMUK66 (HoverGames FMU)
MK66FN2M0XXX18
UCANS32K146
S32K146
RDDRONE-BMS772
S32K144
You can also select the device/core identifier by writing ?
to bring up a selection dialog in which you can select the right device. You can type the device/core identifier into the Device
field in the Target Device Settings window. This will show the selections for that device that are available. Make sure to select the correct device that you are using.
Select the target interface.
When using the J-Link debugger, enter s
to select SWD as the target interface.
Select the target speed.
For the speed entry, refer to the table below to select the correct target interface speed for the board you are flashing.
Board Name
Target Device Speed (kHz)
RDDRONE-FMUK66
4000
UCANS32K146
1000
RDDRONE-BMS772
1000
When pressing "Enter" the Term of Use will pop up. After reading the terms you can continue by pressing the Accept button.
Connected!
The J-Link will then be connected to the target. You should see something similar to the image below if everything worked properly.
J-Link help
At this point you can type?
to get a list of commands that the J-Link accepts. You do not need to follow this step it is just in case you want to try things out yourself.
Step 4 - Flashing bootloader to the board
When a connection is established, we can flash the bootloader files to the board. We first need to download the binary file. To do so go to this page, Download Bootloader. Choose the correct Rev. option. Keep track of where you download the file!
Make sure to double check you are choosing the correct file! On top of the download link there is an explanation to find out what board you have.
Once the download is finished move back to the command window and write the following code (add the path to the binary file you just downloaded):
loadbin "\absolute\path\to\bootloader.bin" 0x0
This code will load the bootloader to your board at address 0x0
. The output should be as follows:
Depending on the size of the binary, it might take a while to flash. A pop-up will appear which shows the different steps. It will first check the contents of the binary and match it against the contents of the memory on the board. If they are equal, the binary doesn't have to be flashed. Otherwise, the old contents of the memory are first erased. Then the contents of the binary are programmed into the memory, and finally it is verified that it was done correctly.
That is everything! You may need to press reset on the board, or power cycle, for the new code to start running on your board.
Note that on boards with just a bootloader, the board will not do much. You will need both a bootloader and PX4 firmware for the board to function as intended. Which is why the next step is to flash the firmware to the board.
Step 5 - Flashing firmware to the board
Flashing the firmware to the board is the next step after flashing the bootloader. First step is to locate the directory you will want to be in. If you followed all the steps so far you should have the PX4-Autopilot
in the src
directory.
The file should be located at the location similar to this one:
Now that you know where the location of the file is we can continue. Do the same steps as the bootloader:
Go to the Terminal and write:
JLinkExe
connect
MK66FN2M0XXX18
or "Enter"S
4000
Now this part is different:
loadbin </path/to/firmware/file.bin> 0x6000
The path for the firmware is the one mentioned in the beginning of the chapter.
It is very important that you get the correct offsets (0x0
, 0x6000
), as the bootloader uses these to find the firmware on your FMU's flash chip.
Once you have finished flashing your board, you can press the RESET button on the side of the FMU to reboot it. It will now be running PX4-Autopilot!
Uploading code
With all the flashing setup we can uplaod example codes to the board. To do so first, use the following code to go to the PX4 directory (this should be done in your WSL):
Once in the correct directory, write the make command bellow:
You have just compiled the file and made it ready to upload. To upload these files, run the following command:
It might take a while and you will get a prompt to unplug and plug back is your USB. Follow those instructions until there is a progress bar uploading your files. Once finished your code will be uploaded and ready to be tested.
Last updated