Compare commits

...

2 Commits

Author SHA1 Message Date
e4a57ac77b WIP 2023-02-07 14:52:47 +00:00
ef833b8b37 Create STM32disco platform 2023-02-07 14:12:20 +00:00
8 changed files with 48 additions and 38 deletions

View File

@ -13,12 +13,13 @@ string(APPEND CMAKE_C_FLAGS "-Os ")
string(APPEND CMAKE_C_FLAGS "-Wno-ignored-qualifiers ") string(APPEND CMAKE_C_FLAGS "-Wno-ignored-qualifiers ")
string(APPEND CMAKE_C_FLAGS "-Wall ") string(APPEND CMAKE_C_FLAGS "-Wall ")
string(APPEND CMAKE_C_FLAGS "-Werror ") string(APPEND CMAKE_C_FLAGS "-Werror ")
string(APPEND CMAKE_C_FLAGS "-Wextra ") #string(APPEND CMAKE_C_FLAGS "-Wextra ")
string(APPEND CMAKE_C_FLAGS "-Wpedantic ") #string(APPEND CMAKE_C_FLAGS "-Wpedantic ")
string(APPEND CMAKE_C_FLAGS "-Wshadow ") string(APPEND CMAKE_C_FLAGS "-Wshadow ")
string(APPEND CMAKE_C_FLAGS "-Wno-variadic-macros ") string(APPEND CMAKE_C_FLAGS "-Wno-variadic-macros ")
string(APPEND CMAKE_C_FLAGS "-Wno-undef ") string(APPEND CMAKE_C_FLAGS "-Wno-undef ")
string(APPEND CMAKE_C_FLAGS "-Wunused-result ") string(APPEND CMAKE_C_FLAGS "-Wno-unused ")
#string(APPEND CMAKE_C_FLAGS "-Wunused-result ")
string(APPEND CMAKE_C_FLAGS "-Wmissing-prototypes ") string(APPEND CMAKE_C_FLAGS "-Wmissing-prototypes ")
string(APPEND CMAKE_C_FLAGS "-Wvla ") string(APPEND CMAKE_C_FLAGS "-Wvla ")
string(APPEND CMAKE_C_FLAGS "-Wredundant-decls ") string(APPEND CMAKE_C_FLAGS "-Wredundant-decls ")
@ -30,8 +31,6 @@ set(uEXAMPLE_SRC
${PROJECT_SOURCE_DIR}/src/common/keccakf1600.S ${PROJECT_SOURCE_DIR}/src/common/keccakf1600.S
${PROJECT_SOURCE_DIR}/src/common/crypto_hashblocks_sha512_inner32.s ${PROJECT_SOURCE_DIR}/src/common/crypto_hashblocks_sha512_inner32.s
${PROJECT_SOURCE_DIR}/src/common/crypto_hashblocks_sha512.c ${PROJECT_SOURCE_DIR}/src/common/crypto_hashblocks_sha512.c
${PROJECT_SOURCE_DIR}/src/common/randombytes.c
${PROJECT_SOURCE_DIR}/src/common/hal-stm32f4.c
${PROJECT_SOURCE_DIR}/src/saber/cbd.c ${PROJECT_SOURCE_DIR}/src/saber/cbd.c
${PROJECT_SOURCE_DIR}/src/saber/kem.c ${PROJECT_SOURCE_DIR}/src/saber/kem.c
${PROJECT_SOURCE_DIR}/src/saber/mul.S ${PROJECT_SOURCE_DIR}/src/saber/mul.S
@ -45,40 +44,15 @@ set(uEXAMPLE_SRC
${PROJECT_SOURCE_DIR}/src/saber/verify.c) ${PROJECT_SOURCE_DIR}/src/saber/verify.c)
add_library( add_library(
uexample_obj OBJECT example STATIC
${uEXAMPLE_SRC}) ${uEXAMPLE_SRC})
target_include_directories( target_include_directories(
uexample_obj PRIVATE example PRIVATE
${PROJECT_SOURCE_DIR}/3rd/libopencm3/include #${PROJECT_SOURCE_DIR}/3rd/libopencm3/include
${PROJECT_SOURCE_DIR}/src/common ${PROJECT_SOURCE_DIR}/src/common
${PROJECT_SOURCE_DIR}/src/sabre) ${PROJECT_SOURCE_DIR}/src/sabre)
add_executable( if(PLATFORM STREQUAL "stm32disco")
uexample_test add_subdirectory(${PROJECT_SOURCE_DIR}/platform/stm32disco)
${uEXAMPLE_SRC} endif()
${PROJECT_SOURCE_DIR}/src/test.c
)
target_include_directories(
uexample_test PRIVATE
${PROJECT_SOURCE_DIR}/3rd/libopencm3/include
${PROJECT_SOURCE_DIR}/src/common
${PROJECT_SOURCE_DIR}/src/saber)
target_link_libraries(
uexample_test PRIVATE
--static -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group
-T${PROJECT_SOURCE_DIR}/src/stm32f405x6.ld
-nostartfiles -Wl,--gc-sections
-L${PROJECT_SOURCE_DIR}/3rd/libopencm3/lib -lm -lopencm3_stm32f4
)
add_custom_command(
TARGET uexample_test POST_BUILD
COMMAND ${OBJCOPY} -Obinary uexample_test uexample_test.bin
COMMENT "Invoking: objcopy")
add_custom_target(
flash
COMMAND st-flash write uexample_test.bin 0x8000000
COMMENT "Flashing device")

View File

@ -1,4 +1,5 @@
#include <stdint.h> #include <stdint.h>
#define UNUSED(x) (void)(x)
#ifndef HAL_H #ifndef HAL_H
#define HAL_H #define HAL_H

View File

@ -0,0 +1,33 @@
add_executable(
uexample_test
${PROJECT_SOURCE_DIR}/test/test.c
${PROJECT_SOURCE_DIR}/platform/${PLATFORM}/hal.c
${PROJECT_SOURCE_DIR}/platform/${PLATFORM}/randombytes.c
)
target_include_directories(
uexample_test PRIVATE
#${PROJECT_SOURCE_DIR}/3rd/libopencm3/include
${PROJECT_SOURCE_DIR}/src/common
${PROJECT_SOURCE_DIR}/src/saber
${PROJECT_SOURCE_DIR}/platform
${PROJECT_SOURCE_DIR}/platform/${PLATFORM}
${PROJECT_SOURCE_DIR}/${PLATFORM_INC})
target_link_libraries(
uexample_test PRIVATE
example
--static -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group
-T${PROJECT_SOURCE_DIR}/platform/stm32disco/stm32f405x6.ld
-nostartfiles -Wl,--gc-sections
-L${PROJECT_SOURCE_DIR}/3rd/libopencm3/lib -lm -lopencm3_stm32f4)
add_custom_command(
TARGET uexample_test POST_BUILD
COMMAND ${OBJCOPY} -Obinary uexample_test uexample_test.bin
COMMENT "Invoking: objcopy")
add_custom_target(
flash
COMMAND st-flash write uexample_test.bin 0x8000000
COMMENT "Flashing device")

View File

@ -13,3 +13,5 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(PLATFORM "stm32disco")
set(PLATFORM_INC "3rd/libopencm3/include")

View File

@ -89,7 +89,7 @@ int main(void)
for(i=0;i<10;i++) for(i=0;i<10;i++)
hal_send_str("=========================="); hal_send_str("==========================");
test_keys(); test_keys();
hal_send_str("# That's all folks!"); hal_send_str("## That's all folks! #");
while(1); while(1);