Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arch setup script #13111

Merged
merged 4 commits into from
Oct 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 127 additions & 0 deletions Tools/setup/arch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
#! /usr/bin/env bash

## Bash script to setup PX4 development environment on Arch Linux.
## Tested on Manjaro 18.0.1.
##
## Installs:
## - Common dependencies and tools for nuttx, jMAVSim
## - NuttX toolchain (omit with arg: --no-nuttx)
## - jMAVSim simulator (omit with arg: --no-sim-tools)
##
## Not Installs:
## - Gazebo simulation
## - FastRTPS and FastCDR

INSTALL_NUTTX="true"
INSTALL_SIM="true"

# Parse arguments
for arg in "$@"
do
if [[ $arg == "--no-nuttx" ]]; then
INSTALL_NUTTX="false"
fi

if [[ $arg == "--no-sim-tools" ]]; then
INSTALL_SIM="false"
fi

done

# script directory
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

# check requirements.txt exists (script not run in source tree)
REQUIREMENTS_FILE="requirements.txt"
if [[ ! -f "${DIR}/${REQUIREMENTS_FILE}" ]]; then
echo "FAILED: ${REQUIREMENTS_FILE} needed in same directory as arch.sh (${DIR})."
return 1
fi

echo
echo "Installing PX4 general dependencies"

sudo pacman -Sy --noconfirm --needed \
astyle \
base-devel \
ccache \
clang \
cmake \
cppcheck \
doxygen \
gdb \
git \
gnutls \
nettle \
ninja \
python-pip \
rsync \
shellcheck \
tar \
unzip \
wget \
zip \
;

# Python dependencies
echo "Installing PX4 Python3 dependencies"
sudo pip install --upgrade pip setuptools wheel
sudo pip install -r ${DIR}/requirements.txt


# NuttX toolchain (arm-none-eabi-gcc)
if [[ $INSTALL_NUTTX == "true" ]]; then
echo
echo "Installing NuttX dependencies"

sudo pacman -S --noconfirm --needed \
gperf \
vim \
;

# add user to dialout group (serial port access)
sudo usermod -aG uucp $USER

# Remove modem manager (interferes with PX4 serial port/USB serial usage).
sudo pacman -R modemmanager --noconfirm
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is evil. I vote we don't do that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed (and done) on ubuntu. So it may be evil, but consistently evil. Of course if the ubuntu and arch modem managers are different this could be pointless.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am also curious to know why this is evil.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because let's say you use modemmanager because you use LTE in your laptop and then the PX4 installer comes along and decides to just remove it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The right thing to do is to make pull requests against modemmanager and add all IDs of all Pixhawks so that it ignores them.

The 3DR USB ID is ignored since 2014:
https://github.com/freedesktop/ModemManager/commit/9447527c357a91bbd3660274c41fd1b802e4cf84

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should only display it if and only if there is a port available but it's already occupied by someone else.

Copy link
Member Author

@MaEtUgR MaEtUgR Oct 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put this to a test with a Pixhawk 4 and a CUAV V5 nano (both fmu-v5) and having the modemmanager (version 1.10.4 latest arch) installed clearly breaks a lot of flashing attempts. Especially every attmpt where you start the script and then power the board every single time. Here's the output of me repeating this case with both board alternately, removing modemmmanager and all subsequent tries are successful. I don't consider to leave it if the chance of successful flashing is that low.

[maetugr@ManjaroVM Firmware]$ make px4_fmu-v5 upload
[0/4] Performing build step for 'px4io_firmware'
ninja: no work to do.
[3/4] uploading px4
==========================================================================================================
WARNING: You should uninstall ModemManager as it conflicts with any non-modem serial device (like Pixhawk)
==========================================================================================================
Loaded firmware for board id: 50,0 size: 1670412 bytes (80.92%), waiting for the bootloader...


Found board id: 50,0 bootloader version: 5 on /dev/serial/by-id/usb-3D_Robotics_PX4_BL_FMU_v5.x_0-if00
sn: 003d00233138510638393738
chip: 10016451
family: b'STM32F7[6|7]x'
revision: b'Z'
flash: 2064384 bytes
Windowed mode: False

Erase  : [====================] 100.0%
Program: [                    ] 3.9%
ERROR: timeout waiting for data (1 bytes)
FAILED: platforms/nuttx/CMakeFiles/upload 
cd /home/maetugr/Firmware/build/px4_fmu-v5_default && /usr/bin/python /home/maetugr/Firmware/Tools/px_uploader.py --port "/dev/serial/by-id/*-3D_Robotics_PX4_FMU_v5.x*,/dev/serial/by-id/*PX4_BL*,/dev/serial/by-id/*BL_FMU*,/dev/serial/by-id/usb-The_Autopilot*,/dev/serial/by-id/usb-Bitcraze*,/dev/serial/by-id/pci-Bitcraze*,/dev/serial/by-id/usb-Gumstix*,/dev/serial/by-id/usb-Hex_ProfiCNC*,/dev/serial/by-id/usb-UVify_FMU_BL*" /home/maetugr/Firmware/build/px4_fmu-v5_default/px4_fmu-v5_default.px4
ninja: build stopped: subcommand failed.
make: *** [Makefile:202: px4_fmu-v5] Error 1
[maetugr@ManjaroVM Firmware]$ make px4_fmu-v5 upload
[0/4] Performing build step for 'px4io_firmware'
ninja: no work to do.
[3/4] uploading px4
==========================================================================================================
WARNING: You should uninstall ModemManager as it conflicts with any non-modem serial device (like Pixhawk)
==========================================================================================================
Loaded firmware for board id: 50,0 size: 1670412 bytes (80.92%), waiting for the bootloader...


Found board id: 50,0 bootloader version: 5 on /dev/serial/by-id/usb-3D_Robotics_PX4_BL_FMU_v5.x_0-if00
sn: 003d00233138510638393738
chip: 10016451
family: b'STM32F7[6|7]x'
revision: b'Z'
flash: 2064384 bytes
Windowed mode: False

Erase  : [====================] 100.0%
Program: [                    ] 0.0%
ERROR: timeout waiting for data (1 bytes)
FAILED: platforms/nuttx/CMakeFiles/upload 
cd /home/maetugr/Firmware/build/px4_fmu-v5_default && /usr/bin/python /home/maetugr/Firmware/Tools/px_uploader.py --port "/dev/serial/by-id/*-3D_Robotics_PX4_FMU_v5.x*,/dev/serial/by-id/*PX4_BL*,/dev/serial/by-id/*BL_FMU*,/dev/serial/by-id/usb-The_Autopilot*,/dev/serial/by-id/usb-Bitcraze*,/dev/serial/by-id/pci-Bitcraze*,/dev/serial/by-id/usb-Gumstix*,/dev/serial/by-id/usb-Hex_ProfiCNC*,/dev/serial/by-id/usb-UVify_FMU_BL*" /home/maetugr/Firmware/build/px4_fmu-v5_default/px4_fmu-v5_default.px4
ninja: build stopped: subcommand failed.
make: *** [Makefile:202: px4_fmu-v5] Error 1
[maetugr@ManjaroVM Firmware]$ make px4_fmu-v5 upload
[0/4] Performing build step for 'px4io_firmware'
ninja: no work to do.
[3/4] uploading px4
==========================================================================================================
WARNING: You should uninstall ModemManager as it conflicts with any non-modem serial device (like Pixhawk)
==========================================================================================================
Loaded firmware for board id: 50,0 size: 1670412 bytes (80.92%), waiting for the bootloader...


Found board id: 50,0 bootloader version: 5 on /dev/serial/by-id/usb-3D_Robotics_PX4_BL_FMU_v5.x_0-if00
sn: 003d00233138510638393738
chip: 10016451
family: b'STM32F7[6|7]x'
revision: b'Z'
flash: 2064384 bytes
Windowed mode: False

Erase  : [====================] 100.0%
Program: [                    ] 0.0%
ERROR: timeout waiting for data (1 bytes)
FAILED: platforms/nuttx/CMakeFiles/upload 
cd /home/maetugr/Firmware/build/px4_fmu-v5_default && /usr/bin/python /home/maetugr/Firmware/Tools/px_uploader.py --port "/dev/serial/by-id/*-3D_Robotics_PX4_FMU_v5.x*,/dev/serial/by-id/*PX4_BL*,/dev/serial/by-id/*BL_FMU*,/dev/serial/by-id/usb-The_Autopilot*,/dev/serial/by-id/usb-Bitcraze*,/dev/serial/by-id/pci-Bitcraze*,/dev/serial/by-id/usb-Gumstix*,/dev/serial/by-id/usb-Hex_ProfiCNC*,/dev/serial/by-id/usb-UVify_FMU_BL*" /home/maetugr/Firmware/build/px4_fmu-v5_default/px4_fmu-v5_default.px4
ninja: build stopped: subcommand failed.
make: *** [Makefile:202: px4_fmu-v5] Error 1
[maetugr@ManjaroVM Firmware]$ make px4_fmu-v5 upload
[0/4] Performing build step for 'px4io_firmware'
ninja: no work to do.
[3/4] uploading px4
==========================================================================================================
WARNING: You should uninstall ModemManager as it conflicts with any non-modem serial device (like Pixhawk)
==========================================================================================================
Loaded firmware for board id: 50,0 size: 1670412 bytes (80.92%), waiting for the bootloader...


Found board id: 50,0 bootloader version: 5 on /dev/serial/by-id/usb-3D_Robotics_PX4_BL_FMU_v5.x_0-if00
sn: 002000223138510138393738
chip: 10016451
family: b'STM32F7[6|7]x'
revision: b'Z'
flash: 2064384 bytes
Windowed mode: False

Erase  : [====================] 100.0%
Program: [                    ] 0.0%
ERROR: timeout waiting for data (1 bytes)
FAILED: platforms/nuttx/CMakeFiles/upload 
cd /home/maetugr/Firmware/build/px4_fmu-v5_default && /usr/bin/python /home/maetugr/Firmware/Tools/px_uploader.py --port "/dev/serial/by-id/*-3D_Robotics_PX4_FMU_v5.x*,/dev/serial/by-id/*PX4_BL*,/dev/serial/by-id/*BL_FMU*,/dev/serial/by-id/usb-The_Autopilot*,/dev/serial/by-id/usb-Bitcraze*,/dev/serial/by-id/pci-Bitcraze*,/dev/serial/by-id/usb-Gumstix*,/dev/serial/by-id/usb-Hex_ProfiCNC*,/dev/serial/by-id/usb-UVify_FMU_BL*" /home/maetugr/Firmware/build/px4_fmu-v5_default/px4_fmu-v5_default.px4
ninja: build stopped: subcommand failed.
make: *** [Makefile:202: px4_fmu-v5] Error 1
[maetugr@ManjaroVM Firmware]$ make px4_fmu-v5 upload
[0/4] Performing build step for 'px4io_firmware'
ninja: no work to do.
[3/4] uploading px4
==========================================================================================================
WARNING: You should uninstall ModemManager as it conflicts with any non-modem serial device (like Pixhawk)
==========================================================================================================
Loaded firmware for board id: 50,0 size: 1670412 bytes (80.92%), waiting for the bootloader...


Found board id: 50,0 bootloader version: 5 on /dev/serial/by-id/usb-3D_Robotics_PX4_BL_FMU_v5.x_0-if00
sn: 003d00233138510638393738
chip: 10016451
family: b'STM32F7[6|7]x'
revision: b'Z'
flash: 2064384 bytes
Windowed mode: False

Erase  : [====================] 100.0%
Program: [                    ] 0.0%
ERROR: timeout waiting for data (1 bytes)
FAILED: platforms/nuttx/CMakeFiles/upload 
cd /home/maetugr/Firmware/build/px4_fmu-v5_default && /usr/bin/python /home/maetugr/Firmware/Tools/px_uploader.py --port "/dev/serial/by-id/*-3D_Robotics_PX4_FMU_v5.x*,/dev/serial/by-id/*PX4_BL*,/dev/serial/by-id/*BL_FMU*,/dev/serial/by-id/usb-The_Autopilot*,/dev/serial/by-id/usb-Bitcraze*,/dev/serial/by-id/pci-Bitcraze*,/dev/serial/by-id/usb-Gumstix*,/dev/serial/by-id/usb-Hex_ProfiCNC*,/dev/serial/by-id/usb-UVify_FMU_BL*" /home/maetugr/Firmware/build/px4_fmu-v5_default/px4_fmu-v5_default.px4
ninja: build stopped: subcommand failed.
make: *** [Makefile:202: px4_fmu-v5] Error 1
[maetugr@ManjaroVM Firmware]$ make px4_fmu-v5 upload
[0/4] Performing build step for 'px4io_firmware'
ninja: no work to do.
[3/4] uploading px4
==========================================================================================================
WARNING: You should uninstall ModemManager as it conflicts with any non-modem serial device (like Pixhawk)
==========================================================================================================
Loaded firmware for board id: 50,0 size: 1670412 bytes (80.92%), waiting for the bootloader...


Found board id: 50,0 bootloader version: 5 on /dev/serial/by-id/usb-3D_Robotics_PX4_BL_FMU_v5.x_0-if00
sn: 002000223138510138393738
chip: 10016451
family: b'STM32F7[6|7]x'
revision: b'Z'
flash: 2064384 bytes
Windowed mode: False

Erase  : [====================] 100.0%
Program: [                    ] 0.0%
ERROR: timeout waiting for data (1 bytes)
FAILED: platforms/nuttx/CMakeFiles/upload 
cd /home/maetugr/Firmware/build/px4_fmu-v5_default && /usr/bin/python /home/maetugr/Firmware/Tools/px_uploader.py --port "/dev/serial/by-id/*-3D_Robotics_PX4_FMU_v5.x*,/dev/serial/by-id/*PX4_BL*,/dev/serial/by-id/*BL_FMU*,/dev/serial/by-id/usb-The_Autopilot*,/dev/serial/by-id/usb-Bitcraze*,/dev/serial/by-id/pci-Bitcraze*,/dev/serial/by-id/usb-Gumstix*,/dev/serial/by-id/usb-Hex_ProfiCNC*,/dev/serial/by-id/usb-UVify_FMU_BL*" /home/maetugr/Firmware/build/px4_fmu-v5_default/px4_fmu-v5_default.px4
ninja: build stopped: subcommand failed.
make: *** [Makefile:202: px4_fmu-v5] Error 1
[maetugr@ManjaroVM Firmware]$ sudo -R pacman modemmanager
sudo: invalid option -- 'R'
usage: sudo -h | -K | -k | -V
usage: sudo -v [-AknS] [-g group] [-h host] [-p prompt] [-u user]
usage: sudo -l [-AknS] [-g group] [-h host] [-p prompt] [-U user] [-u user] [command]
usage: sudo [-AbEHknPS] [-C num] [-g group] [-h host] [-p prompt] [-T timeout] [-u user] [VAR=value] [-i|-s] [<command>]
usage: sudo -e [-AknS] [-C num] [-g group] [-h host] [-p prompt] [-T timeout] [-u user] file ...
[maetugr@ManjaroVM Firmware]$ sudo pacman -R modemmanager
[sudo] password for maetugr: 
checking dependencies...
:: networkmanager optionally requires modemmanager: cellular network support

Packages (1) modemmanager-1.10.4-1

Total Removed Size:  9.55 MiB

:: Do you want to remove these packages? [Y/n] 
:: Processing package changes...
(1/1) removing modemmanager                                                                                                                          [###########################################################################################] 100%
:: Running post-transaction hooks...
(1/5) Reloading system bus configuration...
(2/5) Updating icon theme caches...
(3/5) Reloading system manager configuration...
(4/5) Reloading device manager configuration...
(5/5) Arming ConditionNeedsUpdate...
[maetugr@ManjaroVM Firmware]$ make px4_fmu-v5 upload
[0/4] Performing build step for 'px4io_firmware'
ninja: no work to do.
[3/4] uploading px4
Loaded firmware for board id: 50,0 size: 1670412 bytes (80.92%), waiting for the bootloader...


Found board id: 50,0 bootloader version: 5 on /dev/serial/by-id/usb-3D_Robotics_PX4_BL_FMU_v5.x_0-if00
sn: 002000223138510138393738
chip: 10016451
family: b'STM32F7[6|7]x'
revision: b'Z'
flash: 2064384 bytes
Windowed mode: False

Erase  : [====================] 100.0%
Program: [====================] 100.0%
Verify : [====================] 100.0%
Rebooting. Elapsed Time 28.415

[maetugr@ManjaroVM Firmware]$ make px4_fmu-v5 upload
[0/4] Performing build step for 'px4io_firmware'
ninja: no work to do.
[3/4] uploading px4
Loaded firmware for board id: 50,0 size: 1670412 bytes (80.92%), waiting for the bootloader...


Found board id: 50,0 bootloader version: 5 on /dev/serial/by-id/usb-3D_Robotics_PX4_BL_FMU_v5.x_0-if00
sn: 003d00233138510638393738
chip: 10016451
family: b'STM32F7[6|7]x'
revision: b'Z'
flash: 2064384 bytes
Windowed mode: False

Erase  : [====================] 100.0%
Program: [====================] 100.0%
Verify : [====================] 100.0%
Rebooting. Elapsed Time 28.433

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, just leave it in for now then.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When/if you remove this let me know? The ubuntu.sh removes it too, and should stay/go for same reasons.

As I understand this, it could cause a firmware update to fail. What would that look like to the user? [I'm thinking of adding this as a docs note]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave it in for now and check on it another day.

@hamishwillee it's already covered here: https://dev.px4.io/master/en/debug/faq.html#usb-errors


# arm-none-eabi-gcc
NUTTX_GCC_VERSION="7-2017-q4-major"
GCC_VER_STR=$(arm-none-eabi-gcc --version)
STATUSRETVAL=$(echo $GCC_VER_STR | grep -c "${NUTTX_GCC_VERSION}")

if [ $STATUSRETVAL -eq "1" ]; then
echo "arm-none-eabi-gcc-${NUTTX_GCC_VERSION} found, skipping installation"
else
echo "Installing arm-none-eabi-gcc-${NUTTX_GCC_VERSION}";
wget -O /tmp/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}-linux.tar.bz2 https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/7-2017q4/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}-linux.tar.bz2 && \
sudo tar -jxf /tmp/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}-linux.tar.bz2 -C /opt/;

# add arm-none-eabi-gcc to user's PATH
exportline="export PATH=/opt/gcc-arm-none-eabi-${NUTTX_GCC_VERSION}/bin:\$PATH"

if grep -Fxq "$exportline" $HOME/.profile;
then
echo "${NUTTX_GCC_VERSION} path already set.";
else
echo $exportline >> $HOME/.profile;
fi
fi
fi

# Simulation tools
if [[ $INSTALL_SIM == "true" ]]; then
echo
echo "Installing PX4 simulation dependencies"

# java (jmavsim or fastrtps)
sudo pacman -S --noconfirm --needed \
ant \
jdk8-openjdk \
;
fi

if [[ $INSTALL_NUTTX == "true" ]]; then
echo
echo "Reboot or logout, login computer before attempting to build NuttX targets"
fi
4 changes: 2 additions & 2 deletions Tools/setup/ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
REQUIREMENTS_FILE="requirements.txt"
if [[ ! -f "${DIR}/${REQUIREMENTS_FILE}" ]]; then
echo "FAILED: ${REQUIREMENTS_FILE} needed in same directory as ubuntu.sh (${DIR})."
return 1
return 1
fi


Expand Down Expand Up @@ -216,5 +216,5 @@ fi

if [[ $INSTALL_NUTTX == "true" ]]; then
echo
echo "Reboot computer before attempting to build NUTTX targets"
echo "Reboot or logout, login computer before attempting to build NuttX targets"
fi