-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgdb_smarc_g2l_atf_uboot
95 lines (81 loc) · 3.13 KB
/
gdb_smarc_g2l_atf_uboot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# Please set the board boot mode to SCIF boot: SW11 ON-OFF-ON-OFF
# It must be copied in the u-boot source root folder as well as the bl2_mod.elf file.
# It is assumed that ATF code (strictly required) resides at the same level as u-boot, e.g.:
# PATH/rzg_trusted-firmware-a
# PATH/renesas-u-boot-cip#
#
# This script is meant to load ATF (BL2 and BL31) as well as U-Boot
# directly into RAM using the JTAG, for example to be able
# to program external flashes, or anyway take advantage of all
# U-Boot functionalities. It may be useful also to debug U-Boot.
# We need the initialization done in BL2 and BL31 before loading
# U-Boot.
#
# The flow is:
# 1) Load BL2 into internal SRAM;
# 2) Set a breakpoint to the instruction that loads BL31 and U-Boot;
# 3) Load BL31 and U-Boot via JTAG instead when the breakpoint is hit;
# 4) Continue the execution and relocate U-Boot symbols
#
# The script requires only one change in the ATF: 2 labels in order to
# set the breakpoints just before and after the code that is supposed
# to load stuff from the non-volatile memory. Binaries are also
# provided.
#
# This script works only if OpenOCD write memory functions are patched:
# http://openocd.zylin.com/#/c/6266/
# Connect to OpenOCD
# If the script is launched from GDB command line then the next line shall not be commented out
# In Eclipse it is not needed since the connection is attempted by Eclipse itself
#target remote localhost:3333
mon reset
# Re-examine after reset
mon r9a07g044l.a55.0 arp_examine 0
mon r9a07g044l.a55.0 arp_examine 1
mon halt
shell sleep 0.5
# Disable SMP
mon r9a07g044l.a55.0 aarch64 smp off
# Load modified ATF BL2 and symbols
# You can use your own version (with before_load and after_load defined)
# or just use the bl2_mod.elf
#load ../rzg_trusted-firmware-a_private/build/rzg2l/debug/bl2/bl2.elf
load ./bl2_mod.elf
shell sleep 1
#symbol-file ../rzg_trusted-firmware-a_private/build/rzg2l/debug/bl2/bl2.elf
symbol-file ./bl2_mod.elf
# Restore BOOT_ID to the expected value: 0x3 = QSPI boot
mon mww 0x10000 0x3
# Insert HW breakpoint. SW breakpoints are failing because EL3 MMU is enabled
# and apparently memory is set to read only in the corresponding page
hbreak bl2_load_images:before_load
hbreak console_flush
continue
# Set internal RAM to RO to force GDB using HW breakpoints
mem 0x10000 0x2FFFF ro
# Load ATF BL31
mem 0x40000000 0x4FFFFFFF rw
load ../rzg_trusted-firmware-a_private/build/rzg2l/debug/bl31/bl31.elf
set $x0=0
jump bl2_load_images:after_load
# Load U-boot (BL33)
mem 0x50000000 0xBFFFFFFF rw
restore ../temp/u-boot-test/.out/u-boot.bin binary 0x50000000
set $x0=0
jump bl2_load_images:after_load
# Delete breakpoints that are not used anymore
delete 1
delete 2
# Load U-Boot symbols before the code relocation
symbol-file ../temp/u-boot-test/.out/u-boot
shell sleep 1
# Set a Breakpoint to the start of the U-boot relocation routine
hb relocate_code
c
# Now we are ready to relocate U-boot symbols, note that "-o" requires a relatively new GDB (9.1 is OK).
symbol-file ./u-boot -o gd->reloc_off
# Define memory region to access RZ/G2L peripherals
mem 0x10000000 0x15000000 rw
# Set a breakpoint just before the main loop
hb run_main_loop
c