下载此文档

使用QEMU建立Mini2440及模拟环境.doc


文档分类:法律/法学 | 页数:约22页 举报非法文档有奖
1/22
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/22 下载此文档
文档列表 文档介绍
该【使用QEMU建立Mini2440及模拟环境 】是由【916581885】上传分享,文档一共【22】页,该文档可以免费在线阅读,需要了解更多关于【使用QEMU建立Mini2440及模拟环境 】的内容,可以使用淘豆网的站内搜索功能,选择自己适合的文档,以下文字是截取该文章内的部分文字,如需要获得完整电子版,请下载此文档到您的设备,方便您编辑和打印。使用qemu建立mini2440的模拟仿真环境

gitclonegit:// qemu
如果感觉速度慢,直接打包下载
解压后,今日源代码的主目录中,
1
2
# ./configure--target-list=arm-softmmu
# make-j4
-bootformini2440
gitclone  git://-boot-openmoko/ uboot
或者打包下载
(注意采用打包下载的时候这几个包的文件名可能相同,注意区分)解压后,配置Makefile文件,打开Makefile文件,CROSS_COMPILE变量赋值,即自己所使用的交叉编译工具链,比如我的是arm-none-linux-gnueabi-,保存退出,输入
1
2
# makemini2440_config
# make-j4
稍等两分钟,即在当前目录下生成名为u-,注意如果想在之后使用u-boot的nfs下载文件功能,需要修改代码中的一部分,将net/=2UL修改为NFS_TIMEOUT=20000UL否则会造成nfs文件下载失败,如果不使用nfs下载功能,不改也可。
然后将u--mini2440/mini2440文件夹下。
(可以使用原mini2440开发板的内核源代码)
(下载步骤略去)
进入源码目录
1
2
# makemini2440_defconfigARCH=arm
#makeuImage
之后会在arch/arm/boot/目录下生成uImage文件,将此文件复制到qemu目录下的mini2440文件夹下,
将kernel一行改为-kernel"$base/uImage"\,回到上层目录后运行
1
# shmini2440/
错误解决:
一、
,即makeinstall,那么需要打开mini2440/,将第16行的qemu-img
改为:$base/../qemu-img
,即有makeinstall,不管这一步骤。
二、
期待的画面并没有出来,取而代之的是:
/etc/qemu-ifup:couldnotlaunchnetworkscript
Couldnotinitializedevice'tap'
该错误一般是运行权限错误,使用根用户运行。
三、
使用根用户运行,依旧是:/etc/qemu-ifup:couldnotlaunchnetworkscript……。
:
staticintlaunch_script(constchar*setup_script,constchar*ifname,intfd)
{
intpid,status;
char*args[4];/*baconmodified*/
char**parg;
/*trytolaunchnetworkscript*/
pid=fork();
if(pid>=0){
if(pid==0){
charpath[20];/*baconadd*/
intopen_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=args;
strcpy(path,"/bin/bash");/*baconadd*/
*parg++=(char*)path;/*baconadd*/
*parg++=(char*)setup_script;
*parg++=(char*)ifname;
*parg++=NULL;
status=execv(path,args);/*baconadd*/
fprintf(stderr,"error:%d%d%d%s%s/n",status,errno,ENOEXEC,setup_script,ifname);/*baconaddfor
debug.*/
_exit(1);
}
while(waitpid(pid,&status,0)!=pid);
if(!WIFEXITED(status)||
WEXITSTATUS(status)!=0){
fprintf(stderr,"%s:couldnotlaunchnetworkscript/n",
setup_script);
return-1;
}
}
return0;
}
这时应该看到qemu启动后进入了u-boot界面下,输入命令。
1
#  bootm
就会看到linux内核启动的画面,但此时还没有根文件系统,我们稍候介绍采用nfs挂在根文件系统。
,假设你用的操作系统为ubuntu,首先安装nfs服务器
1
# sudoapt-getinstallnfs-kernel-server
之后修改/etc/exports文件,添加如下一行
/home/wuxia*(rw,sync,no_root_squash)
....................注意 /home/wuxia为你所要共享的目录。
输入命令
1
#  sudo/etc/-kernel-serverrestart
启动nfs服务
测试nfs服务是否成功启动
1
2
# sudomkdir/mnt/nfs
# sudomount-tnfslocalhost:/home/username/nfs/mnt/nfs
查看/mnt/nfs文件是否于/home/username/nfs中相同,若一样,OK

1
2
3
4
5
6
7
#!/bin/sh
sudo ../arm-softmmu/qemu-system-arm\
-Mmini2440 \
-kernelmini2440/uImage -serialstdio\
  -netnic,vlan=0-nettap,vlan=0,ifname=tap0,script=./qemu-ifup,downscript=./qemu-ifdown\
-show-cursor\
-usb-usbdevicekeyboard-usbdevicemouse\
在建立两个脚本,分别为qemu-ifup,qemu-ifdown
qemu-ifup脚本
1
2
3
#!/bin/sh
echo"Excutingqemu-ifup"
ifconfig$
qemu-ifdown脚本
1
2
3
#!/bin/sh
echo"Closetap!"
sudoifconfig$
,我们即可使用nfs根文件系统了
这里我们的根文件系统为/home/wuxia/mini2440/image/rootfs
在qemu的目录中输入
1
#./mini2440/
u-boot启动成功后输入设置linuxkernel的引导参数
setbootargsnoinitrdroot=/dev/nfsrwnfsroot=:/home/wuxia/mini2440/image/rootfsip=:1::=ttySAC0,115200
再输入命令
bootm
OK!kernel就开始加载了,文件系统挂在成功后,就可以进行各种仿真工作了。友善之臂提供的qtopia文件系统在挂载时会初始化网卡,但我们是由nfs挂载的文件系统,这会导致nfs连接中断,挂载失败,所以用nfs挂载之前需要把网卡的初始化过程取消,对应的文件是/etc/-config,只需把该文件内容清空即可。
redbootonQEMUformini2440
分类: eCosonmini2440qemu2023-03-0116:13 603人阅读 评论(0) 收藏 举报
(原创文章,欢迎转载,请注明出处,谢谢。)
最近有空呼吸新鲜空气,重新拿起来了eCos,做点东西共享给大家。
 
rt-thread最近很火,在mini2440的qemu平台上发表了测试和代码,这无疑给更多的爱好者以新的学****机会。
 
这段时间一直在研究ecos,所以有了把ecos移植到mini2440的qemu平台的想法。经过几天的折腾,终于可以在qemu的上面看到redboot的命令了。
 
先看看成果,然后进入枯燥的coding历程
 
现在开始看代码,:-)
 
 

 
gitclonegit:// qemu
 
修改启动部分为ram的最小地址直接启动
 
[cpp] viewplaincopy
******@ricky-laptop:~/ecos/projects/mini2440-qemu/mini2440$ git diff  
diff --git a/hw/ b/hw/  
index 5decf4b..7a70aae 100644  
--- a/hw/  
+++ b/hw/  
@@ -258,46 +258,15 @@ static void mini2440_reset(void *opaque)  
     struct mini2440_board_s *s = (struct mini2440_board_s *) opaque;  
     uint32_t image_size;  
   
-       /* 
-        * Normally we would load 4 KB of nand to SRAM and jump there, but 
-        * it is not working perfectly as expected, so we cheat and load 
-        * it from nand directly relocated to 0x33f80000 and jump there 
-        */  
-       if (mini2440_load_from_nand(s->nand, 0, S3C_RAM_BASE | 0x03f80000, 256*1  
-               mini2440_printf("loaded default u-boot from NAND/n");  
-               s->cpu->env->regs[15] = S3C_RAM_BASE | 0x03f80000; /* start addr 
-       } 
-#if 0 && defined(LATER) 
-       if (mini2440_load_from_nand(s->nand, 0, S3C_SRAM_BASE_NANDBOOT, S3C_SRAM 
-           s->cpu->env->regs[15] = S3C_SRAM_BASE_NANDBOOT;     /* start address 
-           mini2440_printf("4KB SteppingStone loaded from NAND/n"); 
-       } 
-#endif 

diff --git a/hw/ b/hw/ 
index 5decf4b..7a70aae 100644 
--- a/hw/ 
+++ b/hw/ 
@@ -258,46 +258,15 @@ static void mini2440_reset(void *opaque) 
     struct mini2440_board_s *s = (struct mini2440_board_s *) opaque; 
     uint32_t image_size; 
  
-       /* 
-        * Normally we would load 4 KB of nand to SRAM and jump there, but 
-        * it is not working perfectly as expected, so we cheat and load 
-        * it from nand directly relocated to 0x33f80000 and jump there 
-        */  
-       if (mini2440_load_from_nand(s->nand, 0, S3C_RAM_BASE | 0x03f80000, 256*10  
-               mini2440_printf("loaded default u-boot from NAND/n");  
-               s->cpu->env->regs[15] = S3C_RAM_BASE | 0x03f80000; /* start addre 
-       } 
-#if 0 && defined(LATER) 
-       if (mini2440_load_from_nand(s->nand, 0, S3C_SRAM_BASE_NANDBOOT, S3C_SRAM_ 
-           s->cpu->env->regs[15] = S3C_SRAM_BASE_NANDBOOT;     /* start address, 
-           mini2440_printf("4KB SteppingStone loaded from NAND/n"); 
-       } 
-#endif 
-       /* 

diff --git a/hw/ b/hw/ 
index 5decf4b..7a70aae 100644 
--- a/hw/ 
+++ b/hw/ 
@@ -258,46 +258,15 @@ static void mini2440_reset(void *opaque) 
     struct mini2440_board_s *s = (struct mini2440_board_s *) opaque; 
     uint32_t image_size; 
  
-       /* 
-        * Normally we would load 4 KB of nand to SRAM and jump there, but 
-        * it is not working perfectly as expected, so we cheat and load 
-        * it from nand directly relocated to 0x33f80000 and jump there 
-        */  
-       if (mini2440_load_from_nand(s->nand, 0, S3C_RAM_BASE | 0x03f80000, 256*102  
-               mini2440_printf("loaded default u-boot from NAND/n");  
-               s->cpu->env->regs[15] = S3C_RAM_BASE | 0x03f80000; /* start addres 
-       } 
-#if 0 && defined(LATER) 
-       if (mini2440_load_from_nand(s->nand, 0, S3C_SRAM_BASE_NANDBOOT, S3C_SRAM_S 
-           s->cpu->env->regs[15] = S3C_SRAM_BASE_NANDBOOT;     /* start address,  
-           mini2440_printf("4KB SteppingStone loaded from NAND/n"); 
-       } 
-#endif 
-       /* 
-        * if a u--boot is available as a file, we always use it 

diff --git a/hw/ b/hw/ 
index 5decf4b..7a70aae 100644 
--- a/hw/ 
+++ b/hw/ 
@@ -258,46 +258,15 @@ static void mini2440_reset(void *opaque) 
     struct mini2440_board_s *s = (struct mini2440_board_s *) opaque; 
     uint32_t image_size; 
  
-       /* 
-        * Normally we would load 4 KB of nand to SRAM and jump there, but 
-        * it is not working perfectly as expected, so we cheat and load 
-        * it from nand directly relocated to 0x33f80000 and jump there 
-        */  
-       if (mini2440_load_from_nand(s->nand, 0, S3C_RAM_BASE | 0x03f80000, 256*1024)>  
-               mini2440_printf("loaded default u-boot from NAND/n");  
-               s->cpu->env->regs[15] = S3C_RAM_BASE | 0x03f80000; /* start address,  
-       } 
-#if 0 && defined(LATER) 
-       if (mini2440_load_from_nand(s->nand, 0, S3C_SRAM_BASE_NANDBOOT, S3C_SRAM_SIZE 
-           s->cpu->env->regs[15] = S3C_SRAM_BASE_NANDBOOT;     /* start address, u-b 
-           mini2440_printf("4KB SteppingStone loaded from NAND/n"); 
-       } 
-#endif 
-       /* 
-        * if a u--boot is available as a file, we always use it 
-        */  
-       {  
-           image_size = load_image("mini2440/u-", qemu_get_ram_ptr(0x03f8000  
:  
diff --git a/hw/ b/hw/  
index 5decf4b..7a70aae 100644  
--- a/hw/  
+++ b/hw/  
@@ -258,46 +258,15 @@ static void mini2440_reset(void *opaque)  
     struct mini2440_board_s *s = (struct mini2440_board_s *) opaque;  
     uint32_t image_size;  
   
-       /* 
-        * Normally we would load 4 KB of nand to SRAM and jump there, but 
-        * it is not working perfectly as expected, so we cheat and load 
-        * it from nand directly relocated to 0x33f80000 and jump there 
-        */  
-       if (mini2440_load_from_nand(s->nand, 0, S3C_RAM_BASE | 0x03f80000, 256*1024)> 0)  
-               mini2440_printf("loaded default u-boot from NAND/n");  
-               s->cpu->env->regs[15] = S3C_RAM_BASE | 0x03f80000; /* start address, u-b 
-       } 
-#if 0 && defined(LATER) 
-       if (mini2440_load_from_nand(s->nand, 0, S3C_SRAM_BASE_NANDBOOT, S3C_SRAM_SIZE) > 
-           s->cpu->env->regs[15] = S3C_SRAM_BASE_NANDBOOT;     /* start address, u-boot 
-           mini2440_printf("4KB SteppingStone loaded from NAND/n"); 
-       } 
-#endif 
-       /* 
-        * if a u--boot is available as a file, we always use it 
-        */  
-       {  
-           image_size = load_image("mini2440/u-", qemu_get_ram_ptr(0x03f80000))  
-           if (image_size < 0)  
-                   image_size = load_image("u-", qemu_get_ram_ptr(0x03f80000));  
-               if (image_size > 0) {  
:  
diff --git a/hw/ b/hw/  
index 5decf4b..7a70aae 100644  
--- a/hw/  
+++ b/hw/  
@@ -258,46 +258,15 @@ static void mini2440_reset(void *opaque)  
     struct mini2440_board_s *s = (struct mini2440_board_s *) opaque;  
     uint32_t image_size;  
   
-       /* 
-        * Normally we would load 4 KB of nand to SRAM and jump there, but 
-        * it is not working perfectly as expected, so we cheat and load 
-        * it from nand directly relocated to 0x33f80000 and jump there 
-        */  
-       if (mini2440_load_from_nand(s->nand, 0, S3C_RAM_BASE | 0x03f80000, 256*1024)> 0) {  
-               mini2440_printf("loaded default u-boot from NAND/n");  
-               s->cpu->env->regs[15] = S3C_RAM_BASE | 0x03f80000; /* start address, u-boot  
-       } 
-#if 0 && defined(LATER) 
-       if (mini2440_load_from_nand(s->nand, 0, S3C_SRAM_BASE_NANDBOOT, S3C_SRAM_SIZE) > 0)  
-           s->cpu->env->regs[15] = S3C_SRAM_BASE_NANDBOOT;     /* start address, u-boot rel 
-           mini2440_printf("4KB SteppingStone loaded from NAND/n"); 
-       } 
-#endif 
-       /* 
-        * if a u--boot is available as a file, we always use it 
-        */  
-       {  
-           image_size = load_image("mini2440/u-", qemu_get_ram_ptr(0x03f80000));  
-           if (image_size < 0)  
-                   image_size = load_image("u-", qemu_get_ram_ptr(0x03f80000));  
-               if (image_size > 0) {  
-                       if (image_size & (512 -1))      /* round size to a NAND block size * 
-                               image_size = (image_size + 512) & ~(512-1); 
-                

使用QEMU建立Mini2440及模拟环境 来自淘豆网www.taodocs.com转载请标明出处.

非法内容举报中心
文档信息
  • 页数22
  • 收藏数0 收藏
  • 顶次数0
  • 上传人916581885
  • 文件大小280 KB
  • 时间2023-04-15