AnsweredAssumed Answered

kobs-ng / imx-kobs for IMX6UL

Question asked by Andrew Parlane on Jun 15, 2018
Latest reply on Jul 2, 2018 by igorpadykov

Hi, I have a custom board with an IMX6UL on it. It's set up to boot from NAND flash, specifically: MT29F1G08ABAEAWP.

 

Currently NAND is empty, and I'm booting using the serial download protocol over UART. Note this board doesn't have USB, so the IMX6 manufacturing tool which I believe also has support for writing the bootloader into NAND won't work for me, as that only support the serial download protocol over USB.

 

So I boot my custom u-boot, built with:

IMAGE_VERSION 2

BOOT_OFFSET     FLASH_OFFSET_STANDARD

 

and from there I network boot linux (v4.14 mainline).

 

Now I'm not really sure what's going on with the kobs-ng tool. I've tried a few different versions of it:

1) It's included in buildroot as:

 

IMX_KOBS_VERSION = b402243a04e5a6760a860445e5ff6a931d86f794
IMX_KOBS_SITE = $(call github,NXPmicro,imx-kobs,$(IMX_KOBS_VERSION))

 

Not sure what's going on there, because NXPmicro's github page states there are no public repositories. However it does download, build and run with:

 

kobs-ng version : [ 1.3 ] git hash (d9473bdcea05d046330c045ca3c32715883b61e5)
ROM Version 5

 

2) http://www.freescale.com/lgfiles/NMG/MAD/YOCTO/imx-kobs-5.5.tar.gz

 

which I can build and run, and gives me:

 

 

kobs-ng version : [ 1.3 ] git hash (32f144e46f48bcc237f9c686daa3e5a8b2a3d7b1)
ROM Version 5

 

 

3) Finally I found it GitHub - codeauroraforum/imx-kobs: Tool to create and write Freescale/NXP I.MX NAND boot related boot data structure to … 

 

 

kobs-ng version : [ 1.3 ] git hash (c70685de47cfb67c5e16e1631b7033023ca3e97c)
ROM Version 5

 

 

So that's three different locations to get the same version (1.3) but with different git hashes.

 

Then when I try and use it (any version) I get:

 

Cannot open BCH geometry node: "/sys/kernel/debug/gpmi-nand/bch_geometry"

 

However with -v I get:

 

MTD CONFIG:
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
/usr/uboot.imx: verifying using key '00000000000000000000000000000000'
/usr/uboot.imx: is a valid bootstream for key '00000000000000000000000000000000'
mtd: Linux 4.14
mtd: use new bch layout raw access mode
mtd: opening: "/dev/mtd0"
mtd: '/dev/mtd0' bad block @ 0x7f80000 (MTD)
mtd: '/dev/mtd0' bad block @ 0x7fa0000 (MTD)
mtd: '/dev/mtd0' bad block @ 0x7fc0000 (MTD)
mtd: '/dev/mtd0' bad block @ 0x7fe0000 (MTD)
Cannot open BCH geometry node: "/sys/kernel/debug/gpmi-nand/bch_geometry"
NFC geometry :
ECC Strength : 8
Page Size in Bytes : 2112
Metadata size : 10
ECC Chunk Size in byte : 512
ECC Chunk count : 4
Block Mark Byte Offset : 1999
Block Mark Bit Offset : 0
====================================================
mtd: opened '/dev/mtd0' - '(null)'
mtd: max_boot_stream_size_in_bytes = 66584576
mtd: boot_stream_size_in_bytes = 309016
mtd: boot_stream_size_in_pages = 151
mtd: #1 0x00100000 - 0x04080000 (0x0014b718)
mtd: #2 0x04080000 - 0x08000000 (0x040cb718)
FCB
m_u32Checksum = 0x00000000
m_u32FingerPrint = 0x20424346
m_u32Version = 0x01000000
m_NANDTiming.m_u8DataSetup = 80
m_NANDTiming.m_u8DataHold = 60
m_NANDTiming.m_u8AddressSetup = 25
m_NANDTiming.m_u8DSAMPLE_TIME = 6
m_u32PageDataSize = 2048
m_u32TotalPageSize = 2112
m_u32SectorsPerBlock = 64
m_u32NumberOfNANDs = 0
m_u32TotalInternalDie = 0
m_u32CellType = 0
m_u32EccBlockNEccType = 4
m_u32EccBlock0Size = 512
m_u32EccBlockNSize = 512
m_u32EccBlock0EccType = 4
m_u32MetadataBytes = 10
m_u32NumEccBlocksPerPage = 3
m_u32EccBlockNEccLevelSDK = 0
m_u32EccBlock0SizeSDK = 0
m_u32EccBlockNSizeSDK = 0
m_u32EccBlock0EccLevelSDK = 0
m_u32NumEccBlocksPerPageSDK = 0
m_u32MetadataBytesSDK = 0
m_u32EraseThreshold = 0
m_u32Firmware1_startingPage = 512
m_u32Firmware2_startingPage = 33024
m_u32PagesInFirmware1 = 151
m_u32PagesInFirmware2 = 151
m_u32DBBTSearchAreaStartAddress = 256
m_u32BadBlockMarkerByte = 1999
m_u32BadBlockMarkerStartBit = 0
m_u32BBMarkerPhysicalOffset = 2048
m_u32BCHType = 0
m_NANDTMTiming.m_u32TMTiming2_ReadLatency = 0
m_NANDTMTiming.m_u32TMTiming2_PreambleDelay = 0
m_NANDTMTiming.m_u32TMTiming2_CEDelay = 0
m_NANDTMTiming.m_u32TMTiming2_PostambleDelay = 0
m_NANDTMTiming.m_u32TMTiming2_CmdAddPause = 0
m_NANDTMTiming.m_u32TMTiming2_DataPause = 0
m_NANDTMTiming.m_u32TMSpeed = 0
m_NANDTMTiming.m_u32TMTiming1_BusyTimeout = 0
m_u32DISBBM = 0
m_u32BBMarkerPhysicalOffsetInSpareData = 0
m_u32OnfiSyncEnable = 0
m_NANDONFITiming.m_u32ONFISpeed = 0
m_NANDONFITiming.m_u32ONFITiming_ReadLatency = 0
m_NANDONFITiming.m_u32ONFITiming_CEDelay = 0
m_NANDONFITiming.m_u32ONFITiming_PreambleDelay = 0
m_NANDONFITiming.m_u32ONFITiming_PostambleDelay = 0
m_NANDONFITiming.m_u32ONFITiming_CmdAddPause = 0
m_NANDONFITiming.m_u32ONFITiming_DataPause = 0
m_NANDONFITiming.m_u32ONFITiming_BusyTimeout = 0
m_u32DISBBSearch = 0
m_u32RandomizerEnable = 0
m_u32ReadRetryEnable = 0
m_u32ReadRetrySeqLength = 0
DBBT
m_u32Checksum = 0x00000000
m_u32FingerPrint = 0x54424244
m_u32Version = 0x01000000
m_u32DBBTNumOfPages = 1
BBTN#0
uNAND = 0
uNumberBB = 4
BADBLOCKS:
0x3fc 0x3fd 0x3fe 0x3ff
Firmware: image #0 @ 0x100000 size 0x4b800 - available 0x3f80000
Firmware: image #1 @ 0x4080000 size 0x4b800 - available 0x3f80000
-------------- Start to write the [ FCB ] -----
mtd: erasing @0:0x0-0x20000
mtd: Writing FCB0 [ @0:0x0 ] (840) *
mtd: erasing @0:0x20000-0x40000
mtd: Writing FCB1 [ @0:0x20000 ] (840) *
mtd: erasing @0:0x40000-0x60000
mtd: Writing FCB2 [ @0:0x40000 ] (840) *
mtd: erasing @0:0x60000-0x80000
mtd: Writing FCB3 [ @0:0x60000 ] (840) *
mtd_commit_bcb(FCB): status 0

-------------- Start to write the [ DBBT ] -----
mtd: erasing @0:0x80000-0xa0000
mtd: Writing DBBT0 [ @0:0x80000 ] (800) *
mtd: erasing @0:0xa0000-0xc0000
mtd: Writing DBBT1 [ @0:0xa0000 ] (800) *
mtd: erasing @0:0xc0000-0xe0000
mtd: Writing DBBT2 [ @0:0xc0000 ] (800) *
mtd: erasing @0:0xe0000-0x100000
mtd: Writing DBBT3 [ @0:0xe0000 ] (800) *
mtd_commit_bcb(DBBT): status 0

mtd: PUTTING down DBBT0 BBTN0 @0x82000 (0x800)
mtd: PUTTING down DBBT1 BBTN0 @0xa2000 (0x800)
mtd: PUTTING down DBBT2 BBTN0 @0xc2000 (0x800)
mtd: PUTTING down DBBT3 BBTN0 @0xe2000 (0x800)
---------- Start to write the [ /usr/uboot.imx ]----
mtd: Writting /usr/uboot.imx: #0 @0: 0x00100000 - 0x0014b800
mtd: erasing @0:0x100000-0x120000
mtd: erasing @0:0x120000-0x140000
mtd: erasing @0:0x140000-0x160000
mtd: The last page is not full : 1816
mtd: We write one page for save guard. *
mtd: Writting /usr/uboot.imx: #1 @0: 0x04080000 - 0x040cb800
mtd: erasing @0:0x4080000-0x40a0000
mtd: erasing @0:0x40a0000-0x40c0000
mtd: erasing @0:0x40c0000-0x40e0000
mtd: The last page is not full : 1816
mtd: We write one page for save guard. *

 

Which looks like it's actually working.

 

If I try to dump the flash:

# nanddump /dev/mtd0 -c -l 1 -o

ECC failed: 0
ECC corrected: 24
Number of bad blocks: 0
Number of bbt blocks: 0
Block size 131072, page size 2048, OOB size 64
Dumping data starting at 0x00000000 and ending at 0x00000001...
ECC: 8 corrected bitflip(s) at offset 0x00000000
0x00000000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
0x00000010: 00 00 00 00 00 00 2f fb ff ff 46 43 42 20 00 00 |....../...FCB ..|
0x00000020: 00 01 50 3c 19 06 00 00 00 00 00 08 00 00 40 08 |..P<..........@.|
0x00000030: 00 00 40 00 00 00 00 00 00 00 00 00 00 00 00 00 |..@.............|

 

Note the bit about 8 corrected bitflips.

 

Then I use kobs-ng to dump the data

# kobs-ng dump
Cannot open BCH geometry node: "/sys/kernel/debug/gpmi-nand/bch_geometry"
mtd: fingerprints mismatch @0:0x0
mtd: fingerprints mismatch @0:0x20000
mtd: fingerprints mismatch @0:0x40000
mtd: fingerprints mismatch @0:0x60000
mtd: NCB0 not found
mtd: fingerprints mismatch @0:0x80000
mtd: fingerprints mismatch @0:0xa0000
mtd: fingerprints mismatch @0:0xc0000
mtd: fingerprints mismatch @0:0xe0000
mtd: NCB1 not found
mtd: neither NCB1 or NCB2 found ERROR
Unable to load boot structures

 

So it's not happy, and predictably if I reboot it doesn't actually boot (Although I haven't set up the boot 

 

In the IMX6UL TRM section 8.5.2.3 Firmware Configuration Block, in table 8-11, it says finger print should be

 

32 bit word with a value of 0x4E434220, in ascii
"FCB"

 

Whereas in the output from kobs-ng init -v I have: m_u32FingerPrint = 0x20424346

 

Which is close, but there is 0x46 vs 0x4E, + the endieness. This is also shown in the nanddump.

 

So my questions:

 

1) Where should I be getting kobs-ng / imx-kobs from? Is there source available directly from NXP?

2) Do I need to do anything special to write the correct data to NAND for an IMX6UL?

 

Thanks,

Andrew

Outcomes