This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

fw_setenv / NAND / DM8168

Hi,

We use DM8168 and DVRRDK based software, linux-04.04.00.01 (2.6.37)

we try to use uboot tools. fw_printenv works fine but we have problems with fw_setenv:

Example:

fw_setenv test yes

Read 0x2000 bytes at 0x0

Can't open /dev/mtd1:

Permission denied Error: can't write fw_env to flash

 

My NAND configuration is following:

static struct mtd_partition ti816x_nand_partitions_bs128[] =

    /* mtd0 */

    {         .name       = "U-Boot",        

   .offset     = 0,  /* Offset = 0x0 */        

   .size       = 18 * SZ_128K,     },

    /* mtd1 */

    {         .name       = "U-Boot Env",      

    .offset     = MTDPART_OFS_APPEND, 

    .size       = 2 * SZ_128K,       

    .mask_flags = MTD_WRITEABLE,     },

 

Does anybody have experience with fw_setenv and this error ?

  • Hi,

    Pavel. thanks for Your hint, I will put debug output inti fw_env.c.

    BR Holger

  • The problem occurs already in flash_io

    open() fails with "permission denied" but in the NAND configuration in board-ti8168dvr.c

    mtd1 is writable.

     

    int flash_io (int mode)

    {  int fd_current, fd_target, rc, dev_target;

     /* dev_current: fd_current, erase_current */  

    fd_current = open (DEVNAME (dev_current), mode);

    Any ideas ?

  • Holger Eberhard102906 said:

    /* mtd1 */

        {         .name       = "U-Boot Env",      

        .offset     = MTDPART_OFS_APPEND, 

        .size       = 2 * SZ_128K,       

        .mask_flags = MTD_WRITEABLE,     },

    The default mtd1 NAND configuration is:

    {
            .name        = "U-Boot Env",
            .offset        = MTDPART_OFS_APPEND,    /* Offset = 0x240000 */
            .size        = 2 * SZ_128K,
        },

    Can you try with this default configuration?

    Note that when MTD_WRITEABLE mask_flags is used, we have this comment /* force read-only */

    Also in linux-kernel/include/linux/mtd/partitions.h we have:

    /*
     * Partition definition structure:
     *
     * An array of struct partition is passed along with a MTD object to
     * add_mtd_partitions() to create them.
     *
     * For each partition, these fields are available:

    * mask_flags: contains flags that have to be masked (removed) from the
     *     master MTD flag set for the corresponding MTD partition.
     *     For example, to force a read-only partition, simply adding
     *     MTD_WRITEABLE to the mask_flags will do the trick.

    Regards,
    Pavel

  • Ok, this was my  missunderstandig, MTD_WRITEABLE makes the partition read-only.

    I changed this, but now I get an error if the NAND partition is erased:

    MTD erase error on /dev/mtd1: Invalid argument

    Error: can't write fw_env to flash

    I checked the settings in fw_env.h, seems to be OK:

    #define DEVICE1_NAME      "/dev/mtd1"

    #define DEVICE1_OFFSET    0x00000000

    #define ENV1_SIZE         0x2000

  • Last but not least I have found the reason.

    Must set #define DEVICE1_ESIZE  0x20000  in fw_env.h for our NAND partition size.

    Thank You Pavel for the support.

    BR Holger

  • Holger,

    1. Make sure you are building your u-boot with ENV for NAND

    ti8168_evm_config_nand -> u-boot.noxip.bin

    2. In linux kernel, by default we have SPI mapped before NAND, thus we have:

    root@dm814x-evm:~# cat /proc/mtd

    dev:    size   erasesize  name

    mtd0: 00020000 00001000 "U-Boot-min"

    mtd1: 00040000 00001000 "U-Boot"

    mtd2: 00002000 00001000 "U-Boot Env"

    mtd3: 00280000 00001000 "Kernel"

    mtd4: 0011e000 00001000 "File System"

    mtd5: 00020000 00020000 "U-Boot-min"

    mtd6: 00240000 00020000 "U-Boot"

    mtd7: 00020000 00020000 "U-Boot Env"

    mtd8: 00440000 00020000 "Kernel"

    mtd9: 0c820000 00020000 "File System"

    mtd10: 03120000 00020000 "Reserved"

    The NAND u-boot env is mapped at mtd7.

    Can you provide the output of "cat /proc/mtd"? Provide also the kernel boot up log, the default one (SPI + NAND) is:

    m25p80 spi1.0: w25x32 (4096 Kbytes)

    Creating 5 MTD partitions on "spi_flash":

    0x000000000000-0x000000020000 : "U-Boot-min"

    0x000000020000-0x000000060000 : "U-Boot"

    0x000000060000-0x000000062000 : "U-Boot Env"

    0x000000062000-0x0000002e2000 : "Kernel"

    0x0000002e2000-0x000000400000 : "File System"

    omap2-nand driver initializing

    ONFI param page 0 valid

    ONFI flash detected

    NAND device: Manufacturer ID: 0x2c, Chip ID: 0xca (Micron NAND 256MiB 3,3V 16-bit)

    omap2-nand: detected x16 NAND flash

    Creating 6 MTD partitions on "omap2-nand.0":

    0x000000000000-0x000000020000 : "U-Boot-min"

    0x000000020000-0x000000260000 : "U-Boot"

    0x000000260000-0x000000280000 : "U-Boot Env"

    0x000000280000-0x0000006c0000 : "Kernel"

    0x0000006c0000-0x00000cee0000 : "File System"

    0x00000cee0000-0x000010000000 : "Reserved"

    Regards,

    Pavel

  • Holger Eberhard102906 said:

    Last but not least I have found the reason.

    Must set #define DEVICE1_ESIZE  0x20000  in fw_env.h for our NAND partition size.

    Thanks for sharing the solution.

    Regards,
    Pavel