TImada / raspi4_freertos

FreeRTOS UART sample porting to Raspberry Pi 4B.
MIT License
54 stars 20 forks source link

Compiling with arm-eabi #6

Closed LabNelson closed 1 month ago

LabNelson commented 2 months ago

I want to add this port to an application with a large code base. The code base is compiled on windows with msys and arm-eabi-toolchain (gcc-linaro-6.2.1-20170623-win32). I got the compiler on my computer but its too large to share via github-repository. Does anyone tried to compile this port with arm-eabi, another toolchain or can point me in the right direction? When compiling with arm-eabi arm-eabi-as -mcpu=cortex-a72 -c -o build/startup.o src/startup.S

i got the following errors:

src/startup.S: Assembler messages:
src/startup.S:9: Error: ARM register expected -- 'mrs x1,mpidr_el1'
src/startup.S:10: Error: ARM register expected -- 'and x1,x1,#3'
src/startup.S:11: Error: ARM register expected -- 'cmp x1,#3'
src/startup.S:16: Error: ARM register expected -- 'mov x0,#(1<<31)'
src/startup.S:17: Error: ARM register expected -- 'orr x0,x0,#(1<<1)'
src/startup.S:18: Error: selected processor does not support requested special purpose register -- 'msr hcr_el2,x0'
src/startup.S:21: Error: ARM register expected -- 'mov x2,#0x3c5'
src/startup.S:22: Error: flag for {c}psr instruction expected -- 'msr spsr_el2,x2'
src/startup.S:24: Error: ARM register expected -- 'adr x2,start_el1'
src/startup.S:25: Error: selected processor does not support requested special purpose register -- 'msr elr_el2,x2'
src/startup.S:31: Error: ARM register expected -- 'mrs x1,cpacr_el1'
src/startup.S:32: Error: ARM register expected -- 'mov x0,#(3<<20)'
src/startup.S:33: Error: ARM register expected -- 'orr x0,x1,x0'
src/startup.S:34: Error: selected processor does not support requested special purpose register -- 'msr cpacr_el1,x0'
src/startup.S:36: Error: bad instruction 'adrp x1,stack_top'
src/startup.S:37: Error: immediate expression requires a # prefix -- 'mov sp,x1'
src/startup.S:39: Error: ARM register expected -- 'ldr x0,=configure_mmu'
src/startup.S:40: Error: bad instruction 'blr x0'
src/startup.S:42: Error: ARM register expected -- 'ldr x1,=__bss_start'
src/startup.S:43: Error: ARM register expected --'ldr w2,=__bss_size'
src/startup.S:44: Error: selected processor does not support 'cbz w2,2f' in ARM mode
src/startup.S:45: Error: ARM register expected -- 'str xzr,[x1],#8'
src/startup.S:46: Error: ARM register expected -- 'sub w2,w2,#1'
src/startup.S:47: Error: selected processor does not support 'cbnz w2,1b' in ARM mode
src/startup.S:50: Error: bad instruction 'ret'
src/startup.S:53: Error: ARM register expected -- 'mov x1,#0xF0'
src/startup.S:54: Error: ARM register expected -- 'ldr x2,=__start'
src/startup.S:55: Error: ARM register expected -- 'str x2,[x1]'
src/startup.S:58: Error: ARM register expected -- 'mov x0,#0x0'
src/startup.S:59: Error: bad instruction 'ret'
make: *** [Makefile:75: build/startup.o] Error 1### ### 
LabNelson commented 2 months ago

Looks like the FreeRTOS-port uses 64-bit instructions (thats why aarch64-none-elf) and i try compile it with 32-bit compiler (arm-eabi). Can i just change the arm-eabi 32-bit compiler to 64-bit without problems? I will try mingw-w64-i686-arm-none-eabi-toolchain

TImada commented 2 months ago

Can i just change the arm-eabi 32-bit compiler to 64-bit without problems?

aarch64-none-elf should work. (but I'm not sure if or not the latest GCC version can work correctly)

I will try mingw-w64-i686-arm-none-eabi-toolchain

That's arm-none-eabi, not aarch64-none-elf.

LabNelson commented 2 months ago

Can i just change the arm-eabi 32-bit compiler to 64-bit without problems?

aarch64-none-elf should work. (but I'm not sure if or not the latest GCC version can work correctly)

Do you mean that aarch64-none-elf should work for the code base which is compiled by arm-eabi-toolchain (gcc-linaro-6.2.1-20170623-win32)? So i need an aarch64-none-elf compiler which has the same version of GCC as arm-eabi (gcc-linaro-6.2.1-20170623-win32)? Due to date its probably from 2017 I tried this compiler (gcc-linaro-6.4.1-2017.11-i686-mingw32_aarch64-elf) and there is this error:

Compiling sdps
echo "Archiver:" aarch64-elf-ar
Archiver: aarch64-elf-ar
echo "Realeasedir:" ../../../lib
Realeasedir: ../../../lib
echo "Lib:" libxil.a
Lib: libxil.a
aarch64-elf-gcc -mcpu=cortex-a72 -fdata-sections -ffunction-sections -fpic -ffreestanding -std=gnu99 -O2 -Wall -Wextra -DGUEST -c -O2 -nostartfiles -isystem ./. -isystem ../../../include -o xsdps_options.o xsdps_options.c
xsdps_options.c:86:21: fatal error: xil_smc.h: No such file or directory
 #include "xil_smc.h"

Compiling it with arm-eabi, the xil_smc.h will be found:

Compiling sdps
echo "Archiver:" arm-eabi-ar
Archiver: arm-eabi-ar
echo "Realeasedir:" ../../../lib
Realeasedir: ../../../lib
echo "Lib:" libxil.a
Lib: libxil.a
arm-eabi-gcc -mcpu=cortex-a72 -mfpu=vfpv3 -mfloat-abi=hard -fdata-sections -ffunction-sections -c -O2 -nostartfiles -isystem ./. -isystem ../../../include -o xsdps_options.o xsdps_options.c
arm-eabi-gcc -mcpu=cortex-a72 -mfpu=vfpv3 -mfloat-abi=hard -fdata-sections -ffunction-sections -c -O2 -nostartfiles -isystem ./. -isystem ../../../include -o xsdps_sinit.o xsdps_sinit.c
arm-eabi-ar -r ../../../lib/libxil.a xsdps.o xsdps_g.o xsdps_options.o xsdps_sinit.o
rm -rf xsdps.o xsdps_g.o xsdps_options.o xsdps_sinit.o
make[2]: Leaving directory '/c/Users/ehlingn/SAFE_Ehling/Projekte/RPi/CBS-System/Toolboxes/iXnitionTargetRPi4/RaspberryPi4/BSP/Core0_BSP/bcm2711_cortexa72_0/libsrc/sdps_v3_3/src'
Running Make libs in bcm2711_cortexa72_0/libsrc/standalone_v6_4/src
make -C bcm2711_cortexa72_0/libsrc/standalone_v6_4/src libs  "SHELL=/bin/sh" "COMPILER=arm-eabi-gcc" "ARCHIVER=arm-eabi-ar" "COMPILER_FLAGS= -mcpu=cortex-a72 -mfpu=vfpv3 -mfloat-abi=hard -fdata-sections -ffunction-sections -c -O2" "EXTRA_COMPILER_FLAGS= -nostartfiles"
make[2]: Entering directory '/c/Users/ehlingn/SAFE_Ehling/Projekte/RPi/CBS-System/Toolboxes/iXnitionTargetRPi4/RaspberryPi4/BSP/Core0_BSP/bcm2711_cortexa72_0/libsrc/standalone_v6_4/src'

I dont find the xil_smc.h in any project folder, so it must be located in the libxil.a or in an installation-directory of arm-eabi-toolchain?

TImada commented 2 months ago

Do you mean that aarch64-none-elf should work for the code base which is compiled by arm-eabi-toolchain (gcc-linaro-6.2.1-20170623-win32)?

What I mean is just that a GCC compiler toolchain marked as 'aarch64-none-elf' (e.g. obtained from [1]) should work for compiling this UART sample.

[1] https://developer.arm.com/downloads/-/gnu-a

I dont find the xil_smc.h in any project folder, so it must be located in the libxil.a or in an installation-directory of arm-eabi-toolchain?

I'm not sure why your toolchain environment tries to access Xilinx related files like libxil.a or xil_smc.h. You should check your build configuration.

LabNelson commented 2 months ago

What I mean is just that a GCC compiler toolchain marked as 'aarch64-none-elf' (e.g. obtained from [1]) should work for compiling this UART sample.

That's working fine for the UART-sample. I want to compile my large code base and the UART-sample with one compiler. aarch64-none-elf sadly doesn't work for the code base (due to this error). And arm-eabi does'nt work for the FreeRTOS-port (due to missing 64-bit instructions).

The code base is based on the Xlinx Zynq board (where FreeRTOS is also ported for). My aim is to change this port so the RPi4 is working with FreeRTOS and the large code base (maybe xil_smc.h is used in a driver). Your port serves me the FreeRTOS-part, so now I will tackle the other driver related stuff. Yes, I will check, what exactly is hidden in the libxil.a or in the xil_smc.h files. Probably I don't need them. Thank you so far, for your help @TImada - I will keep this thread updated

TImada commented 2 months ago

I will keep this thread updated

Close this issue as it has nothing with your build environment for the code base any more.

LabNelson commented 1 month ago

I changed the compiler to gcc-arm-8.2-2018.08-i686-mingw32-aarch64-elf.tar.xz. It works for your port, but i have to convert the large codebase from 32-bit to 64-bit, yay