bootscript-gateworks_venice 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # distro-config bootscript
  2. # - use only well-known variable names provided by U-Boot Distro boot
  3. # - devtype - device type script run from (mmc|usb|scsi)
  4. # - devnum - device number script run from (0 based int)
  5. # - distro_bootpart - partition script run from (0 based int)
  6. # - prefix - directory boot script was found in
  7. # - kernel_addr_r - address to load kernel image to
  8. # - fdt_addr_r - address to load dtb to
  9. # - ftdcontroladdr - address dtb is at
  10. # - fdt_file{1,2,3,4,5} name of fdt to load
  11. # - fdt_overlays - list of fdt overlay files to load and apply
  12. echo "Gateworks Venice OpenWrt Boot script v1.0"
  13. # determine root device using PARTUUID:
  14. # - this avoids any difference beteween uboot's device names/numbers
  15. # not matching Linux as device enumeration is not a set API.
  16. # - PARTUUID is disk UUID concatenated with partition number
  17. # - for MBR disk UUID is unique disk id at offset 440
  18. # - for GPT disk UUID is GPT UUID
  19. # - for OpenWrt the squasfs rootfs is not readable by U-Boot so we have
  20. # a 'boot' partition containing bootscript kernel dtbs followed by the rootfs
  21. # partition, therefore we add 1 to the current partition
  22. setexpr rootpart ${distro_bootpart} + 1 # root on 'next' partition
  23. part uuid ${devtype} ${devnum}:${rootpart} uuid
  24. setenv bootargs ${bootargs} console=${console} root=PARTUUID=${uuid} rootfstype=squashfs,ext4,f2fs rootwait pci=noaer
  25. # load dtb (we try fdt_file and then fdt_file{1,2,3,4,5})
  26. echo "loading DTB..."
  27. setenv fdt_addr
  28. setenv fdt_list $fdt_file $fdt_file1 $fdt_file2 $fdt_file3 $fdt_file4 $fdt_file5
  29. setenv load_fdt 'echo Loading $fdt...; load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}${fdt} && setenv fdt_addr ${fdt_addr_r}'
  30. setenv apply_overlays 'fdt addr $fdt_addr_r && for fdt in "$fdt_overlays"; do load ${devtype} ${devnum}:${distro_bootpart} $loadaddr $prefix/$fdt && fdt resize $filesize && fdt apply $loadaddr && echo applied $prefix/$fdt; done'
  31. for fdt in ${fdt_list}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${fdt}; then run load_fdt; fi; done
  32. if test -z "$fdt_addr"; then echo "Warning: Using bootloader DTB"; setenv fdt_addr $fdtcontroladdr; fi
  33. if test -n "$fdt_overlays"; then echo "Applying overlays"; run apply_overlays; fi
  34. if test -n "$fixfdt"; then echo "Adjusting FDT"; run fixfdt; fi
  35. # load and boot kernel
  36. echo "loading kernel..."
  37. load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} ${prefix}Image &&
  38. booti ${kernel_addr_r} - ${fdt_addr}