Skip to content

Commit

Permalink
full variants rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
pennam committed Jun 28, 2024
1 parent da5ab5e commit 2ece915
Show file tree
Hide file tree
Showing 29 changed files with 224 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ extern "C" {
#include "pico/assert.h"
#include "pico/time.h"
#include "pico/types.h"
#include "pico/rand.h"
#include "hardware/pwm.h"
#include "hardware/adc.h"
#include "hardware/resets.h"
Expand Down Expand Up @@ -122,6 +123,12 @@ struct flash_s {
uint32_t dummy;
};

#if DEVICE_TRNG
struct trng_s {
uint8_t not_used;
};
#endif

typedef struct gpio_s gpio_t;
typedef struct serial_s serial_t;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ typedef volatile uint32_t spin_lock_t;
#define PICO_SPINLOCK_ID_HARDWARE_CLAIM 11
#endif

// PICO_CONFIG: PICO_SPINLOCK_ID_RAND, Spinlock ID for Random Number Generator, min=0, max=31, default=12, group=hardware_sync
#ifndef PICO_SPINLOCK_ID_RAND
#define PICO_SPINLOCK_ID_RAND 12
#endif

// PICO_CONFIG: PICO_SPINLOCK_ID_OS1, First Spinlock ID reserved for use by low level OS style software, min=0, max=31, default=14, group=hardware_sync
#ifndef PICO_SPINLOCK_ID_OS1
#define PICO_SPINLOCK_ID_OS1 14
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,14 @@ extern "C" {
*
* For example a `uint32_t` foo that will retain its value if the program is restarted by reset.
*
* uint32_t __uninitialized_ram("my_group_name") foo;
* uint32_t __uninitialized_ram(foo);
*
* The section attribute is `.uninitialized_ram.<group>`
* The section attribute is `.uninitialized_data.<group>`
*
* \param group a string suffix to use in the section name to distinguish groups that can be linker
* garbage-collected independently
*/
#define __uninitialized_ram(group) __attribute__((section(".uninitialized_ram." #group))) group
#define __uninitialized_ram(group) __attribute__((section(".uninitialized_data." #group))) group

/*! \brief Section attribute macro for placement in flash even in a COPY_TO_RAM binary
* \ingroup pico_platform
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
/*
* Copyright (c) 2022 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/

#ifndef _PICO_RAND_H
#define _PICO_RAND_H

#include "pico.h"

#ifdef __cplusplus
extern "C" {
#endif

/** \file pico/rand.h
* \defgroup pico_rand pico_rand
*
* Random Number Generator API
*
* This module generates random numbers at runtime utilizing a number of possible entropy
* sources and uses those sources to modify the state of a 128-bit 'Pseudo
* Random Number Generator' implemented in software.
*
* The random numbers (32 to 128 bit) to be supplied are read from the PRNG which is used
* to help provide a large number space.
*
* The following (multiple) sources of entropy are available (of varying quality), each enabled by a #define:
*
* - The Ring Oscillator (ROSC) (\ref PICO_RAND_ENTROPY_SRC_ROSC == 1):
* \ref PICO_RAND_ROSC_BIT_SAMPLE_COUNT bits are gathered from the ring oscillator "random bit" and mixed in each
* time. This should not be used if the ROSC is off, or the processor is running from
* the ROSC.
* \note the maximum throughput of ROSC bit sampling is controlled by PICO_RAND_MIN_ROSC_BIT_SAMPLE_TIME_US which defaults
* to 10us, i.e. 100,000 bits per second.
* - Time (\ref PICO_RAND_ENTROPY_SRC_TIME == 1): The 64-bit microsecond timer is mixed in each time.
* - Bus Performance Counter (\ref PICO_RAND_ENTROPY_SRC_BUS_PERF_COUNTER == 1): One of the bus fabric's performance
* counters is mixed in each time.
*
* \note All entropy sources are hashed before application to the PRNG state machine.
*
* The \em first time a random number is requested, the 128-bit PRNG state
* must be seeded. Multiple entropy sources are also available for the seeding operation:
*
* - The Ring Oscillator (ROSC) (\ref PICO_RAND_SEED_ENTROPY_SRC_ROSC == 1):
* 64 bits are gathered from the ring oscillator "random bit" and mixed into the seed.
* - Time (\ref PICO_RAND_SEED_ENTROPY_SRC_TIME == 1): The 64-bit microsecond timer is mixed into the seed.
* - Board Identifier (PICO_RAND_SEED_ENTROPY_SRC_BOARD_ID == 1): The board id via \ref pico_get_unique_board_id
* is mixed into the seed.
* - RAM hash (\ref PICO_RAND_SEED_ENTROPY_SRC_RAM_HASH (\ref PICO_RAND_SEED_ENTROPY_SRC_RAM_HASH): The hashed contents of a
* subset of RAM are mixed in. Initial RAM contents are undefined on power up, so provide a reasonable source of entropy.
* By default the last 1K of RAM (which usually contains the core 0 stack) is hashed, which may also provide for differences
* after each warm reset.
*
* With default settings, the seed generation takes approximately 1 millisecond while
* subsequent random numbers generally take between 10 and 20 microseconds to generate.
*
* pico_rand methods may be safely called from either core or from an IRQ, but be careful in the latter case as
* the calls may block for a number of microseconds waiting on more entropy.
*/

// ---------------
// ENTROPY SOURCES
// ---------------

// PICO_CONFIG: PICO_RAND_ENTROPY_SRC_ROSC, Enable/disable use of ROSC as an entropy source, type=bool, default=1, group=pico_rand
#ifndef PICO_RAND_ENTROPY_SRC_ROSC
#define PICO_RAND_ENTROPY_SRC_ROSC 1
#endif

// PICO_CONFIG: PICO_RAND_ENTROPY_SRC_TIME, Enable/disable use of hardware timestamp as an entropy source, type=bool, default=1, group=pico_rand
#ifndef PICO_RAND_ENTROPY_SRC_TIME
#define PICO_RAND_ENTROPY_SRC_TIME 1
#endif

// PICO_CONFIG: PICO_RAND_ENTROPY_SRC_BUS_PERF_COUNTER, Enable/disable use of a bus performance counter as an entropy source, type=bool, default=1, group=pico_rand
#ifndef PICO_RAND_ENTROPY_SRC_BUS_PERF_COUNTER
#define PICO_RAND_ENTROPY_SRC_BUS_PERF_COUNTER 1
#endif

// --------------------
// SEED ENTROPY SOURCES
// --------------------

// PICO_CONFIG: PICO_RAND_SEED_ENTROPY_SRC_ROSC, Enable/disable use of ROSC as an entropy source for the random seed, type=bool, default=1, group=pico_rand
#ifndef PICO_RAND_SEED_ENTROPY_SRC_ROSC
#define PICO_RAND_SEED_ENTROPY_SRC_ROSC PICO_RAND_ENTROPY_SRC_ROSC
#endif

// PICO_CONFIG: PICO_RAND_SEED_ENTROPY_SRC_TIME, Enable/disable use of hardware timestamp as an entropy source for the random seed, type=bool, default=1, group=pico_rand
#ifndef PICO_RAND_SEED_ENTROPY_SRC_TIME
#define PICO_RAND_SEED_ENTROPY_SRC_TIME PICO_RAND_ENTROPY_SRC_TIME
#endif

// PICO_CONFIG: PICO_RAND_SEED_ENTROPY_SRC_BOARD_ID, Enable/disable use of board id as part of the random seed, type=bool, default=1, group=pico_rand
#ifndef PICO_RAND_SEED_ENTROPY_SRC_BOARD_ID
#define PICO_RAND_SEED_ENTROPY_SRC_BOARD_ID 0
#endif

// PICO_CONFIG: PICO_RAND_SEED_ENTROPY_SRC_RAM_HASH, Enable/disable use of a RAM hash as an entropy source for the random seed, type=bool, default=1, group=pico_rand
#ifndef PICO_RAND_SEED_ENTROPY_SRC_RAM_HASH
#define PICO_RAND_SEED_ENTROPY_SRC_RAM_HASH 1
#endif

// ---------------------------------
// PICO_RAND_ENTROPY_SRC_ROSC CONFIG
// ---------------------------------

// PICO_CONFIG: PICO_RAND_ROSC_BIT_SAMPLE_COUNT, Number of samples to take of the ROSC random bit per random number generation , min=1, max=64, default=1, group=pico_rand
#ifndef PICO_RAND_ROSC_BIT_SAMPLE_COUNT
#define PICO_RAND_ROSC_BIT_SAMPLE_COUNT 1
#endif

// PICO_CONFIG: PICO_RAND_MIN_ROSC_BIT_SAMPLE_TIME_US, Define a default minimum time between sampling the ROSC random bit, min=5, max=20, default=10, group=pico_rand
#ifndef PICO_RAND_MIN_ROSC_BIT_SAMPLE_TIME_US
// (Arbitrary / tested) minimum time between sampling the ROSC random bit
#define PICO_RAND_MIN_ROSC_BIT_SAMPLE_TIME_US 10u
#endif

// ---------------------------------------------
// PICO_RAND_ENTROPY_SRC_BUS_PERF_COUNTER CONFIG
// ---------------------------------------------

// PICO_CONFIG: PICO_RAND_BUS_PERF_COUNTER_INDEX, Bus performance counter index to use for sourcing entropy, min=0, max=3, group=pico_rand
// this is deliberately undefined by default, meaning the code will pick that appears unused
//#define PICO_RAND_BUS_PERF_COUNTER_INDEX 0

// PICO_CONFIG: PICO_RAND_BUS_PERF_COUNTER_EVENT, Bus performance counter event to use for sourcing entropy, default=arbiter_sram5_perf_event_access, group=pico_rand
#ifndef PICO_RAND_BUS_PERF_COUNTER_EVENT
#define PICO_RAND_BUS_PERF_COUNTER_EVENT arbiter_sram5_perf_event_access
#endif

// ------------------------------------------
// PICO_RAND_SEED_ENTROPY_SRC_RAM_HASH CONFIG
// ------------------------------------------

// PICO_CONFIG: PICO_RAND_RAM_HASH_END, end of address in RAM (non-inclusive) to hash during pico_rand seed initialization, default=SRAM_END, group=pico_rand
#ifndef PICO_RAND_RAM_HASH_END
#define PICO_RAND_RAM_HASH_END SRAM_END
#endif
// PICO_CONFIG: PICO_RAND_RAM_HASH_START, start of address in RAM (inclusive) to hash during pico_rand seed initialization, default=PICO_RAND_RAM_HASH_END - 1024, group=pico_rand
#ifndef PICO_RAND_RAM_HASH_START
#define PICO_RAND_RAM_HASH_START (PICO_RAND_RAM_HASH_END - 1024u)
#endif

// We provide a maximum of 128 bits entropy in one go
typedef struct rng_128 {
uint64_t r[2];
} rng_128_t;

/*! \brief Get 128-bit random number
* \ingroup pico_rand
*
* This method may be safely called from either core or from an IRQ, but be careful in the latter case as
* the call may block for a number of microseconds waiting on more entropy.
*
* \param rand128 Pointer to storage to accept a 128-bit random number
*/
void get_rand_128(rng_128_t *rand128);

/*! \brief Get 64-bit random number
* \ingroup pico_rand
*
* This method may be safely called from either core or from an IRQ, but be careful in the latter case as
* the call may block for a number of microseconds waiting on more entropy.
*
* \return 64-bit random number
*/
uint64_t get_rand_64(void);

/*! \brief Get 32-bit random number
* \ingroup pico_rand
*
* This method may be safely called from either core or from an IRQ, but be careful in the latter case as
* the call may block for a number of microseconds waiting on more entropy.
*
* \return 32-bit random number
*/
uint32_t get_rand_32(void);

#ifdef __cplusplus
}
#endif

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,11 @@ typedef enum {
NC = (int)0xFFFFFFFF
} PinName;

// Standardized LED and button names
#define LED1 LED_RED
#define LED2 LED_GREEN
#define LED3 LED_BLUE

#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion variants/ARDUINO_NANO33BLE/defines.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
-DFEATURE_STORAGE=1
-D__FPU_PRESENT=1
-D__MBED__=1
-DMBED_BUILD_TIMESTAMP=1714634438.5709226
-DMBED_BUILD_TIMESTAMP=1719580467.0657709
-D__MBED_CMSIS_RTOS_CM
-DMBED_MPU_CUSTOM
-DMBED_TICKLESS
Expand Down
Binary file modified variants/ARDUINO_NANO33BLE/libs/libmbed.a
Binary file not shown.
2 changes: 1 addition & 1 deletion variants/EDGE_CONTROL/defines.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
-DFEATURE_STORAGE=1
-D__FPU_PRESENT=1
-D__MBED__=1
-DMBED_BUILD_TIMESTAMP=1714634611.8500743
-DMBED_BUILD_TIMESTAMP=1719580640.5462966
-D__MBED_CMSIS_RTOS_CM
-DMBED_MPU_CUSTOM
-DMBED_TICKLESS
Expand Down
Binary file modified variants/EDGE_CONTROL/libs/libmbed.a
Binary file not shown.
2 changes: 1 addition & 1 deletion variants/GENERIC_STM32H747_M4/defines.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
-DFEATURE_BLE=1
-D__FPU_PRESENT=1
-D__MBED__=1
-DMBED_BUILD_TIMESTAMP=1714634557.8324108
-DMBED_BUILD_TIMESTAMP=1719580585.9789317
-D__MBED_CMSIS_RTOS_CM
-DMBED_MPU_CUSTOM
-DMBED_TICKLESS
Expand Down
Binary file modified variants/GENERIC_STM32H747_M4/libs/libmbed.a
Binary file not shown.
2 changes: 1 addition & 1 deletion variants/GIGA/defines.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
-DFEATURE_BLE=1
-D__FPU_PRESENT=1
-D__MBED__=1
-DMBED_BUILD_TIMESTAMP=1714634802.9424186
-DMBED_BUILD_TIMESTAMP=1719580836.3122623
-D__MBED_CMSIS_RTOS_CM
-DMBED_TICKLESS
-DMBEDTLS_FS_IO
Expand Down
Binary file modified variants/GIGA/libs/libmbed.a
Binary file not shown.
3 changes: 2 additions & 1 deletion variants/NANO_RP2040_CONNECT/defines.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
-DDEVICE_SERIAL=1
-DDEVICE_SERIAL_FC=1
-DDEVICE_SPI=1
-DDEVICE_TRNG=1
-DDEVICE_USBDEVICE=1
-DDEVICE_USTICKER=1
-DDEVICE_WATCHDOG=1
-D__MBED__=1
-DMBED_BUILD_TIMESTAMP=1714634413.5827048
-DMBED_BUILD_TIMESTAMP=1719580442.2641459
-D__MBED_CMSIS_RTOS_CM
-DMBED_MPU_CUSTOM
-DMBEDTLS_ENTROPY_NV_SEED
Expand Down
3 changes: 3 additions & 0 deletions variants/NANO_RP2040_CONNECT/includes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@
-iwithprefixbefore/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_platform
-iwithprefixbefore/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_platform/include
-iwithprefixbefore/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_platform/include/pico
-iwithprefixbefore/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_rand
-iwithprefixbefore/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_rand/include
-iwithprefixbefore/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_rand/include/pico
-iwithprefixbefore/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_runtime
-iwithprefixbefore/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_runtime/include
-iwithprefixbefore/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_runtime/include/pico
Expand Down
Binary file modified variants/NANO_RP2040_CONNECT/libs/libmbed.a
Binary file not shown.
2 changes: 1 addition & 1 deletion variants/NICLA/defines.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
-DFEATURE_BLE=1
-D__FPU_PRESENT=1
-D__MBED__=1
-DMBED_BUILD_TIMESTAMP=1714634654.8014047
-DMBED_BUILD_TIMESTAMP=1719580684.6774077
-D__MBED_CMSIS_RTOS_CM
-DMBED_MPU_CUSTOM
-DMBED_TICKLESS
Expand Down
Binary file modified variants/NICLA/libs/libmbed.a
Binary file not shown.
2 changes: 1 addition & 1 deletion variants/NICLA_VISION/defines.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
-DFLOW_SILENT
-D__FPU_PRESENT=1
-D__MBED__=1
-DMBED_BUILD_TIMESTAMP=1714634691.0340967
-DMBED_BUILD_TIMESTAMP=1719580720.2247646
-D__MBED_CMSIS_RTOS_CM
-DMBED_TICKLESS
-DMBEDTLS_FS_IO
Expand Down
Binary file modified variants/NICLA_VISION/libs/libmbed.a
Binary file not shown.
2 changes: 1 addition & 1 deletion variants/OPTA/defines.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
-DFEATURE_BLE=1
-D__FPU_PRESENT=1
-D__MBED__=1
-DMBED_BUILD_TIMESTAMP=1714634749.1033652
-DMBED_BUILD_TIMESTAMP=1719580779.4364524
-D__MBED_CMSIS_RTOS_CM
-DMBED_TICKLESS
-DMBEDTLS_FS_IO
Expand Down
Binary file modified variants/OPTA/libs/libmbed.a
Binary file not shown.
2 changes: 1 addition & 1 deletion variants/PORTENTA_H7_M7/defines.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
-D__FPU_PRESENT=1
-DLSE_STARTUP_TIMEOUT=200
-D__MBED__=1
-DMBED_BUILD_TIMESTAMP=1714634500.4736958
-DMBED_BUILD_TIMESTAMP=1719580529.7864532
-D__MBED_CMSIS_RTOS_CM
-DMBED_TICKLESS
-DMBEDTLS_FS_IO
Expand Down
Binary file modified variants/PORTENTA_H7_M7/libs/libmbed.a
Binary file not shown.
2 changes: 1 addition & 1 deletion variants/PORTENTA_X8/defines.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
-DEXTRA_IDLE_STACK_REQUIRED
-D__FPU_PRESENT=1
-D__MBED__=1
-DMBED_BUILD_TIMESTAMP=1714634855.9342184
-DMBED_BUILD_TIMESTAMP=1719580895.1557932
-D__MBED_CMSIS_RTOS_CM
-DMBED_MPU_CUSTOM
-DMBED_TICKLESS
Expand Down
Binary file modified variants/PORTENTA_X8/libs/libmbed.a
Binary file not shown.
3 changes: 2 additions & 1 deletion variants/RASPBERRY_PI_PICO/defines.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
-DDEVICE_SERIAL=1
-DDEVICE_SERIAL_FC=1
-DDEVICE_SPI=1
-DDEVICE_TRNG=1
-DDEVICE_USBDEVICE=1
-DDEVICE_USTICKER=1
-DDEVICE_WATCHDOG=1
-D__MBED__=1
-DMBED_BUILD_TIMESTAMP=1714634475.1721134
-DMBED_BUILD_TIMESTAMP=1719580504.0819786
-D__MBED_CMSIS_RTOS_CM
-DMBED_MPU_CUSTOM
-DMBEDTLS_ENTROPY_NV_SEED
Expand Down
3 changes: 3 additions & 0 deletions variants/RASPBERRY_PI_PICO/includes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@
-iwithprefixbefore/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_platform
-iwithprefixbefore/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_platform/include
-iwithprefixbefore/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_platform/include/pico
-iwithprefixbefore/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_rand
-iwithprefixbefore/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_rand/include
-iwithprefixbefore/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_rand/include/pico
-iwithprefixbefore/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_runtime
-iwithprefixbefore/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_runtime/include
-iwithprefixbefore/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_runtime/include/pico
Expand Down
Binary file modified variants/RASPBERRY_PI_PICO/libs/libmbed.a
Binary file not shown.

0 comments on commit 2ece915

Please sign in to comment.