Howto.crosscompile for parrot drones
On this page you find one way to compile the drivers for a Parrot Bebop,Bebop2,Disco or who knows... Anafi. Could well work for others also with maybe slight modifications.
For this to work, remember that there are many ways to Rome... This is just one.
This article is probably 100% right!
Install virtual box, we used v5.2 at the time of writing this page.
Native cross-compiling 64-bit did not work for us, and we spend quite an allnighter on it. 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,
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):
Update APT cache:
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.
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:
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:
Run the following script:
Restart the system:
Handy to transfer your .ko to drone from within host OS
Toolchain in virtual box
Download the toolchain from here via:
Install tools needed via:
$ sudo apt-get install make gcc build-essential
Get Parrot drivers sourcecode
Patch Parrot drivers sourcecode
To be able to compile the whole enchilada, we need to fix something in Parrot sourcecode:
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 \
add a plus ( + ) to the line
EXTRAVERSION = +
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
- rename linux.config to .config
- make the changes to .config required for your modules to be included
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.
Reminter to self
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-
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
- Nothing, feel free to add...