Writing Flash with BLE on PSoC6

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
PaSw_2578827
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked

I'm using PSoC Creator to program a PSoC6 BLE Module dev kit (Cy8CPROTO-0630BLE). Part of my application involves writing a setting via a writeable characteristic which is then used to generate internal settings to be stored in NVM. BLE is configured in Dual Core mode and my application is running on the M4, the M0+ is not doing anything other than BLE stuff.

I've tried using emEeprom API and Cy_BLE_StoreAppData() but both appear to have the same issue, causing the program to enter the FaultHandler. In both cases the fault appears to happen when setting the IPC flag, callstack:

 

Cy_SysLib_ProcessingFault() Generated_Source\PSoC6\pdl\drivers\peripheral\syslib\cy_syslib.c 472 0x10085900 (All)
Cy_SysLib_FaultHandler(const uint32_t * faultStackAddr = 0x80474d0) Generated_Source\PSoC6\pdl\drivers\peripheral\syslib\cy_syslib.c 444 0x100858EC (All)
UsageFault_Handler() gcc/startup_psoc6_01_cm4.S 455 0x1008036A (All)
<signal handler called>() ?????? ?????? 0xFFFFFFF9 (All)
Cy_IPC_Sema_Clear(uint32_t semaNumber = 4294967289, _Bool preemptable = 16) Generated_Source\PSoC6\pdl\drivers\peripheral\ipc\cy_ipc_sema.c 307 0x10082C4C (All)
Cy_Flash_SendCmd(uint32_t mode = 0, uint32_t microseconds = 2580) Generated_Source\PSoC6\pdl\drivers\peripheral\flash\cy_flash.c 443 0x08024D88 (All)
Cy_Flash_StartErase(uint32_t rowAddr = 269005312) Generated_Source\PSoC6\pdl\drivers\peripheral\flash\cy_flash.c 915 0x10082546 (All)
Cy_Flash_StartWrite(uint32_t rowAddr = 269005312, const uint32_t * data = 0x80475a4) Generated_Source\PSoC6\pdl\drivers\peripheral\flash\cy_flash.c 829 0x1008246A (All)
WriteRow(uint32_t rowAddr = 269005312, uint32_t * rowData = 0x80475a4, cy_stc_eeprom_context_t * context = 0x8028650 <ANIM_EEPROM_context>) Generated_Source\PSoC6\pdl\middleware\em_eeprom\cy_em_eeprom.c 985 0x1008A900 (All)
Cy_Em_EEPROM_Write(uint32_t addr = 0, void * eepromData = 0x8027c54, uint32_t size = 160, cy_stc_eeprom_context_t * context = 0x8028650 <ANIM_EEPROM_context>) Generated_Source\PSoC6\pdl\middleware\em_eeprom\cy_em_eeprom.c 549 0x1008A5DC (All)
nvm_update() haptics.c 221 0x10081424 (All)
HostMain() host_main.c 456 0x10081B56 (All)
main() main_cm4.c 73 0x10080386 (All)

 

 

I've found some similar issues by searching the forums but nothing that appeared to be the exact same, mostly it was a DeepSleep issue or possibly a clock change issue when writing flash? I tried the native Cy_BLE_StoreAppData() API function too, hoping that would play better with the BLE Stack but I had the exact same issue. I did try (unsuccessfully) to protect the flash write using:

 

if(cy_ble_pendingFlashWrite != 0u)  return;

<Flash Write>

return

 

and

 

while (CY_IPC_SEMA_SUCCESS != Cy_IPC_Sema_Set(CY_BLE_SEMA, false)){}

<Flash Write>

while (CY_IPC_SEMA_SUCCESS != Cy_IPC_Sema_Clear(CY_BLE_SEMA, false)){}

 

 

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.

Hello,

PSoC 63 application flash range is from 0x1000 0000 to 0x100F FFFF. If you have configured the 'Use Emulated EEPROM' as No in the component, then you have to define the start address of EEPROM in the linker file.

Please follow the below steps.
1. Define the EEPROM storage in work flash in ANIM_EEPROM.c
const uint8 ANIM_EEPROM_em_EepromStorage[ANIM_EEPROM_ACTUAL_SIZE] CY_SECTION(".my_emulated_eeprom") __ALIGNED(CY_FLASH_SIZEOF_ROW) = {0u};

2. Add following lines of code after etext = . ; in the linker file corresponding to the core using Emulated EEPROM component. Suppose, the component is used in CM4, add following lines in cy8c6xx7_cm4_dual.ld line.

EM_EEPROM_START_ADDRESS = 0x100C0000‬;/*Start address*/

.my_emulated_eeprom EM_EEPROM_START_ADDRESS :

{

KEEP(*(.my_emulated_eeprom))

} > flash

Please refer to the below attached sample project. For flash operations, please select the core voltage to 1.1v.

Thanks,
P Yugandhar.

View solution in original post

0 Likes
6 Replies
Yugandhar
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 5 likes given

Hello, 

Could you please share your complete project ?

Thanks,

P Yugandhar.

0 Likes
lock attach
Attachments are accessible only for community members.

I've attached a stripped down version of the project that exhibits the same behavior. I'm using PSoC Creator 4.4 (4.4.0.80) and Peripheral Driver Library 3.1.3

0 Likes

@Yugandhar Any update to this, were you able to replicate using the project that I sent to you?

0 Likes

Hello, 

Sorry for the delay in response. I had tried programming your project. After BLE connection, i tried writing values to the BLE Peripheral device. I didn't observed any issues. Could you please let me know the steps to replicate the issue ? 

Please try running a test project to confirm if flash writes works in an empty project without BLE. Once that is confirmed you could try Enabling the BLE in your application and try writing to Flash.

Please use the latest BLE PDL v3.1.5 and BLE component v2.20 in the project.

Thanks,

P Yugandhar. 

0 Likes

Sorry I should have clarified how that application works, when you write a '1' to the Digital characteristic it attempts to save to non-volatile memory, at that point the application crashes.

I did upgrade to the latest PDL and BLE as both were older versions, but it did not resolve the issue. I tried to emulate saving to flash in a project without BLE and it also crashes, so it's possible I'm reserving memory incorrectly? I thought I used the same format given in the emEeprom datasheet and reference documentation.

const uint8 anim_sequence_flash[ANIM_EEPROM_PHYSICAL_SIZE]__ALIGNED(CY_FLASH_SIZEOF_ROW) = {0u};


I did get it to work just moments ago by resorting to using the emulated eeprom section of flash instead of reserving my own region. I had early run into a problem doing that which is why I pivoted to the approach in the project above. Luckily that issue was a BLE issue and I found the solution to that unrelated problem in the following thread: https://community.infineon.com/t5/PSoC-6/EEPROM-compile-error/td-p/185200

0 Likes
lock attach
Attachments are accessible only for community members.

Hello,

PSoC 63 application flash range is from 0x1000 0000 to 0x100F FFFF. If you have configured the 'Use Emulated EEPROM' as No in the component, then you have to define the start address of EEPROM in the linker file.

Please follow the below steps.
1. Define the EEPROM storage in work flash in ANIM_EEPROM.c
const uint8 ANIM_EEPROM_em_EepromStorage[ANIM_EEPROM_ACTUAL_SIZE] CY_SECTION(".my_emulated_eeprom") __ALIGNED(CY_FLASH_SIZEOF_ROW) = {0u};

2. Add following lines of code after etext = . ; in the linker file corresponding to the core using Emulated EEPROM component. Suppose, the component is used in CM4, add following lines in cy8c6xx7_cm4_dual.ld line.

EM_EEPROM_START_ADDRESS = 0x100C0000‬;/*Start address*/

.my_emulated_eeprom EM_EEPROM_START_ADDRESS :

{

KEEP(*(.my_emulated_eeprom))

} > flash

Please refer to the below attached sample project. For flash operations, please select the core voltage to 1.1v.

Thanks,
P Yugandhar.

0 Likes