Forum Rule: Always post complete source code & details to reproduce any issue!
Page 2 of 2 FirstFirst 1 2
Results 26 to 42 of 42

Thread: Serial Number of Teensy 3.1

  1. #26
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    8,379
    Indeed @MM, I meant had not seen all those #defines in one place
    Last edited by defragster; 05-03-2015 at 03:40 AM.

  2. #27
    Senior Member
    Join Date
    Jun 2013
    Location
    So. Calif
    Posts
    2,828
    @Pauls of course with the unique ID in Freescale's chip, one can derive the lower bits of an Ethernet MAC address, an make the upper bits be a registered IEEE OUI such as PJRC et al have. Or, use IEEE's "self-administed" coding for the high bits, and be generic but still unique from any other NICs in the LAN. Self-administered MACs are for use only on a LAN, not into a WAN.

  3. #28
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,929
    Quote Originally Posted by PaulS View Post
    Do you have any idea why the reported USB serialnumber has an additional zero padded?
    The extra zero is a workaround for a Macintosh OS-X bug, where the last digit of the serial number is lost when creating the /dev/cu.usbmodem#### device name, which then has the interface number appended. If you use a Teensy in USB serial mode on a Mac, you'll see the device name always has the serial number, with the last zero replaced by a 1. Without the extra zero, OS-X loses one digit.

    I and others have reported this bug to Apple. Someone on their mail list figured out the exact place in the Darwin source code where the error happens, because a buffer is too short by 1 byte. This conversation happened years ago. Every indication is Apple will never fix this.

    As a workaround, I added the extra zero, so Mac users get proper non-conflicting device names when they have Teensys that differ in serial numbers only on their last digit.

  4. #29
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    8,379
    Thanks Paul - wasn't sure why the pad was needed - but - it matched what I saw in Win USB and TyQt

    Question: is there an example of reading 'registers' like the on chip ID - I got to the pointed spot in the manual - but like @PaulS not sure on reading: Address: 4004_7000h base + 1054h offset = 4004_8054h (pg265...F1RM.pdf)

  5. #30
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    107
    @PaulS
    Thanks, found your comment in usb-desc.c as well.

    @Defragster
    Here is a piece of code that reads and displays the 128-bit Unique ID:
    Code:
    void setup() {
      char ID[32];
      sprintf(ID, "%08lX %08lX %08lX %08lX", SIM_UIDH, SIM_UIDMH, SIM_UIDML, SIM_UIDL);
    
      Serial.begin(115200);
      while (!Serial);
      pinMode(13, OUTPUT);
      digitalWrite(13, HIGH); // just to show that serial port is opened
      delay (1000);
      Serial.print("Reading 128-bit UniqueID from chip: ");
      Serial.println(ID);
    }
    
    void loop() {
    }
    And this is the output on the serial monitor: "Reading 128-bit UniqueID from chip: A4210000 70E10003 00254018 31374E45"
    What's the ID of your Teensy?

    Regards,
    Paul

  6. #31
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    1,929
    Quote Originally Posted by PaulS View Post
    ...
    Unfortunately, I'm not that familiar with coding C++ to access these registers.
    The 4 32-bit UID registers are defined in the firmware in kinetis.h, so you should be able to reference/print them from your sketch
    Code:
    #define SIM_UIDH        (*(const uint32_t *)0x40048054)    // Unique Identification Register High
    #define SIM_UIDMH       (*(const uint32_t *)0x40048058)    // Unique Identification Register Mid-High
    #define SIM_UIDML       (*(const uint32_t *)0x4004805C)    // Unique Identification Register Mid Low
    #define SIM_UIDL        (*(const uint32_t *)0x40048060)    // Unique Identification Register Low
    The LC has only 3 32-bit UID registers (no UIDH)
    Last edited by manitou; 05-05-2015 at 10:26 AM.

  7. #32
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    107
    Our posts must have been crossed
    Yes, I also found the definitions in kinetis.h and used them in my code.

    Paul

  8. #33
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    1,929
    Quote Originally Posted by PaulS View Post
    And this is the output on the serial monitor: "Reading 128-bit UniqueID from chip: A4210000 70E10003 00254018 31374E45"
    What's the ID of your Teensy?
    here are my IDs
    3.1 Reading 128-bit UniqueID from chip: FFFFFFFF FFFF000A 00364009 24754E45
    3.0 Reading 128-bit UniqueID from chip: FFFFFFFF FFFF0013 000C2003 14134D44
    LC Reading 96-bit UniqueID from chip: 00000051 00701007 28234E45
    beta LC 00000024 000E1007 28234E45

    my favorite macro for displaying symbol/value
    #define PRREG(x) Serial.print(#x" 0x"); Serial.println(x,HEX)
    Last edited by manitou; 05-06-2015 at 05:32 PM.

  9. #34
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    107
    That's interesting. The fineprint on the chip on my (2 months old) Teensy 3.1 reads "1436" on the lowest line, so I guess it's produced in week 36, 2014.
    Since you joined this forum more than 2 years before me, I take it that your Teensy's and chips are manufactured way earlier than mine.
    And that leads to thinking that the default ID on the chip-die is all FF's and then laser-fused before packaging. Someone has an idea about this?

    Regards,
    Paul

  10. #35
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    1,929
    batch dates on my chips: 3.0 is 1226, 3.1 is 1234
    (i never could find a date on my LC chips, code 1N15J ?

  11. #36
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,929
    I've been told those codes like "1N15J" identify which piece of Freescale silicon is actually inside.

    On Teensy 3.1, the oldest boards (from January 2014) have "1N36B". I believe the first digit is the revision of the silicon.

  12. #37
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    107
    On my Teensy 3.1, the chip states "3N36B".
    That would be rev 3 of the silicon, which is consistent with the value I read from the System Device Identification Register (SIM_SDID), bits 15-12 [REVID].

  13. #38
    Hi guys,
    I've just received my first Teensy v3.6.... is there a simple way to retrieve a single byte to be used as unique ID?

    Thanks!

  14. #39
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,567
    A single byte is only 255 combinations.. this is why all unique IDs are using more than one byte...

  15. #40
    whoops, you're right!

    Thanks!

  16. #41
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,929
    How about 16 bytes. NXP put a unique signature into every chip. You can read it with registers SIM_UIDH, SIM_UIDMH, SIM_UIDML and SIM_UIDL.

    Every 32 bit Teensy also has a serial number written by PJRC. Search for info about reading the ethernet mac address.

  17. #42
    Thanks I'll give it a look!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •