1 LCD驱动移植
1.1 修改LCD板卡支持源码
gedit arch/arm/mach-s3c64xx/mach-OK6410.c
(1). 修改OK6410_fb_win0结构体:
static struct s3c_fb_pd_win OK6410_fb_win0 = {
/*this is to ensure we use win0 */
.win_mode = {
.left_margin = 2,
.right_margin = 2,
.upper_margin = 2,
.lower_margin = 2,
.hsync_len = 41,
.vsync_len = 11,
.xres = 480,
.yres = 272,
},
.max_bpp = 32,
.default_bpp = 16,
};
(2). 填充OK6410_iodesc数组:
static struct map_desc OK6410_iodesc[] = {
{
/*LCD support */
.virtual = (unsigned long)S3C_VA_LCD,
.pfn= __phys_to_pfn(S3C_PA_FB),
.length = SZ_16K,
.type = MT_DEVICE,
},
};
(3). 注释掉OK6410_machine_init中的
//gpio_request(S3C64XX_GPN(5),"LCD power");
//gpio_request(S3C64XX_GPF(13),"LCD power");
1.2 拷贝官方示例内核中的drviers/video/samsung拷贝到drviers/video/目录下
1.3 拷贝官方示例内核中arch/arm/mach-s3c64xx/include/mach目录下的regs-fb.h、regs-lcd.h、gpio-bank-f.h到对应目录下
1.4 修改drviers/video/的Kconfig文件
在文件末尾加入:
source "drivers/video/samsung/Kconfig"
1.5 修改drviers/video/的Makefie文件
最后一行添加:
obj-$(CONFIG_FB_S3C_EXT) += samsung/
1.6 修改arch/arm/plat-samsung/include/plat/map-base.h文件
在末尾添加:
#define S3C_VA_LCD S3C_ADDR(0x01100000) /* LCD */
1.7 修改include/generated/autoconf.h文件
在末尾添加:
#define CONFIG_FB_S3C_EXT_NUM 4
1.8 修改drivers/video/samsung/s3cfb_fimd4x.c文件
(4). 将s3c6410_pm_do_save(s3c_lcd_save,ARRAY_SIZE(s3c_lcd_save));改为:
s3c_pm_do_save(s3c_lcd_save,ARRAY_SIZE(s3c_lcd_save));
(5). 将s3c6410_pm_do_restore(s3c_lcd_save,ARRAY_SIZE(s3c_lcd_save));改为:
s3c_pm_do_restore(s3c_lcd_save,ARRAY_SIZE(s3c_lcd_save));
1.9 配置内核
make menuconfig
Device Drivers --->
Graphicssupport --->
<*>Support for frame buffer devices ---> (里面的都空选)
[ ]Backlight & LCD device support --->
<*>S3C Framebuffer Support (eXtended)(修改Kconfig之后才有这个选)
SelectLCD Type (4.3 inch 480x272 TFT LCD) --->
(X) 4.3 inch 480x272 TFT LCD
<*>Advanced options for S3C Framebuffer
SelectBPP(Bits Per Pixel) (16 BPP) --->
(4)Number of Framebuffers
[ ]Enable Virtual Screen
[*]Enable Double Buffering
Consoledisplay driver support --->
<*>Framebuffer Console support
[*] Bootup logo --->(显示小企鹅)
[ ] Standard black and white Linux logo
[] Standard 16-color Linux logo
[*] Standard 224-color Linux logo
2 DM9000网卡驱动移植
2.1 修改arch/arm/mach-s3c64xx/mach-OK6410.c文件
Linux内核里面已经支持了dm9000的网卡驱动,只需要添加平台设备信息即可。
gedit arch/arm/mach-s3c64xx/mach-OK6410.c
(1). 在开头添加:
#include <linux/dm9000.h>
#define S3C64XX_PA_DM9000 (0x18000000)
#define S3C64XX_SZ_DM9000 SZ_1M
(2). 在static struct platform_device*OK6410_devices[] __initdata前插入
/* Support For DM9000 */
static struct resource OK6410_dm9000_resources[] ={
[0] ={
.start=S3C64XX_PA_DM9000,
.end=S3C64XX_PA_DM9000 + 3,
.flags=IORESOURCE_MEM,
},
[1] ={
.start=S3C64XX_PA_DM9000 + 4,
.end=S3C64XX_PA_DM9000 + S3C64XX_SZ_DM9000 - 1,
.flags=IORESOURCE_MEM,
},
[2]= {
.start=IRQ_EINT(7),
.end=IRQ_EINT(7),
.flags=IORESOURCE_IRQ | IRQF_TRIGGER_HIGH,
},
};
static struct dm9000_plat_dataOK6410_dm9000_platdata = {
.flags=DM9000_PLATF_16BITONLY,
.dev_addr={ 0x08, 0x90, 0x00, 0xa0, 0x90, 0x90 },
};
static struct platform_device OK6410_device_dm9000= {
.name="dm9000",
.id=0,
.num_resources=ARRAY_SIZE(OK6410_dm9000_resources),
.resource=OK6410_dm9000_resources,
.dev={
.platform_data= &OK6410_dm9000_platdata,
}
};
(3). 然在static struct platform_device*OK6410_devices[] __initdata 中插入:
&OK6410_device_dm9000,
(4). 因与DM9000的物理地址冲突,注释掉&OK6410_smsc911x,
2.2 配置内核
make menuconfig
[*] Networking support --->
[*] Wireless (NEW) --->
<*> cfg80211 - wirelessconfiguration API
[*] enable powersave by default (NEW)
[*] cfg80211 wireless extensions compatibility(NEW)
[*] Wireless extensions sysfs files
<*> Common routines forIEEE802.11 drivers
<*> Generic IEEE 802.11Networking Stack (mac80211)
Device Drivers --->
[*] Network device support --->
<*> Generic Media Independent Interface device support
[*] Ethernet driver support (NEW) --->
[] Broadcom devices
<*> DM9000 support(即只保留该选项)
[ ] Faraday devices
[ ] Intel devices
[ ] Micrel devices
[ ] Microchip devices
[ ] National Semi-conductor devices
[ ] SEEQ devices
[ ] SMC (SMSC)/Western Digital devices
[ ] STMicroelectronics devices
[*] Wireless LAN (NEW) --->
<*> Ralink driver support --->
<*> Ralink rt2501/rt73 (USB) support
[*] Ralink debug output
2.3 设置网络参数
(1). 使用网线分别连接开发板和宿主机到交换机(OK6410网线直连方式测试不成功);
(2). 本机IP为192.168.1.7,宿主机(虚拟机)IP为192.168.1.8,桥接方式:
(3). 启动开发板,按空格进入Uboot菜单,按6进入命令行模式
(4). 输入指令print查看当前参数配置
(5). 设置开发板IP:
set ipaddr 192.168.1.6
(6). 设置服务器IP:
set serverip 192.168.1.8
(7). 设置网关IP:
set gatewayip 192.168.1.1
(8). 设置子网掩码:
set netmask 255.255.255.0
(9). 保持配置到nandflash
save
(10). 测试网络连接
ping 192.168.1.8
3 搭建NFS文件系统
3.1 下载解压busybox-1.2.7
tar jxvf busybox-1.27.2.tar.bz2
cd busybox-1.27.2
3.2 修改顶层Makefile
gedit Makefile
做如下修改:
CROSS_COMPILE ?= arm-linux-
ARCH ?= arm
3.3 配置busybox
Busybox Settings --->
[*] Build BusyBox as a static binary (noshared libs)
(arm-linux-) Cross Compiler prefix
Busybox Library Tuning --->
[*] Non-POSIX, but safer, copying to specialnodes (NEW)
Linux System Utilities—>
[ ]blkdiscard
[ ]nsenter
Coreutils—>
[ ] sync
3.4 编译
make
将BusyBox安装到指定的root_fs文件夹内
make CONFIG_PREFIX=/opt/OK6410/NFS/root_fs install
注:
编译出现miscutils/nandwrite.c:151:3:error: ‘MTD_FILE_MODE_RAW’ undeclared (first use in thisfunction)错误,按提示修改MTD_FILE_MODE_RAW’为 ‘MTD_MODE_RAW’后重新编译即可。
编译出现util-linux/blkdiscard.c:71:error: 'BLKSECDISCARD' undeclared(first use in this function)错误,取消选中Linux SystemUtilities->blkdiscard
3.5 建立根目录
(1). 进入上面指定目录的上级目录
cd /opt/OK6410/NFS
(2). 在其中创建一个create_rootfs.sh脚本
添加内容如下:
#!/bin/sh
echo "------Create rootfs directons start...--------"
mkdir root_fs
cd root_fs
echo "--------Create root,dev....----------"
mkdir root dev etc boot tmp var sys proc lib mnt home usr
mkdir etc/init.d etc/rc.d etc/sysconfig
mkdir usr/sbin usr/bin usr/lib usr/modules
echo "make node in dev/console dev/null"
mknod -m 600 dev/console c 5 1
mknod -m 600 dev/null c 1 3
mkdir mnt/etc mnt/jffs2 mnt/yaffs mnt/data mnt/temp
mkdir var/lib var/lock var/run var/tmp
chmod 777 tmp
chmod 777 var/tmp
echo "-------make direction done---------"
(3). 运行脚本执行:
sudo ./create_rootfs.sh
(4). 建立etc/inittab 系统init进程配置文件并更改权限
gedit etc/inittab
内容如下:
::sysinit:/etc/init.d/rcS
::askfirst:-/bin/sh #没有这就不行,就不能打开console控制台。
::restart:/sbin/init
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
::shutdown:/sbin/swapoff –a
chmod +x etc/inittab
(5). 建立etc/init.d/rcS系统启动加载项文件并更改权限
gedit etc/init.d/rcS
内容如下:
#!/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
runlevel=S
prevlevel=N
umask 022
export PATH runlevel prevlevel
mount -a
mkdir /dev/pts
mount -t devpts devpts /dev/pts #用于telnet登录时使用
echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s
mkdir -p /var/lock
/bin/hostname -F /etc/sysconfig/HOSTNAME
chmod +x etc/init.d/rcS
(6). 创建系统挂载文件系统列表文件
gedit etc/fstab
内容如下:
#device mount-point type option dump fsck order
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
mdev /dev ramfs defaults 0 0
none /var ramfs defaults 0 0
none /tmp ramfs defaults 0 0
(7). 用户环境配置文件
gedit etc/profile
内容如下:
# Ash profile
# vim: syntax= sh
# No core file by defaults
# ulimit - S - c 0> / dev/ null 2> & 1
USER="id -un"
LOGNAME=$USER
PS1="[\u@\h \w]#" #\w 目录将显示全路径
PATH=$PATH
HOSTNAME= '/bin/hostname'
alias cls="clear"
export USER LOGNAME PS1 PATH
(8). 用户文件以及密码
把主机的passwd shadow 文件拷贝到/etc下
cp /etc/passwd etc
cp /etc/group etc
cp /etc/shadow etc
(9). 修改主机名
gedit etc/sysconfig/HOSTNAME
然后键入自己的名字,如:OK6410
(10). 拷贝库文件
将交叉编译器下的lib下的库拷贝到lib文件夹下
cp/opt/OK6410/arm-linux-gcc/4.4.3/lib/* lib
3.6 配置内核
[*] Networking support --->
Networking options --->
<*> PF_KEY sockets
[*] TCP/IP networking
[*] IP: kernel levelautoconfiguration
File systems --->
[*] Network File Systems --->
<*> NFS clientsupport │ │
││ [*] NFS client support for NFS version 3 │ │
││ [*] NFS client support for the NFSv3 ACLprotocol extension│ │
││ [*] NFS client support for NFS version 4 │ │
││ [*] NFS client support for NFSv4.1(EXPERIMENTAL) │ │
││ [*] Root file system on NFS
3.7 修改uboot启动参数bootargs
默认的为:
bootargs=root=/dev/mtdblock2rootfstype=yaffs2 init=/linuxrc console=ttySAC0,115200
修改为:
setenv bootargsnoinitrd root=/dev/nfs ip=192.168.1.6:192.168.1.8:192.168.1.1:255.255.255.0::eth0:offnfsroot=192.168.1.8:/opt/OK6410/NFS/root_fs,nolock,proto=tcp console=ttySAC0,115200