• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2ProjName=$1
3OutPath=$2
4ToolPath="./tools"
5signature=0
6prikey_sel=0
7code_encrypt=0
8sign_pubkey_src=0
9img_type=1
10zip_type=1
11
12sec_img_header=8002000
13sec_img_pos=8002400
14run_img_header=80d0000
15run_img_pos=80d0400
16upd_img_pos=8010000
17
18echo $ProjName
19if [ $prikey_sel -gt 0 ]
20 then
21  let img_type=$img_type+32*$prikey_sel
22fi
23
24if [ $code_encrypt -eq 1 ]
25 then
26  let img_type=$img_type+16
27fi
28
29if [ $signature -eq 1 ]
30 then
31  let img_type=$img_type+256
32fi
33
34if [ $sign_pubkey_src -eq 1 ]
35 then
36  let img_type=$img_type+512
37fi
38
39echo $img_type
40
41if [ $code_encrypt -eq 1 ]
42 then
43  let prikey_sel=$prikey_sel+1
44  openssl enc -aes-128-ecb -in $OutPath/"$ProjName".bin -out $OutPath/"$ProjName"_enc.bin -K 30313233343536373839616263646566 -iv 01010101010101010101010101010101
45  openssl rsautl -encrypt -in $ToolPath/key.txt -inkey $ToolPath/ca/capub_"$prikey_sel".pem -pubin -out $OutPath/key_en.dat
46  cat $OutPath/"$ProjName"_enc.bin $OutPath/key_en.dat > $OutPath/"$ProjName"_enc_key.bin
47  cat $OutPath/"$ProjName"_enc_key.bin $ToolPath/ca/capub_"$prikey_sel"_N.dat > $OutPath/"$ProjName"_enc_key_N.bin
48  $ToolPath/wm_tool -b $OutPath/"$ProjName"_enc_key_N.bin -o $OutPath/"$ProjName" -it $img_type -fc 0 -ra $run_img_pos -ih $run_img_header -ua $upd_img_pos -nh 0  -un 0
49 else
50  $ToolPath/wm_tool -b $OutPath/"$ProjName".bin -o $OutPath/"$ProjName" -it $img_type -fc 0 -ra $run_img_pos -ih $run_img_header -ua $upd_img_pos -nh 0  -un 0
51fi
52
53if [ $signature -eq 1 ]
54 then
55  openssl dgst -sign  $ToolPath/ca/cakey.pem -sha1 -out $OutPath/"$ProjName"_sign.dat $OutPath/"$ProjName".img
56  cat $OutPath/"$ProjName".img $OutPath/"$ProjName"_sign.dat > $OutPath/"$ProjName"_sign.img
57
58  #when you change run-area image's ih, you must remake secboot img with secboot img's -nh address same as run-area image's ih
59  $ToolPath/wm_tool -b $ToolPath/w800_secboot.bin -o $ToolPath/w800_secboot -it 0 -fc 0 -ra $sec_img_pos -ih $sec_img_header -ua $upd_img_pos -nh $run_img_header  -un 0
60  cat $ToolPath/w800_secboot.img $OutPath/"$ProjName"_sign.img > $OutPath/"$ProjName".fls
61 else
62  #when you change run-area image's ih, you must remake secboot img with secboot img's -nh address same as run-area image's ih
63  $ToolPath/wm_tool -b $ToolPath/w800_secboot.bin -o $ToolPath/w800_secboot -it 0 -fc 0 -ra $sec_img_pos -ih $sec_img_header -ua $upd_img_pos -nh $run_img_header  -un 0
64  cat $ToolPath/w800_secboot.img $OutPath/"$ProjName".img > $OutPath/"$ProjName".fls
65fi
66
67#produce compressed ota firmware*/
68if [ $zip_type -eq 1 ]
69 then
70  if [ $signature -eq 1 ]
71   then
72    $ToolPath/wm_tool -b $OutPath/"$ProjName"_sign.img -o $OutPath/"$ProjName"_sign -it $img_type -fc 1 -ra $run_img_pos -ih $run_img_header -ua $upd_img_pos -nh 0  -un 0
73    mv $OutPath/"$ProjName"_sign_gz.img $OutPath/"$ProjName"_sign_ota.img
74  else
75   $ToolPath/wm_tool -b $OutPath/"$ProjName".img -o $OutPath/"$ProjName" -it $img_type -fc 1 -ra $run_img_pos -ih $run_img_header -ua $upd_img_pos -nh 0  -un 0
76   mv $OutPath/"$ProjName"_gz.img $OutPath/"$ProjName"_ota.img
77  fi
78fi
79#openssl --help