arm64 kernel environment

Table of Contents

Next: , Up: (dir)   [Contents]

arm64 kernel environment

This manual is for program, version version.


Next: , Previous: , Up: Top   [Contents]

1 arm64 kerenel environment

install from binary
sudo apt-get install qemu-system-arm

install from source code
git clone http://git.qemu.org/git/qemu.git
cd qemu
./configure --help
./configure --target-list=aarch64-softmmu
make
sudo make install
cd ~
mkdir bin
cd bin
wget http://releases.linaro.org/14.09/components/toolchain/binaries/gcc-linaro-aarch64-linux-gnu-4.9-2014.09_linux.tar.xz
tar -Jxf gcc-linaro-aarch64-linux-gnu-4.9-2014.09_linux.tar.xz
rm gcc-linaro-aarch64-linux-gnu-4.9-2014.09_linux.tar.xz
cd gcc-linaro-aarch64-linux-gnu-4.9-2014.09_linux/bin/
pwd
edit file ~/.profile, add the following content,

PATH="$PATH:/home/zzy/bin/gcc-linaro-aarch64-linux-gnu-4.9-2014.09_linux/bin"
reboot PC
make directory for work, and change to it.
git clone https://github.com/sys-build/kern4.1_arm64_env.git
cd kern4.1_arm64_env/linux-4.1.16/
chage "CONFIG_INITRAMFS_SOURCE" to the right directory
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- O=../out zzy_defconfig
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- O=../out -j4 Image

Previous: , Up: Top   [Contents]

2 arm64 kerenel debug

cd ..
$qemu-system-aarch64 -machine virt -cpu cortex-a57 -machine type=virt -nographic -smp 1 -m 2048 -kernel out/arch/arm64/boot/Image --append "console=ttyAMA0"
C a c // press Ctrl+a and then press c -> quit arm64 linux
quit // quit qemu
// start kernel and stop the first instruction
$ qemu-system-aarch64 -machine virt -cpu cortex-a57 -machine type=virt -nographic -smp 1 -m 2048 -kernel out/arch/arm64/boot/Image --append "console=ttyAMA0" -s -S

start another console type the following commands
// start gdb and load vmlinux
$ aarch64-linux-gnu-gdb
(gdb) file out/vmlinux
Reading symbols from /media/disk2/03study/kern4.1_arm64_env/out/vmlinux...done.

(gdb) directory linux-4.1.16/
// read source code
Source directories searched: /media/disk2/03study/kern4.1_arm64_env/linux-4.1.16:cdir:cwd

(gdb) target remote localhost:1234
// access qemu guest
Remote debugging using localhost:1234
0x0000000040000000 in ?? ()

(gdb) break start_kernel
Breakpoint 2 at 0xffffffc0007ed5d8: file /media/disk2/03study/kern4.1_arm64_env/linux-4.1.16/init/main.c, line 493.
(gdb) c
Continuing.

Breakpoint 2, start_kernel () at /media/disk2/03study/kern4.1_arm64_env/linux-4.1.16/init/main.c:493
493 {
(gdb) list
488 vmalloc_init();
489 ioremap_huge_init();
490 }

(gdb) s
502 set_task_stack_end_magic(&init_task);
(gdb) info r
x0 0x34d5d91d 886429981
x1 0x40b68000 1085702144
x2 0x40 64
x3 0x3f 63
x4 0xffffffc000ac7000 -274866606080
x5 0xffffffc00081f000 -274869391360
x6 0xffffffc000aca000 -274866593792
x7 0xffffffc000b624a8 -274865970008
x8 0x0 0
x9 0x1124 4388
x10 0x34b5193519 226376627481
x11 0x0 0
x12 0x0 0
x13 0x16 22
x14 0x0 0

dmesg log have no timestamp
echo Y > /sys/module/printk/parameters/time
// todo
git clone https://github.com/zzyjsjcom/zzy_kernel_code.git