gen_scatterfile.sh 2.1 KB

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