From: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx> For two-staged loading via USB we traditionally send the PBL twice. The first PBL is loaded to OCRAM and executed. Then the full barebox image including the PBL is sent again and received here. We might change that in the future in imx-usb-loader so that the PBL is sent only once and we only receive the rest of the image here. To prepare that step check if we get a full barebox image or piggydata only. When it's piggydata only move t to the place where it would be if it would have been a full image. Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx> --- arch/arm/mach-imx/atf.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-imx/atf.c b/arch/arm/mach-imx/atf.c index 709620e5df..ad3800519f 100644 --- a/arch/arm/mach-imx/atf.c +++ b/arch/arm/mach-imx/atf.c @@ -76,6 +76,7 @@ void imx8mm_load_and_start_image_via_tfa(void) const u8 *bl31; enum bootsource src; int instance; + void *bl33 = (void *)MX8M_ATF_BL33_BASE_ADDR; imx8mm_get_boot_source(&src, &instance); switch (src) { @@ -83,7 +84,29 @@ void imx8mm_load_and_start_image_via_tfa(void) imx8m_esdhc_load_image(instance, false); break; case BOOTSOURCE_SERIAL: - imx8mm_barebox_load_usb((void *)MX8M_ATF_BL33_BASE_ADDR); + /* + * Traditionally imx-usb-loader sends the PBL twice. The first + * PBL is loaded to OCRAM and executed. Then the full barebox + * image including the PBL is sent again and received here. We + * might change that in the future in imx-usb-loader so that the + * PBL is sent only once and we only receive the rest of the + * image here. To prepare that step we check if we get a full + * barebox image or piggydata only. When it's piggydata only move + * it to the place where it would be if it would have been a + * full image. + */ + imx8mm_barebox_load_usb(bl33); + + if (!strcmp("barebox", bl33 + 0x20)) { + /* Found the barebox marker, so this is a PBL + piggydata */ + pr_debug("received PBL + piggydata\n"); + } else { + /* no barebox marker, so this is piggydata only */ + pr_debug("received piggydata\n"); + memmove(bl33 + barebox_pbl_size, bl33, + barebox_image_size - barebox_pbl_size); + } + break; default: printf("Unhandled bootsource BOOTSOURCE_%d\n", src); @@ -98,8 +121,7 @@ void imx8mm_load_and_start_image_via_tfa(void) * for the piggy data, so we need to ensure that we are running * the same code in DRAM. */ - memcpy((void *)MX8M_ATF_BL33_BASE_ADDR, - __image_start, barebox_pbl_size); + memcpy(bl33, __image_start, barebox_pbl_size); get_builtin_firmware(imx8mm_bl31_bin, &bl31, &bl31_size); -- 2.30.2