nand相关

以下部分内容摘自:https://blog.csdn.net/tongxin1101124/article/details/110231562
(有现成的东西,嘻嘻嘻,搬运一下,防止到时候删了,哈哈哈)
一、pmon下通过devcp文件系统和内核镜像放到nand分区操作流程
1、启动到pmon命令行下(vmlinuz为编入ramdisk的内核)

    a、mtd_erase /dev/mtd0r
    b、set append "console=ttyS0,115200 rdinit=/sbin/init"
    c、set al1 /dev/mtd0
    d、devcp tftp://ip/vmlinuz /dev/mtd0
    e、重启

二、pmon下通过devcp文件系统和内核镜像放到nand分区操作流程

    a、mtd_erase /dev/mtd0r
    b、mtd_erase /dev/mtd1r
    c、set append "console=ttyS0,115200 init=/linuxrc rw root=/dev/mtdblock1 rootfstype=yaffs2"
    d、set al1 /dev/mtd0
    e、devcp tftp://ip/vmlinuz /dev/mtd0
    f、devcp tftp://ip/rootfs.img /dev/mtd1y
    g、重启

三、通过解压方式将文件系统放到nand分区操作流程

    a、内核放到mtd0分区
    b、文件系统放到mtd1分区
    c、vmlinuz 不带文件系统
    d、vmlinuz-ramdisk 带文件系统
    e、rootfs.tar.gz文件系统压缩包

1、启动到pmon命令行下

    a、mtd_erase /dev/mtd0r
    b、mtd_erase /dev/mtd1r
    c、set append "console=ttyS0,115200 init=/linuxrc rw root=/dev/mtdblock1 rootfstype=yaffs2"
    d、set al1 /dev/mtd0
    e、devcp tftp://ip/vmlinuz /dev/mtd0
    
    f、load tftp://ip/vmlinuz-ramdisk
    g、g console=ttyS0,115200 rdinit=/sbin/init

2、启动到内核下

    a、将rootfs.tar.gz拷贝(通过U盘或tftp)到系统下解压
            tar -zxvf rootfs.tar.gz
    b、挂载mtdblock1分区
            mount -t yaffs2 /dev/mtdblock1 /mnt/
    c、将解压出来的文件系统拷贝到mnt目录下
            cp rootfs/*  /mnt -ad
    d、拷贝完成后卸载重启

四、通过解压方式将文件系统和内核放到nand分区操作流程

    a、内核放到mtd0分区
    b、文件系统放到mtd1分区
    c、vmlinuz 不带文件系统
    d、vmlinuz-ramdisk 带文件系统
    e、rootfs.cpio.gz文件系统压缩包

1、启动到pmon命令行下

    a、mtd_erase /dev/mtd0r
    b、mtd_erase /dev/mtd1r
    c、set append "console=ttyS0,115200"
    d、set al1 /dev/fs/yaffs2@mtd0/vmlinuz
    e、set rd  /dev/fs/yaffs2@mtd1/rootfs.cpio.gz
    
    f、load tftp://ip/vmlinuz-ramdisk
    g、g console=ttyS0,115200 rdinit=/sbin/init

2、启动到内核下

    a、挂载mtdblock0分区
     	mount -t yaffs2 /dev/mtdblock0  /mnt/
    b、将vmlinuz拷贝(通过U盘或tftp)到系统mnt目录下
        cp  .../vmlinuz  /mnt
    c、拷贝完成后卸载
     	umount /mnt/
    d、挂载mtdblock1分区
     	mount -t yaffs2 /dev/mtdblock1 /mnt/
    e、将rootfs.cpio.gz拷贝(通过U盘或tftp)到系统mnt目录下
  	 	cp  .../rootfs.cpio.gz  /mnt
    f、拷贝完成后卸载
    	umount /mnt/
    g、重启
    	reboot

以上内容比较简单,暂不介绍,把分区文件系统制作成img文件是通过mkyaffs2image工具做的,也就是yaffs2文件系统同目录下的utils目录里的工具;此工具负责把rootfs进行页和oob对齐,生成Img文件,默认支持的nand是页2048,oob 64,如果其他nand需要修改配置文件;
以下内容摘自https://blog.csdn.net/tongxin1101124/article/details/90034565
mkyaffs2image工具制作及龙芯板卡使用yaffs2系统

mkyaffs2image工具制作
龙芯板卡使用yaffs2文件系统

mkyaffs2image工具制作
制作yaffs2文件系统时会用到mkyaffs2image工具,系统下默认没有这个工具,需要找到源码制作,源码如下:
http://sources.buildroot.net/yaffs2utils/0.2.9.tar.gz
下载完,解压0.2.9.tar.gz
进入目录下编译: make
编译出需要的工具 mkyaffs2、unyaffs2

sudo chmod 777 mkyaffs2
sudo chmod 777 unyaffs2
sudo cp  mkyaffs2  unyaffs2  /usr/bin/
sudo  mkyaffs2
mkyaffs2 0.2.9 - A utility to make the yaffs2 image

Usage: mkyaffs2 [-h|--help] [-e|--endian] [-v|--verbose]
                [-p|--pagesize pagesize] [-s|sparesize sparesize]
                [-o|--oobimg oobimage] [--all-root] [--yaffs-ecclayout]
                dirname imgfile

Options:
  -h                 display this help message and exit.
  -e                 convert endian differed from local machine.
  -v                 verbose details instead of progress bar.
  -p pagesize        page size of target device.
                     (512|2048(default)|4096|(8192|16384) bytes)
  -s sparesize       spare size of target device.
                     (default: pagesize/32 bytes; max: pagesize)
  -o oobimage        load external oob image file.
  --all-root         all files in the target system are owned by root.
  --yaffs-ecclayout  use yaffs oob scheme instead of the Linux MTD default.
表明安装成功,同时也可以看到该命令的用法

    例如:mkyaffs2 -p 4096 -s 128 --yaffs-ecclayout rootfs/ rootfs.img

龙芯板卡使用yaffs2文件系统

假设nand分两个分区,内核放到mtd0分区;呀文件系统放到mtd1分区;用uart0
A、启动到pmon命令行下,通过tftp或者U盘将内核放到指定分区里

    	PMON> mtd_erase /dev/mtd0r
    	PMON> devcp tftp://ip/vmlinux /dev/mtd0

B、将yaffs2文件系统镜像rootfs.img放到指定分区里

		PMON> mtd_erase /dev/mtd1r
    	PMON> devcp tftp://ip/rootfs.img /dev/mtd1y

C、设置环境变量

		PMON> set al /dev/mtd0   或  set al1 /dev/mtd0   	
		PMON> set append "console=ttyS0,115200 init=/linuxrc rw  root=/dev/mtdblock1 rootfstype=yaffs2"

D、重新上电
补充一下,下面是我个人整理的内核下烧录方法,方便客户实现自动化脚本烧录,批量板卡
1.擦除

./flash_erase /dev/mtd1 0 128

2.烧录

/ # ./nandwrite -o -a -s 0x20000 /dev/mtd1 yaffs.img 
Writing data to block 1 at offset 0x20000
Writing data to block 2 at offset 0x40000
Writing data to block 3 at offset 0x60000
Writing data to block 4 at offset 0x80000
Writing data to block 5 at offset 0xa0000
Writing data to block 6 at offset 0xc0000
Writing data to block 7 at offset 0xe0000
Writing data to block 8 at offset 0x100000
Writing data to block 9 at offset 0x120000
Writing data to block 10 at offset 0x140000
Writing data to block 11 at offset 0x160000
Writing data to block 12 at offset 0x180000
Writing data to block 13 at offset 0x1a0000
Writing data to block 14 at offset 0x1c0000
Writing data to block 15 at offset 0x1e0000
Writing data to block 16 at offset 0x200000
Writing data to block 17 at offset 0x220000
Writing data to block 18 at offset 0x240000
Writing data to block 19 at offset 0x260000
Writing data to block 20 at offset 0x280000
Writing data to block 21 at offset 0x2a0000
Writing data to block 22 at offset 0x2c0000
Writing data to block 23 at offset 0x2e0000
Writing data to block 24 at offset 0x300000
Writing data to block 25 at offset 0x320000
Writing data to block 26 at offset 0x340000
Writing data to block 27 at offset 0x360000
Writing data to block 28 at offset 0x380000
Writing data to block 29 at offset 0x3a0000
Writing data to block 30 at offset 0x3c0000
Writing data to block 31 at offset 0x3e0000
Writing data to block 32 at offset 0x400000
Writing data to block 33 at offset 0x420000
Writing data to block 34 at offset 0x440000
Writing data to block 35 at offset 0x460000
Writing data to block 36 at offset 0x480000
Writing data to block 37 at offset 0x4a0000
Writing data to block 38 at offset 0x4c0000
Writing data to block 39 at offset 0x4e0000
Writing data to block 40 at offset 0x500000
Writing data to block 41 at offset 0x520000
Writing data to block 42 at offset 0x540000
Writing data to block 43 at offset 0x560000
Writing data to block 44 at offset 0x580000
Writing data to block 45 at offset 0x5a0000
Writing data to block 46 at offset 0x5c0000
Writing data to block 47 at offset 0x5e0000
Writing data to block 48 at offset 0x600000
Writing data to block 49 at offset 0x620000
Writing data to block 50 at offset 0x640000
Writing data to block 51 at offset 0x660000
Writing data to block 52 at offset 0x680000
Writing data to block 53 at offset 0x6a0000
Writing data to block 54 at offset 0x6c0000
Writing data to block 55 at offset 0x6e0000
Writing data to block 56 at offset 0x700000
Writing data to block 57 at offset 0x720000
Writing data to block 58 at offset 0x740000
Writing data to block 59 at offset 0x760000
Writing data to block 60 at offset 0x780000
Writing data to block 61 at offset 0x7a0000
Writing data to block 62 at offset 0x7c0000
Writing data to block 63 at offset 0x7e0000
Writing data to block 64 at offset 0x800000
Writing data to block 65 at offset 0x820000
Writing data to block 66 at offset 0x840000
Writing data to block 67 at offset 0x860000
Writing data to block 68 at offset 0x880000
Writing data to block 69 at offset 0x8a0000
Writing data to block 70 at offset 0x8c0000
Writing data to block 71 at offset 0x8e0000
Writing data to block 72 at offset 0x900000
Writing data to block 73 at offset 0x920000
Writing data to block 74 at offset 0x940000
Writing data to block 75 at offset 0x960000
Writing data to block 76 at offset 0x980000
Writing data to block 77 at offset 0x9a0000
Writing data to block 78 at offset 0x9c0000
Writing data to block 79 at offset 0x9e0000
Writing data to block 80 at offset 0xa00000
Writing data to block 81 at offset 0xa20000
Writing data to block 82 at offset 0xa40000
Writing data to block 83 at offset 0xa60000
Writing data to block 84 at offset 0xa80000
Writing data to block 85 at offset 0xaa0000
Writing data to block 86 at offset 0xac0000
Writing data to block 87 at offset 0xae0000
Writing data to block 88 at offset 0xb00000
Writing data to block 89 at offset 0xb20000
Writing data to block 90 at offset 0xb40000
Writing data to block 91 at offset 0xb60000
Writing data to block 92 at offset 0xb80000
Writing data to block 93 at offset 0xba0000
Writing data to block 94 at offset 0xbc0000
Writing data to block 95 at offset 0xbe0000
Writing data to block 96 at offset 0xc00000
Writing data to block 97 at offset 0xc20000
Writing data to block 98 at offset 0xc40000
Writing data to block 99 at offset 0xc60000
Writing data to block 100 at offset 0xc80000
Writing data to block 101 at offset 0xca0000
Writing data to block 102 at offset 0xcc0000
Writing data to block 103 at offset 0xce0000
Writing data to block 104 at offset 0xd00000
Writing data to block 105 at offset 0xd20000
Writing data to block 106 at offset 0xd40000
Writing data to block 107 at offset 0xd60000
Writing data to block 108 at offset 0xd80000
Writing data to block 109 at offset 0xda0000
Writing data to block 110 at offset 0xdc0000
Writing data to block 111 at offset 0xde0000
Writing data to block 112 at offset 0xe00000
Writing data to block 113 at offset 0xe20000
Writing data to block 114 at offset 0xe40000
Writing data to block 115 at offset 0xe60000
Writing data to block 116 at offset 0xe80000
Writing data to block 117 at offset 0xea0000
Writing data to block 118 at offset 0xec0000
Writing data to block 119 at offset 0xee0000
/ # 
/ # 
/ # mount -t yaffs2 /dev/mtdblock1 /mnt
[  907.477451] yaffs: dev is 32505857 name is "mtdblock1" rw
[  907.482937] yaffs: passed flags ""
/ # ls /mnt
bin             linuxrc         mtdpart         stressapptest
dev             lost+found      nanddump        sys
etc             mkfs.jffs2      nandtest        tmp
flash_erase     mkfs.ubifs      nandwrite       ubiattach
flash_otp_dump  mnt             proc            ubiformat
flash_otp_info  mnt1            sbin            ubimkvol
flashcp         mtd_debug       serial.rd       ubinfo
lib             mtdinfo         serial.wr       usr

烧录成功后,挂载查看,若文件正常,则为烧录成功,有一点需要注意,img文件要整页整oob对齐;
启动其他文件系统:

yaffs 文件系统的制作及启动
	cp vmlinux /home/tftpboot/
	./mkfs.yaffs2 rootfs rootfs.img
	备注:rootfs 为文件系统的名字 rootfs.img 为制作的 yaffs 文件格式的文件系统
	cp rootfs.img /home/tftpboot/
	chmod 777 /home/tftpboot/rootfs.img
	
	板卡上电,启动到pmon命令行下,执行以下指令
	ifconfig syn0 192.168.1.1   
	向开发板上的 nand 烧写文件系统的命令
	devcp tftp://192.168.1.100/rootfs.img /dev/mtd1y   
	备注:烧写到 nand 的分区 1,若烧到分区 0,改为 mtd0y,做好烧写到分区 1
	load tftp://192.168.1.100/vmlinux
	g console=ttyS0,115200 init=/linuxrc rootfstype=yaffs2 rw root=/dev/mtdblock1
cramfs 文件系统的制作和启动
	cp vmlinux /home/tftpboot/
	mkfs.cramfs -b 16384 rootfs cramfs.imgs
	备注:-b 参数,大小与 PAGE_SIZE(linux 内核的配置)一样,具体-b 的实际意义
	通过 man mkfs.cramfs 查看
	cp cramfs.imgs /home/tftpboot/
	chmod 777 /home/tftpboot/cramfs.imgs
	
	板卡上电,启动到pmon命令行下,执行以下指令
	ifconfig syn0 192.168.1.1   
	devcp tftp://192.168.1.100/cramfs.imgs /dev/mtd1
	load tftp://192.168.1.100/vmlinux
	g console=ttyS0,115200 init=/linuxrc rootfstype=cramfs rw root=/dev/mtdblock1
	
jffs2 文件系统的制作和启动
	cp vmlinux /home/tftpboot/
	mkfs.jffs2 -r rootfs -o rootfs.jffs2 -e 0x10000 -s 0x100
	备注:-r:指定要生成 image 的目录名。
			-o:指定输出 image 的文件名。
			-e:每一块要擦除的 block size,不同的 flash, block size 会不一样。这里为 64KB。
			-s:节点页大小 这里为256字节
	通过 man mkfs.jffs2查看
	cp rootfs.jffs2 /home/tftpboot/
	chmod 777 /home/tftpboot/rootfs.jffs2
	
	板卡上电,启动到pmon命令行下,执行以下指令
	ifconfig syn0 192.168.1.1   
	mtd_erase /dev/mtd1 -j
	devcp tftp://192.168.1.100/rootfs.jffs2 /dev/mtd1
	load tftp://192.168.1.100/vmlinux
	g console=ttyS0,115200  init=/linuxrc rootfstype=jffs2 rw root=/dev/mtdblock1
	
已标记关键词 清除标记
【为什么还需要学习C++?】 你是否接触很多语言,但从来没有了解过编程语言的本质? 你是否想成为一名资深开发人员,想开发别人做不了的高性能程序? 你是否经常想要窥探大型企业级开发工程的思路,但苦于没有基础只能望洋兴叹?   那么C++就是你个人能力提升,职业之路进阶的不二之选。 【课程特色】 1.课程共19大章节,239课时内容,涵盖数据结构、函数、类、指针、标准库全部知识体系。 2.带你从知识与思想的层面从0构建C++知识框架,分析大型项目实践思路,为你打下坚实的基础。 3.李宁老师结合4大国外顶级C++著作的精华为大家推出的《征服C++11》课程。 【学完后我将达到什么水平?】 1.对C++的各个知识能够熟练配置、开发、部署; 2.吊打一切关于C++的笔试面试题; 3.面向物联网的“嵌入式”和面向大型化的“分布式”开发,掌握职业钥匙,把握行业先机。 【面向人群】 1.希望一站式快速入门的C++初学者; 2.希望快速学习 C++、掌握编程要义、修炼内功的开发者; 3.有志于挑战更高级的开发项目,成为资深开发的工程师。 【课程设计】 本课程包含3大模块 基础篇 本篇主要讲解c++的基础概念,包含数据类型、运算符等基本语法,数组、指针、字符串等基本词法,循环、函数、类等基本句法等。 进阶篇 本篇主要讲解编程中常用的一些技能,包含类的高级技术、类的继承、编译链接和命名空间等。 提升篇: 本篇可以帮助学员更加高效的进行c++开发,其中包含类型转换、文件操作、异常处理、代码重用等内容。
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页