Skip to content

Commit

Permalink
family: nRF91: add UICR region to pack based target
Browse files Browse the repository at this point in the history
Signed-off-by: Maximilian Deubel <[email protected]>
  • Loading branch information
maxd-nordic committed Jul 10, 2023
1 parent 9f7f3a2 commit f724e97
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 81 deletions.
82 changes: 1 addition & 81 deletions pyocd/target/builtin/target_nRF91xx.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

from ...core.memory_map import FlashRegion, RamRegion, MemoryMap
from ...debug.svd.loader import SVDFile
from ..family.target_nRF91 import NRF91
from ..family.target_nRF91 import NRF91, FLASH_ALGO_UICR

FLASH_ALGO = {
'load_address' : 0x20000000,
Expand Down Expand Up @@ -119,86 +119,6 @@
)
}

FLASH_ALGO_UICR = {
'load_address' : 0x20000000,

# Flash algorithm as a hex string
'instructions': [
0xe7fdbe00,
0xf240b570, 0xf2c00604, 0x25000600, 0x0006eb09, 0x5006f849, 0x5501e9c0, 0xb2d060c5, 0xf0004614,
0x2800f9c9, 0xeb09bf1e, 0xe9c10106, 0x46050402, 0xbd704628, 0x4604b510, 0xf0002000, 0xf240f9bb,
0x28000104, 0x0100f2c0, 0xeb09bf1c, 0xe9c20201, 0xeb090402, 0x68920201, 0xbf082a00, 0xf244bd10,
0xf2c20200, 0x23010200, 0xf8596013, 0x44493001, 0x684b6053, 0x688b6093, 0x68c960d3, 0xbd106111,
0xf240b580, 0xf2c00004, 0x21010000, 0x1000f849, 0x21004448, 0x1101e9c0, 0xf00060c1, 0x2000f9ad,
0xbf00bd80, 0xf240b510, 0xf2c00004, 0x21020000, 0x1000f849, 0x24004448, 0x4401e9c0, 0xf00060c4,
0x4601f93b, 0x0000f248, 0x00fff2c0, 0xf00022ff, 0xb138f80f, 0xf9a6f000, 0xd0052869, 0x28004604,
0x2400bf08, 0xbd104620, 0x46202400, 0xbf00bd10, 0xf240b570, 0xf2c00c04, 0x23050c00, 0x300cf849,
0x030ceb09, 0x0e00f04f, 0xe9c30784, 0xf8c3ee01, 0xd006e00c, 0x010ceb09, 0xe9c12203, 0x20652002,
0xeb09bd70, 0xf04f030c, 0x078c0e01, 0xe004f8c3, 0xeb09d006, 0x2203000c, 0x2102e9c0, 0xbd702065,
0x7efff648, 0x0efff2c0, 0x030ceb09, 0x45702402, 0xd906605c, 0x010ceb09, 0xe9c12204, 0x20662002,
0x180bbd70, 0x0501f10e, 0x040ceb09, 0x42ab2603, 0xd9066066, 0x000ceb09, 0xe9c02104, 0x20661302,
0x2900bd70, 0x2000bf04, 0xbf00bd70, 0x42937803, 0x3001d105, 0xf04f3901, 0xd1f70300, 0xeb09e005,
0x2205010c, 0xe9c12301, 0x46182002, 0xbf00bd70, 0xf240b570, 0xf2c00304, 0xf04f0300, 0xeb090c03,
0x24000503, 0xf849078e, 0xe9c5c003, 0x60ec4401, 0xeb09d005, 0xe9c00003, 0x2065c102, 0xf648bd70,
0xf2c076ff, 0xeb0906ff, 0x24020503, 0x606c42b0, 0xeb09d906, 0x22040103, 0x2002e9c1, 0xbd702066,
0x3601180d, 0x0403eb09, 0x0c03f04f, 0xf8c442b5, 0xd906c004, 0x0003eb09, 0xe9c02104, 0x20661502,
0x2300bd70, 0x0f91ebb3, 0x088cd00b, 0x1f161f05, 0x0f04f856, 0x0f04f845, 0xf8d6f000, 0xd1f73c01,
0x46182300, 0xbf00bd70, 0xf240b570, 0xf2c00c04, 0x23040c00, 0x300cf849, 0x030ceb09, 0x0e00f04f,
0xe9c30784, 0xf8c3ee01, 0xd006e00c, 0x010ceb09, 0xe9c12203, 0x20652002, 0xeb09bd70, 0xf04f030c,
0x078c0e01, 0xe004f8c3, 0xeb09d006, 0x2203000c, 0x2102e9c0, 0xbd702065, 0x7efff648, 0x0efff2c0,
0x030ceb09, 0x45702402, 0xd906605c, 0x010ceb09, 0xe9c12204, 0x20662002, 0x180bbd70, 0x0501f10e,
0x040ceb09, 0x42ab2603, 0xd9066066, 0x000ceb09, 0xe9c02104, 0x20661302, 0x2500bd70, 0x0f91ebb5,
0x060ceb09, 0x0504f04f, 0xd0116075, 0xbf000889, 0x68156806, 0xd10542ae, 0x39013004, 0x0204f102,
0xe005d1f6, 0x010ceb09, 0x46032206, 0x2002e9c1, 0xbd704618, 0x1030f240, 0x00fff2c0, 0x31016801,
0x6800bf1c, 0xf6404770, 0xf2cf71e0, 0x78080100, 0xf3616849, 0x4770200b, 0x2020f240, 0x00fff2c0,
0x31016801, 0x6800bf14, 0x5080f44f, 0xbf004770, 0x2024f240, 0x00fff2c0, 0x31016801, 0x6800bf14,
0x7000f44f, 0xbf004770, 0x47702000, 0x47702000, 0xf7ffb510, 0x4604ffe1, 0xffeaf7ff, 0xf004fb00,
0xbf00bd10, 0x42814401, 0x2001bf9c, 0xbf004770, 0x2b04f850, 0xbf1c3201, 0x47702000, 0xbf244288,
0x47702001, 0xbf00e7f4, 0xbf004770, 0x47702000, 0x47702003, 0xbf842803, 0x47702069, 0xb240b580,
0xf851a105, 0xf2490020, 0xf2c55104, 0x60080103, 0xf80af000, 0xbd802000, 0x00000000, 0x00000002,
0x00000001, 0x00000000, 0x4000f249, 0x0003f2c5, 0x29006801, 0x4770d0fc, 0xf249b580, 0xf2c5500c,
0x21010003, 0xf7ff6001, 0xbd80ffef, 0xb082b580, 0x98019001, 0x31fff04f, 0xf7ff6001, 0xb002ffe5,
0xbf00bd80, 0x47702069, 0xf7ffb5b0, 0xb148ffa1, 0x25004604, 0xf7ff4628, 0xf7ffffe9, 0x4405ff7d,
0xd3f742a5, 0xbdb02000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000
],

# Relative function addresses
'pc_init': 0x20000005,
'pc_unInit': 0x20000039,
'pc_program_page': 0x200001b5,
'pc_erase_sector': 0x200000a9,
'pc_eraseAll': 0x20000085,

'static_base' : 0x20000000 + 0x00000004 + 0x00000448,
'begin_stack' : 0x20003460,
'end_stack' : 0x20002460,
'begin_data' : 0x20000000 + 0x1000,
'page_size' : 0x1000,
'analyzer_supported' : False,
'analyzer_address' : 0x00000000,
# Enable double buffering
'page_buffers' : [
0x20000460,
0x20001460
],
'min_program_length' : 0x1000,

# Relative region addresses and sizes
'ro_start': 0x4,
'ro_size': 0x448,
'rw_start': 0x44c,
'rw_size': 0x4,
'zi_start': 0x450,
'zi_size': 0x10,

# Flash information
'flash_start': 0xff8000,
'flash_size': 0x1000,
'sector_sizes': (
(0x0, 0x1000),
)
}

class NRF91XX(NRF91):
MEMORY_MAP = MemoryMap(
FlashRegion(
Expand Down
90 changes: 90 additions & 0 deletions pyocd/target/family/target_nRF91.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from intelhex import IntelHex

from ...core import exceptions
from ...core.memory_map import FlashRegion
from ...core.target import Target
from ...coresight.coresight_target import CoreSightTarget
from ...flash.eraser import FlashEraser
Expand Down Expand Up @@ -301,13 +302,102 @@ def split_addr_range_into_chunks(range, chunk_size):
break
return chunks

FLASH_ALGO_UICR = {
'load_address' : 0x20000000,

# Flash algorithm as a hex string
'instructions': [
0xe7fdbe00,
0xf240b570, 0xf2c00604, 0x25000600, 0x0006eb09, 0x5006f849, 0x5501e9c0, 0xb2d060c5, 0xf0004614,
0x2800f9c9, 0xeb09bf1e, 0xe9c10106, 0x46050402, 0xbd704628, 0x4604b510, 0xf0002000, 0xf240f9bb,
0x28000104, 0x0100f2c0, 0xeb09bf1c, 0xe9c20201, 0xeb090402, 0x68920201, 0xbf082a00, 0xf244bd10,
0xf2c20200, 0x23010200, 0xf8596013, 0x44493001, 0x684b6053, 0x688b6093, 0x68c960d3, 0xbd106111,
0xf240b580, 0xf2c00004, 0x21010000, 0x1000f849, 0x21004448, 0x1101e9c0, 0xf00060c1, 0x2000f9ad,
0xbf00bd80, 0xf240b510, 0xf2c00004, 0x21020000, 0x1000f849, 0x24004448, 0x4401e9c0, 0xf00060c4,
0x4601f93b, 0x0000f248, 0x00fff2c0, 0xf00022ff, 0xb138f80f, 0xf9a6f000, 0xd0052869, 0x28004604,
0x2400bf08, 0xbd104620, 0x46202400, 0xbf00bd10, 0xf240b570, 0xf2c00c04, 0x23050c00, 0x300cf849,
0x030ceb09, 0x0e00f04f, 0xe9c30784, 0xf8c3ee01, 0xd006e00c, 0x010ceb09, 0xe9c12203, 0x20652002,
0xeb09bd70, 0xf04f030c, 0x078c0e01, 0xe004f8c3, 0xeb09d006, 0x2203000c, 0x2102e9c0, 0xbd702065,
0x7efff648, 0x0efff2c0, 0x030ceb09, 0x45702402, 0xd906605c, 0x010ceb09, 0xe9c12204, 0x20662002,
0x180bbd70, 0x0501f10e, 0x040ceb09, 0x42ab2603, 0xd9066066, 0x000ceb09, 0xe9c02104, 0x20661302,
0x2900bd70, 0x2000bf04, 0xbf00bd70, 0x42937803, 0x3001d105, 0xf04f3901, 0xd1f70300, 0xeb09e005,
0x2205010c, 0xe9c12301, 0x46182002, 0xbf00bd70, 0xf240b570, 0xf2c00304, 0xf04f0300, 0xeb090c03,
0x24000503, 0xf849078e, 0xe9c5c003, 0x60ec4401, 0xeb09d005, 0xe9c00003, 0x2065c102, 0xf648bd70,
0xf2c076ff, 0xeb0906ff, 0x24020503, 0x606c42b0, 0xeb09d906, 0x22040103, 0x2002e9c1, 0xbd702066,
0x3601180d, 0x0403eb09, 0x0c03f04f, 0xf8c442b5, 0xd906c004, 0x0003eb09, 0xe9c02104, 0x20661502,
0x2300bd70, 0x0f91ebb3, 0x088cd00b, 0x1f161f05, 0x0f04f856, 0x0f04f845, 0xf8d6f000, 0xd1f73c01,
0x46182300, 0xbf00bd70, 0xf240b570, 0xf2c00c04, 0x23040c00, 0x300cf849, 0x030ceb09, 0x0e00f04f,
0xe9c30784, 0xf8c3ee01, 0xd006e00c, 0x010ceb09, 0xe9c12203, 0x20652002, 0xeb09bd70, 0xf04f030c,
0x078c0e01, 0xe004f8c3, 0xeb09d006, 0x2203000c, 0x2102e9c0, 0xbd702065, 0x7efff648, 0x0efff2c0,
0x030ceb09, 0x45702402, 0xd906605c, 0x010ceb09, 0xe9c12204, 0x20662002, 0x180bbd70, 0x0501f10e,
0x040ceb09, 0x42ab2603, 0xd9066066, 0x000ceb09, 0xe9c02104, 0x20661302, 0x2500bd70, 0x0f91ebb5,
0x060ceb09, 0x0504f04f, 0xd0116075, 0xbf000889, 0x68156806, 0xd10542ae, 0x39013004, 0x0204f102,
0xe005d1f6, 0x010ceb09, 0x46032206, 0x2002e9c1, 0xbd704618, 0x1030f240, 0x00fff2c0, 0x31016801,
0x6800bf1c, 0xf6404770, 0xf2cf71e0, 0x78080100, 0xf3616849, 0x4770200b, 0x2020f240, 0x00fff2c0,
0x31016801, 0x6800bf14, 0x5080f44f, 0xbf004770, 0x2024f240, 0x00fff2c0, 0x31016801, 0x6800bf14,
0x7000f44f, 0xbf004770, 0x47702000, 0x47702000, 0xf7ffb510, 0x4604ffe1, 0xffeaf7ff, 0xf004fb00,
0xbf00bd10, 0x42814401, 0x2001bf9c, 0xbf004770, 0x2b04f850, 0xbf1c3201, 0x47702000, 0xbf244288,
0x47702001, 0xbf00e7f4, 0xbf004770, 0x47702000, 0x47702003, 0xbf842803, 0x47702069, 0xb240b580,
0xf851a105, 0xf2490020, 0xf2c55104, 0x60080103, 0xf80af000, 0xbd802000, 0x00000000, 0x00000002,
0x00000001, 0x00000000, 0x4000f249, 0x0003f2c5, 0x29006801, 0x4770d0fc, 0xf249b580, 0xf2c5500c,
0x21010003, 0xf7ff6001, 0xbd80ffef, 0xb082b580, 0x98019001, 0x31fff04f, 0xf7ff6001, 0xb002ffe5,
0xbf00bd80, 0x47702069, 0xf7ffb5b0, 0xb148ffa1, 0x25004604, 0xf7ff4628, 0xf7ffffe9, 0x4405ff7d,
0xd3f742a5, 0xbdb02000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000
],

# Relative function addresses
'pc_init': 0x20000005,
'pc_unInit': 0x20000039,
'pc_program_page': 0x200001b5,
'pc_erase_sector': 0x200000a9,
'pc_eraseAll': 0x20000085,

'static_base' : 0x20000000 + 0x00000004 + 0x00000448,
'begin_stack' : 0x20003460,
'end_stack' : 0x20002460,
'begin_data' : 0x20000000 + 0x1000,
'page_size' : 0x1000,
'analyzer_supported' : False,
'analyzer_address' : 0x00000000,
# Enable double buffering
'page_buffers' : [
0x20000460,
0x20001460
],
'min_program_length' : 0x1000,

# Relative region addresses and sizes
'ro_start': 0x4,
'ro_size': 0x448,
'rw_start': 0x44c,
'rw_size': 0x4,
'zi_start': 0x450,
'zi_size': 0x10,

# Flash information
'flash_start': 0xff8000,
'flash_size': 0x1000,
'sector_sizes': (
(0x0, 0x1000),
)
}

class NRF91(CoreSightTarget):

VENDOR = "Nordic Semiconductor"

def __init__(self, session, memory_map=None):
super(NRF91, self).__init__(session, memory_map)
if memory_map.get_region_for_address(0x00ff8000) is None:
LOG.debug("Adding UICR region")
memory_map.add_region(FlashRegion(
start=0x00ff8000,
length=0x1000,
blocksize=0x1000,
is_testable=False,
is_erasable=False,
algo=FLASH_ALGO_UICR,
))
self.ctrl_ap = None
self.was_locked = False

Expand Down

0 comments on commit f724e97

Please sign in to comment.