Skip to content
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

HOW to build ros2 canopen raspberrypi4B on x86 platform with cross-compilation? #251

Open
zouzhe1 opened this issue Jan 20, 2024 · 2 comments
Labels
question Further information is requested

Comments

@zouzhe1
Copy link

zouzhe1 commented Jan 20, 2024

Target Device: Raspberry Pi 4B with Ubuntu 22,
Local Device: x86_64 with Ubuntu 22.

Due to the limited memory on my Raspberry Pi 4B, the compilation speed of ROS 2 CANopen is extremely slow, and it often freezes.

Therefore, I intend to perform cross-compilation on my PC.

How should I proceed with cross-compilation?

It would be preferable if you could provide a binary version that can be installed using sudo.

@zouzhe1 zouzhe1 added the question Further information is requested label Jan 20, 2024
@LudoJ49
Copy link

LudoJ49 commented Jan 25, 2024

use this to create 2G of extra swap memory...

sudo fallocate -l 2G /swapfile    # Adjust size as needed (2G in this example)
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

@MichaelT800
Copy link

MichaelT800 commented May 13, 2024

Since lely_core_libraries is generated for x86 architecture, you need to modify the CMakeLists.txt of this package.

add:Cross-compilation or normal compilation

if(CMAKE_CROSSCOMPILING)
set(CONFIGURE_COMMAND_PREFIX . ${CMAKE_CURRENT_SOURCE_DIR}/arm64_toolchain.sh &&)
set(CONFIGURE_HOST_OPTION --host=aarch64-linux-gnu)
else()
set(CONFIGURE_COMMAND_PREFIX "")
set(CONFIGURE_HOST_OPTION "")
endif()

modifications

CONFIGURE_COMMAND ${CONFIGURE_COMMAND_PREFIX} autoreconf -i <SOURCE_DIR> && <SOURCE_DIR>/configure ${CONFIGURE_HOST_OPTION} --prefix=<INSTALL_DIR> --disable-cython --disable-doc --disable-tests --disable-static --disable-diag
as such
截图 2024-05-13 10-22-54
The arm64_toolchain.sh file is placed in the same directory as the CMakeLists.txt file in the package, with the following contents
#!/bin/sh
export CC=/usr/bin/aarch64-linux-gnu-gcc
export CXX=/usr/bin/aarch64-linux-gnu-g++
export AR=/usr/bin/aarch64-linux-gnu-ar
export AS=/usr/bin/aarch64-linux-gnu-as
export LD=/usr/bin/aarch64-linux-gnu-ld
export STRIP=/usr/bin/aarch64-linux-gnu-strip
export RANLIB=/usr/bin/aarch64-linux-gnu-ranlib

Probably not the most logical thing to do, but it worked for me so I could compile x86 and arm64 separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants