Skip to main content
Luca Giuseppe Rodda
Visitor II
June 29, 2017
Question

LoRaWAN demo DevEUI is not unique

  • June 29, 2017
  • 1 reply
  • 939 views
Posted on June 29, 2017 at 18:12

Hello,

We've got two B-L072Z-LRWAN1 LoRa Discovery kit boards and we're trying to use the end_node demo project, included in the

https://my.st.com/content/my_st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-expansion-software/i-cube-lrwan.html

package, to communicate with the LoRaWAN server through a gateway.

In the initialisation phase, it calls the BoardGetUniqueId function to read the DevEUI for the LoRa module. The DevEUI should be unique for each different board. Unfortunately, the BoardGetUniqueId function always returns the same value, but you can't connect two modules with the same DevEUI to LoRaWAN.

I don't find any source code for the BoardGetUniqueId function.

Does someone know how to integrate two or more modules in a LoRaWAN application?

Thanks

#b-l072z-lrwan1 #lorawan
This topic has been closed for replies.

1 reply

Tesla DeLorean
Guru
June 29, 2017
Posted on June 29, 2017 at 20:28

>>

I don't find any source code for the BoardGetUniqueId function.

It is a function pointer, you supply the code

STM32CubeExpansion_LRWAN_V1.1.0\Projects\Multi\Applications\LoRa\End_Node\src\main.c

/* load call backs*/

static LoRaMainCallback_t LoRaMainCallbacks ={ HW_GetBatteryLevel,

HW_GetUniqueId,

HW_GetRandomSeed,

LoraTxData,

LoraRxData};

STM32CubeExpansion_LRWAN_V1.1.0\Projects\Multi\Applications\LoRa\End_Node\src\mlm32l0xx_hw.c

/*!

* \brief Unique Devices IDs register set ( STM32L0xxx )

*/

#define ID1 ( 0x1FF80050 )

#define ID2 ( 0x1FF80054 )

#define ID3 ( 0x1FF80064 )

...

/**

* @brief This function return a unique ID

* @param unique ID

* @retval none

*/

void HW_GetUniqueId( uint8_t *id )

{

id[7] = ( ( *( uint32_t* )ID1 )+ ( *( uint32_t* )ID3 ) ) >> 24;

id[6] = ( ( *( uint32_t* )ID1 )+ ( *( uint32_t* )ID3 ) ) >> 16;

id[5] = ( ( *( uint32_t* )ID1 )+ ( *( uint32_t* )ID3 ) ) >> 8;

id[4] = ( ( *( uint32_t* )ID1 )+ ( *( uint32_t* )ID3 ) );

id[3] = ( ( *( uint32_t* )ID2 ) ) >> 24;

id[2] = ( ( *( uint32_t* )ID2 ) ) >> 16;

id[1] = ( ( *( uint32_t* )ID2 ) ) >> 8;

id[0] = ( ( *( uint32_t* )ID2 ) );

}
Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Tesla DeLorean
Guru
June 30, 2017
Posted on June 30, 2017 at 02:27

Not an ideal 64-bit hash, but likely to result in significantly differ IDs even for parts on the same wafer

uint64_t CRC64_DWORD_Slow(uint64_t Crc, uint32_t Data)
{
 int i;
 Crc ^= Data; // Apply the data
 for(i=0; i<32; i++) // Process 32-bits, 1 at a time
 if (Crc & 1)
 Crc = (Crc >> 1) ^ 0xC96C5795D7870F42;
 else
 Crc >>= 1;
 return(Crc);
}
uint64_t CRC64_DWORD_Quick(uint64_t Crc, uint32_t Data)
{
 static const uint64_t CrcTable[16] = { // Polynomial 0xC96C5795D7870F42
 0x0000000000000000,0x7D9BA13851336649,0xFB374270A266CC92,
 0x86ACE348F355AADB,0x64B62BCAEBC387A1,0x192D8AF2BAF0E1E8,
 0x9F8169BA49A54B33,0xE21AC88218962D7A,0xC96C5795D7870F42,
 0xB4F7F6AD86B4690B,0x325B15E575E1C3D0,0x4FC0B4DD24D2A599,
 0xADDA7C5F3C4488E3,0xD041DD676D77EEAA,0x56ED3E2F9E224471,
 0x2B769F17CF112238 }; // sourcer32@gmail.com
 Crc ^= Data; // Apply the data
 Crc = (Crc >> 4) ^ CrcTable[Crc & 0x0F]; // 32-bit, 8 rounds of 4-bits
 Crc = (Crc >> 4) ^ CrcTable[Crc & 0x0F];
 Crc = (Crc >> 4) ^ CrcTable[Crc & 0x0F];
 Crc = (Crc >> 4) ^ CrcTable[Crc & 0x0F];
 Crc = (Crc >> 4) ^ CrcTable[Crc & 0x0F];
 Crc = (Crc >> 4) ^ CrcTable[Crc & 0x0F];
 Crc = (Crc >> 4) ^ CrcTable[Crc & 0x0F];
 Crc = (Crc >> 4) ^ CrcTable[Crc & 0x0F];
 return(Crc);
}

/**
 * @brief This function return a unique ID
 * @param unique ID
 * @retval none
 */
void HW_GetUniqueId( uint8_t *id )
{
 static uint64_t unique = 0;
 if (!unique)
 {
 unique = CRC64_DWORD_Quick(unique, *( uint32_t *)ID1);
 unique = CRC64_DWORD_Quick(unique, *( uint32_t *)ID2);
 unique = CRC64_DWORD_Quick(unique, *( uint32_t *)ID3);
 }
 memcpy(id, &unique, sizeof(unique));
}
�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..