硬件开发环境:
AT91SAM9261EK开发板,NandFlash启动。使用最新的
AT91Bootstrap 3.8.2+Uboot 2014.04。
因为NandFlash是128M的,需要修改Uboot 里nand的型号,添加128M的支持。
Linux version 2.6.26的内核,移植yaffs2文件系统,一直失败!因此,先使用cramfs文件系统,如果成功跑起来,至少说明文件系统的文件准备好了。
在driver/nandflash.c中,添加128MB NandFlash信息!!
/* Samsung K9F1G08U0A 128MB */
{0xecf1, 0x400, 0x20000, 0x800, 0x40, 0x0},
注意使用Cramfs根文件系统(简单,只读),需要修改Uboot里面的启动参数,这里修改:
include/configs/at91sam9261ek.h
/* bootstrap + u-boot + env + linux in nandflash */
#define CONFIG_ENV_IS_IN_NAND
#define CONFIG_ENV_OFFSET 0xc0000
#define CONFIG_ENV_OFFSET_REDUND 0x100000
#define CONFIG_ENV_SIZE 0x20000 /* 1 sector = 128 kB */
#define CONFIG_BOOTCOMMAND "nand read 0x22000000 0x200000 0x300000; bootm"
#define CONFIG_BOOTARGS \
"mem=64M console=ttyS0,115200 " \
"root=/dev/mtdblock5 rootfstype=cramfs"
#endif
加快网络的启动:
这里是DM9000的,取消
//#define CONFIG_RESET_PHY_R,这样会加快系统启动。
/* Ethernet */
#define CONFIG_DRIVER_DM9000
#define CONFIG_DM9000_BASE 0x30000000
#define DM9000_IO CONFIG_DM9000_BASE
#define DM9000_DATA (CONFIG_DM9000_BASE + 4)
#define CONFIG_DM9000_USE_16BIT
#define CONFIG_DM9000_NO_SROM
#define CONFIG_NET_RETRY_COUNT 20
//#define CONFIG_RESET_PHY_R
内核增加NandFlash的分区。
arch/arm/mach-at91/board-sam9261ek.c
/*
* NAND flash
*/
static struct mtd_partition __initdata ek_nand_partition[] = {
{
.name = "bootstrap",
.offset = 0,
.size = SZ_256K,
},
{
.name = "uboot",
.offset = 0x40000,
.size = SZ_256K,
},
{
.name = "env1",
.offset = 0x80000,
.size = SZ_256K,
},
{
.name = "env2",
.offset = 0xa0000,
.size = SZ_256K,
},
{
.name = "kernel",
.offset = 0x200000,
.size = SZ_2M,
},
{
.name = "rootfs",
.offset = 0x800000,
.size = MTDPART_SIZ_FULL,
},
};
RomBOOT
AT91Bootstrap 3.8.2 (Tue Feb 23 22:43:35 CST 2016)
NAND: ONFI not supported
NAND: Manufacturer ID: 0xec Chip ID: 0xf1
NAND: Disable On-Die ECC
NAND: Using Software ECC
NAND: Image: Copy 0x80000 bytes from 0x40000 to 0x21f00000
NAND: Done to load image
U-Boot 2014.04 (Feb 26 2016 - 22:17:46)
CPU: AT91SAM9261
Crystal frequency: 18.432 MHz
CPU clock : 198.656 MHz
Master clock : 99.328 MHz
DRAM: 64 MiB
WARNING: Caches not enabled
NAND: 128 MiB
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
Net: dm9000
Hit any key to stop autoboot: 0
NAND read: device 0 offset 0x200000, size 0x300000
3145728 bytes read: OK
## Booting kernel from Legacy Image at 22000000 ...
Image Name: Linux-2.6.26-AT91
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1186904 Bytes = 1.1 MiB
Load Address: 20008000
Entry Point: 20008000
Verifying Checksum ... OK
Loading Kernel Image ... OK
Starting kernel ...
Uncompressing Linux.............................................................................. done, booting the kernel.
Linux version 2.6.26-AT91 (root@zhangsz) (gcc version 4.4.1 (Sourcery G++ Lite 2010q1-202) ) #6 Fri Feb 26 21:34:34 CST 2016
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177
Machine: Atmel AT91SAM9261-EK
Memory policy: ECC disabled, Data cache writeback
Clocks: CPU 198 MHz, master 99 MHz, main 18.432 MHz
CPU0: D VIVT write-back cache
CPU0: I cache: 16384 bytes, associativity 4, 32 byte lines, 128 sets
CPU0: D cache: 16384 bytes, associativity 4, 32 byte lines, 128 sets
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
Kernel command line: mem=64M console=ttyS0,115200 root=/dev/mtdblock5 rootfstype=cramfs
AT91: 96 gpio irqs in 3 banks
PID hash table entries: 256 (order: 8, 1024 bytes)
Console: colour dummy device 80x30
console [ttyS0] enabled
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 62396KB available (2164K code, 195K data, 108K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
net_namespace: 192 bytes
NET: Registered protocol family 16
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
NET: Registered protocol family 1
NetWinder Floating Point Emulator V0.97 (double precision)
msgmni has been set to 121
io scheduler noop registered
io scheduler anticipatory registered (default)
atmel_usart.0: ttyS0 at MMIO 0xfefff200 (irq = 1) is a ATMEL_SERIAL
brd: module loaded
ssc ssc.1: Atmel SSC device at 0xc4810000 (irq 15)
dm9000 Ethernet Driver, V1.30
dm9000 dm9000.0: eth%d: Invalid ethernet MAC address. Please set using ifconfig
eth0: dm9000 at c480c000,c480e044 IRQ 107 MAC: 00:00:00:00:00:00 (chip)
Driver 'sd' needs updating - please use bus_type methods
NAND device: Manufacturer ID: 0xec, Chip ID: 0xf1 (Samsung NAND 128MiB 3,3V 8-bit)
Scanning device for bad blocks
Bad eraseblock 446 at 0x037c0000
Bad eraseblock 994 at 0x07c40000
Creating 6 MTD partitions on "at91_nand":
0x00000000-0x00040000 : "bootstrap"
0x00040000-0x00080000 : "uboot"
0x00080000-0x000c0000 : "env1"
0x000a0000-0x000e0000 : "env2"
0x00200000-0x00400000 : "kernel"
0x00800000-0x08000000 : "rootfs"
atmel_spi atmel_spi.0: Atmel SPI Controller at 0xfffc8000 (irq 12)
usbmon: debugfs is not available
at91_ohci at91_ohci: AT91 OHCI
at91_ohci at91_ohci: new USB bus registered, assigned bus number 1
at91_ohci at91_ohci: irq 20, io mem 0x00500000
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
udc: at91_udc version 3 May 2006
mice: PS/2 mouse device common for all mice
input: gpio-keys as /class/input/input0
ads7846 spi0.2: touchscreen, irq 29
input: ADS784x Touchscreen as /class/input/input1
rtc-at91sam9 at91_rtt.0: rtc core: registered at91_rtt as rtc0
rtc-at91sam9 at91_rtt.0: rtc0: SET TIME!
i2c /dev entries driver
i2c-gpio i2c-gpio: using pins 39 (SDA) and 40 (SCL)
Registered led device: ds7
Registered led device: ds8
Registered led device: ds1
TCP cubic registered
NET: Registered protocol family 17
rtc-at91sam9 at91_rtt.0: hctosys: unable to read the hardware clock
VFS: Mounted root (cramfs filesystem) readonly.
Freeing init memory: 108K
#-----Start /etc/init.d/rcS
mkdir: cannot create directory '/var/lock': Read-only file system
------------*******AT91SAM9261EK-Linux 2016-02-26***********------------
ifconfig: SIOCSIFFLAGS: Cannot assign requested address
AT91 login: root
Password:
login[774]: root login on 'ttyS0'
[root@AT91 /]# ls
bin dev home linuxrc proc sbin tmp var
boot etc lib mnt root sys usr
[root@AT91 /]# cd home/
[root@AT91 /home]# ls
[root@AT91 /home]# cd ..
[root@AT91 /]# l
-sh: l: not found
[root@AT91 /]# ls
bin dev home linuxrc proc sbin tmp var
boot etc lib mnt root sys usr
[root@AT91 /]#
以上是重新上电运行的信息,这个cramfs是只读的文件系统,因此只能测试一下,还需要进一步使用yaffs2 jffs2 ubi等可以写的nandflash文件系统。
总结:有了一步,就有以后的千千万万步,不能被眼前的小沙子挡住去路。如果前面有墙,找不到出口,我们就要拆墙,打开出口。才能见到更大的外面的世界!