Hello everyone, this document will explain on how to create and run a custom script for UUU (Universal Update Utility) tool
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.
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:
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.
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:
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.
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
FB: ucmd setenv mmcboot "run m4boot; $mmcboot"
FB: ucmd saveenv
The resulting script will be the following:
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.
> .\uuu.exe custom_script.auto
$ sudo ./uuu custom_script.auto
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
For this test I have used the Prebuilt image which includes sample Cortex-M4 examples for the EVK
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:
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:
> .\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
$ 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.