echo \/bin/mount -a
echo \
echo /sbin/mdev>/proc/sys/kernel/hotplug /sbin/mdev -s
#Set hostname
/bin/hostname \export LOGNAME=root
\新] 24L, 489C 已写入 [root@localhost LS1B]#
3.3.3.3. 新建etc/fstab文件
[root@localhost LS1B]# vim etc/fstab
sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 tmpfs /tmp tmpfs defaults 0 0 tmpfs /mnt tmpfs defaults 0 0 tmpfs /root tmpfs defaults 0 0 tmpfs /var/log tmpfs defaults 0 0 ~
\新] 7L, 213C 已写入 [root@localhost LS1B]#
3.3.3.4. 新建etc/profile文件
[root@localhost LS1B]# vim etc/profile
#!/bin/sh
#/etc/profile:system-wide .profile file for the Bourne shells echo \
#Set search library path
export LD_LIBRARY_PATH=/lib:/usr/lib
#Set user path
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
#Set PS1
11
USER=\LOGNAME=$USER PS1='[\%u@\\h:\\w]\\$' PATH=$PATH
alias ll=\
echo \
\已写入 [root@localhost LS1B]#
3.3.3.5. 修改系统配置文件权限
[root@localhost LS1B]# chmod 755 etc/*
[root@localhost LS1B]# chmod 755 etc/rc.d/rc.sysinit [root@localhost LS1B]#
3.3.3.6. 拷贝Busybox文件
[root@localhost ~]# cd /home/dev/test/busybox-1.19.2-default [root@localhost busybox-1.19.2-default]# ls /nfsramdisk/LS1B dev etc home lib mnt proc root sys tmp usr var
[root@localhost busybox-1.19.2-default]# cp -rf _install/* /nfsramdisk/LS1B [root@localhost busybox-1.19.2-default]# ls /nfsramdisk/LS1B
bin dev etc home lib linuxrc mnt proc root sbin sys tmp usr var
至此根文件系统制作完成!
4. 编译linux
在强调一下,我使用的是red hat,直接root登录,手册《1B开发板用户手册》使用的是Ubuntu。您可能又不一样,这个自己随机应变。
还有手册《1B开发板用户手册》用的是linux-2.6.21,而我用的是开发板光盘中的linux 3.0。这个同样根据自己情况随机应变。
12
4.1. 配置
4.1.1. 首先拷贝源码,并解压
[root@localhost test]# ls
1b-linux-3.0-d8b47bb.tar.gz busybox-1.19.2-default busybox-1.19.2-default.tar.gz [root@localhost test]# tar -zxf 1b-linux-3.0-d8b47bb.tar.gz [root@localhost test]# ls
1b-linux-3.0-d8b47bb busybox-1.19.2-default 1b-linux-3.0-d8b47bb.tar.gz busybox-1.19.2-default.tar.gz [root@localhost test]# cd 1b-linux-3.0-d8b47bb [root@localhost 1b-linux-3.0-d8b47bb]# ls
arch crypto fs Kbuild MAINTAINERS README security virt
block Documentation include Kconfig Makefile REPORTING-BUGS sound COPYING drivers init kernel mm samples tools CREDITS firmware ipc lib net scripts usr [root@localhost 1b-linux-3.0-d8b47bb]#
4.1.2. 不安装Ncurses
我是直接登录的字符界面,没有进入图形界面,也没安装Ncurses。而是直接make menuconfig
13
4.1.3. 没有拷贝.config
如果您是全新移植的话,需要拷贝.config,因为我用的是开发板光盘中的内核,本来就是移植配置好的,这里不需要这步。
[root@localhost 1b-linux-3.0-d8b47bb]# ls -a
. arch .config CREDITS Documentation firmware .gitignore init Kbuild kernel .mailmap Makefile net REPORTING-BUGS scripts sound usr
.. block COPYING crypto drivers fs include ipc Kconfig lib MAINTAINERS mm README samples security tools virt [root@localhost 1b-linux-3.0-d8b47bb]#
4.1.4. 不用修改Makefile
和.config一样,开发板光盘中的内核是配置移植好的,不用再修改Makefile了。不信请看
# CROSS_COMPILE specify the prefix used for all executables used # during compilation. Only gcc and related bin-utils executables # are prefixed with $(CROSS_COMPILE).
# CROSS_COMPILE can be set on the command line # make CROSS_COMPILE=ia64-linux-
# Alternatively CROSS_COMPILE can be set in the environment. # A third alternative is to store a setting in .config so that plain # \# Default value for CROSS_COMPILE is not to prefix executables
# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile export KBUILD_BUILDHOST := $(SUBARCH) ARCH ?= mips#$(SUBARCH)
CROSS_COMPILE ?= mipsel-linux-#$(CONFIG_CROSS_COMPILE:\#CROSS_COMPILE
mipsel-loongson-linux-gnu-#mipsel-linux-#$(CONFIG_CROSS_COMPILE:\
# Architecture as present in compile.h UTS_MACHINE := $(ARCH) SRCARCH := $(ARCH)
现在开始配置,执行make menuconfig
?=
4.1.5. 配置选项简述
CPU平台配置
Machine selection --->
14
System type (Loongson family of machines) --->
(X) Loongson family of machines Machine Type (Loongson 1B board) --->
(X) Loongson 1B board
LCD配置
Device Drivers --->
Graphics support --->
[ ] Support for frame buffer devices --->
触屏配置
Device Drivers --->
[ ] SPI support --->
Input device support --->
[ ] Touchscreens --->
鼠标键盘配置
Device Drivers --->
Input device support --->
[ ] Keyboards ---> [ ] Mouse interface [ ] USB support ---> 网卡配置
Device Drivers --->
[ ] Network device support ---> 声卡配置
Device Drivers --->
[ ] Sound card support --->
串口配置
Device Drivers --->
Character devices --->
Serial drivers --->
[*] 8250/16550 and compatible serial support
[*] Console on 8250/16550 and compatible serial port (6) Maximum number of 8250/16550 serial ports
(6) Number of 8250/16550 serial ports to register at runtime
RAMDISK文件系统 Device Drivers --->
[*] Block devices --->
[*] RAM block device support
15