# <- this is for comment / total file size must be less than 4KB
# console ok
#For pure PM.bin upgrade, use below part
fatload usb 0:1 0x24000000 mb130_PM51_connected.bin
spi_wrc 0x24000000 0x00000000 $(filesize)
#For pure RomBoot.bin (include mboot.bin) upgrade, use below part
fatload usb 0:1 0x24000000 mb130_RomBoot_AMZ.bin;
ncishash 0x24000000 0x24010000 0x24020000 0x24030000 0x3800 0x24033800 0x200000
#---------------------------------------------------------------------
### check file exist or not
fatpartload usb 0:1 0x21000000 mb130_en.bin 0x0 0x500000
#---------------------------------------------------------------------
### check file size. If does not match "ustar" will fail and reset without update
fatfilesize usb 0:1 mb130_en.bin
test F304810 = $(filesize)
nand erase.chip
#--------------------------------------------------------------------
#set partition
dynpart edb64M-nand:0xA00000(KL),0x2800000(CONF),0x2400000(UBIA),0xA400000(VENDOR),0xEF00000(UBIB),0x900000(tee),-(NA)
saveenv
ubi part UBIA
ubi create RFS 0x1E00000
#---------------------------------------------------------------------
### direct write linux kernel image
fatpartload usb 0:1 0x21000000 mb130_en.bin 0x0 0x700000
aesdec 0x21000000 0x700000
nand erase.part KL
nand write.e 0x21000010 KL 0x700000
#setenv bootcmd nand read.e 0x205FFFC0 KL $(filesize)\; bootm 0x205FFFC0
#saveenv
#---------------------------------------------------------------------
#ROOTFS
fatpartload usb 0:1 0x21000000 mb130_en.bin 0x700000 0x1A00000
aesdec 0x21000000 0x1A00000
ubi part UBIA
ubi write 0x21000010 RFS 0x1A00000
fatpartload usb 0:1 0x21000000 mb130_en.bin 0x2100000 0x9A00000
aesdec 0x21000000 0x9A00000
nand erase.part VENDOR
nand write.e 0x21000010 VENDOR 0x9A00000
ubi part CONF
ubi create CON 0x1E00000
fatpartload usb 0:1 0x21000000 mb130_en.bin 0xBB00000 0x1E00000
aesdec 0x21000000 0x1E00000
ubi write 0x21000010 CON 0x1E00000
ubi part UBIB
ubi create BUF 0xBF00000
ubi create APD 0x2100000
fatpartload usb 0:1 0x21000000 mb130_en.bin 0xD900000 0x1100000
aesdec 0x21000000 0x1100000
ubi write 0x21000010 APD 0x1100000
#-------
# in order to set /buffer mode=777, it needs to create a ubifs image, and update it to BUF
# without this, /buffer will be mode=755
fatpartload usb 0:1 0x21000000 mb130_en.bin 0xEF04800 0x400000
aesdec 0x21000000 0x400000
ubi write 0x21000010 BUF 0x400000
#---------------------------------------------------------------------
#TEE
#fatpartload usb 0:1 0x21000000 mb130_en.bin 0xEA00000 0x502210
fatpartload usb 0:1 0x21000000 mb130_en.bin 0xEA00000 0x504800
aesdec 0x21000000 0x504210
nand erase.part tee
nand write.e 0x21000010 tee 0x500000
store_secure_info kernelSign 0x21501010
store_secure_info teeSign 0x21501230
store_secure_info RFSSign 0x21501450
store_secure_info APPSign 0x21502550
#setenv LOAD_NUTTX nand read.e 0x50000000 tee 0x600000\;
#setenv BOOT_NUTTX bootNuttx 0x10000000\;
store_nuttx_config NuttxConfig 0x21500010
#---------------------------------------------------------------------
#Force Mboot to update environment after update
setenv sync_environment 1
saveenv
printenv
reset
% <- this is end of file symbol
# <- this is for comment / total file size must be less than 4KB
# console ok
#For pure PM.bin upgrade, use below part
fatload usb 0:1 0x24000000 mb130_PM51_connected.bin
spi_wrc 0x24000000 0x00000000 $(filesize)
#For pure RomBoot.bin (include mboot.bin) upgrade, use below part
fatload usb 0:1 0x24000000 mb130_RomBoot_AMZ.bin;
ncishash 0x24000000 0x24010000 0x24020000 0x24030000 0x3800 0x24033800 0x200000
#---------------------------------------------------------------------
### check file exist or not
fatpartload usb 0:1 0x21000000 mb130_en.bin 0x0 0x500000
#---------------------------------------------------------------------
### check file size. If does not match "ustar" will fail and reset without update
fatfilesize usb 0:1 mb130_en.bin
test F304810 = $(filesize)
nand erase.chip
#--------------------------------------------------------------------
#set partition
dynpart edb64M-nand:0xA00000(KL),0x2800000(CONF),0x2400000(UBIA),0xA400000(VENDOR),0xEF00000(UBIB),0x900000(tee),-(NA)
saveenv
ubi part UBIA
ubi create RFS 0x1E00000
#---------------------------------------------------------------------
### direct write linux kernel image
fatpartload usb 0:1 0x21000000 mb130_en.bin 0x0 0x700000
aesdec 0x21000000 0x700000
nand erase.part KL
nand write.e 0x21000010 KL 0x700000
#setenv bootcmd nand read.e 0x205FFFC0 KL $(filesize)\; bootm 0x205FFFC0
#saveenv
#---------------------------------------------------------------------
#ROOTFS
fatpartload usb 0:1 0x21000000 mb130_en.bin 0x700000 0x1A00000
aesdec 0x21000000 0x1A00000
ubi part UBIA
ubi write 0x21000010 RFS 0x1A00000
fatpartload usb 0:1 0x21000000 mb130_en.bin 0x2100000 0x9A00000
aesdec 0x21000000 0x9A00000
nand erase.part VENDOR
nand write.e 0x21000010 VENDOR 0x9A00000
ubi part CONF
ubi create CON 0x1E00000
fatpartload usb 0:1 0x21000000 mb130_en.bin 0xBB00000 0x1E00000
aesdec 0x21000000 0x1E00000
ubi write 0x21000010 CON 0x1E00000
ubi part UBIB
ubi create BUF 0xBF00000
ubi create APD 0x2100000
fatpartload usb 0:1 0x21000000 mb130_en.bin 0xD900000 0x1100000
aesdec 0x21000000 0x1100000
ubi write 0x21000010 APD 0x1100000
#-------
# in order to set /buffer mode=777, it needs to create a ubifs image, and update it to BUF
# without this, /buffer will be mode=755
fatpartload usb 0:1 0x21000000 mb130_en.bin 0xEF04800 0x400000
aesdec 0x21000000 0x400000
ubi write 0x21000010 BUF 0x400000
#---------------------------------------------------------------------
#TEE
#fatpartload usb 0:1 0x21000000 mb130_en.bin 0xEA00000 0x502210
fatpartload usb 0:1 0x21000000 mb130_en.bin 0xEA00000 0x504800
aesdec 0x21000000 0x504210
nand erase.part tee
nand write.e 0x21000010 tee 0x500000
store_secure_info kernelSign 0x21501010
store_secure_info teeSign 0x21501230
store_secure_info RFSSign 0x21501450
store_secure_info APPSign 0x21502550
#setenv LOAD_NUTTX nand read.e 0x50000000 tee 0x600000\;
#setenv BOOT_NUTTX bootNuttx 0x10000000\;
store_nuttx_config NuttxConfig 0x21500010
#---------------------------------------------------------------------
#Force Mboot to update environment after update
setenv sync_environment 1
saveenv
printenv
reset
% <- this is end of file symbol