cpu: provide link-time random value, use as fake cpuid#3944
cpu: provide link-time random value, use as fake cpuid#3944kaspar030 wants to merge 1 commit intoRIOT-OS:masterfrom
Conversation
There was a problem hiding this comment.
Shouldn't it be:
v
*(unsigned*)id = (unsigned) *RANDOM;?
There was a problem hiding this comment.
Shouldn't it be:
v(unsigned)id = (unsigned) *RANDOM;
No, somehow when ld defines a symbol, it defines where the symbol points to.
There was a problem hiding this comment.
That makes sense. I assumed it would we like global variable.
|
nice idea |
|
+1. I would propose though to make the |
|
+1 for making this 64 bit. |
|
It's not that easy, as linker-symbols can only be pointer-sized. So to make this 64bit, this would need two symbols on 32bit-platforms and 4 symbols on 16bit platforms. Also, when using a 32bit value as random seed, IMHO using a prng to generate another 32bit should be sufficient, don't you think? |
|
@kaspar030 I have an (hardware) prng that wants an 80 bit seed. To use a software prng to generate the last missing byte seems kind of silly. Why not just create an object file |
While this sounds like a good solution, I think it might practically not be feasible, as we don't have control over the linkerscripts on some platforms (e.g. avr, msp430). |
I'm not even sure about that. The approach would only work for fresh compiles. We should aim at something that works at run-time... |
|
Any update? |
|
Let's close it. It doesn't really solve the problem. |
This PR makes the linker define a symbol with a random value.
Also, it makes cpuid use it if no cpuid implementation is available.
As our boards always relink when flashing, as long "make flash" is used for flashing, all boards using this get a random cpuid.
FEATURE_PERIPH_CPUID is not changed in order to differentiate this fake from "real" cpuids.