Differences

This shows you the differences between two versions of the page.

Link to this comparison view

ass:labs-2024:01:tasks:01 [2025/08/03 10:08] (current)
florin.stancu created
Line 1: Line 1:
 +==== 01. The Aarch64 (arm64) toolchain ====
 +
 +Well, we want to compile things.
 +We'll be using the personal PC / laptop, which is probably running on a Intel/​AMD-based //x86-64// CPU architecture.
 +
 +But we want to compile code for a foreign architecture:​ Aarch64 (also known as arm64).
 +So we will need a cross compiler: a compiler that runs on your **host** but generates binary code for another **target**.
 +
 +Cross compilers are usually named using this convention ''<​target_arch>​-<​vendor>​-[<​os>​-]<​abi>​-gcc''​. In our case, it will be ''​aarch64-none-linux-gnu-gcc'':​
 +
 +  * **aarch64:​** The target architecture;​ ARM 64-bit (why isn't it called this way? don't ask us :( ...).
 +  * **none:** The toolchain supplier. Here, we're dealing with the official cross compiler from ARM so the vendor is not relevant.
 +  * **linux:** The target OS (this filed is optional).
 +  * **gnu:** The Application Binary Interface (ABI) defining how the generated code will interact with other software components. Don't mistake this for **gnueabi**,​ which is meant to generate bare metal code.
 +
 +== Step 0. Download the toolchain ==
 +
 +Identify the correct toolchain and download it from [[https://​developer.arm.com/​downloads/​-/​arm-gnu-toolchain-downloads/​|here]]. Yes, you can also install it with your package manger but it's always better to have a project-specific copy.
 +New compiler releases are known to sometime break the build process.
 +
 +After extracting it, consider exporting the compiler'​s **prefix** (''​aarch64-none-linux-gnu-''​) from your newly downloaded toolchain as the ''​CROSS_COMPILE''​ environment variable. Otherwise, you will have to specify the full path of the cross compiler every time when invoking a script. E.g.:
 +<​code>​
 +export CROSS_COMPILE=/​absolute/​path/​to/​compiler/​bin/​aarch64-none-linux-gnu-
 +# now you can use the cross compiler as such:
 +"​${CROSS_COMPILE}gcc"​ ...
 +# make will inherit this value, so no need to add a CROSS_COMPILE ​
 +# when invoking it from your terminal ;) 
 +make
 +</​code>​
 +But //beware//: export only affects the terminal it's run from (so run it in each one :P)!
 +
 +<note hint>
 +Try to download / clone all projects inside a common root directory.
 +Then, you could create a top-level Makefile with rules for running commands inside each of their subfolder.
 +Try to keep the project'​s official git name and unified structure, e.g.:
 +<​code>​
 +/​home/​user/​arm-summer-school/​
 +├── toolchain/​aarch64-none-linux-gnu/​...
 +├── imx-atf/ ​       # ARM Trusted Firmware code
 +├── firmware/ ​      # NXP IMX proprietary firmware BLOBs
 +├── u-boot-tn-imx/ ​ # U-Boot source code
 +├── imx-mkimage/ ​   # IMX mkimage scripts
 +├── Makefile ​       # your makefile, highly recommended! :P
 +└── ...             # and many others to come!
 +</​code>​
 +</​note>​
 +
  
ass/labs-2024/01/tasks/01.txt · Last modified: 2025/08/03 10:08 by florin.stancu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0