cancel
Showing results for 
Search instead for 
Did you mean: 

Steps to perform Firmware Upgrade using ST25DV dynamic tag

Nikhil D&K
Senior

Hello,

I would like to know how can i perform the Device Firmware upgrade using ST25DV dynamic tag.I am using "en.STSW-ST25DV001SC-Source_v1.2.0" and tried out both demonstration examples

  1. ST25DVDemo ( firmware update using internal flash)

I am able to perform firmware update using ST25DV demo example, but after reset it jumps to original firmware.

So i would like to know how can i implement a firmware upgrade feature using "ST25DVDemo" example so that after reset it boots to the uploaded firmware instead of the old firmware.

Thanks,

Nikhil.

36 REPLIES 36

Hello @Rene Lenerve​ , thanks for clarification.

Before directly testing the dual bank swap on the downloaded upgraded firmware via NFC, i though of testing the dual bank swap with two demo application program.

Main Program (Bank 1 :0x08000000): Blinking on-board led at interval of 2 seconds. After 10 toggles, i am calling the function toggleBankAndReset which contains code which you provided yesterday to swap banks and reset.

Upgraded Program (Bank 2: 0x08080000): Blinking on-board led at interval of 500 milli-seconds.

void toggleBankAndReset() {
    FLASH_OBProgramInitTypeDef OBInit;
    HAL_FLASH_Unlock();
    __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_OPTVERR);
    HAL_FLASH_OB_Unlock();
    HAL_FLASHEx_OBGetConfig(&OBInit);
 
    OBInit.OptionType = OPTIONBYTE_USER;
    OBInit.USERType = OB_USER_BFB2;
 
    if (((OBInit.USERConfig) & (OB_BFB2_ENABLE)) == OB_BFB2_ENABLE) {
        OBInit.USERConfig = OB_BFB2_DISABLE;
    } else {
        OBInit.USERConfig = OB_BFB2_ENABLE;
    }
    if (HAL_FLASHEx_OBProgram(&OBInit) != HAL_OK) {
        // uint32_t errorCode = HAL_FLASH_GetError();
        while (1) {
            HAL_Delay(1000);
            HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
        }
    }
    if (HAL_FLASH_OB_Launch() != HAL_OK) {
        //uint32_t errorCode = HAL_FLASH_GetError();
        while (1) {
            HAL_Delay(100);
            HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
        }
    }
    HAL_FLASH_OB_Lock();
    HAL_FLASH_Lock();
}

In Main program, on calling the function toggleBankAndReset the device hangs (breaks) and no upgraded firmware is loaded even after pressing reset.

I have used STM32 Cube Programmer to flash the upgraded firmware at the Bank 2 address directly.

If possible can you provide me main.c file which implements the dual bank swap for demo purpose.

Rene Lenerve
ST Employee

Hi @NK.13omalan​,

Reading the Reference manual of the STM32L496 there is a note saying that when swapping to Bank 2 you need to relocate the vector table.

"Note: When booting from bank 2, the boot loader will swap the Flash memory banks.

Consequently, in the application initialization code, you have to relocate the vector table to

bank 2 swapped base address (0x0800 0000) using the NVIC exception table and offset

register."

So it it is probably the reason why it doesn't boot. Sorry for the confusion on this point.

Hope this can help you.

Kind Regards.

Hello @Rene Lenerve​ ,

Does that mean i have to call NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x4000) function. And if yes, were should i call this function before HAL_Init() in upgraded firmware ?

Rene Lenerve
ST Employee

Hi @NK.13omalan​,

You probably can use it before calling HAL_Init() (I didn't try it so I'm not sure if it works correctly). but the new vector table is at the first address of the firmware, so where you programmed your binary.

So maybe you probably need to change the value of VECT_TAB_OFFSET in system_stm32l4xx.c to match the correct address too, and the scatter file to set firmware address to the linker.

Kind Regards.

Hello @Rene Lenerve​,

We were able to perform a sample firmware update using the ST25DV_Demo example running on STM32L496 as our main firmware (Bank 1) and the demo upgraded firmware we selected was FLASH_DualBoot_Bank2 project present in the official repository.

Path for the upgraded firmware (FLASH_DualBoot_Bank2) :

" STM32Cube_FW_L4_V1.17.2/Projects/NUCLEO-L496ZG/Examples/FLASH/FLASH_DualBoot/SW4STM32/FLASH_DualBoot_Bank2 "

We are able to switch banks from the ST25DV_DEMO Bank1 firmware example to FLASH_DualBoot_Bank2 example running on Bank 2. When the device is running the FLASH_DualBoot_Bank2 , on user button press we were able to swap the banks again and were able to run NFC example again.

You can check out the main.c code in FLASH_DualBoot_Bank2 for reference.

Query 1:

Now the issue arises when i want to use different example for upgrading purpose instead of the FLASH_DualBoot_Bank2 example. For say if i am running ST25DV_Demo example on Bank1 . And i want to upgrade to firmware similar to ST25DV_Demo example with newer major minor version info and led blinking added to it to differentiate between examples in Bank 1 and Bank 2. I am successfully able to write to Bank 2 the modified ST25DV_Demo example but after swapping the bank the firmware doesn't work after swap.

Note: We also tried using simple blinky example for Bank 2, but that also didn't worked. We were only able to successfully upgrade using DuablBootBank2 example.

What could be the reason here because i am able to successfully upgrade to FLASH_DualBoot_Bank2 example but unable to upgrade to modified ST25DV_Demo example ?

Query 2:

I also wanted to know how the controller get reseted after we set the BFB2 byte, because i don't see anywhere reset function being called.

Rene Lenerve
ST Employee

Hi @NK.13omalan​,

There is some threads in the MCU section of the ST community forum that mention issues with the reboot on some boards (for dual bank) and they have to use this function to reset : HAL_NVIC_SystemReset(); after HAL_FLASH_OB_Launch();.

Your question has shifted from the tag issue to an MCU issue, you should post this kind of question in the MCU section to have more people aware about this topic (This thread is mostly read by people aware about NFC tags and readers).

Kind Regards.

Hello @Rene Lenerve​ ,

Thanks for support we were able to successfully perform the firmware update.

I would like to know, is there any easy way of migrating code made for ST25DV04K to ST25DV04KC.

And do i have to make any changes in my Desktop application for communicating with ST25DV04KC ? Currently desktop application is successfully able to communicate with ST25DV04K using ST25R3911B software.

And is ST25DV04K obsolete ?

Rene Lenerve
ST Employee

Hi @NK.13omalan​,

There are some minor changes between ST25DV04K and ST25DV04KC and it mainly impacts firmware. You can have a look in the AN5633: Migrating from ST25DVxxK to ST25DVxxKC (https://www.st.com/content/ccc/resource/technical/document/application_note/group1/0f/6b/06/3d/eb/bd/48/03/DM00776361/files/DM00776361.pdf/jcr:content/translations/en.DM00776361.pdf) to get more information.

So, you shouldn't have to change anything on your Desktop Application (or maybe only if you read some registers the content might be a little bit different, you can check AN5633 in that case).

On firmware side, you need to get component drivers for the ST25DVxxKC, as there is some changes on some registers and BSP drivers too. But, normally if you already get the STSW-ST25DV002 package, you have both drivers used in the demo, and you can have an example on how to manage both components in the same code.

I hope this can help you on your development.

Kind Regards.

Hello, i would also like to know is ST25DV04K is obsolete ?

Hello @Rene Lenerve​ ,

We replaced the ST25DVxxK drivers with ST25DVxxKC drivers in our firmware project made for firmware update. We are using ST25R3911B NFC reader, but the software made for ST25R3911B doesn't have ST25DV04KC in dynamic tag option. So we are using ST25 Tag application for mobile.

We are facing issues while writing to EEPROM as well as performing firmware upgrade.

  1. EEPROM Issue:

Unable to write to the eeprom memory even when the mailbox is disabled (i.e MB_MODE=0) and the security session is open. I am currently using default settings for writing to EEPROM (i.e password protection disabled for writing to EEPROM and only single Area 1 covering al 128 blocks).

From firmware side i have performed the following steps :

Disabled MB --> Openeded I2C security session (psswd msb lsb = 0) -> Write to address block

I have also tried with out opening i2c security session as well but EEPROM blocks are not getting updated nor i am getting any sort of error while writing.

But when i try to write to EEPROM using mobile application, i am able to write to EEPROM memory. So can you tell me the precise steps to use in firmware for writing to the EEPROM.

2. Firmware Upgrade Issue

Now when i start the firmware update procedure, READ_ID and PASSWORD command are initiated properly. Problem arises after i send one full segment payload (20 packets).

One full segment is received properly and the CRC at both the ends are calculated and matched successfully but after due to some unknown reason the firmware packets are . The calculated CRC and the CRC sent in the last packet of the first segment is same but for some reason the next segment transmission is halted from mobile app (reason unknown).

So can you help us, how to solve the above issues ?