-
Notifications
You must be signed in to change notification settings - Fork 1
/
uboot.env
71 lines (60 loc) · 5.94 KB
/
uboot.env
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
bootargs_common=console=ttyS0,115200 earlyprintk rootwait consoleblank=0 net.ifnames=0 biosdevname=0
mmc_kernel=zImage
mmc_fdt=devicetree.dtb
mmc_bootpart=2
mmc_rootpart=3
nand_fdt_offset=0x80000
nand_fdt_length=0x4000
nand_kernel_offset=0x100000
nand_kernel_length=0x700000
nand_rootpart=3
nand_overlaypart=4
sf_fdt_offset=0x70000
sf_fdt_length=0x10000
sf_kernel_offset=0x80000
sf_kernel_length=0x580000
sf_rootpart=3
sf_overlaypart=4
stderr=serial,vga
stdin=serial
stdout=serial,vga
kernel_addr_r=0x80000000
fdt_addr_r=0x80700000
ramdisk_addr_r=0x80708000
bootm_size=0x1700000
boot_slot_0=empty
boot_slot_1=empty
scan_boot_slot_0=if mmc dev 0; then setenv boot_slot_0 mmc0; fi;
scan_boot_slot_1=if mmc dev 1; then setenv boot_slot_1 mmc1; else if sf probe; then setenv boot_slot_1 spi-nor; else if mtd list; then setenv boot_slot_1 spi-nand; fi; fi; fi;
scan_boot_slot=run scan_boot_slot_0; run scan_boot_slot_1; echo "========================="; echo "Boot Device: ${boot_device}"; echo "Boot Slot 0: ${boot_slot_0}"; echo "Boot Slot 1: ${boot_slot_1}"; echo "=========================";
dfu_wait_timeout=3
mmc_dfu_info=all raw 0x0 0x38000
nand_dfu_info=all raw 0x0 0x8000000;u-boot raw 0x0 0x80000;dtb raw 0x80000 0x20000;kernel raw 0x100000 0x700000;rom raw 0x800000 0x7000000
nor_dfu_info=all raw 0x0 0x1000000;u-boot raw 0x0 0x70000;dtb raw 0x70000 0x10000;kernel raw 0x80000 0x580000;rom raw 0x600000 0x700000
dfu_mmc=setenv dfu_alt_info "${mmc_dfu_info}"; dfu 0 mmc ${dfu_mmc_dev} ${dfu_wait_timeout};
dfu_nand=setenv dfu_alt_info "${nand_dfu_info}"; dfu 0 mtd spi-nand0 ${dfu_wait_timeout};
dfu_nor=setenv dfu_alt_info "${nor_dfu_info}"; dfu 0 sf 0:0 ${dfu_wait_timeout};
dfu_boot=if test "${boot_slot_1}" = "spi-nand"; then echo "DFU waiting on SPI-NAND..."; run dfu_nand; fi; if test "${boot_slot_1}" = "spi-nor"; then echo "DFU waiting on SPI-NOR..."; run dfu_nor; fi; if test "${boot_slot_1}" = "mmc1"; then echo "DFU waiting on MMC1..."; setenv dfu_mmc_dev 1; run dfu_mmc; fi; if test "${boot_slot_1}" = "empty" && test "${boot_slot_0}" = "mmc0"; then echo "DFU waiting on MMC0..."; setenv dfu_mmc_dev 0; run dfu_mmc; fi;
flasher_ptr_counter=0x80000000
flasher_ptr_buffer=0x80000004
flasher_size_buffer=0x800000
flasher_nandimage=sysimage-nand.img
flasher_norimage=sysimage-nor.img
flash_nand=size mmc 0:${mmc_bootpart} ${flasher_nandimage}; setexpr size_image ${filesize}; mw ${flasher_ptr_counter} ${size_image}; mtd erase spi-nand0; flasher_offset=0; while itest *${flasher_ptr_counter} > 0; do if itest ${size_image} > ${flasher_size_buffer}; then blocksize=${flasher_size_buffer}; else blocksize=0x${size_image}; fi; setexpr size_image ${size_image} - ${blocksize}; mw ${flasher_ptr_counter} ${size_image}; load mmc 0:${mmc_bootpart} ${flasher_ptr_buffer} ${flasher_nandimage} ${flasher_size_buffer} ${flasher_offset}; mtd write spi-nand0 ${flasher_ptr_buffer} ${flasher_offset} ${flasher_size_buffer}; setexpr flasher_offset ${flasher_offset} + ${blocksize}; done;
flash_nor=size mmc 0:${mmc_bootpart} ${flasher_norimage}; setexpr size_image ${filesize}; mw ${flasher_ptr_counter} ${size_image}; flasher_offset=0; while itest *${flasher_ptr_counter} > 0; do if itest ${size_image} > ${flasher_size_buffer}; then blocksize=${flasher_size_buffer}; else blocksize=0x${size_image}; fi; setexpr size_image ${size_image} - ${blocksize}; mw ${flasher_ptr_counter} ${size_image}; load mmc 0:${mmc_bootpart} ${flasher_ptr_buffer} ${flasher_norimage} ${flasher_size_buffer} ${flasher_offset}; sf update ${flasher_ptr_buffer} ${flasher_offset} ${flasher_size_buffer}; setexpr flasher_offset ${flasher_offset} + ${blocksize}; done;
flasher_boot=if test -e mmc 0:${mmc_bootpart} ${flasher_norimage}; then if test "${boot_slot_1}" = "spi-nor"; then echo "Flashing SPI-NOR from MMC0..."; run flash_nor; run nor_boot; fi; fi; if test -e mmc 0:${mmc_bootpart} ${flasher_nandimage}; then if test "${boot_slot_1}" = "spi-nand"; then echo "Flashing SPI-NAND from MMC0..."; run flash_nand; run nand_boot; fi; fi;
genbootargs=setenv bootargs ${bootargs_common} root=/dev/mmcblk0p3;
fel_boot=echo "Booting from FEL..."; rootdev=/dev/ram0; run genbootargs; bootz ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r};
mmc_boot=mmc dev ${devnum}; echo "Booting from MMC${devnum}..."; rootdev=/dev/mmcblk${devnum}p${mmc_rootpart}; run genbootargs; load mmc ${devnum}:${mmc_bootpart} $kernel_addr_r ${mmc_kernel}; load mmc ${devnum}:${mmc_bootpart} ${fdt_addr_r} ${mmc_fdt}; bootz ${kernel_addr_r} - ${fdt_addr_r};
nor_boot=echo "Booting from SPI-NOR..."; sf probe; sf read ${fdt_addr_r} ${sf_fdt_offset} ${sf_fdt_length}; sf read ${kernel_addr_r} ${sf_kernel_offset} ${sf_kernel_length}; rootdev=/dev/mtdblock${sf_rootpart}; overlayfs_config="overlayfsdev=/dev/mtdblock${sf_overlaypart}"; run genbootargs; bootz ${kernel_addr_r} - ${fdt_addr_r};
nand_boot=echo "Booting from SPI-NAND..."; mtd read spi-nand0 ${fdt_addr_r} ${nand_fdt_offset} ${nand_fdt_length}; mtd read spi-nand0 ${kernel_addr_r} ${nand_kernel_offset} ${nand_kernel_length}; rootdev=/dev/mtdblock${nand_rootpart}; overlayfs_config="overlayfsdev=/dev/mtdblock${nand_overlaypart}"; run genbootargs; bootz ${kernel_addr_r} - ${fdt_addr_r};
nor_nand_boot=if test "${boot_slot_1}" = "spi-nor"; then run nor_boot; fi; if test "${boot_slot_1}" = "spi-nand"; then run nand_boot; fi;
bootcmd_fel=if test "${boot_device}" = "fel"; then run fel_boot; fi;
bootcmd_dfu=if test "${boot_device}" != "mmc0" || test "${boot_slot_1}" = "empty"; then run dfu_boot; fi;
bootcmd_flasher=if test "${boot_device}" = "mmc0"; then run flasher_boot; fi;
bootcmd_mmc0=if test "${boot_device}" = "mmc0"; then devnum=0; run mmc_boot; fi;
bootcmd_mmc1=if test "${boot_device}" = "mmc1"; then devnum=1; run mmc_boot; fi;
bootcmd_spi=if test "${boot_device}" = "spi"; then run nor_nand_boot; fi;
bootcmd_ums=if test "${boot_slot_0}" = "mmc0"; then echo "Emulating SD Reader on MMC0..."; ums 0 mmc 0:0; fi;
boot_targets=fel dfu flasher mmc0 mmc1 spi ums
bootcmd=run scan_boot_slot; for target in ${boot_targets}; do run bootcmd_${target}; done