Skip to content

Commit fd379a9

Browse files
Merge pull request #1637 from danielnguyen-arm/main
refinfra: update debug guide for new fvp
2 parents ca2c40a + c8b9998 commit fd379a9

File tree

12 files changed

+110
-24
lines changed

12 files changed

+110
-24
lines changed

content/learning-paths/servers-and-cloud-computing/refinfra-debug/debugging-bl1-3.md

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,33 @@ weight: 4
66
layout: learningpathall
77
---
88

9-
## Debugging BL1
9+
## Debugging BL1
10+
Due to RSE CPU wait hold and the APs will be powered off. You will not be able to start the debugger until RSE has powered the AP cores.
11+
12+
A workaround is to modify BL1 to spin on entry.
13+
14+
Navigate to ``<workspace>/rd-infra/tf-a/bl1/aarch64/bl1_entrypoint.S``, find the ``bl1_entrypoint`` function, and add a ``b .`` instruction:
15+
16+
```asm
17+
func bl1_entrypoint
18+
19+
b . // <-- Branch-to-self added here
20+
21+
/* ---------------------------------------------------------------------
22+
* If the reset address is programmable then bl1_entrypoint() is
23+
* executed only on the cold boot path. Therefore, we can skip the warm
24+
* boot mailbox mechanism.
25+
* ---------------------------------------------------------------------
26+
*/
27+
el3_entrypoint_common \
28+
_init_sctlr=1 \
29+
_warm_boot_mailbox=!PROGRAMMABLE_RESET_ADDRESS \
30+
_secondary_cold_boot=!COLD_BOOT_SINGLE_CPU \
31+
_init_memory=1 \
32+
_init_c_runtime=1 \
33+
_exception_vectors=bl1_exceptions
34+
```
35+
1036
In the **Edit configuration and launch** panel **Connection** tab, select the **ARM_Neoverse-N2_0**.
1137

1238
![select target alt-text#center](images/select_target.png "Figure 1. Select target")
@@ -29,16 +55,29 @@ These commands load the symbol files and specify the memory address location, up
2955

3056
The `EL` (Exception Level) and number at the end of each command, for example, `EL3:0`, ensure the symbols are loaded into the correct virtual address space and at the correct memory offset. ATF uses absolute addresses for its symbols so we use an offset of 0.
3157

32-
After connecting to the running model, check that it has stopped. Set a breakpoint on the next instruction of
33-
the TF-A and press **run**. In this debug panel, you can find common debugging functions like stepping and skipping.
58+
When you connect the debugger, the primary CPU will be "spinning" on a ``b .`` instruction from the one you manually added to the ``bl1_entrypoint`` function.
3459

35-
![debug options alt-text#center](images/debug_options.png "Figure 3. Debug options")
60+
In this debug panel, you can find common debugging functions like stepping and skipping.
3661

37-
Observe the SCP console output. After the SCP deasserts, reset for the Neoverse N2 Core 0, it stops on the breakpoint.
62+
Set a breakpoint in the function you would like to debug. In this example, we set a breakpoint at ``bl1_main()``.
3863

64+
Simply interrupt the CPU and enter debug command `set $pc += 4'; you can now step through and debug the TF-A boot flow.
3965

40-
![scp terminal alt-text#center](images/scp_terminal.png "Figure 4. SCP terminal")
66+
![bl1 breakpoint alt-text#center](images/bl1_breakpoint.png "Figure 5. BL1 breakpoint")
4167

42-
Finally, set a breakpoint in the function you would like to debug. In this example, we set a breakpoint at ``bl1_main()``and continue.
68+
## Alternate break method
69+
Another method of setting a breakpoint without modifying TF-A is by launching the model with ``--break``.
70+
The general syntax for defining a breakpoint is:
71+
```bash
72+
--break <INST>=<MEMSPACE>@<ADDRESS>
73+
```
4374

44-
![bl1 breakpoint alt-text#center](images/bl1_breakpoint.png "Figure 5. BL1 breakpoint")
75+
- ``<INST>``: Processor identifier (e.g., AP0 in cluster 0).
76+
- ``<MEMSPACE>``: Memory space identifier (e.g., id=1 for EL2 VA space).
77+
78+
To determine valid instance and memory space names, run: ``--list-instances`` or ``--list-memory``.
79+
80+
Example command:
81+
```bash
82+
./boot.sh -p rdv3r1cfg1 -a "--break RD_V3_R1_Cfg1.socket0.css0.lcp_app_group00.app0.cluster.cpu0=0@0x0"
83+
```

content/learning-paths/servers-and-cloud-computing/refinfra-debug/debugging-bl33-uefi-5.md

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,52 @@ layout: learningpathall
1010

1111
Adding symbol files for UEFI requires you to boot the FVP once without debugging, so that you can retrieve the symbol file locations and memory addresses.
1212

13-
After booting the FVP, notice that in the Non-secure AP console output, the UEFI load system helpfully shows where each driver is relocated to. The UEFI load system pre-formats the output into `add-symbol-file` directives that can be copy-and-pasted.
13+
After booting the FVP, notice that in the Non-secure AP console output, the UEFI load system helpfully shows where each driver is relocated to.
14+
15+
**Do the same actions in the same order you will when you are debugging as this affects the locations of the modules. For example, open UEFI interface -> Enter UEFI Shell -> Load EFI driver in the same order each time.**
1416

1517
The log files are stored in:
1618
```bash
17-
/<workspace>/rd-infra/model-scripts/rdinfra/platforms/rdn2/rdn2
19+
<workspace>/rd-infra/model-scripts/rdinfra/platforms/rdn2/rdn2
1820
```
1921

20-
As we focus on the ``uart-0-nsec`` console, we can use ``grep`` to find all the symbol files.
21-
```bash
22-
grep add-symbol-file refinfra-*-uart-0-nsec-*
23-
```
22+
Following the previous chapter, we should still be in TF-A. In the Commands window, execute the following command to break at the start of UEFI: ``break EL2N:0xE0000000``. Execute until we are in EL2N address space. This is because the script depends on the current address space when loading in symbols.
23+
24+
In Arm DS, go to the scripts tab and hit "Import a script or directory" then "Import a DS or Jython script"
25+
26+
![ArmDS scripts alt-text#center](images/armds-script.png "Figure 4. Add ArmDS scripts")
27+
28+
Select the script ``~/rd-infra/uefi/edk2/ArmPlatformPkg/Scripts/Ds5/cmd_load_symbols.py``.
2429

25-
![grep uart logs alt-text#center](images/grep.png "Figure 1. Grep UART logs")
30+
Enter the following parameters
2631

27-
We can then copy these lines and append them to the list of symbol files, as before.
32+
``-f (<UEFI entry point>, 0x20000)`` The UEFI entry point was found earlier (0xE0000000). 0x20000 is the size which can be found in the UEFI build log.
2833

29-
UEFI runs in EL2, so modify the end of each line to be ``EL2:<address>``.
34+
![FV Size alt-text#center](images/armds-script.png "Figure 5. FV Size")
3035

31-
![uefi symbol files alt-text#center](images/uefi_symbol_files.png "Figure 3. Add uefi symbol files")
36+
```command
37+
-a -v
38+
39+
-i <path to UART log file> This is the path to the UART log which was produced by a running the whole UEFI process
40+
41+
-o <path to objdump executable> This is the path to aarch64-none-linux-gnu-objdump.
42+
```
43+
44+
The script has now been setup.
45+
All the debug symbols have loaded, you can now start debugging!
46+
47+
### Debugging Boot Process
3248

3349
Once the debugger is connected, see the **functions** tab. Here you can search for functions to
34-
set breakpoints. For example, let's set a breakpoint at the entry point to PEI.
50+
set breakpoints.
51+
For example, let's set a breakpoint at the entry point to DxeCore.
3552

36-
![peicore alt-text#center](images/peicore.png "Figure 4. PeiCore functions")
53+
![dxecore alt-text#center](images/dxecore.png "Figure 6. DxeCore functions")
3754

3855
You can see that it has stopped at the breakpoint.
3956

57+
![dxecore breakpoint alt-text#center](images/dxecorebreakpoint.png "Figure 6. DxeCore breakpoint")
58+
4059
### If using Arm Development Studio version <2023.1
4160

4261
Older versions of Arm Development Studio have Beta support for DWARF 5 formats. EDK2 builds the debug files in DWARF 5
@@ -50,5 +69,5 @@ These instructions state that you must enable the LLVM DWARF parser to use DWARF
5069
2. Then, in the **Preferences** dialog box, navigate to **Arm DS** > **Debugger** > **DWARF Parser**.
5170
3. Select the **Use LLVM DWARF parser** checkbox and click **Apply and Close**.
5271

53-
![enable llvm alt-text#center](images/enable_llvm.png "Figure 5. Enable LLVM")
72+
![enable llvm alt-text#center](images/enable_llvm.png "Figure 7. Enable LLVM")
5473

content/learning-paths/servers-and-cloud-computing/refinfra-debug/debugging-scp-2.md renamed to content/learning-paths/servers-and-cloud-computing/refinfra-debug/debugging-scp-lcp-rse-2.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
2-
title: Debugging SCP
2+
title: Debugging SCP/LCP/RSE
33
weight: 3
44

55
### FIXED, DO NOT MODIFY
66
layout: learningpathall
77
---
88

9-
## Debugging SCP
9+
## Setting up a connection
1010
{{% notice %}}
1111
SCP firmware debug uses the `-Og` argument. This optimizes some variables that make debugging difficult. To replace `-Og` with `-O0`, do the following:
1212

@@ -46,16 +46,38 @@ In the **Edit configuration and launch** panel, in the **Connection** tab, selec
4646

4747
For the `SCP` code, select **ARM_Cortex-M7_1**.
4848

49+
{{% notice Selecting the correct core %}}
50+
For different platforms (e.g., RD-N2, RD-V3, etc.), you will see a list of numbered M7 and M55 cores. Typically, even-numbered M7 cores correspond to the MCP, while odd-numbered cores are assigned to the SCP. Additionally:
51+
52+
- `ARM_Cortex-M55_0` to `ARM_Cortex-M55_(N-1)` represent LCP cores.
53+
- `ARM_Cortex-M55_N` represents the RSE.
54+
55+
To verify core assignments, you can set up alerts (e.g., print statements or store variables), connect to a debugger, and test the configuration.
56+
{{% /notice %}}
57+
4958
![select target alt-text#center](images/select_cortexm7.png "Figure 5. Select target")
5059

5160
In the **Files** panel, select **Load Symbols from file**, **File System**, and select the **SCP RAMFW ELF** file, located at:
5261

5362
``rd-infra/scp/output/rdn2/0/scp_ramfw/bin/rdn2-bl2.elf``.
5463

64+
RSE debug symbol file location:
65+
```command
66+
rd-infra/tf-m/cmake_build/<plat>/<cfg>/bin/bl1_1.elf
67+
rd-infra/tf-m/cmake_build/<plat>/<cfg>/bin/bl1_2.elf
68+
rd-infra/tf-m/cmake_build/<plat>/<cfg>/bin/bl2.elf
69+
```
70+
71+
LCP debug symbol file location:
72+
```command
73+
rd-infra/scp/output/<plat>/<cfg>/lcp_ramfw/rdv3-lcp-bl2.elf
74+
```
75+
5576
![scp symbols alt-text#center](images/scp_symbols.png "Figure 6. Load SCP symbols")
5677

5778
Select **Apply** then **Debug**. The debugger now connects to the model.
5879

80+
## Setting breakpoints
5981
Once connected, you can set breakpoints in the source code. This can be done by searching for the function in the **Functions** tab, double-clicking next to the line number, or in the **Command** view.
6082

6183
Set a breakpoint at ``cmn700_discovery()``. Continue execution and the code stops at the breakpoint you specify.
46 KB
Loading
Binary file not shown.
47.5 KB
Loading
212 KB
Loading
129 KB
Loading
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)