-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Significant refactor. Add U0 hal. Add prototype crypto impl for U0.
- Loading branch information
Showing
43 changed files
with
869 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Import('env') | ||
from os.path import join, realpath | ||
|
||
# Private flags for the current "hal-stm32" source files | ||
defines = env.get("CPPDEFINES", []) | ||
|
||
if "STM32U0" in defines: | ||
print("Using ststm32 u0xx HAL implementation") | ||
env.Replace(SRC_FILTER=["+<hal_platform/common/*.*>", "+<hal_platform/u0xx/*.*>"]) | ||
|
||
elif "STM32F4" in defines: | ||
print("Using ststm32 f4xx HAL implementation") | ||
env.Replace(SRC_FILTER=["+<hal_platform/common/*.*>", "+<hal_platform/f4xx/*.*>"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,5 +23,8 @@ | |
"name": "ebs-ds", | ||
"version": "^0.2.0" | ||
} | ||
] | ||
], | ||
"build": { | ||
"extraScript": "family.py" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
#ifdef STM32F4 | ||
#include "f4xx/core_handlers.h" | ||
#endif | ||
#include "families.h" | ||
#include STRINGIFY(FAMILY/core_handlers.h) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
#ifdef STM32F4 | ||
#include "f4xx/core_impl.h" | ||
#endif | ||
#include "families.h" | ||
#include STRINGIFY(FAMILY/core_impl.h) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#include "families.h" | ||
#include STRINGIFY(FAMILY/crypto_handlers.h) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#include "families.h" | ||
#include STRINGIFY(FAMILY/crypto_impl.h) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
#ifdef STM32F4 | ||
#include "f4xx/eeprom_impl.h" | ||
#endif | ||
#include "families.h" | ||
#include STRINGIFY(FAMILY/eeprom_impl.h) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
#ifdef STM32F4 | ||
#include "f4xx/entropy_handlers.h" | ||
#endif | ||
#include "families.h" | ||
#include STRINGIFY(FAMILY/entropy_handlers.h) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
#ifdef STM32F4 | ||
#include "f4xx/entropy_impl.h" | ||
#endif | ||
#include "families.h" | ||
#include STRINGIFY(FAMILY/entropy_impl.h) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
#ifdef STM32F4 | ||
#include "f4xx/exti.h" | ||
#endif | ||
#include "families.h" | ||
#include STRINGIFY(FAMILY/exti.h) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
#ifdef STM32F4 | ||
#include "f4xx/exti_handlers.h" | ||
#endif | ||
#include "families.h" | ||
#include STRINGIFY(FAMILY/exti_handlers.h) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
|
||
#ifndef __FAMILIES_H | ||
#define __FAMILIES_H | ||
|
||
#if defined STM32F4 | ||
#define FAMILY f4xx | ||
#elif defined STM32U0 | ||
#define FAMILY u0xx | ||
#elif defined STM32H7 | ||
#define FAMILY h7xx | ||
#else | ||
#error "STM32 family not recognized" | ||
#endif | ||
|
||
// Stringify macros to construct file paths dynamically | ||
#define STRINGIFY(x) STRINGIFY2(x) | ||
#define STRINGIFY2(x) #x | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
#ifdef STM32F4 | ||
#include "f4xx/gpio_impl.h" | ||
#endif | ||
#include "families.h" | ||
#include STRINGIFY(FAMILY/gpio_impl.h) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
#ifdef STM32F4 | ||
#include "f4xx/id_impl.h" | ||
#endif | ||
#include "families.h" | ||
#include STRINGIFY(FAMILY/id_impl.h) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
#ifdef STM32F4 | ||
#include "f4xx/shared_handlers.h" | ||
#endif | ||
#include "families.h" | ||
#include STRINGIFY(FAMILY/shared_handlers.h) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
#ifdef STM32F4 | ||
#include "f4xx/timer_handlers.h" | ||
#endif | ||
#include "families.h" | ||
#include STRINGIFY(FAMILY/timer_handlers.h) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
#ifdef STM32F4 | ||
#include "f4xx/timer_impl.h" | ||
#endif | ||
#include "families.h" | ||
#include STRINGIFY(FAMILY/timer_impl.h) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
|
||
|
||
#include "core_handlers.h" | ||
#include <irq_handlers.h> | ||
|
||
volatile uint8_t __core_handler_inclusion; | ||
|
||
#if uC_CORE_ENABLED | ||
|
||
/** | ||
* @name Cortex-M4 Processor Interruption and Exception Handlers | ||
*/ | ||
/**@{*/ | ||
/** | ||
* @brief This function handles Non maskable interrupt. | ||
* | ||
* Just drops to the failure state. Debug and inspect the stack. | ||
*/ | ||
void NMI_Handler(void){ | ||
die(); | ||
} | ||
|
||
/** | ||
* @brief This function handles Hard Fault interrupt. | ||
* | ||
* Just drops to the failure state. Debug and inspect the stack. | ||
*/ | ||
void HardFault_Handler(void){ | ||
die(); | ||
} | ||
|
||
/** | ||
* @brief This function handles System Service Call via SWI Instruction. | ||
* | ||
* A System Service architecture needs to be implemented? | ||
* | ||
*/ | ||
void SVC_Handler(void){ | ||
; | ||
} | ||
|
||
/** | ||
* @brief This function handles Pendable Request for System Service. | ||
* | ||
*/ | ||
void PendSV_Handler(void){ | ||
; | ||
} | ||
|
||
#endif | ||
|
||
#if uC_SYSTICK_TIMER_ENABLED | ||
|
||
/** | ||
* @brief This function handles System Tick Timer Interrupts. | ||
*/ | ||
void SysTick_Handler(void) { | ||
// HAL IncTick is only needed if we're using HAL timing primitives | ||
// (directly or indirectly). Ideally, most of those uses should | ||
// be modified to use the considerably faster EBS systick. | ||
// | ||
// Switching the STM32 HAL to use the EBS systick can probably be | ||
// done using the weak functions it provides. | ||
// | ||
// For now, keeping both running. | ||
HAL_IncTick(); | ||
#if APP_USE_CORE_SYSTICK | ||
#ifdef uC_SYSTICK_TIMER_IRQH | ||
uC_SYSTICK_TIMER_IRQH(); | ||
#endif | ||
#endif | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
|
||
|
||
#ifndef CRYPTO_HANDLERS_H | ||
#define CRYPTO_HANDLERS_H | ||
|
||
#include <hal/uc/crypto.h> | ||
|
||
|
||
#if uC_CRYPTO_ENABLED | ||
|
||
static inline void crypto_isr(void) { | ||
// Datasheet talks about an ICR register, but it does not | ||
// show up in the register maps. The MCU headers include | ||
// the register, but does not have all the bits. The bit | ||
// named is shown in the CR register drawing. | ||
// Trusting the tables in the datasheet instead of the text. | ||
//AES->ICR |= AES_ICR_CCF; | ||
AES->CR |= 0x1UL << 7; // Set AES_CR.CCF per refman pp538 | ||
|
||
uint8_t ingest_len = 16; | ||
uint8_t no_release = 0; | ||
|
||
switch (crypto_state.ctx->phase) | ||
{ | ||
case CRYPTO_CTX_PHASE_PREPKEY: | ||
if (crypto_state.ctx->profile->header_size){ | ||
crypto_set_ctx_phase(crypto_state.ctx, CRYPTO_CTX_PHASE_HEADER); | ||
} else { | ||
crypto_set_ctx_phase(crypto_state.ctx, CRYPTO_CTX_PHASE_PAYLOAD); | ||
} | ||
ingest_len = 0; | ||
AES->CR |= AES_CR_EN; | ||
break; | ||
default: | ||
break; | ||
} | ||
|
||
crypto_state.state = CRYPTO_READY; | ||
if (crypto_state.ctx->ingest_cb){ | ||
no_release = crypto_state.ctx->ingest_cb(crypto_state.ctx, ingest_len); | ||
} | ||
if (!no_release){ | ||
crypto_state.state = CRYPTO_BUSY; | ||
} | ||
} | ||
|
||
#endif | ||
#endif |
Oops, something went wrong.