Longxin 1, 2, 3 Processors nand Use Tutorial

Longxin 1, 2, 3 Processors nand Use Tutorial

nand is divided into: nand interface and spi interface, spi interface is divided into spi norflash and spi nandflash

Using LS2K as an example, describe usage routines under pmon and kernel

1. Tutorials under PMON

1. ls2k pmon source acquisition path

	ftp://ftp.loongnix.org/embedd/ls2k/pmon-loongson3.tar.gz

2. pmon source code and nand related files

	a,sys/dev/nand/ls2k-nand.c
	b,sys/dev/nand/spinand_lld.c
	c,sys/dev/nand/m25p80.c
	d,Targets/LS2K/conf/ls2k
	e,Targets/LS2K/ls2k/tgt_machdep.c
	f,Targets/LS2K/include/pmon_target.h

3. The type of nand selected in the pmon configuration file (Targets/LS2K/conf/ls2k)

	a,If you are using nand Interface nand The options are:
		Select  nand
		Option  CONFIG_LS2K_NAND
	b,If used spi Interface nand The options are:
		Select  nand
		Select  spinand_mt29f
	c,If used spi Interface nor flash The options are:
		Select  m25p80

4. nand partition under pmon

	1. Modify Source Adjustment Partition
		Targets/LS2K/include/pmon_target.h
			#define TGT_DEFENV  {"mtdparts","nand-flash:30M@0(kernel),-(rootfs);spinand_flash:30M@0(kernel),-(rootfs)",0,&mtd_rescan},   \
                     {"bootdelay","3",0,0}   
 	2. Command modification under pmon command line
 		set mtdparts "nand-flash:30M@0(kernel),-(rootfs);spinand_flash:30M@0(kernel),-(rootfs)"

	Note: Keep pmon s consistent with kernel partitions!!!

5. Use under pmon

	a,Erase
		mtd_erase /dev/mtd0r			Note: 0 represents the partition, r Suffix means erase does not skip bad fast
	b,Write data
		devcp tftp://Ser-ip/vmlinux/dev/mtd0 Remarks: Write the kernel image into partition 0
		devcp tftp://Server-ip/roofs-yaffs2.img/dev/mtd1y Note: y suffix means write in yaffs2 format
	c,read
		load /dev/mtd0			Note: Read data from partition 0 to memory

2. Using tutorials under the kernel

1. ls2k Kernel Source Getting Path

	ftp://ftp.loongnix.org/embedd/ls2k/linux-3.10.tar.gz

2. Kernel Source and nand Related Files

	a,drivers/mtd/nand/ls-nand.c
	b,drivers/mtd/nand/spinand_lld.c
	c,drivers/mtd/devices/m25p80.c

3. Select nand type for kernel configuration (make menuconfig ARCH=mips)

	a,If you are using nand Interface nand The options are:
		CONFIG_MTD_NAND_LS
	b,If used spi Interface nand The options are:
		CONFIG_MTD_SNAND_MT29F 		
	c,If used spi Interface nor flash The options are:
		CONFIG_MTD_M25P80

4. Undercore nand partition

	Subkernel nand Partitions are partitioned by device tree, which is used by default pmon ( Targets/LS2K/conf/LS2K.dts)
	1,nand Interface
		nand@0x1fe06040 {
             #address-cells = <1>;
             #size-cells = <1>;
             compatible = "loongson,ls-nand";
             reg = <0x1fe06040 0x0
                0x1fe06000 0x20>;
             interrupt-parent = <&icu>;
             interrupts = <52>;
             interrupt-names = "nand_irq";
 
             dmas = <&dma0 1>;
             dma-names = "nand_rw";
             dma-mask = <0xffffffff 0xffffffff>;

             number-of-parts = <0x2>;	Note: Number of partitions
 
             partition@0 {
                label = "kernel_partition";		Note: Partition name
                 reg = <0x0000000 0x01e00000>;	Note: Partition size(<Offset, Size>)
             };
 
             partition@0x01400000 {
                 label = "os_partition";
                 reg = <0x01e00000 0x0>;
             };
         }; 
	2,spi Interface
		spi0: spi@1fff0220{
             compatible = "loongson,ls-spi";
             #address-cells = <1>;
             #size-cells = <0>;
             reg = <0x1fff0220 0x10>;
             spidev@3{
                 compatible = "rohm,dh2228fv";
                 spi-max-frequency = <100000000>;
                 reg = <3>;
             };
             spidev@0{
                 compatible = "m25p80";
                 spi-max-frequency = <40000000>;
                 reg = <0>;
             };
             spidev@1{
                 compatible = "mt29f";
                 spi-max-frequency = <20000000>;
                 reg = <1>;				Remarks: spi Picture Selection
             number-of-parts = <0x2>;	Note: Number of partitions
             partition@0 {
                 label = "kernel_partition";	Note: Partition name
                 reg = <0x0000000 0x01e00000>;	Note: Partition size(<Offset, Size>)
             };
            partition@0x01400000 {
            	label ="os_partition";                                                                                                    
                reg = <0x01e00000 0x0>;
             };
          };
       };
	
	//Note: Keep pmon s consistent with kernel partitions!!!

5. Use under Kernel

 	a, mount-t yaffs2/dev/mtdblok1/mnt Note: Mount the partition mtdblock1 partition onto the MNT directory
 	b, cat/proc/mtd Note: View partitions

3. ecc error correction algorithm

	Supports soft ecc and bch error correction algorithms
	a. Not set in the driver with ecc:
		this->ecc.mode = NAND_ECC_NONE
	b. Set in the driver using the soft ecc algorithm:
		this->ecc.mode = NAND_ECC_SOFT;
	c. Set in the driver using bch algorithm:
		this->ecc.mode = NAND_ECC_SOFT_BCH;
		Note: Selectnand_bch needs to be opened under pmon profile

4. Common Problems in nand Debugging

	a. nand could not be found
		Check if nand tablets are selected correctly
		See if the NAND model used is included in the nand_ids.c file
	b. nand can be found, but not used
		pmon and kernel partition size inconsistency
		pmon is inconsistent with kernel ecc mode

Keywords: ftp Linux

Added by greg on Tue, 30 Jul 2019 21:39:26 +0300