arrow-left

All pages
gitbookPowered by GitBook
1 of 1

Loading...

Building and flashing PX4

How to build and flash PX4 Autopilot for NXP UCANS32K146.

hashtag
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 machinearrow-up-right, or install your own Linux (virtual) machine. When you have a basic Linux environment, you only need to install the PX4 toolchainarrow-up-right to continue.

More information is also available in the PX4 Developer Guidearrow-up-right.

If you have not yet cloned the PX4 source code as part of the toolchain installation, you should do so now:

hashtag
Adding CAN utilities to PX4

If you want to add the can-utils apps to PX4 (candump and cansend applications), you will need to perform an extra step.

Here are the steps:

  1. From the root of your PX4 directory, run make nxp_ucans32k146 menuconfig

  2. Navigate to Application Configuration --->

  3. Navigate to CAN Utilities --->

It should look like this:

Once you've finished this, exit the menuconfig and save, then continue to build PX4 below.

hashtag
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.

hashtag
Bootloader

circle-info

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

hashtag
Downloading the Bootloader

If you don't want to build the bootloader, you can download it by clicking the file below.

Alternatively, run the following command to build the bootloader:

The binary file will be located at PX4-Autopilot/build/nxp_ucans32k146_canbootloader/nxp_ucans32k146.bin. Keep this file handy for flashing later.

hashtag
PX4 Firmware

A prebuilt version of PX4 for UCANS32K146 is linked below. This is the latest build of PX4 master.

Alternatively, you can build the firmware by running the following command in the root of the PX4-Autopilot repository:

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.

hashtag
Flashing PX4 Autopilot to the UCANS32K146 board

Download and install the . 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:

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:

You are now asked to specify a device. It is quickest to manually enter the device:

The target interface needs to be specified, which is SWD:

Finally you have to specify the target interface speed. It is recommended to use 1000 kHz:

Now flash the bootloader with:

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:

And you're good to go.

You can quit the J-Link tools with:

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.

hashtag
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 and . Their software development is managed on . There are also various available.

  • Enable all options except [ ] SocketCAN slcan tool

  • J-Link Software and Documentation Packarrow-up-right
    User Guidearrow-up-right
    Developer Guidearrow-up-right
    GitHubarrow-up-right
    support channelsarrow-up-right
    git clone https://github.com/PX4/PX4-Autopilot
    make nxp_ucans32k146_canbootloader
    make nxp_ucans32k146
    JLinkExe
    connect
    s32k146
    s
    1000
    loadbin /path/to/nxp_ucans32k146.bin 0x0
    # If using pre-built binary
    loadbin /path/to/34-0.1.{commit}.uavcan.bin 0x6000
    # If using self-built binary
    loadbin /path/to/34.bin 0x6000
    q
    http://ci.px4.io/job/PX4_misc/job/Firmware-compile/job/master/lastSuccessfulBuild/artifact/build/nxp_ucans32k146_default/nxp_ucans32k146.binci.px4.iochevron-right
    UCANS32K146 PX4 Bootloader (Latest build)
    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.zipci.px4.iochevron-right
    UAVCAN PX4 firmware binary (Latest build)