cancel
Showing results for 
Search instead for 
Did you mean: 

How to use the EEPROM emulation example code "EEPROM_Emul" from"X-CUBE-EEPROM_V2.0.0" package on a custom STM32WB55CE board.

GBehe
Associate III

I have my custom STM32WB55CE board. I had programmed the example code "EEPROM_Emul" from"X-CUBE-EEPROM_V2.0.0" package on it. It was working fine. Then I did FUS upgrade with BLE full stack binary programming on it. After that, the same EEPROM emulation example code gets stuck at EE_Init() function. It goes into Hardfault handler. I did a FLASH erase and reprogrammed the example code. On my STM32WB55 Neucleo board, it works fine. Please guide on this.

Thank you.

30 REPLIES 30
GBehe
Associate III

Thanks Adam.

I did changed the Address of EEPROM Emulation to a different location(before the FUS area) and now I am able to test/debug my board. It is working as before.

Thank you all for your support.

GBehe
Associate III

Hi Adam.

I tried to include an example code of EEPROM from the X-CUBE-EEPROM_V2.0.0 pakage for my STM32WB55CE controller's project. As my SFSA is 0x0805 7000, I have set the Starting address of EEPROM Emulation as 0x08050000. When I debug to check the code, at function "EE_Init(EE_FORCED_ERASE);", its going to the file "startup_stm32_wb55ceux.s" infinite loop section as shown in the screenshot. Please guide why is it happening and what can be done.

If I run only the example code, as I have mentioned earlier, it works. Only after including the same example in my project, I see this problem.

Thank you.

Adam Santamaria
Associate II

Hello GBehe,

Sorry for the delay.

Have you checked that the ICFEDIT_region_ROM_end in your linker file is below (0x08000000 + (SFSA << 12)) - 1 ?

Also you really don't have information about the last instructions executed ?

Best regards,

Adam

Adam Santamaria
Associate II

You can also try to keep the startup_stm32wb55xx_cm4.s file used in the EEPROM emul project which is compatible with the WB55CE product (where did you find startup_stm32_wb55ceux.s ?).

If you set breakpoints in the FLASH_IRQHandler and HSEM_IRQHandler in the stm32wbxx_it.c file, can you check that they are triggered before looping infinitely ?

Thanks

Adam

GBehe
Associate III

Hi Adam Santamaria.

Sorry for coming late. My health was not well due to CORONA.

Right now I have added OTA feature to my existing code. SO my code starts at 0x08007000 in the flash. And I am facing new problem in implementing EEPROM emulation.

As my SFSA is 0x57, my FUS and BLE stack binary resides from 0x08057000. So using the formula (0x08000000 + (SFSA << 12)) - 1 , I get 56FFFFFF in hex. But I am sorry to say I could not calcluate the byte size for my code.

Right now I have set my "START_PAGE_ADDRESS" as 0x08040000U. I just tried to test for 5 values to be stored in the emulated region. I am able to write and read only the first byte. i.e; with the following functions "EE_WriteVariable32bits()" and "EE_ReadVariable32bits".

For the next 4 byes the write and read operations are failing with return status  "EE_WRITE_ERROR" for Write operation and "EE_NO_DATA" for read.

And this time I am unable to do debugging also. I get a problem as in the screenshot.

Please guide.

Thank you.

Adam Santamaria
Associate II

Hello GBehe,

Sorry to hear you had a bad time and happy if you are recovering well.

Which IDE are you using ? So I can help you to determine your code size.

Regarding the size of the emulated EEPROM (not included in the code size), you can find the formula to determine it in the AN4894 on EEPROM Emulation (https://www.st.com/resource/en/application_note/dm00311483-eeprom-emulation-techniques-and-software-for-stm32-microcontrollers-stmicroelectronics.pdf).

Btw, you should at least be able to read/write the first 5 EEPROM values stored so there might effectively be a problem somewhere.

So I can help you:

* Can you share your linker file ?

* As mentioned in my last message, the startup_stm32wb55xx_cm4.s file used in the EEPROM emul project should be the starting startup file for your customized project if you use EEPROM emulation.

* How can you detect the returned status (EE error) if debugging does not work ? Does the debug ability stops after the failed operation ?

* Also the screenshot you have shared show a break address below the start address for your code (Is this area used by your OTA app ?). Can you try to click disassembly (options proposed in your screenshot) and share with me if the assembly code highlights a specific function ?

Thanks,

Have a great end of year period.

Adam

GBehe
Associate III

Hi Adam,

I am doing good now.

I use STM32Cube IDE. I could find out the code size at Build analyzer. Its showing 156.21KB (35.5%).

I could also figure out the space available for EEPROM emulation, by opening STM32CubeProgrammer. I am looking at the flash memory map, found out that up to 0x0803D000 my code is present. So from 0x0803E000 to 0x08056000 I can use for emulation. Because from 0x08057000, the FUS and BLE stack binary resides.

Is this a wrong way of knowing the available space for emulation?

My emulating START_PAGE_ADDRESS is 0x08040000.

For testing, just before while(1), I was calling the function for EEPROM emulation. And I had the problem of only being able to emulate the first address.

Now I am calling the function in while(1). Its now working fine. I don't have any idea why it behaved like this. However, first I tried to emulate 5 addresses. I am printing the return status of Read and write functions. Also I am printing the written value along with read back value as shown below.

 ee_status = EE_WriteVariable32bits(Index, 3*Index);

USBPrint("\r\nWrite status: %d\r\n",ee_status);

 ee_status|= EE_ReadVariable32bits(Index, &a_VarDataTab[Index-1]);

 USBPrint("\r\nRead status: %d\r\n",ee_status);

if (3*Index != a_VarDataTab[Index-1])

{

USBPrint("\r\nEEPROM emul Read value did not match written value. a_VarDataTab[%d] = %d\r\n", Index, a_VarDataTab[Index-1]);

}

else

{

     USBPrint("\r\nEEPROM emul written value at index[%d] is %d. Read value is: %d.\r\n", Index, 2*Index, a_VarDataTab[Index-1]);

}

So, at first, for few emulated written values, I got the prints correct. But could not see those addresses filled with any value when checked the memory map in STM32CubeProgrammer. I checked multiple times, no data was there. Later when I increased the number of to be emulated values, to 100+, I could see those address filled with some data. Again later tried with few values like 5 numbers. This time it showed. Can this be a problem later?

The screenshot I had shared, shows address which comes in the OTA application region. Debug stops at the main with the error message in the screenshot.

Please find the screenshot of disassembly (options proposed in my screenshot).

How can I check the startup_stm32wb55xx_cm4.s file should be the starting startup file of my project?

Thank you.

Have a great end of year to yo too!!!

GBehe
Associate III

This is my linker file where I set the start address of my application after OTA application. As this kind of files are not supported here to upload I made it a notepad file.

Thank you..

Adam Santamaria
Associate II

Hello GBehe

For me, it's okay to verify the available space for emulation this way.

Which while(1) are you talking about ? Don't you use the sequencer to add tasks in your BLE application ?

Also have you implemented the EEPROM_Emul_Init function as in the app_entry.c file of X-CUBE-EEPROM ?

Regarding your description of your observation (flash is filled only with a high number of transactions), the first thing coming to my mind is that the EEPROM emulator is filling the second " flash pool" and has erased the first one (2nd pool address should be EEPROM_START_ADDRESS + 1/2*EEPROM_SIZE). So until the 2nd pool is not fully filled, you will see nothing at 0x08040000 and more precisely in the whole 1st pool.

The index you pass to the W and R functions does not correspond to a localization in EEPROM but to a label for the variable.

Have you started with the BLE_HeartRate_ota app from the Cube Package and followed the information in AN5247 https://www.st.com/resource/en/application_note/dm00556294-overtheair-application-and-wireless-firmware-update-for-stm32wb-series-microcontrollers-stmicroelectronics.pdf ? To help you and understand better your problem I could try myself to implement EEPROM Emulation in this application.

For STM32CubeIDE the startup file is called startup_stm32wb55rgvx.s and not startup_stm32wb55xx_cm4.s. It is located in STM32CubeIDE/Application/User/Startup. If you are using the BLE_HeartRate_ota app I have checked and its startup file is the same than the X-CUBE-EEPROM one.

BR,

Adam

GBehe
Associate III

Hi Adam.

In a function(eeprom_emulation()), I am initializing the EEPROM emulation followed by doing HAL_FLASH_Unlock() and then I am doing write operation and read operation in a for loop with multiple addresses/locations. Then I do HAL_FLASH_Lock(). Just this much.

When I called this function just before while(1) as below, I faced problem.

 eeprom_emulation();

 while (1)

 {

     UTIL_SEQ_Run( UTIL_SEQ_DEFAULT );

Yes I am not using task implementation in the sequencer. I had just called the  "eeprom_emulation();" function on a button press, next to the sequencer.

After this it worked. Is this unacceptable?

Yes I had started with the BLE_HeartRate_ota app from the Cube Package first. It worked fine. Then my own customized OTA project also works fine. It gets uploaded form phone.

I could find the startup file in my project in STM32CubeIDE/Core/Startup. Its "startup_stm32wb55xxcgux.s". But when I open it, startup_stm32wb55xx_cm4.s opens up in Cube IDE. I had put a break point just for test, at line 142 - " .word Reset_Handler". On debug, I get the same message which I shared in screenshot. Its breaking at an address which starts before 0x08007000(starting address of my program). Am I doing any mistake in tracing out things?

Thank you.