| rjw | 91288f9 | 2022-11-01 13:59:36 +0800 | [diff] [blame^] | 1 | # SPDX-License-Identifier: MediaTekProprietary |
| 2 | |
| 3 | #!/usr/bin/python |
| 4 | import os |
| 5 | |
| 6 | procedures = { |
| 7 | # product : fastboot args |
| 8 | 'DEFAULT': [['fbWait'], |
| 9 | ['fastboot', 'flash', 'EMPTY', 'hsm_bl.img'], |
| 10 | ['fastboot', 'continue'], |
| 11 | ['fbWait'], |
| 12 | ['fastboot', 'flash', 'EMPTY', 'bl2.img'], |
| 13 | ['fastboot', 'continue'], |
| 14 | ['fbWait'], |
| 15 | ['fastboot', 'flash', 'download:tz', 'tee.img'], |
| 16 | ['fastboot', 'flash', 'download:bl33', 'bl33.img'], |
| 17 | ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'], |
| 18 | ['fastboot', 'flash', 'download:mcupm', 'mcupm.img'], |
| 19 | ['fastboot', 'flash', 'download:medmcu', 'medmcu.img'], |
| 20 | ['fastboot', 'flash', 'download:sspm', 'sspm.img'], |
| 21 | ['fastboot', 'flash', 'download:dpm', 'dpm.img'], |
| 22 | ['fastboot', 'flash', 'download:hsmos', 'hsm_os.img'], |
| 23 | ['fastboot', 'oem', 'continue'], |
| 24 | ['fbWait'], |
| 25 | ['fastboot', 'erase', 'nand0'], |
| 26 | ['fastboot', 'flash', 'nand0', 'MBR_NAND'], |
| 27 | ['fastboot', 'flash', 'bl2', 'bl2.img'], |
| 28 | ['fastboot', 'flash', 'bl33', 'bl33.img'], |
| 29 | ['fastboot', 'flash', 'spm_a', 'spmfw.img'], |
| 30 | ['fastboot', 'flash', 'spm_b', 'spmfw.img'], |
| 31 | ['fastboot', 'flash', 'dtbo', 'combo.dtbo'], |
| 32 | ['fastboot', 'flash', 'hsm_bl', 'hsm_bl.img'], |
| 33 | ['fastboot', 'flash', 'hsm_os', 'hsm_os.img'], |
| 34 | ['fastboot', 'flash', 'proinfo', 'sncfg.ubi'], |
| 35 | ['fastboot', 'flash', 'boot_a', 'boot.img'], |
| 36 | ['fastboot', 'flash', 'boot_b', 'boot.img'], |
| 37 | ['fastboot', 'flash', 'system_a', 'system.img'], |
| 38 | ['fastboot', 'flash', 'system_b', 'system.img'], |
| 39 | ['fastboot', 'flash', 'md1img_a', 'md1img.img'], |
| 40 | ['fastboot', 'flash', 'md1img_b', 'md1img.img'], |
| 41 | ['fastboot', 'flash', 'md1dsp_a', 'md1dsp.img'], |
| 42 | ['fastboot', 'flash', 'md1dsp_b', 'md1dsp.img'], |
| 43 | ['fastboot', 'flash', 'tee_a', 'tee.img'], |
| 44 | ['fastboot', 'flash', 'tee_b', 'tee.img'], |
| 45 | ['fastboot', 'flash', 'nvram', 'nvram.ubi'], |
| 46 | ['fastboot', 'flash', 'mcupm', 'mcupm.img'], |
| 47 | ['fastboot', 'flash', 'medmcu', 'medmcu.img'], |
| 48 | ['fastboot', 'flash', 'sspm', 'sspm.img'], |
| 49 | ['fastboot', 'flash', 'dpm', 'dpm.img'], |
| 50 | ['fastboot', 'flash', 'userdata', 'userdata.img'], |
| 51 | ['fastboot', 'flash', 'vbmeta_a', 'vbmeta.img'], |
| 52 | ['fastboot', 'flash', 'vbmeta_b', 'vbmeta.img']] |
| 53 | } |
| 54 | |
| 55 | userprocedures = { |
| 56 | # product : fastboot args |
| 57 | 'DEFAULT': [['fbWait'], |
| 58 | ['fastboot', 'flash', 'EMPTY', 'hsm_bl.img'], |
| 59 | ['fastboot', 'continue'], |
| 60 | ['fbWait'], |
| 61 | ['fastboot', 'flash', 'EMPTY', 'bl2.img'], |
| 62 | ['fastboot', 'continue'], |
| 63 | ['fbWait'], |
| 64 | ['fastboot', 'flash', 'download:tz', 'tee.img'], |
| 65 | ['fastboot', 'flash', 'download:bl33', 'bl33.img'], |
| 66 | ['fbWait'], |
| 67 | ['fastboot', 'erase', 'system_a'], |
| 68 | ['fastboot', 'flash', 'system_a', 'system.img'], |
| 69 | ['fastboot', 'oem', 'set_active', '0']] |
| 70 | } |
| 71 | |
| 72 | bootprocedures = { |
| 73 | # product : fastboot args |
| 74 | 'DEFAULT': [['fbWait'], |
| 75 | ['fastboot', 'flash', 'EMPTY', 'hsm_bl.img'], |
| 76 | ['fastboot', 'continue'], |
| 77 | ['fbWait'], |
| 78 | ['fastboot', 'flash', 'EMPTY', 'bl2.img'], |
| 79 | ['fastboot', 'continue'], |
| 80 | ['fbWait'], |
| 81 | ['fastboot', 'flash', 'download:tz', 'tee.img'], |
| 82 | ['fastboot', 'flash', 'download:bl33', 'bl33.img'], |
| 83 | ['fastboot', 'flash', 'bl2', 'bl2.img'], |
| 84 | ['fastboot', 'flash', 'bl33', 'bl33.img'], |
| 85 | ['fastboot', 'flash', 'boot_a', 'boot.img'], |
| 86 | ['fastboot', 'flash', 'tee_a', 'tee.img'], |
| 87 | ['fastboot', 'oem', 'set_active', '0']] |
| 88 | } |
| 89 | |
| 90 | testprocedures = { |
| 91 | # product : fastboot args |
| 92 | 'DEFAULT': [['fbWait'], |
| 93 | ['fastboot', 'flash', 'EMPTY', 'hsm_bl.img'], |
| 94 | ['fastboot', 'continue'], |
| 95 | ['fbWait'], |
| 96 | ['fastboot', 'flash', 'EMPTY', 'bl2.img'], |
| 97 | ['fastboot', 'continue'], |
| 98 | ['fbWait'], |
| 99 | ['fastboot', 'flash', 'download:tz', 'tee.img'], |
| 100 | ['fastboot', 'flash', 'download:bl33', 'bl33.img'], |
| 101 | ['fastboot', 'oem', 'continue'], |
| 102 | ['fbWait'], |
| 103 | ['fastboot', 'erase', 'bl2'], |
| 104 | ['fastboot', 'flash', 'bl2', 'bl2.img'], |
| 105 | ['fastboot', 'erase', 'bl33'], |
| 106 | ['fastboot', 'flash', 'bl33', 'bl33.img'], |
| 107 | ['fastboot', 'erase', 'dtbo'], |
| 108 | ['fastboot', 'flash', 'dtbo', 'combo.dtbo'], |
| 109 | ['fastboot', 'erase', 'proinfo'], |
| 110 | ['fastboot', 'flash', 'proinfo', 'sncfg.ubi'], |
| 111 | ['fastboot', 'erase', 'boot_a'], |
| 112 | ['fastboot', 'flash', 'boot_a', 'boot.img'], |
| 113 | ['fastboot', 'erase', 'boot_b'], |
| 114 | ['fastboot', 'flash', 'boot_b', 'boot.img'], |
| 115 | ['fastboot', 'erase', 'system_a'], |
| 116 | ['fastboot', 'flash', 'system_a', 'system.img'], |
| 117 | ['fastboot', 'erase', 'system_b'], |
| 118 | ['fastboot', 'flash', 'system_b', 'system.img'], |
| 119 | ['fastboot', 'erase', 'md1img_a'], |
| 120 | ['fastboot', 'flash', 'md1img_a', 'md1img.img'], |
| 121 | ['fastboot', 'erase', 'md1img_b'], |
| 122 | ['fastboot', 'flash', 'md1img_b', 'md1img.img'], |
| 123 | ['fastboot', 'erase', 'md1dsp_a'], |
| 124 | ['fastboot', 'flash', 'md1dsp_a', 'md1dsp.img'], |
| 125 | ['fastboot', 'erase', 'md1dsp_b'], |
| 126 | ['fastboot', 'flash', 'md1dsp_b', 'md1dsp.img'], |
| 127 | ['fastboot', 'erase', 'tee_a'], |
| 128 | ['fastboot', 'flash', 'tee_a', 'tee.img'], |
| 129 | ['fastboot', 'erase', 'tee_b'], |
| 130 | ['fastboot', 'flash', 'tee_b', 'tee.img'], |
| 131 | ['fastboot', 'erase', 'vbmeta_a'], |
| 132 | ['fastboot', 'flash', 'vbmeta_a', 'vbmeta.img'], |
| 133 | ['fastboot', 'erase', 'vbmeta_b'], |
| 134 | ['fastboot', 'flash', 'vbmeta_b', 'vbmeta.img']] |
| 135 | } |
| 136 | |
| 137 | # return procedure list |
| 138 | def getFlashProc(product): |
| 139 | try: |
| 140 | ret = procedures[product.upper()] |
| 141 | return ret |
| 142 | except: |
| 143 | return None |
| 144 | |
| 145 | |
| 146 | def getFlashUserProc(product): |
| 147 | try: |
| 148 | ret = userprocedures[product.upper()] |
| 149 | return ret |
| 150 | except: |
| 151 | return None |
| 152 | |
| 153 | def getFlashBootProc(product): |
| 154 | try: |
| 155 | ret = bootprocedures[product.upper()] |
| 156 | return ret |
| 157 | except: |
| 158 | return None |
| 159 | |
| 160 | def getFlashTestProc(product): |
| 161 | try: |
| 162 | ret = testprocedures[product.upper()] |
| 163 | return ret |
| 164 | except: |
| 165 | return None |