-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathldgen.sh
More file actions
executable file
·48 lines (40 loc) · 1.08 KB
/
ldgen.sh
File metadata and controls
executable file
·48 lines (40 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
section_sz() {
local sz=$($1 -A $2 | sed -n -E "s/^\\$3\s+(\w+).*/\1/p");
echo $sz
}
round_to_power2() {
local tmp=$1
((tmp |= 31))
((tmp |= $tmp >> 1))
((tmp |= $tmp >> 2))
((tmp |= $tmp >> 4))
((tmp |= $tmp >> 8))
((tmp |= $tmp >> 16))
((tmp += 1))
echo $tmp
}
sz_cmd=$1
ktext_sz=$(section_sz $sz_cmd $2 .text);
kdata_sz=$(section_sz $sz_cmd $2 .data);
ksram_sz=$(section_sz $sz_cmd $2 .bss);
((kdata_sz += 0))
((ktext_sz += kdata_sz))
((ksram_sz += kdata_sz))
echo -e "KERN_RO_SZ = $ktext_sz;"
echo -e "KERN_RW_SZ = $ksram_sz;"
counter=0
for ((i=3; i<=$#; i++)); do
f=${!i};
text_raw_sz=$(section_sz $sz_cmd $f .text);
data_raw_sz=$(section_sz $sz_cmd $f .data);
sram_raw_sz=$(section_sz $sz_cmd $f .bss);
((text_raw_sz += data_raw_sz));
((sram_raw_sz += data_raw_sz));
flash_size=$(round_to_power2 $text_raw_sz);
sram_size=$(round_to_power2 $sram_raw_sz);
echo -e "TASK${counter}_RO_SZ = $flash_size;"
echo -e "TASK${counter}_RW_SZ = $sram_size;"
((counter++))
done
echo -e "TASK_NUM = $counter;"