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.

Using MTDPARTS to partition SPI flash on AM335x-EVM

Hi,

We are working on AM335x EVM which has Winbond W25Q64CV SPI Flash. We are able to flash SPI and boot from SPI also.

We need to know how to partition the SPI flash from u-boot.

Tried experiements with mtdparts 

When command mtdparts is given on prompt it will pop out following error.

U-Boot# mtdparts
mtdparts variable not set, see 'help mtdparts'
Device nor1 not found!

Tried to modify the include/configs/am335x-evm, working on MTDIDS_DEFAULT etc. But no luck

Any input will be useful.

Regards,

Nagaraj

 

  • Hi,

    Thanks for the reply and the link.

    When I issue the command mtdparts at u-boot prompt I get the following error.

    mtdparts variable not set, see 'help mtdparts'
    Device nor0 not found!

    When I do the sf probe 0 I get the following ouput

    SF: Detected W25Q64CV with page size 256 Bytes, erase size 4 KiB, total 8 MiB

    Even I tried to change the include/configs/am335x-evm.h in u-boot source code

    #define MTDIDS_DEFAULT "nor0=w25q64cv-flash.0"
    #define MTDPARTS_DEFAULT "mtdparts=w25q64cv-flash.0:" \

    from

    #define MTDIDS_DEFAULT "nor0=m25p80-flash.0"
    #define MTDPARTS_DEFAULT "mtdparts=m25p80-flash.0:"

    Please let me know what part of code to be changed.
  • Hi,

    When you run mtdparts you get:

      "mtdparts variable not set, see 'help mtdparts'

       Device nor1 not found!" 

    But in am335x_evm.h, you are setting: 
      #define MTDIDS_DEFAULT "nor0=w25q64cv-flash.0"
      #define MTDPARTS_DEFAULT "mtdparts=w25q64cv-flash.0:" \ 

    Can you please share the output of printenv on your platform? 

    Do you use uEnv.txt file? What is its content? 

    Best Regards, 

    Yordan

  • Hi Yordan.

    Thanks for reply. Please find the output of printenv environment.

    U-Boot# mtdparts
    mtdparts variable not set, see 'help mtdparts'
    Device nor0 not found!

    U-Boot# echo $mtdids
    nor0=w25q64cv

    U-Boot# printenv
    arch=arm
    baudrate=115200
    board=am335x
    board_name=A33515BB
    board_rev=1.4A
    boot_fdt=try
    bootargs=console=ttyO0,115200n8 root=/dev/mmcblk0p2 ro rootfstype=ext4 rootwait
    bootcmd=run spiboot;
    bootcount=1
    bootdelay=1
    bootdir=/boot
    bootenv=uEnv.txt
    bootfile=zImage
    bootm_size=0x10000000
    bootpart=0:2
    console=ttyO0,115200n8
    cpu=armv7
    eth1addr=00:18:31:f2:5d:58
    ethact=cpsw
    ethaddr=00:18:31:f2:5d:57
    fdt_addr_r=0x88000000
    fdtaddr=0x88000000
    fdtfile=undefined
    findfdt=if test $board_name = A335BONE; then setenv fdtfile am335x-bone.dtb; fi; if test $board_name = A335BNLT; then setenv fdtfile am3i
    importbootenv=echo Importing environment from mmc ...; env import -t -r $loadaddr $filesize
    kernel_addr_r=0x82000000
    loadaddr=0x82000000
    loadbootenv=load mmc ${mmcdev} ${loadaddr} ${bootenv}
    loadfdt=load mmc ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile}
    loadimage=load mmc ${bootpart} ${loadaddr} ${bootdir}/${bootfile}
    loadramdisk=load mmc ${mmcdev} ${rdaddr} ramdisk.gz
    mmcargs=setenv bootargs console=${console} ${optargs} root=${mmcroot} rootfstype=${mmcrootfstype}
    mmcboot=mmc dev ${mmcdev}; if mmc rescan; then echo SD/MMC found on device ${mmcdev};if run loadbootenv; then echo Loaded environment fr;
    mmcdev=0
    mmcloados=run mmcargs; if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if run loadfdt; then bootz ${loadaddr} - ${fdtaddr}; el;
    mmcroot=/dev/mmcblk0p2 ro
    mmcrootfstype=ext4 rootwait
    mtdids=nor0=w25q64cv
    netargs=setenv bootargs console=${console} ${optargs} root=/dev/nfs nfsroot=${serverip}:${rootpath},${nfsopts} rw ip=dhcp
    netboot=echo Booting from network ...; setenv autoload no; dhcp; tftp ${loadaddr} ${bootfile}; tftp ${fdtaddr} ${fdtfile}; run netargs; }
    nfsopts=nolock
    partitions=uuid_disk=${uuid_gpt_disk};name=rootfs,start=2MiB,size=-,uuid=${uuid_gpt_rootfs}
    ramargs=setenv bootargs console=${console} ${optargs} root=${ramroot} rootfstype=${ramrootfstype}
    ramboot=echo Booting from ramdisk ...; run ramargs; bootz ${loadaddr} ${rdaddr} ${fdtaddr}
    ramdisk_addr_r=0x88080000
    ramroot=/dev/ram0 rw
    ramrootfstype=ext2
    rdaddr=0x88080000
    rootpath=/export/rootfs
    soc=am33xx
    spiargs=setenv bootargs console=${console} ${optargs} root=${mmcroot} rootfstype=${mmcrootfstype}
    spiboot=echo Booting from spi ...; run spiargs; sf probe ${spibusno}:0; sf read ${loadaddr} ${spisrcaddr} ${spiimgsize}; bootz ${loadadd}
    spibusno=0
    spiimgsize=0x362000
    spiroot=/dev/mtdblock4 rw
    spirootfstype=jffs2
    spisrcaddr=0xe0000
    static_ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off
    stderr=serial
    stdin=serial
    stdout=serial
    usbnet_devaddr=00:18:31:f2:5d:58
    vendor=ti
    ver=U-Boot 2014.07-00107-gd28f2b9-dirty (May 11 2015 - 16:17:00)

    Environment size: 3215/4091 bytes
  • Hi, 

    Again do you use uEnv.txt? If yes, try deleting it & use the default environment variables in am335x_evm.h. 

    Can you add the highlighted code bellow:

    #define MTDIDS_DEFAULT "nor0=w25q64cv-flash.0"

    #define MTDPARTS_DEFAULT "mtdparts=w25q64cv-flash.0:128k(SPL)," \

                                                             "512k(u-boot),128k(u-boot-env1)," \

                                                              "128k(u-boot-env2),3464k(kernel)," \

                                                              "-(rootfs)"

    #elif defined(CONFIG_EMMC_BOOT)

    #define CONFIG_ENV_IS_IN_MMC

    #define CONFIG_SPL_ENV_SUPPORT

    #define CONFIG_SYS_MMC_ENV_DEV 1

    #define CONFIG_SYS_MMC_ENV_PART 2

    #define CONFIG_ENV_OFFSET 0x0

    #define CONFIG_ENV_OFFSET_REDUND (CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE)

    #define CONFIG_SYS_REDUNDAND_ENVIRONMENT

    #elif defined(CONFIG_NOR_BOOT)

    #define CONFIG_ENV_IS_IN_FLASH

    #define CONFIG_ENV_SECT_SIZE (128 << 10) /* 128 KiB */

    #define CONFIG_ENV_OFFSET (512 << 10) /* 512 KiB */

    #define CONFIG_ENV_OFFSET_REDUND (768 << 10) /* 768 KiB */

    #define MTDIDS_DEFAULT "nor0=physmap-flash.0"

    #define MTDPARTS_DEFAULT "mtdparts=physmap-flash.0:" \

                                                        "512k(u-boot)," \

                                                        "128k(u-boot-env1)," \

                                                        "128k(u-boot-env2)," \

                                                        "4m(kernel),-(rootfs)" 

    In define CONFIG_EXTRA_ENV_SETTINGS  add: 

        "mtdids=" MTDIDS_DEFAULT "\0" \
        "mtdparts=" MTDPARTS_DEFAULT "\0" \ 

    After that, compile your u-boot and try using: 

      u-boot# mtdparts default 

      u-boot# mtdparts 

    Best Regards, 

    Yordan

  • Hi Yordan,

    Appreciate your time and Thanks for the steps. Though I have followed the steps issue is still the same and its say Device nor0 not found.

    U-Boot# sf probe 0
    SF: Detected W25Q64CV with page size 256 Bytes, erase size 4 KiB, total 8 MiB

    U-Boot# mtdparts default
    Device nor0 not found!
    U-Boot# mtdparts
    Device nor0 not found!

    Regards,
    Nagaraj
  • Hi Nagaraj,

    I am not sure what the problem is.. and I can't reproduce it on any of my board.

    It seems that mtdparts breaks first in mtdpartsinit():
        if (!parts)
                 printf("mtdparts variable not set, see 'help mtdparts'\n");
    then in get_mtd_info():
        *mtd = get_mtd_device_nm(mtd_dev);
          if (IS_ERR(*mtd)) {
                 printf("Device %s not found!\n", mtd_dev);
                 return 1;
          }

    Can you try adding #define DEBUG at the beginning of common/cmd_mtdparts.c to enable all debug messages? It could give some hints on how to debug this issue.

    Best Regards,
    Yordan