From 80889c03768d194aa8ef119d9332595c84276d6e Mon Sep 17 00:00:00 2001 From: Ciro Santilli Date: Wed, 12 Jul 2017 11:49:58 +0100 Subject: [PATCH] aarch64, fix gdb with linux-custom --- README.md | 18 ++++++++++++++++-- kernel_config_fragment | 18 ++++++++++++++---- run | 3 +++ rungdb | 5 +++-- runqemu | 17 +++++++++++++++++ 5 files changed, 53 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 5050cf3..fc57870 100644 --- a/README.md +++ b/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. -### ARM +### arm First build: @@ -312,7 +312,21 @@ TODOs: - 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: -### 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 diff --git a/kernel_config_fragment b/kernel_config_fragment index 932afa4..7dde26c 100644 --- a/kernel_config_fragment +++ b/kernel_config_fragment @@ -53,12 +53,15 @@ CONFIG_SCHED_TRACER=y CONFIG_STACK_TRACER=y CONFIG_TRACER_SNAPSHOT=y -# x86 +## x86 + # https://stackoverflow.com/questions/20069620/print-kernels-page-table-entries # cat /sys/kernel/debug/kernel_page_tables CONFIG_X86_PTDUMP=y -# LEDs. ARM only. +## ARM + +# LEDs: # # cd /sys/class/leds/versatile:0 # cat max_brightness @@ -109,8 +112,6 @@ CONFIG_GPIOLIB=y CONFIG_GPIO_SYSFS=y CONFIG_GPIO_PL061=y -# run -a arm -# # In target: # # 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". 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 diff --git a/run b/run index 266d916..c7f1016 100755 --- a/run +++ b/run @@ -21,6 +21,9 @@ case "$arch" in # so let's stick to versatile for now. defconfig='qemu_arm_versatile_defconfig' ;; + 'aarch64') + defconfig='qemu_aarch64_virt_defconfig' + ;; 'mips64') defconfig='qemu_mips64r6_malta_defconfig' ;; diff --git a/rungdb b/rungdb index c81126a..7e7dbdf 100755 --- a/rungdb +++ b/rungdb @@ -23,7 +23,7 @@ fi buildroot_out_dir="$(pwd)/buildroot/output.${arch}~" 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 cmd="$gdb \ -q \ @@ -51,7 +51,7 @@ else -ex 'lx-symbols ../kernel_module-1.0/' " ;; - 'arm'|'mips64') + 'arm'|'aarch64'|'mips64') cmd="$gdb \ -q \ -ex 'add-auto-load-safe-path $(pwd)' \ @@ -63,4 +63,5 @@ else ;; esac fi +echo "$cmd" eval "$cmd" diff --git a/runqemu b/runqemu index 20bfec5..71ab96c 100755 --- a/runqemu +++ b/runqemu @@ -85,6 +85,23 @@ case "$arch" in $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') cmd="$qemu_common \ -M malta \