rockchip: board: implement board_do_bootm()
Implement it to support CLI command:
- Android: bootm [aosp addr]
- FIT: bootm [fit addr]
- uImage: bootm [uimage addr]
Purpose:
- The original bootm command args require fdt addr on AOSP,
which is not flexible on rockchip boot/recovery.img.
- Take Android/FIT/uImage image into sysmem management to avoid image
memory overlap.
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I4ef3f1b0307f2e061105ee29307051202445c9e9
This commit is contained in:
parent
7460c07a1d
commit
ac5d8aa9aa
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
#include <common.h>
|
||||
#include <amp.h>
|
||||
#include <android_bootloader.h>
|
||||
#include <android_image.h>
|
||||
#include <bidram.h>
|
||||
#include <boot_rkimg.h>
|
||||
#include <cli.h>
|
||||
|
|
@ -665,3 +667,90 @@ int bootm_board_start(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Implement it to support CLI command:
|
||||
* - Android: bootm [aosp addr]
|
||||
* - FIT: bootm [fit addr]
|
||||
* - uImage: bootm [uimage addr]
|
||||
*
|
||||
* Purpose:
|
||||
* - The original bootm command args require fdt addr on AOSP,
|
||||
* which is not flexible on rockchip boot/recovery.img.
|
||||
* - Take Android/FIT/uImage image into sysmem management to avoid image
|
||||
* memory overlap.
|
||||
*/
|
||||
#if defined(CONFIG_ANDROID_BOOTLOADER) || \
|
||||
defined(CONFIG_ROCKCHIP_FIT_IMAGE) || \
|
||||
defined(CONFIG_ROCKCHIP_UIMAGE)
|
||||
int board_do_bootm(int argc, char * const argv[])
|
||||
{
|
||||
int format;
|
||||
void *img;
|
||||
|
||||
if (argc != 2)
|
||||
return 0;
|
||||
|
||||
img = (void *)simple_strtoul(argv[1], NULL, 16);
|
||||
format = (genimg_get_format(img));
|
||||
|
||||
/* Android */
|
||||
#ifdef CONFIG_ANDROID_BOOT_IMAGE
|
||||
if (format == IMAGE_FORMAT_ANDROID) {
|
||||
struct andr_img_hdr *hdr;
|
||||
ulong load_addr;
|
||||
ulong size;
|
||||
int ret;
|
||||
|
||||
hdr = (struct andr_img_hdr *)img;
|
||||
printf("BOOTM: transferring to board Android\n");
|
||||
|
||||
#ifdef CONFIG_USING_KERNEL_DTB
|
||||
sysmem_free((phys_addr_t)gd->fdt_blob);
|
||||
/* erase magic */
|
||||
fdt_set_magic((void *)gd->fdt_blob, ~0);
|
||||
gd->fdt_blob = NULL;
|
||||
#endif
|
||||
load_addr = env_get_ulong("kernel_addr_r", 16, 0);
|
||||
load_addr -= hdr->page_size;
|
||||
size = android_image_get_end(hdr) - (ulong)hdr;
|
||||
|
||||
if (!sysmem_alloc_base(MEM_ANDROID, (ulong)hdr, size))
|
||||
return -ENOMEM;
|
||||
|
||||
ret = android_image_memcpy_separate(hdr, &load_addr);
|
||||
if (ret) {
|
||||
printf("board do bootm failed, ret=%d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return android_bootloader_boot_kernel(load_addr);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* FIT */
|
||||
#if IMAGE_ENABLE_FIT
|
||||
if (format == IMAGE_FORMAT_FIT) {
|
||||
char boot_cmd[64];
|
||||
|
||||
printf("BOOTM: transferring to board FIT\n");
|
||||
snprintf(boot_cmd, sizeof(boot_cmd), "boot_fit %s", argv[1]);
|
||||
return run_command(boot_cmd, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* uImage */
|
||||
#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
|
||||
if (format == IMAGE_FORMAT_LEGACY &&
|
||||
image_get_type(img) == IH_TYPE_MULTI) {
|
||||
char boot_cmd[64];
|
||||
|
||||
printf("BOOTM: transferring to board uImage\n");
|
||||
snprintf(boot_cmd, sizeof(boot_cmd), "boot_uimage %s", argv[1]);
|
||||
return run_command(boot_cmd, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue