Commit a89c0efc authored by ji.luo's avatar ji.luo Committed by Jason Liu

Pass bootloader metrics to kernel by kernel cmdline

Pass bootloader metrics (nBLL, nBLE, KD, KL, AVB, ODT, SW)
to kernel by kernel cmdline.

Change-Id: Ibabff6844be86d028548d1ad697d948ef20590f3
Signed-off-by: default avatarji.luo <ji.luo@nxp.com>
parent 36a5dfa4
......@@ -57,6 +57,7 @@ static ulong android_image_get_kernel_addr(const struct andr_img_hdr *hdr)
int android_image_get_kernel(const struct andr_img_hdr *hdr, int verify,
ulong *os_data, ulong *os_len)
{
extern boot_metric metrics;
u32 kernel_addr = android_image_get_kernel_addr(hdr);
/*
......@@ -73,7 +74,7 @@ int android_image_get_kernel(const struct andr_img_hdr *hdr, int verify,
kernel_addr, DIV_ROUND_UP(hdr->kernel_size, 1024));
char newbootargs[512] = {0};
char commandline[1024] = {0};
char commandline[2048] = {0};
char *bootargs = getenv("bootargs");
if (bootargs) {
......@@ -122,6 +123,14 @@ int android_image_get_kernel(const struct andr_img_hdr *hdr, int verify,
strcat(commandline, newbootargs);
}
/* boot metric variables */
metrics.ble_1 = get_timer(0);
sprintf(newbootargs,
" androidboot.boottime=1BLL:%d,1BLE:%d,KL:%d,KD:%d,AVB:%d,ODT:%d,SW:%d",
metrics.bll_1, metrics.ble_1, metrics.kl, metrics.kd, metrics.avb,
metrics.odt, metrics.sw);
strcat(commandline, newbootargs);
#ifdef CONFIG_AVB_SUPPORT
/* secondary cmdline added by avb */
char *bootargs_sec = getenv("bootargs_sec");
......
......@@ -109,6 +109,17 @@ char *fastboot_common_var[FASTBOOT_COMMON_VAR_NUM] = {
"battery-soc-ok"
};
/* Boot metric variables */
boot_metric metrics = {
.bll_1 = 0,
.ble_1 = 0,
.kl = 0,
.kd = 0,
.avb = 0,
.odt = 0,
.sw = 0
};
#ifdef CONFIG_USB_GADGET
struct f_fastboot {
struct usb_function usb_function;
......@@ -1506,6 +1517,7 @@ int do_boota(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) {
struct andr_img_hdr *hdr = NULL;
struct andr_img_hdr *hdrload;
ulong image_size;
u32 avb_metric;
AvbABFlowResult avb_result;
AvbSlotVerifyData *avb_out_data;
......@@ -1520,8 +1532,12 @@ int do_boota(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) {
lock_status = FASTBOOT_LOCK;
}
bool allow_fail = (lock_status == FASTBOOT_UNLOCK ? true : false);
avb_metric = get_timer(0);
/* if in lock state, do avb verify */
avb_result = avb_ab_flow(&fsl_avb_ab_ops, requested_partitions, allow_fail, &avb_out_data);
/* get the duration of avb */
metrics.avb = get_timer(avb_metric);
if (avb_result == AVB_AB_FLOW_RESULT_OK) {
assert(avb_out_data != NULL);
/* load the first partition */
......
......@@ -17,6 +17,19 @@
#define ANDR_BOOT_NAME_SIZE 16
#define ANDR_BOOT_ARGS_SIZE 512
/* Boot metric variables (in millisecond) */
struct boot_metric
{
u32 bll_1; /* 1th bootloader load duration */
u32 ble_1; /* 1th bootloader exec duration */
u32 kl; /* kernel image load duration */
u32 kd; /* kernel image decompress duration */
u32 avb; /* avb verify boot.img duration */
u32 odt; /* overlay device tree duration */
u32 sw; /* system wait for UI interaction duration*/
};
typedef struct boot_metric boot_metric;
struct andr_img_hdr {
char magic[ANDR_BOOT_MAGIC_SIZE];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment