Skip to content

Commit 74d8f1a

Browse files
authored
drivers: flash: telink: Add base addr correction to offset (zephyrproject-rtos#32)
Needs to use MCUBoot with offset. Signed-off-by: Alex Tsitsiura <[email protected]>
1 parent bc46b3a commit 74d8f1a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/flash/soc_flash_b91.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -91,22 +91,22 @@ static int flash_b91_erase(const struct device *dev, off_t offset, size_t len)
9191
/* check for 64K erase possibility, then check for 32K and so on.. */
9292
if ((page_nums >= BLOCK_64K_PAGES) && ((offset % BLOCK_64K_SIZE) == 0)) {
9393
/* erase 64K block */
94-
flash_erase_64kblock(offset);
94+
flash_erase_64kblock(CONFIG_FLASH_BASE_ADDRESS + offset);
9595
page_nums -= BLOCK_64K_PAGES;
9696
offset += BLOCK_64K_SIZE;
9797
} else if ((page_nums >= BLOCK_32K_PAGES) && ((offset % BLOCK_32K_SIZE) == 0)) {
9898
/* erase 32K block */
99-
flash_erase_32kblock(offset);
99+
flash_erase_32kblock(CONFIG_FLASH_BASE_ADDRESS + offset);
100100
page_nums -= BLOCK_32K_PAGES;
101101
offset += BLOCK_32K_SIZE;
102102
} else if ((page_nums >= SECTOR_PAGES) && ((offset % SECTOR_SIZE) == 0)) {
103103
/* erase sector */
104-
flash_erase_sector(offset);
104+
flash_erase_sector(CONFIG_FLASH_BASE_ADDRESS + offset);
105105
page_nums -= SECTOR_PAGES;
106106
offset += SECTOR_SIZE;
107107
} else {
108108
/* erase page */
109-
flash_erase_page(offset);
109+
flash_erase_page(CONFIG_FLASH_BASE_ADDRESS + offset);
110110
page_nums--;
111111
offset += PAGE_SIZE;
112112
}
@@ -158,7 +158,7 @@ static int flash_b91_write(const struct device *dev, off_t offset,
158158
}
159159

160160
/* write flash */
161-
flash_write_page(offset, len, (unsigned char *)data);
161+
flash_write_page(CONFIG_FLASH_BASE_ADDRESS + offset, len, (unsigned char *)data);
162162

163163
/* if ram memory is allocated for flash writing it should be free */
164164
if (buf != NULL) {
@@ -188,7 +188,7 @@ static int flash_b91_read(const struct device *dev, off_t offset,
188188
}
189189

190190
/* read flash */
191-
flash_read_page(offset, len, (unsigned char *)data);
191+
flash_read_page(CONFIG_FLASH_BASE_ADDRESS + offset, len, (unsigned char *)data);
192192

193193
return 0;
194194
}

0 commit comments

Comments
 (0)