aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars Poeschel <poeschell+openocd@mailbox.org>2019-11-05 16:37:43 +0100
committerTomas Vanek <vanekt@fbl.cz>2020-03-24 21:34:18 +0000
commita708b6d25ec72c6de57ff42bdc6c0b4d52a69388 (patch)
treeba365d2f389d45a64652a5f71b0891dd0f55f426 /src
parent85dc63011378c0a8112f99e3a02fa971f96bbc05 (diff)
downloadriscv-openocd-a708b6d25ec72c6de57ff42bdc6c0b4d52a69388.zip
riscv-openocd-a708b6d25ec72c6de57ff42bdc6c0b4d52a69388.tar.gz
riscv-openocd-a708b6d25ec72c6de57ff42bdc6c0b4d52a69388.tar.bz2
avrf.c: Use extended addressing for flash > 0x20000
The current method used for flash addressing uses 16 bit. Every access to flash is 16 bit wide. With 16 address bits one can address 0x10000 unique locations á 16 bits thats 0x20000 bytes. For flashes bigger than that avrs have an extended addressing with more than 16 address bits. This is now implemented and used for flashs larger than 0x20000 bytes. Change-Id: Id8b6337dde3830fb3c56b9042872e040bb67c12d Signed-off-by: Lars Pöschel <poeschell+openocd@mailbox.org> Reviewed-on: http://openocd.zylin.com/5502 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Diffstat (limited to 'src')
-rw-r--r--src/flash/nor/avrf.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/flash/nor/avrf.c b/src/flash/nor/avrf.c
index 178567e..aa86459 100644
--- a/src/flash/nor/avrf.c
+++ b/src/flash/nor/avrf.c
@@ -142,6 +142,7 @@ static int avr_jtagprg_chiperase(struct avr_common *avr)
}
static int avr_jtagprg_writeflashpage(struct avr_common *avr,
+ const bool ext_addressing,
const uint8_t *page_buf,
uint32_t buf_size,
uint32_t addr,
@@ -152,6 +153,13 @@ static int avr_jtagprg_writeflashpage(struct avr_common *avr,
avr_jtag_sendinstr(avr->jtag_info.tap, NULL, AVR_JTAG_INS_PROG_COMMANDS);
avr_jtag_senddat(avr->jtag_info.tap, NULL, 0x2310, AVR_JTAG_REG_ProgrammingCommand_Len);
+ /* load extended high byte */
+ if (ext_addressing)
+ avr_jtag_senddat(avr->jtag_info.tap,
+ NULL,
+ 0x0b00 | ((addr >> 17) & 0xFF),
+ AVR_JTAG_REG_ProgrammingCommand_Len);
+
/* load addr high byte */
avr_jtag_senddat(avr->jtag_info.tap,
NULL,
@@ -238,6 +246,7 @@ static int avrf_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t o
struct target *target = bank->target;
struct avr_common *avr = target->arch_info;
uint32_t cur_size, cur_buffer_size, page_size;
+ bool ext_addressing;
if (bank->target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
@@ -258,6 +267,11 @@ static int avrf_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t o
if (ERROR_OK != avr_jtagprg_enterprogmode(avr))
return ERROR_FAIL;
+ if (bank->size > 0x20000)
+ ext_addressing = true;
+ else
+ ext_addressing = false;
+
cur_size = 0;
while (count > 0) {
if (count > page_size)
@@ -265,6 +279,7 @@ static int avrf_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t o
else
cur_buffer_size = count;
avr_jtagprg_writeflashpage(avr,
+ ext_addressing,
buffer + cur_size,
cur_buffer_size,
offset + cur_size,