Eval » set_hwinfo.sh
1 |
#!/bin/bash
|
---|---|
2 |
|
3 |
|
4 |
set -e |
5 |
set -u |
6 |
|
7 |
|
8 |
cd /home/deseessm/obj/build-qhello-Desktop-Debug
|
9 |
|
10 |
month=$(date +"%m") |
11 |
day=$(date +"%d") |
12 |
year=$(date +"%y") |
13 |
|
14 |
|
15 |
echo -n "Please enter Serial number in hex (e.g. 0x123): " |
16 |
read serial
|
17 |
|
18 |
echo << EOF > gdb.txt |
19 |
|
20 |
br loop
|
21 |
run
|
22 |
call (flash)(10,\"mmm\") |
23 |
clear loop
|
24 |
c
|
25 |
EOF
|
26 |
|
27 |
|
28 |
cat << EOF >gdb.txt |
29 |
|
30 |
br main:loop
|
31 |
run
|
32 |
set var \$new = (SMyStruct *)malloc(sizeof(struct SMyStruct)) |
33 |
set var \$new.version = 1 |
34 |
set var \$new.name="Script" |
35 |
set var \$new.day=$day |
36 |
set var \$new.month=$month |
37 |
set var \$new.year=$year |
38 |
set var \$new.serial=$serial |
39 |
call (flashP)(\$new) |
40 |
|
41 |
# target reset run
|
42 |
|
43 |
set logging file serial.txt
|
44 |
set logging overwrite
|
45 |
set logging on
|
46 |
print/x myStruct.serial
|
47 |
set logging off
|
48 |
|
49 |
EOF
|
50 |
|
51 |
gdb qhello -x gdb.txt -batch-silent -q |
52 |
|
53 |
echo -e "\n\n\n" |
54 |
|
55 |
echo "Serial: " |
56 |
a=$(cat serial.txt) |
57 |
echo ${a##* = } |
58 |
|
59 |
|
60 |
|
61 |
#cat << EOF > gdb.txt
|
62 |
#br main:loop
|
63 |
#run
|
64 |
#set logging file serial.txt
|
65 |
#set logging overwrite
|
66 |
#set logging on
|
67 |
#print/x myStruct.serial
|
68 |
#set logging off
|
69 |
#clear loop
|
70 |
#EOF
|
71 |
#gdb qhello -x gdb.txt -batch-silent -q
|
72 |
|
73 |
|
74 |
|
75 |
#---fin------------------------------------------------------------------------
|