Sigfox : how to upgrade firmware automatically

You may had some problem to reflash your TD1208 once you load the blink example or your own code in the device. This is because you need to reset the device to reach the firmware upgrade procedure during boot procedure.

On of the way to do it is to perform a hard reset putting Reset pin to ground during TDLoader Sync process. The other way is to add some lines in your code to create a soft reset. Here is an example on howto do it :

void TD_USER_Setup(void)
{
    // Initialize the LEUART
    init_printf(TD_UART_Init(9600, true, false),
                TD_UART_Putc,
                TD_UART_Start,
                TD_UART_Stop);
}

void TD_USER_Loop(void)
{
    while ((c = TD_UART_GetChar()) >= 0) {
        NVIC_SystemReset();
    }
}

When the loader is waiting for the bootloader sequence, it send communication over the serial line. In this example, when a such communication is detected, the system is calling a soft reset, starting the boot sequence and as a consequence the firmware upgrade automatically.

The next step will be to identify what type of data is transmitted to manage this softreset only when a sync message is transmitted. Using freeserialanalyzer I was able to see that the TDLoader is starting by sending ATZ command twice over the serial line. This AT command is reseting the device and this is why when you are using a modem firmware You do not have to perform a hard reset. So now, it is possible to detect this sequence of characters in the TD_USER_Loop() to perform the soft reset automatically.

// Manage Soft reset listening serial line (ATZ)
char * resetString = "ATZ\r\n";
char * resetStringPtr;

void TD_USER_Setup(void)
{
    // Initialize the LEUART
    init_printf(TD_UART_Init(9600, true, false),
                TD_UART_Putc,
                TD_UART_Start,
                TD_UART_Stop);
    resetStringPtr = resetString;
}

void TD_USER_Loop(void)
{
    int c;
    while ((c = TD_UART_GetChar()) >= 0) {
        if ( (char)c == *resetStringPtr ) resetStringPtr++;
        else resetStringPtr = resetString;
        if ( *resetStringPtr == 0 ) {
           tfp_printf("OK\r\n");
           TD_RTC_Delay(T500MS);
           NVIC_SystemReset();
        }
    }
}

The two lines in blue are not needed for a TDLoader use but is recommanded if you are using cflash console tool as this tools expect ans answer from ATZ and wait a certain time to send flood message that will change the bootup sequence for going in upgrade mode.

9 thoughts on “Sigfox : how to upgrade firmware automatically

  1. Good afternoon,

    We have recently acquired a TD1208 chipset and we are currently trying to do our preliminar functional tests on it using several example programs provided by Telecom Design as well. The problem comes when we want to reset and/or load a differen program in the TD1208, since we cannot load the new program from Eclipse, having to use the firmware loader application (TDLoader) provided in the developer kit. Is this intended to be like this? Are we missing something?

    Besides, we would like to know if it is possible to detach the board where the TD 1208 is located, from the auxilliary connector board used to connect the TD1208 module to a tester board ( Tiny Gecko in our case).

    Thanks in advance for your consideration.

    Best regards.

    • I had to move your comment to the right place. I assume this post will bring you an answer.
      Concerning the capability to detach TD1208, I have no idea as I do not have the test board, I did myne.

      • In fact it is more a question of rebooting the device to get it listening on update than a question of tool itself

  2. Hello paul ,

    i am trying to run the cflash utility by using gcc compiler inorder to reset and reflash the telecom design firmware can you give me some information how to run and test the cflash directory files? becasue i ahve tried to compile but alwyas it is showing the features. h library fiels missing,and do i ahve to include all those necessaty library files externally?

    Thank you
    prabhu

    • I just run make cflash on a Linux and it works. So i can’t tell you what are the needed headers that are not standard, do you have some error lines to copy for investigation ?

      • Hi,

        is it possible to get a copy of you cflash code because mine doesn’t word on TD1205P (no Reset sent).

        Thanks

      • The cflash is part of the TD SDK.
        I’ll take a look if I modified it or not.
        I’m using it on a raspberry Pi with a FTDI cable.
        Be careful to be able to use it you need to have your firmware accepting ATZ command for reseting. Otherwise you need to make a manual reset right on time and it is a bit complex.
        I also remind that some use atz or ATZ and ATZ\r\n vs ATZ\n … take a ook in this direction.

  3. Hi, Paul!
    I want to say that you could to identify what type of data is transmitted using Serial Port Monitor as well.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.