README.qemu_mips 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. Notes for the Qemu MIPS port
  2. I) Example usage:
  3. # ln -s u-boot.bin mips_bios.bin
  4. start it:
  5. qemu-system-mips -L . /dev/null -nographic
  6. or
  7. if you use a qemu version after commit 4224
  8. create image:
  9. # dd of=flash bs=1k count=4k if=/dev/zero
  10. # dd of=flash bs=1k conv=notrunc if=u-boot.bin
  11. start it:
  12. # qemu-system-mips -M mips -pflash flash -monitor null -nographic
  13. Ide Disk
  14. # dd of=ide bs=1k cout=100k if=/dev/zero
  15. # sfdisk -C 261 -d ide
  16. # partition table of ide
  17. unit: sectors
  18. ide1 : start= 63, size= 32067, Id=83
  19. ide2 : start= 32130, size= 32130, Id=83
  20. ide3 : start= 64260, size= 4128705, Id=83
  21. ide4 : start= 0, size= 0, Id= 0
  22. # Generate uImage
  23. # tools/mkimage -A mips -O linux -T kernel -C gzip -a 0x80010000 -e 0x80245650 -n "Linux 2.6.24.y" -d vmlinux.bin.gz uImage
  24. # Copy to Flash
  25. # dd if=uImage bs=1k conv=notrunc seek=224 of=flash
  26. # Copy to ide
  27. # dd if=uImage bs=512 conv=notrunc seek=63 of=ide
  28. # Generate ext2 on part 2
  29. # Attached as loop device ide offset = 32130 * 512
  30. # losetup -o 16450560 -f ide
  31. # Format as ext2 ( arg2 : nb blocks)
  32. # mke2fs /dev/loop0 16065
  33. # losetup -d /dev/loop0
  34. # Mount and copy uImage and initrd.gz to it
  35. # mount -o loop,offset=16450560 -t ext2 ide /mnt
  36. # Umount it
  37. # umount /mnt
  38. Now you can boot from flash, ide, ide+ext2 and tfp
  39. # qemu-system-mips -M mips -pflash flash -monitor null -nographic -net nic -net user -tftp `pwd` -hda ide
  40. II) How to debug U-Boot
  41. In order to debug U-Boot you need to start qemu with gdb server support (-s)
  42. and waiting the connection to start the CPU (-S)
  43. # qemu-system-mips -S -s -M mips -pflash flash -monitor null -nographic -net nic -net user -tftp `pwd` -hda ide
  44. in an other console you start gdb
  45. 1) Debugging of U-Boot Before Relocation
  46. Before relocation, the addresses in the ELF file can be used without any problems
  47. buy connecting to the gdb server localhost:1234
  48. # mipsel-unknown-linux-gnu-gdb u-boot
  49. GNU gdb 6.6
  50. Copyright (C) 2006 Free Software Foundation, Inc.
  51. GDB is free software, covered by the GNU General Public License, and you are
  52. welcome to change it and/or distribute copies of it under certain conditions.
  53. Type "show copying" to see the conditions.
  54. There is absolutely no warranty for GDB. Type "show warranty" for details.
  55. This GDB was configured as "--host=i486-linux-gnu --target=mipsel-unknown-linux-gnu"...
  56. (gdb) target remote localhost:1234
  57. Remote debugging using localhost:1234
  58. _start () at start.S:64
  59. 64 RVECENT(reset,0) /* U-boot entry point */
  60. Current language: auto; currently asm
  61. (gdb) b board.c:289
  62. Breakpoint 1 at 0xbfc00cc8: file board.c, line 289.
  63. (gdb) c
  64. Continuing.
  65. Breakpoint 1, board_init_f (bootflag=<value optimized out>) at board.c:290
  66. 290 relocate_code (addr_sp, id, addr);
  67. Current language: auto; currently c
  68. (gdb) p/x addr
  69. $1 = 0x87fa0000
  70. 2) Debugging of U-Boot After Relocation
  71. For debugging U-Boot after relocation we need to know the address to which
  72. U-Boot relocates itself to 0x87fa0000 by default.
  73. And replace the symbol table to this offset.
  74. (gdb) symbol-file
  75. Discard symbol table from `/private/u-boot-arm/u-boot'? (y or n) y
  76. Error in re-setting breakpoint 1:
  77. No symbol table is loaded. Use the "file" command.
  78. No symbol file now.
  79. (gdb) add-symbol-file u-boot 0x87fa0000
  80. add symbol table from file "u-boot" at
  81. .text_addr = 0x87fa0000
  82. (y or n) y
  83. Reading symbols from /private/u-boot-arm/u-boot...done.
  84. Breakpoint 1 at 0x87fa0cc8: file board.c, line 289.
  85. (gdb) c
  86. Continuing.
  87. Program received signal SIGINT, Interrupt.
  88. 0xffffffff87fa0de4 in udelay (usec=<value optimized out>) at time.c:78
  89. 78 while ((tmo - read_c0_count()) < 0x7fffffff)