Przeglądaj źródła

Create STM32disco platform

wb55
Henry Case 1 rok temu
rodzic
commit
ef833b8b37
6 zmienionych plików z 41 dodań i 27 usunięć
  1. +12
    -24
      CMakeLists.txt
  2. +16
    -0
      platform/stm32disco/CMakeLists.txt
  3. +0
    -0
      platform/stm32disco/stm32f405x6.ld
  4. +7
    -2
      src/common/hal.h
  5. +5
    -1
      src/common/randombytes.c
  6. +1
    -0
      toolchain.cmake

+ 12
- 24
CMakeLists.txt Wyświetl plik

@@ -8,17 +8,22 @@ set(CMAKE_VERBOSE_MAKEFILE ON)
set(UPQCL_LIBRARY_VER ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
set(CMAKE_C_STANDARD 99)

if(PLATFORM STREQUAL "stm32disco")
include_directories(${PROJECT_SOURCE_DIR}/platform/stm32disco)
endif()

# Global configuration
string(APPEND CMAKE_C_FLAGS "-Os ")
string(APPEND CMAKE_C_FLAGS "-Wno-ignored-qualifiers ")
string(APPEND CMAKE_C_FLAGS "-Wall ")
string(APPEND CMAKE_C_FLAGS "-Werror ")
string(APPEND CMAKE_C_FLAGS "-Wextra ")
string(APPEND CMAKE_C_FLAGS "-Wpedantic ")
#string(APPEND CMAKE_C_FLAGS "-Wextra ")
#string(APPEND CMAKE_C_FLAGS "-Wpedantic ")
string(APPEND CMAKE_C_FLAGS "-Wshadow ")
string(APPEND CMAKE_C_FLAGS "-Wno-variadic-macros ")
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 "-Wvla ")
string(APPEND CMAKE_C_FLAGS "-Wredundant-decls ")
@@ -31,7 +36,7 @@ set(uEXAMPLE_SRC
${PROJECT_SOURCE_DIR}/src/common/crypto_hashblocks_sha512_inner32.s
${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/common/hal-stm32f4.c
${PROJECT_SOURCE_DIR}/src/saber/cbd.c
${PROJECT_SOURCE_DIR}/src/saber/kem.c
${PROJECT_SOURCE_DIR}/src/saber/mul.S
@@ -47,9 +52,10 @@ set(uEXAMPLE_SRC
add_library(
uexample_obj OBJECT
${uEXAMPLE_SRC})

target_include_directories(
uexample_obj PRIVATE
${PROJECT_SOURCE_DIR}/3rd/libopencm3/include
#${PROJECT_SOURCE_DIR}/3rd/libopencm3/include
${PROJECT_SOURCE_DIR}/src/common
${PROJECT_SOURCE_DIR}/src/sabre)

@@ -61,24 +67,6 @@ add_executable(

target_include_directories(
uexample_test PRIVATE
${PROJECT_SOURCE_DIR}/3rd/libopencm3/include
#${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")

+ 16
- 0
platform/stm32disco/CMakeLists.txt Wyświetl plik

@@ -0,0 +1,16 @@
target_link_libraries(
uexample_test PRIVATE
--static -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group
-T${PROJECT_SOURCE_DIR}/platform/stm32disco/stm32f405x6.ld
-nostartfiles -Wl,--gc-sections
cmsis)

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")

src/stm32f405x6.ld → platform/stm32disco/stm32f405x6.ld Wyświetl plik


+ 7
- 2
src/common/hal.h Wyświetl plik

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

#ifndef HAL_H
#define HAL_H
@@ -8,7 +9,11 @@ enum clock_mode {
CLOCK_BENCHMARK
};

void hal_setup(const enum clock_mode clock);
void hal_send_str(const char* in);
static void hal_setup(const enum clock_mode clock) {
UNUSED(clock);
}
static void hal_send_str(const char* in) {
UNUSED(in);
}

#endif

+ 5
- 1
src/common/randombytes.c Wyświetl plik

@@ -1,5 +1,5 @@
#include <stdint.h>
#include <libopencm3/stm32/rng.h>
//#include <libopencm3/stm32/rng.h>
#include "randombytes.h"

//TODO Maybe we do not want to use the hardware RNG for all randomness, but instead only read a seed and then expand that using fips202.
@@ -14,19 +14,23 @@ int randombytes(uint8_t *obuf, size_t len)

while (len > 4)
{
/*
random.asint = rng_get_random_blocking();
*obuf++ = random.aschar[0];
*obuf++ = random.aschar[1];
*obuf++ = random.aschar[2];
*obuf++ = random.aschar[3];
len -= 4;
*/
}
if (len > 0)
{
/*
for (random.asint = rng_get_random_blocking(); len > 0; --len)
{
*obuf++ = random.aschar[len - 1];
}
*/
}

return 0;


+ 1
- 0
toolchain.cmake Wyświetl plik

@@ -13,3 +13,4 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(PLATFORM "stm32disco")

Ładowanie…
Anuluj
Zapisz