Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

UUID from Grand Central
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

UUID from Grand Central

by FlatCat on Tue Mar 10, 2020 10:04 am

Does anyone know how to get the UUID from the SAMD51 of a Grand Central? I have code for doing this on an Arduino DUE, but it is a different processor. (SAM3X).

FlatCat
 
Posts: 20
Joined: Wed Aug 13, 2014 11:07 pm

Re: UUID from Grand Central

by mikeysklar on Tue Mar 10, 2020 12:05 pm

Hi FlatCat,

Good question about reading UUID's on a m4 system using Arduino code.

It looks like you should be able to modify the ArduinoUniqueID code with the address for an m4 processor.

https://github.com/ricaun/ArduinoUniqueID

SAMD51: 128bit (4x 32bit) uid is stored in Flash (nvm) @ these addresses: 0x008061FC, 0x00806010, 0x00806014, 0x00806018

The SAMD21 address are slightly different, but this might be helpful for finding them.

SAMD21: 128bit (4x 32bit) uid is stored in Flash (nvm) @ these addresses: 0x0080A00C, 0x0080A040, 0x0080A044, 0x0080A048.

addresses taken from this 2017 github thread and UUID.

https://github.com/adafruit/circuitpyth ... it-40d63dd

mikeysklar
 
Posts: 1730
Joined: Mon Aug 01, 2016 8:10 pm

Re: UUID from Grand Central

by FlatCat on Tue Mar 10, 2020 6:12 pm

Thanks, Mike. But I'm not sure how to read those locations since the Grand Central page says there is no support for nvm "eeprom'. Or is that independent?

FlatCat
 
Posts: 20
Joined: Wed Aug 13, 2014 11:07 pm

Re: UUID from Grand Central

by mikeysklar on Tue Mar 10, 2020 6:27 pm

I suspect it will still work if you add a new arch here for the SAMD51 with the only difference being the four addresses:

https://raw.githubusercontent.com/ricau ... iqueID.cpp

Code: Select all | TOGGLE FULL SIZE
#elif defined(ARDUINO_ARCH_SAMD)

   // from section 9.3.3 of the datasheet
   #define SERIAL_NUMBER_WORD_0   *(volatile uint32_t*)(0x0080A00C)
   #define SERIAL_NUMBER_WORD_1   *(volatile uint32_t*)(0x0080A040)
   #define SERIAL_NUMBER_WORD_2   *(volatile uint32_t*)(0x0080A044)
   #define SERIAL_NUMBER_WORD_3   *(volatile uint32_t*)(0x0080A048)

   uint32_t pdwUniqueID[4];
   pdwUniqueID[0] = SERIAL_NUMBER_WORD_0;
   pdwUniqueID[1] = SERIAL_NUMBER_WORD_1;
   pdwUniqueID[2] = SERIAL_NUMBER_WORD_2;
   pdwUniqueID[3] = SERIAL_NUMBER_WORD_3;

   for (int i = 0; i < 4; i++)
   {
      id[i*4+0] = (uint8_t)(pdwUniqueID[i] >> 24);
      id[i*4+1] = (uint8_t)(pdwUniqueID[i] >> 16);
      id[i*4+2] = (uint8_t)(pdwUniqueID[i] >> 8);
      id[i*4+3] = (uint8_t)(pdwUniqueID[i] >> 0);
   }

mikeysklar
 
Posts: 1730
Joined: Mon Aug 01, 2016 8:10 pm

Re: UUID from Grand Central

by User_UMjT7KxnxP8YN8 on Wed Mar 11, 2020 3:28 pm

I do it like this on the Metro M4 Express with the same MCU:

Code: Select all | TOGGLE FULL SIZE
void getMCU_ID(uint32_t* MCU_ID) {

  // These are the addresses of the 4 32-bit MCU serial number values for the SAMD51 MCU. Combined, they form a unique 128-bit serial number.
#define SN_WORD_0  (uint32_t*)0x008061FCUL
#define SN_WORD_1  (uint32_t*)0x00806010UL
#define SN_WORD_2  (uint32_t*)0x00806014UL
#define SN_WORD_3  (uint32_t*)0x00806018UL

  MCU_ID[0] = *SN_WORD_0;
  MCU_ID[1] = *SN_WORD_1;
  MCU_ID[2] = *SN_WORD_2;
  MCU_ID[3] = *SN_WORD_3;
}   // getMCU_ID

User_UMjT7KxnxP8YN8
 
Posts: 153
Joined: Tue Jul 17, 2018 1:28 pm

Re: UUID from Grand Central

by FlatCat on Thu Mar 12, 2020 1:02 pm

I tried these but the program hangs when it gets to the first statement. In the library for SAMD21 there are some statements setting EFC1 and STUI-related registers. Are those not required here?

FlatCat
 
Posts: 20
Joined: Wed Aug 13, 2014 11:07 pm

Re: UUID from Grand Central

by mikeysklar on Thu Mar 12, 2020 5:46 pm

I don't think the EFC1 and STUI lines are necessary for just reading the UUID registers. Comment them out.

mikeysklar
 
Posts: 1730
Joined: Mon Aug 01, 2016 8:10 pm

Re: UUID from Grand Central

by User_UMjT7KxnxP8YN8 on Fri Mar 13, 2020 2:36 pm

My function should be called like this:

Code: Select all | TOGGLE FULL SIZE
  uint32_t mcu_id[4];
  getMCU_ID(mcu_id);   

User_UMjT7KxnxP8YN8
 
Posts: 153
Joined: Tue Jul 17, 2018 1:28 pm

Re: UUID from Grand Central

by FlatCat on Thu Jul 16, 2020 12:45 pm

This works! Thanks.

FlatCat
 
Posts: 20
Joined: Wed Aug 13, 2014 11:07 pm

Please be positive and constructive with your questions and comments.