Howto.crosscompile for parrot drones

From PaparazziUAV
Revision as of 09:00, 3 December 2018 by Openuas (talk | contribs) (About)

Jump to: navigation, search

About

On this page you find one way to compile the drivers for a Parrot Bebop,Bebop2,Disco or maybe even the nice Anafi. Could well work for other Parrot mini drones also with maybe slight modifications.

For this to work, remember that there are many ways to Rome... This is just one.

TIP: https://www.techrepublic.com/article/how-to-run-virtualbox-virtual-machines-from-the-command-line/

Start

This article is probably 100% right!

https://blukat29.github.io/2017/12/cross-compile-arm-kernel-module/

Virtual Box

Install virtual box, we used v5.2 at the time of writing this page.

Native cross-compiling 64-bit did not work for us, grrrr :(. Believe us that we spend quite an all-nighter on it. Thanks to uavpal and his disco4g hint that also his cross-compile efforts did not pan out. It did only work for hime also on a 32bit machine. So yes, we admit, we are sissy boys. we gave up native crosscompile on 64bit Linus fro this Busybox one. Anyhow The way it is described, it all worked out, so let's be pragmatic for once...

Install a Virtual machine

Use the ISO of Debian 7 32-bit this worked,

Guest additions

Follow these steps to install the VirtualBox Guest Additions on your Linux Debian virtual machine:

Open terminal and become root (su); if you have sudo enabled, you may also do for example sudo -i; see man sudo for all options):

su

Update APT cache:

apt-get update

Install the latest security updates: This step will upgrade all your packages, so be wise about it. Try the following steps first and they might be enough to work if not, then perform upgrade and retry.

apt-get upgrade

Install these required packages:

Packages build-essential and module-assistant are both required to be able to compile the kernel modules and so when installing the VirtualBox Linux Guest Additions you must have them. So, this command will get the headers and packages (compilers and libraries) required to work. Notice, that after installing your VirtualBox Linux Guest Additions you will leave behind some packages as well as Linux headers, which you might delete afterwards or not. In my case they didn't hurt, but for the sake of system tidiness, you might want to pick up after playing.

apt-get install build-essential module-assistant

Configure your system for building kernel modules:

m-a prepare

Insert Guest Additions ISO:

Expand menu Devices and click on Insert Guest Additions CD image...

It should mount automatically, but if for any reason it doesn't:

mount /media/cdrom
Run the following script:

sh /media/cdrom/VBoxLinuxAdditions.run

Restart the system:

reboot

Shared folder

Handy to transfer your .ko to drone from within host OS

https://help.ubuntu.com/community/VirtualBox/SharedFolders

Toolchain in virtual box

Download the toolchain from here via:

wget https://openuas.org/pub/mirrors/gnu/gnu_toolchain/arm-none-linux-gnueabi/arm-2012.03-57-arm-none-linux-gnueabi.bin

Tools

Install tools needed via:

$ sudo apt-get install make gcc build-essential

Get Parrot drivers sourcecode

git clone https://github.com/Parrot-Developers/disco-opensource.git

Patch Parrot drivers sourcecode

To be able to compile the whole enchilada, we need to fix something in Parrot sourcecode:

Patch

drivers/parrot/gpu/ump/mali_files/Kbuild

and

drivers/parrot/gpu/mali400/Kbuild
https://github.com/96boards/meta-96boards/blob/master/recipes-kernel/linux/linux-96boards/0005-drivers-gpu-arm-utgard-Fix-build-issue.patch


    diff --git a/sources/linux-3.4.11/linux-3.4.11/drivers/parrot/gpu/mali400/Kbuild b/sources/linux-3.4.11/linux-3.4.11/drivers/parrot/gpu/mali400/Kbuild
   index a4481dd..5c45684 100755
   --- a/sources/linux-3.4.11/linux-3.4.11/drivers/parrot/gpu/mali400/Kbuild
   +++ b/sources/linux-3.4.11/linux-3.4.11/drivers/parrot/gpu/mali400/Kbuild
   @@ -25,21 +25,21 @@ DRIVER_DIR=$(KBUILD_SRC)/$(src)
    # For customer releases the Linux Device Drivers will be provided as ARM proprietary and GPL releases:
    # The ARM proprietary product will only include the license/proprietary directory
    # The GPL product will only include the license/gpl directory
   -ifeq ($(wildcard $(DRIVER_DIR)/linux/license/gpl/*),)
   -    ccflags-y += -I$(DRIVER_DIR)/linux/license/proprietary
   -    ifeq ($(CONFIG_MALI400_PROFILING),y)
   -        $(error Profiling is incompatible with non-GPL license)
   -    endif
   -    ifeq ($(CONFIG_PM_RUNTIME),y)
   -        $(error Runtime PM is incompatible with non-GPL license)
   -    endif
   -    ifeq ($(CONFIG_DMA_SHARED_BUFFER),y)
   -        $(error DMA-BUF is incompatible with non-GPL license)
   -    endif
   -    $(error Linux Device integration is incompatible with non-GPL license)
   -else
   -    ccflags-y += -I$(DRIVER_DIR)/linux/license/gpl
   -endif
   +#ifeq ($(wildcard $(DRIVER_DIR)/linux/license/gpl/*),)
   +#    ccflags-y += -I$(DRIVER_DIR)/linux/license/proprietary
   +#    ifeq ($(CONFIG_MALI400_PROFILING),y)
   +#        $(error Profiling is incompatible with non-GPL license)
   +#    endif
   +#    ifeq ($(CONFIG_PM_RUNTIME),y)
   +#        $(error Runtime PM is incompatible with non-GPL license)
   +#    endif
   +#    ifeq ($(CONFIG_DMA_SHARED_BUFFER),y)
   +#        $(error DMA-BUF is incompatible with non-GPL license)
   +#    endif
   +#    $(error Linux Device integration is incompatible with non-GPL license)
   +#else
   +ccflags-y += -I$(DRIVER_DIR)/linux/license/gpl
   +#endif
mali-y += \
   linux/mali_osk_atomics.o \

changeMakefile:

open makefile

nano makefile

add a plus ( + ) to the line

EXTRAVERSION:

EXTRAVERSION = +

Mali

to prevent errors like '/bin/sh: line 0: cd: /drivers/parrot/gpu/mali400: No such file or directory' while compiling, create symlink (stupid, but works)

$ su
# cd /
# ln -s /home/n3yh3hnii/develop/disco-opensource/sources/linux-3.4.11/linux-3.4.11/drivers drivers

Config

  1. rename linux.config to .config
  2. make the changes to .config required for your modules to be included

Environment

as root run:

PATH=$PATH:/yourpath/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/libexec/gcc/arm-none-linux-gnueabi/4.6.3
export ARCH=arm
export CROSS_COMPILE=/yourpath/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin/arm-none-linux-gnueabi-
make oldconfig
make clean
make zImage
make modules

Sadly we have to compile the entire kernel first, the "make zImage" part, if you don’t, the checksums used by Module.symvers (CONFIG_MODVERSIONS) will not match! And your modules will never un on a Parrot drone.

Reminder to self

j8 since..., well we have a fast PC lets also use it.

make -C /home/n$USER/develop/allthings_parrot/disco/disco-opensource/sources/linux-3.4.11/linux-3.4.11/ -j8 ARCH=arm CROSS_COMPILE=/opt/extra/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin/arm-none-linux-gnueabi-

Driver info

To get some more info of your comoiled drivers, these example might come in handy

$ readelf -a usbserial.ko
$ file usbserial.ko
$ modinfo usbserial.ko

Links

  • Nothing, feel free to add...