AnsweredAssumed Answered

How to flash u-boot to nand flash from kernel

Question asked by mrigendra chaubey on Oct 14, 2018
Latest reply on Oct 14, 2018 by igorpadykov

I have a i.mx6 qp SoC based board. This board have a nand flash.

Currently i am using sd card to boot, and it have buildroot created rootfs.

The kernel have support for gpmi.nand and i can see partitions created such as mtd0, mtd1 etc.

Now I want to flash nand partition /dev/mtd0.

I am able to read and write on nand partition, with mtd tools, nandwrite tools and kobs-ng tools.

below is what I have done,


1. Compile a u-boot.imx image with nand support.  


2. keep that image in some directory of rootfs.


3.erase nand /dev/mtd0 partition

flash_erase /dev/mtd0 0 16

4. write uboot binary like this

nandwrite -b 1 -n /dev/mtd0 -p u-boot.imx


dd if=u-boot.imx of=/dev/mtd0 bs=1k seek=1


kobs-ng init -v /boot/u-boot-nand.imx


chip_0_device_path = "/dev/mtd0"
chip_1_device_path = "(null)"
search_exponent = 2
data_setup_time = 80
data_hold_time = 60
address_setup_time = 25
data_sample_time = 6
row_address_size = 3
column_address_size = 2
read_command_code1 = 0
read_command_code2 = 48
boot_stream_major_version = 1
boot_stream_minor_version = 0
boot_stream_sub_version = 0
ncb_version = 3
boot_stream_1_address = 0
boot_stream_2_address = 0
u-boot-nand.imx: verifying using key '00000000000000000000000000000000'
u-boot-nand.imx: is a valid bootstream for key '00000000000000000000000000000000'
mtd: Linux 4.1
mtd: use new bch layout raw access mode
mtd: opening: "/dev/mtd0"
Cannot open BCH geometry node: "/sys/kernel/debug/gpmi-nand/bch_geometry"
NFC geometry :
ECC Strength : 18
Page Size in Bytes : 2176
Metadata size : 10
ECC Chunk Size in byte : 512
ECC Chunk count : 4
Block Mark Byte Offset : 1950
Block Mark Bit Offset : 2
mtd: opened '/dev/mtd0' - '(null)'
mtd: bootstream too large
mtd_init failed!

5. Step 4 is not very clear to me. Reading about kobs tells something very different that what I expected.

All these tools are compiled with latest buildroot.

Kindly tell me the difference and show the correct approach.