-
Notifications
You must be signed in to change notification settings - Fork 13.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Bebop/RPi Toolchain Update v2 #7248
Conversation
Nice! Thanks for taking this up! |
Let me know if you are OK with the approach, I tried to simplify it and it make it easy to change compilers by not hardcoding much. |
Do we need the environment variable PX4_CXX_COMPILER at all? It's generally not a good fit for cmake because various things can cause it to rerun configure right before an incremental build when that environment variable may no longer be set. |
Tools/adb_upload_to_bebop.sh
Outdated
@@ -34,7 +34,7 @@ adb shell mount -o remount,rw / | |||
adb shell touch /home/root/parameters | |||
adb shell mkdir -p /data/ftp/internal_000/fs/microsd | |||
|
|||
${RPI_TOOLCHAIN_DIR}/gcc-linaro-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-strip \ | |||
${PX4_TOOLCHAIN_DIR}/gcc-linaro-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-strip \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why bother stripping before upload? Either let cmake do this (it can find arm-linux-gnueabihf-strip) or consider not bothering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bebop needed the strip for the executable to live on the system partition. Was too big otherwise.
@dagar it was PX4_TOOLCHAIN_DIR before. I would rather get rid of env variables, I've tried using -DCMAKE_CXX_COMPILER without success, for some reason the Toolchain-arm-linux-gnueabihf.cmake file is being parsed twice. Any ideas? |
@dagar , I've changed ii, but since everyone uses "make" in PX4_SOURCE_DIR, we will have to patch the Makefile which invokes CMake to pass the path to the compiler... new usage:
|
Maybe I'm missing something, but I don't see why setting up the environment and building PX4 aren't completely separate things.
|
Tools/adb_upload_to_bebop.sh
Outdated
restart_px4=true | ||
fi | ||
|
||
`dirname ${PX4_CXX_COMPILER}`/arm-linux-gnueabihf-strip \ | ||
-R .comment -R .gnu.version \ | ||
../build_posix_bebop_default/src/firmware/posix/px4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do this as a cmake custom command as it will already have the binary path and arm-linux-gnueabihf-strip.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
custom target like 'make strip' ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kind of like this (https://github.com/PX4/Firmware/blob/master/src/firmware/posix/sitl_tests.cmake#L59), but with add_custom_command (https://cmake.org/cmake/help/v3.0/command/add_custom_command.html).
@@ -8,6 +8,7 @@ include(posix/px4_impl_posix) | |||
add_definitions( | |||
-D__PX4_POSIX_RPI | |||
-D__DF_LINUX # For DriverFramework | |||
-D__DF_RPI # For DriverFramework |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be pushed into https://github.com/PX4/DriverFramework
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where exactly? I see some files in https://github.com/PX4/DriverFramework/tree/master/cmake/toolchains which are not used anywhere in the project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should make a note of it in that repo and come back to it. It seems to me that the DriverFramework cmake should be capable of determining this independently. Especially if there's any value in DF outside of PX4.
@@ -267,22 +267,32 @@ elseif ("${BOARD}" STREQUAL "excelsior") | |||
--sysroot=${HEXAGON_ARM_SYSROOT}/lib32-apq8096 -mfloat-abi=softfp -mfpu=neon -mthumb-interwork | |||
|
|||
) | |||
elseif ("${BOARD}" STREQUAL "rpi" AND "$ENV{RPI_USE_CLANG}" STREQUAL "1") | |||
elseif ("${BOARD}" STREQUAL "rpi") | |||
SET(RPI_COMPILE_FLAGS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this live in the toolchain file or does the existing structure force this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The compiler is not only for RPI, it can be for any ARM CPU, here we are only handling RPI (RPI v3 actually)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it
@dagar ok, that works. Any idea on how to handle Clang ? |
Doesn't that make sense as a separate toolchain file for clang in this situation? Then use find_program to get the arm-linux-gnueabihf path. |
Alright, but how do you tell the build system to pick Clang? We can either add a new target (not desirable), use an environmental variable (again, not desirable), or we could just let the user specify CMAKE_TOOLCHAIN_FILE, and consider this as an advanced configuration. |
Similar issue here - #6892 Some possible solutions
|
@dagar I went with option 3, to fix the CI we need to add the compiler path to PATH, could you help with that please? |
Yes that's fine from my perspective. |
I'm not, should I create a PR there? |
Yes please update the docker file, or I could do it later if you aren't familiar with docker. The idea with add_custom_command is you could let cmake handle the dependencies, find the required tools, and use the path to the binary it already knows. CMake custom targets are always considered out of date and therefore run everytime called. Something like this add_custom_command(OUTPUT px4.stripped
COMMAND arm-linux-gnueabihf-strip -R .comment -R .gnu.version $<TARGET_FILE:px4>
DEPENDS px4) Then the upload could be another dependent custom target that depends on px4.stripped. |
@dagar, hopefully I got it right: PX4/PX4-containers#64 |
I'll give this a try within the updated docker image. Updating semaphore is awkward because the configuration isn't stored within the repository. Thanks for making all these little changes. Getting the structure as simple as possible should help with future platforms and maintenance. |
gentle ping |
We're trying to get a v1.6.0 stable release out, but this can go in right after. I need to find a solution for removing the specific docker container from the non-versioned semaphore config. I was thinking of updating the docker_run.sh script the CI system uses (https://github.com/PX4/Firmware/blob/master/Tools/docker_run.sh) to pick the correct docker image based on input. |
no worries. Should I squash my commits ? |
src/firmware/posix/CMakeLists.txt
Outdated
@@ -138,4 +138,14 @@ install(TARGETS px4 DESTINATION ${CMAKE_INSTALL_BINDIR}) | |||
install(DIRECTORY ${PROJECT_SOURCE_DIR}/ROMFS DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}) | |||
install(DIRECTORY ${PROJECT_SOURCE_DIR}/posix-configs DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}) | |||
|
|||
FIND_PROGRAM(STRIP_TOOL "arm-linux-gnueabihf-strip") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be in the Toolchain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/firmware/posix/CMakeLists.txt
Outdated
) | ||
|
||
add_custom_command(OUTPUT px4.stripped | ||
COMMAND arm-linux-gnueabihf-strip -R .comment -R .gnu.version $<TARGET_FILE:px4> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then use ${STRIP_TOOL} instead of arm-linux-gnueabihf-strip
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Oh, we need to tag your docker changes. |
It'll probably take the better part of an hour for docker hub to build, but once it does can you push a commit to your branch that changes the tag here? https://github.com/PX4/Firmware/blob/master/Tools/docker_run.sh#L8 |
but missed to move it from *-clang.cmake Toolchain Signed-off-by: Nicolae Rosia <nicolae.rosia@gmail.com>
Add CMake target for strip since these changes break adb_upload_to_bebop. GCC users should add the cross compiler bin path to PATH (location of arm-linux-gnueabihf-g++). Clang user should do the following: * set CMAKE_CXX_COMPILER to clang++ by providing -DCMAKE_CXX_COMPILER=clang++ to cmake * get GCC cross compiler - needed because Clang does not ship a CRT * create a symlink for clang and clang++ in GCC cross compiler bin dir. * add GCC bin dir to PATH Signed-off-by: Nicolae Rosia <nicolae.rosia@gmail.com>
Signed-off-by: Nicolae Rosia <nicolae.rosia@gmail.com>
Signed-off-by: Nicolae Rosia <nicolae.rosia@gmail.com>
Signed-off-by: Nicolae Rosia <nicolae.rosia@gmail.com>
@dagar , I have sent a PR for Devguide update, PX4/PX4-Devguide#175 |
src/firmware/posix/CMakeLists.txt
Outdated
) | ||
|
||
add_custom_command(OUTPUT px4.stripped | ||
COMMAND ${STRIP_TOOL} -R .comment -R .gnu.version $<TARGET_FILE:px4> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the upload custom command to depend on the stripped output instead? https://github.com/nicolaerosia/Firmware/blob/f4ba9c5acb3a0efec823e398e76bbbf976013372/src/firmware/posix/CMakeLists.txt#L103
Check the bebop upload dependency, but this looks good to me. @bkueng can you review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Though I have not tested Bebop, only RPi.
Signed-off-by: Nicolae Rosia <nicolae.rosia@gmail.com>
@dagar can we merge this? |
Is anyone able to test bebop? |
@ChristophTobler or @eyeam3 maybe? |
According to @eyeam3 in the v1.6 release sign Bebop wasn't functioning. #7258 (comment) Let's get this in now and revisit once someone is interested in bringing Bebop back to life. |
This is a continuation of #6528
You will need to set
PATH
to a include the path to aarm-linux-gnueabihf-g++
compilerGCC Testing:
a. get rpi-tools,
git clone https://github.com/raspberrypi/tools
b. get a different compiler, like 5.3.1 from Linaro: https://releases.linaro.org/components/toolchain/binaries/5.3-2016.05/arm-linux-gnueabihf/gcc-linaro-5.3.1-2016.05-x86_64_arm-linux-gnueabihf.tar.xz
Clang Testing:
You will need a GCC cross-compiler!
a. get prebuild clang, http://releases.llvm.org/download.html
unpack
Create symlinks for clang and clang++ in gcc cross-compiler dir:
@mhkabir @dagar could you please take a look?