All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v1 0/2] disk: efi: allow gap before partition entries
@ 2017-02-17 17:31 Philipp Tomsich
  2017-02-17 17:31 ` [U-Boot] [PATCH v1 1/2] part_efi: support padding between the GPT header and " Philipp Tomsich
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Philipp Tomsich @ 2017-02-17 17:31 UTC (permalink / raw)
  To: u-boot

Motivated by the the SPL layout for SD/MMC devices on Allwinner SoCs
(the SPL code needs to reside an 8K offset into the device), we add
support for leaving a gap between the MBR (LBA#0), GPT header (LBA#1)
and GPT partition entries (linked from field in the GPT header).

Note that this affects the creation of partition from U-Boot only and
has no effect on reading existing partition tables.

If defined, EFI_PARTITION_ENTRIES_OFF specifies a byte-offset into
a device and the parititon entries will be located starting at the
next LBA folling this offset.

In the latest incarnation of this change, we also allow the byte
offset to be read from the 'u-boot,efi-partition-entries-offset'
property of the '/config' node in the device-tree.

There's a similar change for gparted floating around the internet:
	http://lists.alioth.debian.org/pipermail/parted-devel/2016-March/004826.html

This change has been in production use on our modules for a while
(over a year) both with a Linux and Android userspace.




Philipp Tomsich (2):
  part_efi: support padding between the GPT header and partition entries
  sunxi-common: add EFI_PARTITION_ENTRIES_OFF, CONFIG_RANDOM_UUID and
    CONFIG_CMD_GPT

 disk/part_efi.c                | 41 ++++++++++++++++++++++++++++++++++++++---
 include/configs/sunxi-common.h |  5 ++++-
 scripts/config_whitelist.txt   |  1 +
 3 files changed, 43 insertions(+), 4 deletions(-)

-- 
1.9.1

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

* [U-Boot] [PATCH v1 1/2] part_efi: support padding between the GPT header and partition entries
  2017-02-17 17:31 [U-Boot] [PATCH v1 0/2] disk: efi: allow gap before partition entries Philipp Tomsich
@ 2017-02-17 17:31 ` Philipp Tomsich
  2017-02-22  3:59   ` Simon Glass
  2017-02-17 17:31 ` [U-Boot] [PATCH v1 2/2] sunxi-common: add EFI_PARTITION_ENTRIES_OFF, CONFIG_RANDOM_UUID and CONFIG_CMD_GPT Philipp Tomsich
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Philipp Tomsich @ 2017-02-17 17:31 UTC (permalink / raw)
  To: u-boot

Some architectures require their SPL loader at a fixed address within
the first 16KB of the disk. To avoid an overlap with the partition
entries of the EFI partition table, the first safe offset (in bytes,
from the start of the device) for the entries can be set through
CONFIG_EFI_PARTITION_ENTRIES_OFF.

When formatting a device with an EFI parition table, we may need to
leave a gap between the GPT header (always in LBA 1) and the partition
entries. The GPT header already contains a field to specify the
on-disk location, which has so far always been set to LBA 2. With this
change, a configurable offset will be translated into a LBA address
indicating where to put the entries.

Now also allows an override via device-tree using a config-node.

Tested (exporting an internal MMC formatted with this) against Linux,
MacOS X and Windows.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
---
 disk/part_efi.c              | 46 ++++++++++++++++++++++++++++++++++++++++----
 scripts/config_whitelist.txt |  1 +
 2 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/disk/part_efi.c b/disk/part_efi.c
index 893cbbd..7c4ae69 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -1,22 +1,23 @@
 /*
  * Copyright (C) 2008 RuggedCom, Inc.
  * Richard Retanubun <RichardRetanubun@RuggedCom.com>
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
 /*
  * NOTE:
  *   when CONFIG_SYS_64BIT_LBA is not defined, lbaint_t is 32 bits; this
  *   limits the maximum size of addressable storage to < 2 Terra Bytes
  */
 #include <asm/unaligned.h>
 #include <common.h>
 #include <command.h>
+#include <fdtdec.h>
 #include <ide.h>
 #include <inttypes.h>
 #include <malloc.h>
 #include <memalign.h>
 #include <part_efi.h>
 #include <linux/ctype.h>
 
@@ -350,48 +351,48 @@ static int set_protective_mbr(struct blk_desc *dev_desc)
 int write_gpt_table(struct blk_desc *dev_desc,
 		gpt_header *gpt_h, gpt_entry *gpt_e)
 {
 	const int pte_blk_cnt = BLOCK_CNT((gpt_h->num_partition_entries
 					   * sizeof(gpt_entry)), dev_desc);
 	u32 calc_crc32;
 
 	debug("max lba: %x\n", (u32) dev_desc->lba);
 	/* Setup the Protective MBR */
 	if (set_protective_mbr(dev_desc) < 0)
 		goto err;
 
 	/* Generate CRC for the Primary GPT Header */
 	calc_crc32 = efi_crc32((const unsigned char *)gpt_e,
 			      le32_to_cpu(gpt_h->num_partition_entries) *
 			      le32_to_cpu(gpt_h->sizeof_partition_entry));
 	gpt_h->partition_entry_array_crc32 = cpu_to_le32(calc_crc32);
 
 	calc_crc32 = efi_crc32((const unsigned char *)gpt_h,
 			      le32_to_cpu(gpt_h->header_size));
 	gpt_h->header_crc32 = cpu_to_le32(calc_crc32);
 
 	/* Write the First GPT to the block right after the Legacy MBR */
 	if (blk_dwrite(dev_desc, 1, 1, gpt_h) != 1)
 		goto err;
 
-	if (blk_dwrite(dev_desc, 2, pte_blk_cnt, gpt_e)
-	    != pte_blk_cnt)
+	if (blk_dwrite(dev_desc, le64_to_cpu(gpt_h->partition_entry_lba),
+		       pte_blk_cnt, gpt_e) != pte_blk_cnt)
 		goto err;
 
 	prepare_backup_gpt_header(gpt_h);
 
 	if (blk_dwrite(dev_desc, (lbaint_t)le64_to_cpu(gpt_h->last_usable_lba)
 		       + 1, pte_blk_cnt, gpt_e) != pte_blk_cnt)
 		goto err;
 
 	if (blk_dwrite(dev_desc, (lbaint_t)le64_to_cpu(gpt_h->my_lba), 1,
 		       gpt_h) != 1)
 		goto err;
 
 	debug("GPT successfully written to block device!\n");
 	return 0;
 
  err:
 	printf("** Can't write to device %d **\n", dev_desc->devnum);
 	return -1;
 }
 
@@ -498,25 +499,62 @@ int gpt_fill_pte(gpt_header *gpt_h, gpt_entry *gpt_e,
 	return 0;
 }
 
+static uint32_t partition_entries_offset(struct blk_desc *dev_desc)
+{
+	uint32_t offset_blks;
+	int config_offset;
+
+#if defined(CONFIG_EFI_PARTITION_ENTRIES_OFF)
+	/* Some architectures require their SPL loader at a fixed
+	 * address within the first 16KB of the disk.  To avoid an
+	 * overlap with the partition entries of the EFI partition
+	 * table, the first safe offset (in bytes, from the start of
+	 * the disk) for the entries can be set in
+	 * CONFIG_EFI_PARTITION_ENTRIES_OFF.
+	 */
+	offset_blks =
+		PAD_TO_BLOCKSIZE(CONFIG_EFI_PARTITION_ENTRIES_OFF, dev_desc);
+#else
+	offset_blks = 2;
+#endif
+
+#if defined(CONFIG_OF_LIBFDT)
+	/* Allow the offset of the first partition entires (in bytes
+	   from the start of the device) to be specified as a property
+	   of the device tree '/config' node. */
+	config_offset = fdtdec_get_config_int(gd->fdt_blob,
+					      "u-boot,efi-partition-entries-offset",
+					      -EINVAL);
+	if (config_offset != -EINVAL)
+		offset_blks = PAD_TO_BLOCKSIZE(config_offset, dev_desc);
+#endif
+
+	debug("efi: partition entries offset (in blocks): %d\n", offset_blks);
+
+	return offset_blks;
+}
+
 int gpt_fill_header(struct blk_desc *dev_desc, gpt_header *gpt_h,
 		char *str_guid, int parts_count)
 {
 	gpt_h->signature = cpu_to_le64(GPT_HEADER_SIGNATURE);
 	gpt_h->revision = cpu_to_le32(GPT_HEADER_REVISION_V1);
 	gpt_h->header_size = cpu_to_le32(sizeof(gpt_header));
 	gpt_h->my_lba = cpu_to_le64(1);
 	gpt_h->alternate_lba = cpu_to_le64(dev_desc->lba - 1);
-	gpt_h->first_usable_lba = cpu_to_le64(34);
 	gpt_h->last_usable_lba = cpu_to_le64(dev_desc->lba - 34);
-	gpt_h->partition_entry_lba = cpu_to_le64(2);
+	gpt_h->partition_entry_lba =
+		cpu_to_le64(partition_entries_offset(dev_desc));
+	gpt_h->first_usable_lba =
+		cpu_to_le64(le64_to_cpu(gpt_h->partition_entry_lba) + 32);
 	gpt_h->num_partition_entries = cpu_to_le32(GPT_ENTRY_NUMBERS);
 	gpt_h->sizeof_partition_entry = cpu_to_le32(sizeof(gpt_entry));
 	gpt_h->header_crc32 = 0;
 	gpt_h->partition_entry_array_crc32 = 0;
 
 	if (uuid_str_to_bin(str_guid, gpt_h->disk_guid.b, UUID_STR_FORMAT_GUID))
 		return -1;
 
 	return 0;
 }
 
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index 6a09ad1..195af92 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -934,6 +934,7 @@ CONFIG_EEPRO100_SROM_WRITE
 CONFIG_EEPROM_BUS_ADDRESS
 CONFIG_EEPROM_CHIP_ADDRESS
 CONFIG_EEPROM_LAYOUT_HELP_STRING
+CONFIG_EFI_PARTITION_ENTRIES_OFF
 CONFIG_EFLASH_PROTSECTORS
 CONFIG_EHCI_DESC_BIG_ENDIAN
 CONFIG_EHCI_HCD_INIT_AFTER_RESET
-- 
1.9.1

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

* [U-Boot] [PATCH v1 2/2] sunxi-common: add EFI_PARTITION_ENTRIES_OFF, CONFIG_RANDOM_UUID and CONFIG_CMD_GPT
  2017-02-17 17:31 [U-Boot] [PATCH v1 0/2] disk: efi: allow gap before partition entries Philipp Tomsich
  2017-02-17 17:31 ` [U-Boot] [PATCH v1 1/2] part_efi: support padding between the GPT header and " Philipp Tomsich
@ 2017-02-17 17:31 ` Philipp Tomsich
  2017-02-21 17:45 ` [U-Boot] [PATCH v1 0/2] disk: efi: allow gap before partition entries Maxime Ripard
  2017-02-22  6:11 ` Rask Ingemann Lambertsen
  3 siblings, 0 replies; 10+ messages in thread
From: Philipp Tomsich @ 2017-02-17 17:31 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
---
 include/configs/sunxi-common.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index 4f61452..e8e26a5 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -1,281 +1,283 @@
 /*
  * (C) Copyright 2012-2012 Henrik Nordstrom <henrik@henriknordstrom.net>
  *
  * (C) Copyright 2007-2011
  * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
  * Tom Cubie <tangliang@allwinnertech.com>
  *
  * Configuration settings for the Allwinner sunxi series of boards.
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
 #ifndef _SUNXI_COMMON_CONFIG_H
 #define _SUNXI_COMMON_CONFIG_H
 
 #include <asm/arch/cpu.h>
 #include <linux/stringify.h>
 
 #ifdef CONFIG_OLD_SUNXI_KERNEL_COMPAT
 /*
  * The U-Boot workarounds bugs in the outdated buggy sunxi-3.4 kernels at the
  * expense of restricting some features, so the regular machine id values can
  * be used.
  */
 # define CONFIG_MACH_TYPE_COMPAT_REV	0
 #else
 /*
  * A compatibility guard to prevent loading outdated buggy sunxi-3.4 kernels.
  * Only sunxi-3.4 kernels with appropriate fixes applied are able to pass
  * beyond the machine id check.
  */
 # define CONFIG_MACH_TYPE_COMPAT_REV	1
 #endif
 
 /*
  * High Level Configuration Options
  */
 #if defined(CONFIG_SPL_BUILD) && !defined(CONFIG_ARM64)
 #define CONFIG_SYS_THUMB_BUILD	/* Thumbs mode to save space in SPL */
 #endif
 
 #include <asm/arch/cpu.h>	/* get chip and board defs */
 
 #ifdef CONFIG_SUNXI_PANGOLIN
 # undef CONFIG_SYS_PROMPT
 # define CONFIG_SYS_PROMPT	"u-boot# "
 #endif
 
 /* Serial & console */
 #define CONFIG_SYS_NS16550_SERIAL
 /* ns16550 reg in the low bits of cpu reg */
 #define CONFIG_SYS_NS16550_CLK		24000000
 #ifndef CONFIG_DM_SERIAL
 # define CONFIG_SYS_NS16550_REG_SIZE	-4
 # define CONFIG_SYS_NS16550_COM1		SUNXI_UART0_BASE
 # define CONFIG_SYS_NS16550_COM2		SUNXI_UART1_BASE
 # define CONFIG_SYS_NS16550_COM3		SUNXI_UART2_BASE
 # define CONFIG_SYS_NS16550_COM4		SUNXI_UART3_BASE
 # define CONFIG_SYS_NS16550_COM5		SUNXI_R_UART_BASE
 #endif
 
 /* CPU */
 #define CONFIG_TIMER_CLK_FREQ		24000000
 
 /*
  * The DRAM Base differs between some models. We cannot use macros for the
  * CONFIG_FOO defines which contain the DRAM base address since they end
  * up unexpanded in include/autoconf.mk .
  *
  * So we have to have this #ifdef #else #endif block for these.
  */
 #ifdef CONFIG_MACH_SUN9I
 #define SDRAM_OFFSET(x) 0x2##x
 #define CONFIG_SYS_SDRAM_BASE		0x20000000
 #define CONFIG_SYS_LOAD_ADDR		0x22000000 /* default load address */
 #define CONFIG_SYS_TEXT_BASE		0x2a000000
 /* Note SPL_STACK_R_ADDR is set through Kconfig, we include it here 
  * since it needs to fit in with the other values. By also #defining it
  * we get warnings if the Kconfig value mismatches. */
 #define CONFIG_SPL_STACK_R_ADDR		0x2fe00000
 #define CONFIG_SPL_BSS_START_ADDR	0x2ff80000
 #else
 #define SDRAM_OFFSET(x) 0x4##x
 #define CONFIG_SYS_SDRAM_BASE		0x40000000
 #define CONFIG_SYS_LOAD_ADDR		0x42000000 /* default load address */
 #define CONFIG_SYS_TEXT_BASE		0x4a000000
 /* Note SPL_STACK_R_ADDR is set through Kconfig, we include it here 
  * since it needs to fit in with the other values. By also #defining it
  * we get warnings if the Kconfig value mismatches. */
 #define CONFIG_SPL_STACK_R_ADDR		0x4fe00000
 #define CONFIG_SPL_BSS_START_ADDR	0x4ff80000
 #endif
 
 #define CONFIG_SPL_BSS_MAX_SIZE		0x00080000 /* 512 KiB */
 
 #if defined(CONFIG_MACH_SUN9I) || defined(CONFIG_MACH_SUN50I)
 /*
  * The A80's A1 sram starts at 0x00010000 rather then at 0x00000000 and is
  * slightly bigger. Note that it is possible to map the first 32 KiB of the
  * A1 at 0x00000000 like with older SoCs by writing 0x16aa0001 to the
  * undocumented 0x008000e0 SYS_CTRL register. Where the 16aa is a key and
  * the 1 actually activates the mapping of the first 32 KiB to 0x00000000.
  */
 #define CONFIG_SYS_INIT_RAM_ADDR	0x10000
 #define CONFIG_SYS_INIT_RAM_SIZE	0x08000	/* FIXME: 40 KiB ? */
 #else
 #define CONFIG_SYS_INIT_RAM_ADDR	0x0
 #define CONFIG_SYS_INIT_RAM_SIZE	0x8000	/* 32 KiB */
 #endif
 
 #define CONFIG_SYS_INIT_SP_OFFSET \
 	(CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
 #define CONFIG_SYS_INIT_SP_ADDR \
 	(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
 
 #define CONFIG_NR_DRAM_BANKS		1
 #define PHYS_SDRAM_0			CONFIG_SYS_SDRAM_BASE
 #define PHYS_SDRAM_0_SIZE		0x80000000 /* 2 GiB */
 
 #ifdef CONFIG_AHCI
 #define CONFIG_LIBATA
 #define CONFIG_SCSI_AHCI
 #define CONFIG_SCSI_AHCI_PLAT
 #define CONFIG_SUNXI_AHCI
 #define CONFIG_SYS_64BIT_LBA
 #define CONFIG_SYS_SCSI_MAX_SCSI_ID	1
 #define CONFIG_SYS_SCSI_MAX_LUN		1
 #define CONFIG_SYS_SCSI_MAX_DEVICE	(CONFIG_SYS_SCSI_MAX_SCSI_ID * \
 					 CONFIG_SYS_SCSI_MAX_LUN)
 #define CONFIG_SCSI
 #endif
 
 #define CONFIG_SETUP_MEMORY_TAGS
 #define CONFIG_CMDLINE_TAG
 #define CONFIG_INITRD_TAG
 #define CONFIG_SERIAL_TAG
 
 #ifdef CONFIG_NAND_SUNXI
 #define CONFIG_SYS_NAND_MAX_ECCPOS 1664
 #define CONFIG_SYS_NAND_ONFI_DETECTION
 #define CONFIG_SYS_MAX_NAND_DEVICE 8
 #endif
 
 #ifdef CONFIG_SPL_SPI_SUNXI
 #define CONFIG_SYS_SPI_U_BOOT_OFFS	0x8000
 #endif
 
 /* mmc config */
 #ifdef CONFIG_MMC
 #define CONFIG_MMC_SUNXI_SLOT		0
 
 #ifdef CONFIG_SUNXI_PANGOLIN
   #ifdef CONFIG_SUNXI_ENV_MMC
     #define CONFIG_ENV_IS_IN_MMC
     #define CONFIG_SYS_MMC_ENV_DEV	1	/* first detected MMC controller */
 #define CONFIG_ENV_OFFSET		(840 << 10)  /* 840 KiB */
 /* (544 << 10) */ /* (8 + 24 + 512) KiB */
   #endif
 
   #define CONFIG_SUPPORT_EMMC_BOOT
   #define CONFIG_SUPPORT_EMMC_RPMB
 
   #ifdef CONFIG_SUNXI_ENV_SPI
     #define CONFIG_ENV_IS_IN_SPI_FLASH
     #define CONFIG_ENV_SECT_SIZE	(64 * 1024)
     #define CONFIG_ENV_SPI				0
     #define CONFIG_ENV_SPI_CS			0
     #define CONFIG_ENV_SPI_MAX_HZ	16000000
     #define CONFIG_ENV_OFFSET			0
   #endif
 
   #define CONFIG_SPI_FLASH_MACRONIX
   #define CONFIG_SF_DEFAULT_BUS 0
   #define CONFIG_SF_DEFAULT_CS 0
   #define CONFIG_SF_DEFAULT_SPEED 16000000
   #define CONFIG_SF_DEFAULT_MODE 0
   #define CONFIG_SYS_SPI_U_BOOT_OFFS   ((CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR - 16) * 512)
   #define CONFIG_SPL_SPI_LOAD
   #define CONFIG_SPL_SPI_SUPPORT
   #define CONFIG_SPL_SPI_FLASH_SUPPORT
 #else
 #define CONFIG_ENV_OFFSET		(544 << 10) /* (8 + 24 + 512) KiB */
 #define CONFIG_ENV_IS_IN_MMC
 #define CONFIG_SYS_MMC_ENV_DEV		0	/* first detected MMC controller */
 #define CONFIG_SYS_MMC_MAX_DEVICE	4
+
+#define CONFIG_CMD_GPT
 #endif
 #endif
 
 /* 64MB of malloc() pool */
 #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (64 << 20))
 
 /*
  * Miscellaneous configurable options
  */
 #define CONFIG_SYS_CBSIZE	1024	/* Console I/O Buffer Size */
 #define CONFIG_SYS_PBSIZE	1024	/* Print Buffer Size */
 #define CONFIG_SYS_MAXARGS	16	/* max number of command args */
 
 /* Boot Argument Buffer Size */
 #define CONFIG_SYS_BARGSIZE		CONFIG_SYS_CBSIZE
 
 /* standalone support */
 #define CONFIG_STANDALONE_LOAD_ADDR	CONFIG_SYS_LOAD_ADDR
 
 /* baudrate */
 #define CONFIG_BAUDRATE			115200
 
 /* The stack sizes are set up in start.S using the settings below */
 #define CONFIG_STACKSIZE		(256 << 10)	/* 256 KiB */
 
 /* FLASH and environment organization */
 
 #define CONFIG_SYS_MONITOR_LEN		(768 << 10)	/* 768 KiB */
 
 #define CONFIG_ENV_SIZE			(128 << 10)	/* 128 KiB */
 #define CONFIG_ENV_OVERWRITE
 
 #define CONFIG_FAT_WRITE	/* enable write access */
 
 #define CONFIG_SPL_FRAMEWORK
 
 #ifndef CONFIG_ARM64		/* AArch64 FEL support is not ready yet */
 #define CONFIG_SPL_BOARD_LOAD_IMAGE
 #endif
 
 #if defined(CONFIG_MACH_SUN9I)
 #define CONFIG_SPL_TEXT_BASE		0x10040		/* sram start+header */
 #define CONFIG_SPL_MAX_SIZE		0x5fc0		/* ? KiB on sun9i */
 #elif defined(CONFIG_MACH_SUN50I)
 #define CONFIG_SPL_TEXT_BASE		0x10040		/* sram start+header */
 #define CONFIG_SPL_MAX_SIZE		0x7fc0		/* 32 KiB on sun50i */
 #elif defined(CONFIG_MACH_SUN6I)
 #define CONFIG_SPL_TEXT_BASE		0x40		/* sram start+header */
 #define CONFIG_SPL_MAX_SIZE		0x7fe0		/* 32KB on sun6i */
 #else
 #define CONFIG_SPL_TEXT_BASE		0x40		/* sram start+header */
 #define CONFIG_SPL_MAX_SIZE		0x5fc0		/* 24KB on sun4i/sun7i */
 #endif
 
 #ifndef CONFIG_ARM64
 #define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv7/sunxi/u-boot-spl.lds"
 #endif
 
 #define CONFIG_SPL_PAD_TO		32768		/* decimal for 'dd' */
 
 #if defined(CONFIG_MACH_SUN9I)
 /* FIXME: 40 KiB instead of 32 KiB ? */
 #define LOW_LEVEL_SRAM_STACK		0x00018000
 #define CONFIG_SPL_STACK		LOW_LEVEL_SRAM_STACK
 #elif defined(CONFIG_MACH_SUN50I)
 /* end of SRAM A2 for now, as SRAM A1 is pretty tight */
 #define LOW_LEVEL_SRAM_STACK		0x00054000
 #define CONFIG_SPL_STACK		LOW_LEVEL_SRAM_STACK
 #else
 /* end of 32 KiB in sram */
 #define LOW_LEVEL_SRAM_STACK		0x00008000 /* End of sram */
 #define CONFIG_SPL_STACK		LOW_LEVEL_SRAM_STACK
 #endif
 
 /* I2C */
 #if defined CONFIG_AXP152_POWER || defined CONFIG_AXP209_POWER || \
     defined CONFIG_SY8106A_POWER
 #endif
 
 #if defined CONFIG_I2C0_ENABLE || defined CONFIG_I2C1_ENABLE || \
     defined CONFIG_I2C2_ENABLE || defined CONFIG_I2C3_ENABLE || \
     defined CONFIG_I2C4_ENABLE || defined CONFIG_R_I2C_ENABLE
 #define CONFIG_SYS_I2C
 #define CONFIG_SYS_I2C_MVTWSI
 #define CONFIG_SYS_I2C_SPEED		400000
 #define CONFIG_SYS_I2C_SLAVE		0x7f
 #endif
 
 #if defined CONFIG_VIDEO_LCD_PANEL_I2C && !(defined CONFIG_SPL_BUILD)
 #define CONFIG_SYS_I2C_SOFT
 #define CONFIG_SYS_I2C_SOFT_SPEED	50000
 #define CONFIG_SYS_I2C_SOFT_SLAVE	0x00
 /* We use pin names in Kconfig and sunxi_name_to_gpio() */
 #define CONFIG_SOFT_I2C_GPIO_SDA	soft_i2c_gpio_sda
 #define CONFIG_SOFT_I2C_GPIO_SCL	soft_i2c_gpio_scl
 #ifndef __ASSEMBLY__
@@ -283,322 +285,323 @@ extern int soft_i2c_gpio_sda;
 extern int soft_i2c_gpio_scl;
 #endif
 #define CONFIG_VIDEO_LCD_I2C_BUS	0 /* The lcd panel soft i2c is bus 0 */
 #define CONFIG_SYS_SPD_BUS_NUM		1 /* And the axp209 i2c bus is bus 1 */
 #else
 #define CONFIG_SYS_SPD_BUS_NUM		0 /* The axp209 i2c bus is bus 0 */
 #define CONFIG_VIDEO_LCD_I2C_BUS	-1 /* NA, but necessary to compile */
 #endif
 
 /* PMU */
 #if defined CONFIG_AXP152_POWER || defined CONFIG_AXP209_POWER || \
     defined CONFIG_AXP221_POWER || defined CONFIG_AXP818_POWER || \
     defined CONFIG_SY8106A_POWER
 #endif
 
 #ifndef CONFIG_CONS_INDEX
 #define CONFIG_CONS_INDEX              1       /* UART0 */
 #endif
 
 #ifdef CONFIG_REQUIRE_SERIAL_CONSOLE
 #if CONFIG_CONS_INDEX == 1
 #ifdef CONFIG_MACH_SUN9I
 #define OF_STDOUT_PATH		"/soc/serial at 07000000:115200"
 #else
 #define OF_STDOUT_PATH		"/soc at 01c00000/serial at 01c28000:115200"
 #endif
 #elif CONFIG_CONS_INDEX == 2 && defined(CONFIG_MACH_SUN5I)
 #define OF_STDOUT_PATH		"/soc at 01c00000/serial at 01c28400:115200"
 #elif CONFIG_CONS_INDEX == 3 && defined(CONFIG_MACH_SUN6I)
 #define OF_STDOUT_PATH          "/soc at 01c00000/serial at 01c28800:115200"
 #elif CONFIG_CONS_INDEX == 3 && defined(CONFIG_MACH_SUN8I)
 #define OF_STDOUT_PATH		"/soc at 01c00000/serial at 01c28800:115200"
 #elif CONFIG_CONS_INDEX == 5 && defined(CONFIG_MACH_SUN8I)
 #define OF_STDOUT_PATH		"/soc at 01c00000/serial at 01f02800:115200"
 #else
 #error Unsupported console port nr. Please fix stdout-path in sunxi-common.h.
 #endif
 #endif /* ifdef CONFIG_REQUIRE_SERIAL_CONSOLE */
 
 /* GPIO */
 #define CONFIG_SUNXI_GPIO
 
 #ifdef CONFIG_VIDEO
 /*
  * The amount of RAM to keep free@the top of RAM when relocating u-boot,
  * to use as framebuffer. This must be a multiple of 4096.
  */
 #define CONFIG_SUNXI_MAX_FB_SIZE (16 << 20)
 
 /* Do we want to initialize a simple FB? */
 #define CONFIG_VIDEO_DT_SIMPLEFB
 
 /* Fallback to old sunxi_video if the driver model video driver is disabled */
 #ifndef CONFIG_VIDEO_SUNXI_DM
 #define CONFIG_VIDEO_SUNXI
 #endif
 
 #define CONFIG_VIDEO_LOGO
 #define CONFIG_VIDEO_BMP_LOGO
 
 #define CONFIG_CMD_BMP
 #define CONFIG_SPLASH_SCREEN_ALIGN
 
 #define CONFIG_VIDEO_STD_TIMINGS
 #define CONFIG_I2C_EDID
 #define VIDEO_LINE_LEN (pGD->plnSizeX)
 
 /* allow both serial and cfb console. */
 /* stop x86 thinking in cfbconsole from trying to init a pc keyboard */
 
 #endif /* CONFIG_VIDEO */
 
 /* Ethernet support */
 #ifdef CONFIG_SUNXI_EMAC
 #define CONFIG_PHY_ADDR		1
 #define CONFIG_MII			/* MII PHY management		*/
 #define CONFIG_PHYLIB
 #endif
 
 #ifdef CONFIG_SUNXI_GMAC
 #define CONFIG_PHY_GIGE			/* GMAC can use gigabit PHY	*/
 /* Cherry-pick from A80: #define CONFIG_PHY_ADDR		1 */
 #define CONFIG_MII			/* MII PHY management		*/
 #define CONFIG_PHY_REALTEK
 #define CONFIG_PHY_MICREL
 #define CONFIG_PHY_MICREL_KSZ9031
 #endif
 
 #ifdef CONFIG_USB_EHCI_HCD
 #define CONFIG_USB_OHCI_NEW
 #define CONFIG_USB_OHCI_SUNXI
 #define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS 1
 #define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 1
 #endif
 
 #ifdef CONFIG_USB_MUSB_SUNXI
 #define CONFIG_USB_MUSB_PIO_ONLY
 #endif
 
 #ifdef CONFIG_USB_MUSB_GADGET
 #define CONFIG_USB_FUNCTION_MASS_STORAGE
 #endif
 
 #ifdef CONFIG_USB_FUNCTION_FASTBOOT
 #define CONFIG_FASTBOOT_BUF_SIZE	0x8000000
 #define CONFIG_SYS_BOOTM_LEN            0x1000000
 
 #define CONFIG_SUNXI_FASTBOOT_GPIO      "PM7"
 
 #ifdef CONFIG_SUNXI_FASTBOOT_GPIO
 #  define CONFIG_BOARD_LATE_INIT
 #endif
 
 #ifdef CONFIG_MMC
 #define CONFIG_FASTBOOT_FLASH_MMC_DEV	 1
-#define CONFIG_EFI_PARTITION
+#define CONFIG_EFI_PARTITION_ENTRIES_OFF 1024000
+#define CONFIG_RANDOM_UUID
 #endif
 #endif
 
 #ifdef CONFIG_USB_FUNCTION_MASS_STORAGE
 #endif
 
 #ifdef CONFIG_USB_KEYBOARD
 #define CONFIG_PREBOOT
 #define CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE
 #endif
 
 #if !defined CONFIG_ENV_IS_IN_MMC && \
     !defined CONFIG_ENV_IS_IN_NAND && \
     !defined CONFIG_ENV_IS_IN_FAT && \
     !defined CONFIG_ENV_IS_IN_SPI_FLASH
 #define CONFIG_ENV_IS_NOWHERE
 #endif
 
 #define CONFIG_MISC_INIT_R
 
 #ifndef CONFIG_SPL_BUILD
 #include <config_distro_defaults.h>
 
 #ifdef CONFIG_ARM64
 /*
  * Boards seem to come with at least 512MB of DRAM.
  * The kernel should go at 512K, which is the default text offset (that will
  * be adjusted at runtime if needed).
  * There is no compression for arm64 kernels (yet), so leave some space
  * for really big kernels, say 256MB for now.
  * Scripts, PXE and DTBs should go afterwards, leaving the rest for the initrd.
  * Align the initrd to a 2MB page.
  */
 #define KERNEL_ADDR_R	__stringify(SDRAM_OFFSET(0080000))
 #define FDT_ADDR_R	__stringify(SDRAM_OFFSET(FA00000))
 #define SCRIPT_ADDR_R	__stringify(SDRAM_OFFSET(FC00000))
 #define PXEFILE_ADDR_R	__stringify(SDRAM_OFFSET(FD00000))
 #define RAMDISK_ADDR_R	__stringify(SDRAM_OFFSET(FE00000))
 
 #else
 /*
  * 160M RAM (256M minimum minus 64MB heap + 32MB for u-boot, stack, fb, etc.
  * 32M uncompressed kernel, 16M compressed kernel, 1M fdt,
  * 1M script, 1M pxe and the ramdisk at the end.
  */
 
 #define KERNEL_ADDR_R  __stringify(SDRAM_OFFSET(2000000))
 #define FDT_ADDR_R     __stringify(SDRAM_OFFSET(3000000))
 #define SCRIPT_ADDR_R  __stringify(SDRAM_OFFSET(3100000))
 #define PXEFILE_ADDR_R __stringify(SDRAM_OFFSET(3200000))
 #define RAMDISK_ADDR_R __stringify(SDRAM_OFFSET(3300000))
 #endif
 
 #define MEM_LAYOUT_ENV_SETTINGS \
 	"bootm_size=0xa000000\0" \
 	"kernel_addr_r=" KERNEL_ADDR_R "\0" \
 	"fdt_addr_r=" FDT_ADDR_R "\0" \
 	"scriptaddr=" SCRIPT_ADDR_R "\0" \
 	"pxefile_addr_r=" PXEFILE_ADDR_R "\0" \
 	"ramdisk_addr_r=" RAMDISK_ADDR_R "\0"
 
 #define DFU_ALT_INFO_RAM \
 	"dfu_alt_info_ram=" \
 	"kernel ram " KERNEL_ADDR_R " 0x1000000;" \
 	"fdt ram " FDT_ADDR_R " 0x100000;" \
 	"ramdisk ram " RAMDISK_ADDR_R " 0x4000000\0"
 
 #ifdef CONFIG_MMC
 #define BOOT_TARGET_DEVICES_MMC(func) func(MMC, mmc, 0)
 #if CONFIG_MMC_SUNXI_SLOT_EXTRA != -1
 #define BOOT_TARGET_DEVICES_MMC_EXTRA(func) func(MMC, mmc, 1)
 #else
 #define BOOT_TARGET_DEVICES_MMC_EXTRA(func)
 #endif
 #else
 #define BOOT_TARGET_DEVICES_MMC(func)
 #define BOOT_TARGET_DEVICES_MMC_EXTRA(func)
 #endif
 
 #ifdef CONFIG_AHCI
 #define BOOT_TARGET_DEVICES_SCSI(func) func(SCSI, scsi, 0)
 #else
 #define BOOT_TARGET_DEVICES_SCSI(func)
 #endif
 
 #ifdef CONFIG_USB_STORAGE
 #define BOOT_TARGET_DEVICES_USB(func) func(USB, usb, 0)
 #else
 #define BOOT_TARGET_DEVICES_USB(func)
 #endif
 
 #ifdef CONFIG_USB_FUNCTION_FASTBOOT
 #define BOOT_TARGET_DEVICES_FASTBOOT(func) func(FASTBOOT, fastboot, 0)
 #else
 #define BOOT_TARGET_DEVICES_FASTBOOT(func)
 #endif
 
 /* FEL boot support, auto-execute boot.scr if a script address was provided */
 #define BOOTENV_DEV_FEL(devtypeu, devtypel, instance) \
 	"bootcmd_fel=" \
 		"if test -n ${fel_booted} && test -n ${fel_scriptaddr}; then " \
 			"echo '(FEL boot)'; " \
 			"source ${fel_scriptaddr}; " \
 		"fi\0"
 #define BOOTENV_DEV_NAME_FEL(devtypeu, devtypel, instance) \
 	"fel "
 
 #define BOOTENV_DEV_FASTBOOT(devtypeu, devtypel, instance) \
         "bootcmd_fastboot=" \
 	       "fastboot musb\0"
 
 #define BOOTENV_DEV_NAME_FASTBOOT(devtypeu, devtypel, instance) \
         "fastboot "
 
 #define BOOT_TARGET_DEVICES(func) \
 	func(FEL, fel, na) \
 	BOOT_TARGET_DEVICES_MMC_EXTRA(func) \
 	BOOT_TARGET_DEVICES_MMC(func) \
 	BOOT_TARGET_DEVICES_SCSI(func) \
 	BOOT_TARGET_DEVICES_USB(func) \
 	BOOT_TARGET_DEVICES_FASTBOOT(func) \
 	func(PXE, pxe, na) \
 	func(DHCP, dhcp, na)
 
 #ifdef CONFIG_OLD_SUNXI_KERNEL_COMPAT
 #define BOOTCMD_SUNXI_COMPAT \
 	"bootcmd_sunxi_compat=" \
 		"setenv root /dev/mmcblk0p3 rootwait; " \
 		"if ext2load mmc 0 0x44000000 uEnv.txt; then " \
 			"echo Loaded environment from uEnv.txt; " \
 			"env import -t 0x44000000 ${filesize}; " \
 		"fi; " \
 		"setenv bootargs console=${console} root=${root} ${extraargs}; " \
 		"ext2load mmc 0 0x43000000 script.bin && " \
 		"ext2load mmc 0 0x48000000 uImage && " \
 		"bootm 0x48000000\0"
 #else
 #define BOOTCMD_SUNXI_COMPAT
 #endif
 
 #include <config_distro_bootcmd.h>
 
 #ifdef CONFIG_USB_KEYBOARD
 #define CONSOLE_STDIN_SETTINGS \
 	"preboot=usb start\0" \
 	"stdin=serial,usbkbd\0"
 #else
 #define CONSOLE_STDIN_SETTINGS \
 	"stdin=serial\0"
 #endif
 
 #ifdef CONFIG_VIDEO
 #define CONSOLE_STDOUT_SETTINGS \
 	"stdout=serial,vga\0" \
 	"stderr=serial,vga\0"
 #else
 #define CONSOLE_STDOUT_SETTINGS \
 	"stdout=serial\0" \
 	"stderr=serial\0"
 #endif
 
 #define CONSOLE_ENV_SETTINGS \
 	CONSOLE_STDIN_SETTINGS \
 	CONSOLE_STDOUT_SETTINGS
 
 /* The space below the paritions-entries is reserved by the EFI
  * partition table (i.e. 'first_usable_lba' points to the first
  * LBA beyond the table.  We thus don't need to have any 'magic'
  * partitions for the bootloader or any other reserved areas.
  */
 #define CONFIG_EFI_PARTITION_ENTRIES_OFF 1024000
 #define PARTS_DEFAULT \
   "uuid_disk=${uuid_gpt_disk};" \
   "name=resource,size=16M;" \
   "name=boot,size=16M;" \
   "name=system,size=500M,uuid=69dad710-2ce4-4e3c-b16c-21a1d49abed3;" \
   "name=cache,size=256M;" \
   "name=databk,size=128M;" \
   "name=data,size=-,uuid=933ac7e1-2eb4-4f13-b844-0e14e2aef915;"
 
 #if (CONFIG_CONS_INDEX == 1)
 #define CONSOLE_DEFAULT "console=ttyS0,115200\0"
 #elif (CONFIG_CONS_INDEX == 3)
 #define CONSOLE_DEFAULT "console=ttyS2,115200\0"
 #else
 #error "CONFIG_CONS_INDEX to CONFIG_DEFAULT_CONSOLE_ENV missing."
 #endif
 
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	CONSOLE_ENV_SETTINGS \
 	MEM_LAYOUT_ENV_SETTINGS \
 	DFU_ALT_INFO_RAM \
 	"partitions=" PARTS_DEFAULT "\0" \
 	"partitions_linux=" \
         "uuid_disk=${uuid_gpt_disk};" \
 	"name=rootfs,size=-,uuid=69dad710-2ce4-4e3c-b16c-21a1d49abed3\0" \
 	"fdtfile=" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" \
 	CONSOLE_DEFAULT \
 	BOOTCMD_SUNXI_COMPAT \
 	BOOTENV
 
 #else /* ifndef CONFIG_SPL_BUILD */
 #define CONFIG_EXTRA_ENV_SETTINGS
 #endif
 
 #endif /* _SUNXI_COMMON_CONFIG_H */
-- 
1.9.1

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

* [U-Boot] [PATCH v1 0/2] disk: efi: allow gap before partition entries
  2017-02-17 17:31 [U-Boot] [PATCH v1 0/2] disk: efi: allow gap before partition entries Philipp Tomsich
  2017-02-17 17:31 ` [U-Boot] [PATCH v1 1/2] part_efi: support padding between the GPT header and " Philipp Tomsich
  2017-02-17 17:31 ` [U-Boot] [PATCH v1 2/2] sunxi-common: add EFI_PARTITION_ENTRIES_OFF, CONFIG_RANDOM_UUID and CONFIG_CMD_GPT Philipp Tomsich
@ 2017-02-21 17:45 ` Maxime Ripard
  2017-02-21 18:10   ` Dr. Philipp Tomsich
  2017-02-21 18:21   ` Dr. Philipp Tomsich
  2017-02-22  6:11 ` Rask Ingemann Lambertsen
  3 siblings, 2 replies; 10+ messages in thread
From: Maxime Ripard @ 2017-02-21 17:45 UTC (permalink / raw)
  To: u-boot

Hi Philipp,

On Fri, Feb 17, 2017 at 06:31:29PM +0100, Philipp Tomsich wrote:
> Motivated by the the SPL layout for SD/MMC devices on Allwinner SoCs
> (the SPL code needs to reside an 8K offset into the device), we add
> support for leaving a gap between the MBR (LBA#0), GPT header (LBA#1)
> and GPT partition entries (linked from field in the GPT header).
> 
> Note that this affects the creation of partition from U-Boot only and
> has no effect on reading existing partition tables.
> 
> If defined, EFI_PARTITION_ENTRIES_OFF specifies a byte-offset into
> a device and the parititon entries will be located starting at the
> next LBA folling this offset.
> 
> In the latest incarnation of this change, we also allow the byte
> offset to be read from the 'u-boot,efi-partition-entries-offset'
> property of the '/config' node in the device-tree.
> 
> There's a similar change for gparted floating around the internet:
> 	http://lists.alioth.debian.org/pipermail/parted-devel/2016-March/004826.html
> 
> This change has been in production use on our modules for a while
> (over a year) both with a Linux and Android userspace.

Nice patch. We came up with the same need, but had to restrict the
number of partitions in order to achieve the same goel. This is
obviously a much better solution.

However, I'm a bit skeptical on the /config node. First, this node
doesn't exist at all, and needs to be documented and acked by the DT
maintainers. And why would one need to change that per device?

Also, and this is something that affects all your patches, you
generated them with way too many context, which makes review more
difficults, and make them more conflicts prone. git format-patch
should just do the right thing.

Threading is also kind of broken (even though that's not really a big
deal). git send-email with --no-chain-reply-to will just work too.

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170221/29a9c057/attachment.sig>

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

* [U-Boot] [PATCH v1 0/2] disk: efi: allow gap before partition entries
  2017-02-21 17:45 ` [U-Boot] [PATCH v1 0/2] disk: efi: allow gap before partition entries Maxime Ripard
@ 2017-02-21 18:10   ` Dr. Philipp Tomsich
  2017-02-21 18:21   ` Dr. Philipp Tomsich
  1 sibling, 0 replies; 10+ messages in thread
From: Dr. Philipp Tomsich @ 2017-02-21 18:10 UTC (permalink / raw)
  To: u-boot

Maxime,

> On 21 Feb 2017, at 18:45, Maxime Ripard <maxime.ripard@free-electrons.com> wrote:
> 
> Hi Philipp,
> 
> On Fri, Feb 17, 2017 at 06:31:29PM +0100, Philipp Tomsich wrote:
>> Motivated by the the SPL layout for SD/MMC devices on Allwinner SoCs
>> (the SPL code needs to reside an 8K offset into the device), we add
>> support for leaving a gap between the MBR (LBA#0), GPT header (LBA#1)
>> and GPT partition entries (linked from field in the GPT header).
>> 
>> Note that this affects the creation of partition from U-Boot only and
>> has no effect on reading existing partition tables.
>> 
>> If defined, EFI_PARTITION_ENTRIES_OFF specifies a byte-offset into
>> a device and the parititon entries will be located starting at the
>> next LBA folling this offset.
>> 
>> In the latest incarnation of this change, we also allow the byte
>> offset to be read from the 'u-boot,efi-partition-entries-offset'
>> property of the '/config' node in the device-tree.
>> 
>> There's a similar change for gparted floating around the internet:
>> 	http://lists.alioth.debian.org/pipermail/parted-devel/2016-March/004826.html
>> 
>> This change has been in production use on our modules for a while
>> (over a year) both with a Linux and Android userspace.
> 
> Nice patch. We came up with the same need, but had to restrict the
> number of partitions in order to achieve the same goel. This is
> obviously a much better solution.
> 
> However, I'm a bit skeptical on the /config node. First, this node
> doesn't exist at all, and needs to be documented and acked by the DT
> maintainers. And why would one need to change that per device?

We are currently using the #define for production deployments, but
we have gotten the feedback that it would be nice to change this setting
easily without recompiling.

We also use different settings for the sun6i/sun9i and sun50i modules,
as code-size increases with AArch64 code...

> Also, and this is something that affects all your patches, you
> generated them with way too many context, which makes review more
> difficults, and make them more conflicts prone. git format-patch
> should just do the right thing.

Yes, I noticed that too, but apparently had my setup misconfigured on
Friday?you can probably imagine that pushing all these out on one
day was a bit hectic.

> Threading is also kind of broken (even though that's not really a big
> deal). git send-email with --no-chain-reply-to will just work too.
> 
> Thanks!
> Maxime
> 
> -- 
> Maxime Ripard, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com <http://free-electrons.com/>

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

* [U-Boot] [PATCH v1 0/2] disk: efi: allow gap before partition entries
  2017-02-21 17:45 ` [U-Boot] [PATCH v1 0/2] disk: efi: allow gap before partition entries Maxime Ripard
  2017-02-21 18:10   ` Dr. Philipp Tomsich
@ 2017-02-21 18:21   ` Dr. Philipp Tomsich
  2017-02-22 17:38     ` Maxime Ripard
  1 sibling, 1 reply; 10+ messages in thread
From: Dr. Philipp Tomsich @ 2017-02-21 18:21 UTC (permalink / raw)
  To: u-boot


> On 21 Feb 2017, at 18:45, Maxime Ripard <maxime.ripard@free-electrons.com> wrote:
> 
> However, I'm a bit skeptical on the /config node. First, this node
> doesn't exist at all, and needs to be documented and acked by the DT
> maintainers. And why would one need to change that per device?

What?s the consensus on this: remove the /config-node dependency
(or split off into a separate patch), make the CONFIG-option a first
class citizen and add to Kconfig? and reroll as v2?

?Phil.

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

* [U-Boot] [PATCH v1 1/2] part_efi: support padding between the GPT header and partition entries
  2017-02-17 17:31 ` [U-Boot] [PATCH v1 1/2] part_efi: support padding between the GPT header and " Philipp Tomsich
@ 2017-02-22  3:59   ` Simon Glass
  0 siblings, 0 replies; 10+ messages in thread
From: Simon Glass @ 2017-02-22  3:59 UTC (permalink / raw)
  To: u-boot

Hi,

On 17 February 2017 at 10:31, Philipp Tomsich
<philipp.tomsich@theobroma-systems.com> wrote:
> Some architectures require their SPL loader at a fixed address within
> the first 16KB of the disk. To avoid an overlap with the partition
> entries of the EFI partition table, the first safe offset (in bytes,
> from the start of the device) for the entries can be set through
> CONFIG_EFI_PARTITION_ENTRIES_OFF.
>
> When formatting a device with an EFI parition table, we may need to
> leave a gap between the GPT header (always in LBA 1) and the partition
> entries. The GPT header already contains a field to specify the
> on-disk location, which has so far always been set to LBA 2. With this
> change, a configurable offset will be translated into a LBA address
> indicating where to put the entries.
>
> Now also allows an override via device-tree using a config-node.
>
> Tested (exporting an internal MMC formatted with this) against Linux,
> MacOS X and Windows.
>
> Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> ---
>  disk/part_efi.c              | 46 ++++++++++++++++++++++++++++++++++++++++----
>  scripts/config_whitelist.txt |  1 +
>  2 files changed, 43 insertions(+), 4 deletions(-)

Looks good to me. But there are a few things to tweak, sorry.

Can you please send v2 without all the context lines, and use
CONFIG_OF_CONTROL instead of CONFIG_OF_LIBFDT?

Also you cannot add new CONFIG options. You should add your new option
to a Kconfig file.

For your device tree property, that should be documented in
'Configuration Options' in README.fdt-control. Or better if you can
send a patch to move that section out of that file into
doc/device-tree-bindings/config.txt and then put your new one in
there...

Regards,
Simon

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

* [U-Boot] [PATCH v1 0/2] disk: efi: allow gap before partition entries
  2017-02-17 17:31 [U-Boot] [PATCH v1 0/2] disk: efi: allow gap before partition entries Philipp Tomsich
                   ` (2 preceding siblings ...)
  2017-02-21 17:45 ` [U-Boot] [PATCH v1 0/2] disk: efi: allow gap before partition entries Maxime Ripard
@ 2017-02-22  6:11 ` Rask Ingemann Lambertsen
  2017-02-22 10:08   ` Dr. Philipp Tomsich
  3 siblings, 1 reply; 10+ messages in thread
From: Rask Ingemann Lambertsen @ 2017-02-22  6:11 UTC (permalink / raw)
  To: u-boot

On Fri, Feb 17, 2017 at 06:31:29PM +0100, Philipp Tomsich wrote:
> Motivated by the the SPL layout for SD/MMC devices on Allwinner SoCs
> (the SPL code needs to reside an 8K offset into the device), we add
> support for leaving a gap between the MBR (LBA#0), GPT header (LBA#1)
> and GPT partition entries (linked from field in the GPT header).
> 
> Note that this affects the creation of partition from U-Boot only and
> has no effect on reading existing partition tables.
> 
> If defined, EFI_PARTITION_ENTRIES_OFF specifies a byte-offset into
> a device and the parititon entries will be located starting at the
> next LBA folling this offset.

In principle, this isn't really EFI specific, because all partition table
formats will need to avoid the SPL area, so the configuration string
shouldn't include the word EFI. EFI just happens to be the only(?) partition
table format which is bloated enough to not easily fit into the space before
the SPL area.

Also, it seems to me that there should also be a way of specifying how much
room is available before the SPL area. So you could have
CONFIG_SPL_AREA_START and CONFIG_SPL_AREA_SIZE, which added together gives
the same value as your EFI_PARTITION_ENTRIES_OFF.

-- 
Rask Ingemann Lambertsen

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

* [U-Boot] [PATCH v1 0/2] disk: efi: allow gap before partition entries
  2017-02-22  6:11 ` Rask Ingemann Lambertsen
@ 2017-02-22 10:08   ` Dr. Philipp Tomsich
  0 siblings, 0 replies; 10+ messages in thread
From: Dr. Philipp Tomsich @ 2017-02-22 10:08 UTC (permalink / raw)
  To: u-boot


> On 22 Feb 2017, at 07:11, Rask Ingemann Lambertsen <rask@formelder.dk> wrote:
> 
> On Fri, Feb 17, 2017 at 06:31:29PM +0100, Philipp Tomsich wrote:
>> Motivated by the the SPL layout for SD/MMC devices on Allwinner SoCs
>> (the SPL code needs to reside an 8K offset into the device), we add
>> support for leaving a gap between the MBR (LBA#0), GPT header (LBA#1)
>> and GPT partition entries (linked from field in the GPT header).
>> 
>> Note that this affects the creation of partition from U-Boot only and
>> has no effect on reading existing partition tables.
>> 
>> If defined, EFI_PARTITION_ENTRIES_OFF specifies a byte-offset into
>> a device and the parititon entries will be located starting at the
>> next LBA folling this offset.
> 
> In principle, this isn't really EFI specific, because all partition table
> formats will need to avoid the SPL area, so the configuration string
> shouldn't include the word EFI. EFI just happens to be the only(?) partition
> table format which is bloated enough to not easily fit into the space before
> the SPL area.
> 
> Also, it seems to me that there should also be a way of specifying how much
> room is available before the SPL area. So you could have
> CONFIG_SPL_AREA_START and CONFIG_SPL_AREA_SIZE, which added together gives
> the same value as your EFI_PARTITION_ENTRIES_OFF.

I would rather keep it simple for now, as it?s not just the SPL that we worry
about. In our default configuration, we punch a hole (of blocks not covered
by the partition tables, as they reside between the GPT header and the
partition entries) of at least 1MB (in some applications more) into the device
and then keep all of the following there:
1/	SPL
2/	FIT boot payload
3/	U-Boot environment

Regards,
Philipp.

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

* [U-Boot] [PATCH v1 0/2] disk: efi: allow gap before partition entries
  2017-02-21 18:21   ` Dr. Philipp Tomsich
@ 2017-02-22 17:38     ` Maxime Ripard
  0 siblings, 0 replies; 10+ messages in thread
From: Maxime Ripard @ 2017-02-22 17:38 UTC (permalink / raw)
  To: u-boot

On Tue, Feb 21, 2017 at 07:21:42PM +0100, Dr. Philipp Tomsich wrote:
> 
> > On 21 Feb 2017, at 18:45, Maxime Ripard <maxime.ripard@free-electrons.com> wrote:
> > 
> > However, I'm a bit skeptical on the /config node. First, this node
> > doesn't exist at all, and needs to be documented and acked by the DT
> > maintainers. And why would one need to change that per device?
> 
> What?s the consensus on this: remove the /config-node dependency
> (or split off into a separate patch), make the CONFIG-option a first
> class citizen and add to Kconfig? and reroll as v2?

If Simon is happy with /config parameter, so am I, but yeah, moving it
to Kconfig is needed.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170222/ec743425/attachment.sig>

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

end of thread, other threads:[~2017-02-22 17:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-17 17:31 [U-Boot] [PATCH v1 0/2] disk: efi: allow gap before partition entries Philipp Tomsich
2017-02-17 17:31 ` [U-Boot] [PATCH v1 1/2] part_efi: support padding between the GPT header and " Philipp Tomsich
2017-02-22  3:59   ` Simon Glass
2017-02-17 17:31 ` [U-Boot] [PATCH v1 2/2] sunxi-common: add EFI_PARTITION_ENTRIES_OFF, CONFIG_RANDOM_UUID and CONFIG_CMD_GPT Philipp Tomsich
2017-02-21 17:45 ` [U-Boot] [PATCH v1 0/2] disk: efi: allow gap before partition entries Maxime Ripard
2017-02-21 18:10   ` Dr. Philipp Tomsich
2017-02-21 18:21   ` Dr. Philipp Tomsich
2017-02-22 17:38     ` Maxime Ripard
2017-02-22  6:11 ` Rask Ingemann Lambertsen
2017-02-22 10:08   ` Dr. Philipp Tomsich

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.