|
17 | 17 | from elftools.elf.elffile import ELFFile
|
18 | 18 | from intelhex import IntelHex
|
19 | 19 |
|
| 20 | +# The UICR format version produced by this script |
| 21 | +UICR_FORMAT_VERSION_MAJOR = 2 |
| 22 | +UICR_FORMAT_VERSION_MINOR = 0 |
| 23 | + |
20 | 24 | # Name of the ELF section containing PERIPHCONF entries.
|
21 | 25 | # Must match the name used in the linker script.
|
22 | 26 | PERIPHCONF_SECTION = "uicr_periphconf_entry"
|
@@ -45,6 +49,14 @@ class PeriphconfEntry(c.LittleEndianStructure):
|
45 | 49 | PERIPHCONF_ENTRY_SIZE = c.sizeof(PeriphconfEntry)
|
46 | 50 |
|
47 | 51 |
|
| 52 | +class Version(c.LittleEndianStructure): |
| 53 | + _pack_ = 1 |
| 54 | + _fields_ = [ |
| 55 | + ("MINOR", c.c_uint16), |
| 56 | + ("MAJOR", c.c_uint16), |
| 57 | + ] |
| 58 | + |
| 59 | + |
48 | 60 | class Approtect(c.LittleEndianStructure):
|
49 | 61 | _pack_ = 1
|
50 | 62 | _fields_ = [
|
@@ -104,7 +116,7 @@ class Mpcconf(c.LittleEndianStructure):
|
104 | 116 | class Uicr(c.LittleEndianStructure):
|
105 | 117 | _pack_ = 1
|
106 | 118 | _fields_ = [
|
107 |
| - ("VERSION", c.c_uint32), |
| 119 | + ("VERSION", Version), |
108 | 120 | ("RESERVED", c.c_uint32),
|
109 | 121 | ("LOCK", c.c_uint32),
|
110 | 122 | ("RESERVED1", c.c_uint32),
|
@@ -171,6 +183,9 @@ def main() -> None:
|
171 | 183 | init_values = DISABLED_VALUE.to_bytes(4, "little") * (c.sizeof(Uicr) // 4)
|
172 | 184 | uicr = Uicr.from_buffer_copy(init_values)
|
173 | 185 |
|
| 186 | + uicr.VERSION.MAJOR = UICR_FORMAT_VERSION_MAJOR |
| 187 | + uicr.VERSION.MINOR = UICR_FORMAT_VERSION_MINOR |
| 188 | + |
174 | 189 | kconfig_str = args.in_config.read()
|
175 | 190 | kconfig = parse_kconfig(kconfig_str)
|
176 | 191 |
|
|
0 commit comments