WIP mik32 sections

This commit is contained in:
Sergey Shchelkanov 2023-05-11 12:54:47 +03:00
parent 65faf0eb22
commit 280cc95c44
2 changed files with 23 additions and 6 deletions

View File

@ -2,7 +2,7 @@ from typing import List, Dict
from dataclasses import dataclass
from enum import Enum
from typing import List, Tuple
from typing import List
class RecordType(Enum):

View File

@ -4,7 +4,7 @@ import sys
import subprocess
import os
from enum import Enum
from typing import List, Tuple
from typing import List, NamedTuple
from drivers.tclrpc import OpenOcdTclRpc
from drivers.mik32_eeprom import *
from drivers.mik32_spifi import *
@ -42,6 +42,24 @@ class Segment:
offset: int
data: List[int]
class MemoryType(Enum):
EEPROM = 1
RAM = 2
SPIFI = 80
class MemorySection(NamedTuple):
type: MemoryType
offset: int
length: int # Memory section length in bytes
mik32v0_sections: List[MemorySection] = [
MemorySection(MemoryType.EEPROM, 0x01000000, 8 * 1024),
MemorySection(MemoryType.RAM, 0x02000000, 8 * 1024),
MemorySection(MemoryType.SPIFI, 0x80000000, 8 * 1024 * 1024),
]
def read_file(filename: str) -> List[Segment]:
segments: List[Segment] = []
lines: List[str] = []
@ -63,7 +81,7 @@ def read_file(filename: str) -> List[Segment]:
for line in lines:
record: Record = parse_line(line, file_extension)
if record.type == RecordType.DATA:
drlo: int = record.address # Data Record Load Offset
drlo: int = record.address # Data Record Load Offset
if segments.__len__() == 0:
expect_address = lba+drlo
segments.append(Segment(offset=expect_address, data=[]))
@ -79,7 +97,6 @@ def read_file(filename: str) -> List[Segment]:
elif record.type == RecordType.LINEARSTARTADDR:
print("Start Linear Address:", record.address)
return segments