iMX28 NAND Flash with Yocto

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

iMX28 NAND Flash with Yocto

2,299 Views
xavigarcía
Contributor I

I am trying to run a custom Yocto image from the imx28's nand flash.

I'm using a custom Hardware based on imx28evk, it needs changes on the imxbootlets (patching battery...). On that recipe, I specify the boot mode (I include the whole file):
echo "noinitrd console=ttyAM0,115200 ubi.mtd=1 root=ubi0:rootfs0 rootfstype=ubifs rw gpmi" > linux_prep/cmdlines/${IMXBOOTLETS_MACHINE}.txt


Other changes that I have done is chaging "UBOOT_CONFIG ??= "sd"" to "UBOOT_CONFIG = "nand" on file: sources/meta-fsl-arm/conf/machine/imx28evk.conf

After compiling this way the image, I uncompress the tar.gz file into a folder, and create te ubifs with this command:
mkfs.ubifs -x none -m 2048 -e 126976 -c 1888 -r Folder/ rootfs.ubifs

I will need this ubifs to burn it on the mtd1

 

In mtd0 I need to burn the boot partition (/build/tmp/deploy/image/imx28evk/zImage-imx28evk.linux.sb).

 

With these two files, I use mtd-utils in order to burn them on to the nand flash, these are the commands that I use:
$ mknod /dev/mtd0 c 90 0

$ kobs-ng init zImage-imx28evk.linux.sb

$ flash_eraseall /dev/mtd1

$ mknod /dev/ubi_ctrl c 10 60

$ ubiattach /dev/ubi_ctrl -m 1 -d 0

$ mknod /dev/ubi0 c 250 0

$ mknod /dev/ubi0_0 c 252 1

$ ubimkvol /dev/ubi0 -N rootfs0 -m

$ ubiupdate /dev/ubi0_0 rootfs.ubifs

 

 

I achieved to boot from mtd0, but it fails trying  to find root=ubi0:rootfs0.

 

Am I forgetting anything or doing something wrong? What more do I have to change on Yocto in order to have an usefull Nand image?

Original Attachment has been moved to: imx-bootlets_10.12.01.bbappend.zip

Labels (1)
0 Kudos
Reply
4 Replies

1,306 Views
alejandrolozan1
NXP Employee
NXP Employee

Hi,

If you were able to make it work. Could you share the solution?

Thanks,

Alejandro

0 Kudos
Reply

1,306 Views
xavigarcía
Contributor I

Excuse me Alejandro, I have been busy all this time...
Finally I managed to make it work.

The problem was on the kernel driver for nand in kernel 3.17.2, it didn't create the partitions so Linux was using all the NandFlash space instead of creating a first partition (mtd0) for boot and another for rootfs.
I have made a patch that changes the driver configuration and create both partitions on NandFlash, so I can use them with no problems.

Patch:

>From 2e3339c6865f9214744bbe6f6c6db6ce33b7d169 Mon Sep 17 00:00:00 2001

From: jmalvarez <jmalvarez@dezac.es>

Date: Mon, 18 May 2015 15:40:06 +0200

Subject: [PATCH] Particiones MTD nand flash

---

drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 33 +++++++++++++++++++++++++++++++--

1 file changed, 31 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c

index 959cb9b..1943511 100644

--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c

+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c

@@ -1698,12 +1698,17 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)

  struct mtd_part_parser_data ppdata = {};

  int ret;

+//JM para particiones en nand-flash

+ struct mtd_partition           partitions[2];

+ static char  *chip_0_boot_name      = "gpmi-nfc-0-boot";

+ static char  *general_use_name      = "gpmi-nfc-general-use";

+

  /* init current chip */

  this->current_chip = -1;

  /* init the MTD data structures */

  mtd->priv = chip;

- mtd->name = "gpmi-nand";

+ mtd->name = "gpmi-nand-init";

  mtd->owner = THIS_MODULE;

  /* init the nand_chip{}, we don't support a 16-bit NAND Flash bus. */

@@ -1760,7 +1765,31 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)

  chip->scan_bbt(mtd);

  ppdata.of_node = this->pdev->dev.of_node;

- ret = mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0);

+//JM ret = mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0);

+

+ /*

+ * We partition the medium like so:

+ *

+ * +------+----------------------------------------------------+

+ * | Boot |                    General Use                     |

+ * +------+----------------------------------------------------+

+ */

+

+ /* Chip 0 Boot */

+

+ partitions[0].name       = chip_0_boot_name;

+ partitions[0].offset     = 0;

+ partitions[0].size       = 160 * SZ_128K; //0x1400000;  //JM  rom->boot_area_size_in_bytes;

+ partitions[0].mask_flags = 0;

+

+ /* General Use */

+

+ partitions[1].name       = general_use_name;

+ partitions[1].offset     = 160 * SZ_128K; //0x1400000;  //JM  rom->boot_area_size_in_bytes;

+ partitions[1].size       = MTDPART_SIZ_FULL;

+ partitions[1].mask_flags = 0;

+

+ ret = mtd_device_parse_register(mtd, NULL, &ppdata, partitions, 2);

  if (ret)

  goto err_out;

  return 0;

--

1.9.1

0 Kudos
Reply

1,306 Views
alejandrolozan1
NXP Employee
NXP Employee

Hi,

Can you share the bootlog?

To me it seems that your steps are ok.

/Alejandro

0 Kudos
Reply

1,306 Views
alejandrolozan1
NXP Employee
NXP Employee

Hi,

Any update?

/Alejandro

0 Kudos
Reply