aws / aws-iot-device-sdk-embedded-C

SDK for connecting to AWS IoT from a device using embedded C.
MIT License
978 stars 625 forks source link

What changes I should make so that I will be able to cross compile AWS IOT Embedded C SDK for poky linux? #1773

Closed kumarfirmware closed 2 years ago

kumarfirmware commented 2 years ago

Hi Team,

I have installed AWS IOT Embedded C SDK. I guess 202108.00 is the latest release. I am able to compile the Demo project on Ubuntu Linux.

What changes I should make so that I will be able to cross compile for poky linux.

Can you please help me with this as soon as possible.

I am trying hard but I am not successful. Any help in this is highly appreciated.

Thanks, Regards, Kumar.

abhidixi11 commented 2 years ago

Hello @kumarfirmware Thanks for reaching out.

Can you please elaborate on what you different things you have tried and where are you stuck ? Which demo are you trying to compile ?

Have you looked at our porting guides ?

Thanks!

kumarfirmware commented 2 years ago

Hi Abhdixi11,

Thanks for your quick response.

I have looked at the porting guide. It is not mentioned any where regarding the steps how to cross compile for any other platform.

I am trying to cross compile the demo(mqtt_demo_mutual_auth) for poky Linux. My tool chain is poky Linux.

Can you please let me know which part of the make file or cmake file should I change to cross compile with my tool chain poky Linux.

There is no problem with the source files. Problem is only with make files and cmake files. Which part of the make file or cmake file should I change to cross compile with my tool chain poky Linux.

This will hep me a lot.

Thanks, Regards, Kumar.

abhidixi11 commented 2 years ago

Thanks for clarification @kumarfirmware Here are a few of old issues which discuss about cross compilation :

https://github.com/aws/aws-iot-device-sdk-embedded-C/issues/1382 https://github.com/aws/aws-iot-device-sdk-embedded-C/issues/1579 https://github.com/aws/aws-iot-device-sdk-embedded-C/issues/1606 https://github.com/aws/aws-iot-device-sdk-embedded-C/issues/1635

If these don't answer your question or if you face problems please let us know and we can help you. Thanks !

kumarfirmware commented 2 years ago

Hi Abhdixi11,

Thanks for your immediate response. I have gone through the links you have shared, but I still could not figure out the correct steps.

But I tried following commands, please check if this makes sense and please check why the following error is coming?

This is my compiler or tool chain version.

arm-poky-linux-gnueabi-gcc --version arm-poky-linux-gnueabi-gcc (GCC) 6.3.0

kumar@ubuntu:/opt/AWS_IOT_202108/aws-iot-device-sdk-embedded-c$ source /opt/poky/2.3.2/environment-setup-cortexa8hf-neon-poky-linux-gnueabi kumar@ubuntu:/opt/AWS_IOT_202108/aws-iot-device-sdk-embedded-c$ export CC=arm-poky-linux-gnueabi-gcc kumar@ubuntu:/opt/AWS_IOT_202108/aws-iot-device-sdk-embedded-c$ export CXX=arm-poky-linux-gnueabi-g++ kumar@ubuntu:/opt/AWS_IOT_202108/aws-iot-device-sdk-embedded-c$ export AR=arm-poky-linux-gnueabi-ar kumar@ubuntu:/opt/AWS_IOT_202108/aws-iot-device-sdk-embedded-c$ export LD=arm-poky-linux-gnueabi-ld kumar@ubuntu:/opt/AWS_IOT_202108/aws-iot-device-sdk-embedded-c$ mkdir build && cd build kumar@ubuntu:/opt/AWS_IOT_202108/aws-iot-device-sdk-embedded-c/build$ cmake CMake Error: The source directory "/opt/AWS_IOT_202108/aws-iot-device-sdk-embedded-c/build" does not appear to contain CMakeLists.txt. Specify --help for usage, or press the help button on the CMake GUI. kumar@ubuntu:/opt/AWS_IOT_202108/aws-iot-device-sdk-embedded-c/build$

Thanks, Regards, Kumar.

yourslab commented 2 years ago

Cmake supports specifying the cross-compiler toolchain through the CMAKE_TOOLCHAIN_FILE variable that you can pass in the Cmake configuration command (as cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=<path/to/toolchain/file>.cmake). You must use that build command instead of just cmake.

An example toolchain file for an ARM based Linux platform can be seen in the CMake documentation here where you can pass CC, CXX, AR, and LD instead.

kumarfirmware commented 2 years ago

Hi Team,

I am still getting the following error. Can you please tell me where it is going wrong?

Also I do not see cmake file in my toolchain /opt/poky/2.3.2/environment-setup-cortexa8hf-neon-poky-linux-gnueabi?

Can you kindly help me with this as soon as possible.

Thanks, Regards, Kumar.

kumar@ubuntu:/opt/AWS_IOT_202108/aws-iot-device-sdk-embedded-c$ cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=/opt/poky/2.3.2/environment-setup-cortexa8hf-neon-poky-linux-gnueabi CMake Error: The source directory "/opt/AWS_IOT_202108/aws-iot-device-sdk-embedded-c/build" does not appear to contain CMakeLists.txt. Specify --help for usage, or press the help button on the CMake GUI.

cobusve commented 2 years ago

It seems like CMake is trying to process the output folder. All I can think is that your specification of the build folder is not succeeding, can you try specifying -B ./build instead to ensure that CMake is looking at the right build location? I would also recommend deleting the build folder before you start to ensure you have a clean run.

kumarfirmware commented 2 years ago

Hi Team,

I am still getting the same error. I am getting this error only when I am trying to cross compile AWS SDK for poky linux.

But my workspace with my source files, I am able to compile properly with out any errors.

Problem is when I am trying to compile using the AWS IOT SDK cmake file system. I am not sure what needs to be changed in the AWS IOT SDK cmake file to make it to compile with my tool chain.

Kindly help as soon as possible, I already lost a week. This looks very simple issue and I am missing something fundamental.

kumar@ubuntu:/opt/AWS_IOT_202108/aws-iot-device-sdk-embedded-c$ cmake -S . -B ./build -DCMAKE_TOOLCHAIN_FILE=/opt/poky/2.3.2/environment-setup-cortexa8hf-neon-poky-linux-gnueabi CMake Error: The source directory "/opt/AWS_IOT_202108/aws-iot-device-sdk-embedded-c/build" does not appear to contain CMakeLists.txt. Specify --help for usage, or press the help button on the CMake GUI.

Thanks, Regards, Kumar.

cobusve commented 2 years ago

Hi Kumar,

Unfortunately I am unfamiliar with Poky Linux, I do not have a Poky Linux system to test this on so the best I can do is guess here.

From what I can see - if you are able to build this on Ubuntu with CMake successfully I would expect that the problem is not with the FreeRTOS CMake setup, but rather with the setup of your CMake toolchain for Poky Linux.

From your command line above it does not seem like you are providing a proper .cmake toolchain file, it looks like you are passing in a folder name, perhaps that is the problem?

cobusve commented 2 years ago

I am going ahead and closing this issue as there has been no response after 7 days and the problem seems to be a pky linux cmake setup problem and the build is working fine on the supported platforms like ubuntu.

If you have new information or more questions please feel free to re-open this issue.