[beken-72xx] Use chip ID based on MAC address

This commit is contained in:
Kuba Szczodrzyński
2022-07-07 18:01:35 +02:00
parent e37014ebd6
commit b2df9e6a8b
3 changed files with 14 additions and 5 deletions

View File

@@ -13,11 +13,16 @@
#define FLASH_OP_RDID 20
extern "C" {
#include <flash_pub.h>
#include <param_config.h>
#include <sys_ctrl.h>
#include <sys_rtos.h>
#include <wlan_ui_pub.h>
}
extern uint8_t system_mac[];
} // extern "C"
void LibreTuya::restart() {
bk_reboot();
@@ -35,10 +40,9 @@ const char *LibreTuya::getChipModel() {
}
uint32_t LibreTuya::getChipId() {
// TODO determine if this really is unique
uint32_t chipId = REG_READ(SCTRL_DEVICE_ID);
chipId &= 0xFFFFFF;
return chipId;
uint8_t mac[6];
cfg_load_mac(mac); // force loading MAC from TLV (ignore user-set WiFi MAC)
return (mac[3]) | (mac[4] << 8) | (mac[5] << 16);
}
uint8_t LibreTuya::getChipCores() {

View File

@@ -26,4 +26,7 @@ enum ChipType {
RTL8710L0 = CHIP_TYPE(F_RTL8710B, 0xFB), // CHIPID_8710BN_L0 / QFN32
RTL8711BN = CHIP_TYPE(F_RTL8710B, 0xFD), // CHIPID_8711BN / QFN48
RTL8711BU = CHIP_TYPE(F_RTL8710B, 0xFC), // CHIPID_8711BG / QFN68
// Beken 72XX
BK7231T = CHIP_TYPE(F_BK7231T, 0x1A), // *SCTRL_CHIP_ID = 0x7231a
BK7231N = CHIP_TYPE(F_BK7231N, 0x1C), // *SCTRL_CHIP_ID = 0x7231c
};

View File

@@ -47,6 +47,8 @@ def upload_uart(
except ValueError as e:
print(prefix, f"Writing failed: {e.args[0]}")
return False
# reboot the chip
bk.reboot_chip()
return True