mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-29 21:14:27 +01:00
aarch64, fix gdb with linux-custom
This commit is contained in:
18
README.md
18
README.md
@@ -291,7 +291,7 @@ And then tell GDB where the module was loaded with:
|
|||||||
|
|
||||||
The portability of the kernel and toolchains is amazing: change an option and most things magically work on completely different hardware.
|
The portability of the kernel and toolchains is amazing: change an option and most things magically work on completely different hardware.
|
||||||
|
|
||||||
### ARM
|
### arm
|
||||||
|
|
||||||
First build:
|
First build:
|
||||||
|
|
||||||
@@ -312,7 +312,21 @@ TODOs:
|
|||||||
- only managed to run in the terminal interface (but weirdly a blank QEMU window is still opened)
|
- only managed to run in the terminal interface (but weirdly a blank QEMU window is still opened)
|
||||||
- GDB not connecting to KGDB. Possibly linked to `-serial stdio`. See also: <https://stackoverflow.com/questions/14155577/how-to-use-kgdb-on-arm>
|
- GDB not connecting to KGDB. Possibly linked to `-serial stdio`. See also: <https://stackoverflow.com/questions/14155577/how-to-use-kgdb-on-arm>
|
||||||
|
|
||||||
### MIPS
|
### aarch64
|
||||||
|
|
||||||
|
./run -a aarch64
|
||||||
|
|
||||||
|
TODOs:
|
||||||
|
|
||||||
|
- GDB gives a ton of messages:
|
||||||
|
|
||||||
|
no module object found for ''
|
||||||
|
|
||||||
|
when you connect. `Ctrl + C` then `c` works though.
|
||||||
|
|
||||||
|
- How to add devices to `-M virt` as we did for `-M versatilepb`
|
||||||
|
|
||||||
|
### mips64
|
||||||
|
|
||||||
./run -a mips64
|
./run -a mips64
|
||||||
|
|
||||||
|
|||||||
@@ -53,12 +53,15 @@ CONFIG_SCHED_TRACER=y
|
|||||||
CONFIG_STACK_TRACER=y
|
CONFIG_STACK_TRACER=y
|
||||||
CONFIG_TRACER_SNAPSHOT=y
|
CONFIG_TRACER_SNAPSHOT=y
|
||||||
|
|
||||||
# x86
|
## x86
|
||||||
|
|
||||||
# https://stackoverflow.com/questions/20069620/print-kernels-page-table-entries
|
# https://stackoverflow.com/questions/20069620/print-kernels-page-table-entries
|
||||||
# cat /sys/kernel/debug/kernel_page_tables
|
# cat /sys/kernel/debug/kernel_page_tables
|
||||||
CONFIG_X86_PTDUMP=y
|
CONFIG_X86_PTDUMP=y
|
||||||
|
|
||||||
# LEDs. ARM only.
|
## ARM
|
||||||
|
|
||||||
|
# LEDs:
|
||||||
#
|
#
|
||||||
# cd /sys/class/leds/versatile:0
|
# cd /sys/class/leds/versatile:0
|
||||||
# cat max_brightness
|
# cat max_brightness
|
||||||
@@ -109,8 +112,6 @@ CONFIG_GPIOLIB=y
|
|||||||
CONFIG_GPIO_SYSFS=y
|
CONFIG_GPIO_SYSFS=y
|
||||||
CONFIG_GPIO_PL061=y
|
CONFIG_GPIO_PL061=y
|
||||||
|
|
||||||
# run -a arm
|
|
||||||
#
|
|
||||||
# In target:
|
# In target:
|
||||||
#
|
#
|
||||||
# modprobe dummy-irq irq=34
|
# modprobe dummy-irq irq=34
|
||||||
@@ -125,3 +126,12 @@ CONFIG_GPIO_PL061=y
|
|||||||
#
|
#
|
||||||
# The IRQ number 34 was found by via dmesg on a previous "insmod /platform_device.ko".
|
# The IRQ number 34 was found by via dmesg on a previous "insmod /platform_device.ko".
|
||||||
CONFIG_DUMMY_IRQ=m
|
CONFIG_DUMMY_IRQ=m
|
||||||
|
|
||||||
|
## aarch64
|
||||||
|
|
||||||
|
# For some reason not selected by default as it was for arm, and pci modules fail to build.
|
||||||
|
# Not that we have PCI working on ARM anyways.
|
||||||
|
CONFIG_PCI=y
|
||||||
|
|
||||||
|
# Like CONFIG_X86_PTDUMP for ARM.
|
||||||
|
CONFIG_ARM64_PTDUMP=y
|
||||||
|
|||||||
3
run
3
run
@@ -21,6 +21,9 @@ case "$arch" in
|
|||||||
# so let's stick to versatile for now.
|
# so let's stick to versatile for now.
|
||||||
defconfig='qemu_arm_versatile_defconfig'
|
defconfig='qemu_arm_versatile_defconfig'
|
||||||
;;
|
;;
|
||||||
|
'aarch64')
|
||||||
|
defconfig='qemu_aarch64_virt_defconfig'
|
||||||
|
;;
|
||||||
'mips64')
|
'mips64')
|
||||||
defconfig='qemu_mips64r6_malta_defconfig'
|
defconfig='qemu_mips64r6_malta_defconfig'
|
||||||
;;
|
;;
|
||||||
|
|||||||
5
rungdb
5
rungdb
@@ -23,7 +23,7 @@ fi
|
|||||||
|
|
||||||
buildroot_out_dir="$(pwd)/buildroot/output.${arch}~"
|
buildroot_out_dir="$(pwd)/buildroot/output.${arch}~"
|
||||||
gdb="${buildroot_out_dir}/host/usr/bin/${arch}-linux-gdb"
|
gdb="${buildroot_out_dir}/host/usr/bin/${arch}-linux-gdb"
|
||||||
cd "${buildroot_out_dir}/build"/linux-?.*.*/
|
cd "${buildroot_out_dir}/build"/linux-custom/
|
||||||
if "$kgdb"; then
|
if "$kgdb"; then
|
||||||
cmd="$gdb \
|
cmd="$gdb \
|
||||||
-q \
|
-q \
|
||||||
@@ -51,7 +51,7 @@ else
|
|||||||
-ex 'lx-symbols ../kernel_module-1.0/'
|
-ex 'lx-symbols ../kernel_module-1.0/'
|
||||||
"
|
"
|
||||||
;;
|
;;
|
||||||
'arm'|'mips64')
|
'arm'|'aarch64'|'mips64')
|
||||||
cmd="$gdb \
|
cmd="$gdb \
|
||||||
-q \
|
-q \
|
||||||
-ex 'add-auto-load-safe-path $(pwd)' \
|
-ex 'add-auto-load-safe-path $(pwd)' \
|
||||||
@@ -63,4 +63,5 @@ else
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
echo "$cmd"
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
|
|||||||
17
runqemu
17
runqemu
@@ -85,6 +85,23 @@ case "$arch" in
|
|||||||
$extra_flags
|
$extra_flags
|
||||||
"
|
"
|
||||||
;;
|
;;
|
||||||
|
'aarch64')
|
||||||
|
if $kgdb; then
|
||||||
|
extra_append="$extra_append kgdboc=ttyAMA0,115200"
|
||||||
|
fi
|
||||||
|
cmd="$qemu_common \
|
||||||
|
-M virt \
|
||||||
|
-append 'root=/dev/sda $extra_append' \
|
||||||
|
-cpu cortex-a57 \
|
||||||
|
-device virtio-net-device,netdev=eth0 \
|
||||||
|
-drive file=${images_dir}/rootfs.cpio,if=scsi,format=raw \
|
||||||
|
-kernel ${images_dir}/Image \
|
||||||
|
-netdev user,id=eth0 \
|
||||||
|
-nographic \
|
||||||
|
-serial stdio \
|
||||||
|
$extra_flags
|
||||||
|
"
|
||||||
|
;;
|
||||||
'mips64')
|
'mips64')
|
||||||
cmd="$qemu_common \
|
cmd="$qemu_common \
|
||||||
-M malta \
|
-M malta \
|
||||||
|
|||||||
Reference in New Issue
Block a user