[U-Boot] [PATCH v5 0/6] rockchip: kylin: Boot with android boot image

We are porting android to kylin board now. This series could let it boot up with android's boot image.
Changes in v5: Remove dup CONFIG_SYS_BOOT_RAMDISK_HIGH. Change commit message. Change "grf" to local var. New patch.
Changes in v4: Remove unused reboot mode definitions.
Changes in v3: Use rockchip's legacy reboot mode definitions.
Changes in v2: Add comments.
Jeffy Chen (6): ARM: bootm: Try to use relocated ramdisk rockchip: rk3036: Bind GPIO banks rockchip: kylin: Add default gpt partition table rockchip: kylin: Enable boot with android boot image rockchip: kylin: Check fastboot request rockchip: kylin: Store env in emmc
arch/arm/lib/bootm.c | 12 +++++- board/kylin/kylin_rk3036/kylin_rk3036.c | 32 +++++++++++++++ drivers/pinctrl/rockchip/pinctrl_rk3036.c | 8 ++++ include/configs/kylin_rk3036.h | 66 +++++++++++++++++++++++++++++++ 4 files changed, 117 insertions(+), 1 deletion(-)

After boot_ramdisk_high(), ramdisk would be relocated to initrd_start & initrd_end, so use them instead of rd_start & rd_end.
Signed-off-by: Jeffy Chen jeffy.chen@rock-chips.com Acked-by: Simon Glass sjg@chromium.org Reviewed-by: Tom Rini trini@konsulko.com
---
Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: Add comments.
arch/arm/lib/bootm.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c index a477cae..0838d89 100644 --- a/arch/arm/lib/bootm.c +++ b/arch/arm/lib/bootm.c @@ -225,7 +225,17 @@ static void boot_prep_linux(bootm_headers_t *images) if (BOOTM_ENABLE_MEMORY_TAGS) setup_memory_tags(gd->bd); if (BOOTM_ENABLE_INITRD_TAG) { - if (images->rd_start && images->rd_end) { + /* + * In boot_ramdisk_high(), it may relocate ramdisk to + * a specified location. And set images->initrd_start & + * images->initrd_end to relocated ramdisk's start/end + * addresses. So use them instead of images->rd_start & + * images->rd_end when possible. + */ + if (images->initrd_start && images->initrd_end) { + setup_initrd_tag(gd->bd, images->initrd_start, + images->initrd_end); + } else if (images->rd_start && images->rd_end) { setup_initrd_tag(gd->bd, images->rd_start, images->rd_end); }

On 13 January 2016 at 19:19, Jeffy Chen jeffy.chen@rock-chips.com wrote:
After boot_ramdisk_high(), ramdisk would be relocated to initrd_start & initrd_end, so use them instead of rd_start & rd_end.
Signed-off-by: Jeffy Chen jeffy.chen@rock-chips.com Acked-by: Simon Glass sjg@chromium.org Reviewed-by: Tom Rini trini@konsulko.com
Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: Add comments.
arch/arm/lib/bootm.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
Applied to u-boot-rockchip, thanks!

Call dm_scan_fdt_node() in rk3036 pinctrl uclass binding.
Signed-off-by: Jeffy Chen jeffy.chen@rock-chips.com Acked-by: Simon Glass sjg@chromium.org Reviewed-by: Tom Rini trini@konsulko.com ---
Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None
drivers/pinctrl/rockchip/pinctrl_rk3036.c | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/drivers/pinctrl/rockchip/pinctrl_rk3036.c b/drivers/pinctrl/rockchip/pinctrl_rk3036.c index 581b096..1f78bf8 100644 --- a/drivers/pinctrl/rockchip/pinctrl_rk3036.c +++ b/drivers/pinctrl/rockchip/pinctrl_rk3036.c @@ -15,6 +15,7 @@ #include <asm/arch/hardware.h> #include <asm/arch/periph.h> #include <dm/pinctrl.h> +#include <dm/root.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -252,6 +253,12 @@ static struct pinctrl_ops rk3036_pinctrl_ops = { .get_periph_id = rk3036_pinctrl_get_periph_id, };
+static int rk3036_pinctrl_bind(struct udevice *dev) +{ + /* scan child GPIO banks */ + return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false); +} + static int rk3036_pinctrl_probe(struct udevice *dev) { struct rk3036_pinctrl_priv *priv = dev_get_priv(dev); @@ -272,5 +279,6 @@ U_BOOT_DRIVER(pinctrl_rk3036) = { .of_match = rk3036_pinctrl_ids, .priv_auto_alloc_size = sizeof(struct rk3036_pinctrl_priv), .ops = &rk3036_pinctrl_ops, + .bind = rk3036_pinctrl_bind, .probe = rk3036_pinctrl_probe, };

On 13 January 2016 at 19:19, Jeffy Chen jeffy.chen@rock-chips.com wrote:
Call dm_scan_fdt_node() in rk3036 pinctrl uclass binding.
Signed-off-by: Jeffy Chen jeffy.chen@rock-chips.com Acked-by: Simon Glass sjg@chromium.org Reviewed-by: Tom Rini trini@konsulko.com
Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None
drivers/pinctrl/rockchip/pinctrl_rk3036.c | 8 ++++++++ 1 file changed, 8 insertions(+)
Applied to u-boot-rockchip, thanks!

Add default android gpt partition table for kylin board.
Use "gpt write mmc 0 $partitions" to apply.
Signed-off-by: Jeffy Chen jeffy.chen@rock-chips.com Acked-by: Simon Glass sjg@chromium.org Reviewed-by: Tom Rini trini@konsulko.com ---
Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None
include/configs/kylin_rk3036.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
diff --git a/include/configs/kylin_rk3036.h b/include/configs/kylin_rk3036.h index aa07889..b750b26 100644 --- a/include/configs/kylin_rk3036.h +++ b/include/configs/kylin_rk3036.h @@ -9,4 +9,33 @@
#include <configs/rk3036_common.h>
+#ifndef CONFIG_SPL_BUILD + +/* Enable gpt partition table */ +#define CONFIG_CMD_GPT +#define CONFIG_RANDOM_UUID +#define CONFIG_EFI_PARTITION +#define PARTS_DEFAULT \ + "uuid_disk=${uuid_gpt_disk};" \ + "name=loader,start=32K,size=4000K,uuid=${uuid_gpt_loader};" \ + "name=reserved,size=64K,uuid=${uuid_gpt_reserved};" \ + "name=misc,size=4M,uuid=${uuid_gpt_misc};" \ + "name=recovery,size=32M,uuid=${uuid_gpt_recovery};" \ + "name=boot_a,size=32M,uuid=${uuid_gpt_boot_a};" \ + "name=boot_b,size=32M,uuid=${uuid_gpt_boot_b};" \ + "name=system_a,size=818M,uuid=${uuid_gpt_system_a};" \ + "name=system_b,size=818M,uuid=${uuid_gpt_system_b};" \ + "name=vendor_a,size=50M,uuid=${uuid_gpt_vendor_a};" \ + "name=vendor_b,size=50M,uuid=${uuid_gpt_vendor_b};" \ + "name=cache,size=100M,uuid=${uuid_gpt_cache};" \ + "name=metadata,size=16M,uuid=${uuid_gpt_metadata};" \ + "name=persist,size=4M,uuid=${uuid_gpt_persist};" \ + "name=userdata,size=-,uuid=${uuid_gpt_userdata};\0" \ + +#undef CONFIG_EXTRA_ENV_SETTINGS +#define CONFIG_EXTRA_ENV_SETTINGS \ + "partitions=" PARTS_DEFAULT \ + +#endif + #endif

On 13 January 2016 at 19:19, Jeffy Chen jeffy.chen@rock-chips.com wrote:
Add default android gpt partition table for kylin board.
Use "gpt write mmc 0 $partitions" to apply.
Signed-off-by: Jeffy Chen jeffy.chen@rock-chips.com Acked-by: Simon Glass sjg@chromium.org Reviewed-by: Tom Rini trini@konsulko.com
Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None
include/configs/kylin_rk3036.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
Applied to u-boot-rockchip, thanks!

The android kernel is using appended dtb by default, and store ramdisk right after kernel & dtb.
The u-boot could not touch appended dtb, so we needs to pass params to kernel through atags. And also enable kernel's CONFIG_ARM_ATAG_DTB_COMPAT, which would allowed kernel to merge atags into fdt before decompress itself.
And we needs to relocate ramdisk, in case of been overwritten by the new fdt.
We also split up bootm cmd to get BOOTM_STATE_RAMDISK, which is not enabled in the default flow.
Signed-off-by: Jeffy Chen jeffy.chen@rock-chips.com
---
Changes in v5: Remove dup CONFIG_SYS_BOOT_RAMDISK_HIGH. Change commit message.
Changes in v4: None Changes in v3: None Changes in v2: None
include/configs/kylin_rk3036.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
diff --git a/include/configs/kylin_rk3036.h b/include/configs/kylin_rk3036.h index b750b26..48317f9 100644 --- a/include/configs/kylin_rk3036.h +++ b/include/configs/kylin_rk3036.h @@ -35,6 +35,28 @@ #undef CONFIG_EXTRA_ENV_SETTINGS #define CONFIG_EXTRA_ENV_SETTINGS \ "partitions=" PARTS_DEFAULT \ + "mmcdev=0\0" \ + "mmcpart=5\0" \ + "loadaddr=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \ + +#define CONFIG_ANDROID_BOOT_IMAGE +#define CONFIG_SYS_HUSH_PARSER + +#undef CONFIG_BOOTCOMMAND +#define CONFIG_BOOTCOMMAND \ + "mmc dev ${mmcdev}; if mmc rescan; then " \ + "part start mmc ${mmcdev} ${mmcpart} boot_start;" \ + "part size mmc ${mmcdev} ${mmcpart} boot_size;" \ + "mmc read ${loadaddr} ${boot_start} ${boot_size};" \ + "bootm start ${loadaddr}; bootm ramdisk;" \ + "bootm prep; bootm go;" \ + "fi;" \ + +/* Enable atags */ +#define CONFIG_SYS_BOOTPARAMS_LEN (64*1024) +#define CONFIG_INITRD_TAG +#define CONFIG_SETUP_MEMORY_TAGS +#define CONFIG_CMDLINE_TAG
#endif

We will save boot mode flag in grf's os_reg[4], if fastboot requested or fastboot key pressed, try to enter fastboot mode at preboot stage.
Signed-off-by: Jeffy Chen jeffy.chen@rock-chips.com
---
Changes in v5: Change "grf" to local var.
Changes in v4: Remove unused reboot mode definitions.
Changes in v3: Use rockchip's legacy reboot mode definitions.
Changes in v2: None
board/kylin/kylin_rk3036/kylin_rk3036.c | 32 ++++++++++++++++++++++++++++++++ include/configs/kylin_rk3036.h | 3 +++ 2 files changed, 35 insertions(+)
diff --git a/board/kylin/kylin_rk3036/kylin_rk3036.c b/board/kylin/kylin_rk3036/kylin_rk3036.c index 40d6b52..2a25871 100644 --- a/board/kylin/kylin_rk3036/kylin_rk3036.c +++ b/board/kylin/kylin_rk3036/kylin_rk3036.c @@ -8,10 +8,14 @@ #include <dm.h> #include <asm/io.h> #include <asm/arch/uart.h> +#include <asm/arch-rockchip/grf_rk3036.h> #include <asm/arch/sdram_rk3036.h> +#include <asm/gpio.h>
DECLARE_GLOBAL_DATA_PTR;
+#define GRF_BASE 0x20008000 + void get_ddr_config(struct rk3036_ddr_config *config) { /* K4B4G1646Q config */ @@ -28,6 +32,34 @@ void get_ddr_config(struct rk3036_ddr_config *config) config->bw = 1; }
+#define FASTBOOT_KEY_GPIO 93 + +int fastboot_key_pressed(void) +{ + gpio_request(FASTBOOT_KEY_GPIO, "fastboot_key"); + gpio_direction_input(FASTBOOT_KEY_GPIO); + return !gpio_get_value(FASTBOOT_KEY_GPIO); +} + +#define ROCKCHIP_BOOT_MODE_FASTBOOT 0x5242C309 + +int board_late_init(void) +{ + struct rk3036_grf * const grf = (void *)GRF_BASE; + int boot_mode = readl(&grf->os_reg[4]); + + /* Clear boot mode */ + writel(0, &grf->os_reg[4]); + + if (boot_mode == ROCKCHIP_BOOT_MODE_FASTBOOT || + fastboot_key_pressed()) { + printf("enter fastboot!\n"); + setenv("preboot", "setenv preboot; fastboot usb0"); + } + + return 0; +} + int board_init(void) { return 0; diff --git a/include/configs/kylin_rk3036.h b/include/configs/kylin_rk3036.h index 48317f9..3fe43eb 100644 --- a/include/configs/kylin_rk3036.h +++ b/include/configs/kylin_rk3036.h @@ -39,6 +39,9 @@ "mmcpart=5\0" \ "loadaddr=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \
+#define CONFIG_BOARD_LATE_INIT +#define CONFIG_PREBOOT + #define CONFIG_ANDROID_BOOT_IMAGE #define CONFIG_SYS_HUSH_PARSER

On 13 January 2016 at 19:19, Jeffy Chen jeffy.chen@rock-chips.com wrote:
We will save boot mode flag in grf's os_reg[4], if fastboot requested or fastboot key pressed, try to enter fastboot mode at preboot stage.
Signed-off-by: Jeffy Chen jeffy.chen@rock-chips.com
Changes in v5: Change "grf" to local var.
Changes in v4: Remove unused reboot mode definitions.
Changes in v3: Use rockchip's legacy reboot mode definitions.
Changes in v2: None
board/kylin/kylin_rk3036/kylin_rk3036.c | 32 ++++++++++++++++++++++++++++++++ include/configs/kylin_rk3036.h | 3 +++ 2 files changed, 35 insertions(+)
Acked-by: Simon Glass sjg@chromium.org

On 14 January 2016 at 10:17, Simon Glass sjg@chromium.org wrote:
On 13 January 2016 at 19:19, Jeffy Chen jeffy.chen@rock-chips.com wrote:
We will save boot mode flag in grf's os_reg[4], if fastboot requested or fastboot key pressed, try to enter fastboot mode at preboot stage.
Signed-off-by: Jeffy Chen jeffy.chen@rock-chips.com
Changes in v5: Change "grf" to local var.
Changes in v4: Remove unused reboot mode definitions.
Changes in v3: Use rockchip's legacy reboot mode definitions.
Changes in v2: None
board/kylin/kylin_rk3036/kylin_rk3036.c | 32 ++++++++++++++++++++++++++++++++ include/configs/kylin_rk3036.h | 3 +++ 2 files changed, 35 insertions(+)
Acked-by: Simon Glass sjg@chromium.org
Applied to u-boot-rockchip, thanks!

There's a 64K reserved area at the end of the first 4M. Store env there, so we can use fastboot to flash it.
Signed-off-by: Jeffy Chen jeffy.chen@rock-chips.com
---
Changes in v5: New patch.
Changes in v4: None Changes in v3: None Changes in v2: None
include/configs/kylin_rk3036.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/include/configs/kylin_rk3036.h b/include/configs/kylin_rk3036.h index 3fe43eb..b56c492 100644 --- a/include/configs/kylin_rk3036.h +++ b/include/configs/kylin_rk3036.h @@ -7,10 +7,22 @@ #ifndef __CONFIG_H #define __CONFIG_H
+#include <linux/sizes.h> #include <configs/rk3036_common.h>
#ifndef CONFIG_SPL_BUILD
+/* Store env in emmc */ +#undef CONFIG_ENV_SIZE +#define CONFIG_ENV_SIZE SZ_32K +#undef CONFIG_ENV_IS_NOWHERE +#define CONFIG_ENV_IS_IN_MMC +#define CONFIG_SYS_MMC_ENV_DEV 0 /* emmc */ +#define CONFIG_SYS_MMC_ENV_PART 0 /* user area */ +#define CONFIG_ENV_OFFSET (SZ_4M - SZ_64K) /* reserved area */ +#define CONFIG_ENV_OFFSET_REDUND (CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE) +#define CONFIG_SYS_REDUNDAND_ENVIRONMENT + /* Enable gpt partition table */ #define CONFIG_CMD_GPT #define CONFIG_RANDOM_UUID

On 13 January 2016 at 19:19, Jeffy Chen jeffy.chen@rock-chips.com wrote:
There's a 64K reserved area at the end of the first 4M. Store env there, so we can use fastboot to flash it.
Signed-off-by: Jeffy Chen jeffy.chen@rock-chips.com
Changes in v5: New patch.
Changes in v4: None Changes in v3: None Changes in v2: None
include/configs/kylin_rk3036.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
Acked-by: Simon Glass sjg@chromium.org

On 14 January 2016 at 10:17, Simon Glass sjg@chromium.org wrote:
On 13 January 2016 at 19:19, Jeffy Chen jeffy.chen@rock-chips.com wrote:
There's a 64K reserved area at the end of the first 4M. Store env there, so we can use fastboot to flash it.
Signed-off-by: Jeffy Chen jeffy.chen@rock-chips.com
Changes in v5: New patch.
Changes in v4: None Changes in v3: None Changes in v2: None
include/configs/kylin_rk3036.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
Acked-by: Simon Glass sjg@chromium.org
Applied to u-boot-rockchip, thanks!
participants (2)
-
Jeffy Chen
-
Simon Glass