2022-03-15 02:17 AM
Simple Hello World Application
I have followed all the steps for installing the SDK and verified the environment variables for the cross compiler. I use a make file and it generates a binary. The problem is it generates a binary for x86-64 even when it is being directed to use the arm-ostl-linux-gnueabi-gcc (GCC) 9.3.0 cross compiler.
Output of file:
"gtk_hello_world: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamic ally linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=ac39231d6a72 8870d0248017a6c9cd25d9f02eab, for GNU/Linux 3.2.0, not stripped"
I haven't just used gtk either, a simple printf application with stdio.h will also compile for x86-64 and not the intended cross compile target.
Output of Cross Compile target:
"echo $CC
arm-ostl-linux-gnueabi-gcc -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/home/james/STM32MPU_workspace/STM32MP15-Ecosystem-v3.1.0/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi"
I have repeated this using WSL2 and VMware Workstation Player with Ubuntu 20.04 on both. The result is the same. The simple "hello world" application will open in an Ubuntu environment but not on the discovery kit using the OpenST linux distribution.
Is there any indication of something I may have done wrong in my SDK installation? Or is there some other step I can follow to ensure I get the correct cross compilation?
2022-03-15 03:48 AM
Hello @JOSU ,
Regarding the check that you already made, your SDK looks well installed and well sourced. Could you please share your Makefile ? I think the problem comes from here.
Regards.
Erwan.
2022-03-15 03:58 AM
Thank you for your reply.
I am using a Makefile similar to that given in the hello world example. It is attached.
The relevant line when using "make":
"$(PROG): $(SRCS)
sudo $(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS)"
Where &(CC) is:
"echo $CC
arm-ostl-linux-gnueabi-gcc -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/home/james/STM32MPU_workspace/STM32MP15-Ecosystem-v3.1.0/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi"
I have tried to run compilation separately with this command, but it has issues with "-mfloat-abi=hard" telling me the processor does not have a FPU. There is no such error when using the Makefile.
2022-03-15 04:22 AM
Ok, can we make a simple test together ? With the following files :
helloworld.c:
-------------------------------------------
#include <stdio.h>
int main ()
{
printf("Hello World\n");
return 0;
}
------------------------------------------
Makefile :
-----------------------------------------------------------------------
PROG = helloworld
SRCS = helloworld.c
CLEANFILES = $(PROG)
# Add / change option in CFLAGS and LDFLAGS
CFLAGS += -Wall
LDFLAGS +=
all: $(PROG)
$(PROG): $(SRCS)
$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS)
clean:
rm -f $(CLEANFILES) $(patsubst %.c,%.o, $(SRCS))
------------------------------------------------------------------------------
Then if you source your SDK and make, can you tell me what you can see if you enter file helloworld ?
Regards.
Erwan.
PS: Be careful, if you already compiled your program in local (x86), then you source your SDK and compile again, you need to do a make clean before, because it will not detect that there is any change.
2022-03-15 04:23 AM
You should see something like :
helloworld: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, BuildID[sha1]=ba652fd63d2b63d7c6b2df9f3fe11b32b32fa168, for GNU/Linux 3.2.0, with debug_info, not stripped
2022-03-15 04:53 AM
The output is:
helloworld: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=987960828f1b4a1fd35a19386512d22056a5b05d, for GNU/Linux 3.2.0, not stripped
Compiled for x86-64, not ARM.
And on the virtual machine that binary should not execute, but it does:
$ ./helloworld
Hello World
2022-03-15 05:02 AM
2022-03-15 05:54 AM
Thanks for the verbose.
Considering your first line, a simple "cc" is used to compile the application instead of the arm-ostl-linux-gnueabi-gcc -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/home/james/STM32MPU_workspace/STM32MP15-Ecosystem-v3.1.0/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi" that you should see at this place.
However, you prove me that you can source your SDK because your "echo $CC" command works well.
As another test, instead of using your Makefile, can you compile your application such as :
$CC helloworld.c -o helloworld
(Make clean before).
Do you see any change when you proceed like this ?
2022-03-15 07:32 AM
Using make doesn't have permissions to create a binary. The verbose output is attached and I can see the correct compiler is used for this make output. I had tried "sudo make" but this user is a new environment and is not sourced correctly and uses the x86-64 compiler. I believe this might indicate I have a Linux user permissions problem.
2022-03-15 07:48 AM
Yes it looks like a configuration problem of your own Linux machine. The last traces you sent me are similar to what you should have.