All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/5] Use Android DT image format for TI boards
@ 2018-04-16 20:32 Sam Protsenko
  2018-04-16 20:32 ` [U-Boot] [PATCH 1/5] common: Add support for Android DT image Sam Protsenko
                   ` (6 more replies)
  0 siblings, 7 replies; 22+ messages in thread
From: Sam Protsenko @ 2018-04-16 20:32 UTC (permalink / raw)
  To: u-boot

Android documentation recommends using new image format for storing dtb
and dtbo files: [1]. Using that format, we can pack several dtb files to
dtb.img, and also pack several dtbo files to dtbo.img. Then those images
should be flashed to eMMC partitions, called "dtb" and "dtbo"
respectively.

This patch series introduces support for mentioned Android DT image
format, adds "dtimg" command to deal with that image format from U-Boot
shell, and provides new Android boot scheme to TI boards (AM57x and DRA7
boards). So with this patch series we will have next procedure for
Android boot:
 1. Read next images from eMMC partitions to RAM:
    - boot.img
    - dtb.img
    - dtbo.img
 2. Take addresses of desired dtb/dtbo files from that images (for
    current board)
 3. Apply dtbo overlays to main dtb, if needed
 4. Boot the kernel from Android boot image, using resulting dtb

It was tested on X15 and AM57x EVM boards.

[1] https://source.android.com/devices/architecture/dto/partitions

Sam Protsenko (5):
  common: Add support for Android DT image
  cmd: Add dtimg command
  arm: ti: boot: Extract PARTS_DEFAULT to boot.h
  arm: ti: boot: Add dtbo partition for Android boot
  arm: ti: boot: Implement Android boot using DT image format

 board/ti/common/Kconfig           |   1 +
 cmd/Kconfig                       |   8 ++
 cmd/Makefile                      |   1 +
 cmd/dtimg.c                       | 142 ++++++++++++++++++++++++++++++
 common/Makefile                   |   4 +
 common/image-android-dt.c         | 134 ++++++++++++++++++++++++++++
 configs/am57xx_evm_defconfig      |   1 +
 configs/am57xx_hs_evm_defconfig   |   1 +
 configs/dra7xx_evm_defconfig      |   1 +
 configs/dra7xx_hs_evm_defconfig   |   1 +
 include/configs/am57xx_evm.h      |  25 ------
 include/configs/cl-som-am57x.h    |   2 +
 include/configs/cm_t54.h          |   2 +
 include/configs/dra7xx_evm.h      |  25 ------
 include/configs/ti_armv7_common.h |   1 +
 include/dt_table.h                |  46 ++++++++++
 include/environment/ti/boot.h     |  68 ++++++++++++--
 include/image-android-dt.h        |  18 ++++
 18 files changed, 422 insertions(+), 59 deletions(-)
 create mode 100644 cmd/dtimg.c
 create mode 100644 common/image-android-dt.c
 create mode 100644 include/dt_table.h
 create mode 100644 include/image-android-dt.h

-- 
2.17.0

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

* [U-Boot] [PATCH 1/5] common: Add support for Android DT image
  2018-04-16 20:32 [U-Boot] [PATCH 0/5] Use Android DT image format for TI boards Sam Protsenko
@ 2018-04-16 20:32 ` Sam Protsenko
  2018-04-19 20:24   ` Sam Protsenko
  2018-04-16 20:32 ` [U-Boot] [PATCH 2/5] cmd: Add dtimg command Sam Protsenko
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 22+ messages in thread
From: Sam Protsenko @ 2018-04-16 20:32 UTC (permalink / raw)
  To: u-boot

Android documentation recommends new image format for storing DTB/DTBO
files: [1]. To support that format, two things should be done:

1. Add dt_table.h file from Android (BSD-3 relicensed version): [2].
   This header defines structures and constants that we need to work
   with that DT image format.

   Changes:
    - re-licensed from Apache to BSD-3
    - removed functions declarations
    - change the coding style to kernel (make checkpatch happy)

2. Add helper functions for Android DTB/DTBO format. In
   image-android-dt.* files you can find helper functions to work with
   Android DT image format, such us routines for:
    - printing the dump of image structure
    - getting the address and size of desired dtb/dtbo file

[1] https://source.android.com/devices/architecture/dto/partitions
[2] https://android.googlesource.com/platform/system/libufdt/+/58a7582180f477032cd6c74f8d9afad0038e74c3/utils/src/dt_table.h

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
---
 common/image-android-dt.c  | 134 +++++++++++++++++++++++++++++++++++++
 include/dt_table.h         |  46 +++++++++++++
 include/image-android-dt.h |  18 +++++
 3 files changed, 198 insertions(+)
 create mode 100644 common/image-android-dt.c
 create mode 100644 include/dt_table.h
 create mode 100644 include/image-android-dt.h

diff --git a/common/image-android-dt.c b/common/image-android-dt.c
new file mode 100644
index 0000000000..f218db06bb
--- /dev/null
+++ b/common/image-android-dt.c
@@ -0,0 +1,134 @@
+/*
+ * (C) Copyright 2018 Linaro Ltd.
+ * Sam Protsenko <semen.protsenko@linaro.org>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <image-android-dt.h>
+#include <common.h>
+#include <linux/libfdt_env.h>
+#include <linux/libfdt.h>
+
+/**
+ * Check if image header is correct.
+ *
+ * @param hdr Address to image header
+ * @return true if header is correct or false if header is incorrect
+ */
+bool android_dt_check_header(const struct dt_table_header *hdr)
+{
+	return fdt32_to_cpu(hdr->magic) == DT_TABLE_MAGIC;
+}
+
+/**
+ * Get the address of FDT (dtb or dtbo) in memory by its index in image.
+ *
+ * @param hdr Address to image header
+ * @param index Index of desired FDT in image (starting from 0)
+ * @param[out] addr If not null, will contain address to specified FDT
+ * @param[out] size If not NULL, will contain size of specified FDT
+ *
+ * @return true on success or false on error
+ */
+bool android_dt_get_fdt_by_index(const struct dt_table_header *hdr,
+				 u32 index, ulong *addr, u32 *size)
+{
+	const struct dt_table_entry *e;
+	u32 entry_count = fdt32_to_cpu(hdr->dt_entry_count);
+	u32 entries_offset = fdt32_to_cpu(hdr->dt_entries_offset);
+	u32 entry_size = fdt32_to_cpu(hdr->dt_entry_size);
+	u32 dt_offset, dt_size;
+
+	if (index > entry_count) {
+		printf("Error: index > dt_entry_count (%u > %u)\n", index,
+		       entry_count);
+		return false;
+	}
+
+	e = (const struct dt_table_entry *)((ulong)hdr + entries_offset
+			+ index * entry_size);
+	dt_offset = fdt32_to_cpu(e->dt_offset);
+	dt_size = fdt32_to_cpu(e->dt_size);
+
+	if (addr)
+		*addr = ((ulong)hdr + dt_offset);
+	if (size)
+		*size = dt_size;
+
+	return true;
+}
+
+#if !defined(CONFIG_SPL_BUILD)
+static void android_dt_print_fdt_info(const struct fdt_header *fdt)
+{
+	u32 fdt_size;
+	int root_node_off;
+	const char *compatible = NULL;
+
+	fdt_size = fdt_totalsize(fdt);
+	root_node_off = fdt_path_offset(fdt, "/");
+	if (root_node_off < 0) {
+		printf("Error: Root node not found\n");
+	} else {
+		compatible = fdt_getprop(fdt, root_node_off, "compatible",
+					 NULL);
+	}
+
+	printf("           (FDT)size = %d\n", fdt_size);
+	printf("     (FDT)compatible = %s\n",
+	       compatible ? compatible : "(unknown)");
+}
+
+/**
+ * Print information about DT image structure.
+ *
+ * @param hdr Address to image header
+ */
+void android_dt_print_contents(const struct dt_table_header *hdr)
+{
+	u32 i;
+	u32 entry_count = fdt32_to_cpu(hdr->dt_entry_count);
+	u32 entries_offset = fdt32_to_cpu(hdr->dt_entries_offset);
+	u32 entry_size = fdt32_to_cpu(hdr->dt_entry_size);
+
+	/* Print image header info */
+	printf("dt_table_header:\n");
+	printf("               magic = %08x\n", fdt32_to_cpu(hdr->magic));
+	printf("          total_size = %d\n", fdt32_to_cpu(hdr->total_size));
+	printf("         header_size = %d\n", fdt32_to_cpu(hdr->header_size));
+	printf("       dt_entry_size = %d\n", entry_size);
+	printf("      dt_entry_count = %d\n", entry_count);
+	printf("   dt_entries_offset = %d\n", entries_offset);
+	printf("           page_size = %d\n", fdt32_to_cpu(hdr->page_size));
+	printf("         reserved[0] = %08x\n", fdt32_to_cpu(hdr->reserved[0]));
+
+	/* Print image entries info */
+	for (i = 0; i < entry_count; ++i) {
+		const struct dt_table_entry *e;
+		const struct fdt_header *fdt;
+		u32 dt_offset, dt_size;
+		u32 j;
+
+		e = (const struct dt_table_entry *)((ulong)hdr + entries_offset
+				+ i * entry_size);
+		dt_offset = fdt32_to_cpu(e->dt_offset);
+		dt_size = fdt32_to_cpu(e->dt_size);
+
+		printf("dt_table_entry[%d]:\n", i);
+		printf("             dt_size = %d\n", dt_size);
+		printf("           dt_offset = %d\n", dt_offset);
+		printf("                  id = %08x\n", fdt32_to_cpu(e->id));
+		printf("                 rev = %08x\n", fdt32_to_cpu(e->rev));
+
+		for (j = 0; j < 4; ++j) {
+			printf("           custom[%d] = %08x\n", j,
+			       fdt32_to_cpu(e->custom[j]));
+		}
+
+		/* Print FDT info for this entry */
+		fdt = (const struct fdt_header *)((ulong)hdr + dt_offset);
+		android_dt_print_fdt_info(fdt);
+	}
+}
+#endif
diff --git a/include/dt_table.h b/include/dt_table.h
new file mode 100644
index 0000000000..19cbbeab2a
--- /dev/null
+++ b/include/dt_table.h
@@ -0,0 +1,46 @@
+/*
+ * This is from the Android Project,
+ * Repository: https://android.googlesource.com/platform/system/libufdt
+ * File: utils/src/dt_table.h
+ * Commit: 58a7582180f477032cd6c74f8d9afad0038e74c3
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef DT_TABLE_H
+#define DT_TABLE_H
+
+#include <linux/types.h>
+
+#define DT_TABLE_MAGIC			0xd7b7ab1e
+#define DT_TABLE_DEFAULT_PAGE_SIZE	2048
+
+struct dt_table_header {
+	u32 magic;		/* DT_TABLE_MAGIC */
+	u32 total_size;		/* includes dt_table_header + all dt_table_entry
+				 * and all dtb/dtbo
+				 */
+	u32 header_size;	/* sizeof(dt_table_header) */
+
+	u32 dt_entry_size;	/* sizeof(dt_table_entry) */
+	u32 dt_entry_count;	/* number of dt_table_entry */
+	u32 dt_entries_offset;	/* offset to the first dt_table_entry
+				 * from head of dt_table_header.
+				 * The value will be equal to header_size if
+				 * no padding is appended
+				 */
+	u32 page_size;		/* flash page size we assume */
+	u32 reserved[1];	/* must be zero */
+};
+
+struct dt_table_entry {
+	u32 dt_size;
+	u32 dt_offset;		/* offset from head of dt_table_header */
+
+	u32 id;			/* optional, must be zero if unused */
+	u32 rev;		/* optional, must be zero if unused */
+	u32 custom[4];		/* optional, must be zero if unused */
+};
+
+#endif
diff --git a/include/image-android-dt.h b/include/image-android-dt.h
new file mode 100644
index 0000000000..f9b5ff3f13
--- /dev/null
+++ b/include/image-android-dt.h
@@ -0,0 +1,18 @@
+/*
+ * (C) Copyright 2018 Linaro Ltd.
+ * Sam Protsenko <semen.protsenko@linaro.org>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef IMAGE_ANDROID_DT_H
+#define IMAGE_ANDROID_DT_H
+
+#include <dt_table.h>
+
+bool android_dt_check_header(const struct dt_table_header *hdr);
+void android_dt_print_contents(const struct dt_table_header *hdr);
+bool android_dt_get_fdt_by_index(const struct dt_table_header *hdr,
+				 u32 index, ulong *addr, u32 *size);
+
+#endif /* IMAGE_ANDROID_DT_H */
-- 
2.17.0

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

* [U-Boot] [PATCH 2/5] cmd: Add dtimg command
  2018-04-16 20:32 [U-Boot] [PATCH 0/5] Use Android DT image format for TI boards Sam Protsenko
  2018-04-16 20:32 ` [U-Boot] [PATCH 1/5] common: Add support for Android DT image Sam Protsenko
@ 2018-04-16 20:32 ` Sam Protsenko
  2018-04-19 20:25   ` Sam Protsenko
  2018-04-16 20:32 ` [U-Boot] [PATCH 3/5] arm: ti: boot: Extract PARTS_DEFAULT to boot.h Sam Protsenko
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 22+ messages in thread
From: Sam Protsenko @ 2018-04-16 20:32 UTC (permalink / raw)
  To: u-boot

dtimg command allows user to work with Android DTB/DTBO image format.
Such as, getting the address of desired DTB/DTBO file, printing the dump
of the image in U-Boot shell, etc.

This command is needed to provide Android boot with new Android DT image
format further.

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
---
 cmd/Kconfig     |   8 +++
 cmd/Makefile    |   1 +
 cmd/dtimg.c     | 142 ++++++++++++++++++++++++++++++++++++++++++++++++
 common/Makefile |   4 ++
 4 files changed, 155 insertions(+)
 create mode 100644 cmd/dtimg.c

diff --git a/cmd/Kconfig b/cmd/Kconfig
index bc1d2f31c0..68f3cc7b48 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -256,6 +256,14 @@ config CMD_BOOTMENU
 	help
 	  Add an ANSI terminal boot menu command.
 
+config CMD_DTIMG
+	bool "dtimg"
+	help
+	  Android DTB/DTBO image manipulation commands. Read dtb/dtbo files from
+	  image into RAM, dump image structure information, etc. Those dtb/dtbo
+	  files should be merged in one dtb further, which needs to be passed to
+	  the kernel, as part of a boot process.
+
 config CMD_ELF
 	bool "bootelf, bootvx"
 	default y
diff --git a/cmd/Makefile b/cmd/Makefile
index c4269ac8ac..1cc2e74e9e 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -43,6 +43,7 @@ ifdef CONFIG_POST
 obj-$(CONFIG_CMD_DIAG) += diag.o
 endif
 obj-$(CONFIG_CMD_DISPLAY) += display.o
+obj-$(CONFIG_CMD_DTIMG) += dtimg.o
 obj-$(CONFIG_CMD_ECHO) += echo.o
 obj-$(CONFIG_ENV_IS_IN_EEPROM) += eeprom.o
 obj-$(CONFIG_CMD_EEPROM) += eeprom.o
diff --git a/cmd/dtimg.c b/cmd/dtimg.c
new file mode 100644
index 0000000000..0b046402fe
--- /dev/null
+++ b/cmd/dtimg.c
@@ -0,0 +1,142 @@
+/*
+ * (C) Copyright 2018 Linaro Ltd.
+ * Sam Protsenko <semen.protsenko@linaro.org>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <image-android-dt.h>
+#include <common.h>
+
+enum cmd_dtimg_info {
+	CMD_DTIMG_START = 0,
+	CMD_DTIMG_SIZE,
+};
+
+static int do_dtimg_dump(cmd_tbl_t *cmdtp, int flag, int argc,
+			 char * const argv[])
+{
+	char *endp;
+	void *hdr;
+
+	if (argc != 2)
+		return CMD_RET_USAGE;
+
+	hdr = (void *)simple_strtoul(argv[1], &endp, 16);
+	if (*endp != '\0') {
+		printf("Error: Wrong image address\n");
+		return CMD_RET_FAILURE;
+	}
+
+	if (!android_dt_check_header(hdr)) {
+		printf("Error: DT image header is incorrect\n");
+		return CMD_RET_FAILURE;
+	}
+
+	android_dt_print_contents(hdr);
+
+	return CMD_RET_SUCCESS;
+}
+
+static int dtimg_get_fdt(int argc, char * const argv[], enum cmd_dtimg_info cmd)
+{
+	void *hdr;
+	u32 index;
+	char *endp;
+	ulong addr;
+	u32 size;
+	char buf[512] = { 0 };
+
+	if (argc != 4)
+		return CMD_RET_USAGE;
+
+	hdr = (void *)simple_strtoul(argv[1], &endp, 16);
+	if (*endp != '\0') {
+		printf("Error: Wrong image address\n");
+		return CMD_RET_FAILURE;
+	}
+
+	if (!android_dt_check_header(hdr)) {
+		printf("Error: DT image header is incorrect\n");
+		return CMD_RET_FAILURE;
+	}
+
+	index = simple_strtoul(argv[2], &endp, 0);
+	if (*endp != '\0') {
+		printf("Error: Wrong index\n");
+		return CMD_RET_FAILURE;
+	}
+
+	if (!android_dt_get_fdt_by_index(hdr, index, &addr, &size))
+		return CMD_RET_FAILURE;
+
+	switch (cmd) {
+	case CMD_DTIMG_START:
+		snprintf(buf, sizeof(buf), "%p", (void *)addr);
+		break;
+	case CMD_DTIMG_SIZE:
+		snprintf(buf, sizeof(buf), "%x", size);
+		break;
+	default:
+		printf("Error: Unknown cmd_dtimg_info value: %d\n", cmd);
+		return CMD_RET_FAILURE;
+	}
+
+	env_set(argv[3], buf);
+
+	return CMD_RET_SUCCESS;
+}
+
+static int do_dtimg_start(cmd_tbl_t *cmdtp, int flag, int argc,
+			  char * const argv[])
+{
+	return dtimg_get_fdt(argc, argv, CMD_DTIMG_START);
+}
+
+static int do_dtimg_size(cmd_tbl_t *cmdtp, int flag, int argc,
+			 char * const argv[])
+{
+	return dtimg_get_fdt(argc, argv, CMD_DTIMG_SIZE);
+}
+
+static cmd_tbl_t cmd_dtimg_sub[] = {
+	U_BOOT_CMD_MKENT(dump, 2, 0, do_dtimg_dump, "", ""),
+	U_BOOT_CMD_MKENT(start, 4, 0, do_dtimg_start, "", ""),
+	U_BOOT_CMD_MKENT(size, 4, 0, do_dtimg_size, "", ""),
+};
+
+static int do_dtimg(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	cmd_tbl_t *cp;
+
+	cp = find_cmd_tbl(argv[1], cmd_dtimg_sub, ARRAY_SIZE(cmd_dtimg_sub));
+
+	/* Strip off leading 'dtimg' command argument */
+	argc--;
+	argv++;
+
+	if (!cp || argc > cp->maxargs)
+		return CMD_RET_USAGE;
+	if (flag == CMD_FLAG_REPEAT && !cp->repeatable)
+		return CMD_RET_SUCCESS;
+
+	return cp->cmd(cmdtp, flag, argc, argv);
+}
+
+U_BOOT_CMD(
+	dtimg, CONFIG_SYS_MAXARGS, 0, do_dtimg,
+	"manipulate dtb/dtbo Android image",
+	"dump <addr>\n"
+	"    - parse specified image and print its structure info\n"
+	"      <addr>: image address in RAM, in hex\n"
+	"dtimg start <addr> <index> <varname>\n"
+	"    - get address (hex) of FDT in the image, by index\n"
+	"      <addr>: image address in RAM, in hex\n"
+	"      <index>: index of desired FDT in the image\n"
+	"      <varname>: name of variable where to store address of FDT\n"
+	"dtimg size <addr> <index> <varname>\n"
+	"    - get size (hex, bytes) of FDT in the image, by index\n"
+	"      <addr>: image address in RAM, in hex\n"
+	"      <index>: index of desired FDT in the image\n"
+	"      <varname>: name of variable where to store size of FDT"
+);
diff --git a/common/Makefile b/common/Makefile
index 7011dada99..6ef55d0d7a 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -111,6 +111,10 @@ obj-$(CONFIG_IO_TRACE) += iotrace.o
 obj-y += memsize.o
 obj-y += stdio.o
 
+ifdef CONFIG_CMD_DTIMG
+obj-y += image-android-dt.o
+endif
+
 ifndef CONFIG_SPL_BUILD
 # This option is not just y/n - it can have a numeric value
 ifdef CONFIG_FASTBOOT_FLASH
-- 
2.17.0

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

* [U-Boot] [PATCH 3/5] arm: ti: boot: Extract PARTS_DEFAULT to boot.h
  2018-04-16 20:32 [U-Boot] [PATCH 0/5] Use Android DT image format for TI boards Sam Protsenko
  2018-04-16 20:32 ` [U-Boot] [PATCH 1/5] common: Add support for Android DT image Sam Protsenko
  2018-04-16 20:32 ` [U-Boot] [PATCH 2/5] cmd: Add dtimg command Sam Protsenko
@ 2018-04-16 20:32 ` Sam Protsenko
  2018-04-17 21:02   ` Andrew F. Davis
  2018-04-19 20:25   ` Sam Protsenko
  2018-04-16 20:32 ` [U-Boot] [PATCH 4/5] arm: ti: boot: Add dtbo partition for Android boot Sam Protsenko
                   ` (3 subsequent siblings)
  6 siblings, 2 replies; 22+ messages in thread
From: Sam Protsenko @ 2018-04-16 20:32 UTC (permalink / raw)
  To: u-boot

Eliminate code duplication: the same PARTS_DEFAULT was defined in
am57xx_evm.h and in dra7xx_evm.h. Extract it to environment/boot.h and
use in all OMAP5-based boards.

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
---
 include/configs/am57xx_evm.h   | 25 -------------------------
 include/configs/cl-som-am57x.h |  2 ++
 include/configs/cm_t54.h       |  2 ++
 include/configs/dra7xx_evm.h   | 25 -------------------------
 include/environment/ti/boot.h  | 27 +++++++++++++++++++++++++--
 5 files changed, 29 insertions(+), 52 deletions(-)

diff --git a/include/configs/am57xx_evm.h b/include/configs/am57xx_evm.h
index d1f73f76a4..886a5696f5 100644
--- a/include/configs/am57xx_evm.h
+++ b/include/configs/am57xx_evm.h
@@ -38,31 +38,6 @@
 
 #define CONFIG_SYS_OMAP_ABE_SYSCK
 
-/* Define the default GPT table for eMMC */
-#define PARTS_DEFAULT \
-	/* Linux partitions */ \
-	"uuid_disk=${uuid_gpt_disk};" \
-	"name=bootloader,start=384K,size=1792K,uuid=${uuid_gpt_bootloader};" \
-	"name=rootfs,start=2688K,size=-,uuid=${uuid_gpt_rootfs}\0" \
-	/* Android partitions */ \
-	"partitions_android=" \
-	"uuid_disk=${uuid_gpt_disk};" \
-	"name=xloader,start=128K,size=256K,uuid=${uuid_gpt_xloader};" \
-	"name=bootloader,size=1792K,uuid=${uuid_gpt_bootloader};" \
-	"name=environment,size=128K,uuid=${uuid_gpt_environment};" \
-	"name=misc,size=128K,uuid=${uuid_gpt_misc};" \
-	"name=reserved,size=256K,uuid=${uuid_gpt_reserved};" \
-	"name=efs,size=16M,uuid=${uuid_gpt_efs};" \
-	"name=crypto,size=16K,uuid=${uuid_gpt_crypto};" \
-	"name=recovery,size=40M,uuid=${uuid_gpt_recovery};" \
-	"name=boot,size=10M,uuid=${uuid_gpt_boot};" \
-	"name=system,size=768M,uuid=${uuid_gpt_system};" \
-	"name=vendor,size=256M,uuid=${uuid_gpt_vendor};" \
-	"name=cache,size=256M,uuid=${uuid_gpt_cache};" \
-	"name=ipu1,size=1M,uuid=${uuid_gpt_ipu1};" \
-	"name=ipu2,size=1M,uuid=${uuid_gpt_ipu2};" \
-	"name=userdata,size=-,uuid=${uuid_gpt_userdata}"
-
 #define DFUARGS \
 	"dfu_bufsiz=0x10000\0" \
 	DFU_ALT_INFO_MMC \
diff --git a/include/configs/cl-som-am57x.h b/include/configs/cl-som-am57x.h
index 9c70cf0b37..709e0375b3 100644
--- a/include/configs/cl-som-am57x.h
+++ b/include/configs/cl-som-am57x.h
@@ -18,6 +18,8 @@
 
 #define CONFIG_SYS_OMAP_ABE_SYSCK
 
+#define PARTS_DEFAULT
+
 #include <configs/ti_omap5_common.h>
 
 /* misc */
diff --git a/include/configs/cm_t54.h b/include/configs/cm_t54.h
index 6123cd374d..f0d76ed806 100644
--- a/include/configs/cm_t54.h
+++ b/include/configs/cm_t54.h
@@ -14,6 +14,8 @@
 #define CONFIG_CM_T54
 #define CONFIG_DRAM_2G
 
+#define PARTS_DEFAULT
+
 #include <configs/ti_omap5_common.h>
 
 /* EEPROM related defines */
diff --git a/include/configs/dra7xx_evm.h b/include/configs/dra7xx_evm.h
index 917a05d701..9b3fb2c913 100644
--- a/include/configs/dra7xx_evm.h
+++ b/include/configs/dra7xx_evm.h
@@ -45,31 +45,6 @@
 #define CONFIG_SYS_OMAP_ABE_SYSCK
 
 #ifndef CONFIG_SPL_BUILD
-/* Define the default GPT table for eMMC */
-#define PARTS_DEFAULT \
-	/* Linux partitions */ \
-	"uuid_disk=${uuid_gpt_disk};" \
-	"name=bootloader,start=384K,size=1792K,uuid=${uuid_gpt_bootloader};" \
-	"name=rootfs,start=2688K,size=-,uuid=${uuid_gpt_rootfs}\0" \
-	/* Android partitions */ \
-	"partitions_android=" \
-	"uuid_disk=${uuid_gpt_disk};" \
-	"name=xloader,start=128K,size=256K,uuid=${uuid_gpt_xloader};" \
-	"name=bootloader,size=1792K,uuid=${uuid_gpt_bootloader};" \
-	"name=environment,size=128K,uuid=${uuid_gpt_environment};" \
-	"name=misc,size=128K,uuid=${uuid_gpt_misc};" \
-	"name=reserved,size=256K,uuid=${uuid_gpt_reserved};" \
-	"name=efs,size=16M,uuid=${uuid_gpt_efs};" \
-	"name=crypto,size=16K,uuid=${uuid_gpt_crypto};" \
-	"name=recovery,size=40M,uuid=${uuid_gpt_recovery};" \
-	"name=boot,size=10M,uuid=${uuid_gpt_boot};" \
-	"name=system,size=768M,uuid=${uuid_gpt_system};" \
-	"name=vendor,size=256M,uuid=${uuid_gpt_vendor};" \
-	"name=cache,size=256M,uuid=${uuid_gpt_cache};" \
-	"name=ipu1,size=1M,uuid=${uuid_gpt_ipu1};" \
-	"name=ipu2,size=1M,uuid=${uuid_gpt_ipu2};" \
-	"name=userdata,size=-,uuid=${uuid_gpt_userdata}"
-
 #define DFUARGS \
 	"dfu_bufsiz=0x10000\0" \
 	DFU_ALT_INFO_MMC \
diff --git a/include/environment/ti/boot.h b/include/environment/ti/boot.h
index 24b7783f88..4f3d748b5c 100644
--- a/include/environment/ti/boot.h
+++ b/include/environment/ti/boot.h
@@ -15,8 +15,31 @@
 #endif
 
 #ifndef PARTS_DEFAULT
-#define PARTS_DEFAULT
-#endif
+/* Define the default GPT table for eMMC */
+#define PARTS_DEFAULT \
+	/* Linux partitions */ \
+	"uuid_disk=${uuid_gpt_disk};" \
+	"name=bootloader,start=384K,size=1792K,uuid=${uuid_gpt_bootloader};" \
+	"name=rootfs,start=2688K,size=-,uuid=${uuid_gpt_rootfs}\0" \
+	/* Android partitions */ \
+	"partitions_android=" \
+	"uuid_disk=${uuid_gpt_disk};" \
+	"name=xloader,start=128K,size=256K,uuid=${uuid_gpt_xloader};" \
+	"name=bootloader,size=1792K,uuid=${uuid_gpt_bootloader};" \
+	"name=environment,size=128K,uuid=${uuid_gpt_environment};" \
+	"name=misc,size=128K,uuid=${uuid_gpt_misc};" \
+	"name=reserved,size=256K,uuid=${uuid_gpt_reserved};" \
+	"name=efs,size=16M,uuid=${uuid_gpt_efs};" \
+	"name=crypto,size=16K,uuid=${uuid_gpt_crypto};" \
+	"name=recovery,size=40M,uuid=${uuid_gpt_recovery};" \
+	"name=boot,size=10M,uuid=${uuid_gpt_boot};" \
+	"name=system,size=768M,uuid=${uuid_gpt_system};" \
+	"name=vendor,size=256M,uuid=${uuid_gpt_vendor};" \
+	"name=cache,size=256M,uuid=${uuid_gpt_cache};" \
+	"name=ipu1,size=1M,uuid=${uuid_gpt_ipu1};" \
+	"name=ipu2,size=1M,uuid=${uuid_gpt_ipu2};" \
+	"name=userdata,size=-,uuid=${uuid_gpt_userdata}"
+#endif /* PARTS_DEFAULT */
 
 #define DEFAULT_COMMON_BOOT_TI_ARGS \
 	"console=" CONSOLEDEV ",115200n8\0" \
-- 
2.17.0

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

* [U-Boot] [PATCH 4/5] arm: ti: boot: Add dtbo partition for Android boot
  2018-04-16 20:32 [U-Boot] [PATCH 0/5] Use Android DT image format for TI boards Sam Protsenko
                   ` (2 preceding siblings ...)
  2018-04-16 20:32 ` [U-Boot] [PATCH 3/5] arm: ti: boot: Extract PARTS_DEFAULT to boot.h Sam Protsenko
@ 2018-04-16 20:32 ` Sam Protsenko
  2018-04-17 21:10   ` Andrew F. Davis
  2018-04-19 20:34   ` Sam Protsenko
  2018-04-16 20:32 ` [U-Boot] [PATCH 5/5] arm: ti: boot: Implement Android boot using DT image format Sam Protsenko
                   ` (2 subsequent siblings)
  6 siblings, 2 replies; 22+ messages in thread
From: Sam Protsenko @ 2018-04-16 20:32 UTC (permalink / raw)
  To: u-boot

New Android boot scheme looks like this [1], and it involves adding new
partition for storing Device Tree Overlays. This patch adds dtbo
partition. While at it, let's revise Android partition table a bit.

List of changes:
 - rename "misc" to "hole" (not used for anything, just a guard hole)
 - rename "reserved" to "uenv" (because it hold U-Boot environment)
 - rename "environment" to "dtb" (because it actually holds .dtb file)
 - move "dtb" after "uenv" (so that changes of dtb size won't affect
   "uenv" offset)
 - make "hole" size twice as bigger (to keep "uenv" offset the same,
   because "dtb" was moved after "uenv")
 - add "dtbo" partition (after "dtb", to not affect "uenv" offset)
 - while at it, increase "boot" partition size up to 20 MiB; that's
   needed because while playing with some additional drivers built-in
   and different compression techniques, and also for HS signing, we
   have seen the boot partition size reach close to border and
   sometimes reach over the limit of 10 MiB

Now eMMC layout looks like this:

    offset           content             size          partition
    (KiB)                                (KiB)

    ===============================================================

    0       +------------------------+
            | MBR/GPT header         |   128           -
    128     +------------------------+
            | MLO                    |   256           xloader
    384     +------------------------+
            | u-boot.img             |   1792          bootloader
    2176    +------------------------+
            | //////// hole //////// |   256           hole
    2432    +------------------------+
            | U-Boot environment     |   256           uenv
            | (+ redundant)          |
    2688    +------------------------+
            | dtb files              |   1024          dtb
    3712    +------------------------+
            | dtbo files             |   1024          dtbo
    4736    +------------------------+
              Android partitions         remaining     *

    ===============================================================

"hole" partition is needed just to keep U-Boot environment at 2432 KiB
offset, because:
 - this offset is used in DFU_ALT_INFO_EMMC:

       "u-env.raw raw 0x1300 0x200;"
       0x1300 = 4864 sectors = 2432 KiB

 - which in turn relies on CONFIG_ENV_OFFSET:

       CONFIG_ENV_OFFSET = 0x260000 = 2432 KiB

We are using "hole" partition instead of specifying "start" property to
"uenv" partition, because this way it's easier to maintain change of
preceding partitions.

Also fix Android boot commands appropriately.

[1] https://source.android.com/devices/architecture/dto/partitions

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
---
 include/environment/ti/boot.h | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/include/environment/ti/boot.h b/include/environment/ti/boot.h
index 4f3d748b5c..f2d91f5298 100644
--- a/include/environment/ti/boot.h
+++ b/include/environment/ti/boot.h
@@ -26,13 +26,14 @@
 	"uuid_disk=${uuid_gpt_disk};" \
 	"name=xloader,start=128K,size=256K,uuid=${uuid_gpt_xloader};" \
 	"name=bootloader,size=1792K,uuid=${uuid_gpt_bootloader};" \
-	"name=environment,size=128K,uuid=${uuid_gpt_environment};" \
-	"name=misc,size=128K,uuid=${uuid_gpt_misc};" \
-	"name=reserved,size=256K,uuid=${uuid_gpt_reserved};" \
+	"name=hole,size=256K,uuid=${uuid_gpt_hole};" \
+	"name=uenv,size=256K,uuid=${uuid_gpt_uenv};" \
+	"name=dtb,size=1M,uuid=${uuid_gpt_dtb};" \
+	"name=dtbo,size=1M,uuid=${uuid_gpt_dtbo};" \
 	"name=efs,size=16M,uuid=${uuid_gpt_efs};" \
 	"name=crypto,size=16K,uuid=${uuid_gpt_crypto};" \
 	"name=recovery,size=40M,uuid=${uuid_gpt_recovery};" \
-	"name=boot,size=10M,uuid=${uuid_gpt_boot};" \
+	"name=boot,size=20M,uuid=${uuid_gpt_boot};" \
 	"name=system,size=768M,uuid=${uuid_gpt_system};" \
 	"name=vendor,size=256M,uuid=${uuid_gpt_vendor};" \
 	"name=cache,size=256M,uuid=${uuid_gpt_cache};" \
@@ -66,8 +67,8 @@
 		"setenv machid fe6; " \
 		"mmc dev $mmcdev; " \
 		"mmc rescan; " \
-		"part start mmc ${mmcdev} environment fdt_start; " \
-		"part size mmc ${mmcdev} environment fdt_size; " \
+		"part start mmc ${mmcdev} dtb fdt_start; " \
+		"part size mmc ${mmcdev} dtb fdt_size; " \
 		"part start mmc ${mmcdev} boot boot_start; " \
 		"part size mmc ${mmcdev} boot boot_size; " \
 		"mmc read ${fdtaddr} ${fdt_start} ${fdt_size}; " \
-- 
2.17.0

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

* [U-Boot] [PATCH 5/5] arm: ti: boot: Implement Android boot using DT image format
  2018-04-16 20:32 [U-Boot] [PATCH 0/5] Use Android DT image format for TI boards Sam Protsenko
                   ` (3 preceding siblings ...)
  2018-04-16 20:32 ` [U-Boot] [PATCH 4/5] arm: ti: boot: Add dtbo partition for Android boot Sam Protsenko
@ 2018-04-16 20:32 ` Sam Protsenko
  2018-04-19 20:36   ` Sam Protsenko
  2019-03-14 15:19   ` [U-Boot] [5/5] " Eugeniu Rosca
  2018-04-17 20:57 ` [U-Boot] [PATCH 0/5] Use Android DT image format for TI boards Andrew F. Davis
  2018-04-19 20:23 ` Sam Protsenko
  6 siblings, 2 replies; 22+ messages in thread
From: Sam Protsenko @ 2018-04-16 20:32 UTC (permalink / raw)
  To: u-boot

Make sure we can boot Android on TI boards using scheme described in
Android documentation [1]. For this do next:
 1. Enable "dtimg" command. We will need it to boot the Android using
    new DTB/DTBO image format.
 2. Add fdt overlay support. We will need that to be able to apply fdt
    overlays to dtb file.
 3. Provide new Android boot commands. In case we don't know what board
    it is, let's provide fallback mechanism:
     - use just dtb[0] from dtb.img
     - don't apply any dtbo files on top of it
     - but still that dtb file must be packed into Android DT image

To use new boot scheme, user has to do next:

1. Prepare dtb.img and dtbo.img images, generated with mkdtimg tool (can
   be found in Android sources, see prebuilts/misc/linux-x86/libufdt).
   Example:

   $ ./mkdtimg create dtb.img                            \
                      am57xx-beagle-x15.dtb      --id=0  \
                      am57xx-beagle-x15-revc.dtb --id=1

   $ ./mkdtimg create dtbo.img \
                      am57xx-evm-common.dtbo     --id=0  \
                      mt9t111.dtbo               --id=1  \
                      ov10635.dtbo               --id=2  \
                      am57xx-evm.dtbo            --id=3  \
                      am57xx-evm-reva3.dtbo      --id=4

   Current boot commands rely on that specific order of dtb/dtbo files.
   Also, be sure to compile .dtb files with -@ dtc flag, so that
   overlays can be applied to dtb files.

2. Flash new U-Boot, set new environment and format eMMC:

   $ fastboot flash xloader MLO
   $ fastboot flash bootloader u-boot.img

   => env default -f -a
   => setenv partitions $partitions_android
   => env save
   => fastboot 1

   $ fastboot oem format

3. Flash dtb.img, dtbo.img:

   $ fastboot flash dtb dtb.img
   $ fastboot flash dtbo dtbo.img

4. Flash Android images:

   $ fastboot flash boot boot.img
   $ fastboot flash cache cache.img
   $ fastboot flash recovery recovery.img
   $ fastboot flash system system.img
   $ fastboot flash userdata userdata.img
   $ fastboot flash vendor vendor.img

For more detailed instructions, see [2].

[1] https://source.android.com/devices/architecture/dto/partitions
[2] https://wiki.linaro.org/Boards/BeagleBoard-X15

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
---
 board/ti/common/Kconfig           |  1 +
 configs/am57xx_evm_defconfig      |  1 +
 configs/am57xx_hs_evm_defconfig   |  1 +
 configs/dra7xx_evm_defconfig      |  1 +
 configs/dra7xx_hs_evm_defconfig   |  1 +
 include/configs/ti_armv7_common.h |  1 +
 include/environment/ti/boot.h     | 40 +++++++++++++++++++++++++------
 7 files changed, 39 insertions(+), 7 deletions(-)

diff --git a/board/ti/common/Kconfig b/board/ti/common/Kconfig
index c21eb8c2d2..f5bd9160b3 100644
--- a/board/ti/common/Kconfig
+++ b/board/ti/common/Kconfig
@@ -21,6 +21,7 @@ config TI_COMMON_CMD_OPTIONS
 	imply CRC32_VERIFY if ARCH_KEYSTONE
 	imply CMD_DFU if USB_GADGET_DOWNLOAD
 	imply CMD_DHCP
+	imply CMD_DTIMG
 	imply CMD_EEPROM
 	imply CMD_EXT2
 	imply CMD_EXT4
diff --git a/configs/am57xx_evm_defconfig b/configs/am57xx_evm_defconfig
index 6b11b3476c..7198542d9e 100644
--- a/configs/am57xx_evm_defconfig
+++ b/configs/am57xx_evm_defconfig
@@ -78,3 +78,4 @@ CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
 CONFIG_USB_GADGET_VENDOR_NUM=0x0451
 CONFIG_USB_GADGET_PRODUCT_NUM=0xd022
+CONFIG_OF_LIBFDT_OVERLAY=y
diff --git a/configs/am57xx_hs_evm_defconfig b/configs/am57xx_hs_evm_defconfig
index ca9742f118..e4948d549b 100644
--- a/configs/am57xx_hs_evm_defconfig
+++ b/configs/am57xx_hs_evm_defconfig
@@ -81,3 +81,4 @@ CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
 CONFIG_USB_GADGET_VENDOR_NUM=0x0451
 CONFIG_USB_GADGET_PRODUCT_NUM=0xd022
+CONFIG_OF_LIBFDT_OVERLAY=y
diff --git a/configs/dra7xx_evm_defconfig b/configs/dra7xx_evm_defconfig
index e17135c8f6..4ce687fbda 100644
--- a/configs/dra7xx_evm_defconfig
+++ b/configs/dra7xx_evm_defconfig
@@ -96,3 +96,4 @@ CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
 CONFIG_USB_GADGET_VENDOR_NUM=0x0451
 CONFIG_USB_GADGET_PRODUCT_NUM=0xd022
+CONFIG_OF_LIBFDT_OVERLAY=y
diff --git a/configs/dra7xx_hs_evm_defconfig b/configs/dra7xx_hs_evm_defconfig
index 606f99938c..6546daa080 100644
--- a/configs/dra7xx_hs_evm_defconfig
+++ b/configs/dra7xx_hs_evm_defconfig
@@ -95,3 +95,4 @@ CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
 CONFIG_USB_GADGET_VENDOR_NUM=0x0451
 CONFIG_USB_GADGET_PRODUCT_NUM=0xd022
+CONFIG_OF_LIBFDT_OVERLAY=y
diff --git a/include/configs/ti_armv7_common.h b/include/configs/ti_armv7_common.h
index 4771e74940..4340b5188f 100644
--- a/include/configs/ti_armv7_common.h
+++ b/include/configs/ti_armv7_common.h
@@ -43,6 +43,7 @@
 	"loadaddr=0x82000000\0" \
 	"kernel_addr_r=0x82000000\0" \
 	"fdtaddr=0x88000000\0" \
+	"dtboaddr=0x89000000\0" \
 	"fdt_addr_r=0x88000000\0" \
 	"rdaddr=0x88080000\0" \
 	"ramdisk_addr_r=0x88080000\0" \
diff --git a/include/environment/ti/boot.h b/include/environment/ti/boot.h
index f2d91f5298..52c9f129ed 100644
--- a/include/environment/ti/boot.h
+++ b/include/environment/ti/boot.h
@@ -65,15 +65,41 @@
 		"run eval_bootargs; " \
 		"setenv mmcdev 1; " \
 		"setenv machid fe6; " \
+		"setenv dtbaddr $fdtaddr; " \
+		"setenv dtb_size 0x100000; " \
 		"mmc dev $mmcdev; " \
 		"mmc rescan; " \
-		"part start mmc ${mmcdev} dtb fdt_start; " \
-		"part size mmc ${mmcdev} dtb fdt_size; " \
-		"part start mmc ${mmcdev} boot boot_start; " \
-		"part size mmc ${mmcdev} boot boot_size; " \
-		"mmc read ${fdtaddr} ${fdt_start} ${fdt_size}; " \
-		"mmc read ${loadaddr} ${boot_start} ${boot_size}; " \
-		"bootm $loadaddr $loadaddr $fdtaddr;\0"
+		"part start mmc ${mmcdev} dtb p_dtb_start; " \
+		"part size mmc ${mmcdev} dtb p_dtb_size; " \
+		"part start mmc ${mmcdev} dtbo p_dtbo_start; " \
+		"part size mmc ${mmcdev} dtbo p_dtbo_size; " \
+		"part start mmc ${mmcdev} boot p_boot_start; " \
+		"part size mmc ${mmcdev} boot p_boot_size; " \
+		"mmc read ${dtbaddr} ${p_dtb_start} ${p_dtb_size}; " \
+		"mmc read ${dtboaddr} ${p_dtbo_start} ${p_dtbo_size}; " \
+		"mmc read ${loadaddr} ${p_boot_start} ${p_boot_size}; " \
+		"if test $board_name = am57xx_evm; then " \
+			"dtimg start ${dtbaddr} 0 dtb_addr; " \
+			"fdt addr $dtb_addr $dtb_size; " \
+			"dtimg start ${dtboaddr} 0 dtbo_addr; " \
+			"fdt apply $dtbo_addr; " \
+			"dtimg start ${dtboaddr} 3 dtbo_addr; " \
+			"fdt apply $dtbo_addr; " \
+		"elif test $board_name = am57xx_evm_reva3; then " \
+			"dtimg start ${dtbaddr} 1 dtb_addr; " \
+			"fdt addr $dtb_addr $dtb_size; " \
+			"dtimg start ${dtboaddr} 0 dtbo_addr; " \
+			"fdt apply $dtbo_addr; " \
+			"dtimg start ${dtboaddr} 4 dtbo_addr; " \
+			"fdt apply $dtbo_addr; " \
+		"elif test $board_name = beagle_x15; then " \
+			"dtimg start ${dtbaddr} 0 dtb_addr; " \
+		"elif test $board_name = beagle_x15_revc; then " \
+			"dtimg start ${dtbaddr} 1 dtb_addr; " \
+		"else " \
+			"dtimg start ${dtbaddr} 0 dtb_addr; " \
+		"fi; " \
+		"bootm $loadaddr $loadaddr $dtb_addr;\0"
 
 #ifdef CONFIG_OMAP54XX
 
-- 
2.17.0

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

* [U-Boot] [PATCH 0/5] Use Android DT image format for TI boards
  2018-04-16 20:32 [U-Boot] [PATCH 0/5] Use Android DT image format for TI boards Sam Protsenko
                   ` (4 preceding siblings ...)
  2018-04-16 20:32 ` [U-Boot] [PATCH 5/5] arm: ti: boot: Implement Android boot using DT image format Sam Protsenko
@ 2018-04-17 20:57 ` Andrew F. Davis
  2018-04-19 20:22   ` Sam Protsenko
  2018-04-22 20:12   ` Simon Glass
  2018-04-19 20:23 ` Sam Protsenko
  6 siblings, 2 replies; 22+ messages in thread
From: Andrew F. Davis @ 2018-04-17 20:57 UTC (permalink / raw)
  To: u-boot

On 04/16/2018 03:32 PM, Sam Protsenko wrote:
> Android documentation recommends using new image format for storing dtb
> and dtbo files: [1]. Using that format, we can pack several dtb files to
> dtb.img, and also pack several dtbo files to dtbo.img. Then those images
> should be flashed to eMMC partitions, called "dtb" and "dtbo"
> respectively.
> 


I'm not convinced adding yet another one-off Android specific partition
format is what we need right now. With FIT images this is a solved
problem, why does Android need to go down a different path here?


> This patch series introduces support for mentioned Android DT image
> format, adds "dtimg" command to deal with that image format from U-Boot
> shell, and provides new Android boot scheme to TI boards (AM57x and DRA7
> boards). So with this patch series we will have next procedure for
> Android boot:
>  1. Read next images from eMMC partitions to RAM:
>     - boot.img
>     - dtb.img
>     - dtbo.img
>  2. Take addresses of desired dtb/dtbo files from that images (for
>     current board)
>  3. Apply dtbo overlays to main dtb, if needed
>  4. Boot the kernel from Android boot image, using resulting dtb
> 


All the above logic ends up adding more to our environment scripting at
a time when we are working to reduce that..

Andrew


> It was tested on X15 and AM57x EVM boards.
> 
> [1] https://source.android.com/devices/architecture/dto/partitions
> 
> Sam Protsenko (5):
>   common: Add support for Android DT image
>   cmd: Add dtimg command
>   arm: ti: boot: Extract PARTS_DEFAULT to boot.h
>   arm: ti: boot: Add dtbo partition for Android boot
>   arm: ti: boot: Implement Android boot using DT image format
> 
>  board/ti/common/Kconfig           |   1 +
>  cmd/Kconfig                       |   8 ++
>  cmd/Makefile                      |   1 +
>  cmd/dtimg.c                       | 142 ++++++++++++++++++++++++++++++
>  common/Makefile                   |   4 +
>  common/image-android-dt.c         | 134 ++++++++++++++++++++++++++++
>  configs/am57xx_evm_defconfig      |   1 +
>  configs/am57xx_hs_evm_defconfig   |   1 +
>  configs/dra7xx_evm_defconfig      |   1 +
>  configs/dra7xx_hs_evm_defconfig   |   1 +
>  include/configs/am57xx_evm.h      |  25 ------
>  include/configs/cl-som-am57x.h    |   2 +
>  include/configs/cm_t54.h          |   2 +
>  include/configs/dra7xx_evm.h      |  25 ------
>  include/configs/ti_armv7_common.h |   1 +
>  include/dt_table.h                |  46 ++++++++++
>  include/environment/ti/boot.h     |  68 ++++++++++++--
>  include/image-android-dt.h        |  18 ++++
>  18 files changed, 422 insertions(+), 59 deletions(-)
>  create mode 100644 cmd/dtimg.c
>  create mode 100644 common/image-android-dt.c
>  create mode 100644 include/dt_table.h
>  create mode 100644 include/image-android-dt.h
> 

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

* [U-Boot] [PATCH 3/5] arm: ti: boot: Extract PARTS_DEFAULT to boot.h
  2018-04-16 20:32 ` [U-Boot] [PATCH 3/5] arm: ti: boot: Extract PARTS_DEFAULT to boot.h Sam Protsenko
@ 2018-04-17 21:02   ` Andrew F. Davis
  2018-04-19 20:25   ` Sam Protsenko
  1 sibling, 0 replies; 22+ messages in thread
From: Andrew F. Davis @ 2018-04-17 21:02 UTC (permalink / raw)
  To: u-boot

On 04/16/2018 03:32 PM, Sam Protsenko wrote:
> Eliminate code duplication: the same PARTS_DEFAULT was defined in
> am57xx_evm.h and in dra7xx_evm.h. Extract it to environment/boot.h and
> use in all OMAP5-based boards.
> 
> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
> ---


This patch can be taken independent of my objections to the others in
this series.

Acked-by: Andrew F. Davis <afd@ti.com>


>  include/configs/am57xx_evm.h   | 25 -------------------------
>  include/configs/cl-som-am57x.h |  2 ++
>  include/configs/cm_t54.h       |  2 ++
>  include/configs/dra7xx_evm.h   | 25 -------------------------
>  include/environment/ti/boot.h  | 27 +++++++++++++++++++++++++--
>  5 files changed, 29 insertions(+), 52 deletions(-)
> 
> diff --git a/include/configs/am57xx_evm.h b/include/configs/am57xx_evm.h
> index d1f73f76a4..886a5696f5 100644
> --- a/include/configs/am57xx_evm.h
> +++ b/include/configs/am57xx_evm.h
> @@ -38,31 +38,6 @@
>  
>  #define CONFIG_SYS_OMAP_ABE_SYSCK
>  
> -/* Define the default GPT table for eMMC */
> -#define PARTS_DEFAULT \
> -	/* Linux partitions */ \
> -	"uuid_disk=${uuid_gpt_disk};" \
> -	"name=bootloader,start=384K,size=1792K,uuid=${uuid_gpt_bootloader};" \
> -	"name=rootfs,start=2688K,size=-,uuid=${uuid_gpt_rootfs}\0" \
> -	/* Android partitions */ \
> -	"partitions_android=" \
> -	"uuid_disk=${uuid_gpt_disk};" \
> -	"name=xloader,start=128K,size=256K,uuid=${uuid_gpt_xloader};" \
> -	"name=bootloader,size=1792K,uuid=${uuid_gpt_bootloader};" \
> -	"name=environment,size=128K,uuid=${uuid_gpt_environment};" \
> -	"name=misc,size=128K,uuid=${uuid_gpt_misc};" \
> -	"name=reserved,size=256K,uuid=${uuid_gpt_reserved};" \
> -	"name=efs,size=16M,uuid=${uuid_gpt_efs};" \
> -	"name=crypto,size=16K,uuid=${uuid_gpt_crypto};" \
> -	"name=recovery,size=40M,uuid=${uuid_gpt_recovery};" \
> -	"name=boot,size=10M,uuid=${uuid_gpt_boot};" \
> -	"name=system,size=768M,uuid=${uuid_gpt_system};" \
> -	"name=vendor,size=256M,uuid=${uuid_gpt_vendor};" \
> -	"name=cache,size=256M,uuid=${uuid_gpt_cache};" \
> -	"name=ipu1,size=1M,uuid=${uuid_gpt_ipu1};" \
> -	"name=ipu2,size=1M,uuid=${uuid_gpt_ipu2};" \
> -	"name=userdata,size=-,uuid=${uuid_gpt_userdata}"
> -
>  #define DFUARGS \
>  	"dfu_bufsiz=0x10000\0" \
>  	DFU_ALT_INFO_MMC \
> diff --git a/include/configs/cl-som-am57x.h b/include/configs/cl-som-am57x.h
> index 9c70cf0b37..709e0375b3 100644
> --- a/include/configs/cl-som-am57x.h
> +++ b/include/configs/cl-som-am57x.h
> @@ -18,6 +18,8 @@
>  
>  #define CONFIG_SYS_OMAP_ABE_SYSCK
>  
> +#define PARTS_DEFAULT
> +
>  #include <configs/ti_omap5_common.h>
>  
>  /* misc */
> diff --git a/include/configs/cm_t54.h b/include/configs/cm_t54.h
> index 6123cd374d..f0d76ed806 100644
> --- a/include/configs/cm_t54.h
> +++ b/include/configs/cm_t54.h
> @@ -14,6 +14,8 @@
>  #define CONFIG_CM_T54
>  #define CONFIG_DRAM_2G
>  
> +#define PARTS_DEFAULT
> +
>  #include <configs/ti_omap5_common.h>
>  
>  /* EEPROM related defines */
> diff --git a/include/configs/dra7xx_evm.h b/include/configs/dra7xx_evm.h
> index 917a05d701..9b3fb2c913 100644
> --- a/include/configs/dra7xx_evm.h
> +++ b/include/configs/dra7xx_evm.h
> @@ -45,31 +45,6 @@
>  #define CONFIG_SYS_OMAP_ABE_SYSCK
>  
>  #ifndef CONFIG_SPL_BUILD
> -/* Define the default GPT table for eMMC */
> -#define PARTS_DEFAULT \
> -	/* Linux partitions */ \
> -	"uuid_disk=${uuid_gpt_disk};" \
> -	"name=bootloader,start=384K,size=1792K,uuid=${uuid_gpt_bootloader};" \
> -	"name=rootfs,start=2688K,size=-,uuid=${uuid_gpt_rootfs}\0" \
> -	/* Android partitions */ \
> -	"partitions_android=" \
> -	"uuid_disk=${uuid_gpt_disk};" \
> -	"name=xloader,start=128K,size=256K,uuid=${uuid_gpt_xloader};" \
> -	"name=bootloader,size=1792K,uuid=${uuid_gpt_bootloader};" \
> -	"name=environment,size=128K,uuid=${uuid_gpt_environment};" \
> -	"name=misc,size=128K,uuid=${uuid_gpt_misc};" \
> -	"name=reserved,size=256K,uuid=${uuid_gpt_reserved};" \
> -	"name=efs,size=16M,uuid=${uuid_gpt_efs};" \
> -	"name=crypto,size=16K,uuid=${uuid_gpt_crypto};" \
> -	"name=recovery,size=40M,uuid=${uuid_gpt_recovery};" \
> -	"name=boot,size=10M,uuid=${uuid_gpt_boot};" \
> -	"name=system,size=768M,uuid=${uuid_gpt_system};" \
> -	"name=vendor,size=256M,uuid=${uuid_gpt_vendor};" \
> -	"name=cache,size=256M,uuid=${uuid_gpt_cache};" \
> -	"name=ipu1,size=1M,uuid=${uuid_gpt_ipu1};" \
> -	"name=ipu2,size=1M,uuid=${uuid_gpt_ipu2};" \
> -	"name=userdata,size=-,uuid=${uuid_gpt_userdata}"
> -
>  #define DFUARGS \
>  	"dfu_bufsiz=0x10000\0" \
>  	DFU_ALT_INFO_MMC \
> diff --git a/include/environment/ti/boot.h b/include/environment/ti/boot.h
> index 24b7783f88..4f3d748b5c 100644
> --- a/include/environment/ti/boot.h
> +++ b/include/environment/ti/boot.h
> @@ -15,8 +15,31 @@
>  #endif
>  
>  #ifndef PARTS_DEFAULT
> -#define PARTS_DEFAULT
> -#endif
> +/* Define the default GPT table for eMMC */
> +#define PARTS_DEFAULT \
> +	/* Linux partitions */ \
> +	"uuid_disk=${uuid_gpt_disk};" \
> +	"name=bootloader,start=384K,size=1792K,uuid=${uuid_gpt_bootloader};" \
> +	"name=rootfs,start=2688K,size=-,uuid=${uuid_gpt_rootfs}\0" \
> +	/* Android partitions */ \
> +	"partitions_android=" \
> +	"uuid_disk=${uuid_gpt_disk};" \
> +	"name=xloader,start=128K,size=256K,uuid=${uuid_gpt_xloader};" \
> +	"name=bootloader,size=1792K,uuid=${uuid_gpt_bootloader};" \
> +	"name=environment,size=128K,uuid=${uuid_gpt_environment};" \
> +	"name=misc,size=128K,uuid=${uuid_gpt_misc};" \
> +	"name=reserved,size=256K,uuid=${uuid_gpt_reserved};" \
> +	"name=efs,size=16M,uuid=${uuid_gpt_efs};" \
> +	"name=crypto,size=16K,uuid=${uuid_gpt_crypto};" \
> +	"name=recovery,size=40M,uuid=${uuid_gpt_recovery};" \
> +	"name=boot,size=10M,uuid=${uuid_gpt_boot};" \
> +	"name=system,size=768M,uuid=${uuid_gpt_system};" \
> +	"name=vendor,size=256M,uuid=${uuid_gpt_vendor};" \
> +	"name=cache,size=256M,uuid=${uuid_gpt_cache};" \
> +	"name=ipu1,size=1M,uuid=${uuid_gpt_ipu1};" \
> +	"name=ipu2,size=1M,uuid=${uuid_gpt_ipu2};" \
> +	"name=userdata,size=-,uuid=${uuid_gpt_userdata}"
> +#endif /* PARTS_DEFAULT */
>  
>  #define DEFAULT_COMMON_BOOT_TI_ARGS \
>  	"console=" CONSOLEDEV ",115200n8\0" \
> 

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

* [U-Boot] [PATCH 4/5] arm: ti: boot: Add dtbo partition for Android boot
  2018-04-16 20:32 ` [U-Boot] [PATCH 4/5] arm: ti: boot: Add dtbo partition for Android boot Sam Protsenko
@ 2018-04-17 21:10   ` Andrew F. Davis
  2018-04-19 20:33     ` Sam Protsenko
  2018-04-19 20:34   ` Sam Protsenko
  1 sibling, 1 reply; 22+ messages in thread
From: Andrew F. Davis @ 2018-04-17 21:10 UTC (permalink / raw)
  To: u-boot

On 04/16/2018 03:32 PM, Sam Protsenko wrote:
> New Android boot scheme looks like this [1], and it involves adding new
> partition for storing Device Tree Overlays. This patch adds dtbo
> partition. While at it, let's revise Android partition table a bit.
> 
> List of changes:
>  - rename "misc" to "hole" (not used for anything, just a guard hole)

Could we instead expand the bootloader partition and just remove this
hole partition?

>  - rename "reserved" to "uenv" (because it hold U-Boot environment)

This is fine.

>  - rename "environment" to "dtb" (because it actually holds .dtb file)


We are working to move to FIT with our Android releases, so the
"boot.img" image will now be a FIT image that contains kernel, dtb,
dtbo, op-tee, ipu, ipu2, etc...

The end result is all these custom partitions we had before all just get
folded into the one boot partition.

Andrew


>  - move "dtb" after "uenv" (so that changes of dtb size won't affect
>    "uenv" offset)
>  - make "hole" size twice as bigger (to keep "uenv" offset the same,
>    because "dtb" was moved after "uenv")
>  - add "dtbo" partition (after "dtb", to not affect "uenv" offset)
>  - while at it, increase "boot" partition size up to 20 MiB; that's
>    needed because while playing with some additional drivers built-in
>    and different compression techniques, and also for HS signing, we
>    have seen the boot partition size reach close to border and
>    sometimes reach over the limit of 10 MiB
> 
> Now eMMC layout looks like this:
> 
>     offset           content             size          partition
>     (KiB)                                (KiB)
> 
>     ===============================================================
> 
>     0       +------------------------+
>             | MBR/GPT header         |   128           -
>     128     +------------------------+
>             | MLO                    |   256           xloader
>     384     +------------------------+
>             | u-boot.img             |   1792          bootloader
>     2176    +------------------------+
>             | //////// hole //////// |   256           hole
>     2432    +------------------------+
>             | U-Boot environment     |   256           uenv
>             | (+ redundant)          |
>     2688    +------------------------+
>             | dtb files              |   1024          dtb
>     3712    +------------------------+
>             | dtbo files             |   1024          dtbo
>     4736    +------------------------+
>               Android partitions         remaining     *
> 
>     ===============================================================
> 
> "hole" partition is needed just to keep U-Boot environment at 2432 KiB
> offset, because:
>  - this offset is used in DFU_ALT_INFO_EMMC:
> 
>        "u-env.raw raw 0x1300 0x200;"
>        0x1300 = 4864 sectors = 2432 KiB
> 
>  - which in turn relies on CONFIG_ENV_OFFSET:
> 
>        CONFIG_ENV_OFFSET = 0x260000 = 2432 KiB
> 
> We are using "hole" partition instead of specifying "start" property to
> "uenv" partition, because this way it's easier to maintain change of
> preceding partitions.
> 
> Also fix Android boot commands appropriately.
> 
> [1] https://source.android.com/devices/architecture/dto/partitions
> 
> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
> ---
>  include/environment/ti/boot.h | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/include/environment/ti/boot.h b/include/environment/ti/boot.h
> index 4f3d748b5c..f2d91f5298 100644
> --- a/include/environment/ti/boot.h
> +++ b/include/environment/ti/boot.h
> @@ -26,13 +26,14 @@
>  	"uuid_disk=${uuid_gpt_disk};" \
>  	"name=xloader,start=128K,size=256K,uuid=${uuid_gpt_xloader};" \
>  	"name=bootloader,size=1792K,uuid=${uuid_gpt_bootloader};" \
> -	"name=environment,size=128K,uuid=${uuid_gpt_environment};" \
> -	"name=misc,size=128K,uuid=${uuid_gpt_misc};" \
> -	"name=reserved,size=256K,uuid=${uuid_gpt_reserved};" \
> +	"name=hole,size=256K,uuid=${uuid_gpt_hole};" \
> +	"name=uenv,size=256K,uuid=${uuid_gpt_uenv};" \
> +	"name=dtb,size=1M,uuid=${uuid_gpt_dtb};" \
> +	"name=dtbo,size=1M,uuid=${uuid_gpt_dtbo};" \
>  	"name=efs,size=16M,uuid=${uuid_gpt_efs};" \
>  	"name=crypto,size=16K,uuid=${uuid_gpt_crypto};" \
>  	"name=recovery,size=40M,uuid=${uuid_gpt_recovery};" \
> -	"name=boot,size=10M,uuid=${uuid_gpt_boot};" \
> +	"name=boot,size=20M,uuid=${uuid_gpt_boot};" \
>  	"name=system,size=768M,uuid=${uuid_gpt_system};" \
>  	"name=vendor,size=256M,uuid=${uuid_gpt_vendor};" \
>  	"name=cache,size=256M,uuid=${uuid_gpt_cache};" \
> @@ -66,8 +67,8 @@
>  		"setenv machid fe6; " \
>  		"mmc dev $mmcdev; " \
>  		"mmc rescan; " \
> -		"part start mmc ${mmcdev} environment fdt_start; " \
> -		"part size mmc ${mmcdev} environment fdt_size; " \
> +		"part start mmc ${mmcdev} dtb fdt_start; " \
> +		"part size mmc ${mmcdev} dtb fdt_size; " \
>  		"part start mmc ${mmcdev} boot boot_start; " \
>  		"part size mmc ${mmcdev} boot boot_size; " \
>  		"mmc read ${fdtaddr} ${fdt_start} ${fdt_size}; " \
> 

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

* [U-Boot] [PATCH 0/5] Use Android DT image format for TI boards
  2018-04-17 20:57 ` [U-Boot] [PATCH 0/5] Use Android DT image format for TI boards Andrew F. Davis
@ 2018-04-19 20:22   ` Sam Protsenko
  2018-04-22 20:12   ` Simon Glass
  1 sibling, 0 replies; 22+ messages in thread
From: Sam Protsenko @ 2018-04-19 20:22 UTC (permalink / raw)
  To: u-boot

On 17 April 2018 at 23:57, Andrew F. Davis <afd@ti.com> wrote:
> On 04/16/2018 03:32 PM, Sam Protsenko wrote:
>> Android documentation recommends using new image format for storing dtb
>> and dtbo files: [1]. Using that format, we can pack several dtb files to
>> dtb.img, and also pack several dtbo files to dtbo.img. Then those images
>> should be flashed to eMMC partitions, called "dtb" and "dtbo"
>> respectively.
>>
>
>
> I'm not convinced adding yet another one-off Android specific partition
> format is what we need right now. With FIT images this is a solved
> problem, why does Android need to go down a different path here?
>

We are already in discussion with Google engineers regarding that
question. Both approaches (FIT and Android DT) work fine. This is just
a policy question: if Google doesn't mind us using FIT, we can go with
FIT. Otherwise we are forced to go with Android DT image format.
That's why we decided to implement DT image support: to have it
functional and upstreamed in a case if Google tells us it's mandatory.

>
>> This patch series introduces support for mentioned Android DT image
>> format, adds "dtimg" command to deal with that image format from U-Boot
>> shell, and provides new Android boot scheme to TI boards (AM57x and DRA7
>> boards). So with this patch series we will have next procedure for
>> Android boot:
>>  1. Read next images from eMMC partitions to RAM:
>>     - boot.img
>>     - dtb.img
>>     - dtbo.img
>>  2. Take addresses of desired dtb/dtbo files from that images (for
>>     current board)
>>  3. Apply dtbo overlays to main dtb, if needed
>>  4. Boot the kernel from Android boot image, using resulting dtb
>>
>
>
> All the above logic ends up adding more to our environment scripting at
> a time when we are working to reduce that..
>

Frankly, I don't see a better solution here. Adding another separate
command to do Android boot just for TI case won't be accepted in
upstream obviously, because we already have bootm command for this. If
you see a better way of doing that (in upstream, of course, without
any hacks) -- please advice. Otherwise we will go with this one, in
case Google responds it's mandatory.

> Andrew
>
>
>> It was tested on X15 and AM57x EVM boards.
>>
>> [1] https://source.android.com/devices/architecture/dto/partitions
>>
>> Sam Protsenko (5):
>>   common: Add support for Android DT image
>>   cmd: Add dtimg command
>>   arm: ti: boot: Extract PARTS_DEFAULT to boot.h
>>   arm: ti: boot: Add dtbo partition for Android boot
>>   arm: ti: boot: Implement Android boot using DT image format
>>
>>  board/ti/common/Kconfig           |   1 +
>>  cmd/Kconfig                       |   8 ++
>>  cmd/Makefile                      |   1 +
>>  cmd/dtimg.c                       | 142 ++++++++++++++++++++++++++++++
>>  common/Makefile                   |   4 +
>>  common/image-android-dt.c         | 134 ++++++++++++++++++++++++++++
>>  configs/am57xx_evm_defconfig      |   1 +
>>  configs/am57xx_hs_evm_defconfig   |   1 +
>>  configs/dra7xx_evm_defconfig      |   1 +
>>  configs/dra7xx_hs_evm_defconfig   |   1 +
>>  include/configs/am57xx_evm.h      |  25 ------
>>  include/configs/cl-som-am57x.h    |   2 +
>>  include/configs/cm_t54.h          |   2 +
>>  include/configs/dra7xx_evm.h      |  25 ------
>>  include/configs/ti_armv7_common.h |   1 +
>>  include/dt_table.h                |  46 ++++++++++
>>  include/environment/ti/boot.h     |  68 ++++++++++++--
>>  include/image-android-dt.h        |  18 ++++
>>  18 files changed, 422 insertions(+), 59 deletions(-)
>>  create mode 100644 cmd/dtimg.c
>>  create mode 100644 common/image-android-dt.c
>>  create mode 100644 include/dt_table.h
>>  create mode 100644 include/image-android-dt.h
>>

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

* [U-Boot] [PATCH 0/5] Use Android DT image format for TI boards
  2018-04-16 20:32 [U-Boot] [PATCH 0/5] Use Android DT image format for TI boards Sam Protsenko
                   ` (5 preceding siblings ...)
  2018-04-17 20:57 ` [U-Boot] [PATCH 0/5] Use Android DT image format for TI boards Andrew F. Davis
@ 2018-04-19 20:23 ` Sam Protsenko
  6 siblings, 0 replies; 22+ messages in thread
From: Sam Protsenko @ 2018-04-19 20:23 UTC (permalink / raw)
  To: u-boot

On 16 April 2018 at 23:32, Sam Protsenko <semen.protsenko@linaro.org> wrote:
> Android documentation recommends using new image format for storing dtb
> and dtbo files: [1]. Using that format, we can pack several dtb files to
> dtb.img, and also pack several dtbo files to dtbo.img. Then those images
> should be flashed to eMMC partitions, called "dtb" and "dtbo"
> respectively.
>
> This patch series introduces support for mentioned Android DT image
> format, adds "dtimg" command to deal with that image format from U-Boot
> shell, and provides new Android boot scheme to TI boards (AM57x and DRA7
> boards). So with this patch series we will have next procedure for
> Android boot:
>  1. Read next images from eMMC partitions to RAM:
>     - boot.img
>     - dtb.img
>     - dtbo.img
>  2. Take addresses of desired dtb/dtbo files from that images (for
>     current board)
>  3. Apply dtbo overlays to main dtb, if needed
>  4. Boot the kernel from Android boot image, using resulting dtb
>
> It was tested on X15 and AM57x EVM boards.
>
> [1] https://source.android.com/devices/architecture/dto/partitions
>
> Sam Protsenko (5):
>   common: Add support for Android DT image
>   cmd: Add dtimg command
>   arm: ti: boot: Extract PARTS_DEFAULT to boot.h
>   arm: ti: boot: Add dtbo partition for Android boot
>   arm: ti: boot: Implement Android boot using DT image format
>
>  board/ti/common/Kconfig           |   1 +
>  cmd/Kconfig                       |   8 ++
>  cmd/Makefile                      |   1 +
>  cmd/dtimg.c                       | 142 ++++++++++++++++++++++++++++++
>  common/Makefile                   |   4 +
>  common/image-android-dt.c         | 134 ++++++++++++++++++++++++++++
>  configs/am57xx_evm_defconfig      |   1 +
>  configs/am57xx_hs_evm_defconfig   |   1 +
>  configs/dra7xx_evm_defconfig      |   1 +
>  configs/dra7xx_hs_evm_defconfig   |   1 +
>  include/configs/am57xx_evm.h      |  25 ------
>  include/configs/cl-som-am57x.h    |   2 +
>  include/configs/cm_t54.h          |   2 +
>  include/configs/dra7xx_evm.h      |  25 ------
>  include/configs/ti_armv7_common.h |   1 +
>  include/dt_table.h                |  46 ++++++++++
>  include/environment/ti/boot.h     |  68 ++++++++++++--
>  include/image-android-dt.h        |  18 ++++
>  18 files changed, 422 insertions(+), 59 deletions(-)
>  create mode 100644 cmd/dtimg.c
>  create mode 100644 common/image-android-dt.c
>  create mode 100644 include/dt_table.h
>  create mode 100644 include/image-android-dt.h
>
> --
> 2.17.0
>

Abandon this change. I'm going to send v2 soon.

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

* [U-Boot] [PATCH 1/5] common: Add support for Android DT image
  2018-04-16 20:32 ` [U-Boot] [PATCH 1/5] common: Add support for Android DT image Sam Protsenko
@ 2018-04-19 20:24   ` Sam Protsenko
  0 siblings, 0 replies; 22+ messages in thread
From: Sam Protsenko @ 2018-04-19 20:24 UTC (permalink / raw)
  To: u-boot

On 16 April 2018 at 23:32, Sam Protsenko <semen.protsenko@linaro.org> wrote:
> Android documentation recommends new image format for storing DTB/DTBO
> files: [1]. To support that format, two things should be done:
>
> 1. Add dt_table.h file from Android (BSD-3 relicensed version): [2].
>    This header defines structures and constants that we need to work
>    with that DT image format.
>
>    Changes:
>     - re-licensed from Apache to BSD-3
>     - removed functions declarations
>     - change the coding style to kernel (make checkpatch happy)
>
> 2. Add helper functions for Android DTB/DTBO format. In
>    image-android-dt.* files you can find helper functions to work with
>    Android DT image format, such us routines for:
>     - printing the dump of image structure
>     - getting the address and size of desired dtb/dtbo file
>
> [1] https://source.android.com/devices/architecture/dto/partitions
> [2] https://android.googlesource.com/platform/system/libufdt/+/58a7582180f477032cd6c74f8d9afad0038e74c3/utils/src/dt_table.h
>
> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
> ---
>  common/image-android-dt.c  | 134 +++++++++++++++++++++++++++++++++++++
>  include/dt_table.h         |  46 +++++++++++++
>  include/image-android-dt.h |  18 +++++
>  3 files changed, 198 insertions(+)
>  create mode 100644 common/image-android-dt.c
>  create mode 100644 include/dt_table.h
>  create mode 100644 include/image-android-dt.h
>
> diff --git a/common/image-android-dt.c b/common/image-android-dt.c
> new file mode 100644
> index 0000000000..f218db06bb
> --- /dev/null
> +++ b/common/image-android-dt.c
> @@ -0,0 +1,134 @@
> +/*
> + * (C) Copyright 2018 Linaro Ltd.
> + * Sam Protsenko <semen.protsenko@linaro.org>
> + *
> + * SPDX-License-Identifier:    GPL-2.0+
> + */
> +
> +#include <image-android-dt.h>
> +#include <common.h>
> +#include <linux/libfdt_env.h>
> +#include <linux/libfdt.h>
> +
> +/**
> + * Check if image header is correct.
> + *
> + * @param hdr Address to image header
> + * @return true if header is correct or false if header is incorrect
> + */
> +bool android_dt_check_header(const struct dt_table_header *hdr)
> +{
> +       return fdt32_to_cpu(hdr->magic) == DT_TABLE_MAGIC;
> +}
> +
> +/**
> + * Get the address of FDT (dtb or dtbo) in memory by its index in image.
> + *
> + * @param hdr Address to image header
> + * @param index Index of desired FDT in image (starting from 0)
> + * @param[out] addr If not null, will contain address to specified FDT
> + * @param[out] size If not NULL, will contain size of specified FDT
> + *
> + * @return true on success or false on error
> + */
> +bool android_dt_get_fdt_by_index(const struct dt_table_header *hdr,
> +                                u32 index, ulong *addr, u32 *size)
> +{
> +       const struct dt_table_entry *e;
> +       u32 entry_count = fdt32_to_cpu(hdr->dt_entry_count);
> +       u32 entries_offset = fdt32_to_cpu(hdr->dt_entries_offset);
> +       u32 entry_size = fdt32_to_cpu(hdr->dt_entry_size);
> +       u32 dt_offset, dt_size;
> +
> +       if (index > entry_count) {
> +               printf("Error: index > dt_entry_count (%u > %u)\n", index,
> +                      entry_count);
> +               return false;
> +       }
> +
> +       e = (const struct dt_table_entry *)((ulong)hdr + entries_offset
> +                       + index * entry_size);
> +       dt_offset = fdt32_to_cpu(e->dt_offset);
> +       dt_size = fdt32_to_cpu(e->dt_size);
> +
> +       if (addr)
> +               *addr = ((ulong)hdr + dt_offset);
> +       if (size)
> +               *size = dt_size;
> +
> +       return true;
> +}
> +
> +#if !defined(CONFIG_SPL_BUILD)
> +static void android_dt_print_fdt_info(const struct fdt_header *fdt)
> +{
> +       u32 fdt_size;
> +       int root_node_off;
> +       const char *compatible = NULL;
> +
> +       fdt_size = fdt_totalsize(fdt);
> +       root_node_off = fdt_path_offset(fdt, "/");
> +       if (root_node_off < 0) {
> +               printf("Error: Root node not found\n");
> +       } else {
> +               compatible = fdt_getprop(fdt, root_node_off, "compatible",
> +                                        NULL);
> +       }
> +
> +       printf("           (FDT)size = %d\n", fdt_size);
> +       printf("     (FDT)compatible = %s\n",
> +              compatible ? compatible : "(unknown)");
> +}
> +
> +/**
> + * Print information about DT image structure.
> + *
> + * @param hdr Address to image header
> + */
> +void android_dt_print_contents(const struct dt_table_header *hdr)
> +{
> +       u32 i;
> +       u32 entry_count = fdt32_to_cpu(hdr->dt_entry_count);
> +       u32 entries_offset = fdt32_to_cpu(hdr->dt_entries_offset);
> +       u32 entry_size = fdt32_to_cpu(hdr->dt_entry_size);
> +
> +       /* Print image header info */
> +       printf("dt_table_header:\n");
> +       printf("               magic = %08x\n", fdt32_to_cpu(hdr->magic));
> +       printf("          total_size = %d\n", fdt32_to_cpu(hdr->total_size));
> +       printf("         header_size = %d\n", fdt32_to_cpu(hdr->header_size));
> +       printf("       dt_entry_size = %d\n", entry_size);
> +       printf("      dt_entry_count = %d\n", entry_count);
> +       printf("   dt_entries_offset = %d\n", entries_offset);
> +       printf("           page_size = %d\n", fdt32_to_cpu(hdr->page_size));
> +       printf("         reserved[0] = %08x\n", fdt32_to_cpu(hdr->reserved[0]));
> +
> +       /* Print image entries info */
> +       for (i = 0; i < entry_count; ++i) {
> +               const struct dt_table_entry *e;
> +               const struct fdt_header *fdt;
> +               u32 dt_offset, dt_size;
> +               u32 j;
> +
> +               e = (const struct dt_table_entry *)((ulong)hdr + entries_offset
> +                               + i * entry_size);
> +               dt_offset = fdt32_to_cpu(e->dt_offset);
> +               dt_size = fdt32_to_cpu(e->dt_size);
> +
> +               printf("dt_table_entry[%d]:\n", i);
> +               printf("             dt_size = %d\n", dt_size);
> +               printf("           dt_offset = %d\n", dt_offset);
> +               printf("                  id = %08x\n", fdt32_to_cpu(e->id));
> +               printf("                 rev = %08x\n", fdt32_to_cpu(e->rev));
> +
> +               for (j = 0; j < 4; ++j) {
> +                       printf("           custom[%d] = %08x\n", j,
> +                              fdt32_to_cpu(e->custom[j]));
> +               }
> +
> +               /* Print FDT info for this entry */
> +               fdt = (const struct fdt_header *)((ulong)hdr + dt_offset);
> +               android_dt_print_fdt_info(fdt);
> +       }
> +}
> +#endif
> diff --git a/include/dt_table.h b/include/dt_table.h
> new file mode 100644
> index 0000000000..19cbbeab2a
> --- /dev/null
> +++ b/include/dt_table.h
> @@ -0,0 +1,46 @@
> +/*
> + * This is from the Android Project,
> + * Repository: https://android.googlesource.com/platform/system/libufdt
> + * File: utils/src/dt_table.h
> + * Commit: 58a7582180f477032cd6c74f8d9afad0038e74c3
> + * Copyright (C) 2017 The Android Open Source Project
> + *
> + * SPDX-License-Identifier: BSD-3-Clause
> + */
> +
> +#ifndef DT_TABLE_H
> +#define DT_TABLE_H
> +
> +#include <linux/types.h>
> +
> +#define DT_TABLE_MAGIC                 0xd7b7ab1e
> +#define DT_TABLE_DEFAULT_PAGE_SIZE     2048
> +
> +struct dt_table_header {
> +       u32 magic;              /* DT_TABLE_MAGIC */
> +       u32 total_size;         /* includes dt_table_header + all dt_table_entry
> +                                * and all dtb/dtbo
> +                                */
> +       u32 header_size;        /* sizeof(dt_table_header) */
> +
> +       u32 dt_entry_size;      /* sizeof(dt_table_entry) */
> +       u32 dt_entry_count;     /* number of dt_table_entry */
> +       u32 dt_entries_offset;  /* offset to the first dt_table_entry
> +                                * from head of dt_table_header.
> +                                * The value will be equal to header_size if
> +                                * no padding is appended
> +                                */
> +       u32 page_size;          /* flash page size we assume */
> +       u32 reserved[1];        /* must be zero */
> +};
> +
> +struct dt_table_entry {
> +       u32 dt_size;
> +       u32 dt_offset;          /* offset from head of dt_table_header */
> +
> +       u32 id;                 /* optional, must be zero if unused */
> +       u32 rev;                /* optional, must be zero if unused */
> +       u32 custom[4];          /* optional, must be zero if unused */
> +};
> +
> +#endif
> diff --git a/include/image-android-dt.h b/include/image-android-dt.h
> new file mode 100644
> index 0000000000..f9b5ff3f13
> --- /dev/null
> +++ b/include/image-android-dt.h
> @@ -0,0 +1,18 @@
> +/*
> + * (C) Copyright 2018 Linaro Ltd.
> + * Sam Protsenko <semen.protsenko@linaro.org>
> + *
> + * SPDX-License-Identifier:    GPL-2.0+
> + */
> +
> +#ifndef IMAGE_ANDROID_DT_H
> +#define IMAGE_ANDROID_DT_H
> +
> +#include <dt_table.h>
> +
> +bool android_dt_check_header(const struct dt_table_header *hdr);
> +void android_dt_print_contents(const struct dt_table_header *hdr);
> +bool android_dt_get_fdt_by_index(const struct dt_table_header *hdr,
> +                                u32 index, ulong *addr, u32 *size);
> +
> +#endif /* IMAGE_ANDROID_DT_H */
> --
> 2.17.0
>

Abandon this change. I'm going to send v2 soon.

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

* [U-Boot] [PATCH 2/5] cmd: Add dtimg command
  2018-04-16 20:32 ` [U-Boot] [PATCH 2/5] cmd: Add dtimg command Sam Protsenko
@ 2018-04-19 20:25   ` Sam Protsenko
  0 siblings, 0 replies; 22+ messages in thread
From: Sam Protsenko @ 2018-04-19 20:25 UTC (permalink / raw)
  To: u-boot

On 16 April 2018 at 23:32, Sam Protsenko <semen.protsenko@linaro.org> wrote:
> dtimg command allows user to work with Android DTB/DTBO image format.
> Such as, getting the address of desired DTB/DTBO file, printing the dump
> of the image in U-Boot shell, etc.
>
> This command is needed to provide Android boot with new Android DT image
> format further.
>
> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
> ---
>  cmd/Kconfig     |   8 +++
>  cmd/Makefile    |   1 +
>  cmd/dtimg.c     | 142 ++++++++++++++++++++++++++++++++++++++++++++++++
>  common/Makefile |   4 ++
>  4 files changed, 155 insertions(+)
>  create mode 100644 cmd/dtimg.c
>
> diff --git a/cmd/Kconfig b/cmd/Kconfig
> index bc1d2f31c0..68f3cc7b48 100644
> --- a/cmd/Kconfig
> +++ b/cmd/Kconfig
> @@ -256,6 +256,14 @@ config CMD_BOOTMENU
>         help
>           Add an ANSI terminal boot menu command.
>
> +config CMD_DTIMG
> +       bool "dtimg"
> +       help
> +         Android DTB/DTBO image manipulation commands. Read dtb/dtbo files from
> +         image into RAM, dump image structure information, etc. Those dtb/dtbo
> +         files should be merged in one dtb further, which needs to be passed to
> +         the kernel, as part of a boot process.
> +
>  config CMD_ELF
>         bool "bootelf, bootvx"
>         default y
> diff --git a/cmd/Makefile b/cmd/Makefile
> index c4269ac8ac..1cc2e74e9e 100644
> --- a/cmd/Makefile
> +++ b/cmd/Makefile
> @@ -43,6 +43,7 @@ ifdef CONFIG_POST
>  obj-$(CONFIG_CMD_DIAG) += diag.o
>  endif
>  obj-$(CONFIG_CMD_DISPLAY) += display.o
> +obj-$(CONFIG_CMD_DTIMG) += dtimg.o
>  obj-$(CONFIG_CMD_ECHO) += echo.o
>  obj-$(CONFIG_ENV_IS_IN_EEPROM) += eeprom.o
>  obj-$(CONFIG_CMD_EEPROM) += eeprom.o
> diff --git a/cmd/dtimg.c b/cmd/dtimg.c
> new file mode 100644
> index 0000000000..0b046402fe
> --- /dev/null
> +++ b/cmd/dtimg.c
> @@ -0,0 +1,142 @@
> +/*
> + * (C) Copyright 2018 Linaro Ltd.
> + * Sam Protsenko <semen.protsenko@linaro.org>
> + *
> + * SPDX-License-Identifier:    GPL-2.0+
> + */
> +
> +#include <image-android-dt.h>
> +#include <common.h>
> +
> +enum cmd_dtimg_info {
> +       CMD_DTIMG_START = 0,
> +       CMD_DTIMG_SIZE,
> +};
> +
> +static int do_dtimg_dump(cmd_tbl_t *cmdtp, int flag, int argc,
> +                        char * const argv[])
> +{
> +       char *endp;
> +       void *hdr;
> +
> +       if (argc != 2)
> +               return CMD_RET_USAGE;
> +
> +       hdr = (void *)simple_strtoul(argv[1], &endp, 16);
> +       if (*endp != '\0') {
> +               printf("Error: Wrong image address\n");
> +               return CMD_RET_FAILURE;
> +       }
> +
> +       if (!android_dt_check_header(hdr)) {
> +               printf("Error: DT image header is incorrect\n");
> +               return CMD_RET_FAILURE;
> +       }
> +
> +       android_dt_print_contents(hdr);
> +
> +       return CMD_RET_SUCCESS;
> +}
> +
> +static int dtimg_get_fdt(int argc, char * const argv[], enum cmd_dtimg_info cmd)
> +{
> +       void *hdr;
> +       u32 index;
> +       char *endp;
> +       ulong addr;
> +       u32 size;
> +       char buf[512] = { 0 };
> +
> +       if (argc != 4)
> +               return CMD_RET_USAGE;
> +
> +       hdr = (void *)simple_strtoul(argv[1], &endp, 16);
> +       if (*endp != '\0') {
> +               printf("Error: Wrong image address\n");
> +               return CMD_RET_FAILURE;
> +       }
> +
> +       if (!android_dt_check_header(hdr)) {
> +               printf("Error: DT image header is incorrect\n");
> +               return CMD_RET_FAILURE;
> +       }
> +
> +       index = simple_strtoul(argv[2], &endp, 0);
> +       if (*endp != '\0') {
> +               printf("Error: Wrong index\n");
> +               return CMD_RET_FAILURE;
> +       }
> +
> +       if (!android_dt_get_fdt_by_index(hdr, index, &addr, &size))
> +               return CMD_RET_FAILURE;
> +
> +       switch (cmd) {
> +       case CMD_DTIMG_START:
> +               snprintf(buf, sizeof(buf), "%p", (void *)addr);
> +               break;
> +       case CMD_DTIMG_SIZE:
> +               snprintf(buf, sizeof(buf), "%x", size);
> +               break;
> +       default:
> +               printf("Error: Unknown cmd_dtimg_info value: %d\n", cmd);
> +               return CMD_RET_FAILURE;
> +       }
> +
> +       env_set(argv[3], buf);
> +
> +       return CMD_RET_SUCCESS;
> +}
> +
> +static int do_dtimg_start(cmd_tbl_t *cmdtp, int flag, int argc,
> +                         char * const argv[])
> +{
> +       return dtimg_get_fdt(argc, argv, CMD_DTIMG_START);
> +}
> +
> +static int do_dtimg_size(cmd_tbl_t *cmdtp, int flag, int argc,
> +                        char * const argv[])
> +{
> +       return dtimg_get_fdt(argc, argv, CMD_DTIMG_SIZE);
> +}
> +
> +static cmd_tbl_t cmd_dtimg_sub[] = {
> +       U_BOOT_CMD_MKENT(dump, 2, 0, do_dtimg_dump, "", ""),
> +       U_BOOT_CMD_MKENT(start, 4, 0, do_dtimg_start, "", ""),
> +       U_BOOT_CMD_MKENT(size, 4, 0, do_dtimg_size, "", ""),
> +};
> +
> +static int do_dtimg(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> +{
> +       cmd_tbl_t *cp;
> +
> +       cp = find_cmd_tbl(argv[1], cmd_dtimg_sub, ARRAY_SIZE(cmd_dtimg_sub));
> +
> +       /* Strip off leading 'dtimg' command argument */
> +       argc--;
> +       argv++;
> +
> +       if (!cp || argc > cp->maxargs)
> +               return CMD_RET_USAGE;
> +       if (flag == CMD_FLAG_REPEAT && !cp->repeatable)
> +               return CMD_RET_SUCCESS;
> +
> +       return cp->cmd(cmdtp, flag, argc, argv);
> +}
> +
> +U_BOOT_CMD(
> +       dtimg, CONFIG_SYS_MAXARGS, 0, do_dtimg,
> +       "manipulate dtb/dtbo Android image",
> +       "dump <addr>\n"
> +       "    - parse specified image and print its structure info\n"
> +       "      <addr>: image address in RAM, in hex\n"
> +       "dtimg start <addr> <index> <varname>\n"
> +       "    - get address (hex) of FDT in the image, by index\n"
> +       "      <addr>: image address in RAM, in hex\n"
> +       "      <index>: index of desired FDT in the image\n"
> +       "      <varname>: name of variable where to store address of FDT\n"
> +       "dtimg size <addr> <index> <varname>\n"
> +       "    - get size (hex, bytes) of FDT in the image, by index\n"
> +       "      <addr>: image address in RAM, in hex\n"
> +       "      <index>: index of desired FDT in the image\n"
> +       "      <varname>: name of variable where to store size of FDT"
> +);
> diff --git a/common/Makefile b/common/Makefile
> index 7011dada99..6ef55d0d7a 100644
> --- a/common/Makefile
> +++ b/common/Makefile
> @@ -111,6 +111,10 @@ obj-$(CONFIG_IO_TRACE) += iotrace.o
>  obj-y += memsize.o
>  obj-y += stdio.o
>
> +ifdef CONFIG_CMD_DTIMG
> +obj-y += image-android-dt.o
> +endif
> +
>  ifndef CONFIG_SPL_BUILD
>  # This option is not just y/n - it can have a numeric value
>  ifdef CONFIG_FASTBOOT_FLASH
> --
> 2.17.0
>

Abandon this change. I'm going to send v2 soon.

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

* [U-Boot] [PATCH 3/5] arm: ti: boot: Extract PARTS_DEFAULT to boot.h
  2018-04-16 20:32 ` [U-Boot] [PATCH 3/5] arm: ti: boot: Extract PARTS_DEFAULT to boot.h Sam Protsenko
  2018-04-17 21:02   ` Andrew F. Davis
@ 2018-04-19 20:25   ` Sam Protsenko
  1 sibling, 0 replies; 22+ messages in thread
From: Sam Protsenko @ 2018-04-19 20:25 UTC (permalink / raw)
  To: u-boot

On 16 April 2018 at 23:32, Sam Protsenko <semen.protsenko@linaro.org> wrote:
> Eliminate code duplication: the same PARTS_DEFAULT was defined in
> am57xx_evm.h and in dra7xx_evm.h. Extract it to environment/boot.h and
> use in all OMAP5-based boards.
>
> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
> ---
>  include/configs/am57xx_evm.h   | 25 -------------------------
>  include/configs/cl-som-am57x.h |  2 ++
>  include/configs/cm_t54.h       |  2 ++
>  include/configs/dra7xx_evm.h   | 25 -------------------------
>  include/environment/ti/boot.h  | 27 +++++++++++++++++++++++++--
>  5 files changed, 29 insertions(+), 52 deletions(-)
>
> diff --git a/include/configs/am57xx_evm.h b/include/configs/am57xx_evm.h
> index d1f73f76a4..886a5696f5 100644
> --- a/include/configs/am57xx_evm.h
> +++ b/include/configs/am57xx_evm.h
> @@ -38,31 +38,6 @@
>
>  #define CONFIG_SYS_OMAP_ABE_SYSCK
>
> -/* Define the default GPT table for eMMC */
> -#define PARTS_DEFAULT \
> -       /* Linux partitions */ \
> -       "uuid_disk=${uuid_gpt_disk};" \
> -       "name=bootloader,start=384K,size=1792K,uuid=${uuid_gpt_bootloader};" \
> -       "name=rootfs,start=2688K,size=-,uuid=${uuid_gpt_rootfs}\0" \
> -       /* Android partitions */ \
> -       "partitions_android=" \
> -       "uuid_disk=${uuid_gpt_disk};" \
> -       "name=xloader,start=128K,size=256K,uuid=${uuid_gpt_xloader};" \
> -       "name=bootloader,size=1792K,uuid=${uuid_gpt_bootloader};" \
> -       "name=environment,size=128K,uuid=${uuid_gpt_environment};" \
> -       "name=misc,size=128K,uuid=${uuid_gpt_misc};" \
> -       "name=reserved,size=256K,uuid=${uuid_gpt_reserved};" \
> -       "name=efs,size=16M,uuid=${uuid_gpt_efs};" \
> -       "name=crypto,size=16K,uuid=${uuid_gpt_crypto};" \
> -       "name=recovery,size=40M,uuid=${uuid_gpt_recovery};" \
> -       "name=boot,size=10M,uuid=${uuid_gpt_boot};" \
> -       "name=system,size=768M,uuid=${uuid_gpt_system};" \
> -       "name=vendor,size=256M,uuid=${uuid_gpt_vendor};" \
> -       "name=cache,size=256M,uuid=${uuid_gpt_cache};" \
> -       "name=ipu1,size=1M,uuid=${uuid_gpt_ipu1};" \
> -       "name=ipu2,size=1M,uuid=${uuid_gpt_ipu2};" \
> -       "name=userdata,size=-,uuid=${uuid_gpt_userdata}"
> -
>  #define DFUARGS \
>         "dfu_bufsiz=0x10000\0" \
>         DFU_ALT_INFO_MMC \
> diff --git a/include/configs/cl-som-am57x.h b/include/configs/cl-som-am57x.h
> index 9c70cf0b37..709e0375b3 100644
> --- a/include/configs/cl-som-am57x.h
> +++ b/include/configs/cl-som-am57x.h
> @@ -18,6 +18,8 @@
>
>  #define CONFIG_SYS_OMAP_ABE_SYSCK
>
> +#define PARTS_DEFAULT
> +
>  #include <configs/ti_omap5_common.h>
>
>  /* misc */
> diff --git a/include/configs/cm_t54.h b/include/configs/cm_t54.h
> index 6123cd374d..f0d76ed806 100644
> --- a/include/configs/cm_t54.h
> +++ b/include/configs/cm_t54.h
> @@ -14,6 +14,8 @@
>  #define CONFIG_CM_T54
>  #define CONFIG_DRAM_2G
>
> +#define PARTS_DEFAULT
> +
>  #include <configs/ti_omap5_common.h>
>
>  /* EEPROM related defines */
> diff --git a/include/configs/dra7xx_evm.h b/include/configs/dra7xx_evm.h
> index 917a05d701..9b3fb2c913 100644
> --- a/include/configs/dra7xx_evm.h
> +++ b/include/configs/dra7xx_evm.h
> @@ -45,31 +45,6 @@
>  #define CONFIG_SYS_OMAP_ABE_SYSCK
>
>  #ifndef CONFIG_SPL_BUILD
> -/* Define the default GPT table for eMMC */
> -#define PARTS_DEFAULT \
> -       /* Linux partitions */ \
> -       "uuid_disk=${uuid_gpt_disk};" \
> -       "name=bootloader,start=384K,size=1792K,uuid=${uuid_gpt_bootloader};" \
> -       "name=rootfs,start=2688K,size=-,uuid=${uuid_gpt_rootfs}\0" \
> -       /* Android partitions */ \
> -       "partitions_android=" \
> -       "uuid_disk=${uuid_gpt_disk};" \
> -       "name=xloader,start=128K,size=256K,uuid=${uuid_gpt_xloader};" \
> -       "name=bootloader,size=1792K,uuid=${uuid_gpt_bootloader};" \
> -       "name=environment,size=128K,uuid=${uuid_gpt_environment};" \
> -       "name=misc,size=128K,uuid=${uuid_gpt_misc};" \
> -       "name=reserved,size=256K,uuid=${uuid_gpt_reserved};" \
> -       "name=efs,size=16M,uuid=${uuid_gpt_efs};" \
> -       "name=crypto,size=16K,uuid=${uuid_gpt_crypto};" \
> -       "name=recovery,size=40M,uuid=${uuid_gpt_recovery};" \
> -       "name=boot,size=10M,uuid=${uuid_gpt_boot};" \
> -       "name=system,size=768M,uuid=${uuid_gpt_system};" \
> -       "name=vendor,size=256M,uuid=${uuid_gpt_vendor};" \
> -       "name=cache,size=256M,uuid=${uuid_gpt_cache};" \
> -       "name=ipu1,size=1M,uuid=${uuid_gpt_ipu1};" \
> -       "name=ipu2,size=1M,uuid=${uuid_gpt_ipu2};" \
> -       "name=userdata,size=-,uuid=${uuid_gpt_userdata}"
> -
>  #define DFUARGS \
>         "dfu_bufsiz=0x10000\0" \
>         DFU_ALT_INFO_MMC \
> diff --git a/include/environment/ti/boot.h b/include/environment/ti/boot.h
> index 24b7783f88..4f3d748b5c 100644
> --- a/include/environment/ti/boot.h
> +++ b/include/environment/ti/boot.h
> @@ -15,8 +15,31 @@
>  #endif
>
>  #ifndef PARTS_DEFAULT
> -#define PARTS_DEFAULT
> -#endif
> +/* Define the default GPT table for eMMC */
> +#define PARTS_DEFAULT \
> +       /* Linux partitions */ \
> +       "uuid_disk=${uuid_gpt_disk};" \
> +       "name=bootloader,start=384K,size=1792K,uuid=${uuid_gpt_bootloader};" \
> +       "name=rootfs,start=2688K,size=-,uuid=${uuid_gpt_rootfs}\0" \
> +       /* Android partitions */ \
> +       "partitions_android=" \
> +       "uuid_disk=${uuid_gpt_disk};" \
> +       "name=xloader,start=128K,size=256K,uuid=${uuid_gpt_xloader};" \
> +       "name=bootloader,size=1792K,uuid=${uuid_gpt_bootloader};" \
> +       "name=environment,size=128K,uuid=${uuid_gpt_environment};" \
> +       "name=misc,size=128K,uuid=${uuid_gpt_misc};" \
> +       "name=reserved,size=256K,uuid=${uuid_gpt_reserved};" \
> +       "name=efs,size=16M,uuid=${uuid_gpt_efs};" \
> +       "name=crypto,size=16K,uuid=${uuid_gpt_crypto};" \
> +       "name=recovery,size=40M,uuid=${uuid_gpt_recovery};" \
> +       "name=boot,size=10M,uuid=${uuid_gpt_boot};" \
> +       "name=system,size=768M,uuid=${uuid_gpt_system};" \
> +       "name=vendor,size=256M,uuid=${uuid_gpt_vendor};" \
> +       "name=cache,size=256M,uuid=${uuid_gpt_cache};" \
> +       "name=ipu1,size=1M,uuid=${uuid_gpt_ipu1};" \
> +       "name=ipu2,size=1M,uuid=${uuid_gpt_ipu2};" \
> +       "name=userdata,size=-,uuid=${uuid_gpt_userdata}"
> +#endif /* PARTS_DEFAULT */
>
>  #define DEFAULT_COMMON_BOOT_TI_ARGS \
>         "console=" CONSOLEDEV ",115200n8\0" \
> --
> 2.17.0
>

Abandon this change. I'm going to send v2 soon.

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

* [U-Boot] [PATCH 4/5] arm: ti: boot: Add dtbo partition for Android boot
  2018-04-17 21:10   ` Andrew F. Davis
@ 2018-04-19 20:33     ` Sam Protsenko
  0 siblings, 0 replies; 22+ messages in thread
From: Sam Protsenko @ 2018-04-19 20:33 UTC (permalink / raw)
  To: u-boot

On 18 April 2018 at 00:10, Andrew F. Davis <afd@ti.com> wrote:
> On 04/16/2018 03:32 PM, Sam Protsenko wrote:
>> New Android boot scheme looks like this [1], and it involves adding new
>> partition for storing Device Tree Overlays. This patch adds dtbo
>> partition. While at it, let's revise Android partition table a bit.
>>
>> List of changes:
>>  - rename "misc" to "hole" (not used for anything, just a guard hole)
>
> Could we instead expand the bootloader partition and just remove this
> hole partition?
>

We can, I just think having dedicated partition for this can spare us
some debugging time in future. As I explained it in my commit message:

  We are using "hole" partition instead of specifying "start" property to
  "uenv" partition, because this way it's easier to maintain change of
  preceding partitions.

>>  - rename "reserved" to "uenv" (because it hold U-Boot environment)
>
> This is fine.
>
>>  - rename "environment" to "dtb" (because it actually holds .dtb file)
>
>
> We are working to move to FIT with our Android releases, so the
> "boot.img" image will now be a FIT image that contains kernel, dtb,
> dtbo, op-tee, ipu, ipu2, etc...
>
> The end result is all these custom partitions we had before all just get
> folded into the one boot partition.
>

As I understand, it's not completely our shot. If Google says it's
mandatory to use DT image format, we will use it. That's why I
implemented this patch series. Please discuss it with Praneeth, some
of us obviously is not on the same page with others... For now we are
going to add DT image format support, and once we have confirmation
from Google, we can choose which one to prefer in upstream. But having
support of this format won't hurt anyone, especially knowing that
Google recommends this format in their documentation.

> Andrew
>
>
>>  - move "dtb" after "uenv" (so that changes of dtb size won't affect
>>    "uenv" offset)
>>  - make "hole" size twice as bigger (to keep "uenv" offset the same,
>>    because "dtb" was moved after "uenv")
>>  - add "dtbo" partition (after "dtb", to not affect "uenv" offset)
>>  - while at it, increase "boot" partition size up to 20 MiB; that's
>>    needed because while playing with some additional drivers built-in
>>    and different compression techniques, and also for HS signing, we
>>    have seen the boot partition size reach close to border and
>>    sometimes reach over the limit of 10 MiB
>>
>> Now eMMC layout looks like this:
>>
>>     offset           content             size          partition
>>     (KiB)                                (KiB)
>>
>>     ===============================================================
>>
>>     0       +------------------------+
>>             | MBR/GPT header         |   128           -
>>     128     +------------------------+
>>             | MLO                    |   256           xloader
>>     384     +------------------------+
>>             | u-boot.img             |   1792          bootloader
>>     2176    +------------------------+
>>             | //////// hole //////// |   256           hole
>>     2432    +------------------------+
>>             | U-Boot environment     |   256           uenv
>>             | (+ redundant)          |
>>     2688    +------------------------+
>>             | dtb files              |   1024          dtb
>>     3712    +------------------------+
>>             | dtbo files             |   1024          dtbo
>>     4736    +------------------------+
>>               Android partitions         remaining     *
>>
>>     ===============================================================
>>
>> "hole" partition is needed just to keep U-Boot environment at 2432 KiB
>> offset, because:
>>  - this offset is used in DFU_ALT_INFO_EMMC:
>>
>>        "u-env.raw raw 0x1300 0x200;"
>>        0x1300 = 4864 sectors = 2432 KiB
>>
>>  - which in turn relies on CONFIG_ENV_OFFSET:
>>
>>        CONFIG_ENV_OFFSET = 0x260000 = 2432 KiB
>>
>> We are using "hole" partition instead of specifying "start" property to
>> "uenv" partition, because this way it's easier to maintain change of
>> preceding partitions.
>>
>> Also fix Android boot commands appropriately.
>>
>> [1] https://source.android.com/devices/architecture/dto/partitions
>>
>> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
>> ---
>>  include/environment/ti/boot.h | 13 +++++++------
>>  1 file changed, 7 insertions(+), 6 deletions(-)
>>
>> diff --git a/include/environment/ti/boot.h b/include/environment/ti/boot.h
>> index 4f3d748b5c..f2d91f5298 100644
>> --- a/include/environment/ti/boot.h
>> +++ b/include/environment/ti/boot.h
>> @@ -26,13 +26,14 @@
>>       "uuid_disk=${uuid_gpt_disk};" \
>>       "name=xloader,start=128K,size=256K,uuid=${uuid_gpt_xloader};" \
>>       "name=bootloader,size=1792K,uuid=${uuid_gpt_bootloader};" \
>> -     "name=environment,size=128K,uuid=${uuid_gpt_environment};" \
>> -     "name=misc,size=128K,uuid=${uuid_gpt_misc};" \
>> -     "name=reserved,size=256K,uuid=${uuid_gpt_reserved};" \
>> +     "name=hole,size=256K,uuid=${uuid_gpt_hole};" \
>> +     "name=uenv,size=256K,uuid=${uuid_gpt_uenv};" \
>> +     "name=dtb,size=1M,uuid=${uuid_gpt_dtb};" \
>> +     "name=dtbo,size=1M,uuid=${uuid_gpt_dtbo};" \
>>       "name=efs,size=16M,uuid=${uuid_gpt_efs};" \
>>       "name=crypto,size=16K,uuid=${uuid_gpt_crypto};" \
>>       "name=recovery,size=40M,uuid=${uuid_gpt_recovery};" \
>> -     "name=boot,size=10M,uuid=${uuid_gpt_boot};" \
>> +     "name=boot,size=20M,uuid=${uuid_gpt_boot};" \
>>       "name=system,size=768M,uuid=${uuid_gpt_system};" \
>>       "name=vendor,size=256M,uuid=${uuid_gpt_vendor};" \
>>       "name=cache,size=256M,uuid=${uuid_gpt_cache};" \
>> @@ -66,8 +67,8 @@
>>               "setenv machid fe6; " \
>>               "mmc dev $mmcdev; " \
>>               "mmc rescan; " \
>> -             "part start mmc ${mmcdev} environment fdt_start; " \
>> -             "part size mmc ${mmcdev} environment fdt_size; " \
>> +             "part start mmc ${mmcdev} dtb fdt_start; " \
>> +             "part size mmc ${mmcdev} dtb fdt_size; " \
>>               "part start mmc ${mmcdev} boot boot_start; " \
>>               "part size mmc ${mmcdev} boot boot_size; " \
>>               "mmc read ${fdtaddr} ${fdt_start} ${fdt_size}; " \
>>

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

* [U-Boot] [PATCH 4/5] arm: ti: boot: Add dtbo partition for Android boot
  2018-04-16 20:32 ` [U-Boot] [PATCH 4/5] arm: ti: boot: Add dtbo partition for Android boot Sam Protsenko
  2018-04-17 21:10   ` Andrew F. Davis
@ 2018-04-19 20:34   ` Sam Protsenko
  1 sibling, 0 replies; 22+ messages in thread
From: Sam Protsenko @ 2018-04-19 20:34 UTC (permalink / raw)
  To: u-boot

On 16 April 2018 at 23:32, Sam Protsenko <semen.protsenko@linaro.org> wrote:
> New Android boot scheme looks like this [1], and it involves adding new
> partition for storing Device Tree Overlays. This patch adds dtbo
> partition. While at it, let's revise Android partition table a bit.
>
> List of changes:
>  - rename "misc" to "hole" (not used for anything, just a guard hole)
>  - rename "reserved" to "uenv" (because it hold U-Boot environment)
>  - rename "environment" to "dtb" (because it actually holds .dtb file)
>  - move "dtb" after "uenv" (so that changes of dtb size won't affect
>    "uenv" offset)
>  - make "hole" size twice as bigger (to keep "uenv" offset the same,
>    because "dtb" was moved after "uenv")
>  - add "dtbo" partition (after "dtb", to not affect "uenv" offset)
>  - while at it, increase "boot" partition size up to 20 MiB; that's
>    needed because while playing with some additional drivers built-in
>    and different compression techniques, and also for HS signing, we
>    have seen the boot partition size reach close to border and
>    sometimes reach over the limit of 10 MiB
>
> Now eMMC layout looks like this:
>
>     offset           content             size          partition
>     (KiB)                                (KiB)
>
>     ===============================================================
>
>     0       +------------------------+
>             | MBR/GPT header         |   128           -
>     128     +------------------------+
>             | MLO                    |   256           xloader
>     384     +------------------------+
>             | u-boot.img             |   1792          bootloader
>     2176    +------------------------+
>             | //////// hole //////// |   256           hole
>     2432    +------------------------+
>             | U-Boot environment     |   256           uenv
>             | (+ redundant)          |
>     2688    +------------------------+
>             | dtb files              |   1024          dtb
>     3712    +------------------------+
>             | dtbo files             |   1024          dtbo
>     4736    +------------------------+
>               Android partitions         remaining     *
>
>     ===============================================================
>
> "hole" partition is needed just to keep U-Boot environment at 2432 KiB
> offset, because:
>  - this offset is used in DFU_ALT_INFO_EMMC:
>
>        "u-env.raw raw 0x1300 0x200;"
>        0x1300 = 4864 sectors = 2432 KiB
>
>  - which in turn relies on CONFIG_ENV_OFFSET:
>
>        CONFIG_ENV_OFFSET = 0x260000 = 2432 KiB
>
> We are using "hole" partition instead of specifying "start" property to
> "uenv" partition, because this way it's easier to maintain change of
> preceding partitions.
>
> Also fix Android boot commands appropriately.
>
> [1] https://source.android.com/devices/architecture/dto/partitions
>
> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
> ---
>  include/environment/ti/boot.h | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/include/environment/ti/boot.h b/include/environment/ti/boot.h
> index 4f3d748b5c..f2d91f5298 100644
> --- a/include/environment/ti/boot.h
> +++ b/include/environment/ti/boot.h
> @@ -26,13 +26,14 @@
>         "uuid_disk=${uuid_gpt_disk};" \
>         "name=xloader,start=128K,size=256K,uuid=${uuid_gpt_xloader};" \
>         "name=bootloader,size=1792K,uuid=${uuid_gpt_bootloader};" \
> -       "name=environment,size=128K,uuid=${uuid_gpt_environment};" \
> -       "name=misc,size=128K,uuid=${uuid_gpt_misc};" \
> -       "name=reserved,size=256K,uuid=${uuid_gpt_reserved};" \
> +       "name=hole,size=256K,uuid=${uuid_gpt_hole};" \
> +       "name=uenv,size=256K,uuid=${uuid_gpt_uenv};" \
> +       "name=dtb,size=1M,uuid=${uuid_gpt_dtb};" \
> +       "name=dtbo,size=1M,uuid=${uuid_gpt_dtbo};" \
>         "name=efs,size=16M,uuid=${uuid_gpt_efs};" \
>         "name=crypto,size=16K,uuid=${uuid_gpt_crypto};" \
>         "name=recovery,size=40M,uuid=${uuid_gpt_recovery};" \
> -       "name=boot,size=10M,uuid=${uuid_gpt_boot};" \
> +       "name=boot,size=20M,uuid=${uuid_gpt_boot};" \
>         "name=system,size=768M,uuid=${uuid_gpt_system};" \
>         "name=vendor,size=256M,uuid=${uuid_gpt_vendor};" \
>         "name=cache,size=256M,uuid=${uuid_gpt_cache};" \
> @@ -66,8 +67,8 @@
>                 "setenv machid fe6; " \
>                 "mmc dev $mmcdev; " \
>                 "mmc rescan; " \
> -               "part start mmc ${mmcdev} environment fdt_start; " \
> -               "part size mmc ${mmcdev} environment fdt_size; " \
> +               "part start mmc ${mmcdev} dtb fdt_start; " \
> +               "part size mmc ${mmcdev} dtb fdt_size; " \
>                 "part start mmc ${mmcdev} boot boot_start; " \
>                 "part size mmc ${mmcdev} boot boot_size; " \
>                 "mmc read ${fdtaddr} ${fdt_start} ${fdt_size}; " \
> --
> 2.17.0
>

Abandon this patch. I'm gonna send v2 soon.

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

* [U-Boot] [PATCH 5/5] arm: ti: boot: Implement Android boot using DT image format
  2018-04-16 20:32 ` [U-Boot] [PATCH 5/5] arm: ti: boot: Implement Android boot using DT image format Sam Protsenko
@ 2018-04-19 20:36   ` Sam Protsenko
  2019-03-14 15:19   ` [U-Boot] [5/5] " Eugeniu Rosca
  1 sibling, 0 replies; 22+ messages in thread
From: Sam Protsenko @ 2018-04-19 20:36 UTC (permalink / raw)
  To: u-boot

On 16 April 2018 at 23:32, Sam Protsenko <semen.protsenko@linaro.org> wrote:
> Make sure we can boot Android on TI boards using scheme described in
> Android documentation [1]. For this do next:
>  1. Enable "dtimg" command. We will need it to boot the Android using
>     new DTB/DTBO image format.
>  2. Add fdt overlay support. We will need that to be able to apply fdt
>     overlays to dtb file.
>  3. Provide new Android boot commands. In case we don't know what board
>     it is, let's provide fallback mechanism:
>      - use just dtb[0] from dtb.img
>      - don't apply any dtbo files on top of it
>      - but still that dtb file must be packed into Android DT image
>
> To use new boot scheme, user has to do next:
>
> 1. Prepare dtb.img and dtbo.img images, generated with mkdtimg tool (can
>    be found in Android sources, see prebuilts/misc/linux-x86/libufdt).
>    Example:
>
>    $ ./mkdtimg create dtb.img                            \
>                       am57xx-beagle-x15.dtb      --id=0  \
>                       am57xx-beagle-x15-revc.dtb --id=1
>
>    $ ./mkdtimg create dtbo.img \
>                       am57xx-evm-common.dtbo     --id=0  \
>                       mt9t111.dtbo               --id=1  \
>                       ov10635.dtbo               --id=2  \
>                       am57xx-evm.dtbo            --id=3  \
>                       am57xx-evm-reva3.dtbo      --id=4
>
>    Current boot commands rely on that specific order of dtb/dtbo files.
>    Also, be sure to compile .dtb files with -@ dtc flag, so that
>    overlays can be applied to dtb files.
>
> 2. Flash new U-Boot, set new environment and format eMMC:
>
>    $ fastboot flash xloader MLO
>    $ fastboot flash bootloader u-boot.img
>
>    => env default -f -a
>    => setenv partitions $partitions_android
>    => env save
>    => fastboot 1
>
>    $ fastboot oem format
>
> 3. Flash dtb.img, dtbo.img:
>
>    $ fastboot flash dtb dtb.img
>    $ fastboot flash dtbo dtbo.img
>
> 4. Flash Android images:
>
>    $ fastboot flash boot boot.img
>    $ fastboot flash cache cache.img
>    $ fastboot flash recovery recovery.img
>    $ fastboot flash system system.img
>    $ fastboot flash userdata userdata.img
>    $ fastboot flash vendor vendor.img
>
> For more detailed instructions, see [2].
>
> [1] https://source.android.com/devices/architecture/dto/partitions
> [2] https://wiki.linaro.org/Boards/BeagleBoard-X15
>
> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
> ---
>  board/ti/common/Kconfig           |  1 +
>  configs/am57xx_evm_defconfig      |  1 +
>  configs/am57xx_hs_evm_defconfig   |  1 +
>  configs/dra7xx_evm_defconfig      |  1 +
>  configs/dra7xx_hs_evm_defconfig   |  1 +
>  include/configs/ti_armv7_common.h |  1 +
>  include/environment/ti/boot.h     | 40 +++++++++++++++++++++++++------
>  7 files changed, 39 insertions(+), 7 deletions(-)
>
> diff --git a/board/ti/common/Kconfig b/board/ti/common/Kconfig
> index c21eb8c2d2..f5bd9160b3 100644
> --- a/board/ti/common/Kconfig
> +++ b/board/ti/common/Kconfig
> @@ -21,6 +21,7 @@ config TI_COMMON_CMD_OPTIONS
>         imply CRC32_VERIFY if ARCH_KEYSTONE
>         imply CMD_DFU if USB_GADGET_DOWNLOAD
>         imply CMD_DHCP
> +       imply CMD_DTIMG
>         imply CMD_EEPROM
>         imply CMD_EXT2
>         imply CMD_EXT4
> diff --git a/configs/am57xx_evm_defconfig b/configs/am57xx_evm_defconfig
> index 6b11b3476c..7198542d9e 100644
> --- a/configs/am57xx_evm_defconfig
> +++ b/configs/am57xx_evm_defconfig
> @@ -78,3 +78,4 @@ CONFIG_USB_GADGET=y
>  CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
>  CONFIG_USB_GADGET_VENDOR_NUM=0x0451
>  CONFIG_USB_GADGET_PRODUCT_NUM=0xd022
> +CONFIG_OF_LIBFDT_OVERLAY=y
> diff --git a/configs/am57xx_hs_evm_defconfig b/configs/am57xx_hs_evm_defconfig
> index ca9742f118..e4948d549b 100644
> --- a/configs/am57xx_hs_evm_defconfig
> +++ b/configs/am57xx_hs_evm_defconfig
> @@ -81,3 +81,4 @@ CONFIG_USB_GADGET=y
>  CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
>  CONFIG_USB_GADGET_VENDOR_NUM=0x0451
>  CONFIG_USB_GADGET_PRODUCT_NUM=0xd022
> +CONFIG_OF_LIBFDT_OVERLAY=y
> diff --git a/configs/dra7xx_evm_defconfig b/configs/dra7xx_evm_defconfig
> index e17135c8f6..4ce687fbda 100644
> --- a/configs/dra7xx_evm_defconfig
> +++ b/configs/dra7xx_evm_defconfig
> @@ -96,3 +96,4 @@ CONFIG_USB_GADGET=y
>  CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
>  CONFIG_USB_GADGET_VENDOR_NUM=0x0451
>  CONFIG_USB_GADGET_PRODUCT_NUM=0xd022
> +CONFIG_OF_LIBFDT_OVERLAY=y
> diff --git a/configs/dra7xx_hs_evm_defconfig b/configs/dra7xx_hs_evm_defconfig
> index 606f99938c..6546daa080 100644
> --- a/configs/dra7xx_hs_evm_defconfig
> +++ b/configs/dra7xx_hs_evm_defconfig
> @@ -95,3 +95,4 @@ CONFIG_USB_GADGET=y
>  CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
>  CONFIG_USB_GADGET_VENDOR_NUM=0x0451
>  CONFIG_USB_GADGET_PRODUCT_NUM=0xd022
> +CONFIG_OF_LIBFDT_OVERLAY=y
> diff --git a/include/configs/ti_armv7_common.h b/include/configs/ti_armv7_common.h
> index 4771e74940..4340b5188f 100644
> --- a/include/configs/ti_armv7_common.h
> +++ b/include/configs/ti_armv7_common.h
> @@ -43,6 +43,7 @@
>         "loadaddr=0x82000000\0" \
>         "kernel_addr_r=0x82000000\0" \
>         "fdtaddr=0x88000000\0" \
> +       "dtboaddr=0x89000000\0" \
>         "fdt_addr_r=0x88000000\0" \
>         "rdaddr=0x88080000\0" \
>         "ramdisk_addr_r=0x88080000\0" \
> diff --git a/include/environment/ti/boot.h b/include/environment/ti/boot.h
> index f2d91f5298..52c9f129ed 100644
> --- a/include/environment/ti/boot.h
> +++ b/include/environment/ti/boot.h
> @@ -65,15 +65,41 @@
>                 "run eval_bootargs; " \
>                 "setenv mmcdev 1; " \
>                 "setenv machid fe6; " \
> +               "setenv dtbaddr $fdtaddr; " \
> +               "setenv dtb_size 0x100000; " \
>                 "mmc dev $mmcdev; " \
>                 "mmc rescan; " \
> -               "part start mmc ${mmcdev} dtb fdt_start; " \
> -               "part size mmc ${mmcdev} dtb fdt_size; " \
> -               "part start mmc ${mmcdev} boot boot_start; " \
> -               "part size mmc ${mmcdev} boot boot_size; " \
> -               "mmc read ${fdtaddr} ${fdt_start} ${fdt_size}; " \
> -               "mmc read ${loadaddr} ${boot_start} ${boot_size}; " \
> -               "bootm $loadaddr $loadaddr $fdtaddr;\0"
> +               "part start mmc ${mmcdev} dtb p_dtb_start; " \
> +               "part size mmc ${mmcdev} dtb p_dtb_size; " \
> +               "part start mmc ${mmcdev} dtbo p_dtbo_start; " \
> +               "part size mmc ${mmcdev} dtbo p_dtbo_size; " \
> +               "part start mmc ${mmcdev} boot p_boot_start; " \
> +               "part size mmc ${mmcdev} boot p_boot_size; " \
> +               "mmc read ${dtbaddr} ${p_dtb_start} ${p_dtb_size}; " \
> +               "mmc read ${dtboaddr} ${p_dtbo_start} ${p_dtbo_size}; " \
> +               "mmc read ${loadaddr} ${p_boot_start} ${p_boot_size}; " \
> +               "if test $board_name = am57xx_evm; then " \
> +                       "dtimg start ${dtbaddr} 0 dtb_addr; " \
> +                       "fdt addr $dtb_addr $dtb_size; " \
> +                       "dtimg start ${dtboaddr} 0 dtbo_addr; " \
> +                       "fdt apply $dtbo_addr; " \
> +                       "dtimg start ${dtboaddr} 3 dtbo_addr; " \
> +                       "fdt apply $dtbo_addr; " \
> +               "elif test $board_name = am57xx_evm_reva3; then " \
> +                       "dtimg start ${dtbaddr} 1 dtb_addr; " \
> +                       "fdt addr $dtb_addr $dtb_size; " \
> +                       "dtimg start ${dtboaddr} 0 dtbo_addr; " \
> +                       "fdt apply $dtbo_addr; " \
> +                       "dtimg start ${dtboaddr} 4 dtbo_addr; " \
> +                       "fdt apply $dtbo_addr; " \
> +               "elif test $board_name = beagle_x15; then " \
> +                       "dtimg start ${dtbaddr} 0 dtb_addr; " \
> +               "elif test $board_name = beagle_x15_revc; then " \
> +                       "dtimg start ${dtbaddr} 1 dtb_addr; " \
> +               "else " \
> +                       "dtimg start ${dtbaddr} 0 dtb_addr; " \
> +               "fi; " \
> +               "bootm $loadaddr $loadaddr $dtb_addr;\0"
>
>  #ifdef CONFIG_OMAP54XX
>
> --
> 2.17.0
>

Abandon this patch. I'm gonna send v2 soon.

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

* [U-Boot] [PATCH 0/5] Use Android DT image format for TI boards
  2018-04-17 20:57 ` [U-Boot] [PATCH 0/5] Use Android DT image format for TI boards Andrew F. Davis
  2018-04-19 20:22   ` Sam Protsenko
@ 2018-04-22 20:12   ` Simon Glass
  1 sibling, 0 replies; 22+ messages in thread
From: Simon Glass @ 2018-04-22 20:12 UTC (permalink / raw)
  To: u-boot

Hi,

On 17 April 2018 at 14:57, Andrew F. Davis <afd@ti.com> wrote:
> On 04/16/2018 03:32 PM, Sam Protsenko wrote:
>> Android documentation recommends using new image format for storing dtb
>> and dtbo files: [1]. Using that format, we can pack several dtb files to
>> dtb.img, and also pack several dtbo files to dtbo.img. Then those images
>> should be flashed to eMMC partitions, called "dtb" and "dtbo"
>> respectively.
>>
>
>
> I'm not convinced adding yet another one-off Android specific partition
> format is what we need right now. With FIT images this is a solved
> problem, why does Android need to go down a different path here?

Agreed.

Regards,
Simon

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

* [U-Boot] [5/5] arm: ti: boot: Implement Android boot using DT image format
  2018-04-16 20:32 ` [U-Boot] [PATCH 5/5] arm: ti: boot: Implement Android boot using DT image format Sam Protsenko
  2018-04-19 20:36   ` Sam Protsenko
@ 2019-03-14 15:19   ` Eugeniu Rosca
  2019-03-18 19:41     ` Eugeniu Rosca
  1 sibling, 1 reply; 22+ messages in thread
From: Eugeniu Rosca @ 2019-03-14 15:19 UTC (permalink / raw)
  To: u-boot

Hi Sam,

On April 16, 2018, 8:32 p.m., Sam Protsenko wrote:
[..]
> 1. Prepare dtb.img and dtbo.img images, generated with mkdtimg tool (can
>    be found in Android sources, see prebuilts/misc/linux-x86/libufdt).
>    Example:
>
>   $ ./mkdtimg create dtb.img                            \
>                      am57xx-beagle-x15.dtb      --id=0  \
>                      am57xx-beagle-x15-revc.dtb --id=1
[..]

Thanks for the verbose and helpful descriptions above, which now serve
as source of inspiration for how to implement Android booting on other
platforms.

Both 'mkdtimg' tool and the 'mkdtboimg.py' script seem to lack the
capability of extracting the original dtb/dtbo blobs from the
dtb{o}.img file. It seems doable on the target via the 'dtimg' U-Boot
command. Is there any off-the-shelf tooling to achieve this on the host?

Many thanks,
Eugeniu.

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

* [U-Boot] [5/5] arm: ti: boot: Implement Android boot using DT image format
  2019-03-14 15:19   ` [U-Boot] [5/5] " Eugeniu Rosca
@ 2019-03-18 19:41     ` Eugeniu Rosca
  2019-03-29 15:20       ` Sam Protsenko
  0 siblings, 1 reply; 22+ messages in thread
From: Eugeniu Rosca @ 2019-03-18 19:41 UTC (permalink / raw)
  To: u-boot

On Thu, Mar 14, 2019 at 04:19:31PM +0100, Eugeniu Rosca wrote:
[..]
> 
> Both 'mkdtimg' tool and the 'mkdtboimg.py' script seem to lack the
> capability of extracting the original dtb/dtbo blobs from the
> dtb{o}.img file.
[..]

jFTR, below 'dd' workaround comes to the rescue.

$ dd skip="dt_table_entry[i]->dt_offset" \
    count="dt_table_entry[i]->dt_size"   \
    if=dtb.img of=i.dtb bs=1

> Many thanks,
> Eugeniu.

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

* [U-Boot] [5/5] arm: ti: boot: Implement Android boot using DT image format
  2019-03-18 19:41     ` Eugeniu Rosca
@ 2019-03-29 15:20       ` Sam Protsenko
  2019-03-29 16:04         ` Eugeniu Rosca
  0 siblings, 1 reply; 22+ messages in thread
From: Sam Protsenko @ 2019-03-29 15:20 UTC (permalink / raw)
  To: u-boot

Hi Eugeniu,

On Mon, Mar 18, 2019 at 9:42 PM Eugeniu Rosca <erosca@de.adit-jv.com> wrote:
>
> On Thu, Mar 14, 2019 at 04:19:31PM +0100, Eugeniu Rosca wrote:
> [..]
> >
> > Both 'mkdtimg' tool and the 'mkdtboimg.py' script seem to lack the
> > capability of extracting the original dtb/dtbo blobs from the
> > dtb{o}.img file.
> [..]
>
> jFTR, below 'dd' workaround comes to the rescue.
>
> $ dd skip="dt_table_entry[i]->dt_offset" \
>     count="dt_table_entry[i]->dt_size"   \
>     if=dtb.img of=i.dtb bs=1
>

Just checked in AOSP/master, seems like the feature is there, it's
called "dump".

    $ mkdtimg dump dtbo.img --dtb filename

For details see:

    $ mkdtimg help dump

    mkdtimg dump <image_file> (<option>...)

    options:
      -o, --output <filename>  Output file name.
                               Default is output to stdout.
      -b, --dtb <filename>     Dump dtb/dtbo files from image.
                               Will output to <filename>.0, <filename>.1, etc.

You can convert dtb to dts further, using "dtc" tool.

> > Many thanks,
> > Eugeniu.

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

* [U-Boot] [5/5] arm: ti: boot: Implement Android boot using DT image format
  2019-03-29 15:20       ` Sam Protsenko
@ 2019-03-29 16:04         ` Eugeniu Rosca
  0 siblings, 0 replies; 22+ messages in thread
From: Eugeniu Rosca @ 2019-03-29 16:04 UTC (permalink / raw)
  To: u-boot

Hi Sam,

On Fri, Mar 29, 2019 at 05:20:33PM +0200, Sam Protsenko wrote:
> Hi Eugeniu,
[..]
> Just checked in AOSP/master, seems like the feature is there, it's
> called "dump".
> 
>     $ mkdtimg dump dtbo.img --dtb filename
> 
> For details see:
> 
>     $ mkdtimg help dump
> 
>     mkdtimg dump <image_file> (<option>...)
> 
>     options:
>       -o, --output <filename>  Output file name.
>                                Default is output to stdout.
>       -b, --dtb <filename>     Dump dtb/dtbo files from image.
>                                Will output to <filename>.0, <filename>.1, etc.

The feature works as expected. Thanks!

> 
> > > Many thanks,
> > > Eugeniu.

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

end of thread, other threads:[~2019-03-29 16:04 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-16 20:32 [U-Boot] [PATCH 0/5] Use Android DT image format for TI boards Sam Protsenko
2018-04-16 20:32 ` [U-Boot] [PATCH 1/5] common: Add support for Android DT image Sam Protsenko
2018-04-19 20:24   ` Sam Protsenko
2018-04-16 20:32 ` [U-Boot] [PATCH 2/5] cmd: Add dtimg command Sam Protsenko
2018-04-19 20:25   ` Sam Protsenko
2018-04-16 20:32 ` [U-Boot] [PATCH 3/5] arm: ti: boot: Extract PARTS_DEFAULT to boot.h Sam Protsenko
2018-04-17 21:02   ` Andrew F. Davis
2018-04-19 20:25   ` Sam Protsenko
2018-04-16 20:32 ` [U-Boot] [PATCH 4/5] arm: ti: boot: Add dtbo partition for Android boot Sam Protsenko
2018-04-17 21:10   ` Andrew F. Davis
2018-04-19 20:33     ` Sam Protsenko
2018-04-19 20:34   ` Sam Protsenko
2018-04-16 20:32 ` [U-Boot] [PATCH 5/5] arm: ti: boot: Implement Android boot using DT image format Sam Protsenko
2018-04-19 20:36   ` Sam Protsenko
2019-03-14 15:19   ` [U-Boot] [5/5] " Eugeniu Rosca
2019-03-18 19:41     ` Eugeniu Rosca
2019-03-29 15:20       ` Sam Protsenko
2019-03-29 16:04         ` Eugeniu Rosca
2018-04-17 20:57 ` [U-Boot] [PATCH 0/5] Use Android DT image format for TI boards Andrew F. Davis
2018-04-19 20:22   ` Sam Protsenko
2018-04-22 20:12   ` Simon Glass
2018-04-19 20:23 ` Sam Protsenko

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.