/btstack_tlv_flash_sector: fix valid tlv storage detection for bank 0

This commit is contained in:
Matthias Ringwald 2017-06-06 12:04:56 +02:00
parent b6c1f7f5cc
commit 609709dad2

View File

@ -32,6 +32,7 @@
#include "btstack_tlv_flash_sector.h" #include "btstack_tlv_flash_sector.h"
#include "btstack_debug.h" #include "btstack_debug.h"
#include "btstack_util.h" #include "btstack_util.h"
#include "btstack_debug.h"
#include <string.h> #include <string.h>
@ -96,7 +97,7 @@ static int btstack_tlv_flash_sector_get_latest_bank(btstack_tlv_flash_sector_t *
uint8_t header1[BTSTACK_TLV_HEADER_LEN]; uint8_t header1[BTSTACK_TLV_HEADER_LEN];
self->hal_flash_sector_impl->read(self->hal_flash_sector_context, 0, 0, &header0[0], BTSTACK_TLV_HEADER_LEN); self->hal_flash_sector_impl->read(self->hal_flash_sector_context, 0, 0, &header0[0], BTSTACK_TLV_HEADER_LEN);
self->hal_flash_sector_impl->read(self->hal_flash_sector_context, 1, 0, &header1[0], BTSTACK_TLV_HEADER_LEN); self->hal_flash_sector_impl->read(self->hal_flash_sector_context, 1, 0, &header1[0], BTSTACK_TLV_HEADER_LEN);
int valid0 = memcmp(header1, btstack_tlv_header_magic, BTSTACK_TLV_HEADER_LEN-1) == 0; int valid0 = memcmp(header0, btstack_tlv_header_magic, BTSTACK_TLV_HEADER_LEN-1) == 0;
int valid1 = memcmp(header1, btstack_tlv_header_magic, BTSTACK_TLV_HEADER_LEN-1) == 0; int valid1 = memcmp(header1, btstack_tlv_header_magic, BTSTACK_TLV_HEADER_LEN-1) == 0;
if (!valid0 && !valid1) return -1; if (!valid0 && !valid1) return -1;
if ( valid0 && !valid1) return 0; if ( valid0 && !valid1) return 0;