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 use EtherGetMacAddr() api in sysbios task function?

I want to use EtherGetMacAddr() to get MAC address !

I  add EtherGetMacAddr() function MCUSDK tcpEcho example but can't not build ,  console will show undefined symbol while linking . 

I think it maybe relate header files and lib not include . But after I include header files and lib . console still show undefined symbol  like below:

**** Build of configuration Debug for project DK_LM3S9D96_tcpEcho ****

C:\ti\ccsv5\utils\bin\gmake -k all
'Building target: DK_LM3S9D96_tcpEcho.out'
'Invoking: ARM Linker'
"C:/ti/ccsv5/tools/compiler/tms470_4.9.1/bin/cl470" -mv7M3 --code_state=16 --abi=eabi -me -g --gcc --define=PART_LM3S9D96 --define=TARGET_IS_TEMPEST_RB1 --define=ccs --diag_warning=225 --display_error_number --gen_func_subsections=on -z --stack_size=256 -m"DK_LM3S9D96_tcpEcho.map" --heap_size=0 -i"C:/ti/ccsv5/tools/compiler/tms470_4.9.1/lib" -i"C:/ti/ccsv5/tools/compiler/tms470_4.9.1/include" --reread_libs --warn_sections --display_error_number --rom_model -o "DK_LM3S9D96_tcpEcho.out" -l"./configPkg/linker.cmd" "./tcpEcho.obj" "./DK_LM3S9D96.obj" -l"C:\ti\mcusdk_1_00_00_68\products\ndk_2_21_01_38\packages\ti\ndk\stack\lib\stk_nat_ppp_pppoe.aem3" -l"libc.a" -l"C:/ti/mcusdk_1_00_00_68/products/StellarisWare_9107/driverlib/ccs-cm3/Debug/driverlib-cm3.lib" "../DK_LM3S9D96.cmd"
<Linking>

undefined first referenced
symbol in file
--------- ----------------
EtherGetMacAddr ./tcpEcho.obj

error #10234-D: unresolved symbols remain
error #10010: errors encountered during linking; "DK_LM3S9D96_tcpEcho.out" not
built

>> Compilation failure
gmake: *** [DK_LM3S9D96_tcpEcho.out] Error 1
gmake: Target `all' not remade because of errors.

**** Build Finished ****

I think I include the correct header file <ti/ndk/inc/_stack.h>

Do i call the function on the wrong place ?  see attach0842.tcpEcho.c

Do i link the right Lib or some other problem ? see attach 

MCUSDK version:1_00_00_68

Board : DK_LM3S9D96

ccs Version: 5.2.0.00069 



  • Hi ,

    I think you may be having problems because thefunction you are using is meant for internal stack usage only (this was stated in the beginning of Appendix A of the NDK API Guide).

    You can find an example of getting the MAC address in the NDK telnet console code (ti/ndk/tools/console/conipaddr.c).  Here's the code I saw:

    1. Use NIMUIoctl() to get the mac address

        /* Get the device MAC Address */
        ret_code = NIMUIoctl (NIMU_GET_DEVICE_MAC, &if_req, &mac_address, sizeof(mac_address));
        if (ret_code < 0)
        {
            ConPrintf ("NIMUIOCTL Failed with error code: %d\n",ret_code);
            return;
        }

    2. print out the mac address like this:


        ConPrintf ("MTU           : %d bytes\n", mtu);
        ConPrintf ("MAC Address   : 0x%x-0x%x-0x%x-0x%x-0x%x-0x%x\n\n\n",
                        mac_address[0], mac_address[1], mac_address[2],
                        mac_address[3], mac_address[4], mac_address[5]);

    You should be able to replace the console printf calls with standard printf().

    Steve


  • Thank Steve ,

    After setting right  interface index , it really work !

    Below is the relate code :

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

    /* Allocate memory for the device table*/
    dev_table = mmAlloc(num_device * sizeof(UINT16));

    /* Get a list of all device index. */
    ret_code = NIMUIoctl (NIMU_GET_ALL_INDEX, NULL, dev_table, num_device*sizeof(UINT16));

    if_req.index = dev_table[0];

    ret_code = NIMUIoctl (NIMU_GET_DEVICE_MAC, &if_req, &mac_address, sizeof(mac_address));
    System_printf ("MAC Address : 0x%x-0x%x-0x%x-0x%x-0x%x-0x%x\n\n\n",
    mac_address[0], mac_address[1], mac_address[2],
    mac_address[3], mac_address[4], mac_address[5]);
    System_flush();

    Brenden