Skip to content

Sample scripts

nxpfrankli edited this page Jun 2, 2023 · 1 revision

This pages list some examples on scripts to help UUU to make some tasks automatically.

Copy the source code to the file uuu.auto and execute the application executable file.

Download spl and uboot for imx8mm and imx8mq

uuu_version 1.2.39

# This command will be run when i.MX6/7 i.MX8MM, i.MX8MQ
SDP: boot -f _flash.bin

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

# These commands will be run when use SPL and will be skipped if no spl
# SDPU will be deprecated. please use SDPV instead of SDPU
# {
SDPU: delay 1000
SDPU: write -f _flash.bin -offset 0x57c00
SDPU: jump
SDPU: done
# }

# These commands will be run when use SPL and will be skipped if no spl
# if (SPL support SDPV)
# {
SDPV: delay 1000
SDPV: write -f _flash.bin -skipspl
SDPV: jump
SDPV: done
# }

Burn bootloader to eMMC boot partition

uuu_version 1.2.39

# This command will be run when i.MX6/7 i.MX8MM, i.MX8MQ
SDP: boot -f _flash.bin

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

# These commands will be run when use SPL and will be skipped if no spl
# SDPU will be deprecated. please use SDPV instead of SDPU
# {
SDPU: delay 1000
SDPU: write -f _flash.bin -offset 0x57c00
SDPU: jump
# }

# These commands will be run when use SPL and will be skipped if no spl
# if (SPL support SDPV)
# {
SDPV: delay 1000
SDPV: write -f _flash.bin -skipspl
SDPV: jump
# }

FB: ucmd setenv fastboot_dev mmc
FB: ucmd setenv mmcdev ${emmc_dev}
FB: ucmd mmc dev ${emmc_dev}
FB: flash bootloader _flash.bin
FB: ucmd mmc partconf ${emmc_dev} 0 1 0
FB: Done

Burn android to eMMC

uuu_version 1.2.39

# This command will be run when i.MX6/7 i.MX8MM, i.MX8MQ
SDP: boot -f _flash.bin

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

# These commands will be run when use SPL and will be skipped if no spl
# SDPU will be deprecated. please use SDPV instead of SDPU
# {
SDPU: delay 1000
SDPU: write -f _flash.bin -offset 0x57c00
SDPU: jump
# }

# These commands will be run when use SPL and will be skipped if no spl
# if (SPL support SDPV)
# {
SDPV: delay 1000
SDPV: write -f _flash.bin -skipspl
SDPV: jump
# }

FB: ucmd setenv fastboot_dev mmc
FB: ucmd setenv mmcdev ${emmc_dev}
FB: ucmd mmc dev ${emmc_dev}
FB: flash gpt partition-table.img
FB: flash boot_a boot-imx8qxp.img
FB: flash system_a system.img
FB: flash vendor_a vendor.img
FB: flash vbmeta_a vbmeta-imx8qxp.img
#FB: ucmd setenv fastboot_buffer ${loadaddr}
#FB: download -f u-boot-imx8qxp.imx
#FB: ucmd setexpr fastboot_blk ${fastboot_bytes}
#FB: ucmd setexpr fastboot_blk ${fastboot_blk} + 0x1FF
#FB: ucmd setexpr fastboot_blk ${fastboot_blk} / 0x200
#FB: ucmd mmc partconf ${emmc_dev} 1 1 1
#FB: ucmd echo ${fastboot_buffer}
#FB: ucmd echo ${fastboot_blk}
#FB: ucmd mmc write ${fastboot_buffer} 0x40  ${fastboot_blk}
FB: flash bootloader u-boot-imx8qxp.imx
FB: ucmd mmc partconf ${emmc_dev} 0 1 0
FB: Done

Burn yocto image to eMMC by linux kernel

uuu_version 1.2.39

# This command will be run when i.MX6/7 i.MX8MM, i.MX8MQ
SDP: boot -f _flash.bin

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

# These commands will be run when use SPL and will be skipped if no spl
# SDPU will be deprecated. please use SDPV instead of SDPU
# {
SDPU: delay 1000
SDPU: write -f _flash.bin -offset 0x57c00
SDPU: jump
# }

# These commands will be run when use SPL and will be skipped if no spl
# if (SPL support SDPV)
# {
SDPV: delay 1000
SDPV: write -f _flash.bin -skipspl
SDPV: jump
# }

FB: ucmd setenv fastboot_buffer ${loadaddr}
FB: download -f _Image
FB: ucmd setenv fastboot_buffer ${fdt_addr}
FB: download -f _board.dtb
FB: ucmd setenv fastboot_buffer ${initrd_addr}
FB: download -f _initramfs.cpio.gz.uboot
FB: ucmd setenv mfgtool_args ${mfgtool_args} mfg_mmcdev=${emmc_dev}
FB: ucmd run mfgtool_args
FB: acmd booti ${loadaddr} ${initrd_addr} ${fdt_addr}

# get mmc dev number from kernel command line
FBK: ucmd cmdline=`cat /proc/cmdline`;cmdline=${cmdline#*mfg_mmcdev=};cmds=($cmdline);echo ${cmds[0]}>/tmp/mmcdev
# Wait for mmc
FBK: ucmd mmc=`cat /tmp/mmcdev`; while [ ! -e /dev/mmcblk${mmc} ]; do sleep 1; echo "wait for /dev/mmcblk${mmc} appear"; done;
# create partition
FBK: ucmd mmc=`cat /tmp/mmcdev`; PARTSTR=$'10M,500M,0c\n600M,,83\n'; echo "$PARTSTR" | sfdisk --force /dev/mmcblk${mmc}

FBK: ucmd mmc=`cat /tmp/mmcdev`; dd if=/dev/zero of=/dev/mmcblk${mmc} bs=1k seek=4096 count=1
FBK: ucmd sync
FBK: ucmd mmc=`cat /tmp/mmcdev`; echo 0 > /sys/block/mmcblk${mmc}boot0/force_ro
FBK: ucp  _flash.bin t:/tmp
FBK: ucmd mmc=`cat /tmp/mmcdev`; dd if=/tmp/_flash.bin of=/dev/mmc${mmc}boot0 bs=1K seek=32
FBK: ucmd mmc=`cat /tmp/mmcdev`; echo 1 > /sys/block/mmcblk${mmc}boot0/force_ro
FBK: ucmd mmc=`cat /tmp/mmcdev`; while [ ! -e /dev/mmcblk${mmc}p1 ]; do sleep 1; done
FBK: ucmd mmc=`cat /tmp/mmcdev`; mkfs.vfat /dev/mmcblk${mmc}p1
FBK: ucmd mmc=`cat /tmp/mmcdev`; mkdir -p /mnt/fat
FBK: ucmd mmc=`cat /tmp/mmcdev`; mount -t vfat /dev/mmcblk${mmc}p1 /mnt/fat
FBK: ucp  _Image t:/mnt/fat
FBK: ucp  _board.dtb t:/mnt/fat
FBK: ucmd umount /mnt/fat
FBK: ucmd mmc=`cat /tmp/mmcdev`; mkfs.ext3 -F -E nodiscard /dev/mmcblk${mmc}p2
FBK: ucmd mkdir -p /mnt/ext3
FBK: ucmd mmc=`cat /tmp/mmcdev`; mount /dev/mmcblk${mmc}p2 /mnt/ext3
FBK: acmd export EXTRACT_UNSAFE_SYMLINKS=1; tar -jx -C /mnt/ext3
FBK: ucp  _rootfs.tar.bz2 t:-
FBK: Sync
FBK: ucmd umount /mnt/ext3
FBK: DONE

Burn NAND flash by linux kernel

uuu_version 1.2.39

# Please replace below item with actual name
# @_flash_fw.bin                | boot loader firmware, for i.MX8QM/QX, it's different from _flash.bin, for all other platforms, it's same as _flash.bin
# @_flash.bin                   | boot loader file burn to NAND
# @_Image                       | linux kernel image, zImage for arm32, Image for arm64
# @_board.dtb                   | board dtb file
# @_initramfs.cpio.gz.uboot     | initramfs
# @_tee                         | optee image
# @_rootfs.tar.bz2              | rootfs

# This command will be run when i.MX6/7 i.MX8MM, i.MX8MQ
SDP: boot -f _flash_fw.bin

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

# These commands will be run when use SPL and will be skipped if no spl
# SDPU will be deprecated. please use SDPV instead of SDPU
# {
SDPU: delay 1000
SDPU: write -f _flash_fw.bin -offset 0x57c00
SDPU: jump
# }

# These commands will be run when use SPL and will be skipped if no spl
# if (SPL support SDPV)
# {
SDPV: delay 1000
SDPV: write -f _flash_fw.bin -skipspl
SDPV: jump
# }


FB: ucmd setenv fastboot_buffer ${loadaddr}
FB: download -f _Image
FB: ucmd setenv fastboot_buffer ${fdt_addr}
FB: download -f _board.dtb
FB: ucmd setenv fastboot_buffer ${initrd_addr}
FB: download -f _initramfs.cpio.gz.uboot
FB: ucmd setenv bootargs ${bootargs} ${mtdparts}
#FB: ucmd setenv bootargs console=ttymxc3,115200  ${mtdparts}
FB: acmd ${kboot} ${loadaddr} ${initrd_addr} ${fdt_addr}

FBK: ucmd cat /proc/mtd
FBK: ucmd cat /proc/mtd | while read dev size erase name; do mtd=${dev:3}; mtd=${mtd%:}; name=${name%\"}; name=${name#\"}; echo export $name=$mtd >> /tmp/mtd.sh; done;

FBK: ucmd chmod 777 /tmp/mtd.sh
FBK: ucmd mount -t debugfs debugfs /sys/kernel/debug

# write boot loader
FBK: ucmd source /tmp/mtd.sh; flash_erase /dev/mtd${nandboot} 0 0
FBK: ucp _flash.bin t:/tmp/boot
FBK: ucmd source /tmp/mtd.sh; cd /tmp; if ! [[ `cat /sys/devices/soc0/soc_id` = *"MX8Q"* ]]; then pad="-x"; fi; kobs-ng init $pad -v --chip_0_device_path=/dev/mtd${nandboot} /tmp/boot

# burn FIT
FBK: ucmd if [[ `cat /tmp/mtd.sh` = *"nandfit"* ]]; then source /tmp/mtd.sh; flash_erase /dev/mtd${nandfit} 0 0; dd if=/tmp/boot of=/tmp/fit; nandwrite -p /dev/mtd${nandfit} -p /tmp/fit; fi

# burn kernel
FBK: ucmd source /tmp/mtd.sh; flash_erase /dev/mtd${nandkernel} 0 0
FBK: ucp _Image t:/tmp/img
FBK: ucmd source /tmp/mtd.sh; nandwrite -p /dev/mtd${nandkernel} -p /tmp/img

# burn dtb
FBK: ucmd source /tmp/mtd.sh; flash_erase /dev/mtd${nanddtb} 0 0
FBK: ucp _board.dtb t:/tmp/dtb
FBK: ucmd source /tmp/mtd.sh; nandwrite -p /dev/mtd${nanddtb} -p /tmp/dtb

# burn uTee
FBK: ucmd source /tmp/mtd.sh; flash_erase /dev/mtd${nandtee} 0 0
FBK: ucp _tee t:/tmp/tee
FBK: ucmd source /tmp/mtd.sh; nandwrite -p /dev/mtd${nandtee} -p /tmp/tee

# burn rootfs
FBK: ucmd source /tmp/mtd.sh; flash_erase /dev/mtd${nandrootfs} 0 0
FBK: ucmd source /tmp/mtd.sh; ubiattach /dev/ubi_ctrl -m ${nandrootfs}
FBK: ucmd source /tmp/mtd.sh; ubimkvol /dev/ubi0 -Nnandrootfs -m
FBK: ucmd source /tmp/mtd.sh; mkdir -p /mnt/mtd
FBK: ucmd source /tmp/mtd.sh; mount -t ubifs ubi0:nandrootfs /mnt/mtd
FBK: acmd export EXTRACT_UNSAFE_SYMLINKS=1; tar -jx -C /mnt/mtd
FBK: ucp _rootfs.tar.bz2 t:-
FBK: sync
FBK: ucmd umount /mnt/mtd

FBK: done

Download kernel and mount nfs by usb ncm

uuu_version 1.2.39

# Please replace below item with actual name
# @_flash.bin                   | boot loader
# @_Image                       | linux kernel image, zImage for arm32, Image for arm64
# @_board.dtb                   | board dtb file
# @_initramfs.cpio.gz.uboot     | initramfs
# @_nfspath                     | rootfs path without ip address, ip address will auto detect

# This command will be run when i.MX6/7 i.MX8MM, i.MX8MQ
SDP: boot -f _flash.bin

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

# These commands will be run when use SPL and will be skipped if no spl
# SDPU will be deprecated. please use SDPV instead of SDPU
# {
SDPU: delay 1000
SDPU: write -f _flash.bin -offset 0x57c00
SDPU: jump
# }

# These commands will be run when use SPL and will be skipped if no spl
# if (SPL support SDPV)
# {
SDPV: delay 1000
SDPV: write -f _flash.bin -skipspl
SDPV: jump
# }

FB: ucmd setenv fastboot_buffer ${loadaddr}
FB: download -f _Image
FB: ucmd setenv fastboot_buffer ${fdt_addr}
FB: download -f _board.dtb
FB: ucmd setenv fastboot_buffer ${initrd_addr}
FB: download -f _initramfs.cpio.gz.uboot
FB: ucmd setenv nfsroot _nfspath
FB: ucmd setenv bootargs console=${console},${baudrate} nfsroot=${nfsroot} init=/linuxrc root=/dev/nfs
#uncomment below line to stop at initramfs
#FB: ucmd setenv bootargs console=${console},${baudrate} nfsroot=${nfsroot}
FB: acmd ${kboot} ${loadaddr} ${initrd_addr} ${fdt_addr}
FB: done