Page 1 of 1

Trying to understand cross compilation in ubuntu and execution in luckfox pico RV1103

Posted: 2025-12-07 18:39
by macjan
Team luckfox,

I want to understand how this thing works, specially cross compilation. As I was more familiar with Rasp OS which had its own compilation.
Due to size we need to compile in virutal OS Ubuntu 22.04.5 LTS. Download luckfox SDK and then use it to compile apps.

I usually used direct gcc to compile my c codes. Please check below if my process is correct.


For example in luckfox I did this.
I create 2 files compile.sh and test.c, inside folder home/pico/luckfox-pico/project/app/mycodes/

In compiler.sh below is following script/

Code: Select all

#!/bin/bash

export compiler="/home/pico/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-gcc"


$compiler -mcpu=cortex-a7 -mfpu=vfpv4 test.c -o test
#gcc test.c -o test

chmod +x test
and in test.c below is following code.

Code: Select all

#include <stdio.h>

int main(void){
	printf("Hello this is luckfox test\r\n");
	return 0;
}
Once this is created, i open my terminal in that folder and do sudo ./compile.sh.
This compiles the file and creates test executable. Which doesnt execute in ubuntu virtual OS as m using rockchip suggested compiler.
I copy this file via winscp to luckfox pico mini B.

I go to putty and try executing it with following command in that folder.
sudo ./test
output is "unable to execute ./test: No such file or directory"


Please let me know what I'm doing wrong and why simple code is not working.

Regards,

Macjan

Re: Trying to understand cross compilation in ubuntu and execution in luckfox pico RV1103

Posted: 2025-12-08 9:53
by yangxj121
Hello, regarding cross-compilation, the main approach we recommend is by setting environment variables or writing a Makefile. These two methods are actually quite similar. We also have detailed tutorials on our wiki that you can refer to.https://wiki.luckfox.com/Luckfox-Pico-P ... s-Compile/

Re: Trying to understand cross compilation in ubuntu and execution in luckfox pico RV1103

Posted: 2025-12-10 17:39
by macjan
yangxj121 wrote: 2025-12-08 9:53 Hello, regarding cross-compilation, the main approach we recommend is by setting environment variables or writing a Makefile. These two methods are actually quite similar. We also have detailed tutorials on our wiki that you can refer to.https://wiki.luckfox.com/Luckfox-Pico-P ... s-Compile/
Sir,

The approach you recommended I tried. I Downloaded the gcc-arm-11.2-2022.02-x86_64-arm-none-linux-gnueabihf.tar.gz, unziped. And prepared this new script below:

Code: Select all

#!/bin/bash

export mycompiler="/home/pico/gcc-arm-11.2-2022.02-x86_64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-gcc"

$mycompiler test.c -o test

chmod +x test
With this change my code started working.
Screenshot 2025-12-10 231539.png
Is there any restrictions with this method to complete firmware programming? Well I wanted to write my entire firmware with this method.
For example reading and writing gpio's updating logs in files and so on. Because I do not want to interfere with root files of luckfox besides startup init.d

Regards,

Macjan

Re: Trying to understand cross compilation in ubuntu and execution in luckfox pico RV1103

Posted: 2025-12-11 1:42
by yangxj121
Hello, you need to know that cross-compilation is the toolchain of the SDK. Therefore, the path specified for cross-compilation is the cross-compiler located within the SDK. We also highly recommend generating the required firmware through SDK compilation, and then generating the application through cross-compilation. This development method is not only convenient but also effectively solves dependency issues. Additionally, I see that the development board you are using is Ubuntu. Currently, we only provide Ubuntu images and no longer maintain them. If you want a good development environment, it is recommended to use Buildroot. The final compiled SDK system is also the Buildroot system.