DESK-XZ7-L/Peripherals/NAND

From DAVE Developer's Wiki
Jump to: navigation, search
History
Issue Date Notes
2024/01/23 DESK-XZ7-L-1.0.1 release


Peripheral NAND[edit | edit source]

Device tree configuration[edit | edit source]

Here below an example of device tree configuration used on standard DAVE's kit for the BORA Lite NAND flash:

From bora.dtsi:

...
...
&nand0{
    status = "okay";
    // timings for W29N08GV 8G-BIT 3.3V NAND FLASH MEMORY
    arm,nand-cycle-t0 = <0x5>;
    arm,nand-cycle-t1 = <0x5>;
    arm,nand-cycle-t2 = <0x3>;
    arm,nand-cycle-t3 = <0x2>;
    arm,nand-cycle-t4 = <0x4>;
    arm,nand-cycle-t5 = <0x4>;
    arm,nand-cycle-t6 = <0x4>;
    arm,nand-width = <8>;

    partition@nand-bootbin {
        label = "bootbin";
        reg = <0x00000000 0x01600000>;
    };

    partition@nand-ubootenv {
        label = "ubootenv";
        reg = <0x01600000 0x00040000>;
    };

    partition@nand-rootfs {
        label = "rootfs";
        reg = <0x01640000 0x1BE00000>;
    };
};
...
...

Accessing the peripheral[edit | edit source]

Linux messages at boot time (boot from SD with NAND flash support)[edit | edit source]

[    0.709510] nand: device found, Manufacturer ID: 0xef, Chip ID: 0xd3
[    0.712698] nand: Winbond W29N08GV
[    0.714412] nand: 1024 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
...
[    0.741479] 3 fixed-partitions partitions found on MTD device W29N08GV
[    0.748115] Creating 3 MTD partitions on "W29N08GV":
[    0.753138] 0x000000000000-0x000001600000 : "bootbin"
[    0.760908] 0x000001600000-0x000001640000 : "ubootenv"
[    0.776202] 0x000001640000-0x00001d440000 : "rootfs"
Check the mtd partitions[edit | edit source]
root@boralite:~# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 01600000 00020000 "bootbin"
mtd1: 00040000 00020000 "ubootenv"
mtd2: 1be00000 00020000 "rootfs"

Linux messages at boot time (boot from NAND flash)[edit | edit source]

[    0.705403] nand: device found, Manufacturer ID: 0xef, Chip ID: 0xd3
[    0.708607] nand: Winbond W29N08GV
[    0.710317] nand: 1024 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
...
[    0.734590] 3 fixed-partitions partitions found on MTD device W29N08GV
[    0.741214] Creating 3 MTD partitions on "W29N08GV":
[    0.746250] 0x000000000000-0x000001600000 : "bootbin"
[    0.753605] 0x000001600000-0x000001640000 : "ubootenv"
[    0.760249] 0x000001640000-0x00001d440000 : "rootfs"
...
[    0.838733] ubi0: attaching mtd2
[    2.055918] ubi0: scanning is finished
[    2.074094] ubi0: attached mtd2 (name "rootfs", size 446 MiB)
[    2.079971] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 129024 bytes
[    2.086864] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 512
[    2.093559] ubi0: VID header offset: 512 (aligned 512), data offset: 2048
[    2.100464] ubi0: good PEBs: 3568, bad PEBs: 0, corrupted PEBs: 0
[    2.106577] ubi0: user volume: 1, internal volumes: 1, max. volumes count: 128
[    2.113794] ubi0: max/mean erase counter: 1/0, WL threshold: 4096, image sequence number: 635011865
[    2.122886] ubi0: available PEBs: 0, total reserved PEBs: 3568, PEBs reserved for bad PEB handling: 160
[    2.132320] ubi0: background thread "ubi_bgt0d" started, PID 53
[    2.151720] UBIFS (ubi0:0): Mounting in unauthenticated mode
[    2.157627] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 54
[    2.201015] UBIFS (ubi0:0): recovery needed
[    2.333896] UBIFS (ubi0:0): recovery completed
[    2.338412] UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "rootfs"
[    2.345831] UBIFS (ubi0:0): LEB size: 129024 bytes (126 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[    2.355759] UBIFS (ubi0:0): FS size: 437262336 bytes (417 MiB, 3389 LEBs), journal size 21934080 bytes (20 MiB, 170 LEBs)
[    2.366754] UBIFS (ubi0:0): reserved for root: 4952683 bytes (4836 KiB)
[    2.373371] UBIFS (ubi0:0): media format: w5/r0 (latest is w5/r0), UUID 1D39DE69-4DB4-43C3-B1DC-4790B3D8D8CA, small LPT model
[    2.386230] VFS: Mounted root (ubifs filesystem) on device 0:13.
...
Check the mtd partitions[edit | edit source]
root@boralite:~# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 01600000 00020000 "bootbin"
mtd1: 00040000 00020000 "ubootenv"
mtd2: 1be00000 00020000 "rootfs"