Skip to content

Commit 1399d64

Browse files
committed
Revert "Opta: secure_qspi: simplify code"
This reverts commit 9f8a26b.
1 parent 46bf5d0 commit 1399d64

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

variants/OPTA/variant.cpp

+8-6
Original file line numberDiff line numberDiff line change
@@ -283,17 +283,19 @@ static bool has_otp_info = false;
283283

284284
bool getSecureFlashData() {
285285
static OptaBoardInfo info;
286-
char temp_buf[sizeof(OptaBoardInfo) + 1];
287-
int ret = QSPI_STATUS_OK;
288-
mbed::QSPI _qspi(QSPI_FLASH1_IO0, QSPI_FLASH1_IO1, QSPI_FLASH1_IO2, QSPI_FLASH1_IO3, QSPI_FLASH1_SCK, QSPI_FLASH1_CSN, QSPIF_POLARITY_MODE_0);
289-
auto rxlen = sizeof(temp_buf);
290-
ret = _qspi.read(0x48, -1, 1 << 13, temp_buf, &rxlen);
286+
uint8_t temp_buf[sizeof(OptaBoardInfo) + 1];
287+
int ret = 0;
288+
static SecureQSPIFBlockDevice secure_root;
289+
secure_root.init();
290+
// read secure sector 2 ( address 1 << 13 )
291+
ret = secure_root.readSecure(temp_buf, (1 << 13), sizeof(temp_buf));
291292
memcpy(&info, &temp_buf[1], sizeof(OptaBoardInfo));
292293
if (info.magic == OTP_QSPI_MAGIC) {
293294
_boardInfo = (uint8_t*)&info;
294295
has_otp_info = true;
295296
}
296-
return ret == QSPI_STATUS_OK;
297+
secure_root.deinit();
298+
return ret == 0;
297299
}
298300

299301
uint8_t* boardInfo() {

0 commit comments

Comments
 (0)