One of the scripts of Pixhawk native firmware PX4 to do the environment configuration of Linux system

PX4 official website has released a tutorial of using script to configure Linux firmware compilation environment. It only takes 5 steps to complete the steps required for PX4 firmware compilation:

  1. Input the following command at the terminal:

    sudo usermod -a -G dialout $USER
  2. Log out and log back in
  3. Save the following script
  4. Make script effective, execute instructions


    Wait for the script to finish executing
  5. Reset computer

Next, you will find that you have downloaded the latest PX4 firmware in the home directory, and you can compile it directly.

Now let's focus on what's going on in this script


## Bash script for setting up a PX4 development environment for Pixhawk/NuttX targets on Ubuntu LTS (16.04).
## It can be used for installing simulators and the NuttX toolchain.
## Installs:
## - Common dependencies libraries, tools, and Gazebo8 simulator as defined in ``
## - NuttX toolchain (i.e. gcc compiler)

echo "Downloading dependent script ''"
# Source the script directly from github
ubuntu_sim=$(wget -O -)
# If there was an error downloading the dependent script, we must warn the user and exit at this point.
if [[ $wget_return_code -ne 0 ]]; then echo "Error downloading ''. Sorry but I cannot proceed further :("; exit 1; fi
# Otherwise source the downloaded script.
. <(echo "${ubuntu_sim}")

# NuttX
sudo apt-get install python-serial openocd \
    flex bison libncurses5-dev autoconf texinfo \
    libftdi-dev libtool zlib1g-dev -y

# Clean up old GCC
sudo apt-get remove gcc-arm-none-eabi gdb-arm-none-eabi binutils-arm-none-eabi gcc-arm-embedded -y
sudo add-apt-repository --remove ppa:team-gcc-arm-embedded/ppa -y

# Install GCC 5.4
echo "Installing GCC to: $gcc_dir"
if [ -d "$gcc_dir" ]
    echo " GCC already installed."
    pushd .
    cd ~    
    tar -jxf gccarmnoneeabi542016q220160622linuxtar.bz2
    exportline="export PATH=$HOME/gcc-arm-none-eabi-5_4-2016q2/bin:\$PATH"
    if grep -Fxq "$exportline" ~/.profile; then echo " GCC path already set." ; else echo $exportline >> ~/.profile; fi
    . ~/.profile

    # Install 32 bit support libraries (ignore if fails)
    sudo dpkg --add-architecture i386
    sudo apt-get update
    sudo apt-get install libc6:i386 libgcc1:i386 libstdc++5:i386 libstdc++6:i386 -y
    sudo apt-get install gcc-5.4-base:i386 -y

# Go to the firmware directory
cd $clone_dir/Firmware

#Reboot the computer (required before building)
echo RESTART YOUR COMPUTER to complete installation of PX4 development toolchain

Tags: sudo Linux Ubuntu simulator

Posted on Tue, 14 Apr 2020 10:02:25 -0700 by Dr Evil