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.

How to change host device's MAC address used by NDK?



Hi

I am working with the NDK v.2.22 on a C66 DSP core.  We need to connect several EVMs to our office network so I need to assign a unique MAC address to each board.

How can I change the MAC address of my device?

I have found NIMU IOCTL commands:

  • NIMU_GET_DEVICE_MAC
  • NIMU_SET_DEVICE_MAC

Should I use these?

Is there example code anywhere that shows how to use these in an application?

Best regards

David

  • David,

    See the post http://e2e.ti.com/support/dsp/c6000_multi-core_dsps/f/639/t/232017.aspx?pi239031349=1. Basically, the NIMU driver under C:\ti\pdk_C6678_1_1_2_6\packages\ti\transport\ndk\nimu\src\nimu_eth.c, the function EMACInit_Core, there is a call to platform_get_emac_info followed by memcpy(ptr_pvt_data->pdi.bMacAddr, emac_info.mac_address);. You can try changing emac_info.mac_address to a custom address of your choice, or change the platform function to fit your requirements. Remember to recompile both the library and your application using this library.

    Regards, Eric

  • Hi Eric

    Thanks for your reply.  I have also found the NIMU IOCTL commands, which I should be able to call from the application.  Something like:

            ret_code = NIMUIoctl (NIMU_GET_DEVICE_MAC, &if_req, &MacAddress, 6);

    However, I'm having trouble finding the correct index value to assign to if_req.

    Best regards

    David 

  • David,

    &if_req implies this value is returned by the function, not you assign a value to it.

    Regards, Eric

  • Eric

    I disagree, if_req is a structure, and so is passed to the function by a pointer.

    NIMUIoctl returns (-22). Any idea what that value means please?

    David

  • David,

    I agree this is a structure actually.

    C:\ti\ndk_2_22_02_16\packages\ti\ndk\inc\serrno.h (1 hits)
     Line 66: #define EINVAL          22      /* Invalid argument */

    Regards, Eric

  • Hi Eric

    Thanks for pointing out the error code description.

    I need to enumerate the devices before attempting to set the MAC address.  I have done this, by adding the following code to:

    "C:\ti\mcsdk_bios_3_00_00_11\examples\ndk\helloWorld\helloWorld.c"

    NIMU_IF_REQ if_req;

    UINT16 num_device;  

    int ret_code;

    [snip]

    ret_code = NIMUIoctl (NIMU_GET_NUM_NIMU_OBJ, NULL, &num_device, sizeof(UINT16));

    if (ret_code==0)

        printf("Number of NIMU objects:%d\n", num_device);

    else   

        printf ("NIMUIOCTL Failed with error code: %d\n",ret_code);

    This IOCTL call now succeeds, but it reports that the number of devices is 0.  Perhaps I am calling it before the NIMU is initialised but i don't know when that happens.

    Any help would be appreciated.

    BR

    David

  • Hi David,

    As we discussed - it's worthwhile to step into the platform_get_info function in platform.c.  Seen in the screenshot.

    One possibility is to write your desired mac address to p_info->emac.

    Another possibility we discussed was to write the desired MAC address to the eeprom using the writer utility from the mcsdk tools.

    Regards,

    Tom