Re: imx8mp: Flashing U-Boot into eMMC hardware partition via UUU

2024-05-10 Thread Michael Nazzareno Trimarchi
Hi Fabio

On Fri, May 10, 2024 at 5:10 PM Fabio Estevam  wrote:
>
> Hi Michael,
>
> On Fri, May 10, 2024 at 11:28 AM Michael Nazzareno Trimarchi
>  wrote:
>
> > You can just change as you want. We have this file in buildroot, uuu
> > can run command on the device
> > using FB command. Example how call it
>
> Thanks for sharing the example.
>
> I adapted the UUU script like this:
>
> SDPS: boot -f flash.bin
> FB: ucmd setenv fastboot_buffer ${loadaddr}
> FB: ucmd mmc dev 2 1
> FB: download -f flash.bin
> FB: ucmd setexpr blkcnt $filesize + 0x1ff
> FB: ucmd setexpr blkcnt $blkcnt / 0x200
> FB: ucmd mmc write $loadaddr 0 $blkcnt

My suggestion is use timeout of some command when is possible

> FB: reboot
> FB: done
>
> Did the following changes based on imx8mn_bsh_smm_s2pro:
>
> index 024b46ef8bc2..0b6026c34309 100644
> --- a/board/freescale/imx8mp_evk/imx8mp_evk.c
> +++ b/board/freescale/imx8mp_evk/imx8mp_evk.c
> @@ -3,6 +3,8 @@
>   * Copyright 2019 NXP
>   */
>
> +#include 
> +#include 
>  #include 
>
>  int board_init(void)
> @@ -17,5 +19,11 @@ int board_late_init(void)
> env_set("board_rev", "iMX8MP");
>  #endif
>
> +   if (is_usb_boot()) {
> +   printf("* Entering in USB download mode\n");
> +   env_set("bootcmd", "fastboot usb 0");
> +   env_set("bootdelay", "0");
> +   }
> +

I think that is kind of good example

> return 0;
>  }
> diff --git a/include/configs/imx8mp_evk.h b/include/configs/imx8mp_evk.h
> index 1759318fdd35..148b36bd3169 100644
> --- a/include/configs/imx8mp_evk.h
> +++ b/include/configs/imx8mp_evk.h
> @@ -25,8 +25,17 @@
>
>  #include 
>
> +#define EMMCARGS \
> +   "fastboot_partition_alias_all=" \
> +   __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) ".0:0\0" \
> +   "fastboot_partition_alias_bootloader=" \
> +   __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) ".1:0\0" \
> +   "emmc_dev=" __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) "\0" \
> +   "emmc_ack=1\0" \
> +
>  /* Initial environment variables */
>  #define CFG_EXTRA_ENV_SETTINGS \
> +   EMMCARGS \
> BOOTENV \
> "scriptaddr=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \
> "kernel_addr_r=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \
>
> and now UUU correctly flashes the eMMC hardware partition.
>
> Thanks a lot,

No problem

Micheal

>
> Fabio Estevam



-- 
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
mich...@amarulasolutions.com
__

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
i...@amarulasolutions.com
www.amarulasolutions.com


Re: imx8mp: Flashing U-Boot into eMMC hardware partition via UUU

2024-05-10 Thread Fabio Estevam
Hi Michael,

On Fri, May 10, 2024 at 11:28 AM Michael Nazzareno Trimarchi
 wrote:

> You can just change as you want. We have this file in buildroot, uuu
> can run command on the device
> using FB command. Example how call it

Thanks for sharing the example.

I adapted the UUU script like this:

SDPS: boot -f flash.bin
FB: ucmd setenv fastboot_buffer ${loadaddr}
FB: ucmd mmc dev 2 1
FB: download -f flash.bin
FB: ucmd setexpr blkcnt $filesize + 0x1ff
FB: ucmd setexpr blkcnt $blkcnt / 0x200
FB: ucmd mmc write $loadaddr 0 $blkcnt
FB: reboot
FB: done

Did the following changes based on imx8mn_bsh_smm_s2pro:

index 024b46ef8bc2..0b6026c34309 100644
--- a/board/freescale/imx8mp_evk/imx8mp_evk.c
+++ b/board/freescale/imx8mp_evk/imx8mp_evk.c
@@ -3,6 +3,8 @@
  * Copyright 2019 NXP
  */

+#include 
+#include 
 #include 

 int board_init(void)
@@ -17,5 +19,11 @@ int board_late_init(void)
env_set("board_rev", "iMX8MP");
 #endif

+   if (is_usb_boot()) {
+   printf("* Entering in USB download mode\n");
+   env_set("bootcmd", "fastboot usb 0");
+   env_set("bootdelay", "0");
+   }
+
return 0;
 }
diff --git a/include/configs/imx8mp_evk.h b/include/configs/imx8mp_evk.h
index 1759318fdd35..148b36bd3169 100644
--- a/include/configs/imx8mp_evk.h
+++ b/include/configs/imx8mp_evk.h
@@ -25,8 +25,17 @@

 #include 

+#define EMMCARGS \
+   "fastboot_partition_alias_all=" \
+   __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) ".0:0\0" \
+   "fastboot_partition_alias_bootloader=" \
+   __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) ".1:0\0" \
+   "emmc_dev=" __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) "\0" \
+   "emmc_ack=1\0" \
+
 /* Initial environment variables */
 #define CFG_EXTRA_ENV_SETTINGS \
+   EMMCARGS \
BOOTENV \
"scriptaddr=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \
"kernel_addr_r=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \

and now UUU correctly flashes the eMMC hardware partition.

Thanks a lot,

Fabio Estevam


Re: imx8mp: Flashing U-Boot into eMMC hardware partition via UUU

2024-05-10 Thread Michael Nazzareno Trimarchi
On Fri, May 10, 2024 at 4:19 PM Fabio Estevam  wrote:
>
> Hi,
>
> I am using an imx8mp-evk board and I can flash the U-Boot into the
> eMMC hardware partition 0 by running:
>
>=> tftpboot $loadaddr flash.bin
>=> setexpr blkcnt $filesize + 0x1ff && setexpr blkcnt $blkcnt / 0x200
>=> mmc dev 2 1
>=> mmc write $loadaddr 0 $blkcnt
>
> Now I want to do the same via UUU.
>
> I tried to create a script called emmc_flash:
>
> uuu_version 1.5.21
>
> SDPS: boot -f flash.bin
> SDPS: done
> FB: ucmd setenv fastboot_dev mmc
> FB: ucmd mmc dev 2 1
> FB: flash bootloader flash.bin
> FB: Done
>
> Then on the PC: uuu emmc_flash
>
> U-Boot is loaded to RAM, but the eMMC hardware partition is not programmed.
>
> What is the correct script for doing this?
>
> Any suggestions?

Create an lst file

Hi Fabio

Top posting

# @_flash.bin| bootloader
# @_image   [_flash.bin] | image burn to nand, default is the same as bootloader
# @_filesystem   | filesystem to burn
# @_kernel   | kernel image
# @_dtb  | dtb image

# This command will be run when ROM support stream mode
# i.MX8QXP, i.MX8QM
SDPS: boot -f _flash.bin

FB: ucmd setenv fastboot_buffer ${loadaddr}
FB: download -f _image
# Burn image to nandfit partition if needed
FB: ucmd if env exists nandfit_part; then nand erase.part nandfit;
nand write ${fastboot_buffer} nandfit ${filesize}; else true; fi;
FB: ucmd nandbcb init ${fastboot_buffer} nandboot ${filesize}

FB[-t 1]: ucmd ubi part nandrootfs
FB[-t 1]: ucmd ubi create root -
FB: download -f _filesystem
FB[-t 6]: ucmd ubi write ${loadaddr} root ${filesize}

FB: download -f _kernel
FB[-t 1]: ucmd nand write ${loadaddr} nandkernel ${filesize}

FB: download -f _dtb
FB[-t 8000]: ucmd nand write ${loadaddr} nanddtb ${filesize}

FB: reboot
FB: done

You can just change as you want. We have this file in buildroot, uuu
can run command on the device
using FB command. Example how call it

${OUTPUT_DIR}/host/bin/uuu -v -b ${IMAGES_DIR}/nand-full.lst \
  ${IMAGES_DIR}/flash.bin \
  ${IMAGES_DIR}/flash.bin \
  ${IMAGES_DIR}/rootfs.ubifs \
  ${IMAGES_DIR}/Image \
  ${IMAGES_DIR}/freescale/imx8mn-bsh-smm-s2.dtb


Michael

>
> Thanks



-- 
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
mich...@amarulasolutions.com
__

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
i...@amarulasolutions.com
www.amarulasolutions.com


imx8mp: Flashing U-Boot into eMMC hardware partition via UUU

2024-05-10 Thread Fabio Estevam
Hi,

I am using an imx8mp-evk board and I can flash the U-Boot into the
eMMC hardware partition 0 by running:

   => tftpboot $loadaddr flash.bin
   => setexpr blkcnt $filesize + 0x1ff && setexpr blkcnt $blkcnt / 0x200
   => mmc dev 2 1
   => mmc write $loadaddr 0 $blkcnt

Now I want to do the same via UUU.

I tried to create a script called emmc_flash:

uuu_version 1.5.21

SDPS: boot -f flash.bin
SDPS: done
FB: ucmd setenv fastboot_dev mmc
FB: ucmd mmc dev 2 1
FB: flash bootloader flash.bin
FB: Done

Then on the PC: uuu emmc_flash

U-Boot is loaded to RAM, but the eMMC hardware partition is not programmed.

What is the correct script for doing this?

Any suggestions?

Thanks