Skip to main content
Visitor II
October 31, 2022
Solved

Steps to perform Firmware Upgrade using ST25DV dynamic tag

  • October 31, 2022
  • 13 replies
  • 7486 views

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.

    This topic has been closed for replies.
    Best answer by Rene Lenerve

    Hi @NK.13omalan​,

    Ok, with the dual bank I will list 3 ways to proceed, let me just summarize the concept for the dual bank.

    Double bank means the MCU has 2 flash memory areas which can be remapped using a dedicated option bytes. This remap allows to set the boot address to the bank1 or bank2 by resetting or setting this option byte. So, no need to change vector table address and compilation address with both firmware (original or updated),

    Option 1 : Original firmware is programmed in Bank1 (0x08000000), when doing firmware upgrade the new firmware is programmed at Bank2 address (0x08080000). When update is done the option byte BFB2 must be set to swap Bank address, then reset MCU to boot each time on Bank2 (now at 0x08000000) and Bank1 adress will be remapped at 0x08080000. You can repeat the operation but with Bank1 this time which will receive the new firmware (and so on).

    Option 2 : Original firmware in Bank1, Firmware upgrade firmware on Bank2. When performing the firmware upgrade swap Bank to Bank2 first to run the firmware upgrade procedure then erase Bank1, program with the new firmware and swap again to reboot to the new firmware.

    Option 3 : This is a on the fly firmware upgrade using RAM, here is the link for all the details on that technique https://www.st.com/content/ccc/resource/technical/document/application_note/group0/ab/6a/0f/b7/1a/84/40/c3/DM00230416/files/DM00230416.pdf/jcr:content/translations/en.DM00230416.pdf

    Another documentation that could give you some information on booting with STM32 : https://www.st.com/content/ccc/resource/technical/document/application_note/b9/9b/16/3a/12/1e/40/0c/CD00167594.pdf/files/CD00167594.pdf/jcr:content/translations/en.CD00167594.pdf

    You can find an example of code in the package stm32CubeL4 to perform the Bank swapping (https://www.st.com/en/embedded-software/stm32cubel4.html) in the folder Projects\NUCLEO-L476RG\Examples\FLASH\FLASH_DualBoot.

    I hope this gives you more details on how to proceed.

    Kind Regards.

    13 replies

    ST Employee
    December 5, 2022

    Hi @NK.13omalan​,

    Access to the USER memory doesn't need to open an I²C session. Access to the tag EEPROM of ST25DVxxK or ST25DVxxKC is identical, what could be the issue is the Reference IC number which is 0x24 or 0x26 for ST25DVxxK and 0x50 or 0x51 for ST25DVxxKC if it is checked by the firmware before.

    1. For the mailbox the ST25DVxxKC register has changed a little bit, please read the AN5633 chapter 5.2.3 to check if the Mailbox is correctly deactivated. (MB_MODE vs FTM, MB_WDG vs I2C_CFG).
    2. As in the first point can you check that the mailbox is properly configured while accessing the mailbox, GPO register has also changed, please check it too, chapter 5.2.1 and 5.2.2 (GPO is used in the FTM example).

    I hope this can help you.

    Kind Regards.

    Visitor II
    December 5, 2022

    Hello @Rene Lenerve​ ,

    EEPROM Issue:

    The reference IC number read from my ST25DVxxKC is 0x50.

    Below is the reference code snippet which i am using to write and read from EEPROM. Both the write and read operations are not working via firmware although the same operations are working using android app.

    /* Initialize ST25DV */
    ST25_RETRY(BSP_NFCTAG_Init(BSP_NFCTAG_INSTANCE));
     
    BSP_NFCTAG_ResetMBEN_Dyn(BSP_NFCTAG_INSTANCE);
     
    HAL_Delay(1000);
     
    uint8_t tx_buff[4] = {0x11,0x22,0x33,0x44}, rx_buff[4] = {0};
     
    ret = BSP_NFCTAG_Write_EEPROM(BSP_NFCTAG_INSTANCE, &tx_buff[0], 0x0004, sizeof(tx_buff));
     
    HAL_Delay(1000);
     
    if(ret == HAL_OK)
    {
    	ret = BSP_NFCTAG_Read_EEPROM(BSP_NFCTAG_INSTANCE, &rx_buff[0], 0x0004, sizeof(rx_buff));
    }	

    So can you please help us to diagnose the above issue ?

    Firmware Upgrade Issue:

    Below are the logs printed out after receiving of complete first segment (i.e 20 packets) when i use "ST25DV04K". Here as you can see in the logs, on the line 11 the Rx state changes to FTM_READ_WAIT_ACK_READ and everything works fine.

    [12:06:56:122] 22397 pkt.length - 0xf3�??�?�
    [12:06:56:122] 22400 pkt.totalLength - 0x0�??�?�
    [12:06:56:128] 22402 pkt.ctrl.byte - 0x69�??�?�
    [12:06:56:128] 22405 pkt.crc - 0x0�??�?�
    [12:06:56:128] 22407 pkt.has_crc - 0x0�??�?�
    [12:06:56:134] 22409 GetCrc 2004fe5a 243�??�?�
    [12:06:56:134] 22412 ST25FTM_GetCrc : 0x93c045fe�??�?�
    [12:06:56:139] 22415 segment_crc : 0x93c045fe�??�?�
    [12:06:56:139] 22418 computed_crc : 0x93c045fe�??�?�
    [12:06:56:145] 22421 FtmRx TxAck�??�?�
    [12:06:56:145] 22422 RxState = FTM_READ_WAIT_ACK_READ�??�?�
    [12:06:56:156] Alert pin INT �??�?�
    [12:06:56:158] 22437 lastAck=1�??�?�
    [12:06:56:163] 22439 ignoreRetrans=0�??�?�
    [12:06:56:163] 22441 Ending Segment 0�??�?�
    [12:06:56:169] 22443 receivedLen=4951�??�?�
    [12:06:56:169] 22445 validLen=4951�??�?�
    [12:06:56:169] 22447 totalvalid=4951�??�?�
    [12:06:56:169] 22449 FtmRx Continue reception�??�?�
    [12:06:56:180] 22459 RxState = FTM_READ_CMD�??�?�
    [12:06:56:257] Alert pin INT �??�?�

    Now when i use the "ST25DV04KC", after reception of one full segment the RxState doesn't changes to FTM_READ_WAIT_ACK_READ state.

    [12:06:56:122] 22397 pkt.length - 0xf3�??�?�
    [12:06:56:122] 22400 pkt.totalLength - 0x0�??�?�
    [12:06:56:128] 22402 pkt.ctrl.byte - 0x69�??�?�
    [12:06:56:128] 22405 pkt.crc - 0x0�??�?�
    [12:06:56:128] 22407 pkt.has_crc - 0x0�??�?�
    [12:06:56:134] 22409 GetCrc 2004fe5a 243�??�?�
    [12:06:56:134] 22412 ST25FTM_GetCrc : 0x93c045fe�??�?�
    [12:06:56:139] 22415 segment_crc : 0x93c045fe�??�?�
    [12:06:56:139] 22418 computed_crc : 0x93c045fe�??�?�
    [12:06:56:145] 22421 FtmRx TxAck�??�?�
    [12:06:56:169] 22449 FtmRx Continue reception�??�?�
    [12:06:56:180] 22459 RxState = FTM_READ_CMD�??�?�
    [12:06:56:257] Alert pin INT �??�?�

    Can you please let me know what could be the issue here ?

    ST Employee
    December 5, 2022

    Hi @NK.13omalan​,

    EEPROM Issue:

    What is the return code of the function BSP_NFCTAG_Write_EEPROM?

    Can you also read the content of the register MBEN_Dyn after disabling it(you can use this BSP_NFCTAG_GetMBEN_Dyn or this one BSP_NFCTAG_ReadMBCtrl_Dyn).

    Firmware Upgrade Issue:

    Let's fix the EEPROM issue first then come back to this one after (it could be related).

    kind Regards.

    Visitor II
    December 6, 2022

    Hello @Rene Lenerve​ ,

    Firmware Upgrade Issue: Solved

    EEPROM Issue:

    Below is the code snippet which i am using to write and read data from EEPROM. After disabling mailbox, reading the dynamic register value gives 0x00 (i.e Mailbox off).

    WRITE OPERATION ISSUE:

    Using write data function we were successfully able to write data to EEPROM at different block address but for some reason i am not able to write to a particular block address 0x0024, return error code while writing operation is 0 (success). I am able to write at all other block address.

    READ OPERATION ISSUE:

    Even though i am able to write to the 0x0000 block address, i am unable to read data from the same address. The return error code while performing read operation is 0 (i.e) success, but when i check the read value it gives 0x00. Below in the code snippet i have also shown how i am reading the EEPROM data.

    /* Initialize ST25DV */
    ST25_RETRY(BSP_NFCTAG_Init(BSP_NFCTAG_INSTANCE));
     
    /* Dsiabling the mailbox */
    ret = BSP_NFCTAG_ResetMBEN_Dyn(BSP_NFCTAG_INSTANCE);
     
    /* Read mailbox dynamic register */
    //Read Mailbox Mode value (mb_mode)= 0x00;
    ret = BSP_NFCTAG_GetMBEN_Dyn(BSP_NFCTAG_INSTANCE,&mb_mode);
     
    HAL_Delay(500);
     
    uint8_t tx_buff1[4] = {0x11,0x24,0x36,0x48}, rx_buff[4] = {0};
    uint8_t tx_buff2[4] = {0x10,0x20,0x30,0x40};
     
    ret = BSP_NFCTAG_Write_EEPROM(BSP_NFCTAG_INSTANCE, &tx_buff1[0], 0x0024, sizeof(tx_buff1));
    HAL_Delay(20);
    ret = BSP_NFCTAG_Write_EEPROM(BSP_NFCTAG_INSTANCE, &tx_buff2[0], 0x0028, sizeof(tx_buff2));
     
    HAL_Delay(500);
     
     
    /* Reading operation is succesfful but data read is 0. */ 
    if(ret == HAL_OK)
    {
    ret = BSP_NFCTAG_Read_EEPROM(BSP_NFCTAG_INSTANCE, &rx_buff[0], 0x0024, sizeof(rx_buff));
    ret = BSP_NFCTAG_Read_EEPROM(BSP_NFCTAG_INSTANCE, &rx_buff[0], 0x0028, sizeof(rx_buff));
    }

    So can you please help us to resolve this EEPROM write and read issue ?

    ST Employee
    December 6, 2022

    Hi @NK.13omalan​,

    That's strange there is no difference between address 0x0024 and 0x0028, I tried on my side your code and it was working correctly (read and write) for me. Do you have the possibility to try another ST25DV chip to check that your chip is ok?

    Can you send the content of rx_buff1 and rx_buff2 using the following functions (or corresponding function in your code):

    uint8_t rx_buff1[32] = {0};
    uint8_t rx_buff2[8] = {0};
     
    BSP_NFCTAG_ReadRegister( 0, rx_buff1, 0x0000, 32 );
     
    BSP_NFCTAG_ReadData( 0, rx_buff2, 0x2000, 8 );

    To see if there is nothing wrong in your configuration.

    Great, that you solved your issue for the second topic.

    Kind regards.