MAINTAINERS: Clarify this is about active upstream development
[coreboot.git] / util / mma / mma_setup_test.sh
blobec7baf92ce06c45a5cfb6b03975af5c8af22af71
1 #!/bin/bash
4 # This file is part of the coreboot project.
6 # Copyright (C) 2017 Intel Corporation.
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; version 2 of the License.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
18 file_type_mma="mma"
19 flashrom_temp_image=/tmp/flash_image_mma.bin
20 mma_test_metadata_bin=mma_test_metadata.bin
21 mma_test_metadata_bin_path=/tmp/"${mma_test_metadata_bin}"
23 printf_separator() {
24 printf '=%.0s' {1..80}
25 printf '\n'
28 show_usage() {
29 printf "MMA blobs version : 2.1018\n"
30 printf "usage: $(basename "${0}") %s\n" \
31 "set [<mma_test_name_efi> <mma_test_param_bin>] | reset"
32 printf '=%.0s' {1..29}
33 printf "All possible MMA tests"
34 printf '=%.0s' {1..29}
35 printf "\n"
36 printf_separator
37 printf "Test Name \tMargin1D.efi\n"
38 printf "Test Config\n"
39 printf "\t\t%s %s\n" \
40 Margin1DCkAllConfig.bin \
41 Margin1DCmdAllConfig.bin \
42 Margin1DCmdVrefConfig.bin \
43 Margin1DCtlAllConfig.bin \
44 Margin1DRxDqsDelayConfig.bin \
45 Margin1DRxVrefConfig.bin \
46 Margin1DTxDqDelayConfig.bin \
47 Margin1DTxVrefConfig.bin
48 printf_separator
49 printf "Test Name \tMargin2D.efi\n"
50 printf "Test Config\n"
51 printf "\t\t%s %s\n" \
52 Margin2D_Cmd_Ch0_D0_R0_Config.bin \
53 Margin2D_Cmd_Ch0_D1_R0_Config.bin \
54 Margin2D_Cmd_Ch1_D0_R0_Config.bin \
55 Margin2D_Cmd_Ch1_D1_R0_Config.bin \
56 Margin2D_Rx_Ch0_D0_R0_Config.bin \
57 Margin2D_Rx_Ch0_D0_R1_Config.bin \
58 Margin2D_Rx_Ch0_D1_R0_Config.bin \
59 Margin2D_Rx_Ch0_D1_R1_Config.bin \
60 Margin2D_Rx_Ch1_D0_R0_Config.bin \
61 Margin2D_Rx_Ch1_D0_R1_Config.bin \
62 Margin2D_Rx_Ch1_D1_R0_Config.bin \
63 Margin2D_Rx_Ch1_D1_R1_Config.bin \
64 Margin2D_Tx_Ch0_D0_R0_Config.bin \
65 Margin2D_Tx_Ch0_D0_R1_Config.bin \
66 Margin2D_Tx_Ch0_D1_R0_Config.bin \
67 Margin2D_Tx_Ch0_D1_R1_Config.bin \
68 Margin2D_Tx_Ch1_D0_R0_Config.bin \
69 Margin2D_Tx_Ch1_D0_R1_Config.bin \
70 Margin2D_Tx_Ch1_D1_R0_Config.bin \
71 Margin2D_Tx_Ch1_D1_R1_Config.bin
72 printf_separator
73 printf "Test name \tMarginMapper.efi\n"
74 printf "Test Config\n"
75 printf "\t\t%s %s\n" \
76 MarginMapperRxVref-RxDqsDelayConfigVCh0ACh0_single_ch.bin \
77 MarginMapperRxVref-RxDqsDelayConfigVCh0ACh1_dual_ch.bin \
78 MarginMapperRxVref-RxDqsDelayConfigVCh1ACh0_dual_ch.bin \
79 MarginMapperRxVref-RxDqsDelayConfigVCh1ACh1_single_ch.bin \
80 MarginMapperTxVref-TxDqDelayConfigVCh0ACh0_single_ch.bin \
81 MarginMapperTxVref-TxDqDelayConfigVCh0ACh1_dual_ch.bin \
82 MarginMapperTxVref-TxDqDelayConfigVCh1ACh0_dual_ch.bin \
83 MarginMapperTxVref-TxDqDelayConfigVCh1ACh1_single_ch.bin \
84 ScoreRxVref-RxDqsDelayConfigVCh0ACh0_single_ch.bin \
85 ScoreRxVref-RxDqsDelayConfigVCh0ACh1_dual_ch.bin \
86 ScoreRxVref-RxDqsDelayConfigVCh1ACh0_dual_ch.bin \
87 ScoreRxVref-RxDqsDelayConfigVCh1ACh1_single_ch.bin \
88 ScoreTxVref-TxDqDelayConfigVCh0ACh0_single_ch.bin \
89 ScoreTxVref-TxDqDelayConfigVCh0ACh1_dual_ch.bin \
90 ScoreTxVref-TxDqDelayConfigVCh1ACh0_dual_ch.bin \
91 ScoreTxVref-TxDqDelayConfigVCh1ACh1_single_ch.bin
92 printf_separator
93 printf "Test Name \tRMT.efi\n"
94 printf "Test Config\n"
95 printf "\t\t%s %s\n" \
96 RMTConfig.bin
97 printf_separator
100 write_flash() {
101 printf "Writing back flash contents "${flashrom_temp_image}"\n"
102 flashrom -p host -w "${flashrom_temp_image}" --fast-verify || \
104 printf "failed to read flash\n" ;
105 exit -1;
109 remove_file_if_exists() {
110 if [ -f "${1}" ]; then
111 printf "removing old "${1}"\n"
112 rm -f "${1}"
116 remove_metadata() {
117 printf "Removing "${mma_test_metadata_bin}" from "${flashrom_temp_image}"\n"
118 cbfstool "${flashrom_temp_image}" remove -n ${mma_test_metadata_bin}
119 outout=$(cbfstool "${flashrom_temp_image}" print | \
120 grep ${mma_test_metadata_bin})
122 if [ -z "${outout}" ];then
123 printf "Removed ${mma_test_metadata_bin} from %s\n" \
124 "${flashrom_temp_image}"
125 else
126 printf "Failed to remove ${mma_test_metadata_bin} from %s\n" \
127 "${flashrom_temp_image}"
128 print_failed
129 exit -1;
133 generate_metadata() {
134 remove_file_if_exists "${mma_test_metadata_bin_path}"
136 printf "Creating "${mma_test_metadata_bin_path}"\n"
138 #Format of $mma_test_metadata_bin
139 #MMA_TEST_NAME=xxxxxx.efi;MMA_TEST_PARAM=xxxxxx.bin;
141 printf "MMA_TEST_NAME=${mma_test_name};MMA_TEST_PARAM=${mma_test_param};" \
142 > "${mma_test_metadata_bin_path}"
145 add_metadata_to_flashfile() {
146 cbfstool "${flashrom_temp_image}" add -f "${mma_test_metadata_bin_path}" \
147 -n ${mma_test_metadata_bin} -t ${file_type_mma} || \
149 printf "failed to add "${mma_test_metadata_bin_path}"\n" ;
150 exit -1;
154 cleanup() {
155 remove_file_if_exists "${flashrom_temp_image}"
156 remove_file_if_exists "${mma_test_metadata_bin_path}"
159 print_success() {
160 printf "============== SUCCESS ==============\n"
163 print_failed() {
164 printf "============== FAILED ==============\n"
168 # main entry point
171 main() {
172 case "${#}:${1}" in
173 (3:set)
174 mma_test_name=${2}
175 mma_test_param=${3}
177 (1:reset)
180 show_usage
181 exit -1
182 esac
184 if [ "${1}" != "reset" ];then
185 printf "mma_test_name = ${mma_test_name}\n"
186 printf "mma_test_param = ${mma_test_param}\n"
189 remove_file_if_exists "${flashrom_temp_image}"
191 printf "Reading flash contents to "${flashrom_temp_image}"\n"
192 flashrom -p host -r "${flashrom_temp_image}" || \
194 printf "failed to read flash\n" ;
195 exit -1;
198 outdata=$(cbfstool "${flashrom_temp_image}" print | \
199 grep ${mma_test_metadata_bin})
201 case "$1" in
202 ("set")
203 [ "${outdata}" ] && remove_metadata
204 generate_metadata
205 add_metadata_to_flashfile
206 write_flash
208 ("reset")
209 if [ -z "${outdata}" ];then
210 printf "${mma_test_metadata_bin} not found at all.\n"
211 else
212 remove_metadata
213 write_flash
216 esac
217 cleanup
218 print_success
221 main "$@"