版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、使用qemu 建立mini2440的模拟仿真环境1. 首先下载qemu for mini2440git clone git:/repo.or.cz/qemu/mini2440.git qemu如果感觉速度慢,直接打包下载解压后,今日源代码的主目录中,12# ./configure -target-list=arm-softmmu# make -j42. 下载u-boot for mini2440git clone git:/repo.or.cz/w/u-boot-openmoko/mini2440.git uboot或者打包
2、下载(注意 采用打包下载的时候这几个包的文件名可能相同,注意区分)解压后,配置Makefile文件,打开Makefile文件,CROSS_COMPILE变量赋值,即自己所使用的交叉编译工具链,比如我的是arm-none-linux-gnueabi-,保存退出,输入12# make mini2440_config# make -j4稍等两分钟,即在当前目录下生成名为 u-boot.bin 的文件,注意如果想在之后使用u-boot 的nfs下载文件功能,需要修改代码中的一部分,将net/nfs.c文件中的NFS_TIMEOUT = 2UL 修改为 NFS_TIMEOUT =
3、 20000UL 否则会造成nfs文件下载失败,如果不使用nfs下载功能,不改也可。然后将u-boot.bin文件拷贝到qemu-mini2440/mini2440文件夹下。3. 下载 linux kernel for mini2440(可以使用原mini2440开发板的内核源代码)(下载步骤略去)进入源码目录12# make mini2440_defconfig ARCH=arm#make uImage之后会在arch/arm/boot/目录下生成uImage 文件,将此文件复制到qemu目录下的mini2440文件夹下,并将mini2440文件夹中的mini2440_start.
4、sh作如下修改将 kernel 一行改为-kernel "$base/uImage" ,回到上层目录后运行1# sh mini2440/mini2440_start.sh错误解决:一、1.如果在编译QEMU时没有安装,即 make install,那么需要打开mini2440/mini2440_start.sh,将第16行的 qemu-img改为:$base/./qemu-img2.如果编译时安装了QEMU,即有make install,不管这一步骤。二、期待的画面并没有出来,取而代之的是:/etc/qemu-ifup:could not launch netw
5、ork scriptCould not initialize device 'tap'该错误一般是运行权限错误,使用根用户运行。三、使用根用户运行,依旧是:/etc/qemu-ifup:could not launch network script 。对qemu中的net.c在代码进行修改:static int launch_script(const char *setup_script, const char *ifname, int fd) int pid, status; char *args4; /* bacon modified */ char *parg; /* t
6、ry to launch network script */ pid = fork(); if (pid >= 0) if (pid = 0) char path20;/* bacon add */ int open_max = sysconf (_SC_OPEN_MAX), i; for (i = 0; i < open_max; i+) if (i != STDIN_FILENO && i != STDOUT_FILENO && i != STDERR_FILENO && i != fd) close(i); parg = arg
7、s; strcpy(path, "/bin/bash");/*bacon add*/ *parg+ = (char *)path; /*bacon add*/ *parg+ = (char *)setup_script; *parg+ = (char *)ifname; *parg+ = NULL; status = execv(path, args);/*bacon add*/ fprintf(stderr, "error:%d %d %d %s %s/n", status, errno, ENOEXEC, setup_script, ifname);
8、/*bacon add fordebug.*/ _exit(1); while (waitpid(pid, &status, 0) != pid); if (!WIFEXITED(status) | WEXITSTATUS(status) != 0) fprintf(stderr, "%s: could not launch network script/n", setup_script); return -1; return 0;这时应该看到qemu启动后进入了u-boot界面下,输入命令。1# bootm就会看到linux内核启动的画面,
9、但此时还没有根文件系统,我们稍候介绍采用nfs挂在根文件系统。4. 开启NFS服务,假设你用的操作系统为ubuntu,首先安装 nfs服务器1# sudo apt-get install nfs-kernel-server之后修改/etc/exports文件,添加如下一行/home/wuxia *(rw,sync,no_root_squash).注意 /home/wuxia 为你所要共享的目录。输入命令1# sudo /etc/init.d/nfs-kernel-server restart 启动 nfs服务测试 nfs服务是否成功启动12#
10、160; sudo mkdir /mnt/nfs# sudo mount -t nfs localhost:/home/username/nfs /mnt/nfs查看/mnt/nfs文件是否于/home/username/nfs 中相同,若一样 ,OK5. 将mini2440目录下的mini2440_start.sh修改为1234567#!/bin/shsudo ./arm-softmmu/qemu-system-arm -M mini2440 -kernel mini2440/uImage -serial stdio -net ni
11、c,vlan=0 -net tap,vlan=0,ifname=tap0,script=./qemu-ifup,downscript=./qemu-ifdown -show-cursor -usb -usbdevice keyboard -usbdevice mouse在建立两个脚本,分别为qemu-ifup, qemu-ifdownqemu-ifup 脚本123#!/bin/shecho "Excuting qemu-ifup"ifconfig $1 .1qemu-ifdown脚本123#!/bin/shecho "Close tap!"sudo if
12、config $1 .1 down6. 当这些都配置好后,我们即可使用nfs根文件系统了这里我们的根文件系统为 /home/wuxia/mini2440/image/rootfs在qemu的目录中输入1# ./mini2440/mini2440_start.shu-boot启动成功后输入设置linux kernel的引导参数set bootargs noinitrd root=/dev/nfs rw nfsroot=:/home/wuxia/mini2440/image/rootfs ip=:1:255.255.255.0 console=ttySAC0,115200再输入命令bootmOK
13、! kernel就开始加载了,文件系统挂在成功后,就可以进行各种仿真工作了。友善之臂提供的qtopia文件系统在挂载时会初始化网卡,但我们是由nfs挂载的文件系统,这会导致nfs连接中断,挂载失败,所以用nfs挂载之前需要把网卡的初始化过程取消,对应的文件是/etc/init.d/if-config,只需把该文件内容清空即可。redboot on QEMU for mini2440分类: eCos on mini2440 qemu2011-03-01 16:13 603人阅读 评论(0) 收藏 举报(原创文章,欢迎转载,请注明出处,谢谢。)最近
14、有空呼吸新鲜空气,重新拿起来了eCos,做点东西共享给大家。 rt-thread最近很火,在mini2440的qemu平台上发表了测试和代码,这无疑给更多的爱好者以新的学习机会。 这段时间一直在研究ecos,所以有了把ecos移植到mini2440的qemu平台的想法。经过几天的折腾,终于可以在qemu的上面看到redboot的命令了。 先看看成果,然后进入枯燥的coding历程 现在开始看代码,:-) 1. 获得代码 git clone git:/repo.or.cz/qemu/mini2440.git qe
15、mu 修改启动部分为ram的最小地址直接启动 cpp view plaincopy1. rickyricky-laptop:/ecos/projects/mini2440-qemu/mini2440$ git diff 2. diff -git a/hw/mini2440.c b/hw/mini2440.c 3. index 5decf4b.7a70aae 100644 4. - a/hw/mini2440.c
16、; 5. + b/hw/mini2440.c 6. -258,46 +258,15 static void mini2440_reset(void *opaque) 7. struct mini2440_board_s *s = (struct mini2440_board_s *) opaque; 8. &
17、#160; uint32_t image_size; 9. 10. - /* 11. - * Normally we would load 4 KB of nand to SRAM and&
18、#160;jump there, but 12. - * it is not working perfectly as expected, so we cheat and load 13. - * it from nand
19、 directly relocated to 0x33f80000 and jump there 14. - */ 15. - if (mini2440_load_from_nand(s->nand, 0, S3C_RAM_BASE | 0x03f80000,
20、60;256*1 16. - mini2440_printf("loaded default u-boot from NAND/n"); 17. - &
21、#160;s->cpu->env->regs15 = S3C_RAM_BASE | 0x03f80000; /* start addr 18. - 19. -#if 0 && defined(LATER) 20. - if (mini2440_load_fro
22、m_nand(s->nand, 0, S3C_SRAM_BASE_NANDBOOT, S3C_SRAM 21. - s->cpu->env->regs15 = S3C_SRAM_BASE_NANDBOOT; /* start address 22. -
23、; mini2440_printf("4KB SteppingStone loaded from NAND/n"); 23. - 24. -#endif 25. : 26. diff -git a/hw/mini2440.c b/hw/mini2440.c 27. index 5de
24、cf4b.7a70aae 100644 28. - a/hw/mini2440.c 29. + b/hw/mini2440.c 30. -258,46 +258,15 static void mini2440_reset(void *opaque) 31. struct mini2440_board_s *s = (struct mini244
25、0_board_s *) opaque; 32. uint32_t image_size; 33. 34. - /* 35. - * Normally we would load 4 KB of na
26、nd to SRAM and jump there, but 36. - * it is not working perfectly as expected, so we cheat and load 37. -
27、;* it from nand directly relocated to 0x33f80000 and jump there 38. - */ 39. - if (mini2440_load_from_nand(s->nand, 0, S3C_RAM_B
28、ASE | 0x03f80000, 256*10 40. - mini2440_printf("loaded default u-boot from NAND/n"); 41. -
29、 s->cpu->env->regs15 = S3C_RAM_BASE | 0x03f80000; /* start addre 42. - 43. -#if 0 && defined(LATER) 44. -
30、 if (mini2440_load_from_nand(s->nand, 0, S3C_SRAM_BASE_NANDBOOT, S3C_SRAM_ 45. - s->cpu->env->regs15 = S3C_SRAM_BASE_NANDBOOT; /* start address,
31、 46. - mini2440_printf("4KB SteppingStone loaded from NAND/n"); 47. - 48. -#endif 49. - /* 50. :&
32、#160;51. diff -git a/hw/mini2440.c b/hw/mini2440.c 52. index 5decf4b.7a70aae 100644 53. - a/hw/mini2440.c 54. + b/hw/mini2440.c 55. -258,46 +258,15 static void mini2440_reset(void *opaque) 56.
33、0; struct mini2440_board_s *s = (struct mini2440_board_s *) opaque; 57. uint32_t image_size; 58. 59. - /* 60. -
34、0; * Normally we would load 4 KB of nand to SRAM and jump there, but 61. - * it is not working perfectly as expected, so w
35、e cheat and load 62. - * it from nand directly relocated to 0x33f80000 and jump there 63. - */ 64. -
36、160; if (mini2440_load_from_nand(s->nand, 0, S3C_RAM_BASE | 0x03f80000, 256*102 65. - mini2440_printf("loaded default u-boot from&
37、#160;NAND/n"); 66. - s->cpu->env->regs15 = S3C_RAM_BASE | 0x03f80000; /* start addres 67. - 68. -#i
38、f 0 && defined(LATER) 69. - if (mini2440_load_from_nand(s->nand, 0, S3C_SRAM_BASE_NANDBOOT, S3C_SRAM_S 70. - s->cpu->env->regs15&
39、#160;= S3C_SRAM_BASE_NANDBOOT; /* start address, 71. - mini2440_printf("4KB SteppingStone loaded from NAND/n"); 72. -
40、0; 73. -#endif 74. - /* 75. - * if a u-boot is available as a file, we always use it 76. : 77. diff -git
41、a/hw/mini2440.c b/hw/mini2440.c 78. index 5decf4b.7a70aae 100644 79. - a/hw/mini2440.c 80. + b/hw/mini2440.c 81. -258,46 +258,15 static void mini2440_reset(void *opaque) 82. struct
42、60;mini2440_board_s *s = (struct mini2440_board_s *) opaque; 83. uint32_t image_size; 84. 85. - /* 86. - * Normally
43、 we would load 4 KB of nand to SRAM and jump there, but 87. - * it is not working perfectly as expected, so we cheat and lo
44、ad 88. - * it from nand directly relocated to 0x33f80000 and jump there 89. - */ 90. - if
45、;(mini2440_load_from_nand(s->nand, 0, S3C_RAM_BASE | 0x03f80000, 256*1024)> 91. - mini2440_printf("loaded default u-boot from NAND/n");
46、0; 92. - s->cpu->env->regs15 = S3C_RAM_BASE | 0x03f80000; /* start address, 93. - 94. -#if 0 &
47、amp;& defined(LATER) 95. - if (mini2440_load_from_nand(s->nand, 0, S3C_SRAM_BASE_NANDBOOT, S3C_SRAM_SIZE 96. - s->cpu->env->regs15 =
48、S3C_SRAM_BASE_NANDBOOT; /* start address, u-b 97. - mini2440_printf("4KB SteppingStone loaded from NAND/n"); 98. - &
49、#160; 99. -#endif 100. - /* 101. - * if a u-boot is available as a file, we always use it 102. -
50、 */ 103. - 104. - image_size = load_image("mini2440/u-boot.bin", qemu_get_ram_ptr(0x03f8000 105. : 106. diff
51、;-git a/hw/mini2440.c b/hw/mini2440.c 107. index 5decf4b.7a70aae 100644 108. - a/hw/mini2440.c 109. + b/hw/mini2440.c 110. -258,46 +258,15 static void mini2440_reset(void *opaque)
52、0;111. struct mini2440_board_s *s = (struct mini2440_board_s *) opaque; 112. uint32_t image_size; 113. 114. - /* 1
53、15. - * Normally we would load 4 KB of nand to SRAM and jump there, but 116. - * it is not working perfect
54、ly as expected, so we cheat and load 117. - * it from nand directly relocated to 0x33f80000 and jump there 118. -
55、60;*/ 119. - if (mini2440_load_from_nand(s->nand, 0, S3C_RAM_BASE | 0x03f80000, 256*1024)> 0) 120. - mini24
56、40_printf("loaded default u-boot from NAND/n"); 121. - s->cpu->env->regs15 = S3C_RAM_BASE | 0x03f80000; /* start address,
57、;u-b 122. - 123. -#if 0 && defined(LATER) 124. - if (mini2440_load_from_nand(s->nand, 0, S3C_SRAM_BASE_NANDBOOT, S3C_SRAM_SIZE) > 125. - &
58、#160; s->cpu->env->regs15 = S3C_SRAM_BASE_NANDBOOT; /* start address, u-boot 126. - mini2440_printf("4KB
59、;SteppingStone loaded from NAND/n"); 127. - 128. -#endif 129. - /* 130. - * if a u-boot is available
60、;as a file, we always use it 131. - */ 132. - 133. - image_size = load_image(&q
61、uot;mini2440/u-boot.bin", qemu_get_ram_ptr(0x03f80000) 134. - if (image_size < 0) 135. - &
62、#160; image_size = load_image("u-boot.bin", qemu_get_ram_ptr(0x03f80000); 136. - if (image_size > 0) 137. : 138. diff&
63、#160;-git a/hw/mini2440.c b/hw/mini2440.c 139. index 5decf4b.7a70aae 100644 140. - a/hw/mini2440.c 141. + b/hw/mini2440.c 142. -258,46 +258,15 static void mini2440_reset(void *opaque)
64、 143. struct mini2440_board_s *s = (struct mini2440_board_s *) opaque; 144. uint32_t image_size; 145. 146. - /*
65、60;147. - * Normally we would load 4 KB of nand to SRAM and jump there, but 148. - * it is not working per
66、fectly as expected, so we cheat and load 149. - * it from nand directly relocated to 0x33f80000 and jump there 150. -
67、; */ 151. - if (mini2440_load_from_nand(s->nand, 0, S3C_RAM_BASE | 0x03f80000, 256*1024)> 0) 152. -
68、160;mini2440_printf("loaded default u-boot from NAND/n"); 153. - s->cpu->env->regs15 = S3C_RAM_BASE | 0x03f80000; /* start add
69、ress, u-boot 154. - 155. -#if 0 && defined(LATER) 156. - if (mini2440_load_from_nand(s->nand, 0, S3C_SRAM_BASE_NANDBOOT, S3C_SRAM_SIZE) >
70、 0) 157. - s->cpu->env->regs15 = S3C_SRAM_BASE_NANDBOOT; /* start address, u-boot rel 158. -
71、 mini2440_printf("4KB SteppingStone loaded from NAND/n"); 159. - 160. -#endif 161. - /* 162. - * if
72、;a u-boot is available as a file, we always use it 163. - */ 164. - 165. -
73、 image_size = load_image("mini2440/u-boot.bin", qemu_get_ram_ptr(0x03f80000); 166. - if (image_size < 0) 167. -
74、 image_size = load_image("u-boot.bin", qemu_get_ram_ptr(0x03f80000); 168. - if (image_size > 0)
75、60; 169. - if (image_size & (512 -1) /* round size to a NAND bl
76、ock size * 170. - image_size = (image_size + 512) & (512-1);
77、171. - mini2440_printf("loaded override u-boot (size %x)/n", image_size); 172. : 173. diff -git a/hw/mini244
78、0.c b/hw/mini2440.c 174. index 5decf4b.7a70aae 100644 175. - a/hw/mini2440.c 176. + b/hw/mini2440.c 177. -258,46 +258,15 static void mini2440_reset(void *opaque) 178. struct mini
79、2440_board_s *s = (struct mini2440_board_s *) opaque; 179. uint32_t image_size; 180. 181. - /* 182. - * Normally
80、60;we would load 4 KB of nand to SRAM and jump there, but 183. - * it is not working perfectly as expected, so we cheat and load
81、 184. - * it from nand directly relocated to 0x33f80000 and jump there 185. - */ 186. - if
82、0;(mini2440_load_from_nand(s->nand, 0, S3C_RAM_BASE | 0x03f80000, 256*1024)> 0) 187. - mini2440_printf("loaded default u-boot from NA
83、ND/n"); 188. - s->cpu->env->regs15 = S3C_RAM_BASE | 0x03f80000; /* start address, u-boot alrea 189. -
84、; 190. -#if 0 && defined(LATER) 191. - if (mini2440_load_from_nand(s->nand, 0, S3C_SRAM_BASE_NANDBOOT, S3C_SRAM_SIZE) > 0) 192. -
85、160; s->cpu->env->regs15 = S3C_SRAM_BASE_NANDBOOT; /* start address, u-boot relocati 193. - mini2440_printf("4KB SteppingStone loa
86、ded from NAND/n"); 194. - 195. -#endif 196. - /* 197. - * if a u-boot is available as a file,
87、160;we always use it 198. - */ 199. - 200. - image_size = load_image("mini2440/u-boot.bin
88、", qemu_get_ram_ptr(0x03f80000); 201. - if (image_size < 0) 202. - image
89、_size = load_image("u-boot.bin", qemu_get_ram_ptr(0x03f80000); 203. - if (image_size > 0) 204. -
90、160; if (image_size & (512 -1) /* round size to a NAND block size */ 205. -
91、160; image_size = (image_size + 512) & (512-1); 206. -
92、0; mini2440_printf("loaded override u-boot (size %x)/n", image_size); 207. -
93、; s->cpu->env->regs15 = S3C_RAM_BASE | 0x03f80000; /* start address, u-boot 208. - 209. -
94、60; 210. : 211. diff -git a/hw/mini2440.c b/hw/mini2440.c 212. index 5decf4b.7a70aae 100644 213. - a/hw/mini2440.c 214. + b/hw/mini2440.c 215. -258,46 +258,15 static void mini2440_reset(void&
95、#160;*opaque) 216. struct mini2440_board_s *s = (struct mini2440_board_s *) opaque; 217. uint32_t image_size; 218. 219. - /* 22
96、0. - * Normally we would load 4 KB of nand to SRAM and jump there, but 221. - * it is not working perfectl
97、y as expected, so we cheat and load 222. - * it from nand directly relocated to 0x33f80000 and jump there 223. -
98、0;*/ 224. - if (mini2440_load_from_nand(s->nand, 0, S3C_RAM_BASE | 0x03f80000, 256*1024)> 0) 225. - m
99、ini2440_printf("loaded default u-boot from NAND/n"); 226. - s->cpu->env->regs15 = S3C_RAM_BASE | 0x03f80000; /* start address,
100、 u-boot already relo 227. - 228. -#if 0 && defined(LATER) 229. - if (mini2440_load_from_nand(s->nand, 0, S3C_SRAM_BASE_NANDBOOT, S3C_SRAM_SIZ
101、E) > 0) 230. - s->cpu->env->regs15 = S3C_SRAM_BASE_NANDBOOT; /* start address, u-boot relocating code 231. - &
102、#160; mini2440_printf("4KB SteppingStone loaded from NAND/n"); 232. - 233. -#endif 234. - /* 235. -
103、60; * if a u-boot is available as a file, we always use it 236. - */ 237. - 238. - &
104、#160; image_size = load_image("mini2440/u-boot.bin", qemu_get_ram_ptr(0x03f80000); 239. - if (image_size < 0) 240. - &
105、#160; image_size = load_image("u-boot.bin", qemu_get_ram_ptr(0x03f80000); 241. - if (im
106、age_size > 0) 242. - if (image_size & (512 -1) /* round size
107、0;to a NAND block size */ 243. - image_size = (image_size +
108、;512) & (512-1); 244. - mini2440_printf("loaded override u-boot (size %x)/n", image_size); 2
109、45. - s->cpu->env->regs15 = S3C_RAM_BASE | 0x03f80000; /* start address, u-boot already 246. -
110、0; 247. - 248. - /* 249. - * if a kernel was explicitly specified
111、, we load it too 250. - */ 251. - if (s->kernel) 252. - image_
112、size = load_image(s->kernel, qemu_get_ram_ptr(0x02000000); 253. : 254. diff -git a/hw/mini2440.c b/hw/mini2440.c 255. index 5decf4b.7a70aae 100644 256. - a/hw/mini2440.c 257. + b/hw/mini2440.c
113、 258. -258,46 +258,15 static void mini2440_reset(void *opaque) 259. struct mini2440_board_s *s = (struct mini2440_board_s *) opaque; 260. uint3
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年提高知识产权保护
- 2026年事业单位面试药学岗位知识
- 2026年中草药知识问答活动策划方案
- 2026年银行从业考试重点串讲
- 2026年小学二年级上册语文单元同步基础练习卷含答案
- 消防设施操作员(1000题·附答案)
- 2026年海南省五指山市高三生物下册期末考试模拟卷【典型题】附答案
- 教师信息技术应用能力提升工程培训心得(21篇)
- WindowsServer系统配置管理项目化教程 教案 项目10部署企业Web服务
- 矿产资源总体规划范本
- 2024年湖北省普通高中学业水平合格性考试数学试题(原卷版)
- 深圳市城市规划标准与准则2024版
- 对比剂过敏反应处理流程
- DBJ51-T 040-2021 四川省工程建设项目招标代理操作规程
- PCB设计与制作教程手册
- 光伏电站技术监督管理制度(2篇)
- 人工智能设计伦理(浙江大学)知到智慧树章节答案
- 2024年国网湖北电力部分单位市场化招聘管理单位遴选500模拟题附带答案详解
- 升降车安全操作规程
- 应征公民政治考核表(含各种附表)
- DL-T5841-2021电气装置安装工程母线装置施工及验收规范
评论
0/150
提交评论