How to boot i.MX53 from Nand?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to boot i.MX53 from Nand?

3,540 Views
denisdmitriev
Contributor I

I'm working on custom board based on Freescale i.MX53.

I've got a problem with booting from Nand. So I need a piece of advice how to debug boot process, also it will be great to hear about my mistakes.

I use:

1. Boot loader: u-boot 2009.08.01

2. Nand connected via EIM_DA[0..7]

3. Nand: Micron MT29F4G08ABAEA, 512Mb, 8-bit, 3.3V

3.1 Type..........: SLC

3.2 Page size.....: 4096 + 224 bytes

3.3 Pages in block: 64

3.4 ECC...........: 8-bit

3.5 Bus...........: 8-bit

My current progress:

1. Board can boot from SD (BOOT_MODE[1:0] = 0b00; BT_FUSE_SEL = 0)

2. Board can boot through USB

3. Boot loader can read its configuration and Linux kernel from Nand. (rootfs is also there)

I use "*.imx" image, which consists of structures: IVT, Boot data, DCD; (data sheet, pg. 518 «Image Vector Table and Boot Data»).

During boot process of Linux kernel I print a value of SRC_SBMR (pg. 4357) register:

1. 0x10C63D45 (SD boot configuration, from GPIO)

2. 0x1422C1C8 (Nand boot configuration, from Fuse)

Nand boot configuration:

1. BOOT_MODE[1:0] = 0b10 (Boot From Fuses)

2. BT_FUSE_SEL = 1

3. Fuses:

* FUSE [0x080C] BOOT_CFG1: 00c8                                 

* * Device....: NAND

* * Muxed on..: WEIM

* * Interleave: No

* * Addr cycle: 5

* * Boot freq.: 800

* * MMU enable: 0

* FUSE [0x0810] BOOT_CFG2: 00c1                                 

* * Page size.: 4KB + 218 Bytes

* * NAND iface: 8 bit

* * DDR freq..: PLL2 - 400MHz

* * OSC freq..: 19.2, 24, 26, 27 MHz - auto detect

* * NFC freq..: AXI DDR divide by 12

* * Security..: Off

* FUSE [0x0814] BOOT_CFG3: 0022                                 

* * Stride...: 1 Block

* * LBA......: Non LBA (11ms delay)

* * Use R/B..: Yes

* * ECC/Spare: 8-bit

* * Pages....: 64

* * Boot.....: direct boot from external memory is allowed

* FUSE [0x0804] BOOT_LOCK: 0010                                 

* * JTAG mode: JTAG enable mode

* * Boot mode: Boot mode configuration is taken from fuses

I have tried to use tool "kobs-ng" (11.09.01). It has created all required structures: FCB + DDBT + UBoot image; FCB (pg. 495 «NAND FCB Format») consists of values:

0x68: 00 02 00 00 (Start page number of primary firmware)

0x6C: 80 03 00 00 (Start page number of secondary firmware)

Image of boot loader is located at address 0x200000 (2Mbyte). Also I've tried to write boot loader with offset (0x400 bytes, pg. 518 «Image Vector Table and Boot Data») relatively to this address.

I have tried to create FCB structure by myself, and write bootloader to the first Nand block, with offset

4Kbyte(pg. 495) + 0x400.

As the result of all my attempts, boot load process was always redirected to USB.

Questions:

1. What means "Start page number ..." in FCB (offset 0x68)?

2. Can I debug boot process using JTAG?

Labels (1)
Tags (3)
0 Kudos
5 Replies

1,134 Views
cristiansicilia
Contributor III

Anyone boot from NAND MT29F4G08ABAEA  with success?

I have a nand MT29F4G08ABAEA on a custom board based on loco, but my boot from NAND not work, and in U-Boot I can't read from nand (nand read return 0xFF everywhere).

Some detail in this post:

IMX53 Loco based board with MT29F8G08ABABA as NFC 8bit

0 Kudos

1,134 Views
alejandrolozan1
NXP Employee
NXP Employee

Hi,

How are you flashing the NAND flash? using U-Boot?

Which files are you changing in U-Boot and where did you get from the source code?

I will see what I can do to help you.

Best Regards,

Alejandro

0 Kudos

1,134 Views
denisdmitriev
Contributor I

Hi,

* How are you flashing the NAND flash?
I am flashing NAND from Linux. Using this commands:
> flash_erase /dev/mtd0 0 0
> nandwrite -p /dev/mtd0 u-boot.imx

Some explanations:
1. I have splitted NAND:
dev:    size        erasesize  name
mtd0: 00500000 00040000  "bootloader"
mtd1: 00100000 00040000  "config"
mtd2: 00a00000 00040000  "kernel"
mtd3: 08000000 00040000  "rootfs"
mtd4: 17000000 00040000  "storage"

2. I prepared "u-boot.imx" file using mix of "kobs-ng" (ver. 11.09.01) output and u-boot image.
So this file looks like:
00000000  00 00 00 00 46 43 42 20  01 00 00 00 00 00 00 00  |....FCB ........|
---
00000060  00 00 00 00 00 00 00 00  00 02 00 00 80 03 00 00  |................|
00000070  30 00 00 00 30 00 00 00  00 01 00 00 4a 0f  00 00  |0...0.......J...|
---
00040000  00 00 00 00 46 43 42 20  01 00 00 00 00 00 00 00  |....FCB ........|
---
00040060  00 00 00 00 00 00 00 00  00 02 00 00 80 03 00 00  |................|
00040070  30 00 00 00 30 00 00 00  00 01 00 00 4a 0f  00 00  |0...0.......J...|
---
00080000  00 00 00 00 46 43 42 20  01 00 00 00 00 00 00 00  |....FCB ........|
---
00080060  00 00 00 00 00 00 00 00  00 02 00 00 80 03 00 00  |................|
00080070  30 00 00 00 30 00 00 00  00 01 00 00 4a 0f  00 00  |0...0.......J...|
---
000c0000  00 00 00 00 46 43 42 20  01 00 00 00 00 00 00 00  |....FCB ........|
---
000c0060  00 00 00 00 00 00 00 00  00 02 00 00 80 03 00 00  |................|
000c0070  30 00 00 00 30 00 00 00  00 01 00 00 4a 0f  00 00  |0...0.......J...|
---
00100000  00 00 00 00 54 42 42 44  01 00 00 00 00 00 00 00  |....TBBD........|
---
00140000  00 00 00 00 54 42 42 44  01 00 00 00 00 00 00 00  |....TBBD........|
---
00180000  00 00 00 00 54 42 42 44  01 00 00 00 00 00 00 00  |....TBBD........|
---
001c0000  00 00 00 00 54 42 42 44  01 00 00 00 00 00 00 00  |....TBBD........|
---
00200000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
--- Beginning of: IVT, Boot data, DCD
00200400  d1 00 20 40 00 00 80 77  00 00 00 00 2c  fc 7f  77  |.. @...w....,..w|
---

* Which files are you changing in U-Boot and where did you get from the source code?
I can not find the source link, so I put archive on my FTP: ftp://gauraden.net/sk/
This is patched version of u-boot. I use it because board for which it was intended is similar to my.
I have patched it for board initialisation:
1. Added support for my NAND (drivers/mtd/nand/nand_device_info.c)
static struct nand_device_info nand_device_info_table_type_7[] =
.....
{
    .end_of_table                  = false,
    .manufacturer_code         = 0x2c,
    .device_code                   = 0xdc,
    .cell_technology               = NAND_DEVICE_CELL_TECH_SLC,
    .chip_size_in_bytes          = 512LL*SZ_1M,
    .block_size_in_pages       = 64,
    .page_total_size_in_bytes = 4*SZ_1K + 218,
    .ecc_strength_in_bits        = 8,
    .ecc_size_in_bytes           = 512,
    .data_setup_in_ns             = 7,
    .data_hold_in_ns               = 5,
    .address_setup_in_ns        = 10,
    .gpmi_sample_delay_in_ns = 6,
    .tREA_in_ns                      = 16,
    .tRLOH_in_ns                    = 5,
    .tRHOH_in_ns                   = 15,
    "MT29F4G08ABAEA",
},

2. Initial code for board was copied from "freescale/mx53_loco".
I have added support of NFC (copied from freescale/mx53_evk.c: "void setup_nfc(void)").
So u-boot can read its configuration from nand (mtd1), and then load Linux kernel (mtd2).

Linux kernel MTD driver was patched similar to u-boot (drivers/mtd/nand/nand_device_info.c).
Also I have added initialisation code for NFC:
1. PADs
    // NAND
    MX53_PAD_EIM_DA0__EMI_NAND_WEIM_DA_0, // IO_0
    MX53_PAD_EIM_DA1__EMI_NAND_WEIM_DA_1, // IO_1
    MX53_PAD_EIM_DA2__EMI_NAND_WEIM_DA_2, // IO_2
    MX53_PAD_EIM_DA3__EMI_NAND_WEIM_DA_3, // IO_3
    MX53_PAD_EIM_DA4__EMI_NAND_WEIM_DA_4, // IO_4
    MX53_PAD_EIM_DA5__EMI_NAND_WEIM_DA_5, // IO_5
    MX53_PAD_EIM_DA6__EMI_NAND_WEIM_DA_6, // IO_6
    MX53_PAD_EIM_DA7__EMI_NAND_WEIM_DA_7, // IO_7
    MX53_PAD_NANDF_WE_B__EMI_NANDF_WE_B,  // WE
    MX53_PAD_NANDF_RE_B__EMI_NANDF_RE_B,  // RE
    MX53_PAD_NANDF_ALE__EMI_NANDF_ALE,      // ALE
    MX53_PAD_NANDF_CLE__EMI_NANDF_CLE,    // CLE
    MX53_PAD_NANDF_WP_B__EMI_NANDF_WP_B,  // WP
    MX53_PAD_NANDF_RB0__EMI_NANDF_RB_0,   // R/B
    MX53_PAD_NANDF_CS0__EMI_NANDF_CS_0,   // CE
2. NFC registers. I use my own macroses, hope they are clear enough.
    // CS0GCR1
    EIM_CS0GCR1_DSZ( eim_base, 0x4); // 100 - 8 bit port resides on DATA[7:0]
    EIM_CS0GCR1_MUM( eim_base, 0x1); // Multiplexed Mode enable
    EIM_CS0GCR1_CSEN(eim_base, 0x0); // Chip select function is disabled
    // CS0GCR2
    // Muxed 16 bypass grant. This bit when asserted causes EIM to bypass the
    // grant/ack. arbitration with NFC (only for 16 bit muxed mode accesses).
    // 0 - EIM waits for grant before driving a 16 bit muxed mode access to the
    //     memory.
    // 1 - EIM ignores the grant signal and immediately drives a 16 bit muxed
    //     mode access to the memory.
    // iMX53RM.pdf, page 1121
    EIM_CS0GCR2_MUX16_BYP_GRANT(eim_base, 0);
    // NFC_CONFIGURATION
    NFC_SPAS      (nfc_base, 218); // 218 Spare size
    NFC_PPB       (nfc_base, 1);   // 1 - 64 pages per block
    NFC_ECC_MODE  (nfc_base, 1);   // 1 - set 8bit ECC
    NFC_ECC_EN    (nfc_base, 1);   // 1 - enable ECC
    NFC_NUM_OF_DEV(nfc_base, 0);   // 0 - 1 NAND device
    NFC_FW        (nfc_base, 1);   // 1 - Nand Flash IO width: 8bit
    NFC_TOO       (nfc_base, 0);   // 0 - Only 1 device is connected to all CS lines.
    NFC_ADD_OP    (nfc_base, 0);   // 0 - NFC will use only address_group0 (i.e NAND_ADD0,NAND_ADD8)
   
Kernel can mount rootfs and everything is working well.

On other forum I have been directed to this link: https://community.freescale.com/thread/298706
But it did not help me to understand the problem.

0 Kudos

1,134 Views
alejandrolozan1
NXP Employee
NXP Employee

Hi,

I have been delving into this and it seems everything is ok.

Have you  tried to use MFGtool to create the images and flash the NAND device you are using?

Best Regards,

Alejandro

0 Kudos

1,134 Views
denisdmitriev
Contributor I

Hi,

After your question I have tryed it, but had no success. It was failed at the begining of firmware process.

mfgtool.log:

# 1 - Panel A Start processing MX53LOCO-SD <LIST/>.

# Panel A Start <CMD/> type="boot" body="BootStrap" file="u-boot-mx53-loco.bin" timeout="10" onError="" text="Read from DDR script from U-Boot to init DDR Memory.".

# 1 - Panel A DoBoot() - Failed to load u-boot-mx53-loco.bin to Recovery mode device. (err=6)

....

# Panel A: Reason is unknown,failed to run command: type="boot" body="BootStrap" file="u-boot-mx53-loco.bin" timeout="10" onError="" text="Read from DDR script from U-Boot to init DDR Memory."  2 - Panel A Finished processing MX53LOCO-SD <LIST/> : FAIL code=6.

# Panel A UtpUpdate Event: DeviceRemoval Msg: (null) DevState: Disconnected OpState: WAITING_FOR_DEVICE

# Panel A UtpUpdate Event: DeviceArrival Msg: (null) DevState: BootStrap OpState: WAITING_FOR_DEVICE

... etc.

As I see, it was failed to load u-boot image through USB. Maybe the reason of error is that I have done it from MS Windows under Virtualbox.

Commonly I boot my board under Linux through USB using "imx-usb-loader" utilite and it works well.

I have tryed to boot "u-boot-mx53-loco.bin" using "imx-usb-loader" and had no success too (I mean that board was not started to boot).

Output:

> found i.MX53 USB device [15a2:004e]

> No dcd table, barker=402000d1

> loading binary file(./u-boot-mx53-loco.bin) to f8006400, skip=0x400, fsize=3072 type=170...

> binary file successfully loaded

Maybe I should correct mfgtool profile configuration, by adding there my own images of u-boot and kernel?

After looking at: Profiles\MX53 Linux Update\OS Firmware\ucl.xml; I realise that flashing of bootloader is done by kobs-ng.

Can you advice me kobs-ng version for my MCIMX536AVV8C CPU?

Should I use: disable_bi_swap or ignorebad; before flashing bootloader?

Thanks for your patience!

P.S. I use Mfgtools-Rel-1.6.2.048.

0 Kudos