Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
63 lines (52 loc) · 1.93 KB

File metadata and controls

63 lines (52 loc) · 1.93 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python3
# SPDX-FileCopyrightText: Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
#
# SPDX-License-Identifier: MIT
import re
import sys
# Handle size constants with K or M suffixes (allowed in .ld but not in Python).
K_PATTERN = re.compile(r'([0-9]+)K')
K_REPLACE = r'(\1*1024)'
M_PATTERN = re.compile(r'([0-9]+)M')
M_REPLACE = r'(\1*1024*1024)'
print()
text = 0
data = 0
bss = 0
# stdin is the linker output.
for line in sys.stdin:
# Uncomment to see linker output.
# print(line)
line = line.strip()
if not line.startswith("text"):
text, data, bss = map(int, line.split()[:3])
regions = {}
# This file is the linker script.
with open(sys.argv[1], "r") as f:
for line in f:
line = line.strip()
if line.startswith(("FLASH_FIRMWARE", "RAM")):
regions[line.split()[0]] = line.split("=")[-1]
for region in regions:
space = regions[region]
if "/*" in space:
space = space.split("/*")[0]
space = K_PATTERN.sub(K_REPLACE, space)
space = M_PATTERN.sub(M_REPLACE, space)
regions[region] = int(eval(space))
firmware_region = regions["FLASH_FIRMWARE"]
ram_region = regions["RAM"]
used_flash = data + text
free_flash = firmware_region - used_flash
used_ram = data + bss
free_ram = ram_region - used_ram
print("{} bytes used, {} bytes free in flash firmware space out of {} bytes ({}kB).".format(used_flash, free_flash, firmware_region, firmware_region / 1024))
print("{} bytes used, {} bytes free in ram for stack and heap out of {} bytes ({}kB).".format(used_ram, free_ram, ram_region, ram_region / 1024))
print()
# Check that we have free flash space. GCC doesn't fail when the text + data
# sections don't fit in FLASH. It only counts data in RAM.
if free_flash < 0:
print("Too little flash!!!")
print()
sys.exit(-1)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.