Skip to content

Commit

Permalink
address @gebart's comments RIOT-OS#2
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterKietzmann committed Jul 4, 2018
1 parent fb3b6f3 commit b63725c
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 13 deletions.
3 changes: 1 addition & 2 deletions cpu/cortexm_common/ldscripts/cortexm_base.ld
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,8 @@ SECTIONS
/* stack section */
.stack (NOLOAD):
{
_puf_sram_len = DEFINED(_puf_sram_len) ? _puf_sram_len : 0 ;
KEEP (*(.puf_stack))
. = ALIGN(_puf_sram_len);
. = ALIGN(8);
_pstack = .;
. = ALIGN(8);
_sstack = .;
Expand Down
6 changes: 0 additions & 6 deletions sys/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,3 @@ endif
ifneq (native,$(BOARD))
INCLUDES += -I$(RIOTBASE)/sys/libc/include
endif

ifneq (,$(filter puf_sram,$(USEMODULE)))
# allocate space for 3 x 32 Bit integers: seed, state, marker
export PUF_SRAM_LEN ?= 12
export LINKFLAGS += $(LINKFLAGPREFIX)--defsym=_puf_sram_len=$(PUF_SRAM_LEN)
endif
4 changes: 2 additions & 2 deletions sys/include/puf_sram.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ extern "C" {
#define PUF_SRAM_MARKER (0xad3021ff)

/**
* @brief Global seed variable, allocated on the stack in puf_sram.c
* @brief Global seed variable, allocated in puf_sram.c
*/
extern uint32_t puf_sram_seed;

/**
* @brief Global seed state, allocated on the stack in puf_sram.c
* @brief Global seed state, allocated in puf_sram.c
* 0 means seed was generated from SRAM pattern,
1 means missing power cycle detected,
2 means power cycle detected. The state will most likely
Expand Down
1 change: 1 addition & 0 deletions sys/puf_sram/puf_sram.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ __attribute__((used,section(".puf_stack"))) uint32_t puf_sram_state;

/* Allocation of the memory marker */
__attribute__((used,section(".puf_stack"))) uint32_t puf_sram_marker;
__attribute__((used,section(".puf_stack"))) uint32_t deleteme[120];

uint32_t puf_sram_generate(const uint8_t *ram, size_t len)
{
Expand Down
5 changes: 2 additions & 3 deletions sys/random/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ void auto_init_random(void)
LOG_WARNING("random: PUF SEED not fresh\n");
}
seed = puf_sram_seed;
#endif
#if !defined (MODULE_PUF_SRAM) && defined (MODULE_PERIPH_CPUID)
#elif defined (MODULE_PERIPH_CPUID)
luid_get(&seed, 4);
#elif !defined (MODULE_PUF_SRAM) && !defined (MODULE_PERIPH_CPUID)
#else
LOG_WARNING("random: NO SEED AVAILABLE!\n");
seed = RANDOM_SEED_DEFAULT;
#endif
Expand Down

0 comments on commit b63725c

Please sign in to comment.