嵌入式 hi3518a裸板在nandflash上烧写uboot以及kernel以及文件系统

1、首先还是使用axd以及jlink完成内存初始化。

hi3518a 256M ddr3 init script:

{

setmem 0x20030000 0x11000000 32
setmem 0x20030004 0x0068306E 32
setmem 0x20030008 0x12000000 32
setmem 0x2003000c 0x007C2063 32
setmem 0x20030010 0x19000000 32
setmem 0x20030014 0x00682064 32
setmem 0x20030020 0x1B000000 32
setmem 0x20030024 0x007C40E1 32
setmem 0x20030028 0x00000010 32
setmem 0x2011001c 0x80000600 32

setmem 0x20030028 0x00000410 32
setmem 0x2011001c 0x80000600 32

setmem 0x20050014 0x0fff8000 32
setmem 0x2011001c 0x80000600 32

setmem 0x10000004 0x00000aaa 32
setmem 0x20050000 0x00000214 32
setmem 0x2011001c 0x80000600 32

setmem 0x2011001c 0x80000600 32
setmem 0x20110020 0x00000785 32
setmem 0x20110058 0x3241B000 32 
setmem 0x20110010 0x00000001 32
setmem 0x2011002c 0x00000132 32
setmem 0x20110040 0x80000000 32
setmem 0x20110050 0x62330a08 32
setmem 0x20110054 0xff626721 32
setmem 0x2011005c 0xffcff5f2 32
setmem 0x201100ac 0x03000001 32
setmem 0x2011001c 0x80000600 32

setmem 0x201100f4 0x00000001 32
setmem 0x20110004 0x00000000 32
setmem 0x2011001c 0x80000600 32

setmem 0x20120404 0x80000000 32
setmem 0x2011001c 0x80000600 32

setmem 0x20120408 0x01842202 32
setmem 0x20120418 0x00220055 32
setmem 0x2012041c 0x048b0d41 32
setmem 0x20120420 0x03233881 32
setmem 0x2012042c 0xf200001e 32
setmem 0x20120434 0x288f6693 32
setmem 0x20120438 0x005600DB 32
setmem 0x2012043c 0x1001aa00 32
setmem 0x20120584 0x0000006d 32
setmem 0x20120440 0x00001730 32
setmem 0x20120444 0x00000006 32
setmem 0x20120448 0x00000008 32
setmem 0x2011001c 0x80000600 32

setmem 0x201205c0 0x00000e81 32
setmem 0x20120600 0x00000e81 32
setmem 0x2011001c 0x80000600 32

setmem 0x20120404 0x000000ff 32
setmem 0x2011001c 0x80000600 32

setmem 0x20110058 0x3241B062 32
setmem 0x20120408 0x01842200 32
setmem 0x2011001c 0x80000600 32

}

2、进行烧写uboot laodbin f:\3518a.bin  0x80800000

setpc 0x80800000 ;go


在海思的平台上需要进行的步骤是:

2.1、依据内存初始化流程,把对应的寄存的值进行修改,主要是刷新周期、ddr特性也即是行列地址位宽大约5个reg需要修改,这样把实际值添加到海思提供的“.xlsm”表格中的ddr_init中。

2.2、依据nand手册中实际的nand属性id、pagesize、blocksize、oobsize等实际值添加到海思提供的“.xlsm”表格中的flashtype中。

2.3、使用“.xlsm”生成reg_info.bin ,然后使用下面命令完成uboor制作:

{

make ARCH=arm CROSS_COMPILE=arm-hisiv100nptl-linux- clean
#make ARCH=arm CROSS_COMPILE=arm-hisiv100nptl-linux- hi3518a_config
make ARCH=arm CROSS_COMPILE=arm-hisiv100nptl-linux-
./mkboot.sh reg_info_hi3518a.bin uboot-3518a.bin
sz uboot-3518a.bin

}

2.4、这时可以直接烧写到nand了。幸运的话就可以看到打印信息了:

{

U-Boot 2010.06 (Jun 26 2014 - 16:26:25)
NAND:  Special Nand id table Version 1.35
Nand ID: 0x2C 0xDA 0x90 0x95 0x06 0x00 0x00 0x00
Nand(Hardware): Block:128KB Page:2KB Chip:256MB*1 OOB:64B ECC:1bit/512Byte 
256 MiB
Check spi flash controller v350... Found
Can't find a valid spi flash chip.
Can't find a valid spi flash chip.
*** Warning - bad CRC or NAND, using default environment
In:    serial
Out:   serial
Err:   serial
Hit any key to stop autoboot:  0 

}

3、有时会在nandflash写的时候会出现nand write FAILD!如果是第一次使用nandflash只好用nand scrub清除假坏块。当然也可以使用nand bad查看坏块信息,其中nand erase的时候会标记坏块,由MTD完成。下面看一下我的uboot nand 挂载yaffs2的坏境变量:

{

njqy_ipnc # printenv
bootargs=mem=192M console=ttyAMA0,115200 root=/dev/mtdblock2 rootfstype=yaffs2 init=/sbin/init mtdparts=hinand:1M(boot),5M(kernel),125M(firstfs),125M(secondfs)
bootcmd=nand read 0x82000000 0x100000 500000;bootm 0x82000000
bootdelay=1
baudrate=115200
ethaddr=00:00:23:34:45:66
ipaddr=10.10.1.56
serverip=10.10.1.103
netmask=255.255.255.0
bootfile="uImage"
stdin=serial
stdout=serial
stderr=serial
verify=n
ver=U-Boot 2010.06 (Jun 26 2014 - 16:26:25)
Environment size: 449/262140 bytes
njqy_ipnc # 

}

然后我们看一下uboot中nand常用命令:
3.1、Nand write:

用于向NAND Flash中写入数据。
用法:nand write mem_addr start_offset count 
举例: 
tftp 0x82000000 u-boot.bin<将 u-boot.bin 下载到内存中>nand write 0x82000000 0x0 0x100000<将内存中起始地址为0x82000000 中的内容写入 nandflash 偏移地址为 0 的地方,大小为0x100000。 

3.2、Nand write.yaffs:

专用于向NAND Flash中下载YAFFS2文件系统。 
用法:nand write.yaffs mem_addrstart_offset fs_size 
举例: 
tftp 0x82000000 rootfs-FULL_REL-Flash.yaffs2
nand write.yaffs 0x82000000 0x300000 0x702600 <这个参数是YAFFS2文件系统镜像的实际文件长度,注意这里是16进制的数>
说明:
tftp 82000000rootfs-FULL_REL-Flash.yaffs2扫行完之后,会打印出
Bytes transferred = 7809760 (702600 hex)。参数fs_size需要是YAFFS2文件系统的实际大小,否则会出错,其它参数含义同Nand write

3.3 Nand scrub清除假坏块,以及nand read、nand dump、nand bad、nand erase等可以网上细看。

到此为止我板子就可以运行uboot、kernel、fs了,开始进行上层应用以及IO驱动开发了…………

附录:烧写小结记录

{

HI3518A:
uboot env: ddr3 256 --> system 192;dsp 64
1、setenv bootargs mem=192M console=ttyAMA0,115200 root=/dev/mtdblock2 rootfstype=yaffs2 mtdparts=hinand:1M(boot),5M(kernel),81M(firstfs),41M(secondfs)(128M)
   setenv bootargs mem=192M console=ttyAMA0,115200 root=/dev/mtdblock2 rootfstype=yaffs2 mtdparts=hinand:1M(boot),5M(kernel),125M(oldfs),125M(newfs)(256M)
2、setenv bootcmd nand read 0x82000000 0x100000 500000\;bootm 0x82000000
3、init=/sbin/init init=/linuxrc
setenv bootargs noinitrd mem=192M console=ttyAMA0,115200 root=/dev/mtdblock2 rootfstype=yaffs2 mtdparts=hinand:1M(boot),5M(kernel),81M(firstfs),41(secondfs);saveenv;reset
setenv bootargs noinitrd mem=192M console=ttyAMA0,115200 root=/dev/mtdblock2 rw rootfstype=yaffs2 init=/sbin/init mtdparts=hinand:1M(boot)ro,5M(kernel),125M(oldfs),125M(newfs);saveenv;reset
setenv bootargs noinitrd mem=192M console=ttyAMA0,115200 root=/dev/mtdblock2 rootfstype=jffs2 mtdparts=hinand:1M(boot),5M(kernel),101M(firstfs),21M(secondfs);saveenv;reset

wirte to flash note:
uboot: size 1M 
1.1 com:
nand erase 0x0 0x100000;mw.b 0x82000000 ff 0x100000;loadb 0x82000000;nand write 0x82000000 0x0 0x100000;reset
1.2 tftp:
nand erase 0x0 0x100000;mw.b 0x82000000 ff 0x100000;tftp 0x82000000 uboot-3518a.bin;nand write 0x82000000 0x0 0x100000;reset

kernel: size 5M
1.1 com:
nand erase 0x100000 0x500000;mw.b 0x82000000 ff 0x500000;loadb 0x82000000;nand write 0x82000000 0x100000 0x500000;reset
1.2 tftp:
setenv serverip 10.10.1.103;setenv netmask 255.255.255.0;setenv gatewayip 10.10.1.1;saveenv;ping 10.10.1.103
nand erase 0x100000 0x500000;mw.b 0x82000000 ff 0x500000;tftp 0x82000000 uImage;nand write 0x82000000 0x100000 0x500000;reset

fs: size 81M
make_yaffs2:
1、mkyaffs2image ./rootfs ./yaffs2-root.img pagesize ecctype
mkyaffs2image ./joseph_rootfs/  rootfs_f00000_last_yaffs2.img 2k 4bit
write_yaffs2:
1.1 com:
(18.2M:0x1246440):
nand erase 0x600000 0x5100000;mw.b 0x82000000 ff 0x1246440;loadb 0x82000000;nand write.yaffs 0x82000000 0x600000 0x1246440;reset (128M,81M,20M)
nand erase 0x600000 0x7D00000;mw.b 0x82000000 ff 0x1246440;loadb 0x82000000;nand write.yaffs 0x82000000 0x600000 0x1246440;reset (256M,125M,20M)
1.2 tftp:
setenv serverip 10.10.1.103;setenv netmask 255.255.255.0;setenv gatewayip 10.10.1.1;saveenv;ping 10.10.1.103
nand erase 0x600000 0x5100000;mw.b 0x82000000 ff 0x1400000;tftp 0x82000000 uImage;nand write.yaffs 0x82000000 0x600000 0x1400000;reset

mkfs.jffs2 -d ./joseph_rootfs/ -l -e 0x21000 --pad=0xCF0000 -o rootfs_kj_last.jffs2

HI3518A NandFlsh 256M 2k 1bit:
uboot env-->
{
bootdelay=1
baudrate=115200
ethaddr=00:00:23:34:45:66
serverip=192.168.1.2
netmask=255.255.255.0
bootfile="uImage"
ipaddr=10.10.1.56
bootcmd=nand read 0x82000000 0x100000 500000;bootm 0x82000000
bootargs=noinitrd mem=192M console=ttyAMA0,115200 root=/dev/mtdblock2 rw rootfstype=yaffs2 init=/sbin/init mtdparts=hinand:1M(boot)ro,5M(kernel),125M(firstfs),125M(secondfs)
stdin=serial
stdout=serial
stderr=serial
verify=n
ver=U-Boot 2010.06 (Jun 25 2014 - 13:30:35)
Environment size: 458/262140 bytes
}

}

你可能感兴趣的:(嵌入式 hi3518a裸板在nandflash上烧写uboot以及kernel以及文件系统)