Skip to content

cpu: provide link-time random value, use as fake cpuid#3944

Closed
kaspar030 wants to merge 1 commit intoRIOT-OS:masterfrom
kaspar030:add_link-time_random_value
Closed

cpu: provide link-time random value, use as fake cpuid#3944
kaspar030 wants to merge 1 commit intoRIOT-OS:masterfrom
kaspar030:add_link-time_random_value

Conversation

@kaspar030
Copy link
Copy Markdown
Contributor

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.

@kaspar030 kaspar030 added the Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation label Sep 23, 2015
@kaspar030 kaspar030 added this to the Release NEXT MAJOR milestone Sep 23, 2015
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be:

                            v
*(unsigned*)id = (unsigned) *RANDOM;

?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be:

                        v

(unsigned)id = (unsigned) *RANDOM;

No, somehow when ld defines a symbol, it defines where the symbol points to.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. I assumed it would we like global variable.

@OlegHahm
Copy link
Copy Markdown
Member

nice idea

@haukepetersen
Copy link
Copy Markdown
Contributor

+1.

I would propose though to make the RANDOM 64-bit wide for all platforms: this smplifies the generarion of UUID etc from the cpuid.

@sgso
Copy link
Copy Markdown
Contributor

sgso commented Dec 1, 2015

+1 for making this 64 bit.

@kaspar030
Copy link
Copy Markdown
Contributor Author

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?

@sgso
Copy link
Copy Markdown
Contributor

sgso commented Dec 1, 2015

@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 linkseed.o of configurable size and let the linker embed it as a section? Whoever needs such a seed somehow declares the necessary minimum size and the makefile figures out the maximum.

@haukepetersen
Copy link
Copy Markdown
Contributor

Why not just create an object file linkseed.o of configurable size and let the linker embed it as a section?

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).

@kaspar030
Copy link
Copy Markdown
Contributor Author

While this sounds like a good solution

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...

@OlegHahm OlegHahm modified the milestone: Release 2016.03 Dec 8, 2015
@OlegHahm
Copy link
Copy Markdown
Member

Any update?

@kaspar030
Copy link
Copy Markdown
Contributor Author

Let's close it. It doesn't really solve the problem.

@kaspar030 kaspar030 closed this Feb 26, 2016
@kaspar030 kaspar030 deleted the add_link-time_random_value branch February 26, 2016 20:28
@kaspar030 kaspar030 restored the add_link-time_random_value branch March 29, 2016 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants