You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ut...@apache.org on 2019/06/14 10:08:39 UTC

[mynewt-core] 01/04: [STM32] Enable TRNG/CRYP for NUCLEO-F439ZI

This is an automated email from the ASF dual-hosted git repository.

utzig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 82ddf5c677c6e2a59bf49f6738e50a7ba9f7032b
Author: Fabio Utzig <ut...@apache.org>
AuthorDate: Fri May 17 13:28:48 2019 -0700

    [STM32] Enable TRNG/CRYP for NUCLEO-F439ZI
---
 .../nucleo-f439zi/include/bsp/stm32f4xx_hal_conf.h |  3 +-
 hw/bsp/nucleo-f439zi/pkg.yml                       |  6 ++++
 hw/bsp/nucleo-f439zi/src/hal_bsp.c                 | 33 ++++++++++++++++++++++
 3 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/hw/bsp/nucleo-f439zi/include/bsp/stm32f4xx_hal_conf.h b/hw/bsp/nucleo-f439zi/include/bsp/stm32f4xx_hal_conf.h
index 1ea1f32..966b9fd 100644
--- a/hw/bsp/nucleo-f439zi/include/bsp/stm32f4xx_hal_conf.h
+++ b/hw/bsp/nucleo-f439zi/include/bsp/stm32f4xx_hal_conf.h
@@ -75,7 +75,6 @@
 #define HAL_LTDC_MODULE_ENABLED
 #define HAL_PWR_MODULE_ENABLED
 #define HAL_RCC_MODULE_ENABLED
-#define HAL_RNG_MODULE_ENABLED
 #define HAL_RTC_MODULE_ENABLED
 /* #define HAL_SAI_MODULE_ENABLED */
 #define HAL_SD_MODULE_ENABLED
@@ -99,6 +98,8 @@
 #define HAL_RCC_MODULE_ENABLED
 #define HAL_SPI_MODULE_ENABLED
 #define HAL_CORTEX_MODULE_ENABLED
+#define HAL_RNG_MODULE_ENABLED
+#define HAL_CRYP_MODULE_ENABLED
 #endif
 
 /* ########################## HSE/HSI Values adaptation ##################### */
diff --git a/hw/bsp/nucleo-f439zi/pkg.yml b/hw/bsp/nucleo-f439zi/pkg.yml
index 5bb7578..b2fbde5 100644
--- a/hw/bsp/nucleo-f439zi/pkg.yml
+++ b/hw/bsp/nucleo-f439zi/pkg.yml
@@ -40,3 +40,9 @@ pkg.deps:
 
 pkg.deps.UART_0:
     - "@apache-mynewt-core/hw/drivers/uart/uart_hal"
+
+pkg.deps.TRNG:
+    - "@apache-mynewt-core/hw/drivers/trng/trng_stm32"
+
+pkg.deps.CRYPTO:
+    - "@apache-mynewt-core/hw/drivers/crypto/crypto_stm32"
diff --git a/hw/bsp/nucleo-f439zi/src/hal_bsp.c b/hw/bsp/nucleo-f439zi/src/hal_bsp.c
index 4727bd3..66e05c8 100644
--- a/hw/bsp/nucleo-f439zi/src/hal_bsp.c
+++ b/hw/bsp/nucleo-f439zi/src/hal_bsp.c
@@ -26,6 +26,16 @@
 #include <uart_hal/uart_hal.h>
 #endif
 
+#if MYNEWT_VAL(TRNG)
+#include "trng/trng.h"
+#include "trng_stm32/trng_stm32.h"
+#endif
+
+#if MYNEWT_VAL(CRYPTO)
+#include "crypto/crypto.h"
+#include "crypto_stm32/crypto_stm32.h"
+#endif
+
 #include <hal/hal_bsp.h>
 #include <hal/hal_gpio.h>
 #include <hal/hal_timer.h>
@@ -74,6 +84,14 @@ const uint32_t stm32_flash_sectors[] = {
 _Static_assert(MYNEWT_VAL(STM32_FLASH_NUM_AREAS) == SZ,
         "STM32_FLASH_NUM_AREAS does not match flash sectors");
 
+#if MYNEWT_VAL(TRNG)
+static struct trng_dev os_bsp_trng;
+#endif
+
+#if MYNEWT_VAL(CRYPTO)
+static struct crypto_dev os_bsp_crypto;
+#endif
+
 #if MYNEWT_VAL(UART_0)
 static struct uart_dev hal_uart0;
 
@@ -166,11 +184,26 @@ hal_bsp_init(void)
 
     (void)rc;
 
+#if MYNEWT_VAL(TRNG)
+    rc = os_dev_create(&os_bsp_trng.dev, "trng",
+                       OS_DEV_INIT_KERNEL, OS_DEV_INIT_PRIO_DEFAULT,
+                       stm32_trng_dev_init, NULL);
+    assert(rc == 0);
+#endif
+
+#if MYNEWT_VAL(CRYPTO)
+    rc = os_dev_create(&os_bsp_crypto.dev, "crypto",
+                       OS_DEV_INIT_KERNEL, OS_DEV_INIT_PRIO_DEFAULT,
+                       stm32_crypto_dev_init, NULL);
+    assert(rc == 0);
+#endif
+
 #if MYNEWT_VAL(UART_0)
     rc = os_dev_create((struct os_dev *) &hal_uart0, "uart0",
       OS_DEV_INIT_PRIMARY, 0, uart_hal_init, (void *)&uart_cfg[0]);
     assert(rc == 0);
 #endif
+
 #if MYNEWT_VAL(TIMER_0)
     hal_timer_init(0, TIM9);
 #endif