2015/05/17

Really Unsorted Back Trace

Some Back Trace from GDB

(gdb) bt
#0  vic_handle_irq (regs=0xc03ddf18 ) at drivers/irqchip/irq-vic.c:250
#1  0xc0017640 in __irq_svc () at arch/arm/kernel/entry-armv.S:206

(gdb) bt
#0  tick_handle_periodic (dev=0xc03e1440 ) at kernel/time/tick-common.c:128
#1  0xc001e194 in sp804_timer_interrupt (irq=, dev_id=) at arch/arm/common/timer-sp.c:125
#2  0xc0048010 in handle_irq_event_percpu (desc=0xc03e6a58 , action=0xc03e14c0 ) at kernel/irq/handle.c:143
#3  0xc0048150 in handle_irq_event (desc=0xc03e6a58 ) at kernel/irq/handle.c:192
#4  0xc004a668 in handle_level_irq (irq=, desc=0x0 <__vectors_start>) at kernel/irq/chip.c:457
#5  0xc0047a6c in generic_handle_irq_desc (desc=, irq=) at include/linux/irqdesc.h:129
#6  generic_handle_irq (irq=) at kernel/irq/irqdesc.c:351
#7  __handle_domain_irq (domain=0xc7806020, hwirq=5, lookup=true, regs=) at kernel/irq/irqdesc.c:388
#8  0xc00087c8 in handle_domain_irq (hwirq=, domain=, regs=) at include/linux/irqdesc.h:147
#9  handle_one_vic (regs=, vic=) at drivers/irqchip/irq-vic.c:222
#10 vic_handle_irq (regs=0x0 <__vectors_start>) at drivers/irqchip/irq-vic.c:255
#11 0xc0017640 in __irq_svc () at arch/arm/kernel/entry-armv.S:206


(gdb) bt
#0  fpga_irq_handle (irq=32, desc=0xc03e7988 ) at drivers/irqchip/irq-versatile-fpga.c:70
#1  0xc0047a6c in generic_handle_irq_desc (desc=, irq=) at include/linux/irqdesc.h:129
#2  generic_handle_irq (irq=) at kernel/irq/irqdesc.c:351
#3  __handle_domain_irq (domain=0xc7806020, hwirq=32, lookup=true, regs=) at kernel/irq/irqdesc.c:388
#4  0xc00087c8 in handle_domain_irq (hwirq=, domain=, regs=) at include/linux/irqdesc.h:147
#5  handle_one_vic (regs=, vic=) at drivers/irqchip/irq-vic.c:222
#6  vic_handle_irq (regs=0x20) at drivers/irqchip/irq-vic.c:255
#7  0xc0017640 in __irq_svc () at arch/arm/kernel/entry-armv.S:206

#0  hxvic_of_init (node=0xc7ffc9a0, parent=0x0 <__vectors_start>) at drivers/irqchip/irq-heliosx.c:25
#1  0xc01c2b92 in of_irq_init (matches=0xc01c7660 <__of_table_arm_heliosx_vic>) at drivers/of/irq.c:545
#2  0xc01c0ea6 in irqchip_init () at drivers/irqchip/irqchip.c:29
#3  0xc01b78f0 in init_IRQ () at arch/arm/kernel/irq.c:106
#4  0xc01b685c in start_kernel () at init/main.c:577

(gdb) bt
#0  clk_enable (clk=0xc03e1de8 ) at arch/arm/plat-versatile/clock.c:24
#1  0xc03c1544 in sp804_get_clock_rate (clk=0xc03e1de8 ) at arch/arm/common/timer-sp.c:48
#2  0xc03c16c0 in __sp804_clockevents_init (base=0xf11e2000, irq=5, clk=, name=0xc4000c78 "arm,sp804") at arch/arm/common/timer-sp.c:196
#3  0xc03c1838 in sp804_of_init (np=0xc7ef7950) at arch/arm/common/timer-sp.c:256
#4  0xc03d0358 in clocksource_of_init () at drivers/clocksource/clksrc-of.c:38
#5  0xc03bedd0 in time_init () at arch/arm/kernel/time.c:123
#6  0xc03bbad0 in start_kernel () at init/main.c:584
#7  0x00008040 in ?? ()


#0  tick_setup_periodic (dev=0xc03e1440 , broadcast=0) at kernel/time/tick-common.c:135
#1  0xc0058908 in clockevents_register_device (dev=) at kernel/time/clockevents.c:393
#2  0xc03c1838 in sp804_of_init (np=0xc7ef7950) at arch/arm/common/timer-sp.c:256
#3  0xc03d0358 in clocksource_of_init () at drivers/clocksource/clksrc-of.c:38
#4  0xc03bedd0 in time_init () at arch/arm/kernel/time.c:123
#5  0xc03bbad0 in start_kernel () at init/main.c:584


#0  amba_device_add (dev=0x87908a00, parent=0x80642384 ) at drivers/amba/bus.c:349
#1  0x80387480 in of_amba_device_create (parent=, platform_data=, bus_id=, node=) at drivers/of/platform.c:320
#2  of_platform_bus_create (bus=0x87ef1888, matches=, lookup=, parent=0x80650908 , strict=) at drivers/of/platform.c:410
#3  0x80387590 in of_platform_populate (root=0x87908a00, matches=0x80642384 , lookup=0x0 <__vectors_start>, parent=0x0 <__vectors_start>) at drivers/of/platform.c:501
#4  0x805ff880 in customize_machine () at arch/arm/kernel/setup.c:815
#5  customize_machine () at arch/arm/kernel/setup.c:802
#6  0x80008924 in do_one_initcall (fn=0x805ff850 ) at init/main.c:785
#7  0x805fddf4 in do_initcall_level (level=) at init/main.c:850
#8  do_initcalls () at init/main.c:858
#9  do_basic_setup () at init/main.c:877
#10 kernel_init_freeable () at init/main.c:998
#11 0x80473fdc in kernel_init (unused=) at init/main.c:928
#12 0x8000e5c0 in ret_from_fork () at arch/arm/kernel/entry-common.S:92

2015/05/15

U-Boot Updates Device Tree Blob

When u-boot a kernel image with device tree blob, like
bootz 0x0a000000 - 0x09f00000
( 0x0a000000 is the location of the zImage, 0x9f00000 is the location of device tree blob)

The device tree blob is not passed to kernel as it is, the u-boot will fix up some value like memory bank range and size in the device tree blob.
For memory fix up, it is done in
arch_fixup_fdt, file arch/arm/lib/bootm-fdt.c

2015/05/12

Play U-Boot on Qemu, 2015 version

Package Installation
  sudo apt-get install qemu-system  gcc-arm-none-eabi
  sudo apt-get -o Dpkg::Options::="--force-overwrite" install gdb-arm-none-eabi


U-Boot Build
Get u-boot source from ftp://ftp.denx.de/pub/u-boot/ , I got version u-boot-2015.01.tar.bz2
Extract the source and on console:
  cd u-boot-2015.01
  make versatileqemu_config ARCH=arm CROSS_COMPILE=arm-none-eabi-
  make all ARCH=arm CROSS_COMPILE=arm-none-eabi-
To print out the actual compile and linker command:
  make all ARCH=arm CROSS_COMPILE=arm-none-eabi- KBUILD_VERBOSE=1


Run the U-Boot in Qemu
  qemu-system-arm -M versatilepb -m 128M -nographic -kernel u-boot.bin
You should see U-Boot prompt "VersatilePB # " on the console
To exit QEMU, press “Ctrl a” and then “x”.


Problem Shooting
Run with logging every instruction exectuted
  qemu-system-arm -M versatilepb -m 128M -nographic -kernel u-boot.bin -d in_asm,cpu -D qemu.log -singlestep

Disassemble U-Boot
  arm-none-eabi-objdump -d u-boot

Check memory map info
  gvim u-boot.map
  nm u-boot

To Clean
  make clean
  make mrproper

To enable debug message
in include/configs/versatial.h
add
#define DEBUG 1


Debug with GDB 
Install the gdb for arm
 sudo apt-get -o Dpkg::Options::="--force-overwrite" install gdb-arm-none-eabi


qemu-system-arm  -m some_machine -m 256M -nographic -kernel some_image.bin -s

on the other terminal

ddd --debugger arm-none-eabi-gdb
(gdb) symbol-file ~/git/lhx/vmlinux
(gdb)
(gdb) target remote :1234
(gdb) break setup_arch
(gdb) c

Reference
https://balau82.wordpress.com/2010/02/28/hello-world-for-bare-metal-arm-using-qemu/
http://infocenter.arm.com/help/topic/com.arm.doc.dui0224i/DUI0224I_realview_platform_baseboard_for_arm926ej_s_ug.pdf
http://infocenter.arm.com/help/topic/com.arm.doc.ddi0183g/DDI0183G_uart_pl011_r1p5_trm.pdf http://git.savannah.gnu.org/cgit/qemu.git/tree/hw/versatilepb.c
https://balau82.wordpress.com/2010/11/30/emulating-arm-pl011-serial-ports/
http://elinux.org/Virtual_Development_Board

Post Code on Blogger

Simplest way to post code to blogger for me: <pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black;overflow-x:...