All of lore.kernel.org
 help / color / mirror / Atom feed
* [meta-rockchip][PATCH v2 1/4] rockchip.wks: specify fstype
@ 2024-02-16  8:29 Trevor Woerner
  2024-02-16  8:29 ` [meta-rockchip][PATCH v2 2/4] rockchip.wks: add all Rockchip partitions Trevor Woerner
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Trevor Woerner @ 2024-02-16  8:29 UTC (permalink / raw)
  To: yocto; +Cc: Quentin Schulz

If the wks file doesn't specify, the assumption is that each partition
contains a vfat-formatted filesystem. Most of the partitions in the
Rockchip layout don't have filesystems. Implicitly setting the fstype to
vfat causes wic to format the partitions. It doesn't make sense to format
the rawcopy partitions as vfat just to immediately overwrite them with
binaries, and it wastes time formatting partitions that won't ever be used
as filesystems.

Reviewed-by: Quentin Schulz <foss+yocto@0leil.net>
Signed-off-by: Trevor Woerner <twoerner@gmail.com>
---
changes in v2:
- reword the commit message to add clarity
- add Quentin's tag
---
 wic/rockchip.wks | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/wic/rockchip.wks b/wic/rockchip.wks
index fac0b8f70112..b14ec0d1690a 100644
--- a/wic/rockchip.wks
+++ b/wic/rockchip.wks
@@ -17,12 +17,12 @@
 #   boot        32768           229376
 #   root        262144          -           (suggested)
 
-part loader1    --offset 32     --fixed-size 4000K            --source rawcopy                                                 --sourceparams="file=${SPL_BINARY}"
-part reserved1  --offset 4032   --fixed-size 64K
-part reserved2  --offset 4096   --fixed-size 4096K
-part loader2    --offset 8192   --fixed-size 4096K            --source rawcopy                                                 --sourceparams="file=u-boot.${UBOOT_SUFFIX}"
-part atf        --offset 12288  --fixed-size 4096K
-part /boot      --offset 16384  --size       114688K --active --source bootimg-partition --fstype=vfat --label boot --use-uuid --sourceparams="loader=u-boot"
-part /                                                        --source rootfs            --fstype=ext4 --label root --use-uuid
+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 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"
+part /                                                --fstype=ext4            --source rootfs            --label root --use-uuid
 
 bootloader --ptable gpt --append="console=tty1 console=${RK_CONSOLE_DEVICE},${RK_CONSOLE_BAUD}n8 rw rootfstype=ext4 init=/sbin/init"
-- 
2.43.0.76.g1a87c842ece3



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [meta-rockchip][PATCH v2 2/4] rockchip.wks: add all Rockchip partitions
  2024-02-16  8:29 [meta-rockchip][PATCH v2 1/4] rockchip.wks: specify fstype Trevor Woerner
@ 2024-02-16  8:29 ` Trevor Woerner
  2024-02-16  9:48   ` [yocto] " Quentin Schulz
  2024-02-17 14:58   ` Stephen Chen
  2024-02-16  8:29 ` [meta-rockchip][PATCH v2 3/4] remove /boot partition Trevor Woerner
  2024-02-16  8:29 ` [meta-rockchip][PATCH v2 4/4] wks file cleanup Trevor Woerner
  2 siblings, 2 replies; 10+ messages in thread
From: Trevor Woerner @ 2024-02-16  8:29 UTC (permalink / raw)
  To: yocto

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 <twoerner@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)
+#   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"
-- 
2.43.0.76.g1a87c842ece3



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [meta-rockchip][PATCH v2 3/4] remove /boot partition
  2024-02-16  8:29 [meta-rockchip][PATCH v2 1/4] rockchip.wks: specify fstype Trevor Woerner
  2024-02-16  8:29 ` [meta-rockchip][PATCH v2 2/4] rockchip.wks: add all Rockchip partitions Trevor Woerner
@ 2024-02-16  8:29 ` Trevor Woerner
  2024-02-16 10:06   ` [yocto] " Quentin Schulz
  2024-02-16  8:29 ` [meta-rockchip][PATCH v2 4/4] wks file cleanup Trevor Woerner
  2 siblings, 1 reply; 10+ messages in thread
From: Trevor Woerner @ 2024-02-16  8:29 UTC (permalink / raw)
  To: yocto

In order to boot successfully, most Rockchip SoCs require a specific
partitioning scheme which was defined many years (and many SoCs) ago. That
partitioning scheme places the SPL and U-Boot at specific offsets at the
start of the boot block device:

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

The Rockchip partitioning scheme goes on to also define the locations and
sizes of a number of additional partitions, including the "boot" and "root"
partitions.

Since both the SPL and U-Boot have already been placed on the block device,
the "boot" partition only contains the extlinux config file and the
kernel+dtb/fitImage; it doesn't contain any bootloader artifacts (other
than the extlinux config).

The location and size of the SPL partition is a hard dependency since the
BOOTROM etched inside the Rockchip SoCs is programmed to load and run a
validated binary it finds at this location. The locations, sizes, and
contents of the "boot" and "root" partitions are not so rigid since it
is U-Boot which interacts with them. U-Boot is very flexible with how it
finds boot components, and in its support for various devices, filesystems,
sizes, etc.

Both oe-core's U-Boot metadata and wic's bootimg-partition script contain
logic to generate the extlinux pieces required for a bootloader to boot
a Linux system. If both are enabled, the wic pieces silently clobber the
U-Boot pieces. However, the mechanisms contained in the U-Boot metadata are
much more flexible, from a user's point of view, than the mechanisms in
wic's bootimg-partition.

If a user wishes to setup some sort of A/B redundant update mechanism, they
must have redundant root partitions (in order to update their filesystem
contents) but they also need to have redundant boot partitions if they
wish to update the kernel as part of their update mechanism. Pairing
redundant kernel partitions with redundant filesystem partitions becomes
unnecessarily complicated. Therefore it makes sense to combine the kernel
and the filesystem into the same partition so that both the kernel and
filesystem are updated, or rolled back, in lock-step as one unit. Specific
kernel versions and configurations often have dependencies on user-space
components and versions.

The /boot location is not going away. This patch simply transfers
responsibility for its creation to the more flexible U-Boot mechanism
and includes the kernel as part of the same partition as the root
filesystem. Not only does it add flexibility, it also makes update schemes
more straightforward. Although having a separate /boot partition is a
"requirement" of the Rockchip partitioning scheme, it is not an actual
hard requirement when using a flexible, open-source bootloader (such as
U-Boot) instead of using Rockchip's proprietary miniloader, preloader, and
trust.img.

Signed-off-by: Trevor Woerner <twoerner@gmail.com>
---
changes in v2:
- add UBOOT_EXTLINUX_FDT and tweak UBOOT_EXTLINUX_FDTDIR to modify their
  behaviour based on whether or not KERNEL_IMAGETYPE is fitImage
- remove extraneous WKS_FILE_DEPENDS
- remove "--ptable gpt" from wks
- move newly added "earlycon" to UBOOT_EXTLINUX_CONSOLE
- re-word the commit message to better explain the behaviour of the
  Rockchip BootROM
---
 conf/machine/include/rockchip-defaults.inc |  2 ++
 conf/machine/include/rockchip-extlinux.inc | 12 ++++++++++++
 conf/machine/include/rockchip-wic.inc      | 20 ++------------------
 wic/rockchip.wks                           |  8 ++------
 4 files changed, 18 insertions(+), 24 deletions(-)
 create mode 100644 conf/machine/include/rockchip-extlinux.inc

diff --git a/conf/machine/include/rockchip-defaults.inc b/conf/machine/include/rockchip-defaults.inc
index 3ce2e246ab0b..2387eb909934 100644
--- a/conf/machine/include/rockchip-defaults.inc
+++ b/conf/machine/include/rockchip-defaults.inc
@@ -19,3 +19,5 @@ XSERVER = " \
 
 # misc
 SERIAL_CONSOLES ?= "1500000;ttyS2"
+RK_CONSOLE_BAUD ?= "${@d.getVar('SERIAL_CONSOLES').split(';')[0]}"
+RK_CONSOLE_DEVICE ?= "${@d.getVar('SERIAL_CONSOLES').split(';')[1].split()[0]}"
diff --git a/conf/machine/include/rockchip-extlinux.inc b/conf/machine/include/rockchip-extlinux.inc
new file mode 100644
index 000000000000..3af7ed629e34
--- /dev/null
+++ b/conf/machine/include/rockchip-extlinux.inc
@@ -0,0 +1,12 @@
+UBOOT_EXTLINUX ?= "1"
+UBOOT_EXTLINUX_ROOT ?= "root=PARTLABEL=root"
+UBOOT_EXTLINUX_FDTDIR ?= "${@bb.utils.contains('KERNEL_IMAGETYPE', 'fitImage', '', '/boot', d)}"
+NONFITDT ?= "${@d.getVar('KERNEL_DEVICETREE').split('/')[1]}"
+UBOOT_EXTLINUX_FDT ?= "${@bb.utils.contains('KERNEL_IMAGETYPE', 'fitImage', '', '${NONFITDT}', d)}"
+UBOOT_EXTLINUX_CONSOLE ?= "earlycon console=tty1 console=${RK_CONSOLE_DEVICE},${RK_CONSOLE_BAUD}n8"
+UBOOT_EXTLINUX_KERNEL_ARGS ?= "rootwait rw rootfstype=ext4"
+UBOOT_EXTLINUX_KERNEL_IMAGE ?= "/boot/${KERNEL_IMAGETYPE}"
+UBOOT_EXTLINUX_LABELS ?= "default"
+UBOOT_EXTLINUX_MENU_DESCRIPTION:default ?= "${MACHINE}"
+
+MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "u-boot-extlinux"
diff --git a/conf/machine/include/rockchip-wic.inc b/conf/machine/include/rockchip-wic.inc
index 67a8310f7d6a..147a36685d7d 100644
--- a/conf/machine/include/rockchip-wic.inc
+++ b/conf/machine/include/rockchip-wic.inc
@@ -1,33 +1,17 @@
 # common meta-rockchip wic/wks items
 
+require conf/machine/include/rockchip-extlinux.inc
+
 SPL_BINARY ?= "idbloader.img"
 
 IMAGE_FSTYPES += "wic wic.bmap"
 WKS_FILE ?= "rockchip.wks"
 WKS_FILE_DEPENDS ?= " \
-	mtools-native \
-	dosfstools-native \
 	e2fsprogs-native \
 	virtual/bootloader \
-	virtual/kernel \
-	"
-# KERNEL_DEVICETREE follows the pattern of 'rockchip/${SOC_FAMILY}-${BOARD}.dtb'
-# but is placed in the deploy directory as simply '${SOC_FAMILY}-${BOARD}.dtb'
-# therefore we have to strip off the 'rockchip/' for IMAGE_BOOT_FILES
-NONFITDT="${@d.getVar('KERNEL_DEVICETREE').split('/')[1]}"
-IMAGE_BOOT_FILES = " \
-	${KERNEL_IMAGETYPE} \
-	${@bb.utils.contains('KERNEL_IMAGETYPE', 'fitImage', '', '${NONFITDT}', d)} \
 	"
 
-# use the first-defined <baud>;<device> pair in SERIAL_CONSOLES
-# for the console parameter in the wks files
-RK_CONSOLE_BAUD ?= "${@d.getVar('SERIAL_CONSOLES').split(';')[0]}"
-RK_CONSOLE_DEVICE ?= "${@d.getVar('SERIAL_CONSOLES').split(';')[1].split()[0]}"
-
 WICVARS:append = " \
-	RK_CONSOLE_BAUD \
-	RK_CONSOLE_DEVICE \
 	SPL_BINARY \
 	UBOOT_SUFFIX \
 	"
diff --git a/wic/rockchip.wks b/wic/rockchip.wks
index 034443d90050..4fccdf668c50 100644
--- a/wic/rockchip.wks
+++ b/wic/rockchip.wks
@@ -17,8 +17,7 @@
 #   reserved2   8192            8192        (legacy parameters, ATAGS, etc)
 #   loader2     16384           8192        (U-Boot proper)
 #   atf         24576           8192        (trusted OS e.g. ATR, OP-TEE, etc)
-#   boot        32768           229376
-#   root        262144          -           (suggested)
+#   root        32768           -
 
 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
@@ -28,7 +27,4 @@ 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"
-part /                                                --fstype=ext4            --source rootfs            --label root --use-uuid
-
-bootloader --ptable gpt --append="console=tty1 console=${RK_CONSOLE_DEVICE},${RK_CONSOLE_BAUD}n8 rw rootfstype=ext4 init=/sbin/init"
+part /          --offset 16384                        --fstype=ext4  --active  --source rootfs            --label root
-- 
2.43.0.76.g1a87c842ece3



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [meta-rockchip][PATCH v2 4/4] wks file cleanup
  2024-02-16  8:29 [meta-rockchip][PATCH v2 1/4] rockchip.wks: specify fstype Trevor Woerner
  2024-02-16  8:29 ` [meta-rockchip][PATCH v2 2/4] rockchip.wks: add all Rockchip partitions Trevor Woerner
  2024-02-16  8:29 ` [meta-rockchip][PATCH v2 3/4] remove /boot partition Trevor Woerner
@ 2024-02-16  8:29 ` Trevor Woerner
  2 siblings, 0 replies; 10+ messages in thread
From: Trevor Woerner @ 2024-02-16  8:29 UTC (permalink / raw)
  To: yocto; +Cc: Quentin Schulz

Cleanup the elements of the wic/rockchip.wks file so they take up less
horizontal space.

Reviewed-by: Quentin Schulz <foss+yocto@0leil.net>
Signed-off-by: Trevor Woerner <twoerner@gmail.com>
---
changes in v2:
- add Quentin's tag
---
 wic/rockchip.wks | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/wic/rockchip.wks b/wic/rockchip.wks
index 4fccdf668c50..1dcd9d69ada6 100644
--- a/wic/rockchip.wks
+++ b/wic/rockchip.wks
@@ -19,12 +19,12 @@
 #   atf         24576           8192        (trusted OS e.g. ATR, OP-TEE, etc)
 #   root        32768           -
 
-part loader1    --offset 32     --fixed-size 3552K    --fstype=none            --source rawcopy                                   --sourceparams="file=${SPL_BINARY}"
+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 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 /          --offset 16384                        --fstype=ext4  --active  --source rootfs            --label root
+part /          --offset 16384  --active              --fstype=ext4  --label root  --source rootfs
-- 
2.43.0.76.g1a87c842ece3



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [yocto] [meta-rockchip][PATCH v2 2/4] rockchip.wks: add all Rockchip partitions
  2024-02-16  8:29 ` [meta-rockchip][PATCH v2 2/4] rockchip.wks: add all Rockchip partitions Trevor Woerner
@ 2024-02-16  9:48   ` Quentin Schulz
  2024-02-18 17:12     ` Trevor Woerner
  2024-02-17 14:58   ` Stephen Chen
  1 sibling, 1 reply; 10+ messages in thread
From: Quentin Schulz @ 2024-02-16  9:48 UTC (permalink / raw)
  To: yocto, twoerner

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 <twoerner@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+yocto@0leil.net>

Cheers,
Quentin


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [yocto] [meta-rockchip][PATCH v2 3/4] remove /boot partition
  2024-02-16  8:29 ` [meta-rockchip][PATCH v2 3/4] remove /boot partition Trevor Woerner
@ 2024-02-16 10:06   ` Quentin Schulz
  2024-02-18 17:16     ` Trevor Woerner
  0 siblings, 1 reply; 10+ messages in thread
From: Quentin Schulz @ 2024-02-16 10:06 UTC (permalink / raw)
  To: yocto, twoerner

Hi Trevor,

On 2/16/24 09:29, Trevor Woerner via lists.yoctoproject.org wrote:
> In order to boot successfully, most Rockchip SoCs require a specific
> partitioning scheme which was defined many years (and many SoCs) ago. That
> partitioning scheme places the SPL and U-Boot at specific offsets at the
> start of the boot block device:
> 
> 	https://opensource.rock-chips.com/wiki_Partitions
> 
> The Rockchip partitioning scheme goes on to also define the locations and
> sizes of a number of additional partitions, including the "boot" and "root"
> partitions.
> 
> Since both the SPL and U-Boot have already been placed on the block device,
> the "boot" partition only contains the extlinux config file and the
> kernel+dtb/fitImage; it doesn't contain any bootloader artifacts (other
> than the extlinux config).
> 
> The location and size of the SPL partition is a hard dependency since the

Just because I like being pedantic, I don't thhink the size is a hard 
dependency. The location is (well there are a few possible though :) ), 
but the size is part of the header(s) that is parsed by the BootROM, the 
BootROM will only fetch what it needs as far as I remember. It's a bit 
of convoluted code but it's done in tools/rkcommon.c in U-Boot source code.

What we can say though is that the TPL+SPL has a maximum size, since it 
needs to fit inside the SRAM. But I don't think any SoC has been 
released by Rockchip that has 2.5MiB of SRAM, it's usually a few tens of 
KiB max only. Anyway, the message is fine, just wanted to give a bit 
more info there.

[...]

> diff --git a/conf/machine/include/rockchip-extlinux.inc b/conf/machine/include/rockchip-extlinux.inc
> new file mode 100644
> index 000000000000..3af7ed629e34
> --- /dev/null
> +++ b/conf/machine/include/rockchip-extlinux.inc
> @@ -0,0 +1,12 @@
> +UBOOT_EXTLINUX ?= "1"
> +UBOOT_EXTLINUX_ROOT ?= "root=PARTLABEL=root"
> +UBOOT_EXTLINUX_FDTDIR ?= "${@bb.utils.contains('KERNEL_IMAGETYPE', 'fitImage', '', '/boot', d)}"
> +NONFITDT ?= "${@d.getVar('KERNEL_DEVICETREE').split('/')[1]}"

Maybe keep the comment explaining the logic of this line?

> +UBOOT_EXTLINUX_FDT ?= "${@bb.utils.contains('KERNEL_IMAGETYPE', 'fitImage', '', '${NONFITDT}', d)}"
> +UBOOT_EXTLINUX_CONSOLE ?= "earlycon console=tty1 console=${RK_CONSOLE_DEVICE},${RK_CONSOLE_BAUD}n8"
> +UBOOT_EXTLINUX_KERNEL_ARGS ?= "rootwait rw rootfstype=ext4"
> +UBOOT_EXTLINUX_KERNEL_IMAGE ?= "/boot/${KERNEL_IMAGETYPE}"
> +UBOOT_EXTLINUX_LABELS ?= "default"
> +UBOOT_EXTLINUX_MENU_DESCRIPTION:default ?= "${MACHINE}"
> +
> +MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "u-boot-extlinux"

Going back to the mail I sent a few minutes ago on the v1 (which was 
sent after your v2 was sent :) ), I have a gut feeling we need _RDEPENDS 
here and not _RRECOMMENDS.

Cheers,
Quentin


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [yocto] [meta-rockchip][PATCH v2 2/4] rockchip.wks: add all Rockchip partitions
  2024-02-16  8:29 ` [meta-rockchip][PATCH v2 2/4] rockchip.wks: add all Rockchip partitions Trevor Woerner
  2024-02-16  9:48   ` [yocto] " Quentin Schulz
@ 2024-02-17 14:58   ` Stephen Chen
  2024-02-17 20:27     ` Trevor Woerner
  1 sibling, 1 reply; 10+ messages in thread
From: Stephen Chen @ 2024-02-17 14:58 UTC (permalink / raw)
  To: Trevor Woerner, yocto

[-- Attachment #1: Type: text/plain, Size: 160 bytes --]

On Fri, Feb 16, 2024 at 04:29 PM, Trevor Woerner wrote:

> 
> +# atf 24576 8192 (trusted OS e.g. ATR, OP-TEE, etc)

Is it a typo? Use ATF instead of ATR?

[-- Attachment #2: Type: text/html, Size: 188 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [yocto] [meta-rockchip][PATCH v2 2/4] rockchip.wks: add all Rockchip partitions
  2024-02-17 14:58   ` Stephen Chen
@ 2024-02-17 20:27     ` Trevor Woerner
  0 siblings, 0 replies; 10+ messages in thread
From: Trevor Woerner @ 2024-02-17 20:27 UTC (permalink / raw)
  To: Stephen Chen; +Cc: yocto

On Sat 2024-02-17 @ 06:58:27 AM, Stephen Chen wrote:
> On Fri, Feb 16, 2024 at 04:29 PM, Trevor Woerner wrote:
> 
> > 
> > +# atf 24576 8192 (trusted OS e.g. ATR, OP-TEE, etc)
> 
> Is it a typo? Use ATF instead of ATR?

Oops yes! Good catch, thank you.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [yocto] [meta-rockchip][PATCH v2 2/4] rockchip.wks: add all Rockchip partitions
  2024-02-16  9:48   ` [yocto] " Quentin Schulz
@ 2024-02-18 17:12     ` Trevor Woerner
  0 siblings, 0 replies; 10+ messages in thread
From: Trevor Woerner @ 2024-02-18 17:12 UTC (permalink / raw)
  To: Quentin Schulz; +Cc: yocto

On Fri 2024-02-16 @ 10:48:59 AM, Quentin Schulz wrote:
> 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 <twoerner@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 :)

There are 2 pieces that need to be defined to interact with a U-Boot
environment:
- a U-Boot config
	to setup the environment's storage
- an /etc/fw_env.config file in Linux user-space
	so that the fw_printenv and fw_setenv Linux user-space programs can
	interact with the U-Boot environment from Linux user-space

If we use a partition in which to store the U-Boot environment then we need:
- U-Boot config (assuming it's stored in mmcblkXp6 of a fat partition):
	CONFIG_ENV_SIZE=0x8000
	CONFIG_ENV_IS_IN_FAT=y
	CONFIG_ENV_FAT_DEVICE_AND_PART="1:6"
- /etc/fw_env.config
	/boot/uboot.env 0x0000 ${UBOOT_ENV_SIZE}

If, instead, we use a raw block device:
- U-Boot
	CONFIG_ENV_SIZE=0x8000
	CONFIG_ENV_OFFSET=0x3f8000
	CONFIG_ENV_IS_IN_MMC=y
	CONFIG_SYS_MMC_ENV_DEV=1
- /etc/fw_env.config
	/dev/mmcblk1p6 0x0000 ${UBOOT_ENV_SIZE}

I don't think one is easier than the other. If they're configured properly
one is as easy, or as difficult, as the other. I already have plans and
patches to add this to meta-rockchip, so it will all be handled by the BSP.
From the user's point of view it will all work, regardless of which one is
actually implemented.

I'm working on making the "1", from above variable based on which MACHINE is
specified. The "6", "0x8000", "0x3f8000" should be synchronized with what's in
the wic/partitioning.

> > +#   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?).

I wasn't aware of the s/S suffix for specifying offsets in the wic file! It
took me a couple times to figure out what you were referring to in this and
previous emails. Aha! That makes it a bit nicer! I decided to go with the s/S
suffix for the offsets in the wic file. I thought it would be a quick 2-liner
to also be able to specify s/S for the sizes too (--fixed-size/--size) but
unfortunately the assumption that everything is a multiple of 1024 wrt sizing
is buried too deep in wic's internals to make this an easy change.

I submitted, then retracted, a 2-liner to oe-core in an attempt to specify the
sizes in sectors as well. This keeps us from being able to fully specify the
Rockchip partition scheme. Thankfully the 2 we can't specify are together, at
the start, and aren't really needed for anything important to us. Thankfully
the rest of the table is aligned on 1024-byte boundaries.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [yocto] [meta-rockchip][PATCH v2 3/4] remove /boot partition
  2024-02-16 10:06   ` [yocto] " Quentin Schulz
@ 2024-02-18 17:16     ` Trevor Woerner
  0 siblings, 0 replies; 10+ messages in thread
From: Trevor Woerner @ 2024-02-18 17:16 UTC (permalink / raw)
  To: Quentin Schulz; +Cc: yocto

On Fri 2024-02-16 @ 11:06:03 AM, Quentin Schulz wrote:
> Hi Trevor,
> 
> On 2/16/24 09:29, Trevor Woerner via lists.yoctoproject.org wrote:
> > In order to boot successfully, most Rockchip SoCs require a specific
> > partitioning scheme which was defined many years (and many SoCs) ago. That
> > partitioning scheme places the SPL and U-Boot at specific offsets at the
> > start of the boot block device:
> > 
> > 	https://opensource.rock-chips.com/wiki_Partitions
> > 
> > The Rockchip partitioning scheme goes on to also define the locations and
> > sizes of a number of additional partitions, including the "boot" and "root"
> > partitions.
> > 
> > Since both the SPL and U-Boot have already been placed on the block device,
> > the "boot" partition only contains the extlinux config file and the
> > kernel+dtb/fitImage; it doesn't contain any bootloader artifacts (other
> > than the extlinux config).
> > 
> > The location and size of the SPL partition is a hard dependency since the
> 
> Just because I like being pedantic, I don't thhink the size is a hard
> dependency. The location is (well there are a few possible though :) ), but
> the size is part of the header(s) that is parsed by the BootROM, the BootROM
> will only fetch what it needs as far as I remember. It's a bit of convoluted
> code but it's done in tools/rkcommon.c in U-Boot source code.
> 
> What we can say though is that the TPL+SPL has a maximum size, since it
> needs to fit inside the SRAM. But I don't think any SoC has been released by
> Rockchip that has 2.5MiB of SRAM, it's usually a few tens of KiB max only.
> Anyway, the message is fine, just wanted to give a bit more info there.

I appreciate pedantic, so don't hesitate to jump in. In fact up until this
point we have been playing fast and loose with the partition sizes, so I
already had proof that the sizing was not a hard dependency. And I never mind
in-depth explanations and experiences.

> 
> [...]
> 
> > diff --git a/conf/machine/include/rockchip-extlinux.inc b/conf/machine/include/rockchip-extlinux.inc
> > new file mode 100644
> > index 000000000000..3af7ed629e34
> > --- /dev/null
> > +++ b/conf/machine/include/rockchip-extlinux.inc
> > @@ -0,0 +1,12 @@
> > +UBOOT_EXTLINUX ?= "1"
> > +UBOOT_EXTLINUX_ROOT ?= "root=PARTLABEL=root"
> > +UBOOT_EXTLINUX_FDTDIR ?= "${@bb.utils.contains('KERNEL_IMAGETYPE', 'fitImage', '', '/boot', d)}"
> > +NONFITDT ?= "${@d.getVar('KERNEL_DEVICETREE').split('/')[1]}"
> 
> Maybe keep the comment explaining the logic of this line?

Done. But tweaked a little. The reasons for having it before (as part of the
boot files is slightly different than the reason for keeping it for EXTLINUX,
but very similar.

> 
> > +UBOOT_EXTLINUX_FDT ?= "${@bb.utils.contains('KERNEL_IMAGETYPE', 'fitImage', '', '${NONFITDT}', d)}"
> > +UBOOT_EXTLINUX_CONSOLE ?= "earlycon console=tty1 console=${RK_CONSOLE_DEVICE},${RK_CONSOLE_BAUD}n8"
> > +UBOOT_EXTLINUX_KERNEL_ARGS ?= "rootwait rw rootfstype=ext4"
> > +UBOOT_EXTLINUX_KERNEL_IMAGE ?= "/boot/${KERNEL_IMAGETYPE}"
> > +UBOOT_EXTLINUX_LABELS ?= "default"
> > +UBOOT_EXTLINUX_MENU_DESCRIPTION:default ?= "${MACHINE}"
> > +
> > +MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "u-boot-extlinux"
> 
> Going back to the mail I sent a few minutes ago on the v1 (which was sent
> after your v2 was sent :) ), I have a gut feeling we need _RDEPENDS here and
> not _RRECOMMENDS.

Ah got it. I misunderstood your comments. I thought you had been asking
whether it was necessary at all and I was pointing out that without that
package being added to the rootfs it wouldn't work.

Not a problem, I've upgraded it from a recommendation to a dependency.


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-02-18 17:17 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-16  8:29 [meta-rockchip][PATCH v2 1/4] rockchip.wks: specify fstype Trevor Woerner
2024-02-16  8:29 ` [meta-rockchip][PATCH v2 2/4] rockchip.wks: add all Rockchip partitions Trevor Woerner
2024-02-16  9:48   ` [yocto] " Quentin Schulz
2024-02-18 17:12     ` Trevor Woerner
2024-02-17 14:58   ` Stephen Chen
2024-02-17 20:27     ` Trevor Woerner
2024-02-16  8:29 ` [meta-rockchip][PATCH v2 3/4] remove /boot partition Trevor Woerner
2024-02-16 10:06   ` [yocto] " Quentin Schulz
2024-02-18 17:16     ` Trevor Woerner
2024-02-16  8:29 ` [meta-rockchip][PATCH v2 4/4] wks file cleanup Trevor Woerner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.