Skip to content

Commit e2ddcdf

Browse files
authored
Merge pull request #563 from facchinm/qspi_subclassing
[Portenta] Finally fix RTC drift and read proper information from the board
2 parents 9ce4568 + ceeeab4 commit e2ddcdf

16 files changed

+32055
-31549
lines changed
Binary file not shown.
Binary file not shown.

cores/arduino/mbed/storage/blockdevice/COMPONENT_QSPIF/include/QSPIF/QSPIFBlockDevice.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,11 @@ class QSPIFBlockDevice : public mbed::BlockDevice {
340340
QSPIF_BP_CLEAR_SR, // Clear protection bits in status register 1
341341
};
342342

343+
protected:
343344
// QSPI Driver Object
344345
mbed::QSPI _qspi;
345346

347+
private:
346348
// Static List of different QSPI based Flash devices csel that already exist
347349
// Each QSPI Flash device csel can have only 1 QSPIFBlockDevice instance
348350
// _devices_mutex is used to lock csel list - only one QSPIFBlockDevice instance per csel is allowed

libraries/STM32H747_System/examples/STM32H747_getBootloaderInfo/STM32H747_getBootloaderInfo.ino

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
uint8_t* bootloader_data = (uint8_t*)(0x801F000);
22
uint8_t* bootloader_identification = (uint8_t*)(0x80002F0);
33

4+
#if __has_include("portenta_info.h")
5+
#include "portenta_info.h"
6+
#define GET_OTP_BOARD_INFO
7+
uint8_t* boardInfo();
8+
#endif
9+
410
void setup() {
511
Serial.begin(115200);
612
while (!Serial) {}
@@ -23,6 +29,20 @@ void setup() {
2329
Serial.println("QSPI size: " + String(bootloader_data[7]) + " MB");
2430
Serial.println("Has Video output: " + String(bootloader_data[8] == 1 ? "Yes" : "No"));
2531
Serial.println("Has Crypto chip: " + String(bootloader_data[9] == 1 ? "Yes" : "No"));
32+
33+
#ifdef GET_OTP_BOARD_INFO
34+
auto info = *((PortentaBoardInfo*)boardInfo());
35+
if (info.magic == 0xB5) {
36+
Serial.println("Secure info version: " + String(info.version));
37+
Serial.println("Secure board revision: " + String(info.revision >> 8) + "." + String(info.revision & 0xFF));
38+
Serial.println("Secure carrier identification: " + String(info.carrier >> 8) + "." + String(info.revision & 0xFF));
39+
Serial.println("Secure vid: 0x" + String(info.vid, HEX));
40+
Serial.println("Secure pid: 0x" + String(info.pid, HEX));
41+
Serial.println("Secure mac: " + String(info.mac_address[0], HEX) + ":" + String(info.mac_address[1], HEX) + ":" +
42+
String(info.mac_address[2], HEX) + ":" + String(info.mac_address[3], HEX) + ":" +
43+
String(info.mac_address[4], HEX) + ":" + String(info.mac_address[5], HEX));
44+
}
45+
#endif
2646
}
2747

2848
String getUSBSpeed(uint8_t flag) {

libraries/STM32H747_System/examples/STM32H747_manageBootloader/STM32H747_manageBootloader.ino

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
#include "LittleFileSystem.h"
55
#include "FATFileSystem.h"
66
#if defined(ARDUINO_PORTENTA_H7_M7)
7+
#include "portenta_info.h"
78
#include "portenta_bootloader.h"
89
#include "portenta_lite_bootloader.h"
910
#include "portenta_lite_connected_bootloader.h"
1011
#include "mcuboot_bootloader.h"
1112
#include "ecdsa-p256-encrypt-key.h"
1213
#include "ecdsa-p256-signing-key.h"
14+
#define GET_OTP_BOARD_INFO
1315
#elif defined(ARDUINO_NICLA_VISION)
1416
#include "nicla_vision_bootloader.h"
1517
#endif
@@ -42,6 +44,8 @@ uint8_t* bootloader_identification = (uint8_t*)(BOOTLOADER_ADDR + bootloader_ide
4244
const unsigned char* bootloader_ptr = &bootloader_mbed_bin[0];
4345
long bootloader_len = bootloader_mbed_bin_len;
4446

47+
uint8_t* boardInfo();
48+
4549
void setup() {
4650
Serial.begin(115200);
4751
while (!Serial) {}
@@ -65,6 +69,20 @@ void setup() {
6569
Serial.println("Has Video output: " + String(bootloader_data[8] == 1 ? "Yes" : "No"));
6670
Serial.println("Has Crypto chip: " + String(bootloader_data[9] == 1 ? "Yes" : "No"));
6771

72+
#ifdef GET_OTP_BOARD_INFO
73+
auto info = *((PortentaBoardInfo*)boardInfo());
74+
if (info.magic == 0xB5) {
75+
Serial.println("Secure info version: " + String(info.version));
76+
Serial.println("Secure board revision: " + String(info.revision >> 8) + "." + String(info.revision & 0xFF));
77+
Serial.println("Secure carrier identification: " + String(info.carrier >> 8) + "." + String(info.revision & 0xFF));
78+
Serial.println("Secure vid: 0x" + String(info.vid, HEX));
79+
Serial.println("Secure pid: 0x" + String(info.pid, HEX));
80+
Serial.println("Secure mac: " + String(info.mac_address[0], HEX) + ":" + String(info.mac_address[1], HEX) + ":" +
81+
String(info.mac_address[2], HEX) + ":" + String(info.mac_address[3], HEX) + ":" +
82+
String(info.mac_address[4], HEX) + ":" + String(info.mac_address[5], HEX));
83+
}
84+
#endif
85+
6886
video_available = bootloader_data[8];
6987
wifi_available = bootloader_data[5];
7088

libraries/STM32H747_System/examples/STM32H747_manageBootloader/portenta_bootloader.h

Lines changed: 10580 additions & 10519 deletions
Large diffs are not rendered by default.

libraries/STM32H747_System/examples/STM32H747_manageBootloader/portenta_lite_bootloader.h

Lines changed: 10576 additions & 10515 deletions
Large diffs are not rendered by default.

libraries/STM32H747_System/examples/STM32H747_manageBootloader/portenta_lite_connected_bootloader.h

Lines changed: 10576 additions & 10515 deletions
Large diffs are not rendered by default.

libraries/STM32H747_System/src/Portenta_System.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "Portenta_System.h"
44
#include "Wire.h"
55
#include "mbed.h"
6+
#include "SecureQSPI.h"
67

78
#define PMIC_ADDRESS 0x08
89

libraries/STM32H747_System/src/Portenta_System.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class Portenta_System: public STM32H747
1212
Portenta_System() {};
1313
virtual bool begin();
1414
virtual bool enterLowPower();
15+
String getBoardRevision();
16+
uint16_t getCarrierSpecs();
1517
};
1618

1719
}

0 commit comments

Comments
 (0)