README.qemu_mips 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. 2) Download kernel + initrd
  14. On ftp://ftp.denx.de/pub/contrib/Jean-Christophe_Plagniol-Villard/qemu_mips/
  15. you can downland
  16. #config to build the kernel
  17. qemu_mips_defconfig
  18. #patch to fix mips interupt init on 2.6.24.y kernel
  19. qemu_mips_kernel.patch
  20. initrd.gz
  21. vmlinux
  22. vmlinux.bin
  23. System.map
  24. 4) Generate uImage
  25. # 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
  26. 5) Copy uImage to Flash
  27. # dd if=uImage bs=1k conv=notrunc seek=224 of=flash
  28. 6) Generate Ide Disk
  29. # dd of=ide bs=1k cout=100k if=/dev/zero
  30. # sfdisk -C 261 -d ide
  31. # partition table of ide
  32. unit: sectors
  33. ide1 : start= 63, size= 32067, Id=83
  34. ide2 : start= 32130, size= 32130, Id=83
  35. ide3 : start= 64260, size= 4128705, Id=83
  36. ide4 : start= 0, size= 0, Id= 0
  37. 7) Copy to ide
  38. # dd if=uImage bs=512 conv=notrunc seek=63 of=ide
  39. 8) Generate ext2 on part 2 on Copy uImage and initrd.gz
  40. # Attached as loop device ide offset = 32130 * 512
  41. # losetup -o 16450560 -f ide
  42. # Format as ext2 ( arg2 : nb blocks)
  43. # mke2fs /dev/loop0 16065
  44. # losetup -d /dev/loop0
  45. # Mount and copy uImage and initrd.gz to it
  46. # mount -o loop,offset=16450560 -t ext2 ide /mnt
  47. # mkdir /mnt/boot
  48. # cp {initrd.gz,uImage} /mnt/boot/
  49. # Umount it
  50. # umount /mnt
  51. 9) Set Environment
  52. setenv rd_start 0x80800000
  53. setenv rd_size 2663940
  54. setenv kernel BFC38000
  55. setenv oad_addr 80500000
  56. setenv load_addr2 80F00000
  57. setenv kernel_flash BFC38000
  58. setenv load_addr_hello 80200000
  59. setenv bootargs 'root=/dev/ram0 init=/bin/sh'
  60. setenv load_rd_ext2 'ide res; ext2load ide 0:2 ${rd_start} /boot/initrd.gz'
  61. setenv load_rd_tftp 'tftp ${rd_start} /initrd.gz'
  62. setenv load_kernel_hda 'ide res; diskboot ${load_addr} 0:2'
  63. setenv load_kernel_ext2 'ide res; ext2load ide 0:2 ${load_addr} /boot/uImage'
  64. setenv load_kernel_tftp 'tftp ${load_addr} /qemu_mips/uImage'
  65. setenv boot_ext2_ext2 'run load_rd_ext2; run load_kernel_ext2; run addmisc; bootm ${load_addr}'
  66. setenv boot_ext2_flash 'run load_rd_ext2; run addmisc; bootm ${kernel_flash}'
  67. setenv boot_ext2_hda 'run load_rd_ext2; run load_kernel_hda; run addmisc; bootm ${load_addr}'
  68. setenv boot_ext2_tftp 'run load_rd_ext2; run load_kernel_tftp; run addmisc; bootm ${load_addr}'
  69. setenv boot_tftp_hda 'run load_rd_tftp; run load_kernel_hda; run addmisc; bootm ${load_addr}'
  70. setenv boot_tftp_ext2 'run load_rd_tftp; run load_kernel_ext2; run addmisc; bootm ${load_addr}'
  71. setenv boot_tftp_flash 'run load_rd_tftp; run addmisc; bootm ${kernel_flash}'
  72. setenv boot_tftp_tftp 'run load_rd_tftp; run load_kernel_tftp; run addmisc; bootm ${load_addr}'
  73. setenv load_hello_tftp 'tftp ${load_addr_hello} /examples/hello_world.bin'
  74. setenv go_tftp 'run load_hello_tftp; go ${load_addr_hello}'
  75. setenv addmisc 'setenv bootargs ${bootargs} console=ttyS0,${baudrate} rd_start=${rd_start} rd_size=${rd_size} ethaddr=${ethaddr}'
  76. setenv bootcmd 'run boot_tftp_flash'
  77. 10) Now you can boot from flash, ide, ide+ext2 and tfp
  78. # qemu-system-mips -M mips -pflash flash -monitor null -nographic -net nic -net user -tftp `pwd` -hda ide
  79. II) How to debug U-Boot
  80. In order to debug U-Boot you need to start qemu with gdb server support (-s)
  81. and waiting the connection to start the CPU (-S)
  82. # qemu-system-mips -S -s -M mips -pflash flash -monitor null -nographic -net nic -net user -tftp `pwd` -hda ide
  83. in an other console you start gdb
  84. 1) Debugging of U-Boot Before Relocation
  85. Before relocation, the addresses in the ELF file can be used without any problems
  86. by connecting to the gdb server localhost:1234
  87. # mipsel-unknown-linux-gnu-gdb u-boot
  88. GNU gdb 6.6
  89. Copyright (C) 2006 Free Software Foundation, Inc.
  90. GDB is free software, covered by the GNU General Public License, and you are
  91. welcome to change it and/or distribute copies of it under certain conditions.
  92. Type "show copying" to see the conditions.
  93. There is absolutely no warranty for GDB. Type "show warranty" for details.
  94. This GDB was configured as "--host=i486-linux-gnu --target=mipsel-unknown-linux-gnu"...
  95. (gdb) target remote localhost:1234
  96. Remote debugging using localhost:1234
  97. _start () at start.S:64
  98. 64 RVECENT(reset,0) /* U-boot entry point */
  99. Current language: auto; currently asm
  100. (gdb) b board.c:289
  101. Breakpoint 1 at 0xbfc00cc8: file board.c, line 289.
  102. (gdb) c
  103. Continuing.
  104. Breakpoint 1, board_init_f (bootflag=<value optimized out>) at board.c:290
  105. 290 relocate_code (addr_sp, id, addr);
  106. Current language: auto; currently c
  107. (gdb) p/x addr
  108. $1 = 0x87fa0000
  109. 2) Debugging of U-Boot After Relocation
  110. For debugging U-Boot after relocation we need to know the address to which
  111. U-Boot relocates itself to 0x87fa0000 by default.
  112. And replace the symbol table to this offset.
  113. (gdb) symbol-file
  114. Discard symbol table from `/private/u-boot-arm/u-boot'? (y or n) y
  115. Error in re-setting breakpoint 1:
  116. No symbol table is loaded. Use the "file" command.
  117. No symbol file now.
  118. (gdb) add-symbol-file u-boot 0x87fa0000
  119. add symbol table from file "u-boot" at
  120. .text_addr = 0x87fa0000
  121. (y or n) y
  122. Reading symbols from /private/u-boot-arm/u-boot...done.
  123. Breakpoint 1 at 0x87fa0cc8: file board.c, line 289.
  124. (gdb) c
  125. Continuing.
  126. Program received signal SIGINT, Interrupt.
  127. 0xffffffff87fa0de4 in udelay (usec=<value optimized out>) at time.c:78
  128. 78 while ((tmo - read_c0_count()) < 0x7fffffff)