Building and flashing PX4
How to build and flash PX4 Autopilot for NXP UCANS32K146.

Prerequisites

You need a build environment that can build PX4 Autopilot. You can generally use the same environment as with Apache NuttX, but you will need to install some additional packages. To get started, you can use the HoverGames virtual machine, or install your own Linux (virtual) machine. When you have a basic Linux environment, you only need to install the PX4 toolchain to continue.
More information is also available in the PX4 Developer Guide.
If you have not yet cloned the PX4 source code as part of the toolchain installation, you should do so now:
1
git clone https://github.com/PX4/PX4-Autopilot
Copied!

Building PX4 Autopilot for UCANS32K146

Change your working directory (cd command) to the PX4-Autopilot Git repository that you just cloned. Next we will build the bootloader and firmware for our UCAN board.

Bootloader

You only need to build and flash the bootloader once. If you rebuild/reflash PX4, you can skip all of the bootloader steps.

Downloading the Bootloader

If you don't want to build the bootloader, you can download it by clicking the file below.
http://ci.px4.io/job/PX4_misc/job/Firmware-compile/job/master/lastSuccessfulBuild/artifact/build/nxp_ucans32k146_default/nxp_ucans32k146.bin
UCANS32K146 PX4 Bootloader (Latest build)
Alternatively, run the following command to build the bootloader:
1
make nxp_ucans32k146_canbootloader
Copied!
The binary file will be located at PX4-Autopilot/build/nxp_ucans32k146_canbootloader/nxp_ucans32k146.bin. Keep this file handy for flashing later.

PX4 Firmware

A prebuilt version of PX4 for UCANS32K146 is linked below. This is the latest build of PX4 master.
http://ci.px4.io/job/PX4_misc/job/Firmware-compile/job/master/lastSuccessfulBuild/artifact/build/nxp_ucans32k146_default/34-0.1.*.uavcan.bin/*zip*/nxp_ucans32k146_default.zip
UAVCAN PX4 firmware binary (Latest build)
Alternatively, you can build the firmware by running the following command in the root of the PX4-Autopilot repository:
1
make nxp_ucans32k146
Copied!
The .bin file for flashing the firmware will be stored in build/nxp_ucans32k146_default/deploy. The file you're looking for is 34.bin. You can leave the file there or copy it to another location for flashing the board in the next section.

Flashing PX4 Autopilot to the UCANS32K146 board

Download and install the J-Link Software and Documentation Pack. It is available for all major operating systems, but we will assume here that you are using a Linux-based OS. Open a terminal and navigate to the directory which holds the nxp_ucans32k146.bin file that we build in the previous step.
Now start the J-Link tools by entering:
1
JLinkExe
Copied!
Make sure that the debugger is plugged into both the UCANS32K146 board and your computer. If you are using a virtual machine, the debugger USB device should be made available inside the VM. Also do not forget to power the board. Now enter:
1
connect
Copied!
You are now asked to specify a device. It is quickest to manually enter the device:
1
s32k146
Copied!
The target interface needs to be specified, which is SWD:
1
s
Copied!
Finally you have to specify the target interface speed. It is recommended to use 1000 kHz:
1
1000
Copied!
Now flash the bootloader with:
1
loadbin /path/to/nxp_ucans32k146.bin 0x0
Copied!
The binary will be programmed and this process will also be verified. It should then mention if everything went OK.
Next, flash the PX4 firmware binary with:
1
# If using pre-built binary
2
loadbin /path/to/34-0.1.{commit}.uavcan.bin 0x6000
3
# If using self-built binary
4
loadbin /path/to/34.bin 0x6000
Copied!
And you're good to go.
You can quit the J-Link tools with:
1
q
Copied!
You may need to power cycle the device afterwards. The debug console should now be available on LPUART1 (115200 baud) - which is also accessible on the debugger breakout board.

More information

The PX4-build for UCANS32K146 is in an early state and not all features may be available. More information about PX4 Autopilot is available in their User Guide and Developer Guide. Their software development is managed on GitHub. There are also various support channels available.
Last modified 6mo ago