bt_set_static_random_bd_addr not random enough

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hello,

The random addresses generated by bt_set_static_random_bd_addr are not random enough. When doing my production tests (7boards at a time), I always have duplicates (within just 7 boards).

Any suggestion?

If not, is it legit to *distribute* devices programmed with the address generated by the SDK : "20736A1****"? Or in this case do I need to register a Comapny ID to the BT council? (I want to avoid this)

Kind regards,

Arthur

0 Likes
1 Solution
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

I dug into this one a little bit and I found that our random number generator is a HW block introducing actual entropy into the API. Not pseudo-random as I had said before.

Additionally, I found that you may prevent possible duplicate numbers by postponing your call to the random generator (set random addr) to as late a time as possible in your firmware. Issues could present if the HW RNG doesn't have enough time to warm up.

Jacob

View solution in original post

5 Replies
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

In your firmware did you set the initial device address to 0xffffffffffff?

Does your function call return with success?

Jacob

0 Likes
Anonymous
Not applicable

Yes.

The issue is, within 7 boards, I will have 6 different addresses (so 2 boards actually end up having the same "random" address)

I assume there is little to no entropy on these system, so that would be why it's hard to generate many random addresses?

0 Likes
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

The function call should create pseudo-random addresses. The same address should certainly not appear within 6 iterations. 

Is your NVRAM EEPROM or SFLASH?

When these duplicate addresses appear, are they the same addresses each time? Or is it always different duplicate addresses each time?

Are the two boards that produce duplicate addresses always the same two boards or do different boards produce duplicates each time?

Jacob

0 Likes
Anonymous
Not applicable

Hey,

Using EEPROM.

I couldn't replicate the bug lately. Was I severely unlucky? Or maybe had an issue with my code. I don't really have time to try and replicate the issue. On the next batch on chips we program I will keep an eye open and report here if I see anything wrong.

Out of curiosity, how is it possible for the function to generate pseudo-random id? Each cpu we program has the exact same firmware image, where can entropy come from?

Cheers,

0 Likes
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

I dug into this one a little bit and I found that our random number generator is a HW block introducing actual entropy into the API. Not pseudo-random as I had said before.

Additionally, I found that you may prevent possible duplicate numbers by postponing your call to the random generator (set random addr) to as late a time as possible in your firmware. Issues could present if the HW RNG doesn't have enough time to warm up.

Jacob