blob: f4e381994bef87babaabbaff3bdd3b3ebb403ad6 [file] [log] [blame]
Svyatoslav Ryhel41d86e72024-06-24 20:13:47 +03001boot_block_size_r=0x200000
2boot_block_size=0x1000
3bootloader_file=u-boot-dtb-tegra.bin
4spi_size=0x400000
5boot_dev=0
6
7flash_uboot=echo Preparing RAM;
8 mw ${kernel_addr_r} 0 ${boot_block_size_r};
9 mw ${ramdisk_addr_r} 0 ${boot_block_size_r};
10 echo Reading BCT;
11 mmc dev 0 1;
12 mmc read ${kernel_addr_r} 0 ${boot_block_size};
13 echo Reading bootloader;
14 if load mmc ${boot_dev}:1 ${ramdisk_addr_r} ${bootloader_file};
15 then echo Calculating bootloader size;
16 size mmc ${boot_dev}:1 ${bootloader_file};
17 ebtupdate ${kernel_addr_r} ${ramdisk_addr_r} ${filesize};
18 echo Writing bootloader to eMMC;
19 mmc dev 0 1;
20 mmc write ${kernel_addr_r} 0 ${boot_block_size};
21 mmc dev 0 2;
22 mmc write ${ramdisk_addr_r} 0 ${boot_block_size};
23 echo Bootloader written successfully;
24 pause 'Press ANY key to reboot device...'; reset;
25 else echo Reading bootloader failed;
26 pause 'Press ANY key to return to bootmenu...'; bootmenu; fi
27
28update_spi=sf probe 0:1;
29 echo Dumping current SPI flash content ...;
30 sf read ${kernel_addr_r} 0x0 ${spi_size};
31 if fatwrite mmc 1:1 ${kernel_addr_r} spi-flash-backup.bin ${spi_size};
32 then echo SPI flash content was successfully written into spi-flash-backup.bin;
33 echo Reading SPI flash binary;
34 if load mmc 1:1 ${kernel_addr_r} repart-block.bin;
35 then echo Writing bootloader into SPI flash;
36 sf probe 0:1;
37 sf update ${kernel_addr_r} 0x0 ${spi_size};
38 echo Bootloader SUCCESSFULLY written into SPI flash;
39 pause 'Press ANY key to reboot...'; reset;
40 else echo Preparing RAM;
41 mw ${kernel_addr_r} 0 ${boot_block_size_r};
42 mw ${ramdisk_addr_r} 0 ${boot_block_size_r};
43 echo Reading BCT;
44 sf read ${kernel_addr_r} 0x0 ${boot_block_size_r};
45 echo Reading bootloader;
46 if load mmc 1:1 ${ramdisk_addr_r} ${bootloader_file};
47 then echo Calculating bootloader size;
48 size mmc 1:1 ${bootloader_file};
49 ebtupdate ${kernel_addr_r} ${ramdisk_addr_r} ${filesize};
50 echo Writing bootloader into SPI flash;
51 sf probe 0:1;
52 sf update ${kernel_addr_r} 0x0 ${boot_block_size_r};
53 sf update ${ramdisk_addr_r} ${boot_block_size_r} ${boot_block_size_r};
54 echo Bootloader written SUCCESSFULLY;
55 pause 'Press ANY key to reboot...'; reset;
56 else echo Reading bootloader failed;
57 pause 'Press ANY key to reboot...'; reset; fi;
58 fi;
59 else echo SPI flash backup FAILED! Aborting ...;
60 pause 'Press ANY key to reboot...'; reset; fi