如何调试运行在qemu上的riscv版uboot?

uboot有两个阶段,重定位之前和重定位之后,这两个阶段的符号表是不一样的,因此需关注是调试重定位之前的uboot还是重定位之后的uboot(以riscv版uboot为例)

1. 调试重定位之前的uboot
    1.1 使用qemu启动uboot,并进入调试模式

    $ qemu-system-riscv64 -nographic -machine virt -m 512 -kernel <opensbi>/build/platform/qemu/virt/firmware/fw_jump.elf -device loader,file=<uboot>/u-boot.bin -s -S
    1.2 调试重定位之前的uboot
    $ riscv64-unknown-linux-gnu-gdb <uboot>/u-boot

        (gdb) target remote :1234
        (gdb) b board_init_f
        (gdb) c
2. 调试重定位之后的uboot
    2.1 使用qemu启动uboot,并进入调试模式(同1.1)
    2.2 调试重定位之前的uboot    
    $ riscv64-unknown-elf-gdb(riscv64-unknown-linux-gnu-gdb) <uboot>/u-boot
    (gdb) target remote :1234
     //获取重定位之后uboot在内存中的地址
    (gdb) b relocate_code (relocate_code函数的参数指定了重定位之后的uboot地址)
    (gdb) c
    (gdb) info register a2
     0x8ff64000
    (gdb) b call_board_init_r
    (gdb) symbol-file (delete old symbols)
      Discard symbol table `~/u-boot` (y or n) y
  
    // 加载重定位之后的符号表
    (gdb) add-symbol-file <uboot>/u-boot 0x8ff64000
      add symbol table file from "~/u-boot" at
      .text_addr = 0x8ff64000
      (y or n) y
    (gdb) b board_init_r
    (gdb) c 

 


      

猜你喜欢

转载自www.cnblogs.com/dakewei/p/12290074.html
今日推荐