travisgoodspeed / md380tools

Python tools and patched firmware for the TYT-MD380
805 stars 244 forks source link

Radio unique ID and/or serial number. #26

Open rct opened 8 years ago

rct commented 8 years ago

The MD-380 CPS software shows a Unique Device ID and/or serial number that is stored in the code plug (.rdt) header but doesn't seem to be in the code plug image contents AFAICT. Might be read from the radio as part of a different transaction?

Notes:

rct commented 8 years ago

So I haven't been paying close attention lately. Is this data available from one of the md380 transactions? (if you wanted to create an .rdt code plug that would match the vendor's software?)

travisgoodspeed commented 8 years ago

Apologies. I was trying to clear stale github issues and closed this one by mistake.

marrold commented 7 years ago

Would this help with users flashing the wrong firmware on their radio? Hopefully the serial number or unique ID correlates in GPS or non GPS models.

travisgoodspeed commented 7 years ago

A few notes from IRC with Phr3ak, who is also playing with the serial numbers.

The USB device serial number seems to be laser-etched in STM32's mask ROM starting at 0x1FFF7A10. This is after the bootloader ROM.

Reference code for reading this serial number is available in usb_desc.c in many of the STM32Cube examples like the following:

/**                                                                                                                                                                            
  * @brief  Create the serial number string descriptor                                                                                                                         
  * @param  None                                                                                                                                                               
  * @retval None                                                                                                                                                               
  */
static void Get_SerialNum(void)
{
  uint32_t deviceserial0, deviceserial1, deviceserial2;

  deviceserial0 = *(uint32_t*)DEVICE_ID1;
  deviceserial1 = *(uint32_t*)DEVICE_ID2;
  deviceserial2 = *(uint32_t*)DEVICE_ID3;

  deviceserial0 += deviceserial2;

  if (deviceserial0 != 0)
  {
    IntToUnicode (deviceserial0, (uint8_t*)&USBD_StringSerial[2] ,8);
    IntToUnicode (deviceserial1, (uint8_t*)&USBD_StringSerial[18] ,4);
  }
}

I've not checked whether this is the same serial number that is used in the codeplug file.

marrold commented 7 years ago

Thanks Travis