Revision ef9ca5f9 firmware/zpu/usrp2p/spi_flash.c
| b/firmware/zpu/usrp2p/spi_flash.c | ||
|---|---|---|
| 51 | 51 |
spi_flash_erase_sector_start(uint32_t flash_addr) |
| 52 | 52 |
{
|
| 53 | 53 |
//uprintf(UART_DEBUG, "spi_flash_erase_sector_start: addr = 0x%x\n", flash_addr); |
| 54 |
if(flash_addr > spi_flash_memory_size()) |
|
| 55 |
return; |
|
| 54 | 56 |
|
| 55 | 57 |
spi_flash_wait(); |
| 56 | 58 |
spi_flash_write_enable(); |
| ... | ... | |
| 65 | 67 |
if (nbytes == 0 || nbytes > SPI_FLASH_PAGE_SIZE) |
| 66 | 68 |
return false; |
| 67 | 69 |
|
| 70 |
//please to not be writing past the end of the device |
|
| 71 |
if ((flash_addr + nbytes) > spi_flash_memory_size()) |
|
| 72 |
return false; |
|
| 73 |
|
|
| 68 | 74 |
uint32_t local_buf[SPI_FLASH_PAGE_SIZE / sizeof(uint32_t)]; |
| 69 | 75 |
memset(local_buf, 0xff, sizeof(local_buf)); // init to 0xff (nops when programming) |
| 70 | 76 |
memcpy(local_buf, buf, nbytes); |
| ... | ... | |
| 130 | 136 |
const unsigned char *p = (const unsigned char *) buf; |
| 131 | 137 |
size_t n; |
| 132 | 138 |
|
| 139 |
if ((nbytes + flash_addr) > spi_flash_memory_size()) |
|
| 140 |
return false; |
|
| 133 | 141 |
if (nbytes == 0) |
| 134 | 142 |
return true; |
| 135 | 143 |
|
| ... | ... | |
| 158 | 166 |
spi_flash_async_erase_start(spi_flash_async_state_t *s, |
| 159 | 167 |
uint32_t flash_addr, size_t nbytes) |
| 160 | 168 |
{
|
| 161 |
if (nbytes == 0){
|
|
| 169 |
if ((nbytes == 0) || ((flash_addr + nbytes) > spi_flash_memory_size())){
|
|
| 162 | 170 |
s->first = s->last = s->current = 0; |
| 163 | 171 |
return; |
| 164 | 172 |
} |
Also available in: Unified diff