Skip to content

Commit b8581b4

Browse files
authored
Merge pull request #2721 from hathach/hild-add-metro-m7
HIL add metro m7
2 parents c633920 + 8be0d50 commit b8581b4

File tree

5 files changed

+39
-4
lines changed

5 files changed

+39
-4
lines changed

hw/bsp/board_api.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
* This file is part of the TinyUSB stack.
2525
*/
2626

27-
#ifndef _BOARD_API_H_
28-
#define _BOARD_API_H_
27+
#ifndef BOARD_API_H_
28+
#define BOARD_API_H_
2929

3030
#ifdef __cplusplus
3131
extern "C" {

hw/bsp/imxrt/family.c

+24
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "fsl_iomuxc.h"
4141
#include "fsl_clock.h"
4242
#include "fsl_lpuart.h"
43+
#include "fsl_ocotp.h"
4344

4445
#ifdef __GNUC__
4546
#pragma GCC diagnostic pop
@@ -186,6 +187,29 @@ uint32_t board_button_read(void) {
186187
return BUTTON_STATE_ACTIVE == GPIO_PinRead(BUTTON_PORT, BUTTON_PIN);
187188
}
188189

190+
size_t board_get_unique_id(uint8_t id[], size_t max_len) {
191+
(void) max_len;
192+
193+
#if FSL_FEATURE_OCOTP_HAS_TIMING_CTRL
194+
OCOTP_Init(OCOTP, CLOCK_GetFreq(kCLOCK_IpgClk));
195+
#else
196+
OCOTP_Init(OCOTP, 0u);
197+
#endif
198+
199+
// Reads shadow registers 0x01 - 0x04 (Configuration and Manufacturing Info)
200+
// into 8 bit wide destination, avoiding punning.
201+
for (int i = 0; i < 4; ++i) {
202+
uint32_t wr = OCOTP_ReadFuseShadowRegister(OCOTP, i + 1);
203+
for (int j = 0; j < 4; j++) {
204+
id[i*4+j] = wr & 0xff;
205+
wr >>= 8;
206+
}
207+
}
208+
OCOTP_Deinit(OCOTP);
209+
210+
return 16;
211+
}
212+
189213
int board_uart_read(uint8_t* buf, int len) {
190214
int count = 0;
191215

hw/bsp/imxrt/family.cmake

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ function(add_board_target BOARD_TARGET)
4444
${SDK_DIR}/drivers/igpio/fsl_gpio.c
4545
${SDK_DIR}/drivers/lpspi/fsl_lpspi.c
4646
${SDK_DIR}/drivers/lpuart/fsl_lpuart.c
47+
${SDK_DIR}/drivers/ocotp/fsl_ocotp.c
4748
${SDK_DIR}/devices/${MCU_VARIANT}/system_${MCU_VARIANT_WITH_CORE}.c
4849
${SDK_DIR}/devices/${MCU_VARIANT}/xip/fsl_flexspi_nor_boot.c
4950
${SDK_DIR}/devices/${MCU_VARIANT}/drivers/fsl_clock.c
@@ -75,6 +76,7 @@ function(add_board_target BOARD_TARGET)
7576
${SDK_DIR}/drivers/igpio
7677
${SDK_DIR}/drivers/lpspi
7778
${SDK_DIR}/drivers/lpuart
79+
${SDK_DIR}/drivers/ocotp
7880
)
7981

8082
update_board(${BOARD_TARGET})

hw/bsp/imxrt/family.mk

+4-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ SRC_C += \
5050
$(SDK_DIR)/drivers/common/fsl_common.c \
5151
$(SDK_DIR)/drivers/common/fsl_common_arm.c \
5252
$(SDK_DIR)/drivers/igpio/fsl_gpio.c \
53-
$(SDK_DIR)/drivers/lpuart/fsl_lpuart.c
53+
$(SDK_DIR)/drivers/lpuart/fsl_lpuart.c \
54+
$(SDK_DIR)/drivers/ocotp/fsl_ocotp.c \
5455

5556
# Optional drivers: only available for some mcus: rt1160, rt1170
5657
ifneq (,$(wildcard ${TOP}/${MCU_DIR}/drivers/fsl_dcdc.c))
@@ -68,7 +69,8 @@ INC += \
6869
$(TOP)/$(MCU_DIR)/drivers \
6970
$(TOP)/$(SDK_DIR)/drivers/common \
7071
$(TOP)/$(SDK_DIR)/drivers/igpio \
71-
$(TOP)/$(SDK_DIR)/drivers/lpuart
72+
$(TOP)/$(SDK_DIR)/drivers/lpuart \
73+
$(TOP)/$(SDK_DIR)/drivers/ocotp \
7274

7375
SRC_S += $(MCU_DIR)/gcc/startup_$(MCU_VARIANT_WITH_CORE).S
7476

test/hil/rpi.json

+7
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@
3030
"flasher": "esptool",
3131
"flasher_sn": "3ea619acd1cdeb11a0a0b806e93fd3f1",
3232
"flasher_args": "-b 1500000"
33+
},
34+
{
35+
"name": "metro_m7_1011",
36+
"uid": "9CE8715DD71137363E00005002004200",
37+
"flasher": "jlink",
38+
"flasher_sn": "000611000000",
39+
"flasher_args": "-device MIMXRT1011xxx5A"
3340
}
3441
]
3542
}

0 commit comments

Comments
 (0)