* [PATCH v1 1/3] arm: config: xea: Update environment variables for XEA board (imx287)
@ 2024-01-10 14:48 Lukasz Majewski
2024-01-10 14:48 ` [PATCH v1 2/3] arm: config: Enable CRC8 support in SPL on imx287 XEA board Lukasz Majewski
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Lukasz Majewski @ 2024-01-10 14:48 UTC (permalink / raw)
To: Stefano Babic, Fabio Estevam, Tom Rini, u-boot, NXP u-boot
Cc: Lukasz Majewski
As the XEA now supports fitImage, the default envs shall reflect this
as well.
Moreover, some SPI-NOR layout re-organization has took place.
Signed-off-by: Lukasz Majewski <lukma@denx.de>
---
include/configs/xea.h | 45 ++++++++++++++++++++++++-------------------
1 file changed, 25 insertions(+), 20 deletions(-)
diff --git a/include/configs/xea.h b/include/configs/xea.h
index 04ca5aa12a..a11bb522cd 100644
--- a/include/configs/xea.h
+++ b/include/configs/xea.h
@@ -33,17 +33,21 @@
"bootsec=sf_swu\0" \
"consdev=ttyAMA0\0" \
"baudrate=115200\0" \
- "dtbaddr=0x44000000\0" \
- "dtbfile=imx28-xea.dtb\0" \
"rootdev=/dev/mmcblk0p2\0" \
"netdev=eth0\0" \
- "rdaddr=0x43000000\0" \
- "swufile=swupdate.img\0" \
- "sf_kernel_offset=0x100000\0" \
- "sf_kernel_size=0x400000\0" \
- "sf_swu_offset=0x500000\0" \
- "sf_swu_size=0x800000\0" \
- "rootpath=/opt/eldk-5.5/armv5te/rootfs-qte-sdk\0" \
+ "swufile=swupdate-image-xea-upd.itb\0" \
+ "sf_kernel_offset=0xA0000\0" \
+ "sf_swu_size=0xF40000\0" \
+ "ethact=FEC\0" \
+ "arch=xea\0" \
+ "serverip=10.8.217.79\0" \
+ "nfs_serverip=10.8.218.113\0" \
+ "gatewayip=10.8.209.250\0" \
+ "lwe_env=" \
+ "if dhcp ${loadaddr} ${hostname}/${lwe_uenv} ; then " \
+ "source ${loadaddr}; " \
+ "fi\0" \
+ "lwe_uenv=env_uboot_xea.bin\0" \
"do_update_mmc=" \
"if mmc rescan ; then " \
"mmc dev 0 ${update_mmc_part} ; " \
@@ -60,6 +64,12 @@
"sf write ${loadaddr} ${update_offset} ${filesize} ; " \
"fi ; " \
"fi\0" \
+ "factory_reset=" \
+ "if sf probe ; then " \
+ "run update_swu ; " \
+ "setenv bootmode update ; " \
+ "saveenv ; " \
+ "fi\0" \
"update_spl_filename=u-boot.sb\0" \
"update_spl=" \
"setenv update_filename ${update_spl_filename} ; " \
@@ -72,6 +82,8 @@
"run do_update_sf ; " \
"setenv update_mmc_part 1 ; " \
"setenv update_offset 0 ; " \
+ "run do_update_mmc ; " \
+ "setenv update_mmc_part 2 ; " \
"run do_update_mmc\0" \
"update_kernel_filename=uImage\0" \
"update_kernel=" \
@@ -82,13 +94,9 @@
"setenv update_filename ${dtbfile} ; " \
"setenv update_offset 0x400 ; " \
"run do_update_mmc\0" \
- "update_sfkernel=" \
- "setenv update_filename fitImage ; " \
- "setenv update_offset ${sf_kernel_offset} ; " \
- "run do_update_sf\0" \
"update_swu=" \
"setenv update_filename ${swufile} ; " \
- "setenv update_offset ${sf_swu_offset} ; " \
+ "setenv update_offset ${sf_kernel_offset} ; " \
"run do_update_sf\0" \
"addcons=" \
"setenv bootargs ${bootargs} " \
@@ -108,9 +116,6 @@
"netload=" \
"dhcp ${loadaddr} ${hostname}/${bootfile} ; " \
"tftp ${dtbaddr} ${hostname}/${dtbfile}\0" \
- "sfload=" \
- "sf probe ; " \
- "sf read ${loadaddr} ${sf_kernel_offset} ${sf_kernel_size}\0" \
"usbload=" \
"usb start ; " \
"load usb 0:1 ${loadaddr} ${bootfile}\0" \
@@ -132,11 +137,11 @@
"bootm ${loadaddr} - ${dtbaddr} ; " \
"fi\0" \
"sf_swu=" \
- "if run sfload ; then " \
- "sf read ${rdaddr} ${sf_swu_offset} ${sf_swu_size} ; " \
+ "if sf probe ; then " \
+ "sf read ${loadaddr} ${sf_kernel_offset} ${sf_swu_size} ; " \
"setenv bootargs root=/dev/ram0 rw ; " \
"run addargs ; " \
- "bootm ${loadaddr} ${rdaddr} ; " \
+ "bootm ${loadaddr} ; " \
"fi\0" \
"net_mmc=" \
"if run netload mmcargs addargs ; then " \
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v1 2/3] arm: config: Enable CRC8 support in SPL on imx287 XEA board
2024-01-10 14:48 [PATCH v1 1/3] arm: config: xea: Update environment variables for XEA board (imx287) Lukasz Majewski
@ 2024-01-10 14:48 ` Lukasz Majewski
2024-01-10 14:48 ` [PATCH v1 3/3] arm: xea: Add support for boot image source descriptor in SPL Lukasz Majewski
2024-01-10 14:52 ` [PATCH v1 1/3] arm: config: xea: Update environment variables for XEA board (imx287) Tom Rini
2 siblings, 0 replies; 5+ messages in thread
From: Lukasz Majewski @ 2024-01-10 14:48 UTC (permalink / raw)
To: Stefano Babic, Fabio Estevam, Tom Rini, u-boot, NXP u-boot
Cc: Lukasz Majewski, Simon Glass
The boot0/1 feature uses simple CRC8 to check (in SPL) if
SPI-NOR content is not corrupted, hence the need to enable
it.
Signed-off-by: Lukasz Majewski <lukma@denx.de>
---
configs/imx28_xea_defconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/configs/imx28_xea_defconfig b/configs/imx28_xea_defconfig
index c1b0487f7e..64a0561a34 100644
--- a/configs/imx28_xea_defconfig
+++ b/configs/imx28_xea_defconfig
@@ -123,4 +123,5 @@ CONFIG_DM_SERIAL=y
CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_MXS_SPI=y
+CONFIG_SPL_CRC8=y
# CONFIG_SPL_OF_LIBFDT is not set
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v1 3/3] arm: xea: Add support for boot image source descriptor in SPL
2024-01-10 14:48 [PATCH v1 1/3] arm: config: xea: Update environment variables for XEA board (imx287) Lukasz Majewski
2024-01-10 14:48 ` [PATCH v1 2/3] arm: config: Enable CRC8 support in SPL on imx287 XEA board Lukasz Majewski
@ 2024-01-10 14:48 ` Lukasz Majewski
2024-01-10 14:52 ` [PATCH v1 1/3] arm: config: xea: Update environment variables for XEA board (imx287) Tom Rini
2 siblings, 0 replies; 5+ messages in thread
From: Lukasz Majewski @ 2024-01-10 14:48 UTC (permalink / raw)
To: Stefano Babic, Fabio Estevam, Tom Rini, u-boot, NXP u-boot
Cc: Anatolij Gustschin, Lukasz Majewski
From: Anatolij Gustschin <agust@denx.de>
We load two boot image source descriptor structures from last
two sectors in the SPI NOR flash and determine the boot source
for loading the kernel/DTB images, then adjust the boot order for
loading image from eMMC boot0 or boot1 partition.
Signed-off-by: Anatolij Gustschin <agust@denx.de>
Signed-off-by: Lukasz Majewski <lukma@denx.de>
---
board/liebherr/xea/boot_img_scr.h | 27 ++++++++++
board/liebherr/xea/xea.c | 85 +++++++++++++++++++++++++++++++
2 files changed, 112 insertions(+)
create mode 100644 board/liebherr/xea/boot_img_scr.h
diff --git a/board/liebherr/xea/boot_img_scr.h b/board/liebherr/xea/boot_img_scr.h
new file mode 100644
index 0000000000..baa3072b49
--- /dev/null
+++ b/board/liebherr/xea/boot_img_scr.h
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Struct for boot image source description for placing in last
+ * two SPI NOR flash sectors on legcom.
+ */
+
+struct boot_img_src {
+ u8 magic; /* Must be 'B' = 0x42 */
+ u8 flags; /* flags to specify mmcblk[0|1] boot[0|1] */
+ u8 crc8; /* CRC-8 over above two bytes */
+} __packed;
+
+/*
+ * Bit definition in boot_img_src.flags:
+ * Bit 0: mmcblk device 0 or 1 (1 - if this bit set)
+ * Bit 1: mmcblk boot partition 0 or 1.
+ * for eMMC: boot0 if this bit is cleared, boot1 - if set
+ * for SD-card the boot partition value will always be 0
+ * (independent of the value of this bit)
+ *
+ */
+#define BOOT_SRC_MMC1 BIT(0)
+#define BOOT_SRC_PART1 BIT(1)
+
+/* Offset of the first boot image source descriptor in SPI NOR */
+#define SPI_FLASH_BOOT_SRC_OFFS 0xFE0000
+#define SPI_FLASH_SECTOR_SIZE 0x10000
diff --git a/board/liebherr/xea/xea.c b/board/liebherr/xea/xea.c
index e4d2eb65cc..c8ac526cb4 100644
--- a/board/liebherr/xea/xea.c
+++ b/board/liebherr/xea/xea.c
@@ -32,6 +32,11 @@
#include <errno.h>
#include <usb.h>
#include <serial.h>
+#include <u-boot/crc.h>
+#include "boot_img_scr.h"
+
+#include <spi.h>
+#include <spi_flash.h>
#ifdef CONFIG_SPL_BUILD
#include <spl.h>
@@ -66,6 +71,52 @@ void board_init_f(ulong arg)
preloader_console_init();
}
+static struct boot_img_src img_src[2];
+static int spi_load_boot_info(void)
+{
+ struct spi_flash *flash;
+ int err;
+
+ flash = spi_flash_probe(CONFIG_SF_DEFAULT_BUS,
+ CONFIG_SF_DEFAULT_CS,
+ CONFIG_SF_DEFAULT_SPEED,
+ CONFIG_SF_DEFAULT_MODE);
+ if (!flash) {
+ printf("%s: SPI probe err\n", __func__);
+ return -ENODEV;
+ }
+
+ /*
+ * Load both boot info structs from SPI flash
+ */
+ err = spi_flash_read(flash, SPI_FLASH_BOOT_SRC_OFFS,
+ sizeof(img_src[0]),
+ (void *)&img_src[0]);
+ if (err) {
+ debug("%s: First boot info NOR sector read error %d\n",
+ __func__, err);
+ return err;
+ }
+
+ err = spi_flash_read(flash,
+ SPI_FLASH_BOOT_SRC_OFFS + SPI_FLASH_SECTOR_SIZE,
+ sizeof(img_src[0]),
+ (void *)&img_src[1]);
+ if (err) {
+ debug("%s: First boot info NOR sector read error %d\n",
+ __func__, err);
+ return err;
+ }
+
+ debug("%s: BI0 0x%x 0x%x 0x%x\n", __func__,
+ img_src[0].magic, img_src[0].flags, img_src[0].crc8);
+
+ debug("%s: BI1 0x%x 0x%x 0x%x\n", __func__,
+ img_src[1].magic, img_src[1].flags, img_src[1].crc8);
+
+ return 0;
+}
+
static int boot_tiva0, boot_tiva1;
/* Check if TIVAs request booting via U-Boot proper */
@@ -114,6 +165,40 @@ void spl_board_init(void)
boot_tiva1 = dm_gpio_get_value(&btiva1);
}
+int spl_mmc_emmc_boot_partition(struct mmc *mmc)
+{
+ int i, src_idx = -1, ret;
+
+ ret = spi_load_boot_info();
+ if (ret) {
+ printf("%s: Cannot read XEA boot info! [%d]\n", __func__, ret);
+ /* To avoid bricking board - by default boot from boot0 eMMC */
+ return 1;
+ }
+
+ for (i = 0; i < 2; i++) {
+ if (img_src[i].magic == 'B' &&
+ img_src[i].crc8 == crc8(0, &img_src[i].magic, 2)) {
+ src_idx = i;
+ break;
+ }
+ }
+
+ debug("%s: src idx: %d\n", __func__, src_idx);
+
+ if (src_idx < 0)
+ /*
+ * Always use eMMC (mmcblkX) boot0 if no
+ * valid image source description found
+ */
+ return 1;
+
+ if (img_src[src_idx].flags & BOOT_SRC_PART1)
+ return 2;
+
+ return 1;
+}
+
void board_boot_order(u32 *spl_boot_list)
{
spl_boot_list[0] = BOOT_DEVICE_MMC1;
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/3] arm: config: xea: Update environment variables for XEA board (imx287)
2024-01-10 14:48 [PATCH v1 1/3] arm: config: xea: Update environment variables for XEA board (imx287) Lukasz Majewski
2024-01-10 14:48 ` [PATCH v1 2/3] arm: config: Enable CRC8 support in SPL on imx287 XEA board Lukasz Majewski
2024-01-10 14:48 ` [PATCH v1 3/3] arm: xea: Add support for boot image source descriptor in SPL Lukasz Majewski
@ 2024-01-10 14:52 ` Tom Rini
2024-01-11 8:18 ` Lukasz Majewski
2 siblings, 1 reply; 5+ messages in thread
From: Tom Rini @ 2024-01-10 14:52 UTC (permalink / raw)
To: Lukasz Majewski; +Cc: Stefano Babic, Fabio Estevam, u-boot, NXP u-boot
[-- Attachment #1: Type: text/plain, Size: 480 bytes --]
On Wed, Jan 10, 2024 at 03:48:47PM +0100, Lukasz Majewski wrote:
> As the XEA now supports fitImage, the default envs shall reflect this
> as well.
>
> Moreover, some SPI-NOR layout re-organization has took place.
>
> Signed-off-by: Lukasz Majewski <lukma@denx.de>
> ---
>
> include/configs/xea.h | 45 ++++++++++++++++++++++++-------------------
> 1 file changed, 25 insertions(+), 20 deletions(-)
Please migrate this to a plain text environment.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/3] arm: config: xea: Update environment variables for XEA board (imx287)
2024-01-10 14:52 ` [PATCH v1 1/3] arm: config: xea: Update environment variables for XEA board (imx287) Tom Rini
@ 2024-01-11 8:18 ` Lukasz Majewski
0 siblings, 0 replies; 5+ messages in thread
From: Lukasz Majewski @ 2024-01-11 8:18 UTC (permalink / raw)
To: Tom Rini; +Cc: Stefano Babic, Fabio Estevam, u-boot, NXP u-boot
[-- Attachment #1: Type: text/plain, Size: 895 bytes --]
Hi Tom,
> On Wed, Jan 10, 2024 at 03:48:47PM +0100, Lukasz Majewski wrote:
>
> > As the XEA now supports fitImage, the default envs shall reflect
> > this as well.
> >
> > Moreover, some SPI-NOR layout re-organization has took place.
> >
> > Signed-off-by: Lukasz Majewski <lukma@denx.de>
> > ---
> >
> > include/configs/xea.h | 45
> > ++++++++++++++++++++++++------------------- 1 file changed, 25
> > insertions(+), 20 deletions(-)
>
> Please migrate this to a plain text environment.
>
Ok, so I will prepare new patch especially for it.
(IMHO, patches 2/3 and 3/3 can be applied without this one).
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-01-11 8:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-10 14:48 [PATCH v1 1/3] arm: config: xea: Update environment variables for XEA board (imx287) Lukasz Majewski
2024-01-10 14:48 ` [PATCH v1 2/3] arm: config: Enable CRC8 support in SPL on imx287 XEA board Lukasz Majewski
2024-01-10 14:48 ` [PATCH v1 3/3] arm: xea: Add support for boot image source descriptor in SPL Lukasz Majewski
2024-01-10 14:52 ` [PATCH v1 1/3] arm: config: xea: Update environment variables for XEA board (imx287) Tom Rini
2024-01-11 8:18 ` Lukasz Majewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox