* [PATCH v2 1/3] ARM: i.MX8MP: bbu: fix wrong flash header offset for eMMC boot partition
@ 2021-08-30 11:51 Ahmad Fatoum
2021-08-30 11:51 ` [PATCH v2 2/3] mci: imx-esdhc-pbl: support eMMC boot partitions on i.MX8MP Ahmad Fatoum
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Ahmad Fatoum @ 2021-08-30 11:51 UTC (permalink / raw)
To: barebox; +Cc: lst, ukl, rcz, Ahmad Fatoum
According to the reference manual of the i.MX8MP, the bootrom expects
the bootloader to sit directly at the start of the eMMC boot partition.
The 32K offset is only valid for eMMC user partitions and SD.
Tell barebox_update about this, so it can strip away the first 32K
when writing to an eMMC boot partition.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
v1 -> v2:
- fix wrong use of flash header offset: This refers to offset in file,
but we want to change offset on disk. There is a knob for that
(IMX_BBU_FLAG_PARTITION_STARTS_AT_HEADER), so use that instead
Tested on i.MX8MN.
---
arch/arm/mach-imx/imx-bbu-internal.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index 880f8b249642..91e1785d18e0 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -393,6 +393,18 @@ static unsigned long imx_bbu_flash_header_offset_mmc(void)
return SZ_1K;
}
+static unsigned long imx_bbu_flash_header_offset_mmcboot(unsigned long *flags)
+{
+ /*
+ * i.MX8MP places IVT directly at start of eMMC boot partition. IVT
+ * in eMMC user partition and SD is at 32K offset.
+ */
+ if (cpu_is_mx8mp())
+ *flags |= IMX_BBU_FLAG_PARTITION_STARTS_AT_HEADER;
+
+ return imx_bbu_flash_header_offset_mmc();
+}
+
static int imx_bbu_update(struct bbu_handler *handler, struct bbu_data *data)
{
struct imx_internal_bbu_handler *imx_handler =
@@ -606,9 +618,12 @@ static int imx_bbu_internal_mmcboot_register_handler(const char *name,
unsigned long flags)
{
struct imx_internal_bbu_handler *imx_handler;
+ unsigned long flash_header_offset;
+
+ flash_header_offset = imx_bbu_flash_header_offset_mmcboot(&flags);
imx_handler = __init_handler(name, devicefile, flags);
- imx_handler->flash_header_offset = imx_bbu_flash_header_offset_mmc();
+ imx_handler->flash_header_offset = flash_header_offset;
imx_handler->handler.handler = imx_bbu_internal_mmcboot_update;
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 2/3] mci: imx-esdhc-pbl: support eMMC boot partitions on i.MX8MP
2021-08-30 11:51 [PATCH v2 1/3] ARM: i.MX8MP: bbu: fix wrong flash header offset for eMMC boot partition Ahmad Fatoum
@ 2021-08-30 11:51 ` Ahmad Fatoum
2021-10-04 10:56 ` Sascha Hauer
2021-08-30 11:51 ` [PATCH v2 3/3] ARM: i.MX8MP: EVK: change bbu handler from eMMC user to boot partition Ahmad Fatoum
2021-08-31 9:42 ` [PATCH v2 1/3] ARM: i.MX8MP: bbu: fix wrong flash header offset for eMMC " Rouven Czerwinski
2 siblings, 1 reply; 7+ messages in thread
From: Ahmad Fatoum @ 2021-08-30 11:51 UTC (permalink / raw)
To: barebox; +Cc: lst, ukl, rcz, Ahmad Fatoum
The i.MX header for SD/MMC starts at an offset to allow for a partition
table at offset 0. i.MX8MN/P bootrom did away with the offset for eMMC
boot partitions, which usually lack on-disk partition tables, but kept a
32-byte offset for SD and eMMC user partitions.
The i.MX8MN/P also introduced a ROM API that allows chainloading from
boot medium by calling back into ROM. This likely handles that
difference for us, but as we don't support it yet and we already have
the PBL eSDHC driver, teach it to detect whether boot is from eMMC boot
partition or not and use the appropriate offset.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
v1 -> v2:
- new patch. Without, barebox can be written, but not booted.
Tested on i.MX8MN.
---
drivers/mci/imx-esdhc-pbl.c | 39 ++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
diff --git a/drivers/mci/imx-esdhc-pbl.c b/drivers/mci/imx-esdhc-pbl.c
index e649eb8bbafb..66df4f6dfc74 100644
--- a/drivers/mci/imx-esdhc-pbl.c
+++ b/drivers/mci/imx-esdhc-pbl.c
@@ -25,6 +25,40 @@
#define esdhc_send_cmd __esdhc_send_cmd
+static u8 ext_csd[512] __aligned(64);
+
+static int esdhc_send_ext_csd(struct fsl_esdhc_host *host)
+{
+ struct mci_cmd cmd;
+ struct mci_data data;
+
+ cmd.cmdidx = MMC_CMD_SEND_EXT_CSD;
+ cmd.cmdarg = 0;
+ cmd.resp_type = MMC_RSP_R1;
+
+ data.dest = ext_csd;
+ data.blocks = 1;
+ data.blocksize = sizeof(ext_csd);
+ data.flags = MMC_DATA_READ;
+
+ return esdhc_send_cmd(host, &cmd, &data);
+}
+
+static bool esdhc_bootpart_active(struct fsl_esdhc_host *host)
+{
+ unsigned bootpart;
+
+ int ret = esdhc_send_ext_csd(host);
+ if (ret)
+ return false;
+
+ bootpart = (ext_csd[EXT_CSD_PARTITION_CONFIG] >> 3) & 0x7;
+ if (bootpart == 1 || bootpart == 2)
+ return true;
+
+ return false;
+}
+
static int esdhc_read_blocks(struct fsl_esdhc_host *host, void *dst, size_t len)
{
struct mci_cmd cmd;
@@ -338,14 +372,17 @@ int imx8mp_esdhc_load_image(int instance, bool start)
{
struct esdhc_soc_data data;
struct fsl_esdhc_host host = { 0 };
+ u32 offset;
int ret;
ret = imx8m_esdhc_init(&host, &data, instance);
if (ret)
return ret;
+ offset = esdhc_bootpart_active(&host)? 0 : SZ_32K;
+
return esdhc_load_image(&host, MX8M_DDR_CSD1_BASE_ADDR,
- MX8MQ_ATF_BL33_BASE_ADDR, SZ_32K, 0, start);
+ MX8MQ_ATF_BL33_BASE_ADDR, offset, 0, start);
}
#endif
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 3/3] ARM: i.MX8MP: EVK: change bbu handler from eMMC user to boot partition
2021-08-30 11:51 [PATCH v2 1/3] ARM: i.MX8MP: bbu: fix wrong flash header offset for eMMC boot partition Ahmad Fatoum
2021-08-30 11:51 ` [PATCH v2 2/3] mci: imx-esdhc-pbl: support eMMC boot partitions on i.MX8MP Ahmad Fatoum
@ 2021-08-30 11:51 ` Ahmad Fatoum
2021-08-31 9:42 ` [PATCH v2 1/3] ARM: i.MX8MP: bbu: fix wrong flash header offset for eMMC " Rouven Czerwinski
2 siblings, 0 replies; 7+ messages in thread
From: Ahmad Fatoum @ 2021-08-30 11:51 UTC (permalink / raw)
To: barebox; +Cc: lst, ukl, rcz, Ahmad Fatoum
With recent changes, it's now possible to update and start barebox from
an eMMC boot partition on the i.MX8MP. Reflect this in the board code, so
future barebox updates on eMMC will automatically leverage this.
Tested on an i.MX8MN, which has the same flash header offsets as the 8MP.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
v1 -> v2:
- new patch. Tested on i.MX8MN.
---
arch/arm/boards/nxp-imx8mp-evk/board.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/boards/nxp-imx8mp-evk/board.c b/arch/arm/boards/nxp-imx8mp-evk/board.c
index a3ff59810888..8f1c2471091e 100644
--- a/arch/arm/boards/nxp-imx8mp-evk/board.c
+++ b/arch/arm/boards/nxp-imx8mp-evk/board.c
@@ -37,7 +37,7 @@ static int nxp_imx8mp_evk_init(void)
}
imx8m_bbu_internal_mmc_register_handler("SD", "/dev/mmc1.barebox", sd_bbu_flag);
- imx8m_bbu_internal_mmc_register_handler("eMMC", "/dev/mmc2", emmc_bbu_flag);
+ imx8m_bbu_internal_mmcboot_register_handler("eMMC", "/dev/mmc2", emmc_bbu_flag);
val = readl(MX8MP_IOMUXC_GPR_BASE_ADDR + MX8MP_IOMUXC_GPR1);
val |= MX8MP_IOMUXC_GPR1_ENET1_RGMII_EN;
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/3] ARM: i.MX8MP: bbu: fix wrong flash header offset for eMMC boot partition
2021-08-30 11:51 [PATCH v2 1/3] ARM: i.MX8MP: bbu: fix wrong flash header offset for eMMC boot partition Ahmad Fatoum
2021-08-30 11:51 ` [PATCH v2 2/3] mci: imx-esdhc-pbl: support eMMC boot partitions on i.MX8MP Ahmad Fatoum
2021-08-30 11:51 ` [PATCH v2 3/3] ARM: i.MX8MP: EVK: change bbu handler from eMMC user to boot partition Ahmad Fatoum
@ 2021-08-31 9:42 ` Rouven Czerwinski
2 siblings, 0 replies; 7+ messages in thread
From: Rouven Czerwinski @ 2021-08-31 9:42 UTC (permalink / raw)
To: Ahmad Fatoum, barebox; +Cc: lst, ukl
Hi,
On Mon, 2021-08-30 at 13:51 +0200, Ahmad Fatoum wrote:
> According to the reference manual of the i.MX8MP, the bootrom expects
> the bootloader to sit directly at the start of the eMMC boot partition.
>
> The 32K offset is only valid for eMMC user partitions and SD.
> Tell barebox_update about this, so it can strip away the first 32K
> when writing to an eMMC boot partition.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> v1 -> v2:
> - fix wrong use of flash header offset: This refers to offset in file,
> but we want to change offset on disk. There is a knob for that
> (IMX_BBU_FLAG_PARTITION_STARTS_AT_HEADER), so use that instead
>
> Tested on i.MX8MN.
Whole series is,
Tested-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
on i.MX8MP-EVK.
Best Regards,
Rouven
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/3] mci: imx-esdhc-pbl: support eMMC boot partitions on i.MX8MP
2021-08-30 11:51 ` [PATCH v2 2/3] mci: imx-esdhc-pbl: support eMMC boot partitions on i.MX8MP Ahmad Fatoum
@ 2021-10-04 10:56 ` Sascha Hauer
2021-10-04 11:00 ` Ahmad Fatoum
0 siblings, 1 reply; 7+ messages in thread
From: Sascha Hauer @ 2021-10-04 10:56 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox, lst, ukl, rcz
On Mon, Aug 30, 2021 at 01:51:55PM +0200, Ahmad Fatoum wrote:
> The i.MX header for SD/MMC starts at an offset to allow for a partition
> table at offset 0. i.MX8MN/P bootrom did away with the offset for eMMC
> boot partitions, which usually lack on-disk partition tables, but kept a
> 32-byte offset for SD and eMMC user partitions.
>
> The i.MX8MN/P also introduced a ROM API that allows chainloading from
> boot medium by calling back into ROM. This likely handles that
> difference for us, but as we don't support it yet and we already have
> the PBL eSDHC driver, teach it to detect whether boot is from eMMC boot
> partition or not and use the appropriate offset.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> v1 -> v2:
> - new patch. Without, barebox can be written, but not booted.
> Tested on i.MX8MN.
> ---
> drivers/mci/imx-esdhc-pbl.c | 39 ++++++++++++++++++++++++++++++++++++-
> 1 file changed, 38 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mci/imx-esdhc-pbl.c b/drivers/mci/imx-esdhc-pbl.c
> index e649eb8bbafb..66df4f6dfc74 100644
> --- a/drivers/mci/imx-esdhc-pbl.c
> +++ b/drivers/mci/imx-esdhc-pbl.c
> @@ -25,6 +25,40 @@
>
> #define esdhc_send_cmd __esdhc_send_cmd
>
> +static u8 ext_csd[512] __aligned(64);
> +
> +static int esdhc_send_ext_csd(struct fsl_esdhc_host *host)
> +{
> + struct mci_cmd cmd;
> + struct mci_data data;
> +
> + cmd.cmdidx = MMC_CMD_SEND_EXT_CSD;
> + cmd.cmdarg = 0;
> + cmd.resp_type = MMC_RSP_R1;
> +
> + data.dest = ext_csd;
> + data.blocks = 1;
> + data.blocksize = sizeof(ext_csd);
> + data.flags = MMC_DATA_READ;
> +
> + return esdhc_send_cmd(host, &cmd, &data);
> +}
Is this operation valid for SD cards as well? If not we would first have
to know if we have a SD or eMMC card.
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/3] mci: imx-esdhc-pbl: support eMMC boot partitions on i.MX8MP
2021-10-04 10:56 ` Sascha Hauer
@ 2021-10-04 11:00 ` Ahmad Fatoum
2021-10-04 11:41 ` Sascha Hauer
0 siblings, 1 reply; 7+ messages in thread
From: Ahmad Fatoum @ 2021-10-04 11:00 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox, lst, ukl, rcz
Hello Sascha,
On 04.10.21 12:56, Sascha Hauer wrote:
> On Mon, Aug 30, 2021 at 01:51:55PM +0200, Ahmad Fatoum wrote:
>> The i.MX header for SD/MMC starts at an offset to allow for a partition
>> table at offset 0. i.MX8MN/P bootrom did away with the offset for eMMC
>> boot partitions, which usually lack on-disk partition tables, but kept a
>> 32-byte offset for SD and eMMC user partitions.
>>
>> The i.MX8MN/P also introduced a ROM API that allows chainloading from
>> boot medium by calling back into ROM. This likely handles that
>> difference for us, but as we don't support it yet and we already have
>> the PBL eSDHC driver, teach it to detect whether boot is from eMMC boot
>> partition or not and use the appropriate offset.
>>
>> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
>> ---
>> v1 -> v2:
>> - new patch. Without, barebox can be written, but not booted.
>> Tested on i.MX8MN.
>> ---
>> drivers/mci/imx-esdhc-pbl.c | 39 ++++++++++++++++++++++++++++++++++++-
>> 1 file changed, 38 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/mci/imx-esdhc-pbl.c b/drivers/mci/imx-esdhc-pbl.c
>> index e649eb8bbafb..66df4f6dfc74 100644
>> --- a/drivers/mci/imx-esdhc-pbl.c
>> +++ b/drivers/mci/imx-esdhc-pbl.c
>> @@ -25,6 +25,40 @@
>>
>> #define esdhc_send_cmd __esdhc_send_cmd
>>
>> +static u8 ext_csd[512] __aligned(64);
>> +
>> +static int esdhc_send_ext_csd(struct fsl_esdhc_host *host)
>> +{
>> + struct mci_cmd cmd;
>> + struct mci_data data;
>> +
>> + cmd.cmdidx = MMC_CMD_SEND_EXT_CSD;
>> + cmd.cmdarg = 0;
>> + cmd.resp_type = MMC_RSP_R1;
>> +
>> + data.dest = ext_csd;
>> + data.blocks = 1;
>> + data.blocksize = sizeof(ext_csd);
>> + data.flags = MMC_DATA_READ;
>> +
>> + return esdhc_send_cmd(host, &cmd, &data);
>> +}
>
> Is this operation valid for SD cards as well? If not we would first have
> to know if we have a SD or eMMC card.
This has been tested on both SD and eMMC cards.
In SD case, esdhc_send_cmd will fail and esdhc_bootpart_active will
return false. In MMC case, it will succeed and result will be
evaluated.
>
> Sascha
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/3] mci: imx-esdhc-pbl: support eMMC boot partitions on i.MX8MP
2021-10-04 11:00 ` Ahmad Fatoum
@ 2021-10-04 11:41 ` Sascha Hauer
0 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2021-10-04 11:41 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox, lst, ukl, rcz
On Mon, Oct 04, 2021 at 01:00:19PM +0200, Ahmad Fatoum wrote:
> Hello Sascha,
>
> On 04.10.21 12:56, Sascha Hauer wrote:
> > On Mon, Aug 30, 2021 at 01:51:55PM +0200, Ahmad Fatoum wrote:
> >> The i.MX header for SD/MMC starts at an offset to allow for a partition
> >> table at offset 0. i.MX8MN/P bootrom did away with the offset for eMMC
> >> boot partitions, which usually lack on-disk partition tables, but kept a
> >> 32-byte offset for SD and eMMC user partitions.
> >>
> >> The i.MX8MN/P also introduced a ROM API that allows chainloading from
> >> boot medium by calling back into ROM. This likely handles that
> >> difference for us, but as we don't support it yet and we already have
> >> the PBL eSDHC driver, teach it to detect whether boot is from eMMC boot
> >> partition or not and use the appropriate offset.
> >>
> >> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> >> ---
> >> v1 -> v2:
> >> - new patch. Without, barebox can be written, but not booted.
> >> Tested on i.MX8MN.
> >> ---
> >> drivers/mci/imx-esdhc-pbl.c | 39 ++++++++++++++++++++++++++++++++++++-
> >> 1 file changed, 38 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/mci/imx-esdhc-pbl.c b/drivers/mci/imx-esdhc-pbl.c
> >> index e649eb8bbafb..66df4f6dfc74 100644
> >> --- a/drivers/mci/imx-esdhc-pbl.c
> >> +++ b/drivers/mci/imx-esdhc-pbl.c
> >> @@ -25,6 +25,40 @@
> >>
> >> #define esdhc_send_cmd __esdhc_send_cmd
> >>
> >> +static u8 ext_csd[512] __aligned(64);
> >> +
> >> +static int esdhc_send_ext_csd(struct fsl_esdhc_host *host)
> >> +{
> >> + struct mci_cmd cmd;
> >> + struct mci_data data;
> >> +
> >> + cmd.cmdidx = MMC_CMD_SEND_EXT_CSD;
> >> + cmd.cmdarg = 0;
> >> + cmd.resp_type = MMC_RSP_R1;
> >> +
> >> + data.dest = ext_csd;
> >> + data.blocks = 1;
> >> + data.blocksize = sizeof(ext_csd);
> >> + data.flags = MMC_DATA_READ;
> >> +
> >> + return esdhc_send_cmd(host, &cmd, &data);
> >> +}
> >
> > Is this operation valid for SD cards as well? If not we would first have
> > to know if we have a SD or eMMC card.
>
> This has been tested on both SD and eMMC cards.
> In SD case, esdhc_send_cmd will fail and esdhc_bootpart_active will
> return false. In MMC case, it will succeed and result will be
> evaluated.
Ok, applied then.
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-10-04 11:43 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-30 11:51 [PATCH v2 1/3] ARM: i.MX8MP: bbu: fix wrong flash header offset for eMMC boot partition Ahmad Fatoum
2021-08-30 11:51 ` [PATCH v2 2/3] mci: imx-esdhc-pbl: support eMMC boot partitions on i.MX8MP Ahmad Fatoum
2021-10-04 10:56 ` Sascha Hauer
2021-10-04 11:00 ` Ahmad Fatoum
2021-10-04 11:41 ` Sascha Hauer
2021-08-30 11:51 ` [PATCH v2 3/3] ARM: i.MX8MP: EVK: change bbu handler from eMMC user to boot partition Ahmad Fatoum
2021-08-31 9:42 ` [PATCH v2 1/3] ARM: i.MX8MP: bbu: fix wrong flash header offset for eMMC " Rouven Czerwinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox