Arm Community
Arm Community
  • Site
  • User
  • Site
  • Search
  • User
  • Groups
    • Research Collaboration and Enablement
    • DesignStart
    • Education Hub
    • Innovation
    • Open Source Software and Platforms
  • Forums
    • AI and ML forum
    • Architectures and Processors forum
    • Arm Development Platforms forum
    • Arm Development Studio forum
    • Arm Virtual Hardware forum
    • Automotive forum
    • Compilers and Libraries forum
    • Graphics, Gaming, and VR forum
    • High Performance Computing (HPC) forum
    • Infrastructure Solutions forum
    • Internet of Things (IoT) forum
    • Keil forum
    • Morello Forum
    • Operating Systems forum
    • SoC Design and Simulation forum
    • 中文社区论区
  • Blogs
    • AI and ML blog
    • Announcements
    • Architectures and Processors blog
    • Automotive blog
    • Graphics, Gaming, and VR blog
    • High Performance Computing (HPC) blog
    • Infrastructure Solutions blog
    • Innovation blog
    • Internet of Things (IoT) blog
    • Operating Systems blog
    • Research Articles
    • SoC Design and Simulation blog
    • Tools, Software and IDEs blog
    • 中文社区博客
  • Support
    • Arm Support Services
    • Documentation
    • Downloads
    • Training
    • Arm Approved program
    • Arm Design Reviews
  • Community Help
  • More
  • Cancel
Arm Community blogs
Arm Community blogs
Tools, Software and IDEs blog Debug the Arm Trust Firmware, U-boot and Linux Kernel on Juno-r2 board from source level with Arm Development Studio
  • Blogs
  • Mentions
  • Sub-Groups
  • Tags
  • Jump...
  • Cancel
More blogs in Arm Community blogs
  • AI and ML blog

  • Announcements

  • Architectures and Processors blog

  • Automotive blog

  • Embedded blog

  • Graphics, Gaming, and VR blog

  • High Performance Computing (HPC) blog

  • Infrastructure Solutions blog

  • Internet of Things (IoT) blog

  • Operating Systems blog

  • SoC Design and Simulation blog

  • Tools, Software and IDEs blog

Tags
  • Juno Arm Development Platform
  • Arm Trusted Firmware
  • U-Boot
  • Debugging
Actions
  • RSS
  • More
  • Cancel
Related blog posts
Related forum threads

Debug the Arm Trust Firmware, U-boot and Linux Kernel on Juno-r2 board from source level with Arm Development Studio

Kaiyou Wang
Kaiyou Wang
September 4, 2023
4 minute read time.

Many users need to debug code from source level. This blog describes how to use Arm Development Studio (Arm DS) to debug the Arm Trust Firmware (ATF), U-boot, and Linux Kernel on the Juno-r2 platform at the source level.

In this blog post, we assume that the Trust Firmware, U-boot, and Linux kernel images are already uploaded to the SD-card storage on the Juno-r2 board, as the following figure shows:

 Image files on SD card

The primary CPU after reset is Cortex-A53_0. Other cores 2 Cortex-A72, 3 Cortex-A53 are in powerdown state, as the following figure shows:

 Only Cortex-A53_0 is power on

The version of Arm DS is 2023.0. In Arm DS, to set up the Juno-r2 connection, click the Connect Only option like the following figure shows:

 Connect only option

This blog post describes the debug skills in the following topics:

  • Debug the Arm Trust Firmware
  • Debug the U-BOOT
  • Debug the Linux Kernel

Debug the Arm Trust Firmware (ATF)

When the debugger connects to the target and stops the CPU running, it halts at ATF BL1 at EL3. If you want to debug the BL1, you must add the symbol file, bl1.elf, to the debugger like the following figure shows:

 Add the symbol file

If the debugger and the source code are on different Host machines you must set up a path mapping for the debugger to locate the source code. This blog post describes the example where the Arm DS runs on a Windows system, but the source code is on a Ubuntu system. Therefore, you must set up a mapping Z: disk to access the source code by using Samba service, as the figure shows:

 Edit the Substitution

 Edit Substitute Path

The following figure shows you the source code on the Arm DS Window View. You can debug the code from source level.

 See the source code

Make sure that the Symbol Loading EL and the Code running EL are at the same address space. For example, when the CPU is stopped at EL3 and you want to add the BL2 Symbol file to the debugger, you must add an offset EL1S:0x0 with the EL1S: prefix:

 Load file with EL1S prefix

The EL1S: prefix is added because the BL2 runs at EL1S. If you do not add the EL1S: prefix, the debugger loads the symbol file at the current EL address space, EL3.

The offset EL3:0x0 is needed when loading the BL31 symbol file, because BL31 runs at EL3 while BL2 runs at EL1S.

 Add symbol file with EL3 prefix

Debug the U-boot

If you want to debug the U-boot that runs at EL2N address space, you do not need to add the prefix  offset when the CPU is stopped at EL2, as the figure shows:

 Add u-boot symbol file

During the U-boot execution, the U-boot does the relocation of code section and data section. Therefore, you must reload the symbol file to the debugger with the correct offset that U-boot is going to use.

On the Juno-r2 platform, you can see the offset value 0x000000001ef6e000 with the U-boot command bdinfo as the following figure shows:

 u-boot boardinfo

Therefore, you add the Symbol file u-boot with the offset value EL2N:0x1ef6e000.

 Add u-boot symbol file with EL2N prefix

Debug the Linux kernel

Running the U-boot command printenv shows you the kernel load address is 0x80080000. The kernel entry address is 0xffffff8010080000, and you must add the symbol file, vmliux, with the offset 0x80700000000, 0x80080000-0xffffff8010080000. The figure shows this:

 Printevn on U-Boot shell

 Kernel ELF Header

 Add Kernel Symbol file with offset

The following figure shows you can view and debug from the assembly code at EL2N address space now.

 See the Kernel boot source at EL2

There is an EL switch from EL2 to EL1, so you must add the symbol file again with the same offset value after the kernel is switched to EL1.

 Add the kernel symbol file with offset again

As shown in the following figure, you can view and debug from the assembly code at EL1N address space.

 See the Kernel boot code at EL1

There is an MMU mapping from physical address space to virtual address space. Therefore, you must add the symbol file again without the offset value after the MMU is enabled.

 Add the kernel symbol file without offset

As shown in the following figure, you can view and debug the code from source level at EL1N address space.

 See the Kernel source code after MMU

For more information about debugging the Armv8-A Linux Kernel with DS-5, see the blog Debugging the Armv8-A Linux Kernel with DS-5.

There are some differences between Arm DS debugging on the Juno-r2 hardware platform and debugging on the FVP:

  • The software breakpoint does not work on the Juno Kernel debugging. This is because the code section is read-only and does not allow writing operations. For details, see the document Why does Arm DS or DS-5 software breakpoint not work for Linux kernel debug?
  • The FVP debug function is implemented by the Iris or Component Architecture Debug Interface. The FVP does not model CoreSight debug and trace components so any values contained in CoreSight debug registers cannot be trusted.
Anonymous
Tools, Software and IDEs blog
  • Debug the Arm Trust Firmware, U-boot and Linux Kernel on Juno-r2 board from source level with Arm Development Studio

    Kaiyou Wang
    Kaiyou Wang
    Debug the Arm Trust Firmware, U-Boot and Linux Kernel with Arm DS from the source code level.
    • September 4, 2023
  • First macOS release of Arm Performance Libraries

    Chris Goodyer
    Chris Goodyer
    We have released our first version of Arm Performance Libraries (ArmPL) fully compatible with M-series Apple silicon running macOS.
    • September 1, 2023
  • Windows Release of Arm Performance Libraries

    Chris Goodyer
    Chris Goodyer
    Arm are proud to announce that we have now released our first version of Arm Performance Libraries (Arm PL) for Windows 11 devices. 
    • August 24, 2023