Skip to content

Commit

Permalink
Merge pull request #2721 from hathach/hild-add-metro-m7
Browse files Browse the repository at this point in the history
HIL add metro m7
  • Loading branch information
hathach authored Jul 18, 2024
2 parents c633920 + 8be0d50 commit b8581b4
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
4 changes: 2 additions & 2 deletions hw/bsp/board_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack.
*/

#ifndef _BOARD_API_H_
#define _BOARD_API_H_
#ifndef BOARD_API_H_
#define BOARD_API_H_

#ifdef __cplusplus
extern "C" {
Expand Down
24 changes: 24 additions & 0 deletions hw/bsp/imxrt/family.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "fsl_iomuxc.h"
#include "fsl_clock.h"
#include "fsl_lpuart.h"
#include "fsl_ocotp.h"

#ifdef __GNUC__
#pragma GCC diagnostic pop
Expand Down Expand Up @@ -186,6 +187,29 @@ uint32_t board_button_read(void) {
return BUTTON_STATE_ACTIVE == GPIO_PinRead(BUTTON_PORT, BUTTON_PIN);
}

size_t board_get_unique_id(uint8_t id[], size_t max_len) {
(void) max_len;

#if FSL_FEATURE_OCOTP_HAS_TIMING_CTRL
OCOTP_Init(OCOTP, CLOCK_GetFreq(kCLOCK_IpgClk));
#else
OCOTP_Init(OCOTP, 0u);
#endif

// Reads shadow registers 0x01 - 0x04 (Configuration and Manufacturing Info)
// into 8 bit wide destination, avoiding punning.
for (int i = 0; i < 4; ++i) {
uint32_t wr = OCOTP_ReadFuseShadowRegister(OCOTP, i + 1);
for (int j = 0; j < 4; j++) {
id[i*4+j] = wr & 0xff;
wr >>= 8;
}
}
OCOTP_Deinit(OCOTP);

return 16;
}

int board_uart_read(uint8_t* buf, int len) {
int count = 0;

Expand Down
2 changes: 2 additions & 0 deletions hw/bsp/imxrt/family.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ function(add_board_target BOARD_TARGET)
${SDK_DIR}/drivers/igpio/fsl_gpio.c
${SDK_DIR}/drivers/lpspi/fsl_lpspi.c
${SDK_DIR}/drivers/lpuart/fsl_lpuart.c
${SDK_DIR}/drivers/ocotp/fsl_ocotp.c
${SDK_DIR}/devices/${MCU_VARIANT}/system_${MCU_VARIANT_WITH_CORE}.c
${SDK_DIR}/devices/${MCU_VARIANT}/xip/fsl_flexspi_nor_boot.c
${SDK_DIR}/devices/${MCU_VARIANT}/drivers/fsl_clock.c
Expand Down Expand Up @@ -75,6 +76,7 @@ function(add_board_target BOARD_TARGET)
${SDK_DIR}/drivers/igpio
${SDK_DIR}/drivers/lpspi
${SDK_DIR}/drivers/lpuart
${SDK_DIR}/drivers/ocotp
)

update_board(${BOARD_TARGET})
Expand Down
6 changes: 4 additions & 2 deletions hw/bsp/imxrt/family.mk
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ SRC_C += \
$(SDK_DIR)/drivers/common/fsl_common.c \
$(SDK_DIR)/drivers/common/fsl_common_arm.c \
$(SDK_DIR)/drivers/igpio/fsl_gpio.c \
$(SDK_DIR)/drivers/lpuart/fsl_lpuart.c
$(SDK_DIR)/drivers/lpuart/fsl_lpuart.c \
$(SDK_DIR)/drivers/ocotp/fsl_ocotp.c \

# Optional drivers: only available for some mcus: rt1160, rt1170
ifneq (,$(wildcard ${TOP}/${MCU_DIR}/drivers/fsl_dcdc.c))
Expand All @@ -68,7 +69,8 @@ INC += \
$(TOP)/$(MCU_DIR)/drivers \
$(TOP)/$(SDK_DIR)/drivers/common \
$(TOP)/$(SDK_DIR)/drivers/igpio \
$(TOP)/$(SDK_DIR)/drivers/lpuart
$(TOP)/$(SDK_DIR)/drivers/lpuart \
$(TOP)/$(SDK_DIR)/drivers/ocotp \

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

Expand Down
7 changes: 7 additions & 0 deletions test/hil/rpi.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
"flasher": "esptool",
"flasher_sn": "3ea619acd1cdeb11a0a0b806e93fd3f1",
"flasher_args": "-b 1500000"
},
{
"name": "metro_m7_1011",
"uid": "9CE8715DD71137363E00005002004200",
"flasher": "jlink",
"flasher_sn": "000611000000",
"flasher_args": "-device MIMXRT1011xxx5A"
}
]
}

0 comments on commit b8581b4

Please sign in to comment.