u-boot中的Nand分区
我正在开发嵌入式 ARM9 开发板。我想重新排列我的 nand 分区。有人能告诉我该怎么做吗?
在我的 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)
内核启动消息显示如下:
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"
任何人都可以解释一下这两条消息之间的关系是什么。内核或 u-boot 中哪一个负责在 nand flash 上创建分区?据我所知,内核不会在每次启动时创建分区,但为什么会出现消息“创建 3 MTD 分区”?
I am working on an Embedded ARM9 development board. In that i want rearrange my nand partitions. Can anybody tell me how to do that ?
In my u-boot shell if i give the command mtdparts which gives following information .
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?. As for as i know kernel is not creating partitions on each boot but why the message "Creating 3 MTD partitions"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于闪存设备,无论是 NAND 还是 NOR,设备本身没有分区表。也就是说,您无法在闪存读取器中读取设备并找到一些表来指示设备上有多少个分区以及每个分区的开始和结束位置。只有一个无差别的块序列。这是MTD闪存设备与磁盘或MMC等FTL设备之间的根本区别。
因此,闪存设备的分区是在旁观者的眼中,即U-Boot或内核,并且分区是在旁观者运行时“创建”的。这就是您看到消息
创建 3 个 MTD 分区
的原因。它反映了这样一个事实:闪存分区实际上只存在于正在运行的内核的 MTD 系统中,而不存在于闪存设备本身上。这会导致 U-Boot 和内核对闪存分区有不同的定义,这显然就是 OP 中发生的情况。
在 U-Boot 中,您可以在
mtdparts
环境变量中定义闪存分区。在 Linux 内核中,闪存分区在以下位置定义:gpmi-nfc-mil.c
中硬编码> 或其他驱动程序源代码。 (真可惜!)。分区类型因此,内核中的支持取决于您使用的闪存类型、驱动程序是否支持内核命令行解析以及内核是否具有设备树支持。
无论如何,闪存的 U-Boot 和内核分区之间存在固有的冲突风险。因此,我的建议是在 U-Boot
mtdparts
变量中定义闪存分区,并在 U-Boot 内核命令行中将其传递给内核,假设您的内核支持此选项。For flash devices, either NAND or NOR, there is no partition table on the device itself. 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.
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. That's why you see the message
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.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.
In U-Boot, you define the flash partitions in the
mtdparts
environment variable. In the Linux kernel, the flash partitions are defined in the following places:gpmi-nfc-mil.c
or other driver source code. (what a bummer!).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. 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.您可以在 uboot 中设置 mtdparts 环境变量来执行此操作,并且只有在内核启动命令行中传递此参数时,内核才会使用此变量,否则它将默认为您平台的内核源代码中的 nand 分区结构,该结构在本例默认为 3 个 MTD 分区。
you can set the mtdparts environment variable to do so in uboot, and the kernel only use this if you pass this in kernel boot commandline, or else it'll default to the nand partition structure in the kernel source code for your platform, which in this case the 3 MTD partition default.