Skip to content

Commit 946674e

Browse files
committed
Implement erease slot OSAL API to avoid using gecko bootloader platform calls in TLVs
1 parent 870523c commit 946674e

File tree

7 files changed

+63
-17
lines changed

7 files changed

+63
-17
lines changed

osal/efr32_wisun/osal_efr32_wisun.c

+17-1
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ osal_basetype_t osal_write_storage(osal_slotid_t slotid,
635635
}
636636

637637
ret = bootloader_writeStorage(__slotid2gblslotid(slotid), offset, data, len);
638-
638+
639639
if (ret != BOOTLOADER_OK) {
640640
DPRINTF("write_storage: bootloader_writeStorage failed\n");
641641
return OSAL_FAILURE;
@@ -644,6 +644,22 @@ osal_basetype_t osal_write_storage(osal_slotid_t slotid,
644644
return OSAL_SUCCESS;
645645
}
646646

647+
osal_basetype_t osal_erase_storaqe(osal_slotid_t slotid, osal_csmp_slothdr_t *slot)
648+
{
649+
int32_t ret = 0l;
650+
651+
if (slot == NULL) {
652+
return OSAL_FAILURE;
653+
}
654+
655+
ret = bootloader_eraseStorageSlot(__slotid2gblslotid(slotid));
656+
657+
if (ret != BOOTLOADER_OK) {
658+
return OSAL_FAILURE;
659+
}
660+
661+
return OSAL_SUCCESS;
662+
}
647663

648664
osal_basetype_t osal_deploy_and_reboot_firmware(osal_slotid_t slotid, osal_csmp_slothdr_t *slot)
649665
{

osal/freertos/osal_freertos.c

+13-6
Original file line numberDiff line numberDiff line change
@@ -530,14 +530,21 @@ osal_basetype_t osal_write_storage(osal_slotid_t slotid,
530530
uint8_t *data,
531531
uint32_t len)
532532
{
533-
(void) slotid;
534-
if (slot == NULL || data == NULL || !len) {
535-
return OSAL_FAILURE;
536-
}
533+
(void) slotid;
534+
if (slot == NULL || data == NULL || !len) {
535+
return OSAL_FAILURE;
536+
}
537537

538-
(void) memcpy(&slot->image[offset], data, len);
538+
(void) memcpy(&slot->image[offset], data, len);
539+
540+
return OSAL_SUCCESS;
541+
}
539542

540-
return OSAL_SUCCESS;
543+
osal_basetype_t osal_erase_storaqe(osal_slotid_t slotid, osal_csmp_slothdr_t *slot)
544+
{
545+
(void) slotid;
546+
(void) slot;
547+
return OSAL_SUCCESS;
541548
}
542549

543550
osal_basetype_t osal_deploy_and_reboot_firmware(osal_slotid_t slotid, osal_csmp_slothdr_t *slot)

osal/linux/osal_linux.c

+6
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,12 @@ osal_basetype_t osal_write_storage(osal_slotid_t slotid,
515515
return OSAL_SUCCESS;
516516
}
517517

518+
osal_basetype_t osal_erase_storaqe(osal_slotid_t slotid, osal_csmp_slothdr_t *slot)
519+
{
520+
(void) slotid;
521+
(void) slot;
522+
return OSAL_SUCCESS;
523+
}
518524

519525
osal_basetype_t osal_deploy_and_reboot_firmware(osal_slotid_t slotid, osal_csmp_slothdr_t *slot)
520526
{

osal/osal.h

+18-5
Original file line numberDiff line numberDiff line change
@@ -611,11 +611,11 @@ osal_basetype_t osal_write_firmware_slothdr(osal_slotid_t slotid, osal_csmp_slot
611611
/****************************************************************************
612612
* @fn osal_write_storage
613613
* @brief write data to the storage
614-
* @param[in] slotid slot id
615-
* @param[in] slot slot structure
616-
* @param[in] offset offset to write
617-
* @param[in] data data to write
618-
* @param[in] len length of data
614+
* @param[in] slotid slot id
615+
* @param[in] slot slot structure
616+
* @param[in] offset offset to write
617+
* @param[in] data data to write
618+
* @param[in] len length of data
619619
* @return returns 0 on success and -1 on error
620620
*****************************************************************************/
621621
osal_basetype_t osal_write_storage(osal_slotid_t slotid,
@@ -624,6 +624,19 @@ osal_basetype_t osal_write_storage(osal_slotid_t slotid,
624624
uint8_t *data,
625625
uint32_t len);
626626

627+
628+
/****************************************************************************
629+
* @fn osal_erase_storage
630+
*
631+
* @brief Erase storage.
632+
*
633+
* @param[in] slotid Slot ID.
634+
* @param[in] slot Pointer to slot structure.
635+
*
636+
* @return Returns 0 on success and -1 on error.
637+
*****************************************************************************/
638+
osal_basetype_t osal_erase_storaqe(osal_slotid_t slotid, osal_csmp_slothdr_t *slot);
639+
627640
/****************************************************************************
628641
* @fn osal_deploy_and_reboot_firmware
629642
*

sample/tlvs/efr32_wisun_tlvs.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
#include "sl_wisun_app_core.h"
2929
#include "../../src/lib/debug.h"
3030

31-
#include "btl_interface.h"
32-
3331
#define nexthop_IP "fe80::a00:27ff:fe3b:2ab1"
3432

3533

@@ -687,8 +685,8 @@ void transferRequest_post(tlvid_t tlvid, Transfer_Request *tlv) {
687685
// Initiliase new transfer - done
688686
g_initxfer = false;
689687

690-
DPRINTF("Erasing gecko bootloader 'UPLOAD' storage slot...\n");
691-
assert(bootloader_eraseStorageSlot(GECKO_BTL_UPLOAD_SLOT_ID) == BOOTLOADER_OK);
688+
DPRINTF("Erasing 'UPLOAD' storage slot...\n");
689+
assert(osal_erase_storaqe(UPLOAD_IMAGE, &g_slothdr[UPLOAD_IMAGE]) == OSAL_SUCCESS);
692690

693691
DPRINTF("## sample_firmwaremgmt: POST for TLV %ld done.\n", tlvid.type);
694692
}

sample/tlvs/freertos_tlvs.c

+3
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,9 @@ void transferRequest_post(tlvid_t tlvid, Transfer_Request *tlv) {
679679
// Initiliase new transfer - done
680680
g_initxfer = false;
681681

682+
DPRINTF("Erasing 'UPLOAD' storage slot...\n");
683+
assert(osal_erase_storaqe(UPLOAD_IMAGE, &g_slothdr[UPLOAD_IMAGE]) == OSAL_SUCCESS);
684+
682685
DPRINTF("## sample_firmwaremgmt: POST for TLV %d done.\n", tlvid.type);
683686
}
684687

sample/tlvs/linux_tlvs.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,9 @@ void transferRequest_post(tlvid_t tlvid, Transfer_Request *tlv) {
739739
// Initiliase new transfer - done
740740
g_initxfer = false;
741741

742+
DPRINTF("Erasing 'UPLOAD' storage slot...\n");
743+
assert(osal_erase_storaqe(UPLOAD_IMAGE, &g_slothdr[UPLOAD_IMAGE]) == OSAL_SUCCESS);
744+
742745
DPRINTF("## sample_firmwaremgmt: POST for TLV %d done.\n", tlvid.type);
743746
}
744747

@@ -848,7 +851,7 @@ void imageBlock_post(tlvid_t tlvid, Image_Block *tlv) {
848851
}
849852

850853
osal_basetype_t ret = OSAL_FAILURE;
851-
854+
852855
// Write image block to slot at valid offset
853856
if (offset < OSAL_CSMP_FWMGMT_SLOTIMG_SIZE &&
854857
((offset + g_imageBlock.blockdata.len) < OSAL_CSMP_FWMGMT_SLOTIMG_SIZE)) {

0 commit comments

Comments
 (0)