Updated demo and chconf.h

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11903 110e8d01-0319-4d1e-a829-52ad28d1bb01
This commit is contained in:
edolomb 2018-04-11 16:53:22 +00:00
parent 1ad24ae0b3
commit 1987d9006e
4 changed files with 100 additions and 8 deletions

View File

@ -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).

View File

@ -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.

View File

@ -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
/**

View File

@ -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) {
(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;