.erase = aduc702x_erase,
.protect = aduc702x_protect,
.write = aduc702x_write,
+ .read = default_flash_read,
.probe = aduc702x_probe,
.auto_probe = aduc702x_probe,
.erase_check = default_flash_blank_check,
.erase = sam3_erase,
.protect = sam3_protect,
.write = sam3_write,
+ .read = default_flash_read,
.probe = sam3_probe,
.auto_probe = sam3_auto_probe,
.erase_check = sam3_erase_check,
.erase = at91sam7_erase,
.protect = at91sam7_protect,
.write = at91sam7_write,
+ .read = default_flash_read,
.probe = at91sam7_probe,
.auto_probe = at91sam7_probe,
.erase_check = at91sam7_erase_check,
.erase = avrf_erase,
.protect = avrf_protect,
.write = avrf_write,
+ .read = default_flash_read,
.probe = avrf_probe,
.auto_probe = avrf_auto_probe,
.erase_check = default_flash_mem_blank_check,
.erase = cfi_erase,
.protect = cfi_protect,
.write = cfi_write,
+ /* FIXME: access flash at bus_width size */
+ .read = default_flash_read,
.probe = cfi_probe,
.auto_probe = cfi_auto_probe,
/* FIXME: access flash at bus_width size */
* Copyright (C) 2007-2010 Øyvind Harboe <oyvind.harboe@zylin.com> *
* Copyright (C) 2008 by Spencer Oliver <spen@spen-soft.co.uk> *
* Copyright (C) 2009 Zachary T Welch <zw@superlucidity.net> *
+ * Copyright (C) 2010 by Antonio Borneo <borneo.antonio@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
return retval;
}
+int flash_driver_read(struct flash_bank *bank,
+ uint8_t *buffer, uint32_t offset, uint32_t count)
+{
+ int retval;
+
+ LOG_DEBUG("call flash_driver_read()");
+
+ retval = bank->driver->read(bank, buffer, offset, count);
+ if (retval != ERROR_OK)
+ {
+ LOG_ERROR("error reading to flash at address 0x%08" PRIx32 " at offset 0x%8.8" PRIx32 " (%d)",
+ bank->base, offset, retval);
+ }
+
+ return retval;
+}
+
+int default_flash_read(struct flash_bank *bank,
+ uint8_t *buffer, uint32_t offset, uint32_t count)
+{
+ return target_read_buffer(bank->target, offset + bank->base, count, buffer);
+}
+
void flash_bank_add(struct flash_bank *bank)
{
/* put flash bank in linked list */
* Copyright (C) 2007,2008 Øyvind Harboe <oyvind.harboe@zylin.com> *
* Copyright (C) 2008 by Spencer Oliver <spen@spen-soft.co.uk> *
* Copyright (C) 2009 Zachary T Welch <zw@superlucidity.net> *
+ * Copyright (C) 2010 by Antonio Borneo <borneo.antonio@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
void flash_set_dirty(void);
/// @returns The number of flash banks currently defined.
int flash_get_bank_count(void);
+/**
+ * Provides default read implementation for flash memory.
+ * @param bank The bank to read.
+ * @param buffer The data bytes read.
+ * @param offset The offset into the chip to read.
+ * @param count The number of bytes to read.
+ * @returns ERROR_OK if successful; otherwise, an error code.
+ */
+int default_flash_read(struct flash_bank *bank,
+ uint8_t *buffer, uint32_t offset, uint32_t count);
/**
* Provides default erased-bank check handling. Checks to see if
* the flash driver knows they are erased; if things look uncertain,
* Copyright (C) 2007,2008 Øyvind Harboe <oyvind.harboe@zylin.com> *
* Copyright (C) 2008 by Spencer Oliver <spen@spen-soft.co.uk> *
* Copyright (C) 2009 Zachary T Welch <zw@superlucidity.net> *
+ * Copyright (C) 2010 by Antonio Borneo <borneo.antonio@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
int (*write)(struct flash_bank *bank,
uint8_t *buffer, uint32_t offset, uint32_t count);
+ /**
+ * Read data from the flash. Note CPU address will be
+ * "bank->base + offset", while the physical address is
+ * dependent upon current target MMU mappings.
+ *
+ * @param bank The bank to read.
+ * @param buffer The data bytes read.
+ * @param offset The offset into the chip to read.
+ * @param count The number of bytes to read.
+ * @returns ERROR_OK if successful; otherwise, an error code.
+ */
+ int (*read)(struct flash_bank *bank,
+ uint8_t *buffer, uint32_t offset, uint32_t count);
+
/**
* Probe to determine what kind of flash is present.
* This is invoked by the "probe" script command.
.erase = ecosflash_erase,
.protect = ecosflash_protect,
.write = ecosflash_write,
+ .read = default_flash_read,
.probe = ecosflash_probe,
.auto_probe = ecosflash_probe,
.erase_check = default_flash_blank_check,
.erase = faux_erase,
.protect = faux_protect,
.write = faux_write,
+ .read = default_flash_read,
.probe = faux_probe,
.auto_probe = faux_probe,
.erase_check = default_flash_blank_check,
int flash_driver_protect(struct flash_bank *bank, int set, int first, int last);
int flash_driver_write(struct flash_bank *bank,
uint8_t *buffer, uint32_t offset, uint32_t count);
+int flash_driver_read(struct flash_bank *bank,
+ uint8_t *buffer, uint32_t offset, uint32_t count);
/* write (optional verify) an image to flash memory of the given target */
int flash_write_unlock(struct target *target, struct image *image,
.erase = lpc2000_erase,
.protect = lpc2000_protect,
.write = lpc2000_write,
+ .read = default_flash_read,
.probe = lpc2000_probe,
.auto_probe = lpc2000_probe,
.erase_check = lpc2000_erase_check,
.erase = lpc288x_erase,
.protect = lpc288x_protect,
.write = lpc288x_write,
+ .read = default_flash_read,
.probe = lpc288x_probe,
.auto_probe = lpc288x_probe,
.erase_check = lpc288x_erase_check,
.erase = lpc2900_erase,
.protect = lpc2900_protect,
.write = lpc2900_write,
+ .read = default_flash_read,
.probe = lpc2900_probe,
.auto_probe = lpc2900_probe,
.erase_check = lpc2900_erase_check,
.erase = ocl_erase,
.protect = ocl_protect,
.write = ocl_write,
+ .read = default_flash_read,
.probe = ocl_probe,
.erase_check = ocl_erase_check,
.protect_check = ocl_protect_check,
.erase = pic32mx_erase,
.protect = pic32mx_protect,
.write = pic32mx_write,
+ .read = default_flash_read,
.probe = pic32mx_probe,
.auto_probe = pic32mx_auto_probe,
.erase_check = default_flash_mem_blank_check,
.erase = stellaris_erase,
.protect = stellaris_protect,
.write = stellaris_write,
+ .read = default_flash_read,
.probe = stellaris_probe,
.auto_probe = stellaris_probe,
.erase_check = default_flash_mem_blank_check,
.erase = stm32x_erase,
.protect = stm32x_protect,
.write = stm32x_write,
+ .read = default_flash_read,
.probe = stm32x_probe,
.auto_probe = stm32x_auto_probe,
.erase_check = default_flash_mem_blank_check,
.erase = str7x_erase,
.protect = str7x_protect,
.write = str7x_write,
+ .read = default_flash_read,
.probe = str7x_probe,
.auto_probe = str7x_probe,
.erase_check = default_flash_blank_check,
.erase = str9x_erase,
.protect = str9x_protect,
.write = str9x_write,
+ .read = default_flash_read,
.probe = str9x_probe,
.auto_probe = str9x_probe,
.erase_check = default_flash_blank_check,
.erase = str9xpec_erase,
.protect = str9xpec_protect,
.write = str9xpec_write,
+ .read = default_flash_read,
.probe = str9xpec_probe,
.auto_probe = str9xpec_probe,
.erase_check = str9xpec_erase_check,
goto done;
}
- err = target_read_buffer(target, address + wrote, cur_size, readback);
+ err = flash_driver_read(bank, readback, address - bank->base + wrote, cur_size);
if (err != ERROR_OK)
{
retval = err;
.erase = tms470_erase,
.protect = tms470_protect,
.write = tms470_write,
+ .read = default_flash_read,
.probe = tms470_probe,
.auto_probe = tms470_auto_probe,
.erase_check = tms470_erase_check,