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.

EK-TM4C1294XL: EK-TM4C1294XL

Part Number: EK-TM4C1294XL

Dear TI support,

I have a EK-TM4C1294XL evaluation kit. I downloaded SPMA072 (Serial to Ethernet Converter for TM4C129x).

I am able to compile using CCS 11.2.0. The application is running fine and I am able to open webserver.

Currently I use the MAC address which is already programmed in development board. The one that shows on sticker.

My application however is going to read MAC address from an external MAC chip. I already wrote the code to read MAC address from this chip. 

Currently, I am using boot_emac_flash to do firmware updates. It reads MAC address from user register ui32User0 and ui32User1.

What I would like to do is write the MAC address that I get from MAC chip to user registers so when boot_emac_flash takes over, it will read MAC address from it. 

Do you have sample code on how to write to NV user registers? I looked at example code folder but I am not sure if is there.

Thanks so much for your help.

Felix

  • Hi Felix,

      Please use these two APIs. After you read the MAC address from external, you should write to USER_REG0 and USER_REG1 because these are the two registers the Ethernet stack will read to obtain the MAC address.  Please note that once you commit to save these registers permanently they are irreversible unless a unlock operation is performed. 

    Please read the reference note in the datasheet. 

    This below post will be helpful too. 

    https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/969133/tm4c1294kcpdt-how-to-program-mac-address-during-app-code-programming/3580187?tisearch=e2e-sitesearch&keymatch=FlashAllUserRegisterSet#3580187

  • Thanks Charles, for some reason FlashAllUserRegisterSet is not working for me. In the following code, I entered hardcoded values  for user0 and user1 as a test. I use MAP_FlashUserGet to read back, however usermem0 and usermem1 always come back with value 0. I added a delay after FlashAllUserRegisterSet just in case it takes a while to complete writing. I get no errors, it is like it wrote without errors, however the values that I read back are incorrect. Any suggestions? Much appreciated your help. Felix

    if(FlashAllUserRegisterSet(0xFF801F12, 0xFFE097F9, 0xFFFFFFFF, 0xFFFFFFFF) != 0)
    {
    UARTprintf("Failed to write MAC address\n");
    }

    SysCtlDelay(SysCtlClockGet()/3);

    MAP_FlashUserGet(&usermem0, &usermem1);

  • Hi Felix,

      Is this a virgin device? Can you try to unlock the device first so that it is reverted to its factory setting and then try again? I try your code and I got the correct value. See below. 

  • Hi Charles, this is a new board I received and downloaded my application. I had never tried before to write user registers. How do I unlock the device?

    Thanks, Felix 

  • Hi Felix,

     Which debug probe do you have? Follow section 5.3.2 if you XDS type of debug probe to unlock the device. https://www.ti.com/lit/pdf/spma075

      I will also suggest you try to program USER_REGx on your LaunchPad to get a feel how it is supposed to work. Please note that once MAC address is programmed and committed, you must unlock the device before you can program a new MAC. 

      

  • Hi Charles, I have the XDS200 probe. I tried the same code on LaunchPad and get wrong values too. I know LaunchPad came with user registers programmed with MAC address. I don't know if is locked or not.  When you say MAC address is committed, you mean FlashAllUserRegisterSave was executed? And FlashAllUserRegisterSet means device is programmed but not commited and therefore not locked, is this correct?

    Thanks,

    Felix

  • Hi Charles, is it possible for you to send me the code you used to test user register? I even modified the simple Blinky project in examples folder and added user register read and still can not get right values. I don't know what I am doing wrong. I am just trying to read MAC address which shows in label on back of LaunchPad.

    Felix 

  • Hi Felix, 

      This the code I use, actually came from you. I didn't even commit the MAC address change. However, I do first unlock the device so that MAC is all 0xF before I run the program. 

    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_types.h"
    #include "inc/hw_memmap.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/gpio.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/rom.h"
    #include "driverlib/rom_map.h"
    #include "driverlib/eeprom.h"
    #include "driverlib/flash.h"
    #include "driverlib/uart.h"
    #include "utils/uartstdio.h"
    
    
    
    //*****************************************************************************
    //
    // Define pin to LED mapping.
    //
    //*****************************************************************************
    
    //*****************************************************************************
    //
    //! \addtogroup example_list
    //! <h1>Project Zero (project0)</h1>
    //!
    //! This example demonstrates the use of TivaWare to setup the clocks and
    //! toggle GPIO pins to make the LED blink. This is a good place to start
    //! understanding your launchpad and the tools that can be used to program it.
    //
    //*****************************************************************************
    
    #define USER_LED1  GPIO_PIN_0
    #define USER_LED2  GPIO_PIN_1
    
    uint32_t ui32SysClock;
    
    
    //*****************************************************************************
    //
    // The error routine that is called if the driver library encounters an error.
    //
    //*****************************************************************************
    #ifdef DEBUG
    void
    __error__(char *pcFilename, uint32_t ui32Line)
    {
    }
    #endif
    
    void
    ConfigureUART(void)
    {
    	//
    	// Enable the GPIO Peripheral used by the UART.
    	//
    	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    
    	//
    	// Enable UART0
    	//
    	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    
    	//
    	// Configure GPIO Pins for UART mode.
    	//
    	MAP_GPIOPinConfigure(GPIO_PA0_U0RX);
    	MAP_GPIOPinConfigure(GPIO_PA1_U0TX);
    	MAP_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    
    	//
    	// Initialize the UART for console I/O.
    	//
    	UARTStdioConfig(0, 115200, ui32SysClock);
    }
    //*****************************************************************************
    //
    // Main 'C' Language entry point.  Toggle an LED using TivaWare.
    //
    //*****************************************************************************
    int
    main(void)
    {
    	uint32_t usermem0, usermem1;
    
    	//
    	// Run from the PLL at 120 MHz.
    	//
    	ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
    			SYSCTL_OSC_MAIN |
    			SYSCTL_USE_PLL |
    			SYSCTL_CFG_VCO_480), 120000000);
    
    	ConfigureUART();
    
    
    
    	if(FlashAllUserRegisterSet(0x12345678, 0xFFE097F9, 0xFFFFFFFF, 0xFFFFFFFF) != 0)
    	{
    		UARTprintf("Failed to write MAC address\n");
    	}
    
    	SysCtlDelay(SysCtlClockGet()/3);
    
    	MAP_FlashUserGet(&usermem0, &usermem1);
    	while(1);
    }

  • Also if you look at some of the Ethernet examples, FlashUserGet() is used to read out the user0 and user1 registers. 

        //
        // Configure the hardware MAC address for Ethernet Controller filtering of
        // incoming packets.  The MAC address will be stored in the non-volatile
        // USER0 and USER1 registers.
        //
        MAP_FlashUserGet(&ui32User0, &ui32User1);
        if((ui32User0 == 0xffffffff) || (ui32User1 == 0xffffffff))
        {
            //
            // We should never get here.  This is an error if the MAC address has
            // not been programmed into the device.  Exit the program.
            // Let the user know there is no MAC address
            //
            UARTprintf("No MAC programmed!\n");
            while(1)
            {
            }
        }

  • Thanks Charles, you were right. After I unlocked device, I was able to program and read back correctly. 

    Much appreciate your excellent support.

    Felix