aboutsummaryrefslogtreecommitdiffstats
path: root/testhal
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2018-10-07 08:56:43 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2018-10-07 08:56:43 +0000
commit0f2e8f0b01edd1a0389426b316f491acf49af596 (patch)
tree78d608ed936ff7f1c5fc20c21fcbb68a717ea837 /testhal
parente72ef8c943b3a335fe4354e6451be99ab1346081 (diff)
downloadChibiOS-0f2e8f0b01edd1a0389426b316f491acf49af596.tar.gz
ChibiOS-0f2e8f0b01edd1a0389426b316f491acf49af596.tar.bz2
ChibiOS-0f2e8f0b01edd1a0389426b316f491acf49af596.zip
TRNG driver working.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12343 110e8d01-0319-4d1e-a829-52ad28d1bb01
Diffstat (limited to 'testhal')
-rw-r--r--testhal/STM32/STM32L4xx/ADC/mcuconf.h5
-rw-r--r--testhal/STM32/STM32L4xx/CAN/mcuconf.h5
-rw-r--r--testhal/STM32/STM32L4xx/GPT-ADC/mcuconf.h5
-rw-r--r--testhal/STM32/STM32L4xx/IRQ_STORM/mcuconf.h5
-rw-r--r--testhal/STM32/STM32L4xx/WSPI-N25Q128/mcuconf.h5
-rw-r--r--testhal/STM32/multi/PAL/cfg/stm32l476_discovery/mcuconf.h5
-rw-r--r--testhal/STM32/multi/SPI/cfg/stm32l476_discovery/mcuconf.h5
-rw-r--r--testhal/STM32/multi/TRNG/debug/STM32-TRNG (Select ELF file)(OpenOCD, Flash and Run).launch2
-rw-r--r--testhal/STM32/multi/TRNG/main.c48
-rw-r--r--testhal/STM32/multi/TRNG/make/stm32l476_discovery.make3
-rw-r--r--testhal/STM32/multi/USB_CDC/cfg/stm32l476_discovery/mcuconf.h5
-rw-r--r--testhal/STM32/multi/WSPI-MFS/cfg/stm32l476_discovery/mcuconf.h5
12 files changed, 96 insertions, 2 deletions
diff --git a/testhal/STM32/STM32L4xx/ADC/mcuconf.h b/testhal/STM32/STM32L4xx/ADC/mcuconf.h
index 794d15778..dd2ad2869 100644
--- a/testhal/STM32/STM32L4xx/ADC/mcuconf.h
+++ b/testhal/STM32/STM32L4xx/ADC/mcuconf.h
@@ -278,6 +278,11 @@
#define STM32_ST_USE_TIMER 2
/*
+ * TRNG driver system settings.
+ */
+#define STM32_TRNG_USE_RNG1 FALSE
+
+/*
* UART driver system settings.
*/
#define STM32_UART_USE_USART1 FALSE
diff --git a/testhal/STM32/STM32L4xx/CAN/mcuconf.h b/testhal/STM32/STM32L4xx/CAN/mcuconf.h
index f1f97e475..dacd19d6c 100644
--- a/testhal/STM32/STM32L4xx/CAN/mcuconf.h
+++ b/testhal/STM32/STM32L4xx/CAN/mcuconf.h
@@ -278,6 +278,11 @@
#define STM32_ST_USE_TIMER 2
/*
+ * TRNG driver system settings.
+ */
+#define STM32_TRNG_USE_RNG1 FALSE
+
+/*
* UART driver system settings.
*/
#define STM32_UART_USE_USART1 FALSE
diff --git a/testhal/STM32/STM32L4xx/GPT-ADC/mcuconf.h b/testhal/STM32/STM32L4xx/GPT-ADC/mcuconf.h
index 5775b917e..4bb6a40e6 100644
--- a/testhal/STM32/STM32L4xx/GPT-ADC/mcuconf.h
+++ b/testhal/STM32/STM32L4xx/GPT-ADC/mcuconf.h
@@ -278,6 +278,11 @@
#define STM32_ST_USE_TIMER 2
/*
+ * TRNG driver system settings.
+ */
+#define STM32_TRNG_USE_RNG1 FALSE
+
+/*
* UART driver system settings.
*/
#define STM32_UART_USE_USART1 FALSE
diff --git a/testhal/STM32/STM32L4xx/IRQ_STORM/mcuconf.h b/testhal/STM32/STM32L4xx/IRQ_STORM/mcuconf.h
index 5359f99d3..94f048bd8 100644
--- a/testhal/STM32/STM32L4xx/IRQ_STORM/mcuconf.h
+++ b/testhal/STM32/STM32L4xx/IRQ_STORM/mcuconf.h
@@ -278,6 +278,11 @@
#define STM32_ST_USE_TIMER 2
/*
+ * TRNG driver system settings.
+ */
+#define STM32_TRNG_USE_RNG1 FALSE
+
+/*
* UART driver system settings.
*/
#define STM32_UART_USE_USART1 FALSE
diff --git a/testhal/STM32/STM32L4xx/WSPI-N25Q128/mcuconf.h b/testhal/STM32/STM32L4xx/WSPI-N25Q128/mcuconf.h
index d5acc2985..6bf47d820 100644
--- a/testhal/STM32/STM32L4xx/WSPI-N25Q128/mcuconf.h
+++ b/testhal/STM32/STM32L4xx/WSPI-N25Q128/mcuconf.h
@@ -278,6 +278,11 @@
#define STM32_ST_USE_TIMER 2
/*
+ * TRNG driver system settings.
+ */
+#define STM32_TRNG_USE_RNG1 FALSE
+
+/*
* UART driver system settings.
*/
#define STM32_UART_USE_USART1 FALSE
diff --git a/testhal/STM32/multi/PAL/cfg/stm32l476_discovery/mcuconf.h b/testhal/STM32/multi/PAL/cfg/stm32l476_discovery/mcuconf.h
index ca04e21c0..b60398347 100644
--- a/testhal/STM32/multi/PAL/cfg/stm32l476_discovery/mcuconf.h
+++ b/testhal/STM32/multi/PAL/cfg/stm32l476_discovery/mcuconf.h
@@ -278,6 +278,11 @@
#define STM32_ST_USE_TIMER 2
/*
+ * TRNG driver system settings.
+ */
+#define STM32_TRNG_USE_RNG1 FALSE
+
+/*
* UART driver system settings.
*/
#define STM32_UART_USE_USART1 FALSE
diff --git a/testhal/STM32/multi/SPI/cfg/stm32l476_discovery/mcuconf.h b/testhal/STM32/multi/SPI/cfg/stm32l476_discovery/mcuconf.h
index 80c9adf1b..d5a4b4865 100644
--- a/testhal/STM32/multi/SPI/cfg/stm32l476_discovery/mcuconf.h
+++ b/testhal/STM32/multi/SPI/cfg/stm32l476_discovery/mcuconf.h
@@ -278,6 +278,11 @@
#define STM32_ST_USE_TIMER 2
/*
+ * TRNG driver system settings.
+ */
+#define STM32_TRNG_USE_RNG1 FALSE
+
+/*
* UART driver system settings.
*/
#define STM32_UART_USE_USART1 FALSE
diff --git a/testhal/STM32/multi/TRNG/debug/STM32-TRNG (Select ELF file)(OpenOCD, Flash and Run).launch b/testhal/STM32/multi/TRNG/debug/STM32-TRNG (Select ELF file)(OpenOCD, Flash and Run).launch
index 5b1ae6f78..c5b8ef7e9 100644
--- a/testhal/STM32/multi/TRNG/debug/STM32-TRNG (Select ELF file)(OpenOCD, Flash and Run).launch
+++ b/testhal/STM32/multi/TRNG/debug/STM32-TRNG (Select ELF file)(OpenOCD, Flash and Run).launch
@@ -33,7 +33,7 @@
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
-<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;contentList&gt;&lt;content id=&quot;xPSR-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;mfs_buffer[447]-null-mfs_test_001_005_execute-(format)&quot; val=&quot;0&quot;/&gt;&lt;content id=&quot;mfs_buffer[507]-null-mfs_test_001_005_execute-(format)&quot; val=&quot;0&quot;/&gt;&lt;content id=&quot;rp[506]-rp-mfs_flash_read-(format)&quot; val=&quot;0&quot;/&gt;&lt;content id=&quot;rp[507]-rp-mfs_flash_read-(format)&quot; val=&quot;0&quot;/&gt;&lt;content id=&quot;rp-mfs_flash_read-(cast_to_array)&quot; val=&quot;0:511&quot;/&gt;&lt;/contentList&gt;"/>
+<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;contentList&gt;&lt;content id=&quot;rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rp-mfs_flash_read-(cast_to_array)&quot; val=&quot;0:511&quot;/&gt;&lt;content id=&quot;rp[507]-rp-mfs_flash_read-(format)&quot; val=&quot;0&quot;/&gt;&lt;content id=&quot;rp[506]-rp-mfs_flash_read-(format)&quot; val=&quot;0&quot;/&gt;&lt;content id=&quot;mfs_buffer[507]-null-mfs_test_001_005_execute-(format)&quot; val=&quot;0&quot;/&gt;&lt;content id=&quot;mfs_buffer[447]-null-mfs_test_001_005_execute-(format)&quot; val=&quot;0&quot;/&gt;&lt;content id=&quot;xPSR-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[0]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[1]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[2]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[3]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[4]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[5]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[6]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[7]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[8]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[9]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[10]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[11]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[12]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[13]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[14]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[15]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[16]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[17]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[18]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[19]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[20]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[21]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[22]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[23]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[24]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[25]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[26]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[27]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[28]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[29]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[30]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;rand[31]-rand-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;/contentList&gt;"/>
<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;globalVariableList/&gt;&#10;"/>
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;memoryBlockExpressionList&gt;&#10;&lt;memoryBlockExpressionItem&gt;&#10;&lt;expression text=&quot;0x20000c34&quot;/&gt;&#10;&lt;/memoryBlockExpressionItem&gt;&#10;&lt;/memoryBlockExpressionList&gt;&#10;"/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="${selected_resource_loc}"/>
diff --git a/testhal/STM32/multi/TRNG/main.c b/testhal/STM32/multi/TRNG/main.c
index 83edb3e63..51d03718d 100644
--- a/testhal/STM32/multi/TRNG/main.c
+++ b/testhal/STM32/multi/TRNG/main.c
@@ -16,6 +16,7 @@
#include "ch.h"
#include "hal.h"
+#include "chprintf.h"
#include "portab.h"
@@ -61,6 +62,53 @@ int main(void) {
/* Normal main() thread activity, in this demo it does nothing.*/
while (true) {
+ if (palReadLine(PORTAB_LINE_BUTTON) == PORTAB_BUTTON_PRESSED) {
+ bool err;
+ uint8_t rand[32];
+
+ trngStart(&TRNGD1, NULL);
+
+ err = trngGenerate(&TRNGD1, 32, rand);
+ if (err) {
+ chprintf((BaseSequentialStream *)&PORTAB_SD1, "Error!\r\n");
+ }
+ else {
+ unsigned i;
+
+ for (i = 0; i < 32; i++) {
+ chprintf((BaseSequentialStream *)&PORTAB_SD1, "%02x", rand[i]);
+ }
+ chprintf((BaseSequentialStream *)&PORTAB_SD1, "\r\n");
+ }
+
+ err = trngGenerate(&TRNGD1, 15, rand);
+ if (err) {
+ chprintf((BaseSequentialStream *)&PORTAB_SD1, "Error!\r\n");
+ }
+ else {
+ unsigned i;
+
+ for (i = 0; i < 15; i++) {
+ chprintf((BaseSequentialStream *)&PORTAB_SD1, "%02x", rand[i]);
+ }
+ chprintf((BaseSequentialStream *)&PORTAB_SD1, "\r\n");
+ }
+
+ err = trngGenerate(&TRNGD1, 2, rand);
+ if (err) {
+ chprintf((BaseSequentialStream *)&PORTAB_SD1, "Error!\r\n");
+ }
+ else {
+ unsigned i;
+
+ for (i = 0; i < 2; i++) {
+ chprintf((BaseSequentialStream *)&PORTAB_SD1, "%02x", rand[i]);
+ }
+ chprintf((BaseSequentialStream *)&PORTAB_SD1, "\r\n");
+ }
+
+ trngStop(&TRNGD1);
+ }
chThdSleepMilliseconds(500);
}
return 0;
diff --git a/testhal/STM32/multi/TRNG/make/stm32l476_discovery.make b/testhal/STM32/multi/TRNG/make/stm32l476_discovery.make
index a8d43f714..21875522e 100644
--- a/testhal/STM32/multi/TRNG/make/stm32l476_discovery.make
+++ b/testhal/STM32/multi/TRNG/make/stm32l476_discovery.make
@@ -5,7 +5,7 @@
# Compiler options here.
ifeq ($(USE_OPT),)
- USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
+ USE_OPT = -O0 -ggdb -fomit-frame-pointer -falign-functions=16
endif
# C specific options here (added to USE_OPT).
@@ -112,6 +112,7 @@ include $(CHIBIOS)/tools/mk/autobuild.mk
include $(CHIBIOS)/test/lib/test.mk
include $(CHIBIOS)/test/rt/rt_test.mk
include $(CHIBIOS)/test/oslib/oslib_test.mk
+include $(CHIBIOS)/os/hal/lib/streams/streams.mk
# Define linker script file here.
LDSCRIPT= $(STARTUPLD)/STM32L476xG.ld
diff --git a/testhal/STM32/multi/USB_CDC/cfg/stm32l476_discovery/mcuconf.h b/testhal/STM32/multi/USB_CDC/cfg/stm32l476_discovery/mcuconf.h
index 669ff94cb..bf0da7566 100644
--- a/testhal/STM32/multi/USB_CDC/cfg/stm32l476_discovery/mcuconf.h
+++ b/testhal/STM32/multi/USB_CDC/cfg/stm32l476_discovery/mcuconf.h
@@ -278,6 +278,11 @@
#define STM32_ST_USE_TIMER 2
/*
+ * TRNG driver system settings.
+ */
+#define STM32_TRNG_USE_RNG1 FALSE
+
+/*
* UART driver system settings.
*/
#define STM32_UART_USE_USART1 FALSE
diff --git a/testhal/STM32/multi/WSPI-MFS/cfg/stm32l476_discovery/mcuconf.h b/testhal/STM32/multi/WSPI-MFS/cfg/stm32l476_discovery/mcuconf.h
index 46e69ff34..c4e6a0754 100644
--- a/testhal/STM32/multi/WSPI-MFS/cfg/stm32l476_discovery/mcuconf.h
+++ b/testhal/STM32/multi/WSPI-MFS/cfg/stm32l476_discovery/mcuconf.h
@@ -278,6 +278,11 @@
#define STM32_ST_USE_TIMER 2
/*
+ * TRNG driver system settings.
+ */
+#define STM32_TRNG_USE_RNG1 FALSE
+
+/*
* UART driver system settings.
*/
#define STM32_UART_USE_USART1 FALSE