FIX for Flash problems (#1252)

Platform crash on Flash Write - FIXED
Platform crash on Flash Erase - FIXED
This commit is contained in:
JakubBrachTieto
2017-02-09 14:55:56 -08:00
committed by Jonathan Hui
parent bd28d8d8d4
commit 5fec1105c0
5 changed files with 28 additions and 41 deletions
+2 -2
View File
@@ -72,8 +72,8 @@ endif
TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))..
AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))..
CONFIG_FILE = OPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-da15000-config.h\"'
CONFIG_FILE_PATH = $(AbsTopSourceDir)/examples/platforms/da15000/
CONFIG_FILE = OPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-da15000-config.h\"'
CONFIG_FILE_PATH = $(AbsTopSourceDir)/examples/platforms/da15000/
COMMONCFLAGS := \
-fdata-sections \
+4 -2
View File
@@ -5,7 +5,9 @@ This directory contains example platform drivers for the [Dialog Semiconductor D
[da15000]: https://support.dialog-semiconductor.com/connectivity/product/openthread-sandbox
**NOTE:** Each Thread node requires a unique EUI-64.
Please make sure all Thread nodes in your network have a unique EUI-64 by setting NODE_ID in radio.c to a unique value.
Please make sure all Thread nodes in your network have a unique EUI-64 by setting HARDCODED_NODE_ID in radio.c to a unique value.
**NOTE:** Current version works only with DA15000 rev. BA
## Build Examples (How to build and flash):
```bash
@@ -113,7 +115,7 @@ Board will indicate state of device according to LED blink speed.
## Remarks
* Validation
The DA15000 example has been validated by Dialog Semiconductor with commit 0bc2efe included.
The DA15000 example has been validated by Dialog Semiconductor with commit d250105 included.
* Build environment
@@ -115,4 +115,11 @@
/* Include bsp default values */
#include "bsp_defaults.h"
/*************************************************************************************************\
* Open Thread specific config
*/
#define SETTINGS_CONFIG_BASE_ADDRESS (0x7B000)
#endif /* CUSTOM_CONFIG_QSPI_H_ */
+13 -37
View File
@@ -33,10 +33,8 @@
#include "platform/alarm.h"
#include "openthread-config.h"
#define FLASH_SECTOR_SIZE 0x1000
#define FLASH_PAGE_SIZE 0x0100
#define FLASH_BUFFER_SIZE 0x2000 // 8kB
#define FLASH_OFFSET 0x7B000 // Flash memory size is 512kB (0x7D000) and starts from 0x8000000. Offset point to 500kB position
#define FLASH_SECTOR_SIZE 0x1000
#define FLASH_BUFFER_SIZE 0x2000
#define W25Q_READ_STATUS_REGISTER1 0x05
@@ -46,27 +44,27 @@
static uint32_t sWaitStatusTimeout;
QSPI_SECTION static inline uint8_t qspi_get_erase_status(void)
QSPI_SECTION static uint8_t qspi_get_erase_status(void)
{
QSPIC->QSPIC_CHCKERASE_REG = 0;
return HW_QSPIC_REG_GETF(ERASECTRL, ERS_STATE);
}
volatile bool DisableErase = false;
// Erase QSPI memory section as non-blocking function. Remember to check utilsFlashStatusWait before write or read!!
ThreadError utilsFlashErasePage(uint32_t aAddress)
{
uint32_t flash_offset = (aAddress + FLASH_OFFSET) & ~(FLASH_SECTOR_SIZE - 1);
uint32_t flash_offset = (aAddress) & ~(FLASH_SECTOR_SIZE - 1);
if (aAddress > FLASH_BUFFER_SIZE)
if (DisableErase)
{
return kThreadError_InvalidArgs;
return kThreadError_None;
}
/* Setup erase block page */
HW_QSPIC_REG_SETF(ERASECTRL, ERS_ADDR, (flash_offset >>= 4));
/* Fire erase */
HW_QSPIC_REG_SETF(ERASECTRL, ERASE_EN, 1);
qspi_automode_init();
qspi_automode_erase_flash_sector(flash_offset);
CACHE->CACHE_CTRL1_REG = CACHE_CACHE_CTRL1_REG_CACHE_FLUSH_Msk;
@@ -113,44 +111,22 @@ ThreadError utilsFlashInit(void)
uint32_t utilsFlashWrite(uint32_t aAddress, uint8_t *aData, uint32_t aSize)
{
uint32_t flash_offset = (aAddress + FLASH_OFFSET);
return flash_offset;
}
uint32_t utilsFlashWrite2(uint32_t aAddress, uint8_t *aData, uint32_t aSize)
{
uint32_t flash_offset = (aAddress + FLASH_OFFSET);
size_t offset = 0;
size_t written;
while (flash_offset < (aAddress + FLASH_OFFSET) + aSize)
{
qspi_automode_erase_flash_sector(flash_offset);
flash_offset += FLASH_SECTOR_SIZE;
}
flash_offset = (aAddress + FLASH_OFFSET);
while (offset < aSize)
{
written = qspi_automode_write_flash_page(flash_offset + offset, aData + offset,
written = qspi_automode_write_flash_page(aAddress + offset, aData + offset,
aSize - offset);
offset += written;
}
return flash_offset;
return offset;
}
uint32_t utilsFlashRead(uint32_t aAddress, uint8_t *aData, uint32_t aSize)
{
size_t written = 0;
size_t offset = 0;
uint32_t flash_offset = (aAddress + FLASH_OFFSET);
memcpy(aData, (void *)(MEMORY_QSPIF_BASE + flash_offset), aSize);
memcpy(aData, (void *)(MEMORY_QSPIF_BASE + aAddress), aSize);
return aSize;
}
@@ -34,6 +34,8 @@
#ifndef OPENTHREAD_CORE_DA15000_CONFIG_H_
#define OPENTHREAD_CORE_DA15000_CONFIG_H_
#define SETTINGS_CONFIG_BASE_ADDRESS (0x7B000)
/**
* @def OPENTHREAD_CONFIG_ENABLE_SOFTWARE_ACK_TIMEOUT
*