blob: adc93261284ea25ae184aedd8ef512492d17b47a [file] [log] [blame]
Bo Lv85ad69b2023-04-11 20:34:47 +08001 #!/bin/bash
2
3EXEC_BASEDIR=$(dirname $(readlink -f $0))
4BASEDIR_TOP=$(readlink -f ${EXEC_BASEDIR}/..)
5VENDOR_KEYTOOL=${EXEC_BASEDIR}/../binary-tool/vendor-keytool
6#
7# Settings
8#
9VERSION=0.4
10
11# Check file
12check_file() {
13 if [ ! -f "$2" ]; then echo Error: Unable to open $1: \""$2"\"; exit 1 ; fi
14}
15
16# Check file is size or exit. $1: file, $2: size
17check_size() {
18 local filesize=$(wc -c < "$1")
19 if [ $filesize -ne $2 ]; then
20 echo "Error: File \"$1\" incorrect size. Was $filesize, expected $2"
21 exit 1
22 fi
23}
24
25# Check optional file argument exists and is given size
26# $1 arg name
27# $2 size
28# $3 file
29check_opt_file() {
30 if [ -n "$3" ]; then
31 check_file "$1" "$3"
32 local filesize=$(wc -c < "$3")
33 if [ $filesize -ne $2 ]; then
34 echo "Incorrect size $filesize != $2 for $1 $3"
35 exit 1
36 fi
37 fi
38}
39
40check_opt_boolean() {
41 if [ -n "$2" ]; then
42 if [ "$2" != "true" ] && [ "$2" != "false" ]; then
43 echo Error: invalid value $1: \""$2"\"
44 exit 1
45 fi
46 fi
47}
48
49usage() {
50 cat << EOF
51Usage: $(basename $0) --help
52 $(basename $0) --version
Zhongfu Luo91e4e272023-07-31 17:01:55 +080053 $(basename $0) [--device-roothash device_roothash.bin] \\
Bo Lv85ad69b2023-04-11 20:34:47 +080054 [--dvgk dvgk.bin] \\
55 [--dvuk dvuk.bin] \\
56 [--enable-usb-password true] \\
57 [--enable-dif-password true] \\
58 [--enable-dvuk-derive-with-cid true] \\
59 [--enable-device-vendor-scs true] \\
60 -o pattern.efuse
61 $(basename $0) --audio-id audio_id_value \\
62 -o audio_id.efuse
Zhongfu Luo91e4e272023-07-31 17:01:55 +080063 $(basename $0) --device-scs-vendor-segid seg_id_value \\
64 -o device-scs-vendor-id.efuse
Bo Lv85ad69b2023-04-11 20:34:47 +080065 $(basename $0) --kl -etsi [csv_file_input for etsi] \\
66 $(basename $0) --kl -dgpk1 [csv_file_input for dgpk1] \\
67 $(basename $0) --kl -dgpk2 [csv_file_input for dgpk2]
68
69EOF
70 exit 1
71}
72
73function generate_efuse_device_pattern() {
74 local argv=("$@")
75 local i=0
Bo Lv85ad69b2023-04-11 20:34:47 +080076 local patt_text=$(mktemp --tmpdir)
77
Bo Lv85ad69b2023-04-11 20:34:47 +080078 # Parse args
79 while [ $i -lt $# ]; do
80 arg="${argv[$i]}"
81 #echo "i=$i argv[$i]=${argv[$i]}"
82 i=$((i + 1))
83 case "$arg" in
Bo Lv85ad69b2023-04-11 20:34:47 +080084 -o)
85 output="${argv[$i]}" ;;
86 --dvgk)
87 dvgk="${argv[$i]}" ;;
88 --dvuk)
89 dvuk="${argv[$i]}" ;;
90 --device-roothash)
91 device_roothash="${argv[$i]}" ;;
92 --enable-usb-password)
93 enable_usb_password="${argv[$i]}" ;;
94 --enable-dif-password)
95 enable_dif_password="${argv[$i]}" ;;
96 --enable-dvuk-derive-with-cid)
97 enable_dvuk_derive_with_cid="${argv[$i]}" ;;
98 --enable-device-vendor-scs)
99 enable_device_vendor_scs="${argv[$i]}" ;;
100 *)
101 echo "Unknown option $arg"; exit 1
102 ;;
103 esac
104 i=$((i + 1))
105 done
106
107 # Verify args
108 if [ -z "$output" ]; then echo Error: Missing output file option -o; exit 1; fi
109
110 check_opt_file input 1024 "$input"
111 check_opt_file dvgk 16 "$dvgk"
112 check_opt_file dvuk 16 "$dvuk"
113 check_opt_file device_roothash 32 "$device_roothash"
114
115 check_opt_boolean enable-usb-password "$enable_usb_password"
116 check_opt_boolean enable-dif-password "$enable_dif_password"
117 check_opt_boolean enable-dvuk-derive-with-cid "$enable_dvuk_derive_with_cid"
118 check_opt_boolean enable-device-vendor-scs "$enable_device_vendor_scs"
119
120 #efuse_obj mode
121 if [ "$dvgk" != "" ]; then
122 keyinfo="$(xxd -p -c 16 $dvgk)"
123 echo "efuse_obj set DVGK $keyinfo" >> $patt_text
124 echo "efuse_obj lock DVGK" >> $patt_text
125 fi
126
127 if [ "$dvuk" != "" ]; then
128 keyinfo="$(xxd -p -c 16 $dvuk)"
129 echo "efuse_obj set DVUK $keyinfo" >> $patt_text
130 echo "efuse_obj lock DVUK" >> $patt_text
131 fi
132
133 if [ "$device_roothash" != "" ]; then
134 keyinfo="$(xxd -p -c 32 $device_roothash)"
135 echo "efuse_obj set HASH_NORMAL_DEVICE_ROOTCERT $keyinfo" >> $patt_text
136 echo "efuse_obj lock HASH_NORMAL_DEVICE_ROOTCERT" >> $patt_text
Bo Lv85ad69b2023-04-11 20:34:47 +0800137 fi
138
139 if [ "$enable_device_vendor_scs" == "true" ]; then
140 echo "efuse_obj set FEAT_ENABLE_DEVICE_ROOT_PUBRSA_PROT 01" >> $patt_text
141 echo "efuse_obj set FEAT_ENABLE_DEVICE_LVL1_PUBRSA_PROT 01" >> $patt_text
142 echo "efuse_obj set FEAT_ENABLE_DEVICE_LVLX_PUBRSA_PROT 01" >> $patt_text
143 echo "efuse_obj set FEAT_ENABLE_DEVICE_VENDOR_SIG 01" >> $patt_text
144 echo "efuse_obj set FEAT_ENABLE_DEVICE_PROT 01" >> $patt_text
145 echo "efuse_obj set FEAT_ENABLE_DEVICE_SCS_SIG 01" >> $patt_text
146 fi
147
148 if [ "$enable_usb_password" == "true" ]; then
149 echo "efuse_obj set FEAT_ENABLE_USB_AUTH 01" >> $patt_text
150 fi
151
152 if [ "$enable_dif_password" == "true" ]; then
153 echo "efuse_obj set FEAT_ENABLE_DIF_MASTER_PROT 01" >> $patt_text
154 fi
155
156 if [ "$enable_dvuk_derive_with_cid" == "true" ]; then
157 echo "efuse_obj set FEAT_ENABLE_DVUK_DERIVE_WITH_CID 01" >> $patt_text
158 fi
159
Zhongfu Luo91e4e272023-07-31 17:01:55 +0800160 cp $patt_text $output
Bo Lv85ad69b2023-04-11 20:34:47 +0800161 rm -f $patt_text
Bo Lv85ad69b2023-04-11 20:34:47 +0800162}
163
164function generate_audio_id_pattern() {
165 local argv=("$@")
166 local i=0
Bo Lv85ad69b2023-04-11 20:34:47 +0800167 local patt_text=$(mktemp --tmpdir)
168
Bo Lv85ad69b2023-04-11 20:34:47 +0800169 # Parse args
170 i=0
171 while [ $i -lt $# ]; do
172 arg="${argv[$i]}"
173 #echo "i=$i argv[$i]=${argv[$i]}"
174 i=$((i + 1))
175 case "$arg" in
176 --audio-id)
177 audio_id_value="${argv[$i]}" ;;
178 -o)
179 output="${argv[$i]}" ;;
180 *)
181 echo "Unknown option $arg"; exit 1
182 ;;
183 esac
184 i=$((i + 1))
185 done
186
187 # Verify args
188 if [ -z "$output" ]; then echo Error: Missing output file option -o; exit 1; fi
189
190 if [ -z $audio_id_value ]; then
191 echo Error: invalid audio_id_value
192 exit 1
193 fi
194
195 #efuse_obj mode
196 v=$(printf %08x $audio_id_value)
197 id_info=${v:6:2}${v:4:2}${v:2:2}${v:0:2}
198 echo "efuse_obj set AUDIO_VENDOR_ID $id_info" >> $patt_text
199 echo "efuse_obj lock AUDIO_VENDOR_ID" >> $patt_text
Zhongfu Luo91e4e272023-07-31 17:01:55 +0800200 cp $patt_text $output
Bo Lv85ad69b2023-04-11 20:34:47 +0800201 rm -f $patt_text
Bo Lv85ad69b2023-04-11 20:34:47 +0800202}
203
Bo Lv85ad69b2023-04-11 20:34:47 +0800204function generate_mkt_id_pattern() {
205 local argv=("$@")
206 local i=0
Bo Lv85ad69b2023-04-11 20:34:47 +0800207 local patt_text=$(mktemp --tmpdir)
208
Bo Lv85ad69b2023-04-11 20:34:47 +0800209 # Parse args
210 i=0
211 while [ $i -lt $# ]; do
212 arg="${argv[$i]}"
213 #echo "i=$i argv[$i]=${argv[$i]}"
214 i=$((i + 1))
215 case "$arg" in
Zhongfu Luo91e4e272023-07-31 17:01:55 +0800216 --device-scs-vendor-segid)
Bo Lv85ad69b2023-04-11 20:34:47 +0800217 mkt_id_value="${argv[$i]}" ;;
218 -o)
219 output="${argv[$i]}" ;;
220 *)
221 echo "Unknown option $arg"; exit 1
222 ;;
223 esac
224 i=$((i + 1))
225 done
226
227 # Verify args
228 if [ -z "$output" ]; then echo Error: Missing output file option -o; exit 1; fi
229
230 if [ -z $mkt_id_value ]; then
231 echo Error: invalid mkt_id_value
232 exit 1
233 fi
234
235 #efuse_obj mode
236 v=$(printf %08x $mkt_id_value)
237 id_info=${v:6:2}${v:4:2}${v:2:2}${v:0:2}
Zhongfu Luo91e4e272023-07-31 17:01:55 +0800238 echo "efuse_obj set DEVICE_SCS_VENDOR_SEGID $id_info" >> $patt_text
239 echo "efuse_obj lock DEVICE_SCS_VENDOR_SEGID" >> $patt_text
240 cp $patt_text $output
Bo Lv85ad69b2023-04-11 20:34:47 +0800241 rm -f $patt_text
Bo Lv85ad69b2023-04-11 20:34:47 +0800242}
243
244function generate_kl_pattern() {
245 local argv=("$@")
246 local i=1
247
248 # Parse args
249 while [ $i -lt $# ]; do
250 arg="${argv[$i]}"
251 i=$((i + 1))
252 #echo "generate_kl_pattern arg=$arg"
253 case "$arg" in
254 -etsi)
255 input="${argv[$i]}"
256 echo "reading input=$input"
257 etsi_fuse=true
258 echo "reading etsi_fuse=$etsi_fuse"
259 output="${argv[$i]}".bin
260 echo "reading output=$output"
261 ;;
262 -dgpk1)
263 input="${argv[$i]}"
264 echo "reading input=$input"
265 dgpk1_fuse=true
266 echo "reading dgpk1_fuse=$dgpk1_fuse"
267 output="${argv[$i]}".bin
268 echo "reading output=$output"
269 ;;
270 -dgpk2)
271 input="${argv[$i]}"
272 echo "reading input=$input"
273 dgpk2_fuse=true
274 echo "reading dgpk2_fuse=$dgpk2_fuse"
275 output="${argv[$i]}".bin
276 echo "reading output=$output"
277 ;;
278 *)
279 echo "Unknown option $arg"; exit 1
280 ;;
281 esac
282 i=$((i + 1))
283 done
284
285 # Verify args
286 if [ -z "$input" ]; then echo Error: Missing input file option ; exit 1; fi
287 if [ -z "$output" ]; then echo Error: Missing output path option ; exit 1; fi
288
289 local patt=$(mktemp -p .)
290 local etsi_sck_0=$(mktemp -p .)
291 local etsi_sck_1=$(mktemp -p .)
292 local etsi_sck_2=$(mktemp -p .)
293 local etsi_sck_3=$(mktemp -p .)
294 local etsi_config_0=$(mktemp -p .)
295 local etsi_config_1=$(mktemp -p .)
296 local etsi_config_2=$(mktemp -p .)
297 local etsi_config_3=$(mktemp -p .)
298 local etsi_sck_lock=$(mktemp -p .)
299
300 local dgpk_1=$(mktemp -p .)
301 local dgpk_2=$(mktemp -p .)
302 local dgpk_lock=$(mktemp -p .)
303
304 echo "reading $input, Generating $output"
305 dos2unix $input
306 sed -i -e '$a\' $input
307
308 #Generate empty efuse pattern bytes array
309 dd if=/dev/zero of=$patt count=1024 bs=1 &> /dev/null
310
311
312 if [ "$etsi_fuse" != "" ]; then
313 # Construct zero-filled etsi_sck0~3
314 dd if=/dev/zero of=$etsi_sck_0 count=16 bs=1 &>/dev/null
315 dd if=/dev/zero of=$etsi_sck_1 count=16 bs=1 &>/dev/null
316 dd if=/dev/zero of=$etsi_sck_2 count=16 bs=1 &>/dev/null
317 dd if=/dev/zero of=$etsi_sck_3 count=16 bs=1 &>/dev/null
318
319 # Construct zero-filled etsi_sck0~3_config
320 dd if=/dev/zero of=$etsi_config_0 count=4 bs=1 &>/dev/null
321 dd if=/dev/zero of=$etsi_config_1 count=4 bs=1 &>/dev/null
322 dd if=/dev/zero of=$etsi_config_2 count=4 bs=1 &>/dev/null
323 dd if=/dev/zero of=$etsi_config_3 count=4 bs=1 &>/dev/null
324
325 # Construct zero-filled etsi_sck_0~1_lock
326 dd if=/dev/zero of=$etsi_sck_lock count=1 bs=1 &>/dev/null
327
328 b_etsi_sck_lock=$(xxd -ps -l1 $etsi_sck_lock)
329 fi
330
331 if [ "$dgpk1_fuse" != "" ]; then
332 # Construct zero-filled dgpk1
333 dd if=/dev/zero of=$dgpk_1 count=16 bs=1 &>/dev/null
334
335 # Construct zero-filled dgpk1_lock
336 dd if=/dev/zero of=$dgpk_lock count=1 bs=1 &>/dev/null
337 b_dgpk_1_lock=$(xxd -ps -l1 $dgpk_lock)
338 fi
339
340 if [ "$dgpk2_fuse" != "" ]; then
341 # Construct zero-filled dgpk2
342 dd if=/dev/zero of=$dgpk_2 count=16 bs=1 &>/dev/null
343
344 # Construct zero-filled dgpk2_lock
345 dd if=/dev/zero of=$dgpk_lock count=1 bs=1 &>/dev/null
346 b_dgpk_2_lock=$(xxd -ps -l1 $dgpk_lock)
347 fi
348
349 while IFS=',' read feat sz value
350 do
351 len_value=${#value}
352 case $feat in
353 ETSI_SCK_0)
354 echo found ${feat} bit length ${sz} value ${value}
355 if [ $len_value != $(($sz / 4)) ]; then
356 echo feature $feat : $value has invalid length $(($len_value * 4)).
357 echo expected length is $sz bits.
358 break
359 fi
360 if ! [[ $value =~ ^[0-9a-fA-F]{$len_value}$ ]]; then
361 echo $feat:$value invalid format, Only hexadecimal numbers are acceptable.
362 break
363 fi
364 echo $value | xxd -r -p > $etsi_sck_0
365 ;;
366 ETSI_SCK_1)
367 echo found ${feat} bit length ${sz} value ${value}
368 if [ $len_value != $(($sz / 4)) ]; then
369 echo feature $feat : $value has invalid length $(($len_value * 4)).
370 echo expected length is $sz bits.
371 break
372 fi
373 if ! [[ $value =~ ^[0-9a-fA-F]{$len_value}$ ]]; then
374 echo $feat:$value invalid format, Only hexadecimal numbers are acceptable.
375 break
376 fi
377 echo $value | xxd -r -p > $etsi_sck_1
378 ;;
379 ETSI_SCK_2)
380 echo found ${feat} bit length ${sz} value ${value}
381 if [ $len_value != $(($sz / 4)) ]; then
382 echo feature $feat : $value has invalid length $(($len_value * 4)).
383 echo expected length is $sz bits.
384 break
385 fi
386 if ! [[ $value =~ ^[0-9a-fA-F]{$len_value}$ ]]; then
387 echo $feat:$value invalid format, Only hexadecimal numbers are acceptable.
388 break
389 fi
390 echo $value | xxd -r -p > $etsi_sck_2
391 ;;
392 ETSI_SCK_3)
393 echo found ${feat} bit length ${sz} value ${value}
394 if [ $len_value != $(($sz / 4)) ]; then
395 echo feature $feat : $value has invalid length $(($len_value * 4)).
396 echo expected length is $sz bits.
397 break
398 fi
399 if ! [[ $value =~ ^[0-9a-fA-F]{$len_value}$ ]]; then
400 echo $feat:$value invalid format, Only hexadecimal numbers are acceptable.
401 break
402 fi
403 echo $value | xxd -r -p > $etsi_sck_3
404 ;;
405 ETSI_SCK_CONFIG_0)
406 echo found ${feat} bit length ${sz} value ${value}
407 if [ $len_value != $(($sz / 4)) ]; then
408 echo feature $feat : $value has invalid length $(($len_value * 4)).
409 echo expected length is $sz bits.
410 break
411 fi
412 if ! [[ $value =~ ^[0-9a-fA-F]{$len_value}$ ]]; then
413 echo $feat:$value invalid format, Only hexadecimal numbers are acceptable.
414 break
415 fi
416 echo $value | xxd -r -p > $etsi_config_0
417 ;;
418 ETSI_SCK_CONFIG_1)
419 echo found ${feat} bit length ${sz} value ${value}
420 if [ $len_value != $(($sz / 4)) ]; then
421 echo feature $feat : $value has invalid length $(($len_value * 4)).
422 echo expected length is $sz bits.
423 break
424 fi
425 if ! [[ $value =~ ^[0-9a-fA-F]{$len_value}$ ]]; then
426 echo $feat:$value invalid format, Only hexadecimal numbers are acceptable.
427 break
428 fi
429 echo $value | xxd -r -p > $etsi_config_1
430 ;;
431 ETSI_SCK_CONFIG_2)
432 echo found ${feat} bit length ${sz} value ${value}
433 if [ $len_value != $(($sz / 4)) ]; then
434 echo feature $feat : $value has invalid length $(($len_value * 4)).
435 echo expected length is $sz bits.
436 break
437 fi
438 if ! [[ $value =~ ^[0-9a-fA-F]{$len_value}$ ]]; then
439 echo $feat:$value invalid format, Only hexadecimal numbers are acceptable.
440 break
441 fi
442 echo $value | xxd -r -p > $etsi_config_2
443 ;;
444 ETSI_SCK_CONFIG_3)
445 echo found ${feat} bit length ${sz} value ${value}
446 if [ $len_value != $(($sz / 4)) ]; then
447 echo feature $feat : $value has invalid length $(($len_value * 4)).
448 echo expected length is $sz bits.
449 break
450 fi
451 if ! [[ $value =~ ^[0-9a-fA-F]{$len_value}$ ]]; then
452 echo $feat:$value invalid format, Only hexadecimal numbers are acceptable.
453 break
454 fi
455 echo $value | xxd -r -p > $etsi_config_3
456 ;;
457 ETSI_SCK_0_LOCK)
458 echo found ${feat} bit length ${sz} value ${value}
459 if ([ "$value" != "0" ] && [ "$value" != "1" ]); then
460 echo feature $feat : $value is not in expected range
461 break
462 fi
463 if [ "$value" == "1" ]; then
464 b_etsi_sck_lock="$(printf %02x $(( 0x$b_etsi_sck_lock | 0x01 )))"
465 fi
466 ;;
467 ETSI_SCK_1_LOCK)
468 echo found ${feat} bit length ${sz} value ${value}
469 if ([ "$value" != "0" ] && [ "$value" != "1" ]); then
470 echo feature $feat : $value is not in expected range
471 break
472 fi
473 if [ "$value" == "1" ]; then
474 b_etsi_sck_lock="$(printf %02x $(( 0x$b_etsi_sck_lock | 0x02 )))"
475 fi
476 ;;
477 ETSI_SCK_2_LOCK)
478 echo found ${feat} bit length ${sz} value ${value}
479 if ([ "$value" != "0" ] && [ "$value" != "1" ]); then
480 echo feature $feat : $value is not in expected range
481 break
482 fi
483 if [ "$value" == "1" ]; then
484 b_etsi_sck_lock="$(printf %02x $(( 0x$b_etsi_sck_lock | 0x04 )))"
485 fi
486 ;;
487 ETSI_SCK_3_LOCK)
488 echo found ${feat} bit length ${sz} value ${value}
489 if ([ "$value" != "0" ] && [ "$value" != "1" ]); then
490 echo feature $feat : $value is not in expected range
491 break
492 fi
493 if [ "$value" == "1" ]; then
494 b_etsi_sck_lock="$(printf %02x $(( 0x$b_etsi_sck_lock | 0x08 )))"
495 fi
496 ;;
497 DGPK_1)
498 echo found ${feat} bit length ${sz} value ${value}
499 if [ $len_value != $(($sz / 4)) ]; then
500 echo feature $feat : $value has invalid length $(($len_value * 4)).
501 echo expected length is $sz bits.
502 break
503 fi
504 if ! [[ $value =~ ^[0-9a-fA-F]{$len_value}$ ]]; then
505 echo $feat:$value invalid format, Only hexadecimal numbers are acceptable.
506 break
507 fi
508 echo $value | xxd -r -p > $dgpk_1
509 ;;
510 DGPK_2)
511 echo found ${feat} bit length ${sz} value ${value}
512 if [ $len_value != $(($sz / 4)) ]; then
513 echo feature $feat : $value has invalid length $(($len_value * 4)).
514 echo expected length is $sz bits.
515 break
516 fi
517 if ! [[ $value =~ ^[0-9a-fA-F]{$len_value}$ ]]; then
518 echo $feat:$value invalid format, Only hexadecimal numbers are acceptable.
519 break
520 fi
521 echo $value | xxd -r -p > $dgpk_2
522 ;;
523 DGPK_1_LOCK)
524 echo found ${feat} bit length ${sz} value ${value}
525 if ([ "$value" != "0" ] && [ "$value" != "1" ]); then
526 echo feature $feat : $value is not in expected range
527 break
528 fi
529 if [ "$value" == "1" ]; then
530 b_dgpk_1_lock="$(printf %02x $(( 0x$b_dgpk_1_lock | 0x10 )))"
531 fi
532 ;;
533 DGPK_2_LOCK)
534 echo found ${feat} bit length ${sz} value ${value}
535 if ([ "$value" != "0" ] && [ "$value" != "1" ]); then
536 echo feature $feat : $value is not in expected range
537 break
538 fi
539 if [ "$value" == "1" ]; then
540 b_dgpk_2_lock="$(printf %02x $(( 0x$b_dgpk_2_lock | 0x20 )))"
541 fi
542 ;;
543 *)
544 echo Feature ${feat} is not supported
545 ;;
546 esac
547 done < <(tail -n +2 $input)
548
549 if [ "$etsi_fuse" != "" ]; then
550 #ETSI_SCK_0, 56=block#56
551 dd if="$etsi_sck_0" of="$patt" bs=16 seek=56 count=1 conv=notrunc >& /dev/null
552 dd if="$etsi_sck_1" of="$patt" bs=16 seek=57 count=1 conv=notrunc >& /dev/null
553 dd if="$etsi_sck_2" of="$patt" bs=16 seek=58 count=1 conv=notrunc >& /dev/null
554 dd if="$etsi_sck_3" of="$patt" bs=16 seek=59 count=1 conv=notrunc >& /dev/null
555
556 #ETSI_CONFIG_0, 56=(128/32)*block#14
557 dd if="$etsi_config_0" of="$patt" bs=4 seek=56 count=1 conv=notrunc >& /dev/null
558 dd if="$etsi_config_1" of="$patt" bs=4 seek=57 count=1 conv=notrunc >& /dev/null
559 dd if="$etsi_config_2" of="$patt" bs=4 seek=58 count=1 conv=notrunc >& /dev/null
560 dd if="$etsi_config_3" of="$patt" bs=4 seek=59 count=1 conv=notrunc >& /dev/null
561
562 #LICENSE_LOCK_0_B56_LOCK, 471=(Byte offset: 0x1D7)
563 echo $b_etsi_sck_lock | xxd -r -p > $etsi_sck_lock
564 dd if="$etsi_sck_lock" of="$patt" bs=1 seek=471 count=1 conv=notrunc >& /dev/null
565 fi
566
567 if [ "$dgpk1_fuse" != "" ]; then
568 #DGPK_1, 52=block#52
569 dd if="$dgpk_1" of="$patt" bs=16 seek=52 count=1 conv=notrunc >& /dev/null
570
571 #LICENSE_LOCK_0_B52_LOCK, 470=(Byte offset: 0x1D6)
572 echo $b_dgpk_1_lock | xxd -r -p > $dgpk_lock
573 dd if="$dgpk_lock" of="$patt" bs=1 seek=470 count=1 conv=notrunc >& /dev/null
574 fi
575
576 if [ "$dgpk2_fuse" != "" ]; then
577 #DGPK_2, 53=block#53
578 dd if="$dgpk_2" of="$patt" bs=16 seek=53 count=1 conv=notrunc >& /dev/null
579
580 #LICENSE_LOCK_0_B52_LOCK, 470=(Byte offset: 0x1D6)
581 echo $b_dgpk_2_lock | xxd -r -p > $dgpk_lock
582 dd if="$dgpk_lock" of="$patt" bs=1 seek=470 count=1 conv=notrunc >& /dev/null
583 fi
584
585 ${BASEDIR_TOP}/aml_encrypt_s4 --efsproc --input $patt --output $output --option=debug
586
587 rm -f $patt
588 rm -f $etsi_sck_lock
589 rm -f $etsi_config_0
590 rm -f $etsi_config_1
591 rm -f $etsi_config_2
592 rm -f $etsi_config_3
593 rm -f $etsi_sck_0
594 rm -f $etsi_sck_1
595 rm -f $etsi_sck_2
596 rm -f $etsi_sck_3
597
598 rm -f $dgpk_lock
599 rm -f $dgpk_1
600 rm -f $dgpk_2
601}
602
603parse_main() {
604 case "$@" in
605 --help)
606 usage
607 ;;
608 --version)
609 echo "$(basename $0) version $VERSION"
610 ;;
611 *--audio-id*)
612 generate_audio_id_pattern "$@"
613 ;;
Zhongfu Luo6217f5a2023-08-22 17:16:22 +0800614 *--device-scs-vendor-segid*)
Bo Lv85ad69b2023-04-11 20:34:47 +0800615 generate_mkt_id_pattern "$@"
616 ;;
617 *--kl*)
618 generate_kl_pattern "$@"
619 ;;
620 *-o*)
621 generate_efuse_device_pattern "$@"
622 ;;
623 *)
624 usage "$@"
625 ;;
626 esac
627}
628
629parse_main "$@"