This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MCU-PLUS-SDK-AM243X: Profinet Stack dependancy on MAC from EEPROM

Part Number: MCU-PLUS-SDK-AM243X


Tool/software:

Hello,

As I understand it from the related post (https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1131479/mcu-plus-sdk-am243x-is-board-id-eeprom-eeprom-at24cm01-necessary-on-am243x/4199462?tisearch=e2e-sitesearch&keymatch=APP_HW_BOARD_INFO_getMacInfo#),

there is no dependancy on EEPROM MAC as long as MAC is provided via  APP_HW_BOARD_INFO_getMacInfo function.

But when I removed EEPROM and manually filled the APP_HW_BOARD_INFO_data_g structure with a MAC and other data, Communication with PRONETA or PLC is not happening.

Does stack read other than MAC from "&APP_HW_BOARD_INFO_data_g.mac;"  in appHwBoardInfo.c file ?

We want to remove EEPROM and store the MAC in out Non Volatile Memory.

Thank you.

Best Regards,
Upendar

  • Hello Upendar,

    I'm looking into this issue now. Do you observe any messages being sent on any of the device's ports? would you please check the MAC address using Wireshark and share it with us? A Wireshark trace would also be helpful.

    Thanks.
    Kind regards,
    Kamil

  • Hello Kamil,

    I am unable to send the wireshark pcap file. But it would not be difficult to reproduce. Please try from your side.

    thank you.

  • Hello Upendar,

    Would you please clarify where are you modifying APP_HW_BOARD_INFO_data_g.mac structure? Perhaps the stack is trying to read it before you assign it. If the MAC isn't available, the stack can use it's default value. To verify this, I need at least the MAC address you see on your Wireshark traces?

    I tried to reproduce your issue on my side by modifying APP_HW_BOARD_INFO_read() to manually fill APP_HW_BOARD_INFO_data_g.mac structure instead of calling EEPROM read. The MAC address of the device was updated successfully and I was still able to detect it via PRONETA and PLC.

    Thanks.
    Kind regards,
    Kamil

  • uint32_t APP_pruInit (void)
    {
        PRU_PN_TPruLoadParameter    pruParam   = {0};
        uint32_t                    result     = OSAL_NO_ERROR;
        APP_HW_EError_t             status     = APP_HW_eNO_ERROR;
    
        //status = APP_HW_BOARD_INFO_read();
    
        if (status == APP_HW_eNO_ERROR)
        {
            memset(&pruParam, 0, sizeof(pruParam));
            memmove(pruParam.aMacAddr, PN_APP_IOD_getMacAddr(), PRU_PN_MAC_ADDR_LEN);

    APP_HW_BOARD_INFO_SMAC_Addr_t *APP_HW_BOARD_INFO_getMacInfo(void)
    {
    
        APP_HW_BOARD_INFO_data_g.mac.length = 194;
        APP_HW_BOARD_INFO_data_g.mac.type = 19;
        APP_HW_BOARD_INFO_data_g.mac.ctrl = 16;
    
        uint8_t * flashMac = PN_APP_IOD_getMacAddr();
    
        for (uint8_t i = 0; i < 3; i++)
        {
            OSAL_MEMORY_memcpy(&APP_HW_BOARD_INFO_data_g.mac.macAddr[6 * i], flashMac, 6);
    
            flashMac[5] = flashMac[5] + 1;
        }
    
        return &APP_HW_BOARD_INFO_data_g.mac;
    }
    

    These are the changes I made. _getMacAddr function returns 6 byte mac address.

  • Hello Upendar,

    Ok now I can see the problem and I understand the confusion. PROFINET stack assumes that APP_HW_BOARD_INFO_getMacInfo() is just a getter function for the static APP_HW_BOARD_INFO_data_g.mac structure, so before calling it, it calls APP_HW_BOARD_INFO_read() to make sure the structure is filled. In your case, APP_HW_BOARD_INFO_read() probably does not fill the structure so the stack never calls APP_HW_BOARD_INFO_getMacInfo() during the initialization phase. To solve this you can try to move your code from APP_HW_BOARD_INFO_getMacInfo() to APP_HW_BOARD_INFO_read() so the structure is initialized first.

    I will also create a bug report on our side so we can modify the stack's behavior to make it less confusing for the user and more compliant with the E2E ticket you mentioned above.

    Would you please confirm if the problem is resolved this way?

    Thanks.
    Kamil

  • Hello Kamil,

    First APP_HW_BOARD_INFO_read was called, I disabled the readblock call and returned success and then APP_HW_BOARD_INFO_getMacInfo function was called by the stack.

    Thats why I am confused. In the code I sent earlier, I have filled the APP_HW_BOARD_INFO_data_g same as it would be done in APP_HW_BOARD_readBlock but still it won't work.

    Maybe could you please make my changes and debug? my suspicion is that stack is using more than mac addr data from APP_HW_BOARD_INFO_data_g pointer.

    Thank you.
    Best Regards,
    Upendar
  • Hello Upendar,

    I tried to replicate your code on my side and I still see no issue. I will share my changes so we can take a look together:

    APP_HW_EError_t APP_HW_BOARD_INFO_read(void)
    {
        APP_HW_EError_t result = APP_HW_eNO_ERROR;
        return result;
    }
    
    uint8_t flashMac[194] = {0};
    
    APP_HW_BOARD_INFO_SMAC_Addr_t *APP_HW_BOARD_INFO_getMacInfo(void)
    {
    	uint8_t macAddr[6] = {0x70,0xFF,0x76,0x1E,0x68,0x7C}; //Instead of flash access
    	OSAL_MEMORY_memcpy(flashMac, macAddr, 6);
    
    	APP_HW_BOARD_INFO_data_g.mac.type = APP_HW_BOARD_INFO_TYPE_MAC_ADDR;
    	APP_HW_BOARD_INFO_data_g.mac.length = APP_HW_BOARD_INFO_MAC_ADDR_LEN_TOTAL + 2;
    	APP_HW_BOARD_INFO_data_g.mac.ctrl = APP_HW_BOARD_INFO_TYPE_BRD_INFO;
    
    	for (uint8_t i = 0; i < 3; i++)
    	{
    	    OSAL_MEMORY_memcpy(&APP_HW_BOARD_INFO_data_g.mac.macAddr[6 * i], flashMac, 6);
    	    flashMac[5] = flashMac[5] + 1;
    	}
    
        return &APP_HW_BOARD_INFO_data_g.mac;
    }


    Here's also a screenshot from PRONETA:


    Can you make a comparison with what you have on your side?

    Thanks.
    Kind regards,
    Kamil
     

  • Hello Kamil,

    This is bit unsettling. The only change i see is use of PN_APP_IOD_getMacAddr function in APP_pruInit instead of the APP_HW_BOARD_INFO_getMacInfo. I guess I will check again.

    Thank again.

    Regards,
    Upendar

  • Hello Upendar,

    do you have any updates regarding this ticket? is there anything I can do to support you further?

    Thanks.
    Kind regards,
    Kamil

  • Hello Kamil,

    Sorry for not responding earlier. I did not work for me. But it could be a problem with my board. I wanted to debug it properly. I am busy with other work right now. 

    I will write here if I need further support.

    Thank you.

    Regards,
    Upendar