Search code examples
typesarmcpuembedded-linux

Selecting a specific ARM arch for compiling


I'm new to embedded linux and just started building a custom kernel for raspberry 4 board. There are several tutorials on how to compile linux kernel for specific boards. To my understanding I can specify the cpu type and toolchain as parameters to make command with ARCH and CROSS_COMPILE but I wonder how compiler recognizes for which specific ARM architecture (ARMv7,ARMv8 etc...) I want to get a kernel image.


Solution

  • Since Armv7a and Armv8a architectures use different/incompatible instructions sets, the compiler you will use will be specific to one of the Armv7a/Armv8a architectures.

    It will therefore not need to 'know' for which architecture it is compiling your kernel for, because it will have no choice.

    Your 'make' commands will have to begin with one these statements:

    # Armv7a/Aarch32/32 bit Arm Linux kernel
    make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf-  ... 
    
    # Armv8a/Aarch64/64 bit Arm Linux kernel
    make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu-  ...
    

    All different combinations of ARCH/CROSS_COMPILE will not work.

    Please note that the exact name of for toolchains may vary slightly - I used the Arm toolchains triplets for the purpose of this answer.