Skip to content

Commit 279115e

Browse files
nvlsianpucarlescufi
authored andcommitted
drives/flash: provide boundaries info for nRF9160
nRF9160 can't provide FICR data while operation in non-secure domain. This patch start using flash layout properties provides by nrfx API for get flash properties, which resolves problem described above. Signed-off-by: Andrzej Puzdrowski <[email protected]>
1 parent 560b458 commit 279115e

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

drivers/flash/soc_flash_nrf.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ static struct k_sem sem_lock;
7777
#define SYNC_LOCK()
7878
#define SYNC_UNLOCK()
7979
#endif
80+
8081
static bool write_protect;
8182

8283
static int write(off_t addr, const void *data, size_t len);
@@ -89,10 +90,12 @@ static inline bool is_aligned_32(u32_t data)
8990

9091
static inline bool is_regular_addr_valid(off_t addr, size_t len)
9192
{
92-
if (addr >= NRF_FICR->CODEPAGESIZE * NRF_FICR->CODESIZE ||
93+
size_t flash_size = nrfx_nvmc_flash_size_get();
94+
95+
if (addr >= flash_size ||
9396
addr < 0 ||
94-
len > NRF_FICR->CODEPAGESIZE * NRF_FICR->CODESIZE ||
95-
addr + len > NRF_FICR->CODEPAGESIZE * NRF_FICR->CODESIZE) {
97+
len > flash_size ||
98+
addr + len > flash_size) {
9699
return false;
97100
}
98101

@@ -180,7 +183,7 @@ static int flash_nrf_write(struct device *dev, off_t addr,
180183

181184
static int flash_nrf_erase(struct device *dev, off_t addr, size_t size)
182185
{
183-
u32_t pg_size = NRF_FICR->CODEPAGESIZE;
186+
u32_t pg_size = nrfx_nvmc_flash_page_size_get();
184187
u32_t n_pages = size / pg_size;
185188
int ret;
186189

@@ -263,8 +266,8 @@ static int nrf_flash_init(struct device *dev)
263266
#endif /* CONFIG_SOC_FLASH_NRF_RADIO_SYNC */
264267

265268
#if defined(CONFIG_FLASH_PAGE_LAYOUT)
266-
dev_layout.pages_count = NRF_FICR->CODESIZE;
267-
dev_layout.pages_size = NRF_FICR->CODEPAGESIZE;
269+
dev_layout.pages_count = nrfx_nvmc_flash_page_count_get();
270+
dev_layout.pages_size = nrfx_nvmc_flash_page_size_get();
268271
#endif
269272
write_protect = true;
270273

@@ -435,7 +438,7 @@ static int write_in_timeslice(off_t addr, const void *data, size_t len)
435438

436439
static int erase_op(void *context)
437440
{
438-
u32_t pg_size = NRF_FICR->CODEPAGESIZE;
441+
u32_t pg_size = nrfx_nvmc_flash_page_size_get();
439442
struct flash_context *e_ctx = context;
440443

441444
#if defined(CONFIG_SOC_FLASH_NRF_RADIO_SYNC)

0 commit comments

Comments
 (0)