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.

TM4C129XNCZAD: Automated production of MAC addresses and serial number

Part Number: TM4C129XNCZAD
Other Parts Discussed in Thread: UNIFLASH, SEGGER

What tool can automatically fill in the unique portion of the MAC address and a serial number?

The dev-kits store that MAC address in user register 0 and 1. I can read and write new address to this memory with UniFlash. Unfortunately, humans are slow and error prone, so this method is not good for manufacturing.

Uniflash is inspiring due to the command line. The flash process should be part of some script that performs testing and logs results. A simple interface is deal for a python script.

Does Uniflash have some feature that grabs the next valid number form file and flash it to a memory region (or inject it to the .out binary)? I can't find anything similar in the documentation...

TI has invested effort into the manufacturing of the TM4C dev kits. Documenting and sharing this process would be an amazing resource.

  • Hello Peter,

    Okay so there are two parts to this (MAC and Serial Number) and I will answer them separately in this post.

    For the MAC Address, the blunt answer is no we don't have an automated process as far as using a tool like Uniflash.

    Both Uniflash or the LM Flash Programming Tool can be used for programming the MAC Address, as well as just flashing the MAC Address as part of the initial application being programmed into the board.

    Another possibility would be to make some sort of script to automate the process of the using Uniflash (seen on another forum post as a suggestion, not something we have done).

    As far the manufacturing for our TM4C dev kits, for the LaunchPad the MAC address is allocated from the pool of MAC Address allocated to TI. So that is what is used to flash the boards before shipping. So with that in mind, for a custom design the MAC address must come from the pool of allocated MAC address to the organization/company - just a general recurring note I thought you may want to see.

    Now then, onto the topic of the Serial Number, are you referring to the 128-bit unique identifier that is programmed in each TM4C device? If so, that cannot be modified. Or is there some other Serial Number you are referring to? I don't see anything else that would fit that description from the datasheeet.
  • Bear in mind that I haven't used it, but Segger supports writing a unique serial number to memory. As well this could be leveraged to update the MAC address of the micro since you can do that from the user application.

    Segger may also have other support mechanisms for writing the user registers but I haven't checked with them.



    Robert

  • Hi Ralph,

    Could you describe how exactly numbers from your address pool are flashed into the micros? Do your people manually insert all the MAC addresses with Uniflash, or is there some other process you follow?

    I already have a pool allocated to my company. I just need to know how to physically put them into the flash in a reasonable way.

    The serial number is a 12 digit code generated by the date and some other things. I assume the same answer for the MAC address numbers can also apply to the serial number. If you have some way of putting 6 bytes in memory, it probably also works for 12.
  • Robert,

    I will look into Segger. Everyone who has made an IP device must have run into this issue. Unique serialized IDs are a fairly common hardware requirement for embedded devices. I'm very surprised there aren't more straightforward answers...
  • Peter Borenstein said:
    I'm very surprised there aren't more straightforward answers...

    I'm not. These tools are not TI's primary product and semiconductor vendors do not have an especially great track record in this regard.

    Robert

  • Hi Peter,

    Asked around and the answer is that a script is used with Uniflash which reads addresses in from a file, programs USER_REG0/USER_REG1 via XDS programmer, and then increments to pull in the next address.

    As far as the details of how the script was written, how it accesses the file, etc.. well, it's handled by a 3rd party for TI so your guess is as good as mine. Sorry about that. :(

    You might be able to browse and/or ask the UniFlash folks how customers generally write/run scripts for it though, I can't imagine that hasn't been asked a dozen+ times already given topics like this.
  • Thanks for the inside scoop. Its good to know that there is a solution at the bottom of the rabbit hole.

    There are a few posts/questions like mine, but many of the comment threads are rife with other problems and confusions.

    How would I reach out to the Uniflash team if I still need help?
  • Hi Peter,

    As far as I can tell, the Code Composer Forum handles all Uniflash questions as well: e2e.ti.com/.../81
  • Peter, Ralph,

    Regarding the programming of the MAC Address, I believe this justifies a bit more of customized software for acquiring the values from a remote location, and writing it to the product's MCU, possibly during the test phase. It seems unlikely that a product with a MAC address won't have some sort of serial communication port, and that would be a convenient path for this number to get transferred... This automation seems beyond "just a script in the programming (Uniflash) solution)", for it will require some sort of feedback to wherever the allocated pool is stored in the company... How to avoid reallocating mac addresses accidentally, right?

    Now, as for the Unique Id, I have to express my flabbergastness! So many years with Tivas, since LM and XM part numbers, and I had not known of such registers. Being them "Register 182...", might I believe my attention of reading the summary of a datasheet had faded some lines before? Interestingly enough, not only I posted long ago a question related to how to uniquely identify a product, but in other posts I also suggested the part number of an eeprom we apply in our products to get a 128-bit UID, and never such comment came up! Wow.

    Ralph, is the 128-bit content of UNIQUEID0-3 indeed that: a unique Id across the whole TM4C family? Does this uniqueness extend out to other TI devices that you are aware of?

    Regards

    Bruno

  • Hello Bruno,

    The UNIQUEID0-3 contents are specific to the TM4C129x devices only, not the TM4C123x devices. Which also might explain how you didn't notice the existence of them sooner and hopefully will leave you feeling less flabbergasted! :)

    The 128-bit will be unique across all TM4C129x devices, but there is nothing about it that would make it unique vs any other TI family devices.
  • Hi Ralph,

    Thanks for replying! The mentioning of the fact that the 123x family does not have the Id feature is also a relevant point.

    This "unique id" theme is probably a recurring discussion among developers, and possibly one with no definitive solution... Such as mac addresses have a regulating board to allocate pools, there should exist (maybe there is, I never searched that deep) a real "worldwide unique id" for hardware... I'd say 128bits are still enough for "any active processing device to be ever built" - but even that statement is risky in these Moore times.

    Just to share the status, in our case we shall remain using an external small, low cost eeprom IC that comes with a 128bit UID. It is "our chosen way" to uniquely identify a product of ours. But at least having learned about the 129x feature, it won't hurt to trace that as well, when there's some boring time available for a small library - or suggest it for colleagues developing other products with the IC.

    Cheers

    Bruno

  • There exists UUIDs: en.wikipedia.org/.../Universally_unique_identifier

    "While the probability that a UUID will be duplicated is not zero, it is close enough to zero to be negligible"
  • Thanks Peter, I wasn't aware of that. This statement

    Peter Borenstein said:
    "While the probability that a UUID will be duplicated is not zero, it is close enough to zero to be negligible"

    only applies for one of the cases (the random generation case, the others rely on pre-existing unique values) and seems perhaps a touch optimistic.

    What they consider negligible is that if (and these conditions are not small considerations)

    • you can assume independent random number generation
    • you can assume the random number generation is actually random**

    then you have a 50% probability of duplication in 1018 generations***. That's a lot of numbers but it's also a very high probability. It virtually guarantees collisions once you reach that point. In fact I think you want to limit the population to a range such that the probability of collision was < say 1 part in 106, maybe less. That's going to reduce the population of available numbers substantially although I'm not sure how much. Maybe an order of magnitude or two? Maybe more? That's a solvable problem if anyone wants to work it out.

    As a proxy for how many numbers might be needed, consider the market for CPUs which according to wiki https://en.wikipedia.org/wiki/Microprocessor#Market_statistics has been recently at 1010 per year and growing. So depending on the likelihood of collision you are willing to accept the limitations of this technique are visible for use as a 'guaranteed unique' product identifier*.

    The good news is that really the only requirement for a unique identifier is communications and that brings us back to the MAC number. Since it relies on assignment rather than random numbers a small number size can still guarantee uniqueness. I've seen suggestions that would remove even that requirement in the same way it's been removed for IP address. Not sure how that would be managed behind the 'router' though.

    I think Bruno's approach is the only method that will work across products from multiple vendors for unique identifiers (if you can guarantee all of you products have MACs then that is an alternative) and I think I've seen a couple of suppliers for similar products. The problem is that you need all of your products to use the same IC from the same supplier. Mind you I've not seen anyone really require a serial number unique across the company for all products, only within a product or product line. And that reduces the problem considerably.

    The good news is you could use this method to apply serial numbers to your products and it is only going to be an issue if you start approaching the current CPU production for a significant period of time. OTOH you could just assign serial numbers from a corporate pool (or use the ICs mentioned) and solve the problem in a much simpler fashion.

    Robert

    * by orders of magnitude 18-10 giving 108 years at recent production rates and 8-2 for reducing the probability reduces that again to 106. That's still a large number but increases in global production or desires for greater resistance to collision will reduce it even further. As will any imperfections in the random number generators. One item that would work in your favour is that most items have reasonably short lifetimes so their identifiers could return to the available pool.

    ** Pretty much by definition any PRNG will, at some level, be non-random.

    *** This is out of a number space of 1036 so you don't fill in much of the space before the likelihood of collision become high.

  • R.A. "The only way to guarantee uniqueness is to be non-random."

    And the converse (perhaps), "Is only the guarantee of "randomness" - the result of being "unique?"

  • I don't think so, there is no requirement for uniqueness within randomness.

    As far as I know, and I'm open to information otherwise, the only really random number generators use physically random processes. That said, pseudo random number generators (PRNG) are good enough for most uses. They do have limitations though and the affect of those limitations has led to improvements in PRNGs. The main improvement drivers that I've heard of are cryptography (which this universal unique ID appears to be a cousin of) and simulation.

    Robert
  • And I have always wondered about the BootP random seed generator embedded in the Stellaris Serial Boot Loader application. Code was written as if it could assign a MAC address from thin air to blank USER0/1 registers.  Not that it ever seemed to assign a random MAC to a erased M3 MCU or otherwise do anything useful after the boot loader was flashed.

    What was the purpose for an random seed number generator, perhaps at one time thought ok within the confines of the private network not so regulated by RFC's as the Internet of late. Yet the  code seemingly could not register USER0/1 on erased M3 when the boot loader was flashed via JTAG and forget LM flash M4 easy method to update USER0/1 registers it didn't exist for the M3.

    //*****************************************************************************
    //
    //! Computes a new random number.
    //!
    //! This function computes a new pseudo-random number, using a linear
    //! congruence random number generator.  Note that if the entire 32-bits of the
    //! produced random number are not being used, the upper N bits should be used
    //! instead of the lower N bits as they are much more random (for example, use
    //! ``RandomNumber() >> 28'' instead of ``RandomNumber() & 15'').
    //!
    //! \return Returns a 32-bit pseudo-random number.
    //
    //*****************************************************************************
    static unsigned long
    RandomNumber(void)
    {
        //
        // Generate a new pseudo-random number with a linear congruence random
        // number generator.  This new random number becomes the seed for the next
        // random number.
        //
        g_ulRandomSeed = (g_ulRandomSeed * 1664525) + 1013904223;
    
        //
        // Return the new random number.
        //
        return(g_ulRandomSeed);
    }
    
    
        //
        // If a static MAC address is not being used, then get the MAC address from
        // the flash user registers.
        //
    #ifndef ENET_MAC_ADDR0
        ulTemp = HWREG(FLASH_USERREG0);
        g_sMACAddr.addr[0] = ulTemp & 0xff;
        g_sMACAddr.addr[1] = (ulTemp >> 8) & 0xff;
        g_sMACAddr.addr[2] = (ulTemp >> 16) & 0xff;
        ulTemp = HWREG(FLASH_USERREG1);
        g_sMACAddr.addr[3] = ulTemp & 0xff;
        g_sMACAddr.addr[4] = (ulTemp >> 8) & 0xff;
        g_sMACAddr.addr[5] = (ulTemp >> 16) & 0xff;
    #endif
    
        //
        // Seed the random number generator from the MAC address.
        //
        g_ulRandomSeed = *(unsigned long *)(g_sMACAddr.addr + 2);
    
        //
        // Initialize the uIP stack.
        //
        uip_init();
        uip_arp_init();
    
        //
        // Program the MAC address.
        //
        HWREG(ETH_BASE + MAC_O_IA0) = *((unsigned long *)g_sMACAddr.addr);
        HWREG(ETH_BASE + MAC_O_IA1) = *((unsigned short *)(g_sMACAddr.addr + 4));
        uip_setethaddr(g_sMACAddr);