2 Replies Latest reply on Jul 21, 2016 7:51 PM by MichaelF_56

    OTA issue with new image size and DSx length

    clrac_2121416

      I had an issue, where my new image was slightly larger than the DSx space was insufficient.  The original OTA files do not validate that the space is sufficient before it starts.  Additionally, it will continue to write past the end of the DSx block with spurious results.  I've attached the files I have used and tested just in case someone else runs into this issue.   Below are the diff's.

       

      ws_upgrade.h

      ***************

      *** 98,103 ****

      --- 98,111 ----

        * switch active partitions with the one that has been receiving the new image.

        *

        */

        void     ws_upgrade_finish(void);

       

       

      + /**

      +  * \validate that the new image length will fit in the DSx_Len space allocated for it!

      +  * \the new_len should pass in the value sent from the central performing the OTA to

      +  * initiate the download

      +  *

      +  */

      + UINT16 ws_upgrade_len_ok(UINT16 new_len);

      +

        #endif

       

       

      ws_upgrade..c:

      ***************

      *** 380,384 ****

      --- 380,392 ----

            bleappfwu_watchdogExpired(0);

       

       

            // End of the world - will not return.

        }

       

       

      + UINT16 ws_upgrade_len_ok(UINT16 new_len){

      +       //ble_trace2("ws_upgrade_len_ok: upgrade_ds_length: %d, new_len %d", upgrade_ds_length, new_len);

      +       if (new_len <= upgrade_ds_length){

      +               return 1;

      +       } else {

      +               return 0;

      +       }

      + }

       

       

      ws_upgrade_ota.c

      ***************

      *** 275,286 ****

      --- 275,292 ----

                    ws_upgrade_total_len            = data[1] + (data[2] << 8);

                    ws_upgrade_state                = WS_UPGRADE_STATE_DATA_TRANSFER;

       

       

                    ble_trace2("\rstate:%d total_len:%d", ws_upgrade_state, ws_upgrade_total_len);

       

       

      +             if( ws_upgrade_len_ok(ws_upgrade_total_len) ){

                                      ws_upgrade_send_status(WS_UPGRADE_STATUS_OK, 0);

                                      return (TRUE);

      +             } else {

      +               ws_upgrade_send_status(WS_UPGRADE_STATUS_INVALID_IMAGE, 0);

      +               return (FALSE);

      +             }

      +

                }

                break;

       

       

            case WS_UPGRADE_STATE_DATA_TRANSFER:

                if (command == WS_UPGRADE_COMMAND_VERIFY)