| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | # |
| 3 | # SPDX-License-Identifier: GPL-2.0-only |
| 4 | |
| 5 | file_type_mma="mma" |
| 6 | flashrom_temp_image=/tmp/flash_image_mma.binscip-shell filesystem . . `/tmp/flash_image_mma.bin`. |
| 7 | mma_test_metadata_bin=mma_test_metadata.bin |
| 8 | mma_test_metadata_bin_path=/tmp/"${mma_test_metadata_bin}" |
| 9 | |
| 10 | printf_separatorscip-shell shell coreboot 25.09+dfsg-1 printf_separator().() { |
| 11 | printfscip-shell system . . printf. '=%.0s' {1..80} |
| 12 | printfscip-shell system . . printf. '\n' |
| 13 | } |
| 14 | |
| 15 | show_usagescip-shell shell coreboot 25.09+dfsg-1 show_usage().() { |
| 16 | printfscip-shell system . . printf. "MMA blobs version : 2.1018\n" |
| 17 | printfscip-shell system . . printf. "usage: $(basenamescip-shell system . . basename. "${0}") %s\n" \ |
| 18 | "set [<mma_test_name_efi> <mma_test_param_bin>] | reset" |
| 19 | printfscip-shell system . . printf. '=%.0s' {1..29} |
| 20 | printfscip-shell system . . printf. "All possible MMA tests" |
| 21 | printfscip-shell system . . printf. '=%.0s' {1..29} |
| 22 | printfscip-shell system . . printf. "\n" |
| 23 | printf_separatorscip-shell shell coreboot 25.09+dfsg-1 printf_separator(). |
| 24 | printfscip-shell system . . printf. "Test Name \tMargin1D.efi\n" |
| 25 | printfscip-shell system . . printf. "Test Config\n" |
| 26 | printfscip-shell system . . printf. "\t\t%s %s\n" \ |
| 27 | Margin1DCkAllConfig.bin \ |
| 28 | Margin1DCmdAllConfig.bin \ |
| 29 | Margin1DCmdVrefConfig.bin \ |
| 30 | Margin1DCtlAllConfig.bin \ |
| 31 | Margin1DRxDqsDelayConfig.bin \ |
| 32 | Margin1DRxVrefConfig.bin \ |
| 33 | Margin1DTxDqDelayConfig.bin \ |
| 34 | Margin1DTxVrefConfig.bin |
| 35 | printf_separatorscip-shell shell coreboot 25.09+dfsg-1 printf_separator(). |
| 36 | printfscip-shell system . . printf. "Test Name \tMargin2D.efi\n" |
| 37 | printfscip-shell system . . printf. "Test Config\n" |
| 38 | printfscip-shell system . . printf. "\t\t%s %s\n" \ |
| 39 | Margin2D_Cmd_Ch0_D0_R0_Config.bin \ |
| 40 | Margin2D_Cmd_Ch0_D1_R0_Config.bin \ |
| 41 | Margin2D_Cmd_Ch1_D0_R0_Config.bin \ |
| 42 | Margin2D_Cmd_Ch1_D1_R0_Config.bin \ |
| 43 | Margin2D_Rx_Ch0_D0_R0_Config.bin \ |
| 44 | Margin2D_Rx_Ch0_D0_R1_Config.bin \ |
| 45 | Margin2D_Rx_Ch0_D1_R0_Config.bin \ |
| 46 | Margin2D_Rx_Ch0_D1_R1_Config.bin \ |
| 47 | Margin2D_Rx_Ch1_D0_R0_Config.bin \ |
| 48 | Margin2D_Rx_Ch1_D0_R1_Config.bin \ |
| 49 | Margin2D_Rx_Ch1_D1_R0_Config.bin \ |
| 50 | Margin2D_Rx_Ch1_D1_R1_Config.bin \ |
| 51 | Margin2D_Tx_Ch0_D0_R0_Config.bin \ |
| 52 | Margin2D_Tx_Ch0_D0_R1_Config.bin \ |
| 53 | Margin2D_Tx_Ch0_D1_R0_Config.bin \ |
| 54 | Margin2D_Tx_Ch0_D1_R1_Config.bin \ |
| 55 | Margin2D_Tx_Ch1_D0_R0_Config.bin \ |
| 56 | Margin2D_Tx_Ch1_D0_R1_Config.bin \ |
| 57 | Margin2D_Tx_Ch1_D1_R0_Config.bin \ |
| 58 | Margin2D_Tx_Ch1_D1_R1_Config.bin |
| 59 | printf_separatorscip-shell shell coreboot 25.09+dfsg-1 printf_separator(). |
| 60 | printfscip-shell system . . printf. "Test name \tMarginMapper.efi\n" |
| 61 | printfscip-shell system . . printf. "Test Config\n" |
| 62 | printfscip-shell system . . printf. "\t\t%s %s\n" \ |
| 63 | MarginMapperRxVref-RxDqsDelayConfigVCh0ACh0_single_ch.bin \ |
| 64 | MarginMapperRxVref-RxDqsDelayConfigVCh0ACh1_dual_ch.bin \ |
| 65 | MarginMapperRxVref-RxDqsDelayConfigVCh1ACh0_dual_ch.bin \ |
| 66 | MarginMapperRxVref-RxDqsDelayConfigVCh1ACh1_single_ch.bin \ |
| 67 | MarginMapperTxVref-TxDqDelayConfigVCh0ACh0_single_ch.bin \ |
| 68 | MarginMapperTxVref-TxDqDelayConfigVCh0ACh1_dual_ch.bin \ |
| 69 | MarginMapperTxVref-TxDqDelayConfigVCh1ACh0_dual_ch.bin \ |
| 70 | MarginMapperTxVref-TxDqDelayConfigVCh1ACh1_single_ch.bin \ |
| 71 | ScoreRxVref-RxDqsDelayConfigVCh0ACh0_single_ch.bin \ |
| 72 | ScoreRxVref-RxDqsDelayConfigVCh0ACh1_dual_ch.bin \ |
| 73 | ScoreRxVref-RxDqsDelayConfigVCh1ACh0_dual_ch.bin \ |
| 74 | ScoreRxVref-RxDqsDelayConfigVCh1ACh1_single_ch.bin \ |
| 75 | ScoreTxVref-TxDqDelayConfigVCh0ACh0_single_ch.bin \ |
| 76 | ScoreTxVref-TxDqDelayConfigVCh0ACh1_dual_ch.bin \ |
| 77 | ScoreTxVref-TxDqDelayConfigVCh1ACh0_dual_ch.bin \ |
| 78 | ScoreTxVref-TxDqDelayConfigVCh1ACh1_single_ch.bin |
| 79 | printf_separatorscip-shell shell coreboot 25.09+dfsg-1 printf_separator(). |
| 80 | printfscip-shell system . . printf. "Test Name \tRMT.efi\n" |
| 81 | printfscip-shell system . . printf. "Test Config\n" |
| 82 | printfscip-shell system . . printf. "\t\t%s %s\n" \ |
| 83 | RMTConfig.bin |
| 84 | printf_separatorscip-shell shell coreboot 25.09+dfsg-1 printf_separator(). |
| 85 | } |
| 86 | |
| 87 | write_flashscip-shell shell coreboot 25.09+dfsg-1 write_flash().() { |
| 88 | printfscip-shell system . . printf. "Writing back flash contents "${flashrom_temp_image}"\n" |
| 89 | flashrom -p internal -w "${flashrom_temp_image}" --noverify-all || \ |
| 90 | { |
| 91 | printfscip-shell system . . printf. "failed to read flash\n" ; |
| 92 | exit -1; |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | remove_file_if_existsscip-shell shell coreboot 25.09+dfsg-1 remove_file_if_exists().() { |
| 97 | if [scip-shell system . . `[`. -f "${1}" ]; then |
| 98 | printfscip-shell system . . printf. "removing old "${1}"\n" |
| 99 | rmscip-shell system . . rm. -f "${1}" |
| 100 | fi |
| 101 | } |
| 102 | |
| 103 | remove_metadatascip-shell shell coreboot 25.09+dfsg-1 remove_metadata().() { |
| 104 | printfscip-shell system . . printf. "Removing "${mma_test_metadata_bin}" from "${flashrom_temp_image}"\n" |
| 105 | cbfstool "${flashrom_temp_image}" remove -n ${mma_test_metadata_bin} |
| 106 | outout=$(cbfstool "${flashrom_temp_image}" print | \ |
| 107 | grep ${mma_test_metadata_bin}) |
| 108 | |
| 109 | if [scip-shell system . . `[`. -z "${outout}" ];then |
| 110 | prscip-shell system . . printf.intfscip-shell system . . printf. "Removed ${mma_test_metadata_bin} from %s\n" \ |
| 111 | "${flashrom_temp_image}" |
| 112 | else |
| 113 | prscip-shell system . . printf.intfscip-shell system . . printf. "Failed to remove ${mma_test_metadata_bin} from %s\n" \ |
| 114 | "${flashrom_temp_image}" |
| 115 | print_failedscip-shell shell coreboot 25.09+dfsg-1 print_failed(). |
| 116 | exit -1; |
| 117 | fi |
| 118 | } |
| 119 | |
| 120 | generate_metadatascip-shell shell coreboot 25.09+dfsg-1 generate_metadata().() { |
| 121 | remove_file_if_existsscip-shell shell coreboot 25.09+dfsg-1 remove_file_if_exists(). "${mma_test_metadata_bin_path}" |
| 122 | |
| 123 | printfscip-shell system . . printf. "Creating "${mma_test_metadata_bin_path}"\n" |
| 124 | # |
| 125 | #Format of $mma_test_metadata_bin |
| 126 | #MMA_TEST_NAME=xxxxxx.efi;MMA_TEST_PARAM=xxxxxx.bin; |
| 127 | # |
| 128 | printfscip-shell system . . printf. "MMA_TEST_NAME=${mma_test_name};MMA_TEST_PARAM=${mma_test_param};" \ |
| 129 | > "${mma_test_metadata_bin_path}" |
| 130 | } |
| 131 | |
| 132 | add_metadata_to_flashfilescip-shell shell coreboot 25.09+dfsg-1 add_metadata_to_flashfile().() { |
| 133 | cbfstool "${flashrom_temp_image}" add -f "${mma_test_metadata_bin_path}" \ |
| 134 | -n ${mma_test_metadata_bin} -t ${file_type_mma} || \ |
| 135 | { |
| 136 | printfscip-shell system . . printf. "failed to add "${mma_test_metadata_bin_path}"\n" ; |
| 137 | exit -1; |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | cleanupscip-shell shell coreboot 25.09+dfsg-1 cleanup().() { |
| 142 | remove_file_if_existsscip-shell shell coreboot 25.09+dfsg-1 remove_file_if_exists(). "${flashrom_temp_image}" |
| 143 | remove_file_if_existsscip-shell shell coreboot 25.09+dfsg-1 remove_file_if_exists(). "${mma_test_metadata_bin_path}" |
| 144 | } |
| 145 | |
| 146 | print_successscip-shell shell coreboot 25.09+dfsg-1 print_success().() { |
| 147 | printfscip-shell system . . printf. "============== SUCCESS ==============\n" |
| 148 | } |
| 149 | |
| 150 | print_failedscip-shell shell coreboot 25.09+dfsg-1 print_failed().() { |
| 151 | printfscip-shell system . . printf. "============== FAILED ==============\n" |
| 152 | } |
| 153 | |
| 154 | # |
| 155 | # main entry point |
| 156 | # |
| 157 | |
| 158 | mainscip-shell shell coreboot 25.09+dfsg-1 main().() { |
| 159 | case "${#}:${1}" in |
| 160 | (3:set) |
| 161 | mma_test_name=${2} |
| 162 | mma_test_param=${3} |
| 163 | ;; |
| 164 | (1:reset) |
| 165 | ;; |
| 166 | (*) |
| 167 | show_usagescip-shell shell coreboot 25.09+dfsg-1 show_usage(). |
| 168 | exit -1 |
| 169 | esac |
| 170 | |
| 171 | if [scip-shell system . . `[`. "${1}" != "reset" ];then |
| 172 | printfscip-shell system . . printf. "mma_test_name = ${mma_test_name}\n" |
| 173 | printfscip-shell system . . printf. "mma_test_param = ${mma_test_param}\n" |
| 174 | fi |
| 175 | |
| 176 | remove_file_if_existsscip-shell shell coreboot 25.09+dfsg-1 remove_file_if_exists(). "${flashrom_temp_image}" |
| 177 | |
| 178 | printfscip-shell system . . printf. "Reading flash contents to "${flashrom_temp_image}"\n" |
| 179 | flashrom -p internal -r "${flashrom_temp_image}" || \ |
| 180 | { |
| 181 | printfscip-shell system . . printf. "failed to read flash\n" ; |
| 182 | exit -1; |
| 183 | } |
| 184 | |
| 185 | outdata=$(cbfstool "${flashrom_temp_image}" print | \ |
| 186 | grep ${mma_test_metadata_bin}) |
| 187 | |
| 188 | case "$1" in |
| 189 | ("set") |
| 190 | [scip-shell system . . `[`. "${outdata}" ] && remove_metadatascip-shell shell coreboot 25.09+dfsg-1 remove_metadata(). |
| 191 | generate_metadatascip-shell shell coreboot 25.09+dfsg-1 generate_metadata(). |
| 192 | add_metadata_to_flashfilescip-shell shell coreboot 25.09+dfsg-1 add_metadata_to_flashfile(). |
| 193 | write_flashscip-shell shell coreboot 25.09+dfsg-1 write_flash(). |
| 194 | ;; |
| 195 | ("reset") |
| 196 | if [scip-shell system . . `[`. -z "${outdata}" ];then |
| 197 | printfscip-shell system . . printf. "${mma_test_metadata_bin} not found at all.\n" |
| 198 | else |
| 199 | remove_metadatascip-shell shell coreboot 25.09+dfsg-1 remove_metadata(). |
| 200 | write_flashscip-shell shell coreboot 25.09+dfsg-1 write_flash(). |
| 201 | fi |
| 202 | ;; |
| 203 | esac |
| 204 | cleanupscip-shell shell coreboot 25.09+dfsg-1 cleanup(). |
| 205 | print_successscip-shell shell coreboot 25.09+dfsg-1 print_success(). |
| 206 | } |
| 207 | |
| 208 | mainscip-shell shell coreboot 25.09+dfsg-1 main(). "$@" |