forked from jsandin/esp-bin2elf
-
Notifications
You must be signed in to change notification settings - Fork 4
/
esp_memory_map.py
70 lines (57 loc) · 2.9 KB
/
esp_memory_map.py
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
64
65
66
67
68
69
70
# esp-bin2elf written by Joel Sandin <[email protected]>
#
# MIT licence
# data here from: http://esp8266-re.foogod.com/wiki/Memory_Map
class EspMemoryRegion(object):
def __init__(self, base_address, size, permissions, min_access_width, description):
self.base_address = base_address
self.size = size
self.permissions = permissions
self.min_access_width = min_access_width
self.description = description
def __str__(self):
rep = "EspMemoryRegion("
rep += "base_address: 0x%08x, " % self.base_address
rep += "size: 0x%x, " % self.size
rep += "permissions: %s, " % self.permissions
rep += "min_access_width: %d, " % self.min_access_width
rep += "description: %s)" % self.description
return rep
memory_regions = [
EspMemoryRegion(0x00000000, 0x20000000, '', 8, "protected region"),
EspMemoryRegion(0x20000000, 0x1FF00000, 'r', 8, "unmapped? (reads 0x00800000)"),
EspMemoryRegion(0x3FF00000, 0x00010000, 'rw', 8, "dport0"),
EspMemoryRegion(0x3FF10000, 0x00010000, 'r', 8, "unmapped? (reads 0x00000000)"),
EspMemoryRegion(0x3FF20000, 0x00010000, 'rw', 8, "wdev control registers"),
EspMemoryRegion(0x3FF30000, 0x00090000, 'r', 8, "unmapped? (reads 0x00000000)"),
EspMemoryRegion(0x3FFC0000, 0x00020000, 'r', 8, "unknown region 1"),
EspMemoryRegion(0x3FFE0000, 0x00008000, 'r', 8, "unmapped? (reads 0x00000000)"),
EspMemoryRegion(0x3FFE8000, 0x00018000, 'rw', 8, "data RAM"),
EspMemoryRegion(0x40000000, 0x00010000, 'rx', 32, "boot ROM"),
EspMemoryRegion(0x40010000, 0x00010000, 'rx', 32, "boot ROM (repeated)"),
EspMemoryRegion(0x40020000, 0x000D0000, 'r', 32, "unmapped? (reads 0x00000000)"),
EspMemoryRegion(0x40100000, 0x00008000, 'rwx', 32, "instruction RAM"),
EspMemoryRegion(0x40108000, 0x00008000, 'rwx', 32, "mappable instruction RAM"),
EspMemoryRegion(0x40110000, 0x00030000, 'r', 32, "unmapped? (reads 0x00000000)"),
EspMemoryRegion(0x40140000, 0x000C0000, 'r', 32, "unmapped? (reads 0x5931d8ec)"),
EspMemoryRegion(0x40200000, 0x00100000, 'r', 32, "spi flash cache"),
EspMemoryRegion(0x40300000, 0x1FD00000, 'rx', 8, "unmapped? (reads 0x00800000)"),
EspMemoryRegion(0x60000000, 0x10000000, 'rw', 8, "Memory-Mapped IO Ports"),
EspMemoryRegion(0x70000000, 0x90000000, 'r', 8, "unmapped? (reads 0x00000000)")
]
def find_region_for_address(address):
for i in range(len(memory_regions) - 1):
low, high = memory_regions[i], memory_regions[i + 1]
if low.base_address <= address < high.base_address:
return low, high
return None, None
def is_code(address):
low, high = find_region_for_address(address)
if low and 'x' in low.permissions:
return True
return False
def is_data(address):
low, high = find_region_for_address(address)
if low and low.base_address == 0x3FFE8000:
return True
return False