error writing data to AuxFlash

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

cross mob
SagginDragon
Level 2
Level 2
5 likes given 5 questions asked 5 replies posted

We're experimenting with using the auxiliary memory of the MCU to log ADC voltage readings for later retrieval. Having called SystemInit() earlier in main(), I wrote a for loop to scroll through array values (previously recorded in voltagemVolts[mVLength]) and send them to the desired memory block.

 

 

for (short i = 0; i < mVLength; i++) {
     uint32_t mV = voltagemVolts[i];
     uint32_t *mVar = &mV;
     Cy_Flash_WriteRow(0x14000000 + i, mVar);
}

 

 

When testing the code, we get a double lockup error and automatic termination when the program gets to Cy_Flash_WriteRow().

0 Likes
1 Solution
Ekta
Moderator
Moderator
Moderator
750 replies posted First like given 250 solutions authored

Hi @SagginDragon 

1. I have encountered a similar issue when trying to debug the code while executing the flash write API.
The Cy_Flash_WriteRow() returns a CY_FLASH_DRV_IPC_BUSY error code. I guess this might be because both flash write and debug make use of IPC.

Therefore, what you can try (and as I have suggested earlier), is to simply program the device. In the program, you can write to the desired flash row and read back the flash content (you can print the read content over a serial terminal using UART) to verify if the data was written correctly.

2. You have mentioned that you are trying to use the Em_EEPROM, Infineon provides an Em_EEPROM Middleware that you can use directly to write and read data in the Em_EEPROM section of the flash.

I am attaching the link to the datasheet which mentions steps to configure the Em_eeprom: https://www.infineon.com/dgdl/Infineon-Component_Emulated_EEPROM_V2.0-Software%20Module%20Datasheets...

We also have a code example for PSoC 6 EMEEPROM, In PSoC Creator you can go to File> Code examples> Find PSoC 6 EMEEPOM example:

Ekta_0-1691574503556.png

 

For modustoolbox you can can find the example here: https://github.com/Infineon/mtb-example-psoc6-emulated-eeprom
Link to Em_EEPROM Middleware: https://infineon.github.io/emeeprom/em_eeprom_api_reference_manual/html/index.html

Best Regards
Ekta

 

View solution in original post

5 Replies
Ekta
Moderator
Moderator
Moderator
750 replies posted First like given 250 solutions authored

Hi @SagginDragon 

Q1 .From what I understand, you are getting error when debugging. In this case, what is the return value of the Cy_Flash_WriteRow() function? The function should returns immediately and reports a CY_FLASH_DRV_IPC_BUSY error in the case when another process is writing to flash.


Q2. Could you let me know if the data written to the auxiliary flash location is correct if you just program the hex file instead of debugging?

Q3. Are you just trying to write to the auxiliary flash or want to use it as Em_EEPROM?

Best Regards
Ekta

 

0 Likes

Yes, essentially we are trying to use the auxiliary flash as simulated EEPROM, as is suggested on the chip's datasheet. We have not tried it without the debugger turned on AFAIK.

Essentially your suggestion is to run it like this and see what the result is?

 

cy_en_flashdrv_status_t write = Cy_Flash_WriteRow(args);

 

I also had the thought of triggering it as part of an if statement to automatically break the for loop:

 

if (Cy_Flash_WriteRow(args) == CY_FLASH_DRV_IPC_BUSY) break;

 

0 Likes

What's happening is when it hits Cy_Flash_WriteRow(), the debugger immediately throws an error and crashes out.

 

Error: [psoc6.cpu.cm0] clearing lockup after double fault
[psoc6.cpu.cm0] halted due to debug-request, current mode: Handler NMI
xPSR: 0x01000002 pc: 0xfffffffe msp: 0x0803fce4
Info : psoc6.cpu.cm4: Waiting up to 10.0 sec for valid Vector Table address...
Info : psoc6.cpu.cm4: Vector Table found at 0x10002000
Info : psoc6.cpu.cm4: bkpt @0x10002389, issuing SYSRESETREQ
Info : SWD DPIDR 0x6ba02477
[psoc6.cpu.cm4] halted due to debug-request, current mode: Thread 
xPSR: 0x61000000 pc: 0x10002388 msp: 0x0803f800, semihosting
Info : [psoc6.cpu.cm0] external reset detected
===== arm v7m registers
(0) r0 (/32): 0x40200000
(1) r1 (/32): 0x0000000e
(2) r2 (/32): 0x40200200
(3) r3 (/32): 0x10002000
(4) r4 (/32): 0x10002389
(5) r5 (/32): 0x4022003c
(6) r6 (/32): 0x00000001
(7) r7 (/32): 0x00000100
(8) r8 (/32): 0x00000000
(9) r9 (/32): 0x78951181
(10) r10 (/32): 0xfe8902e1
(11) r11 (/32): 0x66875089
(12) r12 (/32): 0x80000000
(13) sp (/32): 0x0803f800
(14) lr (/32): 0xffffffff
(15) pc (/32): 0x10002388
(16) xpsr (/32): 0x61000000
(17) msp (/32): 0x0803f800
(18) psp (/32): 0x76114080
(20) primask (/1): 0x00
(21) basepri (/8): 0x00
(22) faultmask (/1): 0x00
(23) control (/3): 0x00
(42) d0 (/64): 0x2bdefdd7095bedd9
(43) d1 (/64): 0x0bd56dcd6b5fe5d9
(44) d2 (/64): 0x4b7eddcc0b5fe0cc
(45) d3 (/64): 0x0fdff9dd6b576dfb
(46) d4 (/64): 0x0b5d3ddd0a56dd1e
(47) d5 (/64): 0x2a0bb1d54b5fdddb
(48) d6 (/64): 0x285fedd9031fed5d
(49) d7 (/64): 0x1f5ffdd92b5ffddd
(50) d8 (/64): 0x2afef5cd8b56ed1d
(51) d9 (/64): 0x2b4ffed92a5f8d98
(52) d10 (/64): 0x2b1faddd6b567ddd
(53) d11 (/64): 0x0b1f90590b7ff51d
(54) d12 (/64): 0x43dbffdd1b4fe5fd
(55) d13 (/64): 0x2b7decdd6b5de99d
(56) d14 (/64): 0x2b39ecdd4b56f5cd
(57) d15 (/64): 0x237bedd90bdfeddd
(58) fpscr (/32): 0x00000000
===== Cortex-M DWT registers
Error: [psoc6.cpu.cm0] clearing lockup after double fault
[psoc6.cpu.cm0] halted due to debug-request, current mode: Handler NMI
xPSR: 0x01000002 pc: 0xfffffffe msp: 0x0803fce4
Polling target psoc6.cpu.cm0 failed, trying to reexamine
Info : [psoc6.cpu.cm0] Cortex-M0+ r0p1 processor detected
Info : [psoc6.cpu.cm0] target has 4 breakpoints, 2 watchpoints
Info : dropped 'gdb' connection

 

 

ETA: Having stepped through the program, the error hits in cy_flash.c when Cy_Flash_WriteRow() calls Cy_Flash_SendCmd() in the else case.

0 Likes
Ekta
Moderator
Moderator
Moderator
750 replies posted First like given 250 solutions authored

Hi @SagginDragon 

1. I have encountered a similar issue when trying to debug the code while executing the flash write API.
The Cy_Flash_WriteRow() returns a CY_FLASH_DRV_IPC_BUSY error code. I guess this might be because both flash write and debug make use of IPC.

Therefore, what you can try (and as I have suggested earlier), is to simply program the device. In the program, you can write to the desired flash row and read back the flash content (you can print the read content over a serial terminal using UART) to verify if the data was written correctly.

2. You have mentioned that you are trying to use the Em_EEPROM, Infineon provides an Em_EEPROM Middleware that you can use directly to write and read data in the Em_EEPROM section of the flash.

I am attaching the link to the datasheet which mentions steps to configure the Em_eeprom: https://www.infineon.com/dgdl/Infineon-Component_Emulated_EEPROM_V2.0-Software%20Module%20Datasheets...

We also have a code example for PSoC 6 EMEEPROM, In PSoC Creator you can go to File> Code examples> Find PSoC 6 EMEEPOM example:

Ekta_0-1691574503556.png

 

For modustoolbox you can can find the example here: https://github.com/Infineon/mtb-example-psoc6-emulated-eeprom
Link to Em_EEPROM Middleware: https://infineon.github.io/emeeprom/em_eeprom_api_reference_manual/html/index.html

Best Regards
Ekta

 

Yeah, this seems to be working a lot better: got the Em_EEPROM initialized, set an int to count times that Cy_Em_EEPROM_Write() failed to execute, and so far so good.

 

int writeError = 0;
if (CY_EM_EEPROM_SUCCESS != Cy_Em_EEPROM_Write(0u, &voltagemVolts, sizeof(voltagemVolts), &eepromContext) writeError++;

 

writeError never goes above 0 so this seems good. EDIT: Strike that, it's throwing some kind of non-success CY_EM_EEPROM_BAD_PARAM so I guess there's more rework to be done.

 

EDIT 3: Problem solved, we needed to add a few more defines earlier in main.c

0 Likes