gen_scatterfile.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/sh
  2. #
  3. # Copyright © 2020 David Woodhouse <[email protected]>
  4. #
  5. # This is free software, licensed under the GNU General Public License v2.
  6. # See /LICENSE for more information.
  7. #
  8. # Generate as "scatter file" for use with the MediaTek SP Flash tool for
  9. # writing images to MediaTek boards. This can be used to write images
  10. # even on a bricked board which has no preloader installed, or broken
  11. # U-Boot.
  12. #
  13. # NOTE: At the time of writing (2020-07-20), the Linux tool linked from
  14. # the front page of https://spflashtool.com/ is out of date and does not
  15. # support MT7623. The newer v5.1916 found on the download page at
  16. # https://spflashtool.com/download/ has been tested on UniElec U7623 and
  17. # Banana Pi R2 from Linux, and does work.
  18. #
  19. SOC=$1
  20. IMAGE=${2%.gz}
  21. PROJECT=${3%-scatter.txt}
  22. DEVICENAME="$4"
  23. cat <<EOF
  24. # OpenWrt eMMC scatter file for ${DEVICENAME}
  25. # For use with SP Flash Tool: https://spflashtool.com/download/
  26. #
  27. # Unzip the file system file ${PROJECT}-${IMAGE}.gz before flashing.
  28. # Connect the device's USB port, although it won't appear to the host yet.
  29. # Load this scatter file into the SP Flash Tool, select 'Format All + Download'
  30. # After pressing the 'Download' button, power on the board.
  31. # The /dev/ttyACM0 device should appear on USB and the tool should find it.
  32. - general: MTK_PLATFORM_CFG
  33. info:
  34. - config_version: V1.1.2
  35. platform: ${SOC}
  36. project: ${PROJECT}
  37. storage: EMMC
  38. boot_channel: MSDC_0
  39. block_size: 0x20000
  40. - partition_index: SYS0
  41. partition_name: PRELOADER
  42. file_name: ${PROJECT}-preloader.bin
  43. is_download: true
  44. type: SV5_BL_BIN
  45. linear_start_addr: 0x0
  46. physical_start_addr: 0x0
  47. partition_size: 0x40000
  48. region: EMMC_BOOT_1
  49. storage: HW_STORAGE_EMMC
  50. boundary_check: true
  51. is_reserved: false
  52. operation_type: BOOTLOADERS
  53. d_type: FALSE
  54. reserve: 0x00
  55. - partition_index: SYS1
  56. partition_name: OPENWRT
  57. file_name: ${PROJECT}-${IMAGE}
  58. is_download: true
  59. type: NORMAL_ROM
  60. linear_start_addr: 0x00000
  61. physical_start_addr: 0x00000
  62. partition_size: 0x4000000
  63. region: EMMC_USER
  64. storage: HW_STORAGE_EMMC
  65. boundary_check: true
  66. is_reserved: false
  67. operation_type: UPDATE
  68. d_type: FALSE
  69. reserve: 0x00
  70. EOF