From: Alex Deymo <deymo@google.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/6] cmd: Add 'load_android' command to load Android images.
Date: Sun, 2 Apr 2017 01:49:49 -0700 [thread overview]
Message-ID: <20170402084952.5102-4-deymo@google.com> (raw)
In-Reply-To: <20170402084952.5102-3-deymo@google.com>
Android kernel images include a header that specifies addresses and
kernel size. This patch adds a command to load these images from
storage without specifying the size or address of them, and parsing
them from the header instead.
---
cmd/Kconfig | 9 +++++++++
cmd/Makefile | 1 +
cmd/load_android.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 66 insertions(+)
create mode 100644 cmd/load_android.c
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 25e3b783a8..87a445d269 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -422,6 +422,15 @@ config CMD_LOADS
help
Load an S-Record file over serial line
+config CMD_LOAD_ANDROID
+ bool "load_android"
+ default n
+ depends on ANDROID_BOOT_IMAGE
+ help
+ Load an Android Boot image from storage. The Android Boot images
+ define the size and kernel address on the header, which are used by
+ this command.
+
config CMD_FLASH
bool "flinfo, erase, protect"
default y
diff --git a/cmd/Makefile b/cmd/Makefile
index f13bb8c11e..2f75dab040 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -82,6 +82,7 @@ obj-$(CONFIG_CMD_LDRINFO) += ldrinfo.o
obj-$(CONFIG_LED_STATUS_CMD) += led.o
obj-$(CONFIG_CMD_LICENSE) += license.o
obj-y += load.o
+obj-$(CONFIG_CMD_LOAD_ANDROID) += load_android.o
obj-$(CONFIG_LOGBUFFER) += log.o
obj-$(CONFIG_ID_EEPROM) += mac.o
obj-$(CONFIG_CMD_MD5SUM) += md5sum.o
diff --git a/cmd/load_android.c b/cmd/load_android.c
new file mode 100644
index 0000000000..b9f3b1b372
--- /dev/null
+++ b/cmd/load_android.c
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <common.h>
+#include <command.h>
+
+static int do_load_android(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
+{
+ int boot_partition;
+ unsigned long load_address;
+ char *addr_arg_endp, *addr_str;
+ struct blk_desc *dev_desc;
+ disk_partition_t part_info;
+
+ if (argc < 2)
+ return CMD_RET_USAGE;
+ if (argc > 4)
+ return CMD_RET_USAGE;
+
+ if (argc >= 4) {
+ load_address = simple_strtoul(argv[3], &addr_arg_endp, 16);
+ if (addr_arg_endp == argv[3] || *addr_arg_endp != '\0')
+ return CMD_RET_USAGE;
+ } else {
+ addr_str = getenv("loadaddr");
+ if (addr_str != NULL)
+ load_address = simple_strtoul(addr_str, NULL, 16);
+ else
+ load_address = CONFIG_SYS_LOAD_ADDR;
+ }
+
+ boot_partition = blk_get_device_part_str(argv[1],
+ (argc >= 3) ? argv[2] : NULL,
+ &dev_desc, &part_info, 1);
+ if (boot_partition < 0)
+ return CMD_RET_FAILURE;
+
+ if (android_image_load(dev_desc, &part_info, load_address, -1UL) < 0) {
+ printf("Error loading Android Image from %s %d:%d to 0x%lx.\n",
+ argv[1], dev_desc->devnum, boot_partition, load_address);
+ return CMD_RET_FAILURE;
+ }
+ return CMD_RET_SUCCESS;
+}
+
+U_BOOT_CMD(
+ load_android, 4, 0, do_load_android,
+ "load Android Boot image from storage.",
+ "<interface> [<dev[:part]> [<addr>]]\n"
+ " - Load a binary Android Boot image from the partition 'part' on\n"
+ " device type 'interface' instance 'dev' to address 'addr'."
+);
--
2.12.2.564.g063fe858b8-goog
next prev parent reply other threads:[~2017-04-02 8:49 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <a74b3d5e65b4bf5c2edca98bba9e678be762ebe7>
2017-04-02 8:49 ` [U-Boot] [PATCH 0/6] Android A/B Bootloader support Alex Deymo
2017-04-02 8:49 ` [U-Boot] [PATCH 1/6] image: Update include/android_image.h Alex Deymo
2017-04-02 8:49 ` [U-Boot] [PATCH 2/6] image: Implement a function to load Android Images Alex Deymo
2017-04-02 8:49 ` Alex Deymo [this message]
2017-04-02 8:49 ` [U-Boot] [PATCH 4/6] disk: Return the partition number in part_get_info_by_name() Alex Deymo
2017-04-02 8:49 ` [U-Boot] [PATCH 5/6] Initial support for the Android Bootloader flow Alex Deymo
2017-04-02 8:49 ` [U-Boot] [PATCH 6/6] cmd: Add "boot_android" command Alex Deymo
2017-04-04 14:46 ` Lukasz Majewski
2017-04-09 19:27 ` [U-Boot] [PATCH 5/6] Initial support for the Android Bootloader flow Simon Glass
2017-04-06 22:42 ` [U-Boot] [PATCH 4/6] disk: Return the partition number in part_get_info_by_name() Simon Glass
2017-05-12 17:18 ` [U-Boot] [U-Boot, " Tom Rini
2017-04-06 22:42 ` [U-Boot] [PATCH 3/6] cmd: Add 'load_android' command to load Android images Simon Glass
2017-04-06 22:42 ` [U-Boot] [PATCH 2/6] image: Implement a function to load Android Images Simon Glass
2017-04-06 22:42 ` [U-Boot] [PATCH 1/6] image: Update include/android_image.h Simon Glass
2017-05-12 17:18 ` [U-Boot] [U-Boot,1/6] " Tom Rini
2017-04-19 8:42 ` [U-Boot] [PATCH 0/6] Android A/B Bootloader support Kever Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170402084952.5102-4-deymo@google.com \
--to=deymo@google.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.