Creating and running a custom script for UUU

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating and running a custom script for UUU

No ratings

Creating and running a custom script for UUU

Hello everyone, this document will explain on how to create and run a custom script for UUU (Universal Update Utility) tool

Requirements:

UUU is a pretty flexible tool since it uses the Fastboot protocol through uboot to flash the desired images, this will make possible to create a custom script to add many uboot commands to customize further the boot settings.

In this example I will create a custom script which will flash uboot and Linux rootfs and write a Cortex-M binary to the FAT partition of the eMMC.

At the same time I’ll create and modify a set of environmental variables, this variables will have a set of uboot commands that will load to the TCM this same binary before the device starts booting into Linux.

 

Creating the script

For this document I'll be using Notepad++ but any text editor may be used instead, since the scripts used by UUU are written in plain text.

The very first line of the script must be the version number which will represent the minimum UUU version that UUU can parse this script. For this case that version is 1.2.39

After it, we will add all standard commands to flash uboot and filesystem into the eMMC.

flashemmc.JPG

Note: This may be also copied from the uuu.auto script inside the Demo files.

Please note that the UUU commands format is PROTOCOL: CMD, for this example we will be using mainly SDP and FB protocols which corresponds to the serial download protocol and Fastboot respectively.

For a list of all supported UUU protocols and commands please refer to the UUU documentation here:

https://github.com/NXPmicro/mfgtools/releases/download/uuu_1.4.165/UUU.pdf

Now add the following commands to the script, this will download and write into eMMC FAT partition, which was created when flashing the .wic image, the Cortex-M binary.

 

Spoiler
FB: ucmd setenv fastboot_buffer ${loadaddr}
FB: download -f hello_world_test.bin
FB[-t 20000]: ucmd fatwrite mmc ${emmc_dev}:1 ${fastboot_buffer} hello_world_test.bin ${fastboot_bytes}

 

#fatwrite
write file into a dos filesystem
"<interface> <dev[:part]> <addr> <filename> [<bytes> [<offset>]]

- write file 'filename' from the address 'addr' in RAM  to 'dev' on 'interface'

Note: The Cortex-M binary was named as hello_world_test.bin, but any example name may be used. At this point, in the script we will be using only uboot commands as seen above, in this case was fatwrite.

The script will look as following:

writteFAT.JPG

If the script is run now uboot (imx-boot-imx8mmevk-sd.bin-flash_evk), rootfs (imx-image-multimedia-imx8mmevk.wic) will be flashed and the Cortex-M binary (hello_world_test.bin) written to the FAT partition of the eMMC.

To add environmental variables to modify uboot boot settings, i.e. overwrite the dtb variable so the EVK will select the RPMSG dtb, this in case the Cortex-M example needs to be run at the same time as Cortex-A.

Spoiler

FB: ucmd setenv fdtfile imx8mm-evk-rpmsg.dtb

Next add to the UUU script the set of uboot commands in form of environmental variables that will load to the TCM the Cortex-M binary

 

Spoiler
FB: ucmd setenv loadm4image "fatload mmc ${emmc_dev}:1 0x48000000 hello_world_test.bin; cp.b 0x48000000 0x7e0000 0x20000"
FB: ucmd setenv m4boot "run loadm4image; bootaux 0x48000000"
Note: This can be changed to load it to different targets not only TCM, for example DRAM.

Now for the set of environmental variable to run when uboot starts booting into Linux we may add it to the variable mmcboot. Also adding the command to save the environmental variables set so the settings persist after reboot, this by adding the following commands to the script:

 

Spoiler

FB: ucmd setenv mmcboot "run m4boot; $mmcboot"
FB: ucmd saveenv

The resulting script will be the following:

finalscript.JPG

Now just save the script and name it as you see fit, for this example the name will be custom_script.auto.

 

Running the script

To run a UUU script is pretty simple, just make sure that the files used in the script are in the same folder as the script.

Windows

> .\uuu.exe  custom_script.auto

Linux

$ sudo ./uuu custom_script.auto

 

test1.JPGtest2.JPG


Wait till it finish, turn the board off, set it to boot from eMMC and turn it on, the EVK will boot into Linux automatically and will launch the Cortex-M core automatically.

We may also, double check that the environmental variables were written correctly by stopping at uboot and using the printenv command

test3.JPG


For this test I have used the Prebuilt image which includes sample Cortex-M4 examples for the EVK

 

further flexibility

UUU scripts can be customized even more, for example using macros, so the script can take input arguments so it may be possible to select the uboot, rootfs, Cortex-M binary and dtb to be used when booting, and to be used for other i.MX chips as well.

The resulting script will be as following:

flexiblescript.JPG

Note: Here is assumed that the dtb file is already at the FAT partition, if not same procedure may be added as the Cortex-M binary.

To run a script which expect to have input arguments is as follow:

Windows

> .\uuu.exe -b uuu_cortexM_loader.auto imx-boot-imx8mmevk-sd.bin-flash_evk imx-image-multimedia-imx8mmevk.wic hello_world_test.bin imx8mm-evk-rpmsg.dtb

Linux

$ sudo ./uuu -b uuu_cortexM_loader.auto imx-boot-imx8mmevk-sd.bin-flash_evk imx-image-multimedia-imx8mmevk.wic hello_world_test.bin imx8mm-evk-rpmsg.dtb

Please find both UUU scripts attached and feel free to use them. Hope this helps everyone to better understand how this tool works and the capabilities it have.

Attachments
Version history
Revision #:
5 of 5
Last update:
‎11-26-2021 03:13 PM
Updated by: