diff --git a/arch.mk b/arch.mk index 48e6e9c15..a09668e93 100644 --- a/arch.mk +++ b/arch.mk @@ -363,6 +363,8 @@ ifeq ($(ARCH),RENESAS_RX) $(RX_TSIP_SRC_PATH)/ip/r_tsip_rx_pfa.o \ $(RX_TSIP_SRC_PATH)/ip/r_tsip_rx_pfb.o \ $(RX_TSIP_SRC_PATH)/ip/r_tsip_rx_pf1.o \ + $(RX_TSIP_SRC_PATH)/ip/r_tsip_rx_pf5.o \ + $(RX_TSIP_SRC_PATH)/ip/r_tsip_rx_pf6.o \ $(RX_TSIP_SRC_PATH)/ip/s_flash.o \ $(RX_TSIP_SRC_PATH)/ip/r_tsip_rx_p00.o \ $(RX_TSIP_SRC_PATH)/ip/r_tsip_rx_p01.o \ @@ -379,6 +381,8 @@ ifeq ($(ARCH),RENESAS_RX) $(RX_TSIP_SRC_PATH)/ip/r_tsip_rx_function010.o \ $(RX_TSIP_SRC_PATH)/ip/r_tsip_rx_function011.o \ $(RX_TSIP_SRC_PATH)/ip/r_tsip_rx_function023.o \ + $(RX_TSIP_SRC_PATH)/ip/r_tsip_rx_function027.o \ + $(RX_TSIP_SRC_PATH)/ip/r_tsip_rx_function028.o \ $(RX_TSIP_SRC_PATH)/ip/r_tsip_rx_function050.o \ $(RX_TSIP_SRC_PATH)/ip/r_tsip_rx_function051.o \ $(RX_TSIP_SRC_PATH)/ip/r_tsip_rx_function052.o \ diff --git a/hal/renesas-rx.c b/hal/renesas-rx.c index a31b250bc..484753467 100644 --- a/hal/renesas-rx.c +++ b/hal/renesas-rx.c @@ -454,20 +454,25 @@ int hal_flash_init(void) return 0; } -/* write up to 256 bytes at a time */ +/* write up to 128 bytes at a time */ int RAMFUNCTION hal_flash_write(uint32_t addr, const uint8_t *data, int len) { - int ret, i; + int ret, i, chunk; const uint16_t* data16 = (const uint16_t*)data; while (len > 0) { + chunk = len/2; + if (chunk > FLASH_FACI_CMD_PROGRAM_CODE_LENGTH) { + chunk = FLASH_FACI_CMD_PROGRAM_CODE_LENGTH; + } + FLASH_FSADDR = addr; FLASH_FACI_CMD8 = FLASH_FACI_CMD_PROGRAM; - FLASH_FACI_CMD8 = FLASH_FACI_CMD_PROGRAM_CODE_LENGTH; + FLASH_FACI_CMD8 = chunk; /* write 64 * 2 bytes */ - for (i=0; i < FLASH_FACI_CMD_PROGRAM_CODE_LENGTH; i++) { + for (i=0; i < chunk; i++) { FLASH_FACI_CMD16 = *data16++; /* wait for data buffer not full */ @@ -479,10 +484,8 @@ int RAMFUNCTION hal_flash_write(uint32_t addr, const uint8_t *data, int len) /* Wait for FCU operation to complete */ while ((FLASH_FSTATR & FLASH_FSTATR_FRDY) == 0); - len -= (FLASH_FACI_CMD_PROGRAM_CODE_LENGTH * - FLASH_FACI_CMD_PROGRAM_DATA_LENGTH); - addr += (FLASH_FACI_CMD_PROGRAM_CODE_LENGTH * - FLASH_FACI_CMD_PROGRAM_DATA_LENGTH); + len -= (chunk * FLASH_FACI_CMD_PROGRAM_DATA_LENGTH); + addr += (chunk * FLASH_FACI_CMD_PROGRAM_DATA_LENGTH); } return 0; }