Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Downmerge more changes to enable SDC w nrf54l15bsim #2017

Merged
merged 3 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions boards/native/nrf_bsim/nrf54l15bsim_nrf54l15_cpuapp_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ CONFIG_NO_OPTIMIZATIONS=y

# Start SYSCOUNTER on driver init
CONFIG_NRF_GRTC_START_SYSCOUNTER=y

CONFIG_FAKE_ENTROPY_NATIVE_POSIX_SEED_BY_DEFAULT=n
9 changes: 9 additions & 0 deletions drivers/entropy/Kconfig.native_posix
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,12 @@ config FAKE_ENTROPY_NATIVE_POSIX
not generate real entropy.
It actually generates always the same sequence of random numbers if
initialized with the same seed.

config FAKE_ENTROPY_NATIVE_POSIX_SEED_BY_DEFAULT
bool "Seed the generator by default"
default y
depends on FAKE_ENTROPY_NATIVE_POSIX
help
Apply a seed by default, even if the user does not request it through the command line.
Disabling this feature allows some other component to seed the host standard library random
generator without this component's default initialization interfering.
14 changes: 13 additions & 1 deletion drivers/entropy/fake_entropy_native_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

static unsigned int seed = 0x5678;
static bool seed_random;
static bool seed_set;

static int entropy_native_posix_get_entropy(const struct device *dev,
uint8_t *buffer,
Expand Down Expand Up @@ -69,7 +70,10 @@ static int entropy_native_posix_get_entropy_isr(const struct device *dev,
static int entropy_native_posix_init(const struct device *dev)
{
ARG_UNUSED(dev);
entropy_native_seed(seed, seed_random);
if (seed_set || seed_random ||
IS_ENABLED(CONFIG_FAKE_ENTROPY_NATIVE_POSIX_SEED_BY_DEFAULT)) {
entropy_native_seed(seed, seed_random);
}
posix_print_warning("WARNING: "
"Using a test - not safe - entropy source\n");
return 0;
Expand All @@ -86,6 +90,13 @@ DEVICE_DT_INST_DEFINE(0,
PRE_KERNEL_1, CONFIG_ENTROPY_INIT_PRIORITY,
&entropy_native_posix_api_funcs);

static void seed_was_set(char *argv, int offset)
{
ARG_UNUSED(argv);
ARG_UNUSED(offset);
seed_set = true;
}

static void add_fake_entropy_option(void)
{
static struct args_struct_t entropy_options[] = {
Expand All @@ -94,6 +105,7 @@ static void add_fake_entropy_option(void)
.name = "r_seed",
.type = 'u',
.dest = (void *)&seed,
.call_when_found = seed_was_set,
.descript = "A 32-bit integer seed value for the entropy device, such as "
"97229 (decimal), 0x17BCD (hex), or 0275715 (octal)"
},
Expand Down
2 changes: 1 addition & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ manifest:
groups:
- tools
- name: nrf_hw_models
revision: 4b0b020e25dbf1a11ccccf7b7741d6ca991ba9e4
revision: d2a119a9c7600ce06033a794de042e0ad9a38702
path: modules/bsim_hw_models/nrf_hw_models
- name: open-amp
revision: da78aea63159771956fe0c9263f2e6985b66e9d5
Expand Down
Loading