Mavsdk: Cross-compile and deploy for Raspberry Pi

Created on 26 Nov 2018  路  12Comments  路  Source: mavlink/MAVSDK

It would actually be very nice if we could also generate a .deb for Raspbian, so it can be installed easily on Raspberry Pi.

Building on Raspberry Pi is really quite slow, especially when you would add the gRPC backend.

beginner enhancement

All 12 comments

I'm not sure this is a beginner issue :sweat_smile:.

This means that you need to cross-compile all the libs for rpi, and last time I tried it was already not working for curl (I contributed to fix the bug, and I believe it was working in the end).

Still with curl, one issue we have is that we don't really compile it from sources but have this "curl-android-ios" for Android and iOS, which is already some kind of workaround.

Love the idea.

More generally we still need an idiot proof deployment of all our runtimes for our supported platforms - ie no more pointing people to the build page at all.

It's good for an SDK beginner knowing cross-compilation :smile:

More generally we still need an idiot proof deployment of all our runtimes for our supported platforms - ie no more pointing people to the build page at all.

I agree.

This will be easier after #724.

I'm taking this task.

Wait, I can help with the latest develop! Which architecture do you need to build? armv7?

yes, I would be building for armv7, Rpi.

Would you mind trying with dockcross? I think I successfully built the C++ SDK (I did not try the backend):

cd /path/to/DronecodeSDK
docker run --rm dockcross/linux-armv7 > ./dockcross
chmod +x dockcross
./dockcross cmake -DCMAKE_INSTALL_PREFIX=install_armv7 -Bbuild/armv7 -S.
./dockcross cmake --build build/armv7 --target install

And then I checked that a library was indeed an ARM binary:

file install_armv7/lib/libdronecode_sdk.so
install_armv7/lib/libdronecode_sdk.so: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (GNU/Linux), dynamically linked, with debug_info, not stripped

Seems like building the backend has issues, though ($ ./dockcross cmake -DCMAKE_INSTALL_PREFIX=install_armv7 -DBUILD_BACKEND=ON -Bbuild/armv7 -S.). @ameya7295 if you feel like debugging that, that would be awesome. It seems like FindZLIB.cmake doesn't find zlib when building gRPC. However, it also says:

CMake variable ZLIB_ROOT is set to:

/work/build/armv7/third_party/install

and zlib is indeed installed there. But still it errors with:

CMake Error at /usr/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)

For debugging, I would either run the dockcross image interactively (docker run --rm -it dockcross/linux-armv7 /bin/bash) or try to build on a RPi natively (i.e. without dockcross), to see if it is reproducible there.

okay, I would give this a try. thanks for sharing the required info.

Now wondering if it could be related to this cmake bug... :thinking:

Thanks to @JonasVautherin's fix against Dockcross this should work now:

docker run --rm dockcross/linux-armv7 > ./dockcross-linux-armv7
chmod +x ./dockcross-linux-armv7
./dockcross-linux-armv7 cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_BACKEND=ON -DBUILD_SHARED_LIBS=OFF -Bbuild/linux-armv7 -S.
./dockcross-linux-armv7 cmake --build build/linux-armv7 -j 8

Please re-open the issue if this is still a problem.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hamishwillee picture hamishwillee  路  6Comments

shakthi-prashanth-m picture shakthi-prashanth-m  路  7Comments

bresch picture bresch  路  5Comments

dangviethieu picture dangviethieu  路  6Comments

petergerten picture petergerten  路  6Comments