Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4470251
  • 博文数量: 1148
  • 博客积分: 25453
  • 博客等级: 上将
  • 技术积分: 11949
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-06 21:14
文章分类

全部博文(1148)

文章存档

2012年(15)

2011年(1078)

2010年(58)

分类: 嵌入式

2011-04-13 13:48:22

参考资料:天嵌科技出品--Qt程序开发完全手册之24小时超级版本_V2.2_20100606.pdf
           qt-4.5 移植篇章

说明:移植qt4.5时,使用的环境配置
      开发板:TQ2440 256MB nandflash 64MB sdram  东华3.5寸屏
      uboot:TQ_W35 东华2009 年的uboot
      内核:2440+2.6.33 UDA声卡移植(九) 移植后,继续的内核
      文件系统:使用自己保存的 root-2.6.33-final.tar.bz2 
最原始的文件系统镜像root-2.6.33-final.bin 9.4MB

1.QT4.5的环境建立


   3.这里简单介绍建立好  qt 开发环境后使用的方法:
比如说编译tq提供的 hello_cn 这个应用程序 ,这里加上 三个源码附件hello_cn.rar hello_cn.rar  
  1. 我删除了tq提供的/hello_cn/目录下其他的文件,只留下了下面三个文件
  2. ywx@yuweixian:~/yu/qt/hello_cn$ ls
  3. hello_cn.cpp hello_cn.h main.cpp
  4. ywx@yuweixian:~/yu/qt/hello_cn$

将 qmake 文件指向 arm 架构
ywx@yuweixian:~/yu/qt/hello_cn$ source /usr/local/Trolltech/QtEmbedded-4.5.3-arm/setenv.sh
ywx@yuweixian:~/yu/qt/hello_cn$

编译 源文件
ywx@yuweixian:~/yu/qt/hello_cn$ qmake -project   编译生成 工程文件
ywx@yuweixian:~/yu/qt/hello_cn$ qmake            编译生成 Makefile
ywx@yuweixian:~/yu/qt/hello_cn$ make             编译文件 Makefile

参看生成文件,其中hello_cn 就是我们需要的 二进制应用程序文件

ywx@yuweixian:~/yu/qt/hello_cn$ ls
hello_cn      hello_cn.h  hello_cn.pro  main.o    moc_hello_cn.cpp
hello_cn.cpp  hello_cn.o  main.cpp      Makefile  moc_hello_cn.o
ywx@yuweixian:~/yu/qt/hello_cn$

当让,我们也可以使用 qt creator  实现上面一样的功能,具体参考 qt-4.5 篇章中的qt creator 使用部分


2.qt4.5 文件系统的制作
 
   1.在文件系统 opt/新建目录 qt-4.5 目录
   2.复制 4.5.3-arm/lib 目录到 文件系统  qt-4.5/下,删除掉出“fonts”和*.so* 文件外其他的文件
  1. ywx@yuweixian:/usr/local/Trolltech/QtEmbedded-4.5.3-arm$ ls
  2. bin examples lib plugins setenv.sh
  3. demos include mkspecs qtc-debugging-helper
  4. ywx@yuweixian:/usr/local/Trolltech/QtEmbedded-4.5.3-arm$
  3.在这里我只移植了hello_cn 这个应用程序,所以在第 2 步骤中,我还删除了其他.so 文件。
     3.1 使用 arm-linux-readelf -d hello_cn 查看动态链接库
         所以我只复制了 下面三个 qt 库
  1. ywx@yuweixian:~/yu/qt/hello_cn$ arm-linux-readelf -d hello_cn

  2. Dynamic section at offset 0x2b0c contains 34 entries:
  3.   Tag Type Name/Value
  4.  0x00000001 (NEEDED) Shared library: [libQtGui.so.4]
  5.  0x00000001 (NEEDED) Shared library: [libQtNetwork.so.4]
  6.  0x00000001 (NEEDED) Shared library: [libQtCore.so.4]   ###这三个是 qt库,
  7.  0x00000001 (NEEDED) Shared library: [librt.so.1]       ### 下面的都是 busybox 中生成库
  8.  0x00000001 (NEEDED) Shared library: [libdl.so.2]
  9.  0x00000001 (NEEDED) Shared library: [libpthread.so.0]
  10.  0x00000001 (NEEDED) Shared library: [libstdc++.so.6]
  11.  0x00000001 (NEEDED) Shared library: [libm.so.6]
  12.  0x00000001 (NEEDED) Shared library: [libgcc_s.so.1]
  13.  0x00000001 (NEEDED) Shared library: [libc.so.6]
  14.  0x0000000f (RPATH) Library rpath: [/usr/local/Trolltech/QtEmbedded-4.5.0-arm/lib]
  15.  0x0000000c (INIT) 0x9d50
  16.  0x0000000d (FINI) 0xa80c
  17.  0x00000019 (INIT_ARRAY) 0x12b00
  18.  0x0000001b (INIT_ARRAYSZ) 4 (bytes)
  19.  0x0000001a (FINI_ARRAY) 0x12b04
  20.  0x0000001c (FINI_ARRAYSZ) 4 (bytes)
  21.  0x00000004 (HASH) 0x8168
  22.  0x00000005 (STRTAB) 0x8c50
  23.  0x00000006 (SYMTAB) 0x85f0
  24.  0x0000000a (STRSZ) 3315 (bytes)
  25.  0x0000000b (SYMENT) 16 (bytes)
  26.  0x00000015 (DEBUG) 0x0
  27.  0x00000003 (PLTGOT) 0x12c44
  28.  0x00000002 (PLTRELSZ) 672 (bytes)
  29.  0x00000014 (PLTREL) REL
  30.  0x00000017 (JMPREL) 0x9ab0
  31.  0x00000011 (REL) 0x9a80
  32.  0x00000012 (RELSZ) 48 (bytes)
  33.  0x00000013 (RELENT) 8 (bytes)
  34.  0x6ffffffe (VERNEED) 0x9a10
  35.  0x6fffffff (VERNEEDNUM) 3
  36.  0x6ffffff0 (VERSYM) 0x9944
  37.  0x00000000 (NULL) 0x0
  38. ywx@yuweixian:~/yu/qt/hello_cn$
   
     3.2 复制上面提到的 qt 动态链接库  到文件系统 qt-4.5/lib/下
  1. fonts libQtGui.so libQtNetwork.so.4
  2. libQtCore.so libQtGui.so.4 libQtNetwork.so.4.5
  3. libQtCore.so.4 libQtGui.so.4.5 libQtNetwork.so.4.5.3
  4. libQtCore.so.4.5 libQtGui.so.4.5.3
  5. libQtCore.so.4.5.3 libQtNetwork.so


4.复制 -arm/plugins/imageformates 文件到 文件系统/opt/qt-4.5/plugins/
  1. ywx@yuweixian:/usr/local/Trolltech/QtEmbedded-4.5.3-arm/plugins$ ls
  2. accessible iconengines imageformats sqldrivers
  3. ywx@yuweixian:/usr/local/Trolltech/QtEmbedded-4.5.3-arm/plugins$


5.建立 opt/qt-4.5/bin 目录
  在bin 目录中加入我们上面制作的二进制应用程序 hell0_cn

6.修改文件系统的/etc/profiel 文件, 为了单独运行QT程序
  1. # Ash profile
  2. # vim: syntax=sh

  3. # No core files by default
  4. #ulimit -S -c 0 > /dev/null 2>&1

  5. ###################################### qt 添加开始
  6. export set HOME=/root
  7. export set QTDIR=/opt/qt-4.5
  8. export set QPEDIR=/opt/qt-4.5
  9. export set QWS_DISPLAY="LinuxFB:/dev/fb0"
  10. export set QWS_DISPLAY="LinuxFB:mmWidth130:mmHeight100:0"   注意这里没有空格 哟
  11. export set QWS_KEYBOARD="TTY:/dev/tty1"

  12. export set QT_PLUGIN_PATH=$QTDIR/plugins/
  13. export set QT_QWS_FONTDIR=$QTDIR/lib/fonts
  14. export set PATH=$QPEDIR/bin:$PATH
  15. export set LD_LIBRARY_PATH=$QTDIR/lib:$QPEDIR/plugins/imageformats:$LD_LIBRARY_PATH

  16. ####################################### qt 添加结束


  17. USER="`id -un`"
  18. LOGNAME=$USER
  19. PS1='[\u@\h \W]# '
  20. PATH=$PATH

  21. HOSTNAME=`/bin/hostname`

  22. export USER LOGNAME PS1 PATH

7.在/bin/建立 qt4 执行文件
  1. #!/bin/sh

  2. echo Start qt-4.5 > /dev/ywx_serial0

  3. export set HOME=/root
  4. export set QTDIR=/opt/qt-4.5
  5. export set QPEDIR=/opt/qt-4.5
  6. export set QWS_DISPLAY="LinuxFB:/dev/fb0"
  7. export set QWS_DISPLAY="LinuxFB:mmWidth130:mmHeight100:0"
  8. export set QWS_KEYBOARD="TTY:/dev/tty1"

  9. export set QT_PLUGIN_PATH=$QTDIR/plugins/
  10. export set QT_QWS_FONTDIR=$QTDIR/lib/fonts
  11. export set PATH=$QPEDIR/bin:$PATH
  12. export set LD_LIBRARY_PATH=$QTDIR/lib:$QPEDIR/plugins/imageformats:$LD_LIBRARY_PATH

  13. $QPEDIR/bin/hello_cn -qws 1>/dev/null 2>/dev/null

8.加入自动启动项  gedit /etc/init.d/rcS
  1. ifconfig lo 127.0.0.1
  2. net_set&

  3. qt4 &   加入 qt4 自动启动

  4. /bin/hostname -F /etc/sysconfig/HOSTNAME

9.好了,这样就可以了

  mkyaffs2image root-2.6.33-final root-2.6.33-fianl.bin
  .bin 文件有 30 MB
注意:生成的bin 文件太大,会出错 ,下都下不进开发板,自己遇到了这个问题


10.启动,详细信息

  1. ##### EmbedSky BIOS for SKY2440/TQ2440 #####
  2. Press Space key to Download Mode !
  3. Booting Linux ...
  4. Copy linux kernel from 0x00200000 to 0x30008000, size = 0x00200000 ... Copy Kernel to SDRAM done,NOW, Booting Linux......
  5. Uncompressing Linux... done, booting the kernel.
  6. Linux version 2.6.33-yuweixian (root@yuweixian) (gcc version 4.5.1 (Sourcery G++ Lite 2010.09-50) ) #18 Mon Apr 11 10:50:44 CST 2011
  7. CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
  8. CPU: VIVT data cache, VIVT instruction cache
  9. Machine: SMDK2440
  10. ATAG_INITRD is deprecated; please update your bootloader.
  11. Memory policy: ECC disabled, Data cache writeback
  12. CPU S3C2440A (id 0x32440001)
  13. S3C24XX Clocks, Copyright 2004 Simtec Electronics
  14. S3C244X: core 400.000 MHz, memory 100.000 MHz, peripheral 50.000 MHz
  15. CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
  16. Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
  17. Kernel command line: noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0
  18. PID hash table entries: 256 (order: -2, 1024 bytes)
  19. Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
  20. Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
  21. Memory: 64MB = 64MB total
  22. Memory: 60864KB available (3372K code, 312K data, 196K init, 0K highmem)
  23. Hierarchical RCU implementation.
  24. NR_IRQS:85
  25. irq: clearing pending ext status 00080000
  26. irq: clearing subpending status 00000002
  27. Console: colour dummy device 80x30
  28. console [ttySAC0] enabled
  29. Calibrating delay loop... 199.47 BogoMIPS (lpj=498688)
  30. Mount-cache hash table entries: 512
  31. CPU: Testing write buffer coherency: ok
  32. NET: Registered protocol family 16
  33. S3C Power Management, Copyright 2004 Simtec Electronics
  34. S3C2440: Initialising architecture
  35. S3C2440: IRQ Support
  36. S3C24XX DMA Driver, Copyright 2003-2006 Simtec Electronics
  37. DMA channel 0 at c4808000, irq 33
  38. DMA channel 1 at c4808040, irq 34
  39. DMA channel 2 at c4808080, irq 35
  40. DMA channel 3 at c48080c0, irq 36
  41. S3C244X: Clock Support, DVS off
  42. bio: create slab <bio-0> at 0
  43. SCSI subsystem initialized
  44. usbcore: registered new interface driver usbfs
  45. usbcore: registered new interface driver hub
  46. usbcore: registered new device driver usb
  47. s3c-i2c s3c2440-i2c: slave address 0x10
  48. s3c-i2c s3c2440-i2c: bus frequency set to 97 KHz
  49. s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
  50. Advanced Linux Sound Architecture Driver Version 1.0.21.
  51. NET: Registered protocol family 2
  52. IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
  53. TCP established hash table entries: 2048 (order: 2, 16384 bytes)
  54. TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
  55. TCP: Hash tables configured (established 2048 bind 2048)
  56. TCP reno registered
  57. UDP hash table entries: 256 (order: 0, 4096 bytes)
  58. UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
  59. NET: Registered protocol family 1
  60. RPC: Registered udp transport module.
  61. RPC: Registered tcp transport module.
  62. RPC: Registered tcp NFSv4.1 backchannel transport module.
  63. NetWinder Floating Point Emulator V0.97 (extended precision)
  64. ROMFS MTD (C) 2007 Red Hat, Inc.
  65. yaffs Apr 5 2011 12:09:55 Installing.
  66. msgmni has been set to 119
  67. io scheduler noop registered
  68. io scheduler deadline registered
  69. io scheduler cfq registered (default)
  70. Console: switching to colour frame buffer device 40x30
  71. fb0: s3c2410fb frame buffer device
  72. lp: driver loaded but no devices found
  73. ppdev: user-space parallel port driver
  74. Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
  75. s3c2440-uart.0: ywx-serial0 at MMIO 0x50000000 (irq = 70) is a S3C2440
  76. s3c2440-uart.1: ywx-serial1 at MMIO 0x50004000 (irq = 73) is a S3C2440
  77. s3c2440-uart.2: ywx-serial2 at MMIO 0x50008000 (irq = 76) is a S3C2440
  78. brd: module loaded
  79. loop: module loaded
  80. Uniform Multi-Platform E-IDE driver
  81. ide-gd driver 1.18
  82. ide-cd driver 5.00
  83. st: Version 20081215, fixed bufsize 32768, s/g segs 256
  84. S3C24XX NAND Driver, (c) 2004 Simtec Electronics
  85. s3c24xx-nand s3c2440-nand: Tacls=2, 20ns Twrph0=6 60ns, Twrph1=2 20ns
  86. s3c24xx-nand s3c2440-nand: NAND hardware ECC
  87. NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
  88. Scanning device for bad blocks
  89. Creating 3 MTD partitions on "NAND 256MiB 3,3V 8-bit":
  90. 0x000000000000-0x000000040000 : "ywx-boot"
  91. 0x000000200000-0x000000400000 : "ywx-kernel"
  92. 0x000000400000-0x00000ff80000 : "ywx-yaffs2"
  93. dm9000 Ethernet Driver, V1.31
  94. Now use the default MAC address: 10:23:45:67:89:ab
  95. eth0: dm9000e at c481c000,c4820004 IRQ 51 MAC: 10:23:45:67:89:ab (yuweixian-MAC)
  96. usbmon: debugfs is not available
  97. ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
  98. s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
  99. s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
  100. s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
  101. hub 1-0:1.0: USB hub found
  102. hub 1-0:1.0: 2 ports detected
  103. Initializing USB Mass Storage driver...
  104. usbcore: registered new interface driver usb-storage
  105. USB Mass Storage support registered.
  106. usbcore: registered new interface driver libusual
  107. usbcore: registered new interface driver usbserial
  108. USB Serial support registered for generic
  109. usbcore: registered new interface driver usbserial_generic
  110. usbserial: USB Serial Driver core
  111. USB Serial support registered for FTDI USB Serial Device
  112. usbcore: registered new interface driver ftdi_sio
  113. ftdi_sio: v1.5.0:USB FTDI Serial Converters Driver
  114. USB Serial support registered for pl2303
  115. usbcore: registered new interface driver pl2303
  116. pl2303: Prolific PL2303 USB to serial adaptor driver
  117. mice: PS/2 mouse device common for all mice
  118. TQ2440 TouchScreen successfully loaded
  119. input: TQ2440 TouchScreen as /class/input/input0
  120. S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
  121. s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
  122. s3c-sdi s3c2440-sdi: host detect has no irq available
  123. s3c-sdi s3c2440-sdi: failed to get writeprotect
  124. s3c-sdi: probe of s3c2440-sdi failed with error -16
  125. No device for DAI UDA134X
  126. No device for DAI s3c24xx-i2s
  127. S3C24XX_UDA134X SoC Audio driver
  128. UDA134X SoC Audio Codec
  129. asoc: UDA134X <-> s3c24xx-i2s mapping ok
  130. ALSA device list:
  131.   #0: S3C24XX_UDA134X (UDA134X)
  132. TCP cubic registered
  133. NET: Registered protocol family 17
  134. end_request: I/O error, dev mtdblock2, sector 256
  135. isofs_fill_super: bread failed, dev=mtdblock2, iso_blknum=64, block=128
  136. yaffs: dev is 32505858 name is "mtdblock2"
  137. yaffs: passed flags ""
  138. yaffs: Attempting MTD mount on 31.2, "mtdblock2"
  139. yaffs: auto selecting yaffs2
  140. yaffs_read_super: isCheckpointed 0
  141. VFS: Mounted root (yaffs filesystem) on device 31:2.
  142. Freeing init memory: 196K
  143. Try to bring eth0 interface up ...

  144. Please press Enter to activate this console. ifconfig eth0 hw ether 10:23:45:67:89:ab
  145. eth0: link down
  146. ifconfig eth0 192.168.1.6 netmask 255.255.255.0 up
  147. add default gw 192.168.1.2
  148. Done

  149. [root@yuweixian /]#
























阅读(2653) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~