From 028b25c768eb6676ae6ce87ce6a83d75fe9d8838 Mon Sep 17 00:00:00 2001 From: Luo Ji Date: Thu, 13 Sep 2018 16:08:44 +0800 Subject: MA-12703 Android: Read bootargs from u-boot dts Load bootargs from the "/chosen/bootargs" dts node and combine it with the bootargs in bootimage header. Change-Id: I68c9b0d53fff1f51c4d91aa513dfd38b5d9650d4 Signed-off-by: Luo Ji --- common/image-android.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/common/image-android.c b/common/image-android.c index 81eaca8ef4d..90fd3ca7f31 100644 --- a/common/image-android.c +++ b/common/image-android.c @@ -17,6 +17,7 @@ #include #include #include +#include #define ANDROID_IMAGE_DEFAULT_KERNEL_ADDR 0x10008000 @@ -77,6 +78,7 @@ int android_image_get_kernel(const struct andr_img_hdr *hdr, int verify, char newbootargs[512] = {0}; char commandline[2048] = {0}; + int offset; char *bootargs = env_get("bootargs"); if (bootargs) { @@ -86,13 +88,24 @@ int android_image_get_kernel(const struct andr_img_hdr *hdr, int verify, } else strncpy(commandline, bootargs, sizeof(commandline) - 1); - } else if (*hdr->cmdline) { - if (strlen(hdr->cmdline) + 1 > sizeof(commandline)) { - printf("cmdline in bootimg is too long!\n"); - return -1; + } else { + offset = fdt_path_offset(gd->fdt_blob, "/chosen"); + if (offset > 0) { + bootargs = (char *)fdt_getprop(gd->fdt_blob, offset, + "bootargs", NULL); + if (bootargs) + sprintf(commandline, "%s ", bootargs); + } + + if (*hdr->cmdline) { + if (strlen(hdr->cmdline) + 1 > + sizeof(commandline) - strlen(commandline)) { + printf("cmdline in bootimg is too long!\n"); + return -1; + } + else + strncat(commandline, hdr->cmdline, sizeof(commandline) - strlen(commandline)); } - else - strncpy(commandline, hdr->cmdline, strlen(commandline) - 1); } #ifdef CONFIG_SERIAL_TAG -- cgit v1.2.3