WIP: Works.

But I don't like it much yet.
This commit is contained in:
Kris Kwiatkowski 2025-02-19 00:03:36 +00:00
parent e4d67cc355
commit 62fd3a825c
4 changed files with 19 additions and 13 deletions

View File

@ -1,10 +1,10 @@
all: all:
arm-none-eabi-gcc -ggdb -mcpu=Cortex-M4 -mthumb -r -Tlibpqscheme.ld -fPIC -nostartfiles -o libpqscheme_test.elf libpqscheme_test.c -Iruntime_mps2/out/an386/pack/include arm-none-eabi-gcc -ggdb -mcpu=Cortex-M4 -mthumb -Tlibpqscheme.ld -nostartfiles -o libpqscheme_test.elf libpqscheme_test.c -Iruntime_mps2/out/an386/pack/include -L/home/kris/repos/pqshield/epcc/out/armv7e-m/lib -I/home/kris/repos/pqshield/epcc/out/armv7e-m/inc -lmlkem -lsha3 -lcommon
arm-none-eabi-gcc -ggdb -mcpu=Cortex-M4 -mthumb -Truntime_mps2/out/an386/pack/lib/mps2.ld -nostartfiles -o runner.elf runner.c -Lruntime_mps2/out/an386/pack/lib -lmps2-an386_runtime -Iruntime_mps2/out/an386/pack/include arm-none-eabi-gcc -ggdb -mcpu=Cortex-M4 -mthumb -Truntime_mps2/out/an386/pack/lib/mps2.ld -nostartfiles -o runner.elf runner.c -Lruntime_mps2/out/an386/pack/lib -lmps2-an386_runtime -Iruntime_mps2/out/an386/pack/include
arm-none-eabi-ar rcs runner runner.elf arm-none-eabi-ar rcs runner runner.elf
arm-none-eabi-objcopy -O binary libpqscheme_test.elf libpqscheme_test.bin arm-none-eabi-objcopy -O binary libpqscheme_test.elf libpqscheme_test.bin
run: run:
qemu-system-arm \ qemu-system-arm \
-M mps2-an386 \ -M mps2-an386 \
@ -12,11 +12,10 @@ run:
-nographic \ -nographic \
-kernel runner.elf \ -kernel runner.elf \
-semihosting \ -semihosting \
-device loader,file=libpqscheme_test.elf,addr=0x20000000 -device loader,file=libpqscheme_test.bin,addr=0x20000000
# -S -gdb tcp::1234 # -S -gdb tcp::1234
# -monitor unix:/tmp/qemu-monitor,server,nowait # -monitor unix:/tmp/qemu-monitor,server,nowait
clean: clean:
rm -rf *.o *.a *.elf *.bin rm -rf *.o *.a *.elf *.bin
rm -rf runner rm -rf runner

View File

@ -1,23 +1,26 @@
MEMORY MEMORY
{ {
FLASH (rx) : ORIGIN = 0x00300000, LENGTH = 0x00100000 /* Runner */ RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 16K
RAM (rwx) : ORIGIN = 0x00000000, LENGTH = 16K
} }
SECTIONS SECTIONS
{ {
.magic_header : { .magic_header : ALIGN(4) {
LONG(0x88DAD0F2) /* Magic header containing */ LONG(0x88DAD0F2) /* Magic header containing */
LONG(ADDR(.text)) /* Entry point */ LONG(ADDR(.text)) /* Entry point */
} > RAM } > RAM
.text : { .text : ALIGN(4) {
*(.text) *(.text)
*(.rodata) *(.rodata)
} > RAM } > RAM
.data : { .data : ALIGN(4) {
*(.data) *(.data)
} > RAM } > RAM
.bss : ALIGN(4) {
*(.bss)
*(COMMON)
} > RAM
} }

View File

@ -1,7 +1,10 @@
#include <epcc/sha3.h>
#include <stdint.h> #include <stdint.h>
int run();
__attribute__((section(".text"))) int cryptographic_test() { __attribute__((used, section(".text"))) int cryptographic_test() {
// Run unit tests for cryptographic scheme // Run unit tests for cryptographic scheme
//while(1); // Debug loop return 7 + run();
return 7;
} }
int run() { return (int)epcc_sha3_serialized_size(); }

View File

@ -16,7 +16,8 @@ void execute_library_function() {
while ((uint32_t)ptr < RAM_END) { while ((uint32_t)ptr < RAM_END) {
if (*ptr == LIB_MAGIC) { if (*ptr == LIB_MAGIC) {
printf("Found libpqscheme_test 0x%X!\n", ptr); printf("Found libpqscheme_test 0x%X!\n", ptr);
entry_point = RAM_START + (*(ptr + 1)); entry_point = (*(ptr + 1));
printf("Calling function at 0x%X\n", entry_point);
entry_point |= 1; // Ensure thumb mod entry_point |= 1; // Ensure thumb mod
func_t test_func = (func_t)(entry_point); func_t test_func = (func_t)(entry_point);
if (test_func) { if (test_func) {