Howto.crosscompile for parrot drones
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.
All wrong advise given on the internet, it does not matter to you probbably, but this article is likely 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, grrrr :(. Believe it, we spend an all-nighter on it. Thanks to uavpal and his disco4g's hint that also his cross-compile efforts did not pan out on native 64 OS. It did only work for him on a 32bit Linux OS. So yes, we admit, we are sissy boys; we gave up on native crosscompiling on 64bit Linux for 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, find e.g. here https://cdimage.debian.org/cdimage/archive/7.11.0/i386/iso-dvd/ , a network install might not work when the LTS period is over.
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
The same kind of URL if needed for Bebop, Bebop2 or minidrones, you get the drift.
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 \
If you do not know how to apply a patch file, one can also use a text editor like nano and comment out the lines oneself so it looks, but do not add the three dots (...) , like:
... #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 ...
If you have a Disco then also change the makefile. Thus open makefile via:
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 way to do things, but a quick and dirty solution that works...)
Where you have to change the path to where you copier your source files ofcourse. So for a developer who stores all its code in a ~/develop directory and wants to compile for e.g. Bebop2 steps would like:
$ su # cd / # ln -s /home/yourusername/develop/bebop2-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: (Hint: Where "yourpath" is the path where you installed your toolchain...)
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-
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...