-
Notifications
You must be signed in to change notification settings - Fork 10
/
kgdb_qemu_run.sh
executable file
·75 lines (70 loc) · 2.11 KB
/
kgdb_qemu_run.sh
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
#!/bin/bash
# The SEALS Opensource Project
# SEALS : Simple Embedded Arm Linux System
# Maintainer : Kaiwan N Billimoria
# kaiwan -at- kaiwantech -dot- com
# Project URL:
# https://github.com/kaiwan/seals
# (c) kaiwanTECH
name=$(basename $0)
#############################
# ${BUILD_CONFIG_FILE} : a configuration script that asks the user for and sets up
# folder locations, toolchain PATH, any other configs as required.
#############################
export BUILD_CONFIG_FILE=./build.config
source ${BUILD_CONFIG_FILE} || {
echo "${name}: source failed! ${BUILD_CONFIG_FILE} missing or invalid?"
exit 1
}
source ./common.sh || {
echo "${name}: source failed! ./common.sh missing or invalid?"
exit 1
}
color_reset
if [ $# -ne 1 ]; then
echo "Usage: $name kernel-[b]zImage (compiled with -g)"
exit 1
fi
[ ! -f $1 ] && {
echo "$1 invalid.."
exit 1
}
echo
echo "REMEMBER this kernel is run w/ the -S QEMU switch: it *waits* for a gdb client to connect to it..."
echo
echo "You are expected to run (in another terminal window):
$ ${CXX}gdb <path-to-ARM-built-kernel-src-tree>/vmlinux # <-- built w/ -g
...
# and then have gdb connect to the target kernel using
(gdb) target remote :1235
...
"
echo
#ARMPLAT=vexpress-a9 ## make sure it's right! ##
# It's IMPORTANT to pass along the Device Tree Blob !
DTB=${STG}/images/vexpress-v2p-ca9.dtb
PORT=1235
[ ! -f ${DTB} ] && {
echo "${name}: FATAL: DTB file \"${DTB}\" not present?"
exit 1
}
cmd="qemu-system-arm -m 256 -M ${ARM_PLATFORM_OPT} -kernel $1 \
-drive file=${STG}/images/rfs.img,if=sd,format=raw \
-append \"console=ttyAMA0 root=/dev/mmcblk0 init=/sbin/init\" -nographic \
-gdb tcp::${PORT} -S \
-dtb ${DTB}"
# qemu help:
# -gdb dev wait for gdb connection on 'dev'
# -S freeze CPU at startup (use 'c' to start execution)
echo "Running: ${cmd}"
eval "${cmd}"
#
# If you get this error::
#
# inet_listen_opts: bind(ipv4,0.0.0.0,1234): Address already in use
#inet_listen_opts: bind(ipv6,::,1234): Address already in use
#inet_listen_opts: FAILED
#chardev: opening backend "socket" failed
##
# try using a different port # (and do
# (gdb) target remote :<new-port#>