3331 |
kaklik |
1 |
#!/usr/bin/python |
|
|
2 |
# ====================================================================== |
|
|
3 |
# check.py - Check section sizes and other constraints |
|
|
4 |
# |
|
|
5 |
# Copyright (C) 2006 Dick Streefland |
|
|
6 |
# |
|
|
7 |
# This is free software, licensed under the terms of the GNU General |
|
|
8 |
# Public License as published by the Free Software Foundation. |
|
|
9 |
# ====================================================================== |
|
|
10 |
|
|
|
11 |
import os, sys |
|
|
12 |
|
|
|
13 |
stacksize = 32 |
|
|
14 |
flashsize = 2048 |
|
|
15 |
ramsize = 128 |
|
|
16 |
|
|
|
17 |
if len(sys.argv) > 2: |
|
|
18 |
stacksize = int(sys.argv[2]) |
|
|
19 |
if len(sys.argv) > 3: |
|
|
20 |
flashsize = int(sys.argv[3]) |
|
|
21 |
if len(sys.argv) > 4: |
|
|
22 |
ramsize = int(sys.argv[4]) |
|
|
23 |
|
|
|
24 |
max_sram = ramsize - stacksize |
|
|
25 |
|
|
|
26 |
for line in os.popen('avr-objdump -ht ' + sys.argv[1]).readlines(): |
|
|
27 |
a = line.split() |
|
|
28 |
if len(a) == 7: |
|
|
29 |
if a[1] == '.text': |
|
|
30 |
text = int(a[2], 16) |
|
|
31 |
if a[1] == '.data': |
|
|
32 |
data = int(a[2], 16) |
|
|
33 |
if a[1] == '.bss': |
|
|
34 |
bss = int(a[2], 16) |
|
|
35 |
if len(a) == 5 and a[4] == 'crc4tab': |
|
|
36 |
crc4tab = int(a[0], 16) |
|
|
37 |
print 'text: %d, data: %d, bss: %d' % (text, data, bss) |
|
|
38 |
|
|
|
39 |
status = 0 |
|
|
40 |
overflow = text + data - flashsize |
|
|
41 |
if overflow > 0: |
|
|
42 |
print 'ERROR: Flash size limit exceeded by %d bytes.' % overflow |
|
|
43 |
status = 1 |
|
|
44 |
overflow = bss + data - max_sram |
|
|
45 |
if overflow > 0: |
|
|
46 |
print 'ERROR: SRAM size limit exceeded by %d bytes.' % overflow |
|
|
47 |
status = 1 |
|
|
48 |
if (crc4tab & 0xff) > 0xf0: |
|
|
49 |
print 'ERROR: The table crc4tab should not cross a page boundary.' |
|
|
50 |
status = 1 |
|
|
51 |
sys.exit(status) |