定制最简linux和根文件系统平台龙芯1B开发板.docx
- 文档编号:29630083
- 上传时间:2023-07-25
- 格式:DOCX
- 页数:20
- 大小:699.79KB
定制最简linux和根文件系统平台龙芯1B开发板.docx
《定制最简linux和根文件系统平台龙芯1B开发板.docx》由会员分享,可在线阅读,更多相关《定制最简linux和根文件系统平台龙芯1B开发板.docx(20页珍藏版)》请在冰豆网上搜索。
定制最简linux和根文件系统平台龙芯1B开发板
定制最简linux和根文件系统(平台龙芯1B开发板)
版本历史
版本
时间
备注
V1.0
2013-08-28
创建
1.
前言
很高心拿到了龙芯1B开发板。
然后仔细的看了开发板光盘里的《1B开发板用户手册.pdf》。
里面写得非常详细,并且都附有截图,很明了。
从最开始装虚拟机到编译linux,制作根文件系统等等,连虚拟机软件和Ubuntu系统镜像都有。
可以说这套开发板考虑得非常周到。
然后我就参照《1B开发板用户手册.pdf》编译了linux,制作了根文件系统,最后终于跑起来,进入了shell。
这里谈谈我的感想
●用户手册更像一个工具书
就拿根文件系统来说吧。
Cramfs,Jffs2,Yaffs2的制作步骤都有,这表示该手册很全面,但是如果是一个初学者的话,给的选择太多不一定是好事。
这也是我想写这篇文档的原因。
我想linux的配置尽量简单(除了串口驱动以外,其它的比如,网卡,声卡,触屏等都暂时不需要),根文件系统也尽量简单(手册中的已经很简单了,后面我们就参照手册),另外为了再简单一点我把根文件系统也选择内存文件系统,内核只下载到内存而不烧写到flash,同时PMON参数也不修改。
这样做有个好处——任何时候我可以复位进入开发板预装的linux和文件系统。
这便于在我们遇到问题时参考。
●制作根文件系统的章节还有点小小的问题需要改进
⏹手册中的笔误Busybox配置过程中ionice错写为inoice
⏹没有新建目录/root和/var/log
⏹没有新建console和串口设备节点ttyS2
另外,说点题外话,回想以前读大学时,非常想学习嵌入式,但是感觉非常困难。
现在看来,当时感觉困难的原因是入门太难了。
为什么入门难,弄了很久连环境都没打起来,更别说编译linux,制作根文件系统了。
在这里我想说“朋友们,搭建环境只需要把开发板的工具链解压到指定目录就可以了。
就相当于windows上的绿色软件一样,仅此而已,这比安装vs2005快多了,方便多了”。
既然开发环境搭建起来了,后面就是配置编译linux,制作根文件系统了(先不要管PMON了,就像电脑一样,很少有人换bios,最多重装系统)。
这也就是本篇文章的任务。
1.1.开发板版本号
LS1BDEMOBOARDSchematicRevision2.0即版本为2.0
1.2.工具链版本号
版本为gcc-3.4.6-2f.tar.gz
1.3.参考文档及其版本号
《1B开发板用户手册》V1.2
1.4.目标
参考《1B开发板用户手册》创建一个最简化的linux和根文件系统。
同时不破坏开发板预装的linux等,并将这个过程记录下来,仅供参考。
这里在明确一下本次任务的详细内容
⏹PMON不变(不要动PMON,包括PMON环境变量,除了ip地址外)
⏹LINUX内核配置尽量简单(驱动方面,除了串口外,其它的网口,声卡,触屏都不要选上),linux内核也仅仅下载到内存,不要写到flash
⏹根文件系统尽量简单(根文件系统就直接从busybox编译后得到,暂时不移植什么应用),同时这里也选择RAMDISK文件系统,不要写到flash
2.搭建开发环境
安装虚拟机和Ubuntu网上有很多,当然手册中也讲得很详细,这个就自己解决。
假设您已经装好了。
另外我用的是redhat企业版5(手册中用的是Ubuntu),并且直接登录root账户,避免了什么权限的麻烦。
安装工具链手册中已经讲得非常好了,这里直接截图。
3.制作根文件系统
3.1.配置
3.1.1.拷贝源码,并解压
[root@localhosttest]#cp../LS1B/busybox-1.19.2-default.tar.gz./
l[root@localhosttest]#ls
1b-linux-3.0-d8b47bb1b-linux-3.0-d8b47bb.tar.gzbusybox-1.19.2-default.tar.gz
[root@localhosttest]#tar-zxfbusybox-1.19.2-default.tar.gz
[root@localhosttest]#ls
1b-linux-3.0-d8b47bbbusybox-1.19.2-default
1b-linux-3.0-d8b47bb.tar.gzbusybox-1.19.2-default.tar.gz
[root@localhosttest]#cdbusybox-1.19.2-default
[root@localhostbusybox-1.19.2-default]#
和linux内核一样,通过执行makemenuconfig来配置,输入后回车如下图所示
3.1.2.配置选项简述
BusyboxSettings--->
BuildOptions--->
[*]BuildBusyBoxasastaticbinary(nosharedlibs)
(/opt/GCC/gcc-3.4.6-2f/bin/mipsel-linux-)CrossCompilerprefix(交叉编译器的绝对路径前缀,根据自己情况修改)
BusyboxLibraryTuning--->
[*]vi-stylelineeditingcommands
[*]Fancyshellprompts
InitUtilities--->
[*]init
[*]Supportreadinganinittabfile
[*]Runcommandswithleadingdashwithcontrollingtty
[*]Supportrunninginitfromwithinaninitrd(notinitramfs)
MiscellaneousUtilities--->
[]ionice
[]ubiattach
[]ubidetach
[]ubimkvol
[]ubirmvol
[]ubirsvol
[]ubiupdatevol
3.2.编译
执行make
[root@localhostbusybox-1.19.2-default]#make
执行完后,如下
然后执行makeinstall
[root@localhostbusybox-1.19.2-default]#makeinstall
已经把需要的东西放到当前目录的_install下
然后在这基础上制作根文件系统
3.3.构建根文件系统
3.3.1.建立系统根目录
[root@localhostnfsramdisk]#mkdirLS1B
[root@localhostnfsramdisk]#cdLS1B
[root@localhostLS1B]#ls
[root@localhostLS1B]#mkdirdevhomeproctmpvaretclibmntsysusretc/rc.drootvar/log
[root@localhostLS1B]#ls
devetchomelibmntprocrootsystmpusrvar
[root@localhostLS1B]#
3.3.2.建立设备文件
建立console和串口设备文件
[root@localhostLS1B]#mknod-m600dev/consolec51
[root@localhostLS1B]#mknod-m600dev/ttyS2c466
[root@localhostLS1B]#
3.3.3.建立系统配置文件
注意:
以下的配置文件不是在开发主机的根目录下创建的。
3.3.3.1.添加etc/inittab文件
[root@localhostLS1B]#vimetc/inittab
:
:
sysinit:
/etc/rc.d/rc.sysinit//指定系统启动后首先执行的文件
#Exampleofhowtoputagettyonaserialline(rotaterminal)
ttyS2:
:
respawn:
~/bin/sh#nologin(启动后进入shell)
#:
:
respawn:
/sbin/getty-LttyS2115200vt100#uselogin
#tty:
:
respawn:
~/bin/sh
#Stufftodowhenrestartingtheinitprocess
:
:
restart:
/sbin/init
#Stufftodobeforerebooting
:
:
ctrlaltdel:
/sbin/reboot//捕捉ctrl+alt+del键,重启文件系统
:
:
shutdown:
/bin/umount-a-r//当关机时卸载所有文件系统
:
:
shutdown:
/sbin/swapoff-a
~
~
"etc/inittab"[新]14L,553C已写入
[root@localhostLS1B]#
3.3.3.2.新建etc/rc.d/rc.sysinit文件
[root@localhostLS1B]#vimetc/rc.d/rc.sysinit
#!
/bin/sh
#Setbinarypath
exportPATH=/bin:
/sbin:
/usr/bin:
/usr/sbin
#Configdevenvironment
mount-ttmpfs-osize=64k,mode=0755tmpfs/dev
mkdir-p/dev/pts
mount-tdevptsdevpts/dev/pts
#mknod-m600/dev/consolec51
#mknod-m600/dev/ttyS2c466
#mountallfilesystemdefinedin/etc/fstab
echo"#mountall......"
/bin/mount-a
echo"#Startingmdev......"
echo/sbin/mdev>/proc/sys/kernel/hotplug
/sbin/mdev-s
#Sethostname
/bin/hostname"Loongson-gz"
exportLOGNAME=root
"etc/rc.d/rc.sysinit"[新]24L,489C已写入
[root@localhostLS1B]#
3.3.3.3.新建etc/fstab文件
[root@localhostLS1B]#vimetc/fstab
sysfs/syssysfsdefaults00
proc/procprocdefaults00
tmpfs/tmptmpfsdefaults00
tmpfs/mnttmpfsdefaults00
tmpfs/roottmpfsdefaults00
tmpfs/var/logtmpfsdefaults00
~
"etc/fstab"[新]7L,213C已写入
[root@localhostLS1B]#
3.3.3.4.新建etc/profile文件
[root@localhostLS1B]#vimetc/profile
#!
/bin/sh
#/etc/profile:
system-wide.profilefilefortheBourneshells
echo"Processing/etc/profile..."
#Setsearchlibrarypath
exportLD_LIBRARY_PATH=/lib:
/usr/lib
#Setuserpath
exportPATH=/bin:
/sbin:
/usr/bin:
/usr/sbin
#SetPS1
USER="'id-un'"
LOGNAME=$USER
PS1='[\u@\h:
\w]\$'
PATH=$PATH
aliasll="ls-l"
echo"Done!
"
"etc/profile"20L,330C已写入
[root@localhostLS1B]#
3.3.3.5.修改系统配置文件权限
[root@localhostLS1B]#chmod755etc/*
[root@localhostLS1B]#chmod755etc/rc.d/rc.sysinit
[root@localhostLS1B]#
3.3.3.6.拷贝Busybox文件
[root@localhost~]#cd/home/dev/test/busybox-1.19.2-default
[root@localhostbusybox-1.19.2-default]#ls/nfsramdisk/LS1B
devetchomelibmntprocrootsystmpusrvar
[root@localhostbusybox-1.19.2-default]#cp-rf_install/*/nfsramdisk/LS1B
[root@localhostbusybox-1.19.2-default]#ls/nfsramdisk/LS1B
bindevetchomeliblinuxrcmntprocrootsbinsystmpusrvar
至此根文件系统制作完成!
4.编译linux
在强调一下,我使用的是redhat,直接root登录,手册《1B开发板用户手册》使用的是Ubuntu。
您可能又不一样,这个自己随机应变。
还有手册《1B开发板用户手册》用的是linux-2.6.21,而我用的是开发板光盘中的linux3.0。
这个同样根据自己情况随机应变。
4.1.配置
4.1.1.首先拷贝源码,并解压
[root@localhosttest]#ls
1b-linux-3.0-d8b47bb.tar.gzbusybox-1.19.2-defaultbusybox-1.19.2-default.tar.gz
[root@localhosttest]#tar-zxf1b-linux-3.0-d8b47bb.tar.gz
[root@localhosttest]#ls
1b-linux-3.0-d8b47bbbusybox-1.19.2-default
1b-linux-3.0-d8b47bb.tar.gzbusybox-1.19.2-default.tar.gz
[root@localhosttest]#cd1b-linux-3.0-d8b47bb
[root@localhost1b-linux-3.0-d8b47bb]#ls
archcryptofsKbuildMAINTAINERSREADMEsecurityvirt
blockDocumentationincludeKconfigMakefileREPORTING-BUGSsound
COPYINGdriversinitkernelmmsamplestools
CREDITSfirmwareipclibnetscriptsusr
[root@localhost1b-linux-3.0-d8b47bb]#
4.1.2.不安装Ncurses
我是直接登录的字符界面,没有进入图形界面,也没安装Ncurses。
而是直接makemenuconfig
4.1.3.没有拷贝.config
如果您是全新移植的话,需要拷贝.config,因为我用的是开发板光盘中的内核,本来就是移植配置好的,这里不需要这步。
[root@localhost1b-linux-3.0-d8b47bb]#ls-a
.arch.configCREDITSDocumentationfirmware.gitignoreinitKbuildkernel.mailmapMakefilenetREPORTING-BUGSscriptssoundusr
..blockCOPYINGcryptodriversfsincludeipcKconfiglibMAINTAINERSmmREADMEsamplessecuritytoolsvirt
[root@localhost1b-linux-3.0-d8b47bb]#
4.1.4.不用修改Makefile
和.config一样,开发板光盘中的内核是配置移植好的,不用再修改Makefile了。
不信请看
#CROSS_COMPILEspecifytheprefixusedforallexecutablesused
#duringcompilation.Onlygccandrelatedbin-utilsexecutables
#areprefixedwith$(CROSS_COMPILE).
#CROSS_COMPILEcanbesetonthecommandline
#makeCROSS_COMPILE=ia64-linux-
#AlternativelyCROSS_COMPILEcanbesetintheenvironment.
#Athirdalternativeistostoreasettingin.configsothatplain
#"make"intheconfiguredkernelbuilddirectoryalwaysusesthat.
#DefaultvalueforCROSS_COMPILEisnottoprefixexecutables
#Note:
SomearchitecturesassignCROSS_COMPILEintheirarch/*/Makefile
exportKBUILD_BUILDHOST:
=$(SUBARCH)
ARCH?
=mips#$(SUBARCH)
CROSS_COMPILE?
=mipsel-linux-#$(CONFIG_CROSS_COMPILE:
"%"=%)
#CROSS_COMPILE?
=mipsel-loongson-linux-gnu-#mipsel-linux-#$(CONFIG_CROSS_COMPILE:
"%"=%)
#Architectureaspresentincompile.h
UTS_MACHINE:
=$(ARCH)
SRCARCH:
=$(ARCH)
现在开始配置,执行makemenuconfig
4.1.5.配置选项简述
CPU平台配置
Machineselection--->
Systemtype(Loongsonfamilyofmachines)--->
(X)Loongsonfamilyofmachines
MachineType(Loongson1Bboard)--->
(X)Loongson1Bboard
LCD配置
DeviceDrivers--->
Graphicssupport--->
[]Supportforframebufferdevices--->
触屏配置
DeviceDrivers--->
[]SPIsupport--->
Inputdevicesupport--->
[]Touchscreens--->
鼠标键盘配置
DeviceDrivers--->
Inputdevicesupport--->
[]Keyboards--->
[]Mouseinterface
[]USBsupport--->
网卡配置
DeviceDrivers--->
[]Networkdevicesupport--->
声卡配置
DeviceDrivers--->
[]Soundcardsupport--->
串口配置
DeviceDrivers--->
Characterdevices--->
Serialdrivers--->
[*]8250/16550andcompatibleserialsupport
[*]Consoleon8250/16550andcompatibleserialport
(6)Maximumnumberof8250/16550serialports
(6)Numberof8250/16550serialportstoregisteratruntime
RAMDISK文件系统
DeviceDrivers--->
[*]Blockdevices--->
[*]RAMblockdevicesupport
(16)DefaultnumberofRAMdisks
(65536)DefaultRAMdisksize(kbytes)
Generalsetup--->
[*]InitialRAMfilesystemandRAMdisk(initramfs/initrd)support
(/nfsramdisk/LS1B)Initramfssourcefile(s)
(1)UserIDtomapto0(userroot)(NEW)
(1)GroupIDtomapto0(grouproot)(NEW)
[*]Supportinitialramdiskscompressedusinggzip(NEW)
保存退出
4.2.编译
刚才配置好了,这里编译只需make一下就可以了
[root@localhost1b-linux-3.0-d8b47bb]#make
然后,慢慢等,直到编译完成。
LD.tmp_vmlinux2
KSYM.tmp_kallsyms2.S
AS.tmp_kallsyms2.o
LDvmlinux
SYSMAPSystem.map
SYSMAP.tmp_System.map
CCarch/mips/boot/compressed/dummy.o
OBJCOPYarch/mips/boot/compressed/
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 定制 linux 文件系统 平台 开发