From: Rouven Czerwinski <r.czerwinski@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Rouven Czerwinski <r.czerwinski@pengutronix.de>
Subject: [PATCH 05/13] esdhc-pbl: add piggy load function
Date: Wed, 26 Jun 2019 06:58:46 +0200 [thread overview]
Message-ID: <a91917e722a601f835984958b8b1344806eede84.1561525118.git-series.r.czerwinski@pengutronix.de> (raw)
In-Reply-To: <cover.a507585555be94a0fb8946fdfd851a30ab8b296f.1561525118.git-series.r.czerwinski@pengutronix.de>
Add a function to load and copy the piggy data to the correct offset
expected by barebox in the RAM. This way the PBL can later verify the
piggydata before uncompressing and loading the main barebox.
Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
---
arch/arm/mach-imx/include/mach/xload.h | 5 +++-
arch/arm/mach-imx/xload-common.c | 6 ++++-
drivers/mci/imx-esdhc-pbl.c | 46 +++++++++++++++++++++++++++-
3 files changed, 57 insertions(+)
diff --git a/arch/arm/mach-imx/include/mach/xload.h b/arch/arm/mach-imx/include/mach/xload.h
index 8f141bc..a605e76 100644
--- a/arch/arm/mach-imx/include/mach/xload.h
+++ b/arch/arm/mach-imx/include/mach/xload.h
@@ -6,7 +6,12 @@ int imx6_spi_load_image(int instance, unsigned int flash_offset, void *buf, int
int imx6_spi_start_image(int instance);
int imx6_esdhc_start_image(int instance);
int imx8_esdhc_start_image(int instance);
+int imx8_esdhc_load_piggy(int instance);
int imx_image_size(void);
+int piggydata_size(void);
+
+extern unsigned char input_data[];
+extern unsigned char input_data_end[];
#endif /* __MACH_XLOAD_H */
diff --git a/arch/arm/mach-imx/xload-common.c b/arch/arm/mach-imx/xload-common.c
index c5727eb..bd64052 100644
--- a/arch/arm/mach-imx/xload-common.c
+++ b/arch/arm/mach-imx/xload-common.c
@@ -8,3 +8,9 @@ int imx_image_size(void)
/* i.MX header is 4k */
return barebox_image_size + SZ_4K;
}
+
+int piggydata_size(void)
+{
+ return input_data_end - input_data;
+}
+
diff --git a/drivers/mci/imx-esdhc-pbl.c b/drivers/mci/imx-esdhc-pbl.c
index 35faf6d..75593e8 100644
--- a/drivers/mci/imx-esdhc-pbl.c
+++ b/drivers/mci/imx-esdhc-pbl.c
@@ -423,6 +423,52 @@ int imx8_esdhc_start_image(int instance)
return esdhc_start_image(&esdhc, MX8MQ_DDR_CSD1_BASE_ADDR,
MX8MQ_ATF_BL33_BASE_ADDR, SZ_32K);
}
+
+int imx8_esdhc_load_piggy(int instance)
+{
+ void *buf = (void *)MX8MQ_ATF_BL33_BASE_ADDR;
+ struct imx_flash_header_v2 *hdr = NULL;
+ void *bb = 0;
+ struct esdhc esdhc;
+ int ret, len;
+ int offset = SZ_32K;
+
+
+ switch (instance) {
+ case 0:
+ esdhc.regs = IOMEM(MX8MQ_USDHC1_BASE_ADDR);
+ break;
+ case 1:
+ esdhc.regs = IOMEM(MX8MQ_USDHC2_BASE_ADDR);
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ esdhc.is_be = 0;
+ esdhc.is_mx6 = 1;
+
+ ret = esdhc_search_header(&esdhc, &hdr, buf, &offset);
+ if (ret)
+ return ret;
+
+ len = offset + hdr->boot_data.size + piggydata_size();
+ len = ALIGN(len, SECTOR_SIZE);
+
+ ret = esdhc_read_blocks(&esdhc, buf, len);
+
+ /*
+ * Calculate location of the piggydata at the offset loaded into RAM
+ */
+ buf = buf + offset + hdr->boot_data.size;
+ /*
+ * Barebox expects the piggydata right behind the PBL in the beginning
+ * of RAM.
+ */
+ bb = (void *) MX8MQ_DDR_CSD1_BASE_ADDR + barebox_pbl_size;
+ memcpy(bb, buf, piggydata_size());
+ return ret;
+}
#endif
#ifdef CONFIG_ARCH_LS1046
--
git-series 0.9.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2019-06-26 4:59 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-26 4:58 [PATCH 00/13] HAB for i.MX8MQ Rouven Czerwinski
2019-06-26 4:58 ` [PATCH 01/13] hab: implement interface " Rouven Czerwinski
2019-06-26 7:31 ` Sascha Hauer
2019-06-26 10:26 ` Roland Hieber
2019-06-26 4:58 ` [PATCH 02/13] mach-imx: enable HAB on i.MX8MQ Rouven Czerwinski
2019-06-26 4:58 ` [PATCH 03/13] arm: lib: add CSF section between PBL and piggy Rouven Czerwinski
2019-06-26 4:58 ` [PATCH 04/13] esdhc-pbl: extract header parsing from image start Rouven Czerwinski
2019-06-26 4:58 ` Rouven Czerwinski [this message]
2019-06-26 4:58 ` [PATCH 06/13] sections: fix macro for barebox_pbl_size Rouven Czerwinski
2019-06-26 4:58 ` [PATCH 07/13] scripts: imx: support signing for i.MX8MQ Rouven Czerwinski
2019-06-26 7:51 ` Sascha Hauer
2019-07-02 5:47 ` Rouven Czerwinski
2019-06-26 4:58 ` [PATCH 08/13] images: always build sha256sum into pbl Rouven Czerwinski
2019-06-26 4:58 ` [PATCH 09/13] pbl: add sha256 and piggy verification to PBL Rouven Czerwinski
2019-06-26 4:58 ` [PATCH 10/13] arm: uncompress: verify sha256 if enabled Rouven Czerwinski
2019-06-26 7:52 ` Sascha Hauer
2019-07-01 6:19 ` Rouven Czerwinski
2019-07-01 6:45 ` Sascha Hauer
2019-06-26 4:58 ` [PATCH 11/13] mach-imx: add gencsf header for i.MX8MQ Rouven Czerwinski
2019-06-26 4:58 ` [PATCH 12/13] mach-imx: hab: select piggy verification for i.MX8 Rouven Czerwinski
2019-06-26 4:58 ` [PATCH 13/13] boards: nxp-mx8-evk: rework to different boot flow Rouven Czerwinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a91917e722a601f835984958b8b1344806eede84.1561525118.git-series.r.czerwinski@pengutronix.de \
--to=r.czerwinski@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox