From: asterix Date: Fri, 10 Sep 2010 15:53:03 +0000 (+0000) Subject: Consider the offset when read directly into flash memory. X-Git-Tag: 2.6.0~170 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=fd567eaa9f9e24f25929bfdcd95b536986c3aeef;p=bertos.git Consider the offset when read directly into flash memory. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4231 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/cpu/arm/drv/flash_at91.c b/bertos/cpu/arm/drv/flash_at91.c index d501102a..1cdf6b78 100644 --- a/bertos/cpu/arm/drv/flash_at91.c +++ b/bertos/cpu/arm/drv/flash_at91.c @@ -139,7 +139,7 @@ static bool flash_getStatus(struct KBlock *blk) static size_t at91_flash_readDirect(struct KBlock *blk, block_idx_t idx, void *buf, size_t offset, size_t size) { - memcpy(buf, (void *)(idx * blk->blk_size + FLASH_BASE), size); + memcpy(buf, (void *)(idx * blk->blk_size + FLASH_BASE + offset), size); return size; } diff --git a/bertos/cpu/arm/drv/flash_lpc2.c b/bertos/cpu/arm/drv/flash_lpc2.c index f25e7b92..a78ade27 100644 --- a/bertos/cpu/arm/drv/flash_lpc2.c +++ b/bertos/cpu/arm/drv/flash_lpc2.c @@ -179,7 +179,7 @@ static uint32_t addr_to_sector(size_t addr) static size_t lpc2_flash_readDirect(struct KBlock *blk, block_idx_t idx, void *buf, size_t offset, size_t size) { - memcpy(buf, (void *)(idx * blk->blk_size), size); + memcpy(buf, (void *)(idx * blk->blk_size + offset), size); return size; } diff --git a/bertos/cpu/avr/drv/flash_avr.c b/bertos/cpu/avr/drv/flash_avr.c index 231e01eb..7584200e 100644 --- a/bertos/cpu/avr/drv/flash_avr.c +++ b/bertos/cpu/avr/drv/flash_avr.c @@ -71,7 +71,7 @@ struct FlashHardware; static size_t avr_flash_readDirect(struct KBlock *blk, block_idx_t idx, void *buf, size_t offset, size_t size) { - memcpy_P(buf, (const void *)(uint16_t)(idx * blk->blk_size), size); + memcpy_P(buf, (const void *)(uint16_t)(idx * blk->blk_size + offset), size); return blk->blk_size; } diff --git a/bertos/cpu/cortex-m3/drv/flash_lm3s.c b/bertos/cpu/cortex-m3/drv/flash_lm3s.c index df478b61..281c2704 100644 --- a/bertos/cpu/cortex-m3/drv/flash_lm3s.c +++ b/bertos/cpu/cortex-m3/drv/flash_lm3s.c @@ -111,7 +111,7 @@ static int lm3s_writeWord(struct KBlock *blk, uint32_t addr, uint32_t data) static size_t lm3s_flash_readDirect(struct KBlock *blk, block_idx_t idx, void *buf, size_t offset, size_t size) { - memcpy(buf, (void *)(idx * blk->blk_size), size); + memcpy(buf, (void *)(idx * blk->blk_size + offset), size); return size; } diff --git a/bertos/cpu/cortex-m3/drv/flash_stm32.c b/bertos/cpu/cortex-m3/drv/flash_stm32.c index a11777b7..62e448f3 100644 --- a/bertos/cpu/cortex-m3/drv/flash_stm32.c +++ b/bertos/cpu/cortex-m3/drv/flash_stm32.c @@ -139,7 +139,7 @@ static void stm32_flash_clearerror(struct KBlock *blk) static size_t stm32_flash_readDirect(struct KBlock *blk, block_idx_t idx, void *buf, size_t offset, size_t size) { - memcpy(buf, (void *)(idx * blk->blk_size), size); + memcpy(buf, (void *)(idx * blk->blk_size + offset), size); return size; }