(window.webpackJsonp=window.webpackJsonp||[]).push([[802],{1617:function(t,a,s){"use strict";s.r(a);var e=s(18),r=Object(e.a)({},(function(){var t=this,a=t.$createElement,s=t._self._c||a;return s("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[s("h1",{attrs:{id:"pilotpi-with-ubuntu-server"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#pilotpi-with-ubuntu-server"}},[t._v("#")]),t._v(" PilotPi with Ubuntu Server")]),t._v(" "),s("div",{staticClass:"custom-block warning"},[s("p",{staticClass:"custom-block-title"},[t._v("WARNING")]),t._v(" "),s("p",[t._v("Ubuntu Server on RPi 4B consumes a lot of current and generates a lot of heat.\nDesign for better heat dissipation and high power consumption when using this hardware.")])]),t._v(" "),s("h2",{attrs:{id:"developer-quick-start"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#developer-quick-start"}},[t._v("#")]),t._v(" Developer Quick Start")]),t._v(" "),s("h3",{attrs:{id:"os-image"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#os-image"}},[t._v("#")]),t._v(" OS Image")]),t._v(" "),s("p",[t._v("Both armhf and arm64 arch are supported.")]),t._v(" "),s("h4",{attrs:{id:"armhf"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#armhf"}},[t._v("#")]),t._v(" armhf")]),t._v(" "),s("ul",[s("li",[s("a",{attrs:{href:"https://cdimage.ubuntu.com/releases/18.04.5/release/ubuntu-18.04.5-preinstalled-server-armhf+raspi2.img.xz",target:"_blank",rel:"noopener noreferrer"}},[t._v("Ubuntu Server 18.04.5 for RPi2"),s("OutboundLink")],1)]),t._v(" "),s("li",[s("a",{attrs:{href:"https://cdimage.ubuntu.com/releases/18.04.5/release/ubuntu-18.04.5-preinstalled-server-armhf+raspi3.img.xz.zsync",target:"_blank",rel:"noopener noreferrer"}},[t._v("Ubuntu Server 18.04.5 for RPi3"),s("OutboundLink")],1)]),t._v(" "),s("li",[s("a",{attrs:{href:"https://cdimage.ubuntu.com/releases/18.04.5/release/ubuntu-18.04.5-preinstalled-server-armhf+raspi4.img.xz",target:"_blank",rel:"noopener noreferrer"}},[t._v("Ubuntu Server 18.04.5 for RPi4"),s("OutboundLink")],1)]),t._v(" "),s("li",[s("a",{attrs:{href:"https://cdimage.ubuntu.com/releases/20.04.1/release/ubuntu-20.04.1-preinstalled-server-armhf+raspi.img.xz",target:"_blank",rel:"noopener noreferrer"}},[t._v("Ubuntu Server 20.04.1 for RPi 2/3/4"),s("OutboundLink")],1)])]),t._v(" "),s("h4",{attrs:{id:"arm64"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#arm64"}},[t._v("#")]),t._v(" arm64")]),t._v(" "),s("ul",[s("li",[s("a",{attrs:{href:"https://cdimage.ubuntu.com/releases/18.04.5/release/ubuntu-18.04.5-preinstalled-server-arm64+raspi3.img.xz",target:"_blank",rel:"noopener noreferrer"}},[t._v("Ubuntu Server 18.04.5 for RPi3"),s("OutboundLink")],1)]),t._v(" "),s("li",[s("a",{attrs:{href:"https://cdimage.ubuntu.com/releases/18.04.5/release/ubuntu-18.04.5-preinstalled-server-arm64+raspi4.img.xz",target:"_blank",rel:"noopener noreferrer"}},[t._v("Ubuntu Server 18.04.5 for RPi4"),s("OutboundLink")],1)]),t._v(" "),s("li",[s("a",{attrs:{href:"https://cdimage.ubuntu.com/releases/20.04.1/release/ubuntu-20.04.1-preinstalled-server-arm64+raspi.img.xz",target:"_blank",rel:"noopener noreferrer"}},[t._v("Ubuntu Server 20.04.1 for RPi 3/4"),s("OutboundLink")],1)])]),t._v(" "),s("h4",{attrs:{id:"latest-os"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#latest-os"}},[t._v("#")]),t._v(" Latest OS")]),t._v(" "),s("p",[t._v("Please refer to official "),s("a",{attrs:{href:"https://cdimage.ubuntu.com/releases/",target:"_blank",rel:"noopener noreferrer"}},[t._v("cdimage"),s("OutboundLink")],1),t._v(" page for any new updates.")]),t._v(" "),s("h3",{attrs:{id:"first-boot"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#first-boot"}},[t._v("#")]),t._v(" First boot")]),t._v(" "),s("p",[t._v("When setting up RaPi's WiFi for the first time we recommended using a wired Ethernet connection between your home router and RPi, and a monitor and keyboard.")]),t._v(" "),s("h4",{attrs:{id:"before-booting"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#before-booting"}},[t._v("#")]),t._v(" Before booting")]),t._v(" "),s("p",[t._v("Mount the SD card onto your computer and modify the network settings.\nPlease follow the official instruction "),s("a",{attrs:{href:"https://ubuntu.com/tutorials/how-to-install-ubuntu-on-your-raspberry-pi#3-wifi-or-ethernet",target:"_blank",rel:"noopener noreferrer"}},[t._v("here"),s("OutboundLink")],1),t._v(".")]),t._v(" "),s("p",[t._v("Now plug the SD card onto your Pi and boot for the first time.\nMake sure you have shell access to the RPi - either SSH connection over wired Ethernet, or direct accessing with keyboard and monitor.")]),t._v(" "),s("h4",{attrs:{id:"wifi-region"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#wifi-region"}},[t._v("#")]),t._v(" WiFi region")]),t._v(" "),s("p",[t._v("First install required package:")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("sudo")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("apt-get")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("install")]),t._v(" crda\n")])])]),s("p",[t._v("Edit the file "),s("code",[t._v("/etc/default/crda")]),t._v(" to change the correct WiFi region. "),s("a",{attrs:{href:"https://www.arubanetworks.com/techdocs/InstantWenger_Mobile/Advanced/Content/Instant%20User%20Guide%20-%20volumes/Country_Codes_List.htm",target:"_blank",rel:"noopener noreferrer"}},[t._v("Reference List"),s("OutboundLink")],1)]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("sudo")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("nano")]),t._v(" /etc/default/crda\n")])])]),s("p",[t._v("Then your Pi will able to join your WiFi network after reboot.")]),t._v(" "),s("h4",{attrs:{id:"hostname-and-mdns"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#hostname-and-mdns"}},[t._v("#")]),t._v(" Hostname and mDNS")]),t._v(" "),s("p",[t._v("Let's set up hostname at first.")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("sudo")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("nano")]),t._v(" /etc/hostname\n")])])]),s("p",[t._v("Change the hostname to whatever you like.\nThen install the package required by mDNS:")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("sudo")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("apt-get")]),t._v(" update\n"),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("sudo")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("apt-get")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("install")]),t._v(" avahi-daemon\n")])])]),s("p",[t._v("Perform a reboot.")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("sudo")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("reboot")]),t._v("\n")])])]),s("p",[t._v("Regain the accessibility through WiFi connection after the above operation.")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("ssh")]),t._v(" ubuntu@pi_hostname.local\n")])])]),s("h4",{attrs:{id:"password-less-auth-optional"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#password-less-auth-optional"}},[t._v("#")]),t._v(" Password-less Auth (Optional)")]),t._v(" "),s("p",[t._v("You may want to setup "),s("a",{attrs:{href:"https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md",target:"_blank",rel:"noopener noreferrer"}},[t._v("passwordless auth"),s("OutboundLink")],1),t._v(" as well.")]),t._v(" "),s("h3",{attrs:{id:"setting-up-os"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#setting-up-os"}},[t._v("#")]),t._v(" Setting up OS")]),t._v(" "),s("h4",{attrs:{id:"config-txt"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#config-txt"}},[t._v("#")]),t._v(" config.txt")]),t._v(" "),s("p",[t._v("The corresponding file in Ubuntu is "),s("code",[t._v("/boot/firmware/usercfg.txt")]),t._v(".")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("sudo")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("nano")]),t._v(" /boot/firmware/usercfg.txt\n")])])]),s("p",[t._v("Replace the file with:")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# enable sc16is752 overlay")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token assign-left variable"}},[t._v("dtoverlay")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v("sc16is752-spi1\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# enable I2C-1 and set the frequency to 400KHz")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token assign-left variable"}},[t._v("dtparam")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v("i2c_arm"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v("on,i2c_arm_baudrate"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("400000")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# enable spidev0.0")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token assign-left variable"}},[t._v("dtparam")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v("spi"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v("on\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# enable RC input")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token assign-left variable"}},[t._v("enable_uart")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("1")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# enable I2C-0")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token assign-left variable"}},[t._v("dtparam")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v("i2c_vc"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v("on\n"),s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# switch Bluetooth to miniuart")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token assign-left variable"}},[t._v("dtoverlay")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v("miniuart-bt\n")])])]),s("h4",{attrs:{id:"cmdline-txt"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#cmdline-txt"}},[t._v("#")]),t._v(" cmdline.txt")]),t._v(" "),s("p",[t._v("On Ubuntu Server 20.04:")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("sudo")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("nano")]),t._v(" /boot/firmware/cmdline.txt\n")])])]),s("p",[t._v("On Ubuntu Server 18.04 or earlier, "),s("code",[t._v("nobtcmd.txt")]),t._v(" and "),s("code",[t._v("btcmd.txt")]),t._v(" should both be modified.")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("sudo")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("nano")]),t._v(" /boot/firmware/nobtcmd.txt\n")])])]),s("p",[t._v("Find "),s("code",[t._v("console=/dev/ttyAMA0,115200")]),t._v(" and remove that part to disable the login shell on serial interface.")]),t._v(" "),s("p",[t._v("Append "),s("code",[t._v("isolcpus=2")]),t._v(" after the last word.\nThe whole file will then look like:")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[t._v("net.ifnames"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("0")]),t._v(" dwc_otg.lpm_enable"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("0")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token assign-left variable"}},[t._v("console")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v("tty1 "),s("span",{pre:!0,attrs:{class:"token assign-left variable"}},[t._v("root")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v("LABEL"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v("writable "),s("span",{pre:!0,attrs:{class:"token assign-left variable"}},[t._v("rootfstype")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v("ext4 "),s("span",{pre:!0,attrs:{class:"token assign-left variable"}},[t._v("elevator")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v("deadline rootwait fixrtc "),s("span",{pre:!0,attrs:{class:"token assign-left variable"}},[t._v("isolcpus")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),t._v("\n")])])]),s("p",[t._v("The above line tells the Linux kernel do not schedule any process on CPU core 2.\nWe will manually run PX4 onto that core later.")]),t._v(" "),s("p",[t._v("Reboot and SSH onto your Pi.")]),t._v(" "),s("p",[t._v("Check UART interface:")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("ls")]),t._v(" /dev/tty*\n")])])]),s("p",[t._v("There should be "),s("code",[t._v("/dev/ttyAMA0")]),t._v(", "),s("code",[t._v("/dev/ttySC0")]),t._v(" and "),s("code",[t._v("/dev/ttySC1")]),t._v(".")]),t._v(" "),s("p",[t._v("Check I2C interface:")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("ls")]),t._v(" /dev/i2c*\n")])])]),s("p",[t._v("There should be "),s("code",[t._v("/dev/i2c-0")]),t._v(" and "),s("code",[t._v("/dev/i2c-1")])]),t._v(" "),s("p",[t._v("Check SPI interface:")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("ls")]),t._v(" /dev/spidev*\n")])])]),s("p",[t._v("There should be "),s("code",[t._v("/dev/spidev0.0")]),t._v(".")]),t._v(" "),s("h4",{attrs:{id:"rc-local"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#rc-local"}},[t._v("#")]),t._v(" rc.local")]),t._v(" "),s("p",[t._v("In this section we will configure the auto-start script in "),s("strong",[t._v("rc.local")]),t._v(".\nNote that we need to create this file, as it is not present on a fresh Ubuntu OS.")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("sudo")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("nano")]),t._v(" /etc/rc.local\n")])])]),s("p",[t._v("Append the content below to the file:")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token shebang important"}},[t._v("#!/bin/sh")]),t._v("\n\n"),s("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("echo")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"25"')]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v(" /sys/class/gpio/export\n"),s("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("echo")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"in"')]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v(" /sys/class/gpio/gpio25/direction\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("if")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token variable"}},[s("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$(")]),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("cat")]),t._v(" /sys/class/gpio/gpio25/value"),s("span",{pre:!0,attrs:{class:"token variable"}},[t._v(")")])]),t._v(" -eq "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("1")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("then")]),t._v("\n        "),s("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("echo")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"Launching PX4"')]),t._v("\n        "),s("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("cd")]),t._v(" /home/ubuntu/px4 "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("nohup")]),t._v(" taskset -c "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),t._v(" ./bin/px4 -d -s pilotpi_mc.config "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&>")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("1")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v(" /home/ubuntu/px4/px4.log "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("fi")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("echo")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"25"')]),t._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v(" /sys/class/gpio/unexport\n\n"),s("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("exit")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("0")]),t._v("\n")])])]),s("p",[t._v("Save and exit.\nThen set the correct permissions:")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("sudo")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("chmod")]),t._v(" +x /etc/rc.local\n")])])]),s("div",{staticClass:"custom-block note"},[s("p",{staticClass:"custom-block-title"},[t._v("Note")]),t._v(" "),s("p",[t._v("Don't forget to turn off the switch when it is not needed!")])]),t._v(" "),s("h4",{attrs:{id:"csi-camera"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#csi-camera"}},[t._v("#")]),t._v(" CSI camera")]),t._v(" "),s("div",{staticClass:"custom-block warning"},[s("p",{staticClass:"custom-block-title"},[t._v("WARNING")]),t._v(" "),s("p",[t._v("Enable CSI camera will stop anything works on I2C-0.")])]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("sudo")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("nano")]),t._v(" /boot/firmware/usercfg.txt\n")])])]),s("p",[t._v("Append the following line at the end of file:")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token assign-left variable"}},[t._v("start_x")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("1")]),t._v("\n")])])]),s("h3",{attrs:{id:"building-the-code"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#building-the-code"}},[t._v("#")]),t._v(" Building the code")]),t._v(" "),s("p",[t._v("To get the "),s("em",[t._v("very latest")]),t._v(" version onto your computer, enter the following command into a terminal:")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("git")]),t._v(" clone https://github.com/PX4/PX4-Autopilot.git --recursive\n")])])]),s("div",{staticClass:"custom-block note"},[s("p",{staticClass:"custom-block-title"},[t._v("Note")]),t._v(" "),s("p",[t._v("This is all you need to do just to build the latest code.")])]),t._v(" "),s("h4",{attrs:{id:"set-rpi-upload-target"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#set-rpi-upload-target"}},[t._v("#")]),t._v(" Set RPi upload target")]),t._v(" "),s("p",[t._v("Set the IP (or hostname) of your RPi using:")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("export")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token assign-left variable"}},[t._v("AUTOPILOT_HOST")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("192.168")]),t._v(".X.X\n")])])]),s("p",[t._v("or")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("export")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token assign-left variable"}},[t._v("AUTOPILOT_HOST")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v("pi_hostname.local\n")])])]),s("p",[t._v("Additionally, we need to set the username:")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("export")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token assign-left variable"}},[t._v("AUTOPILOT_USER")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v("ubuntu\n")])])]),s("h4",{attrs:{id:"build-for-armhf-target"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#build-for-armhf-target"}},[t._v("#")]),t._v(" Build for armhf target")]),t._v(" "),s("p",[t._v("Build the executable file:")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("cd")]),t._v(" Firmware\n"),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("make")]),t._v(" scumaker_pilotpi_default\n")])])]),s("p",[t._v("Then upload it with:")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("make")]),t._v(" scumaker_pilotpi_default upload\n")])])]),s("h4",{attrs:{id:"alternative-build-method-for-armhf-using-docker"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#alternative-build-method-for-armhf-using-docker"}},[t._v("#")]),t._v(" Alternative build method for armhf (using docker)")]),t._v(" "),s("p",[t._v("If you are compiling for the first time with docker, please refer to the "),s("RouterLink",{attrs:{to:"/en/test_and_ci/docker.html#prerequisites"}},[t._v("offical docs")]),t._v(".")],1),t._v(" "),s("p",[t._v("Execute the command in firmware folder:")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[t._v("./Tools/docker_run.sh "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"export AUTOPILOT_HOST=192.168.X.X; export AUTOPILOT_USER=ubuntu; export NO_NINJA_BUILD=1; make scumaker_pilotpi_default upload"')]),t._v("\n")])])]),s("div",{staticClass:"custom-block note"},[s("p",{staticClass:"custom-block-title"},[t._v("Note")]),t._v(" "),s("p",[t._v("mDNS is not supported within docker. You must specify the correct IP address every time when uploading.")])]),t._v(" "),s("div",{staticClass:"custom-block note"},[s("p",{staticClass:"custom-block-title"},[t._v("Note")]),t._v(" "),s("p",[t._v("If your IDE doesn't support ninja build, "),s("code",[t._v("NO_NINJA_BUILD=1")]),t._v(" option will help.\nYou can compile without uploading too. Just remove "),s("code",[t._v("upload")]),t._v(" target.")])]),t._v(" "),s("p",[t._v("It is also possible to just compile the code with command:")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[t._v("./Tools/docker_run.sh "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"make scumaker_pilotpi_default"')]),t._v("\n")])])]),s("h4",{attrs:{id:"build-for-arm64-target"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#build-for-arm64-target"}},[t._v("#")]),t._v(" Build for arm64 target")]),t._v(" "),s("div",{staticClass:"custom-block note"},[s("p",{staticClass:"custom-block-title"},[t._v("Note")]),t._v(" "),s("p",[t._v("This step requires "),s("code",[t._v("aarch64-linux-gnu")]),t._v(" tool-chain to be installed.")])]),t._v(" "),s("p",[t._v("Build the executable file:")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("cd")]),t._v(" PX4-Autopilot\n"),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("make")]),t._v(" scumaker_pilotpi_arm64\n")])])]),s("p",[t._v("Then upload it with:")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("make")]),t._v(" scumaker_pilotpi_arm64 upload\n")])])]),s("h4",{attrs:{id:"alternative-build-method-for-arm64-using-docker"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#alternative-build-method-for-arm64-using-docker"}},[t._v("#")]),t._v(" Alternative build method for arm64 (using docker)")]),t._v(" "),s("p",[t._v("If you are compiling for the first time with docker, please refer to the "),s("RouterLink",{attrs:{to:"/en/test_and_ci/docker.html#prerequisites"}},[t._v("offical docs")]),t._v(".")],1),t._v(" "),s("p",[t._v("Execute the command in "),s("code",[t._v("PX4-Autopilot")]),t._v(" folder:")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[t._v("./Tools/docker_run.sh "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"export AUTOPILOT_HOST=192.168.X.X; export AUTOPILOT_USER=ubuntu; export NO_NINJA_BUILD=1; make scumaker_pilotpi_arm64 upload"')]),t._v("\n")])])]),s("div",{staticClass:"custom-block note"},[s("p",{staticClass:"custom-block-title"},[t._v("Note")]),t._v(" "),s("p",[t._v("mDNS is not supported within docker. You must specify the correct IP address everytime when uploading.")])]),t._v(" "),s("div",{staticClass:"custom-block note"},[s("p",{staticClass:"custom-block-title"},[t._v("Note")]),t._v(" "),s("p",[t._v("If your IDE doesn't support ninja build, "),s("code",[t._v("NO_NINJA_BUILD=1")]),t._v(" option will help.\nYou can compile without uploading too - just remove the "),s("code",[t._v("upload")]),t._v(" target.")])]),t._v(" "),s("p",[t._v("It is also possible to just compile the code with command:")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[t._v("./Tools/docker_run.sh "),s("span",{pre:!0,attrs:{class:"token string"}},[t._v('"make scumaker_pilotpi_arm64"')]),t._v("\n")])])]),s("h4",{attrs:{id:"manually-run-px4"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#manually-run-px4"}},[t._v("#")]),t._v(" Manually run PX4")]),t._v(" "),s("p",[t._v("Connect over SSH and run it with:")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("cd")]),t._v(" px4\n"),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("sudo")]),t._v(" taskset -c "),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),t._v(" ./bin/px4 -s pilotpi_mc.config\n")])])]),s("p",[t._v("Now PX4 is started with multi-rotor configuration.")]),t._v(" "),s("p",[t._v("If you encountered the similar problem executing "),s("code",[t._v("bin/px4")]),t._v(" on your Pi as following:")]),t._v(" "),s("div",{staticClass:"language- extra-class"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[t._v("bin/px4: /lib/xxxx/xxxx: version `GLIBC_2.29' not found (required by bin/px4)\n")])])]),s("p",[t._v("Then you should compile with docker instead.")]),t._v(" "),s("p",[t._v("Before proceeding to next step, clear the existing building at first:")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("rm")]),t._v(" -rf build/scumaker_pilotpi_*\n")])])]),s("p",[t._v("Then go back to the corresponding chapter above.")]),t._v(" "),s("h3",{attrs:{id:"post-configuration"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#post-configuration"}},[t._v("#")]),t._v(" Post-configuration")]),t._v(" "),s("p",[t._v("Please refer to the instructions "),s("RouterLink",{attrs:{to:"/en/flight_controller/raspberry_pi_pilotpi_rpios.html"}},[t._v("here")])],1)])}),[],!1,null,null,null);a.default=r.exports}}]);