I’ve got an ARM Chromebook for a year, but I didn’t fully make use of it for GDB testing, because
- It is not easy to install linux on Chromebook
- It is not easy to use mainline kernel on Chromebook,
Recently, I tried again to upgrade its kernel, and tweak the kernel a little bit for GDB testing. I write my experiences down in this post.
Install a Linux distribution
Ubuntu is better than Fedora on usability, but Fedora is much better on debugging support (in kernel, system library, and compiler). I choose Fedora 19 for my Chromebook. Here is the article. Follow the instructions in the article, a Fedora 19 is installed on an SD card, with five partitions, the first two are for kernels, and last one is for root file system.
Upgrade to mainline kernel
The fundamentals of GDB debugging are ptrace and signals, so it highly relies on kernel. From time to time, we (GDB developers) have to upgrade kernels to
- verify kernel bug fixes, so these kernel bugs will not affect GDB in user space,
- make sure kernel changes don’t make any troubles to debugging,
I use 4.7.2 kernel. Configure and build it.
make CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm exynos_defconfig
make CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm prepare modules_prepare
make CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm zImage modules dtbs
make CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm INSTALL_MOD_PATH=../4_7_2 modules_install
I also need arch/arm/boot/zImage and arch/arm/boot/dts/exynos5250-snow.dtb to build kernel image,
mkimage -f kernel.its kernel.itb
vbutil_kernel --pack newkernel \
--keyblock /usr/share/vboot/devkeys/kernel.keyblock \
--version 1 \
--signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
--config kcmdline --vmlinuz kernel.itb --arch arm
File kernel.its describes the kernel image. Write the generated newkernel to partition 1 of SD card on PC.
sudo dd if=./newkernel of=/dev/mmcblk0p1
Then, we need to update root file systems to have kernel modes. Mount partition 5 somewhere, and copy 4.7.2 kernel modules to lib/modules/
$ sudo mount /dev/mmcblk0p5 ./tmp/
$ sudo cp ../4_7_2/lib/modules/4.7.2 ./tmp/lib/modules/
Insert the SD card back to Chromebook, and boot!
Turn on HW breakpoint
HW brekapoint in kernel is not turned on in default, and it depends on perf events. I need to reconfigure kernel to enable them.
make CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm menuconfig
In “General Setup”, select “Kernel Performance Events And Counters”, and then select perf events. Exit. Open .config file, and search HW_BREAKPOINT, to make sure HW breakpoint is enabled. Rebuild kernel to follow the steps above. Reboot and “breakpoint” is shown the boot message,
$ dmesg | grep breakpoint
[ 0.102099] hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers.
[ 0.102119] hw-breakpoint: maximum watchpoint size is 8 bytes.