Difference between revisions of "Howto.crosscompile for parrot drones"
(→Start) |
(→About) |
||
(12 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
=About= | =About= | ||
On this page you find one way to compile the drivers for a Parrot Bebop,Bebop2,Disco | On this page you find one way to '''compile the device drivers''' for a Parrot Bebop,Bebop2,Disco. | ||
Works for Parrot mini drones like the Mambo and Swing as well with slight modifications. | |||
'''This is not the page for you''' if you only need to fly a Parrot Drone, in that case just follow regular instructions. | |||
For this to work, remember that there are many ways to Rome... This is just one. | For this to work, remember that there are many ways to Rome... This is just one. | ||
=Start= | =Start= | ||
Line 17: | Line 16: | ||
Install [[www.virtualbox.org | virtual box]], we used v5.2 at the time of writing this page. | Install [[www.virtualbox.org | 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 | 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= | =Install a Virtual machine= | ||
Use the ISO of Debian 7 32-bit this worked, | 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. | ||
==Guest additions== | ==Guest additions== | ||
Line 87: | Line 86: | ||
git clone https://github.com/Parrot-Developers/disco-opensource.git | git clone https://github.com/Parrot-Developers/disco-opensource.git | ||
The same kind of URL if needed for Bebop, Bebop2 or minidrones, you get the drift. | |||
==Patch Parrot drivers sourcecode== | ==Patch Parrot drivers sourcecode== | ||
Line 141: | Line 142: | ||
+ccflags-y += -I$(DRIVER_DIR)/linux/license/gpl | +ccflags-y += -I$(DRIVER_DIR)/linux/license/gpl | ||
+#endif | +#endif | ||
till: | |||
mali-y += \ | mali-y += \ | ||
linux/mali_osk_atomics.o \ | 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 | |||
... | |||
==changeMakefile:== | ==changeMakefile:== | ||
open makefile | If you have a Disco then also change the makefile. Thus open makefile via: | ||
nano makefile | nano makefile | ||
Line 158: | Line 183: | ||
==Mali== | ==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) | 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 | $ su | ||
# cd / | # cd / | ||
# ln -s /home/ | # ln -s /home/yourusername/develop/bebop2-opensource/sources/linux-3.4.11/linux-3.4.11/drivers drivers | ||
=Config= | =Config= | ||
Line 171: | Line 198: | ||
=Environment= | =Environment= | ||
as root run: | 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 | PATH=$PATH:/yourpath/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/libexec/gcc/arm-none-linux-gnueabi/4.6.3 | ||
Line 189: | Line 216: | ||
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- | 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- | ||
TIP: https://www.techrepublic.com/article/how-to-run-virtualbox-virtual-machines-from-the-command-line/ | |||
=Driver info= | =Driver info= |
Latest revision as of 00:53, 6 May 2021
About
On this page you find one way to compile the device drivers for a Parrot Bebop,Bebop2,Disco. Works for Parrot mini drones like the Mambo and Swing as well with slight modifications.
This is not the page for you if you only need to fly a Parrot Drone, in that case just follow regular instructions.
For this to work, remember that there are many ways to Rome... This is just one.
Start
All wrong advise given on the internet, it does not matter to you probbably, but this article is likely 100% right!
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 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.
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
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
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:
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
till:
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 ...
changeMakefile:
If you have a Disco then also change the makefile. Thus open makefile via:
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 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
Config
- rename linux.config to .config
- make the changes to .config required for your modules to be included
Environment
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-
TIP: https://www.techrepublic.com/article/how-to-run-virtualbox-virtual-machines-from-the-command-line/
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...