Hi Trevor,

On 2/16/24 09:29, Trevor Woerner via lists.yoctoproject.org wrote:
Rockchip defines the expected layout/map of the default storage device.
Fill out the wks description so it matches.

        https://opensource.rock-chips.com/wiki_Partitions

Note: in the Rockchip layout, not all partitions are expected to show up
in the gpt partition table. This patch uses "--no-table" to only number the
partitions that are numbered in the Rockchip wiki, as well as to give these
partitions the partition numbers indicated in the wiki.

Note: there is a mistake in the Rockchip table (which I've copied
verbatim here). Going by the values of the "Start Sector", the size of
the "reserved1" partition is listed as being 2x its actual size/number of
sectors.

Expected:
        Partition       Start Sector       Number of Sectors    Partition Size  
   PartNum in GPT    Requirements
        MBR             0      00000000    1       00000001     512       0.5KB
        Primary GPT     1      00000001    63      0000003F     32256     31.5KB
        loader1         64     00000040    7104    00001bc0     4096000   2.5MB 
   1                 preloader (miniloader or U-Boot SPL)
        Vendor Storage  7168   00001c00    512     00000200     262144    256KB 
                     SN, MAC and etc.
        Reserved Space  7680   00001e00    384     00000180     196608    192KB 
                     Not used
        reserved1       8064   00001f80    128     00000080     65536     64KB  
                     legacy DRM key
        U-Boot ENV      8128   00001fc0    64      00000040     32768     32KB
        reserved2       8192   00002000    8192    00002000     4194304   4MB   
                     legacy parameter
        loader2         16384  00004000    8192    00002000     4194304   4MB   
   2                 U-Boot or UEFI
        trust           24576  00006000    8192    00002000     4194304   4MB   
   3                 trusted-os like ATF, OP-TEE
        boot            32768  00008000    229376  00038000     117440512 112MB 
   4                 kernel, dtb, extlinux.conf, ramdisk
        rootfs          262144 00040000    -       -            -         -MB   
   5                 Linux system

Prior to this patch:
        # fdisk -l /dev/mmcblk1
        GPT PMBR size mismatch (1504727 != 30375935) will be corrected by write.
        The backup GPT table is not on the end of the device.
        Disk /dev/mmcblk1: 14.48 GiB, 15552479232 bytes, 30375936 sectors
        Units: sectors of 1 * 512 = 512 bytes
        Sector size (logical/physical): 512 bytes / 512 bytes
        I/O size (minimum/optimal): 512 bytes / 512 bytes
        Disklabel type: gpt
        Disk identifier: 00000000-0000-0000-0000-00004D9B9EF0

        Device          Start     End Sectors   Size Type
        /dev/mmcblk1p1     64    8063    8000   3.9M Microsoft basic data
        /dev/mmcblk1p2   8064    8191     128    64K Microsoft basic data
        /dev/mmcblk1p3   8192   16383    8192     4M Microsoft basic data
        /dev/mmcblk1p4  16384   24575    8192     4M Microsoft basic data
        /dev/mmcblk1p5  24576   32767    8192     4M Microsoft basic data
        /dev/mmcblk1p6  32768  330955  298188 145.6M Microsoft basic data
        /dev/mmcblk1p7 330956 1504693 1173738 573.1M Linux filesystem

New:
        # fdisk -l /dev/mmcblk1
        GPT PMBR size mismatch (1504727 != 30375935) will be corrected by write.
        The backup GPT table is not on the end of the device.
        Disk /dev/mmcblk1: 14.48 GiB, 15552479232 bytes, 30375936 sectors
        Units: sectors of 1 * 512 = 512 bytes
        Sector size (logical/physical): 512 bytes / 512 bytes
        I/O size (minimum/optimal): 512 bytes / 512 bytes
        Disklabel type: gpt
        Disk identifier: 00000000-0000-0000-0000-00004D9B9EF0

        Device          Start     End Sectors   Size Type
        /dev/mmcblk1p1     64    7167    7104   3.5M Linux filesystem
        /dev/mmcblk1p2  16384   24575    8192     4M Linux filesystem
        /dev/mmcblk1p3  24576   32767    8192     4M Linux filesystem
        /dev/mmcblk1p4  32768  330955  298188 145.6M Microsoft basic data
        /dev/mmcblk1p5 330956 1504693 1173738 573.1M Linux filesystem

Signed-off-by: Trevor Woerner <twoer...@gmail.com>
---
changes in v2:
- expand the commit message to show past, expected, and new behaviour
- spell out that vstorage stands for "vendor storage"
---
  wic/rockchip.wks | 20 +++++++++++++-------
  1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/wic/rockchip.wks b/wic/rockchip.wks
index b14ec0d1690a..034443d90050 100644
--- a/wic/rockchip.wks
+++ b/wic/rockchip.wks
@@ -9,17 +9,23 @@
  # wic uses 1KB blocks. The following table uses 512 byte sectors:
  #
  #   Partition   Start Sector    Number of Sectors
-#   loader1     64              8000        (idbloader / U-Boot SPL)
-#   reserved1   8064            128
-#   reserved2   8192            8192
+#   loader1     64              7104        (idbloader / U-Boot SPL)
+#   vstorage    7168            512         (vendor storage: e.g. serial 
number, MAC address, etc)
+#   reserved    7680            384         (not used)
+#   reserved1   8064            64          (legacy DRM key)
+#   uboot_env   8128            64          (U-Boot environment)

I'm surprised this isn't a partition, because then I assume it'd be easier to use fw_setenv/fw_printenv from Linux userspace to interact with U-Boot's env?

But if we make it a partition, then the partition number for the next partitions are now off by one compared to what we have today, no perfect solution here :)

+#   reserved2   8192            8192        (legacy parameters, ATAGS, etc)
  #   loader2     16384           8192        (U-Boot proper)
-#   atf         24576           8192
+#   atf         24576           8192        (trusted OS e.g. ATR, OP-TEE, etc)
  #   boot        32768           229376
  #   root        262144          -           (suggested)
-part loader1 --offset 32 --fixed-size 4000K --fstype=none --source rawcopy --sourceparams="file=${SPL_BINARY}"
-part reserved1  --offset 4032   --fixed-size 64K      --fstype=none
-part reserved2  --offset 4096   --fixed-size 4096K    --fstype=none
+part loader1    --offset 32     --fixed-size 3552K    --fstype=none            --source 
rawcopy                                   --sourceparams="file=${SPL_BINARY}"
+part vstorage   --offset 3584   --fixed-size 256K     --fstype=none  --no-table
+part reserved   --offset 3840   --fixed-size 192K     --fstype=none  --no-table
+part reserved1  --offset 4032   --fixed-size 32K      --fstype=none  --no-table
+part uboot_env  --offset 4064   --fixed-size 32K      --fstype=none  --no-table
+part reserved2  --offset 4096   --fixed-size 4096K    --fstype=none  --no-table
  part loader2    --offset 8192   --fixed-size 4096K    --fstype=none            --source 
rawcopy                                   
--sourceparams="file=u-boot.${UBOOT_SUFFIX}"
  part atf        --offset 12288  --fixed-size 4096K    --fstype=none
  part /boot      --offset 16384  --size       114688K  --fstype=vfat  --active  --source 
bootimg-partition --label boot --use-uuid --sourceparams="loader=u-boot"


Wow, just realized that --offset doesn't have a unit (so thought B) and fixed-size has one. offset default unit if missing is K and fixed-size's M... Maybe we could also specify the unit for offset to be K so that it's a bit less confusing (or if you want to switch to S for sector to match the documentation above?).

Reviewed-by: Quentin Schulz <foss+yo...@0leil.net>

Cheers,
Quentin
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#62518): https://lists.yoctoproject.org/g/yocto/message/62518
Mute This Topic: https://lists.yoctoproject.org/mt/104389369/21656
Group Owner: yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to