Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
lwc
/
compare
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Pipelines
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
04c5f18d
authored
Jul 22, 2019
by
Sebastian Renner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimizing F7 template
parent
26d6015e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
201 additions
and
8 deletions
+201
-8
templates/f7/Makefile
+3
-2
templates/f7/NIST_Makefile
+192
-0
templates/f7/Src/main.c
+5
-5
templates/f7/middleware.py
+1
-1
No files found.
templates/f7/Makefile
View file @
04c5f18d
...
@@ -20,9 +20,9 @@ TARGET = f7
...
@@ -20,9 +20,9 @@ TARGET = f7
# building variables
# building variables
######################################
######################################
# debug build?
# debug build?
DEBUG
=
1
DEBUG
=
0
# optimization
# optimization
OPT
=
-O
g
OPT
=
-O
2
#######################################
#######################################
...
@@ -130,6 +130,7 @@ endif
...
@@ -130,6 +130,7 @@ endif
# Generate dependency information
# Generate dependency information
CFLAGS
+=
-MMD
-MP
-MF
"
$
(@:%.o=%.d)"
CFLAGS
+=
-MMD
-MP
-MF
"
$
(@:%.o=%.d)"
#CFLAGS +=-std=c99 -Wextra -Wshadow
#######################################
#######################################
...
...
templates/f7/NIST_Makefile
0 → 100644
View file @
04c5f18d
##########################################################################################################################
# File automatically-generated by tool: [projectgenerator] version: [3.3.0] date: [Sun Jul 14 11:29:48 CEST 2019]
##########################################################################################################################
# ------------------------------------------------
# Generic Makefile (based on gcc)
#
# ChangeLog :
# 2017-02-10 - Several enhancements + project update mode
# 2015-07-22 - first version
# ------------------------------------------------
######################################
# target
######################################
TARGET = f7
######################################
# building variables
######################################
# debug build?
DEBUG = 0
# optimization
OPT = -O2
#######################################
# paths
#######################################
# Build path
BUILD_DIR = build
######################################
# source
######################################
# C sources
C_SOURCES = \
Src/main.c \
Src/stm32f7xx_it.c \
Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_cortex.c \
Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_gpio.c \
Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_usart.c \
Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_dma.c \
Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_rcc.c \
Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_utils.c \
Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_exti.c \
Src/system_stm32f7xx.c \
Src/RTT/SEGGER_RTT.c \
Src/RTT/SEGGER_RTT_printf.c \
$(SRC_FILES)
# ASM sources
ASM_SOURCES = \
startup_stm32f746xx.s
#######################################
# binaries
#######################################
PREFIX = arm-none-eabi-
# The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
# either it can be added to the PATH environment variable.
ifdef GCC_PATH
CC = $(GCC_PATH)/$(PREFIX)gcc
AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
CP = $(GCC_PATH)/$(PREFIX)objcopy
SZ = $(GCC_PATH)/$(PREFIX)size
else
CC = $(PREFIX)gcc
AS = $(PREFIX)gcc -x assembler-with-cpp
CP = $(PREFIX)objcopy
SZ = $(PREFIX)size
endif
HEX = $(CP) -O ihex
BIN = $(CP) -O binary -S
#######################################
# CFLAGS
#######################################
# cpu
CPU = -mcpu=cortex-m7
# fpu
FPU = -mfpu=fpv5-sp-d16
# float-abi
FLOAT-ABI = -mfloat-abi=hard
# mcu
MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
# macros for gcc
# AS defines
AS_DEFS =
# C defines
C_DEFS = \
-DUSE_FULL_LL_DRIVER \
-DUSE_HAL_DRIVER \
-DSTM32F746xx \
-DUSE_FULL_LL_DRIVER \
-DUSE_HAL_DRIVER \
-DUSE_HAL_DRIVER \
-DSTM32F746xx
# AS includes
AS_INCLUDES =
# C includes
C_INCLUDES = \
-IInc \
-IDrivers/STM32F7xx_HAL_Driver/Inc \
-IDrivers/STM32F7xx_HAL_Driver/Inc/Legacy \
-IDrivers/CMSIS/Device/ST/STM32F7xx/Include \
-IDrivers/CMSIS/Include \
# compile gcc flags
ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
ifeq ($(DEBUG), 1)
CFLAGS += -g -gdwarf-2
endif
# Generate dependency information
CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
CFLAGS +=-std=c99 -Wall -Wextra -Wshadow
LFLAGS=-lm
#######################################
# LDFLAGS
#######################################
# link script
LDSCRIPT = STM32F746ZGTx_FLASH.ld
# libraries
LIBS = -lc -lm -lnosys
LIBDIR =
LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
# default action: build all
all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
#######################################
# build the application
#######################################
# list of objects
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
vpath %.c $(sort $(dir $(C_SOURCES)))
# list of ASM program objects
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
vpath %.s $(sort $(dir $(ASM_SOURCES)))
$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
$(AS) -c $(CFLAGS) $< -o $@
$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
$(CC) $(OBJECTS) $(LDFLAGS) -o $@
$(SZ) $@
$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
$(HEX) $< $@
$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
$(BIN) $< $@
$(BUILD_DIR):
mkdir $@
#######################################
# clean up
#######################################
clean:
-rm -fR $(BUILD_DIR)
#######################################
# dependencies
#######################################
-include $(wildcard $(BUILD_DIR)/*.d)
# *** EOF ***
templates/f7/Src/main.c
View file @
04c5f18d
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
#include "api.h"
#include "api.h"
#include <main.h>
#include <main.h>
//#define DEBUG
//#define DEBUG
#define MAX_LEN 1
4
00
#define MAX_LEN 100
#ifdef DEBUG
#ifdef DEBUG
#include "SEGGER_RTT.h"
#include "SEGGER_RTT.h"
...
@@ -213,9 +213,9 @@ int main(void)
...
@@ -213,9 +213,9 @@ int main(void)
dbg_printf
(
"p: "
);
for
(
int
i
=
0
;
i
<
nplen
;
i
++
)
dbg_printf
(
"%02x"
,
npub
[
i
]);
dbg_printf
(
"
\n
"
);
dbg_printf
(
"p: "
);
for
(
int
i
=
0
;
i
<
nplen
;
i
++
)
dbg_printf
(
"%02x"
,
npub
[
i
]);
dbg_printf
(
"
\n
"
);
dbg_printf
(
"k: "
);
for
(
int
i
=
0
;
i
<
klen
;
i
++
)
dbg_printf
(
"%02x"
,
k
[
i
]);
dbg_printf
(
"
\n
"
);
dbg_printf
(
"k: "
);
for
(
int
i
=
0
;
i
<
klen
;
i
++
)
dbg_printf
(
"%02x"
,
k
[
i
]);
dbg_printf
(
"
\n
"
);
#endif
#endif
LL_GPIO_
TogglePin
(
GPIOB
,
LL_GPIO_PIN_7
);
LL_GPIO_
ResetOutputPin
(
GPIOD
,
LL_GPIO_PIN_7
);
res
=
crypto_aead_encrypt
(
c
,
&
clen
,
m
,
mlen
,
ad
,
adlen
,
nsec
,
npub
,
k
);
res
=
crypto_aead_encrypt
(
c
,
&
clen
,
m
,
mlen
,
ad
,
adlen
,
nsec
,
npub
,
k
);
LL_GPIO_
TogglePin
(
GPIOB
,
LL_GPIO_PIN_7
);
LL_GPIO_
SetOutputPin
(
GPIOD
,
LL_GPIO_PIN_7
);
break
;
break
;
case
'd'
:
case
'd'
:
...
@@ -226,9 +226,9 @@ int main(void)
...
@@ -226,9 +226,9 @@ int main(void)
dbg_printf
(
"k: "
);
for
(
int
i
=
0
;
i
<
klen
;
i
++
)
dbg_printf
(
"%02x"
,
k
[
i
]);
dbg_printf
(
"
\n
"
);
dbg_printf
(
"k: "
);
for
(
int
i
=
0
;
i
<
klen
;
i
++
)
dbg_printf
(
"%02x"
,
k
[
i
]);
dbg_printf
(
"
\n
"
);
#endif
#endif
LL_GPIO_
TogglePin
(
GPIOB
,
LL_GPIO_PIN_12
);
LL_GPIO_
ResetOutputPin
(
GPIOD
,
LL_GPIO_PIN_7
);
res
=
crypto_aead_decrypt
(
m
,
&
mlen
,
nsec
,
c
,
clen
,
ad
,
adlen
,
npub
,
k
);
res
=
crypto_aead_decrypt
(
m
,
&
mlen
,
nsec
,
c
,
clen
,
ad
,
adlen
,
npub
,
k
);
LL_GPIO_
TogglePin
(
GPIOB
,
LL_GPIO_PIN_12
);
LL_GPIO_
SetOutputPin
(
GPIOD
,
LL_GPIO_PIN_7
);
break
;
break
;
default:
default:
...
...
templates/f7/middleware.py
View file @
04c5f18d
...
@@ -55,7 +55,6 @@ def submit(channel, action, data):
...
@@ -55,7 +55,6 @@ def submit(channel, action, data):
h
=
struct
.
pack
(
"<BI"
,
ord
(
action
),
len
(
data
))
h
=
struct
.
pack
(
"<BI"
,
ord
(
action
),
len
(
data
))
write
(
channel
,
h
)
write
(
channel
,
h
)
write
(
channel
,
data
)
write
(
channel
,
data
)
time
.
sleep
(
0.1
)
def
main
(
argv
):
def
main
(
argv
):
if
DBG
:
if
DBG
:
...
@@ -78,6 +77,7 @@ def main(argv):
...
@@ -78,6 +77,7 @@ def main(argv):
elif
action
==
b
'C'
or
action
==
b
'M'
or
action
==
b
'A'
or
action
==
b
'K'
or
action
==
b
'S'
or
action
==
b
'P'
:
elif
action
==
b
'C'
or
action
==
b
'M'
or
action
==
b
'A'
or
action
==
b
'K'
or
action
==
b
'S'
or
action
==
b
'P'
:
write
(
'ser'
,
action
)
write
(
'ser'
,
action
)
time
.
sleep
(
0.1
)
data
=
obtain
(
'ser'
)
data
=
obtain
(
'ser'
)
if
DBG
:
if
DBG
:
print
(
"Obtained following data from serial:
%
s
\n
"
%
data
,
file
=
sys
.
stderr
)
print
(
"Obtained following data from serial:
%
s
\n
"
%
data
,
file
=
sys
.
stderr
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment