diff options
author | edolomb <none@example.com> | 2018-04-11 16:53:22 +0000 |
---|---|---|
committer | edolomb <none@example.com> | 2018-04-11 16:53:22 +0000 |
commit | 1987d9006e9a0a1b5c62520e0d9c6413f70e0853 (patch) | |
tree | 3a1f5702eaa545a50aa9bc688091db5e61d5a4df /testhal | |
parent | 1ad24ae0b3e2d4083612159158762a06a4af75e0 (diff) | |
download | ChibiOS-1987d9006e9a0a1b5c62520e0d9c6413f70e0853.tar.gz ChibiOS-1987d9006e9a0a1b5c62520e0d9c6413f70e0853.tar.bz2 ChibiOS-1987d9006e9a0a1b5c62520e0d9c6413f70e0853.zip |
Updated demo and chconf.h
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11903 110e8d01-0319-4d1e-a829-52ad28d1bb01
Diffstat (limited to 'testhal')
-rwxr-xr-x | testhal/ATSAMA5D2/SECUMOD/Makefile | 2 | ||||
-rwxr-xr-x | testhal/ATSAMA5D2/SECUMOD/chconf.h | 3 | ||||
-rw-r--r-- | testhal/ATSAMA5D2/SECUMOD/halconf.h | 2 | ||||
-rwxr-xr-x | testhal/ATSAMA5D2/SECUMOD/main.c | 101 |
4 files changed, 100 insertions, 8 deletions
diff --git a/testhal/ATSAMA5D2/SECUMOD/Makefile b/testhal/ATSAMA5D2/SECUMOD/Makefile index 8cc6738d3..1203041c0 100755 --- a/testhal/ATSAMA5D2/SECUMOD/Makefile +++ b/testhal/ATSAMA5D2/SECUMOD/Makefile @@ -5,7 +5,7 @@ # Compiler options here.
ifeq ($(USE_OPT),)
- USE_OPT = -Og -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).
diff --git a/testhal/ATSAMA5D2/SECUMOD/chconf.h b/testhal/ATSAMA5D2/SECUMOD/chconf.h index b1e3841a8..33b59452e 100755 --- a/testhal/ATSAMA5D2/SECUMOD/chconf.h +++ b/testhal/ATSAMA5D2/SECUMOD/chconf.h @@ -49,7 +49,8 @@ * @details Frequency of the system timer that drives the system ticks. This
* setting also defines the system tick time unit.
*/
-#define CH_CFG_ST_FREQUENCY 1000
+#define CH_CFG_ST_FREQUENCY 1000 /* periodic tick. */
+//#define CH_CFG_ST_FREQUENCY (83000000 / 32) /* tick-less. */
/**
* @brief Time intervals data size.
diff --git a/testhal/ATSAMA5D2/SECUMOD/halconf.h b/testhal/ATSAMA5D2/SECUMOD/halconf.h index 0fa8e3ca4..a70d4e11a 100644 --- a/testhal/ATSAMA5D2/SECUMOD/halconf.h +++ b/testhal/ATSAMA5D2/SECUMOD/halconf.h @@ -135,7 +135,7 @@ * @brief Enables the RTC subsystem.
*/
#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__)
-#define HAL_USE_RTC FALSE
+#define HAL_USE_RTC TRUE
#endif
/**
diff --git a/testhal/ATSAMA5D2/SECUMOD/main.c b/testhal/ATSAMA5D2/SECUMOD/main.c index 3b6cadf5a..2a2709106 100755 --- a/testhal/ATSAMA5D2/SECUMOD/main.c +++ b/testhal/ATSAMA5D2/SECUMOD/main.c @@ -17,6 +17,69 @@ #include "ch.h"
#include "hal.h"
+/* Time and source of tamper */
+typedef struct {
+ uint8_t mode; /* tamper occurs in normal or backup mode */
+ RTCDateTime tamper_time;
+ uint32_t source; /* tamper source */
+} tamper_detail;
+
+/* informations of tamper */
+typedef struct {
+ bool jtag_sel_ca5; /* JTAGSEL, CA5 Tap response or CA5 debug ACK detected */
+ bool jtag_tck_tms; /* JTAG TCK/TMS activity detected */
+
+ /* tamper counter */
+ uint32_t tampers;
+
+ /* total number of tampers occured */
+ uint32_t total_tampers;
+
+ /* detail information of first and last tamper */
+ tamper_detail details[2];
+} tamper_info;
+
+static tamper_info t_info;
+
+RTCDateTime cfg_time = {
+ 38,
+ 4,
+ 0,
+ 1,
+ 9,
+ 66840000
+};
+
+void updateTamperStruct(tamper_info *info, secevent_t event) {
+
+ /*Clear the tamper_info bits before checking the tamper type*/
+ info->jtag_sel_ca5 = FALSE;
+ info->jtag_tck_tms = FALSE;
+ info->total_tampers = 0;
+
+ /* Read auxiliary status if needed */
+ if (event == SEC_EVENT_JTAG) {
+ uint32_t jtag = SECUMOD->SECUMOD_ASR;
+ info->jtag_sel_ca5 = ((jtag & SECUMOD_ASR_JTAG) != 0);
+ info->jtag_tck_tms = ((jtag & SECUMOD_ASR_TCK) != 0);
+ }
+
+ /* Read tamper counter */
+ info->tampers = rtcGetTamperEventCounter(&RTCD0);
+ /* Update the total counter */
+ info->total_tampers += 1;
+
+ /* Read tamper information */
+ uint8_t index = (info->total_tampers != 0 ) ? 2 : 1;
+ while (index) {
+ index--;
+ tamper_detail *detail = &(info->details[index]);
+ rtcGetTamperTime(&RTCD0, index, &detail->tamper_time);
+ detail->source = rtcGetTamperSource(&RTCD0, index);
+ detail->mode = rtcGetTamperMode(&RTCD0, index);
+ }
+}
+
/* PIOBU pin attribute */
static PIOBUConfig piocfg[] = {
{
@@ -95,20 +158,40 @@ static PIOBUConfig piocfg[] = { static void secram_callback(SECDriver *secp) {
(void)secp;
- palToggleLine(LINE_LED_RED);
+ palClearLine(LINE_LED_RED);
}
static void erase_callback(SECDriver *secp) {
(void)secp;
- palToggleLine(LINE_LED_GREEN);
+ palClearLine(LINE_LED_GREEN);
}
-static void secmod_callback(SECDriver *secp, secevent_t event) {
+static void secmod_callback(SECDriver *secp, secevent_t event) {
(void)secp;
chSysLockFromISR();
switch (event) {
- case SEC_EVENT_PIOBU:
- /* Erasing memories on intrusion */
+ case (SEC_EVENT_PIOBU0):
+ secumodSoftwareProtection();
+ break;
+ case (SEC_EVENT_PIOBU1):
+ secumodSoftwareProtection();
+ break;
+ case (SEC_EVENT_PIOBU2):
+ secumodSoftwareProtection();
+ break;
+ case (SEC_EVENT_PIOBU3):
+ secumodSoftwareProtection();
+ break;
+ case (SEC_EVENT_PIOBU4):
+ secumodSoftwareProtection();
+ break;
+ case (SEC_EVENT_PIOBU5):
+ secumodSoftwareProtection();
+ break;
+ case (SEC_EVENT_PIOBU6):
+ secumodSoftwareProtection();
+ break;
+ case (SEC_EVENT_PIOBU7):
secumodSoftwareProtection();
break;
case SEC_EVENT_SHLDM:
@@ -145,6 +228,9 @@ static void secmod_callback(SECDriver *secp, secevent_t event) { ;
break;
}
+
+ /* Storing tamper information */
+ updateTamperStruct(&t_info, event);
chSysUnlockFromISR();
}
@@ -207,6 +293,11 @@ int main(void) { chSysInit();
secInit();
+ /*
+ * Configures date
+ */
+ rtcSetTime(&RTCD0, &cfg_time);
+
/* REGION_0 location */
uint32_t *region0 = (uint32_t *) 0xF8044000;
|