Skip to content

# 20.1. J6X MCU Board Id 修改适配

## 20.1.1. SBL修改适配

- 文件路径： `BootLoader/Sys/src/Sys_InitSocEarly.c`

- 功能说明：根据boardid判断板子类型，从而进行对应PMIC的GPIO配置

- 添加说明：新增一个对应boardid的case，PMIC配置视具体情况而定

    switch (boardid)
    {
        case 0xD8U:
            /* EN_MCU_MPQ2918_P5V0_SOC*/
            Sys_Lld_SetBits32(0x23480000U, BIT_15);
            Sys_Lld_SetBits32(0x23480004U, BIT_15);
            Common_Delay_Us((30U * 1000U));
            /* EN_MCU_74201_PMIC_TOP23_H */
            Sys_Lld_SetBits32(0x23490000U, BIT_6);
            Sys_Lld_SetBits32(0x23490004U, BIT_6);
            Common_Delay_Us(1000U);
            /* EN_MCU_74201_PMIC_TOP1_H*/
            Sys_Lld_SetBits32(0x23205000U, BIT_12);
            Sys_Lld_SetBits32(0x23205004U, BIT_12);
            Common_Delay_Us(1000U);
            break;
        case 0xF0U:
        case 0xF1U:
            /*maipre MPQ4371_EN*/
            Sys_Lld_SetBits32(0x23490000U, BIT_6);
            Sys_Lld_SetBits32(0x23490004U, BIT_6);
            Common_Delay_Us((30U * 1000U));
            /*main TOP123_EN*/
            Sys_Lld_SetBits32(0x23490000U, BIT_2);
            Sys_Lld_SetBits32(0x23490004U, BIT_2);
            Common_Delay_Us(30U);
            /*dram TOP1_EN */
            Sys_Lld_SetBits32(0x23205000U, BIT_12);
            Sys_Lld_SetBits32(0x23205004U, BIT_12);
            break;
        case 0x30U:
        case 0x39U:
        case 0x40U:
        case 0x41U:
        case 0x48U:
        case 0x49U:
        case 0x60U:
        case 0x61U:
        case 0x70U:
        case 0x71U:
            /*can2 tx MPQ4371_EN*/
            Sys_Lld_SetBits32(0x23480000U, BIT_7);
            Sys_Lld_SetBits32(0x23480004U, BIT_7);
            Common_Delay_Us((30U * 1000U));
            /*can3 tx TOP123_MPQ7421_EN*/
            Sys_Lld_SetBits32(0x23480000U, BIT_8);
            Sys_Lld_SetBits32(0x23480004U, BIT_8);
            Common_Delay_Us(30U);
            /*wakeup_io TOP1_MPQ74201_EN */
            Sys_Lld_SetBits32(0x23205000U, BIT_12);
            Sys_Lld_SetBits32(0x23205004U, BIT_12);
            break;
        case 0x42U:
        case 0x43U:
        case 0x4AU:
        case 0x4BU:
        case 0x62U:
        case 0x63U:
        case 0x68U:
        case 0x69U:
        case 0xC0U:
        case 0xC1U:
        case 0xC2U:
        case 0xC3U:
            /*SPI2_CSN1 MPQ4371_EN*/
            Sys_Lld_SetBits32(0x23480000U, BIT_15);
            Sys_Lld_SetBits32(0x23480004U, BIT_15);
            Common_Delay_Us((30U * 1000U));
            /*SPI6_MISO TOP123_MPQ7421_EN*/
            Sys_Lld_SetBits32(0x23490000U, BIT_6);
            Sys_Lld_SetBits32(0x23490004U, BIT_6);
            Common_Delay_Us(30U);
            /*wakeup_io TOP1_MPQ74201_EN */
            Sys_Lld_SetBits32(0x23205000U, BIT_12);
            Sys_Lld_SetBits32(0x23205004U, BIT_12);
            break;
        default:
            LogSync("can't find boardid\r\n");
            break;
    }

## 20.1.2. AUTOSAR修改适配

### 20.1.2.1. service boardid info

- 文件路径： `Service/Board/BoardInfo/src/Hobot_Board_Info.c`

- 功能说明：USB下载时，USB驱动可以根据boardid打印出对应板子类型，避免烧错镜像

- 添加说明：在g_BoardInfo数组中新增一个成员，新增成员仿照其他成员补充boardid、板子类型信息

    Hobot_BoardInfo_t g_BoardInfo[BOARD_TYPE_NUM] =
    {
        /* J6E Matrix */
        {0x40, "J6E", "Matrix", "rc", "V1.0"},
        {0x41, "J6E", "Matrix", "ep", "V1.0"},
        {0x42, "J6E", "Matrix", "rc", "V1.1"},
        {0x43, "J6E", "Matrix", "ep", "V1.1"},
        /* J6M Matrix */
        {0x48, "J6M", "Matrix", "rc", "V1.0"},
        {0x49, "J6M", "Matrix", "ep", "V1.0"},
        {0x4A, "J6M", "Matrix", "rc", "V1.1"},
        {0x4B, "J6M", "Matrix", "ep", "V1.1"},
        /* J6E/M EMC */
        {0x50, "J6E", "EMC", "", "V1.0"},
        {0x51, "J6M", "EMC", "", "V1.0"},
        /* J6M SIP Matrix */
        {0x60, "J6M", "SIP_Matrix", "rc", "V1.0"},
        {0x61, "J6M", "SIP_Matrix", "ep", "V1.0"},
        {0x62, "J6M", "SIP_Matrix", "rc", "V1.1"},
        {0x63, "J6M", "SIP_Matrix", "ep", "V1.1"},
        /* J6E SIP Matrix */
        {0x68, "J6E", "SIP_Matrix", "rc", "V1.1"},
        {0x69, "J6E", "SIP_Matrix", "ep", "V1.1"},
        /* J6E SIP CVB */
        {0x70, "J6E", "SIP_CVB", "rc", "V1.0"},
        {0x71, "J6E", "SIP_CVB", "ep", "V1.0"},
        /* J6M PAC */
        {0x80, "J6M", "PAC", "", "V1.0"},
        {0x81, "J6M", "PAC", "", "V1.0"},
        /* J6E SLT */
        {0x90, "J6E", "SLT", "", "V1.0"},
        /* J6E SIP EMC */
        {0xA0, "J6E", "SIP_EMC", "", "V1.0"},
        /* Other */
        {0xC0, "J6E", "Matrix_LX", "rc", "V1.1"},
        {0xC1, "J6E", "Matrix_LX", "ep", "V1.1"},
        {0xC2, "J6M", "Matrix_LX", "rc", "V1.1"},
        {0xC3, "J6M", "Matrix_LX", "ep", "V1.1"},
        {0xD8, "J6M", "Brandy", "", "V1.0"},
        {0xF0, "J6E", "Galaxy", "", "V1.0"},
        {0xF1, "J6E", "Galaxy", "", "V1.0"},
    };

### 20.1.2.2. version检查

- 文件路径： `Autosar/Infra/ASW/hb_SysSrv/McuVersion/McuVersion.*`

- 功能说明：根据SBL写入AON_SRAM的ADC数据，判断板子的硬件类型，再根据bin_process写入变量McuVersion_sConfig的数据判断烧录的镜像类型

- 添加说明：注册对应的硬件id号与硬件名称，再添加到对比函数中进行比对

McuVersion.h:

    #define J6E_MATRIX_RC_CODE_V1_0     0x40
    #define J6E_MATRIX_EP_CODE_V1_0     0x41
    #define J6E_MATRIX_RC_CODE_V1_1     0x42
    #define J6E_MATRIX_EP_CODE_V1_1     0x43
    #define J6M_MATRIX_RC_CODE_V1_0     0x48
    #define J6M_MATRIX_EP_CODE_V1_0     0x49
    #define J6M_MATRIX_RC_CODE_V1_1     0x4A
    #define J6M_MATRIX_EP_CODE_V1_1     0x4B
    #define J6E_EMC_CODE_V1_0           0x50
    #define J6M_EMC_CODE_V1_0           0x51
    #define J6M_SIP_MATRIX_RC_CODE_V1_0 0x60
    #define J6M_SIP_MATRIX_EP_CODE_V1_0 0x61
    #define J6M_SIP_MATRIX_RC_CODE_V1_1 0x62
    #define J6M_SIP_MATRIX_EP_CODE_V1_1 0x63
    #define J6E_SIP_MATRIX_RC_CODE_V1_0 0x68
    #define J6E_SIP_MATRIX_EP_CODE_V1_0 0x69
    #define J6E_SIP_CVB_RC_CODE_V1_0    0x70
    #define J6E_SIP_CVB_EP_CODE_V1_0    0x71
    #define J6M_PCA_RC_CODE_V1_0        0x80
    #define J6M_PCA_EP_CODE_V1_0        0x81
    #define J6E_SLT_CODE_V1_0           0x90
    #define J6E_SIP_EMC_CODE_V1_0       0xA0
    #define J6E_MATRIX_LX_RC_CODE_V1_1  0xC0
    #define J6E_MATRIX_LX_EP_CODE_V1_1  0xC1
    #define J6M_MATRIX_LX_RC_CODE_V1_1  0xC2
    #define J6M_MATRIX_LX_EP_CODE_V1_1  0xC3
    #define J6E_GALAXY_CODE_V1_1        0xF0
    #define J6E_GALAXY_CODE_V1_2        0xF1

    #define J6E_MATRIX_RC_CODE_V1_0_NAME        "Matrix_V1.0"
    #define J6E_MATRIX_EP_CODE_V1_0_NAME        "Matrix_V1.0"
    #define J6E_MATRIX_RC_CODE_V1_1_NAME        "Matrix_V1.1"
    #define J6E_MATRIX_EP_CODE_V1_1_NAME        "Matrix_V1.1"
    #define J6M_MATRIX_RC_CODE_V1_0_NAME        "Matrix_V1.0"
    #define J6M_MATRIX_EP_CODE_V1_0_NAME        "Matrix_V1.0"
    #define J6M_MATRIX_RC_CODE_V1_1_NAME        "Matrix_V1.1"
    #define J6M_MATRIX_EP_CODE_V1_1_NAME        "Matrix_V1.1"
    #define J6E_EMC_CODE_V1_0_NAME              "EMC_V1.0"
    #define J6M_EMC_CODE_V1_0_NAME              "EMC_V1.0"
    #define J6M_SIP_MATRIX_RC_CODE_V1_0_NAME    "SIP_Matrix_V1.0"
    #define J6M_SIP_MATRIX_EP_CODE_V1_0_NAME    "SIP_Matrix_V1.0"
    #define J6M_SIP_MATRIX_RC_CODE_V1_1_NAME    "SIP_Matrix_V1.1"
    #define J6M_SIP_MATRIX_EP_CODE_V1_1_NAME    "SIP_Matrix_V1.1"
    #define J6E_SIP_MATRIX_RC_CODE_V1_0_NAME    "SIP_Matrix_V1.0"
    #define J6E_SIP_MATRIX_EP_CODE_V1_0_NAME    "SIP_Matrix_V1.0"
    #define J6E_SIP_CVB_RC_CODE_V1_0_NAME       "SIP_CVB_V1.0"
    #define J6E_SIP_CVB_EP_CODE_V1_0_NAME       "SIP_CVB_V1.0"
    #define J6M_PCA_RC_CODE_V1_0_NAME           "PCA_V1.0"
    #define J6M_PCA_EP_CODE_V1_0_NAME           "PCA_V1.0"
    #define J6E_SLT_CODE_V1_0_NAME              "SLT_V1.0"
    #define J6E_SIP_EMC_CODE_V1_0_NAME          "SIP_EMC_V1.0"
    #define J6E_MATRIX_LX_RC_CODE_V1_1_NAME     "Matrix_LX_V1.1"
    #define J6E_MATRIX_LX_EP_CODE_V1_1_NAME     "Matrix_LX_V1.1"
    #define J6M_MATRIX_LX_RC_CODE_V1_1_NAME     "Matrix_LX_V1.1"
    #define J6M_MATRIX_LX_EP_CODE_V1_1_NAME     "Matrix_LX_V1.1"
    #define J6E_GALAXY_CODE_V1_1_NAME           "Galaxy_V1.1"

McuVersion.c:

    static int BoardId_Check(uint32 BoardId)
    {
        int result = 1;
        switch(BoardId)
        {
            case J6E_MATRIX_RC_CODE_V1_0:
                result = Compare_board_id(J6E_MATRIX_RC_CODE_V1_0_NAME);
                break;
            case J6E_MATRIX_EP_CODE_V1_0:
                result = Compare_board_id(J6E_MATRIX_EP_CODE_V1_0_NAME);
                break;
            case J6E_MATRIX_RC_CODE_V1_1:
                result = Compare_board_id(J6E_MATRIX_RC_CODE_V1_1_NAME);
                break;
            case J6E_MATRIX_EP_CODE_V1_1:
                result = Compare_board_id(J6E_MATRIX_EP_CODE_V1_1_NAME);
                break;
            case J6M_MATRIX_RC_CODE_V1_0:
                result = Compare_board_id(J6M_MATRIX_RC_CODE_V1_0_NAME);
                break;
            case J6M_MATRIX_EP_CODE_V1_0:
                result = Compare_board_id(J6M_MATRIX_EP_CODE_V1_0_NAME);
                break;
            case J6M_MATRIX_RC_CODE_V1_1:
                result = Compare_board_id(J6M_MATRIX_RC_CODE_V1_1_NAME);
                break;
            case J6M_MATRIX_EP_CODE_V1_1:
                result = Compare_board_id(J6M_MATRIX_EP_CODE_V1_1_NAME);
                break;
            case J6E_EMC_CODE_V1_0:
                result = Compare_board_id(J6E_EMC_CODE_V1_0_NAME);
                break;
            case J6M_EMC_CODE_V1_0:
                result = Compare_board_id(J6M_EMC_CODE_V1_0_NAME);
                break;
            case J6M_SIP_MATRIX_RC_CODE_V1_0:
                result = Compare_board_id(J6M_SIP_MATRIX_RC_CODE_V1_0_NAME);
                break;
            case J6M_SIP_MATRIX_EP_CODE_V1_0:
                result = Compare_board_id(J6M_SIP_MATRIX_EP_CODE_V1_0_NAME);
                break;
            case J6M_SIP_MATRIX_RC_CODE_V1_1:
                result = Compare_board_id(J6M_SIP_MATRIX_RC_CODE_V1_1_NAME);
                break;
            case J6M_SIP_MATRIX_EP_CODE_V1_1:
                result = Compare_board_id(J6M_SIP_MATRIX_EP_CODE_V1_1_NAME);
                break;
            case J6E_SIP_MATRIX_RC_CODE_V1_0:
                result = Compare_board_id(J6E_SIP_MATRIX_RC_CODE_V1_0_NAME);
                break;
            case J6E_SIP_MATRIX_EP_CODE_V1_0:
                result = Compare_board_id(J6E_SIP_MATRIX_EP_CODE_V1_0_NAME);
                break;
            case J6E_SIP_CVB_RC_CODE_V1_0:
                result = Compare_board_id(J6E_SIP_CVB_RC_CODE_V1_0_NAME);
                break;
            case J6E_SIP_CVB_EP_CODE_V1_0:
                result = Compare_board_id(J6E_SIP_CVB_EP_CODE_V1_0_NAME);
                break;
            case J6M_PCA_RC_CODE_V1_0:
                result = Compare_board_id(J6M_PCA_RC_CODE_V1_0_NAME);
                break;
            case J6M_PCA_EP_CODE_V1_0:
                result = Compare_board_id(J6M_PCA_EP_CODE_V1_0_NAME);
                break;
            case J6E_SLT_CODE_V1_0:
                result = Compare_board_id(J6E_SLT_CODE_V1_0_NAME);
                break;
            case J6E_SIP_EMC_CODE_V1_0:
                result = Compare_board_id(J6E_SIP_EMC_CODE_V1_0_NAME);
                break;
            case J6E_MATRIX_LX_RC_CODE_V1_1:
                result = Compare_board_id(J6E_MATRIX_LX_RC_CODE_V1_1_NAME);
                break;
            case J6E_MATRIX_LX_EP_CODE_V1_1:
                result = Compare_board_id(J6E_MATRIX_LX_EP_CODE_V1_1_NAME);
                break;
            case J6M_MATRIX_LX_RC_CODE_V1_1:
                result = Compare_board_id(J6M_MATRIX_LX_RC_CODE_V1_1_NAME);
                break;
            case J6M_MATRIX_LX_EP_CODE_V1_1:
                result = Compare_board_id(J6M_MATRIX_LX_EP_CODE_V1_1_NAME);
                break;
            case J6E_GALAXY_CODE_V1_1:
                result = 0;
                break;
            case J6E_GALAXY_CODE_V1_2:
                result = 0;
                break;
            default:
                result = 1;
                break;
        }
        return result;
    }

McuVersion.c:

    void McuVersion_Init(void)
    {
        uint16 len;
        int result = 1;
        McuVerion_ReadCommitInfo(&mcu_all_commit_info[0], &len);
        BoardInfo_Get();
        result = BoardId_Check(hw_board_info.board_id);
        if(result != 0)
        {
            LogSync("Error: MCU image and Board ID do not correspond!!!");
            LogSync("Hardware BoardId is: 0x%x \r\n", hw_board_info.board_id);
            LogSync("Hardware adc0 value is: %d \r\n", hw_board_info.adc_value[0]);
            LogSync("Hardware adc1 value is: %d \r\n", hw_board_info.adc_value[1]);
            LogSync("Hardware adc2 value is: %d \r\n", hw_board_info.adc_value[2]);
            while(1)
            {

            }
        }
    }

### 20.1.2.3. 函数调用

在main.c中调用相关函数，如果版本不匹配，会卡死在调用该函数的位置

    if (OS_CORE_ID_MASTER == GetCoreID())
    {
        Det_Init(NULL_PTR);
        PreOS_Firewall_Config();
        _main();
        Stack_Monitor_Init();
        PpsIcu_Irq_Init();
        Port_Init(NULL);
        Uart_Init();
        Log_Init();
        #ifdef SHELL_ENABLE
        Shell_Init();
        #endif
        LogSync("MCU ETAS_OS Init Success!\r\n");
        LogSync("Dbg fix table address is 0x%x !\r\n",VarPtr_FixedAddr_Table);
        McuVersion_Init();
    }