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

size_t cross-compilation issue #8

Closed
alsora opened this issue May 15, 2019 · 8 comments · Fixed by #9
Closed

size_t cross-compilation issue #8

alsora opened this issue May 15, 2019 · 8 comments · Fixed by #9

Comments

@alsora
Copy link
Contributor

alsora commented May 15, 2019

Bug report

I'm trying to cross-compile this repository for RaspberryPi (32 bit)

The cross-compilation of this package fails because deserializeSequenceSize function takes a size_t argument and then converts it into `uint64_t.

https://github.com/ros2/rmw_dps/blob/master/rmw_dps_cpp/include/rmw_dps_cpp/CborStream.hpp#L444

error: cannot convert ‘size_t* {aka unsigned int*}’ to ‘uint64_t* {aka long long unsigned int*}’ for argument ‘3’ to ‘DPS_Status CBOR_Peek(DPS_RxBuffer*, uint8_t*, uint64_t*)’
     DPS_Status ret = CBOR_Peek(&buffer_, &maj, size);

Do you think that it is possible to change the GenericCSequence object to directly use the proper type?

https://github.com/ros2/rmw_dps/blob/ab6f8d0257d6cf61fc499fee6ab3936e0b3234f6/rmw_dps_cpp/include/rmw_dps_cpp/macros.hpp

@malsbat
Copy link
Collaborator

malsbat commented May 15, 2019

The rosidl_generator_c__ functions are defined elsewhere, so it'd probably be more straightforward to have a local uint64_t for the argument, then assign that to the size_t out argument, after some range checking depending on how paranoid you are.

Longer term, it appears that CBOR_Peek is not consistent with other CBOR functions from DPS that take a size_t instead of a uint64_t (i.e. CBOR_DecodeArray). I filed intel/dps-for-iot#96 to track this.

malsbat added a commit that referenced this issue May 15, 2019
This fixes #8.

Signed-off-by: Todd Malsbary <[email protected]>
@malsbat
Copy link
Collaborator

malsbat commented May 16, 2019

Can you provide me some pointers on how to configure ros2 to cross-compile for RaspberryPi? I see a handful of questions and answers online, but I'm not finding anything definitive looking.

@alsora
Copy link
Contributor Author

alsora commented May 17, 2019

Yes, you are right.

This is a PR I opened to add RaspberryPi cross-compilation support to the OSRF tools ros-tooling/cross_compile#15

NOTE:

  • When cross-compiling the whole ROS2 workspace, it's necessary to find a way to pass the compiler flags to the DPS Sconstruct file. This is an example for a ROS2 vendor package https://github.com/ros2/tinyxml_vendor/blob/master/CMakeLists.txt#L14
    I'm no expert of Scons, so for my tests I simply tried to build the DPS library directly on RaspberryPi

@alsora
Copy link
Contributor Author

alsora commented May 17, 2019

@malsbat I tested your new branch https://github.com/intel/dps-for-iot/tree/x86 and it works!

I haven't been able to cross-compile it, but this can be fixed by passing the compilation flags as done in the example I posted above.
However, the changes you did to the source code are enough for building it on 32 bit platforms.

This is what I did in order to test it:

  1. On a RaspberryPi ->
    git clone https://github.com/intel/dps-for-iot.git
    cd dps-for-iot
    git checkout x86
    scons variant=release transport=udp bindings=none DEF_FILE=~/rmw_dps/dps_for_iot_cmake_module/librmw_dps_shared.map

  2. Copy the ~/dps-for-iot directory to the laptop

  3. On the laptop ->
    create a ROS2 workspace
    mkdir -p build/dps_for_iot_cmake_module
    mkdir -p install/lib
    cp ~/dps-for-iot/build/dist/lib/libdps* install/lib
    cp -r ~/dps-for-iot build/dps_for_iot_cmake_module
    touch src/rmw_dps/dps_for_iot_cmake_module/COLCON_IGNORE

  4. Cross-Compile the ROS2 workspace

@malsbat
Copy link
Collaborator

malsbat commented May 17, 2019

@alsora Great, I'm going to do a bit more testing with the x86 branch before I merge it. I need to make sure it works on Windows and I'd like to verify your RPi build as well on my end.

@malsbat malsbat closed this as completed in #9 Jun 3, 2019
@malsbat
Copy link
Collaborator

malsbat commented Jun 3, 2019

I did not intend merging PR #9 to close this issue. I want to continue to track the general cross-compilation here.

@malsbat
Copy link
Collaborator

malsbat commented Jun 4, 2019

@alsora, I had trouble with the instructions at ros-tooling/cross_compile#15, however I was able to verify PR #33 with the instructions at https://index.ros.org/doc/ros2/Tutorials/Cross-compilation/#cross-compiling-examples-for-arm.

@malsbat
Copy link
Collaborator

malsbat commented Jun 6, 2019

I believe this can be closed now with the merge of intel/dps-for-iot#108 and #33.

@malsbat malsbat closed this as completed Jun 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants