diff options
author | Luo Ji <ji.luo@nxp.com> | 2018-09-13 16:08:44 +0800 |
---|---|---|
committer | Luo Ji <ji.luo@nxp.com> | 2018-09-13 16:10:01 +0800 |
commit | 028b25c768eb6676ae6ce87ce6a83d75fe9d8838 (patch) | |
tree | 0a957771ca6887634271a4892c3d604eb83ad700 | |
parent | cf2a6c19c8fe7db54f49712b52175aca160c404f (diff) |
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 <ji.luo@nxp.com>
-rw-r--r-- | common/image-android.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/common/image-android.c b/common/image-android.c index 81eaca8ef4..90fd3ca7f3 100644 --- a/common/image-android.c +++ b/common/image-android.c @@ -17,6 +17,7 @@ #include <asm/arch/sys_proto.h> #include <fsl_fastboot.h> #include <asm/setup.h> +#include <dm.h> #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 |