最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【记录】Ubuntu下测试QEMU中加载和测试Uboot

QEMU crifan 6622浏览 0评论

【背景】

折腾:

【记录】尝试用QEMU模拟ARM开发板去加载并运行Uboot,kernel,rootfs

期间,接着去折腾,尝试,是否可以加载自己已经在:

【记录】Ubuntu下用arm-xscale-linux-gnueabi交叉编译uboot

【记录】Ubuntu下基于Eclipse去调用Makefile交叉编译Uboot

编译好的uboot,并且正常运行输出。

【折腾过程】

1.参考:

Virtual Development Board

先去看看mkimage的事情。

去uboot的tools下面看看

果然有个mkimage,是个x86的程序:

crifan@ubuntu:u-boot-1.1.4-whgs$ cd tools/
crifan@ubuntu:tools$ ls
bddb        bmp_logo.o  CVS       envcrc    environment.c  gen_eth_addr    img2brec.sh  img2srec.o         Makefile        mkimage.c     ncb.c
bmp_logo    crc32.c     easylogo  envcrc.c  environment.o  gen_eth_addr.c  img2srec     inca-swap-bytes.c  Makefile.win32  mkimage.o     scripts
bmp_logo.c  crc32.o     env       envcrc.o  gdb            gen_eth_addr.o  img2srec.c   logos              mkimage         mpc86x_clk.c  updater
crifan@ubuntu:tools$ ll -ha
total 280K
drwxrwxrwx 10 crifan root   4.0K Aug 15 19:11 ./
drwxrwxrwx 26 crifan root   4.0K Aug 15 19:11 ../
drwxrwxrwx  3 crifan root   4.0K Aug  5 19:52 bddb/
-rwxrwxr-x  1 crifan crifan 9.5K Aug 15 19:11 bmp_logo*
-rwxrwxrwx  1 crifan root   3.6K Jun  4 06:50 bmp_logo.c*
-rw-rw-r--  1 crifan crifan 3.8K Aug 15 19:11 bmp_logo.o
lrwxrwxrwx  1 crifan crifan   22 Aug 13 02:51 crc32.c -> ../lib_generic/crc32.c*
-rw-rw-r--  1 crifan crifan 4.4K Aug 15 19:11 crc32.o
drwxrwxrwx  2 crifan root   4.0K Aug  5 19:52 CVS/
-rw-rw-r--  1 crifan crifan 9.5K Aug 13 02:52 .depend
drwxrwxrwx  3 crifan root   4.0K Aug  5 19:52 easylogo/
drwxrwxrwx  3 crifan root   4.0K Aug  5 19:52 env/
-rwxrwxr-x  1 crifan crifan  11K Aug 15 19:11 envcrc*
-rwxrwxrwx  1 crifan root   3.0K Jun  4 06:50 envcrc.c*
-rw-rw-r--  1 crifan crifan 4.4K Aug 15 19:11 envcrc.o
lrwxrwxrwx  1 crifan crifan   23 Aug 13 02:51 environment.c -> ../common/environment.c*
-rw-rw-r--  1 crifan crifan 1.4K Aug 15 19:11 environment.o
drwxrwxrwx  3 crifan root   4.0K Aug  5 19:52 gdb/
-rwxrwxr-x  1 crifan crifan 5.5K Aug 15 19:11 gen_eth_addr*
-rwxrwxrwx  1 crifan root   1.5K Jun  4 06:50 gen_eth_addr.c*
-rw-rw-r--  1 crifan crifan 5.5K Aug 15 19:11 gen_eth_addr.o
-rwxrwxrwx  1 crifan root    15K Jun  4 06:50 img2brec.sh*
-rwxrwxr-x  1 crifan crifan 9.5K Aug 15 19:11 img2srec*
-rwxrwxrwx  1 crifan root    12K Jun  4 06:50 img2srec.c*
-rw-rw-r--  1 crifan crifan 4.3K Aug 15 19:11 img2srec.o
-rwxrwxrwx  1 crifan root    647 Jun  4 06:50 inca-swap-bytes.c*
drwxrwxrwx  3 crifan root   4.0K Aug  5 19:52 logos/
-rwxrwxrwx  1 crifan root   4.9K Jun  4 06:50 Makefile*
-rwxrwxrwx  1 crifan root   1.1K Jun  4 06:50 Makefile.win32*
-rwxrwxr-x  1 crifan crifan  15K Aug 15 19:11 mkimage*
-rwxrwxrwx  1 crifan root    18K Jun  4 06:50 mkimage.c*
-rw-rw-r--  1 crifan crifan  39K Aug 15 19:11 mkimage.o
-rwxrwxrwx  1 crifan root   5.1K Jun  4 06:50 mpc86x_clk.c*
-rwxrwxrwx  1 crifan root    715 Jun  4 06:50 ncb.c*
drwxrwxrwx  3 crifan root   4.0K Aug  5 19:52 scripts/
drwxrwxrwx  3 crifan root   4.0K Aug  5 19:52 updater/
crifan@ubuntu:tools$ file mkimage
mkimage: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x2ab578053a3643e0f4fe1e862768d77ab32ccd33, stripped
crifan@ubuntu:tools$ 

2.然后去做个对应的mkimage的软链接:

crifan@ubuntu:u-boot-1.1.4-whgs$ ln -sf \$PWD/tools/mkimage /usr/local/bin/mkimage
ln: failed to create symbolic link ‘/usr/local/bin/mkimage’: Permission denied
crifan@ubuntu:u-boot-1.1.4-whgs$ sudo ln -sf \$PWD/tools/mkimage /usr/local/bin/mkimage
crifan@ubuntu:u-boot-1.1.4-whgs$ ls /usr/local/bin -lha
total 8.0K
drwxr-xr-x  2 root root 4.0K Aug 15 19:14 .
drwxr-xr-x 10 root root 4.0K Apr 24 10:02 ..
lrwxrwxrwx  1 root root   18 Aug 15 19:14 mkimage -> $PWD/tools/mkimage
crifan@ubuntu:u-boot-1.1.4-whgs$ sudo ln -sf $PWD/tools/mkimage /usr/local/bin/mkimage
crifan@ubuntu:u-boot-1.1.4-whgs$ ls /usr/local/bin -lha
total 12K
drwxr-xr-x  2 root root 4.0K Aug 15 19:14 .
drwxr-xr-x 10 root root 4.0K Apr 24 10:02 ..
lrwxrwxrwx  1 root root   71 Aug 15 19:14 mkimage -> /home/crifan/develop/crosscompile/uboot/u-boot-1.1.4-whgs/tools/mkimage
crifan@ubuntu:u-boot-1.1.4-whgs$ 

3。对于教程中:

qemu-system-arm -M versatilepb -nographic -kernel u-boot

中的

versatilepb

对应的模拟的板子是:

QEMU Emulator User Documentation

中提到的:

ARM Versatile baseboard (ARM)

。。。

The ARM Versatile baseboard is emulated with the following devices:

  • ARM926E, ARM1136 or Cortex-A8 CPU
  • PL190 Vectored Interrupt Controller
  • Four PL011 UARTs
  • SMC 91c111 Ethernet adapter
  • PL110 LCD controller
  • PL050 KMI with PS/2 keyboard and mouse.
  • PCI host bridge. Note the emulated PCI bridge only provides access to PCI memory space. It does not provide access to PCI IO space. This means some devices (eg. ne2k_pci NIC) are not usable, and others (eg. rtl8139 NIC) are only usable when the guest drivers use the memory mapped control registers.
  • PCI OHCI USB controller.
  • LSI53C895A PCI SCSI Host Bus Adapter with hard disk and CD-ROM devices.
  • PL181 MultiMedia Card Interface with SD card.

而我此处的,xscale的板子,自然的,暂时不支持。

所以,看起来,想要用QEMU去模拟我此处的pxa的板子,是没希望了。

只能是用其自带的那个versatilepb才可以。

换句话说,必须自己去下载教程中提到的,最新的u-boot-2010.09.tar.bz2,然后配置为versatilepb,然后编出个uboot,然后供此处QEMU去加载和运行。

4.下载对应的,最新的uboot:

【记录】用git下载最新的uboot代码

最终得到:

u-boot-2013.07.tar.bz2

5.然后解压得到源码:

crifan@ubuntu:u-boot-2013.07$ ls
u-boot  u-boot-2013.07.tar.bz2
crifan@ubuntu:u-boot-2013.07$ cd u-boot/
crifan@ubuntu:u-boot$ ls
api   board       common     COPYING  disk  drivers  examples  include  MAINTAINERS  Makefile  nand_spl  post    rules.mk         spl   tools
arch  boards.cfg  config.mk  CREDITS  doc   dts      fs        lib      MAKEALL      mkconfig  net       README  snapshot.commit  test
crifan@ubuntu:u-boot$ pwd
/home/crifan/develop/crosscompile/uboot/u-boot-2013.07/u-boot
crifan@ubuntu:u-boot$ 

6.然后去配置和编译最新的u-boot-2013.07:

【记录】用arm-xscale-linux-gnueabi为u-boot-2013.07去配置和交叉编译versatilepb

7.重新用最新的uboot的mkimage:

crifan@ubuntu:u-boot$ sudo ln -sf $PWD/tools/mkimage /usr/local/bin/mkimage
crifan@ubuntu:u-boot$ ls /usr/local/bin/ -lha
total 12K
drwxr-xr-x  2 root root 4.0K Aug 15 20:24 .
drwxr-xr-x 10 root root 4.0K Apr 24 10:02 ..
lrwxrwxrwx  1 root root   75 Aug 15 20:24 mkimage -> /home/crifan/develop/crosscompile/uboot/u-boot-2013.07/u-boot/tools/mkimage
crifan@ubuntu:u-boot$ 

8.然后就可以去测试了:

就可以了:

crifan@ubuntu:u-boot$ ls
api    boards.cfg  COPYING  doc      examples  lib          Makefile   nand_spl  README           spl         tools       u-boot.lds
arch   common      CREDITS  drivers  fs        MAINTAINERS  Makefile~  net       rules.mk         System.map  u-boot      u-boot.map
board  config.mk   disk     dts      include   MAKEALL      mkconfig   post      snapshot.commit  test        u-boot.bin  u-boot.srec
crifan@ubuntu:u-boot$ sudo ln -sf $PWD/tools/mkimage /usr/local/bin/mkimage
crifan@ubuntu:u-boot$ ls /usr/local/bin/ -lha
total 12K
drwxr-xr-x  2 root root 4.0K Aug 15 20:24 .
drwxr-xr-x 10 root root 4.0K Apr 24 10:02 ..
lrwxrwxrwx  1 root root   75 Aug 15 20:24 mkimage -> /home/crifan/develop/crosscompile/uboot/u-boot-2013.07/u-boot/tools/mkimage
crifan@ubuntu:u-boot$ qemu-system-arm -M versatilepb -nographic -kernel u-boot
oss: Could not initialize DAC
oss: Failed to open `/dev/dsp'
oss: Reason: No such file or directory
oss: Could not initialize DAC
oss: Failed to open `/dev/dsp'
oss: Reason: No such file or directory
audio: Failed to create voice `lm4549.out'


U-Boot 2013.07 (Aug 15 2013 - 20:08:41)

DRAM:  128 MiB
WARNING: Caches not enabled
Flash: 64 MiB
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   SMC91111-0
Warning: SMC91111-0 using MAC address from net device

VersatilePB # 

如图:

qemu test arm versatilepb ok

 

9.然后又去试了试基本的一些命令,输出如下:

VersatilePB # help
?       - alias for 'help'
base    - print or set address offset
bdinfo  - print Board Info structure
bootm   - boot application image from memory
bootp   - boot image via network using BOOTP/TFTP protocol
cmp     - memory compare
cp      - memory copy
crc32   - checksum calculation
dhcp    - boot image via network using DHCP/TFTP protocol
env     - environment handling commands
erase   - erase FLASH memory
flinfo  - print FLASH memory information
go      - start application at address 'addr'
help    - print command description/usage
iminfo  - print header information for application image
loop    - infinite loop on address range
md      - memory display
mm      - memory modify (auto-incrementing address)
mw      - memory write (fill)
nm      - memory modify (constant address)
ping    - send ICMP ECHO_REQUEST to network host
printenv- print environment variables
protect - enable or disable FLASH write protection
reset   - Perform RESET of the CPU
saveenv - save environment variables to persistent storage
setenv  - set environment variables
tftpboot- boot image via network using TFTP protocol
version - print monitor, compiler and linker version
VersatilePB # bdinfo
arch_number = 0x00000183
boot_params = 0x00000100
DRAM bank   = 0x00000000
-> start    = 0x00000000
-> size     = 0x08000000
eth0name    = SMC91111-0
ethaddr     = 52:54:00:12:34:56
current eth = SMC91111-0
ip_addr     = <NULL>
baudrate    = 38400 bps
TLB addr    = 0x07FF0000
relocaddr   = 0x07FD3000
reloc off   = 0x06FD3000
irq_sp      = 0x07FAEF48
sp start    = 0x07FAEF38
VersatilePB # iminfo

## Checking Image at 00007fc0 ...
Unknown image format!
VersatilePB # printenv
baudrate=38400
bootargs=root=/dev/nfs mem=128M ip=dhcp netdev=25,0,0xf1010000,0xf1010010,eth0
bootdelay=2
bootfile=/tftpboot/uImage
ethact=SMC91111-0
ethaddr=52:54:00:12:34:56
stderr=serial
stdin=serial
stdout=serial
verify=n

Environment size: 247/8188 bytes
VersatilePB # version

U-Boot 2013.07 (Aug 15 2013 - 20:08:41)
arm-xscale-linux-gnueabi-gcc (crosstool-NG 1.18.0) 4.6.0
GNU ld (crosstool-NG 1.18.0) 2.22
VersatilePB # flinfo

Bank # 1: CFI conformant flash (32 x 32)  Size: 64 MB in 256 Sectors
  Intel Extended command set, Manufacturer ID: 0x18, Device ID: 0x00
  Erase timeout: 16384 ms, write timeout: 3 ms
  Buffer write timeout: 3 ms, buffer size: 2048 bytes

  Sector Start Addresses:
  34000000        34040000        34080000        340C0000        34100000      
  34140000        34180000        341C0000        34200000        34240000      
  34280000        342C0000        34300000        34340000        34380000      
  343C0000        34400000        34440000        34480000        344C0000      
  34500000        34540000        34580000        345C0000        34600000      
  34640000        34680000        346C0000        34700000        34740000      
  34780000        347C0000        34800000        34840000        34880000      
  348C0000        34900000        34940000        34980000        349C0000      
  34A00000        34A40000        34A80000        34AC0000        34B00000      
  34B40000        34B80000        34BC0000        34C00000        34C40000      
  34C80000        34CC0000        34D00000        34D40000        34D80000      
  34DC0000        34E00000        34E40000        34E80000        34EC0000      
  34F00000        34F40000        34F80000        34FC0000        35000000      
  35040000        35080000        350C0000        35100000        35140000      
  35180000        351C0000        35200000        35240000        35280000      
  352C0000        35300000        35340000        35380000        353C0000      
  35400000        35440000        35480000        354C0000        35500000      
  35540000        35580000        355C0000        35600000        35640000      
  35680000        356C0000        35700000        35740000        35780000      
  357C0000        35800000        35840000        35880000        358C0000      
  35900000        35940000        35980000        359C0000        35A00000      
  35A40000        35A80000        35AC0000        35B00000        35B40000      
  35B80000        35BC0000        35C00000        35C40000        35C80000      
  35CC0000        35D00000        35D40000        35D80000        35DC0000      
  35E00000        35E40000        35E80000        35EC0000        35F00000      
  35F40000        35F80000        35FC0000        36000000        36040000      
  36080000        360C0000        36100000        36140000        36180000      
  361C0000        36200000        36240000        36280000        362C0000      
  36300000        36340000        36380000        363C0000        36400000      
  36440000        36480000        364C0000        36500000        36540000      
  36580000        365C0000        36600000        36640000        36680000      
  366C0000        36700000        36740000        36780000        367C0000      
  36800000        36840000        36880000        368C0000        36900000      
  36940000        36980000        369C0000        36A00000        36A40000      
  36A80000        36AC0000        36B00000        36B40000        36B80000      
  36BC0000        36C00000        36C40000        36C80000        36CC0000      
  36D00000        36D40000        36D80000        36DC0000        36E00000      
  36E40000        36E80000        36EC0000        36F00000        36F40000      
  36F80000        36FC0000        37000000        37040000        37080000      
  370C0000        37100000        37140000        37180000        371C0000      
  37200000        37240000        37280000        372C0000        37300000      
  37340000        37380000        373C0000        37400000        37440000      
  37480000        374C0000        37500000        37540000        37580000      
  375C0000        37600000        37640000        37680000        376C0000      
  37700000        37740000        37780000        377C0000        37800000      
  37840000        37880000        378C0000        37900000        37940000      
  37980000        379C0000        37A00000        37A40000        37A80000      
  37AC0000        37B00000        37B40000        37B80000        37BC0000      
  37C00000        37C40000        37C80000        37CC0000        37D00000      
  37D40000        37D80000        37DC0000        37E00000        37E40000      
  37E80000        37EC0000   RO   37F00000        37F40000        37F80000      
  37FC0000   RO 
VersatilePB # base
Base Address: 0x00000000
VersatilePB # dhcp
SMC91111: PHY auto-negotiate timed out
SMC91111: MAC 52:54:00:12:34:56
BOOTP broadcast 1

Abort
VersatilePB # <INTERRUPT>

10.此处,试试直接运行,我之前自己的pax的uboot试试结果:

crifan@ubuntu:u-boot-1.1.4-whgs$ ls
arm_config.mk  CREDITS   fs              lib_microblaze  MAKEALL               nios2_config.mk  tools
board          CVS       i386_config.mk  lib_mips        Makefile              nios_config.mk   u-boot
CHANGELOG      disk      include         lib_nios        Makefile.orig         post             u-boot.bin
common         doc       lib_arm         lib_nios2       microblaze_config.mk  ppc_config.mk    u-boot.map
config.mk      drivers   lib_generic     lib_ppc         mips_config.mk        README           u-boot.srec
COPYING        dtt       lib_i386        m68k_config.mk  mkconfig              rtc
cpu            examples  lib_m68k        MAINTAINERS     net                   System.map
crifan@ubuntu:u-boot-1.1.4-whgs$ qemu-system-arm -M versatilepb -nographic -kernel u-boot
oss: Could not initialize DAC
oss: Failed to open `/dev/dsp'
oss: Reason: No such file or directory
oss: Could not initialize DAC
oss: Failed to open `/dev/dsp'
oss: Reason: No such file or directory
audio: Failed to create voice `lm4549.out'
qemu: fatal: Trying to execute code outside RAM or ROM at 0x5c010000

R00=00000000 R01=00000000 R02=00000000 R03=00000000
R04=00000000 R05=00000000 R06=00000000 R07=00000000
R08=00000000 R09=00000000 R10=00000000 R11=00000000
R12=00000000 R13=00000000 R14=00000000 R15=5c010000
PSR=400001d3 -Z-- A svc32
s00=00000000 s01=00000000 d00=0000000000000000
s02=00000000 s03=00000000 d01=0000000000000000
s04=00000000 s05=00000000 d02=0000000000000000
s06=00000000 s07=00000000 d03=0000000000000000
s08=00000000 s09=00000000 d04=0000000000000000
s10=00000000 s11=00000000 d05=0000000000000000
s12=00000000 s13=00000000 d06=0000000000000000
s14=00000000 s15=00000000 d07=0000000000000000
s16=00000000 s17=00000000 d08=0000000000000000
s18=00000000 s19=00000000 d09=0000000000000000
s20=00000000 s21=00000000 d10=0000000000000000
s22=00000000 s23=00000000 d11=0000000000000000
s24=00000000 s25=00000000 d12=0000000000000000
s26=00000000 s27=00000000 d13=0000000000000000
s28=00000000 s29=00000000 d14=0000000000000000
s30=00000000 s31=00000000 d15=0000000000000000
FPSCR: 00000000
Aborted (core dumped)
crifan@ubuntu:u-boot-1.1.4-whgs$ 

很明显,是无法运行的,直接挂掉。

 

【总结】

此处,只能运行,QEMU自己的versatilepb,无法运行自己的uboot。

转载请注明:在路上 » 【记录】Ubuntu下测试QEMU中加载和测试Uboot

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
83 queries in 0.173 seconds, using 22.44MB memory