uboot 分区表概念

以下内容来源于ChatGPT:

Q: the partition table of linux for embeded device

A: The partition table of a Linux embedded device is typically defined in the device's bootloader configuration file or in the device tree. The partition table defines the layout of the storage device and specifies the size and location of each partition.

Here is an example of a partition table for a Linux embedded device:

```

Device Boot Start End Sectors Size Id Type

/dev/sda1 * 2048 1026047 1024000 500M 83 Linux

/dev/sda2 1026048 2047999 1021952 499M 83 Linux

/dev/sda3 2048000 3071999 1024000 500M 83 Linux

/dev/sda4 3072000 3907029167 3903957168 1.8T 83 Linux

```

In this example, the device has a single storage device (/dev/sda) that is partitioned into four partitions. The first three partitions are 500MB each and are formatted with the Linux file system. The fourth partition is the remaining space on the device and is also formatted with the Linux file system.

The partition table is important because it defines the layout of the storage device and determines how the device is used. Each partition can be mounted as a separate file system, which allows for different parts of the device to be used for different purposes. For example, one partition might be used for the operating system, while another partition might be used for user data.

The partition table can be modified using tools like fdisk or parted, but care must be taken to avoid data loss or corruption. It is important to understand the existing partition layout and to backup any important data before making any changes to the partition table.

理解:分区表定义了磁盘的空间分配及各分区的大小和位置;每个分区可以挂载为独立的文件系统,即允许磁盘不同的空间用作不同的功能,如一个分区用于OS,另一个分区用于存放用户数据;

Q: uboot & partition table

A: U-Boot is a popular bootloader used in embedded systems that supports a wide range of processors and architectures. One of the important tasks of U-Boot is to load and boot the Linux kernel, which requires knowledge of the partition table.

The partition table provides information about the layout of the storage device, including the number and size of partitions, their type, and their location on the device. U-Boot uses this information to locate the boot partition and load the Linux kernel from it.

U-Boot supports several partition table formats, including the traditional MBR (Master Boot Record) and the newer GPT (GUID Partition Table). The partition table format used depends on the type of storage device and the requirements of the system.

To configure the partition table in U-Boot, the user needs to modify the U-Boot environment variables. The environment variables define the boot arguments that U-Boot passes to the Linux kernel and include the root file system partition and the kernel image location.

Here is an example of how to set the U-Boot environment variables for a partition table with two partitions:

```

setenv bootargs root=/dev/mmcblk0p1 rw rootwait console=ttyS0,115200

setenv bootcmd 'fatload mmc 0:1 ${loadaddr} kernel.img; bootz ${loadaddr}'

```

In this example, the bootargs variable specifies the root file system partition (/dev/mmcblk0p1) and the console settings. The bootcmd variable loads the kernel image from the first partition of the MMC/SD card and boots the kernel.

In summary, U-Boot relies on the partition table to load and boot the Linux kernel in embedded systems. The partition table provides information about the storage device layout, which U-Boot uses to locate the boot partition and load the kernel image. The U-Boot environment variables are used to configure the boot arguments and specify the kernel image location.

理解:uboot支持多种分区表格式,如传统的MBR及新生代GPT;分区表的定义会体现在uboot的bootarg中,并传递给kernel。

在PC领域,常见的2种引导程序BIOS(对应MBR格式分区表)、UEFI(对应GPT格式分区表);

BIOS/UEFI为bootrom中固化的程序,在上电后首先执行,并根据分区表加载bootloader,并由bootloader引导os的启动。

在嵌入式领域,soc的bootrom程序在上电后执行,并根据分区表加载uboot,由uboot引导os启动;

Q: uboot & gpt partition

A: U-Boot can be used with GPT (GUID Partition Table) partitioning scheme. GPT is a newer partitioning scheme that replaces the older MBR (Master Boot Record) partitioning scheme. GPT allows for larger disk sizes and more partitions than MBR.

To use GPT with U-Boot, the board configuration must be set up to support GPT. This involves setting the environment variables to point to the GPT partitions. The following is an example of setting up the environment variables for a GPT partition scheme:

```

setenv bootargs root=/dev/mmcblk0p2 rootwait rw

setenv bootcmd 'mmc dev 0; gpt write mmc 0 ${partitions}; gpt verify mmc 0 ${partitions};

ext4load mmc 0:1 ${kernel_addr_r} /boot/zImage; ext4load mmc 0:1 ${fdt_addr_r} /boot/dtbs/${fdtfile}; bootz ${kernel_addr_r} - ${fdt_addr_r}'

setenv partitions 'name=boot,start=1MiB,size=128MiB;name=rootfs,start=129MiB,size=-'

```

In this example, the boot partition is set to start at 1MiB and be 128MiB in size, while the rootfs partition starts at 129MiB and is the rest of the available space. The bootargs variable specifies the root partition for the kernel to use.

Once the environment variables are set up, U-Boot can be used to boot the system from the GPT partition scheme.

理解:

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值