简体   繁体   English

在u-boot中进行Nand分区

[英]Nand partitioning in u-boot

I am working on an Embedded ARM9 development board. 我正在开发嵌入式ARM9开发板。 In that i want rearrange my nand partitions. 因为我想重新排列我的nand分区。 Can anybody tell me how to do that ? 谁能告诉我怎么做?

In my u-boot shell if i give the command mtdparts which gives following information . 在我的u-boot shell中,如果我给出命令mtdparts,它提供以下信息。

Boardcon> mtdparts      

device nand0 <nandflash0>, # parts = 7

#: name                size            offset          mask_flags
0: bios                0x00040000      0x00000000      0
1: params              0x00020000      0x00040000      0
2: toc                 0x00020000      0x00060000      0
3: eboot               0x00080000      0x00080000      0
4: logo                0x00100000      0x00100000      0
5: kernel              0x00200000      0x00200000      0
6: root                0x03c00000      0x00400000      0

active partition: nand0,0 - (bios) 0x00040000 @ 0x00000000

defaults:
mtdids  : nand0=nandflash0 
mtdparts: mtdparts=nandflash0:256k@0(bios),128k(params),128k(toc),512k(eboot),1024k(logo),2m(kernel),-(root) 

Kernel boot message shows the following : 内核启动消息显示以下内容:

 Creating 3 MTD partitions on "NAND 64MiB 3,3V 8-bit":
 0x000000000000-0x000000040000 : "Boardcon_Board_uboot"
 0x000000200000-0x000000400000 : "Boardcon_Board_kernel"
 0x000000400000-0x000003ff8000 : "Boardcon_Board_yaffs2"

Anybody can please explain me what is the relation between both these messages . 任何人都可以请解释我这两个消息之间的关系。 And which one either kernel or u-boot is responsible for creating partions on nand flash?. 哪一个内核或u-boot负责在nand flash上​​创建partion? As for as i know kernel is not creating partitions on each boot but why the message " Creating 3 MTD partitions "? 至于我知道内核不是在每次启动时创建分区,而是为什么消息“ 创建3个MTD分区 ”?

For flash devices, either NAND or NOR, there is no partition table on the device itself. 对于闪存设备,NAND或NOR,设备本身没有分区表 That is, you can't read the device in a flash reader and find some table that indicates how many partitions are on the device and where each partition begins and ends. 也就是说,您无法在闪存读取器中读取设备,并找到一些表格,指示设备上有多少分区以及每个分区的开始和结束位置。 There is only an undifferentiated sequence of blocks. 只有一个未分化的块序列。 This is a fundamental difference between MTD flash devices and devices such as disks or FTL devices such as MMC. 这是MTD闪存设备与磁盘或FTL等设备(如MMC)之间的根本区别。

The partitioning of the flash device is therefore in the eyes of the beholder, that is, either U-Boot or the kernel, and the partitions are "created" when beholder runs. 因此,闪存设备的分区是旁观者的眼睛,即U-Boot或内核,并且在旁观者运行时“创建”分区。 That's why you see the message Creating 3 MTD partitions . 这就是为什么你看到Creating 3 MTD partitions的消息。 It reflects the fact that the flash partitions really only exist in the MTD system of the running kernel, not on the flash device itself. 它反映了闪存分区实际上只存在于正在运行的内核的MTD系统中而不是闪存设备本身的事实。

This leads to a situation in which U-Boot and the kernel can have different definitions of the flash partitions, which is apparently what has happened in the case of the OP. 这导致U-Boot和内核可以具有不同的闪存分区定义的情况,这显然是在OP的情况下发生的情况。

In U-Boot, you define the flash partitions in the mtdparts environment variable. 在U-Boot中,您可以在mtdparts环境变量中定义闪存分区。 In the Linux kernel, the flash partitions are defined in the following places: 在Linux内核中,flash分区在以下位置定义:

  1. In older kernels (eg 2.6.35 for i.MX28) the flash partitioning could be hard-coded in gpmi-nfc-mil.c or other driver source code. 在较旧的内核中(例如i.MX28的2.6.35),flash分区可以用gpmi-nfc-mil.c或其他驱动程序源代码进行硬编码。 (what a bummer!). (多么糟糕!)。
  2. In the newer mainline kernels with device tree support, you can define the MTD paritions in the device tree 在具有设备树支持的较新主线内核中,您可以在设备树中定义MTD分区
  3. In the newer kernels there is usually support for kernel command line partition definition using a command line like root=/dev/mmcblk0p2 rootwait console=ttyS2,115200 mtdparts=nand:6656k(all),1m(squash),-(jffs2) 在较新的内核中,通常使用命令行支持内核命令行分区定义,例如root=/dev/mmcblk0p2 rootwait console=ttyS2,115200 mtdparts=nand:6656k(all),1m(squash),-(jffs2)

The type of partitioning support that you have in the kernel therefore depends on the type of flash you are using, whether it's driver supports kernel command line parsing and whether your kernel has device tree support. 因此,内核中的分区支持类型取决于您使用的闪存类型,它的驱动程序是否支持内核命令行解析以及您的内核是否具有设备树支持。

In any event, there is an inherent risk of conflict between the U-Boot and kernel partitioning of the flash. 无论如何,U-Boot和闪存的内核分区之间存在固有的冲突风险。 Therefore, my recommendation is to define the flash partitions in the U-Boot mtdparts variable and to pass this to the kernel in the U-Boot kernel command line, assuming that your kernel support this option. 因此,我的建议是在U-Boot mtdparts变量中定义flash分区,并将其传递给U-Boot内核命令行中的内核,假设您的内核支持此选项。

你可以设置mtdparts环境变量在uboot中这样做,如果你在内核启动命令行中传递它,内核只使用它,否则它将默认为你平台的内核源代码中的nand分区结构,在这种情况下3 MTD分区默认。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM