Skip to content

[Opta] Set default Eth MAC Address from OTP #595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions variants/OPTA/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ static const uint8_t SCK = PIN_SPI_SCK;
uint16_t _getVid_();
uint16_t _getPid_();

// Retrieve (Arduino OUI) Ethernet MAC Address from QSPIF OTP
uint8_t _getSecureEthMac_(uint8_t *);

#define BOARD_NAME "Arduino Opta"

#define DFU_MAGIC_SERIAL_ONLY_RESET 0xb0
Expand Down
15 changes: 15 additions & 0 deletions variants/OPTA/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,21 @@ uint16_t _getPid_() {
#endif
}

uint8_t _getSecureEthMac_(uint8_t *mac_address) {
if (!has_otp_info) {
getSecureFlashData();
}
memcpy(mac_address, ((OptaBoardInfo*)_boardInfo)->mac_address, 6);

return 6;
}

uint8_t mbed_otp_mac_address(char *mac)
{
auto ret = _getSecureEthMac_(reinterpret_cast<uint8_t *>(mac));
return ret;
}

#define BOARD_REVISION(x,y) (x << 8 | y)

void initVariant() {
Expand Down