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.

Where do the extra NAND partitions come from?

I'm using a beaglebone with the am335x_evm config, and it seems to see several NAND partitions beyond what has been defined. Both uboot and linux have the configuration that ends with the first root partition and continue that partition to the end of NAND, but when I boot linux (even with the NAND completely erased) it sees:

[ 0.810729] 0x000000780000-0x000002780000 : "File System"
[ 0.830932] 0x000002780000-0x000002960000 : "U-Boot.backup"
[ 0.838745] 0x000002960000-0x000002e60000 : "Kernel.backup"
[ 0.847930] 0x000002e60000-0x000020000000 : "Extended File System"

File system is the last partition I can see defined in the u-boot config and in board-am335xevm.c. Where are the rest of the partitions coming from?

  • Hi Matt,

    The function that creates the MTD partitions is located inside drivers/mtd/mtdparts.c:

    /*
     * This function, given a master MTD object and a partition table, creates
     * and registers slave MTD objects which are bound to the master according to
     * the partition definitions.
     *
     * We don't register the master, or expect the caller to have done so,
     * for reasons of data integrity.
     */

    int add_mtd_partitions(struct mtd_info *master,
                   const struct mtd_partition *parts,
                   int nbparts)
    {
        struct mtd_part *slave;
        uint64_t cur_offset = 0;
        int i;

        printk(KERN_NOTICE "Creating %d MTD partitions on \"%s\":\n", nbparts, master->name);

        for (i = 0; i < nbparts; i++) {
            slave = allocate_partition(master, parts + i, i, cur_offset);
            if (IS_ERR(slave))
                return PTR_ERR(slave);

            mutex_lock(&mtd_partitions_mutex);
            list_add(&slave->list, &mtd_partitions);
            mutex_unlock(&mtd_partitions_mutex);

            add_mtd_device(&slave->mtd);

            cur_offset = slave->offset + slave->mtd.size;
        }

        return 0;
    }

    It should be called passing the partition table from the board-am335xevm.c board file:

    /* NAND partition information */
    static struct mtd_partition am335x_nand_partitions[] = {
    /* All the partition sizes are listed in terms of NAND block size */
        {
            .name           = "SPL",
            .offset         = 0,            /* Offset = 0x0 */
            .size           = SZ_128K,
        },
        {
            .name           = "SPL.backup1",
            .offset         = MTDPART_OFS_APPEND,    /* Offset = 0x20000 */
            .size           = SZ_128K,
        },
        {
            .name           = "SPL.backup2",
            .offset         = MTDPART_OFS_APPEND,    /* Offset = 0x40000 */
            .size           = SZ_128K,
        },
        {
            .name           = "SPL.backup3",
            .offset         = MTDPART_OFS_APPEND,    /* Offset = 0x60000 */
            .size           = SZ_128K,
        },
        {
            .name           = "U-Boot",
            .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x80000 */
            .size           = 15 * SZ_128K,
        },
        {
            .name           = "U-Boot Env",
            .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x260000 */
            .size           = 1 * SZ_128K,
        },
        {
            .name           = "Kernel",
            .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x280000 */
            .size           = 40 * SZ_128K,
        },
        {
            .name           = "File System",
            .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x780000 */
            .size           = MTDPART_SIZ_FULL,
        },
    };

    Have you done any modifications to the source code? Please make sure that this is the correct structure that is used inside the evm_nand_init() function inside the board file.

    Are you using an IDE/indexer (i.e. CCS5)? I strongly recommend using one, since it will help you traverse faster through the source code.

    You should check why the "nbparts" argument to the add_mtd_partitions() function is greater than it should be.

    Best regards,
    Miroslav

  • I'm using the linux tree found in the sitara_board_port_linux directory under the board port labs. I checked out the 06.00.00.00-nand16 tag and built from that. In the instructions for the board port lab it also shows these partitions under the section "Flashing the File System to NAND with UBIFS" at 

    http://processors.wiki.ti.com/index.php/Sitara_Linux_Training:_Boot_Time_Reduction

    So I think this is a normal part of this build. I just want to rearrange the partitions a bit, but I can't do that until I find out where they are being defined.

    I checked the board_am335xevm.c file and it definitely passes the same parameters you show above...

  • Hi,

    I just checked the 06.00.00.00-nand16 tag (git checkout 06.00.00.00-nand16) and here is how the am335x_nand_partitions[] table looks like in the arch/arm/mach-omap2/board-am335xevm.c board file:

    /* NAND partition information */
    static struct mtd_partition am335x_nand_partitions[] = {
    /* All the partition sizes are listed in terms of NAND block size */
            {
                    .name           = "SPL",
                    .offset         = 0,                    /* Offset = 0x0 */
                    .size           = SZ_128K,
            },
            {
                    .name           = "SPL.backup1",
                    .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x20000 */
                    .size           = SZ_128K,
            },
            {
                    .name           = "SPL.backup2",
                    .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x40000 */
                    .size           = SZ_128K,
            },
            {
                    .name           = "SPL.backup3",
                    .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x60000 */
                    .size           = SZ_128K,
            },
            {
                    .name           = "U-Boot",
                    .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x80000 */
                    .size           = 15 * SZ_128K,
            },
            {
                    .name           = "U-Boot Env",
                    .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x260000 */
                    .size           = 1 * SZ_128K,
            },
            {
                    .name           = "Kernel",
                    .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x280000 */
                    .size           = 40 * SZ_128K,
            },
            {
                    .name           = "File System",
                    .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x780000 */
                    .size           = 1 * SZ_32M,
            },
            {
                    .name           = "U-Boot.backup",
                    .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x2780000 */
                    .size           = 15 * SZ_128K,
            },
            {
                    .name           = "Kernel.backup",
                    .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x2960000 */
                    .size           = 40 * SZ_128K,
            },
            {
                    .name           = "Extended File System",
                    .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x2e60000 */
                    .size           = MTDPART_SIZ_FULL,
            },
    };

    As I stated before, this is the partitions table, which is used to create the partitions. Please double check the file you are viewing. I strongly recommend using an IDE with an indexer, so that you may browse your source code easier.

    Best regards,
    Miroslav

  • Sorry, I was looking at the wrong git tag before. Thanks.