Search

Technical Discussion Group Forum

This forum is provided for user discussion. While Beacon EmbeddedWorks support staff and engineers participate, Beacon EmbeddedWorks does not guarantee the accuracy of all information within in the Technical Discussion Group (TDG).

The "Articles" forums provide brief Articles written by Beacon EmbeddedWorks engineers that address the most frequently asked technical questions.

To receive email notifications when updates are posted for a Beacon EmbeddedWorks product download, please subscribe to the TDG Forum of interest.

TDG Forum

PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 08 Oct 2013 10:57 AM by  jemiaha
U-Boot and NAND Flash Partitions
 0 Replies
Sort:
You are not authorized to post a reply.
Author Messages
jemiaha
New Member
New Member
Posts:10


--
08 Oct 2013 10:57 AM
    The process for adjusting the NAND partitions in U-Boot isn't clearly documented. Here's an example of how to make changes.

    First lets take a look at the default partitions as shown by U-Boot:

    OMAP Logic # mtdparts

    device nand0 , # parts = 6
    #: name size offset mask_flags nand_flags
    0: x-loader 0x00080000 0x00000000 0 ecc_hw,repeat
    1: u-boot 0x001a0000 0x00080000 0 (ecc_chip)
    2: u-boot-env 0x00060000 0x00220000 0 (ecc_chip)
    3: kernel 0x00500000 0x00280000 0 (ecc_chip)
    4: ramdisk 0x01400000 0x00780000 0 (ecc_chip)
    5: fs 0x1e480000 0x01b80000 0 (ecc_chip),yaffs


    This is from the DM37 Torpedo + WiFi. Let's say the issue is that the ramdisk partition (#4) is too small to contain the desire ramdisk image. To remedy this we will take some space from the file system partition (#5). The following commands will add 10MB to the U-boot ramdisk partition and subtract the increase from the fs partition:

    mtdparts del nand0,5
    mtdparts del nand0,4
    mtdparts add nand0 0x1E00000@0x00780000 ramdisk
    mtdparts add nand0 0x1DA80000@0x2580000 fs
    setenv mtdflags 'default=ecc_chip;x-loader=ecc_hw,repeat;fs=yaffs'


    Lets talk through the steps.

    The first two steps remove the existing "fs" and "ramdisk" partitions. "nand0" refers to NAND device 0 and the second number is the partition number. The order is important because when you remove a partition those with a higher number will shift down so it simplifies things to delete all partitions above and including the desired change and rebuild from that point up.

    The next two steps add in the new partitions, lowest partition first. The notation "x@y" calls out the size (x) and the location (y) of the new partition.

    The final command sets a flag on the "fs" partition that calls it out as containing a yaffs file system. It uses the "setenv" command to do this but many things have now changed in the background. When you do a printenv you will see the related environment variables (partition, mtdparts) will have automatically changed. This is slightly confusing because these variables can be manually changed or automatically changed when the partition table is manipulated. Now when you view the partition table you should see:

    #: name size offset mask_flags nand_flags
    0: x-loader 0x00080000 0x00000000 0 ecc_hw,repeat
    1: u-boot 0x001a0000 0x00080000 0 (ecc_chip)
    2: u-boot-env 0x00060000 0x00220000 0 (ecc_chip)
    3: kernel 0x00500000 0x00280000 0 (ecc_chip)
    4: ramdisk 0x01e00000 0x00780000 0 (ecc_chip)
    5: fs 0x1da80000 0x02580000 0 (ecc_chip),yaffs


    Once the values fit your desired application then finally use "saveenv" make them permanent. If you reset without saving the environment the changes will be lost.

    To take this to the next level, if you want to change the default values used by U-Boot for the NAND partitions you would need to change the source code for U-boot itself. To do this in the Logic BSP, prep the U-boot source code with the following command:
    ./ltib -p u-boot -m prep

    If this command and it's use isn't familiar to you, please read the Logic Linux BSP user guide which you can find here:
    http://support.logicpd.co...talid=0&EntryId=1392

    Once the U-Boot source is prep'd you will find the default U-Boot environment variable values here:
    rpm/BUILD/u-boot-2011.06/include/configs/omap3logic.h

    The majority of them are defined in the macro named CONFIG_EXTRA_ENV_SETTINGS but for the NAND partitions you need to find MTDPARTS_NAND_DEFAULT. This is the default value:
    #define MTDPARTS_NAND_DEFAULT "mtdparts=omap2-nand.0:512k(x-loader),"\
    "1664k(u-boot),384k(u-boot-env),"\
    "5m(kernel),20m(ramdisk),-(fs)"

    Take care when changing this directly as the value of the macro is interpreted by U-Boot when it loads. Do not use fractions or decimals. For example, if you desired size is 2.5m use 2560k.

    Making these change will automatically adjust the sizes of the NAND partitions passed to the Linux kernel in the command line arguments but not adjust the size of the ramdisk area reserved in RAM. If you see kernel panics related to mounting the rootfs after booting a ramdisk image take a look at the 'ramdisksize' environment variable in U-Boot as it may need to be increased to allocate more RAM for the RAM based file system.

    .
    You are not authorized to post a reply.