Code to allow testing on lpc1114 board.

This commit is contained in:
Ken MacKay
2014-05-03 21:49:20 -07:00
parent e1a0a9dc10
commit 57636a7bfa
3 changed files with 87 additions and 3 deletions
+23 -3
View File
@@ -1,6 +1,6 @@
import os
c, link = emk.module("c", "link")
c, link, asm, utils = emk.module("c", "link", "asm", "utils")
default_compile_flags = ["-fvisibility=hidden", "-Wall", "-Wextra", "-Wshadow", "-Werror", "-Wno-missing-field-initializers", "-Wno-unused-parameter", \
"-Wno-comment", "-Wno-unused", "-Wno-unknown-pragmas"]
@@ -63,13 +63,33 @@ def setup_avr():
def setup_arm_thumb():
global c
global link
global asm
global utils
asm.assembler = asm.GccAssembler("/cross/arm_cortex/bin/arm-none-eabi-")
c.compiler = c.GccCompiler("/cross/arm_cortex/bin/arm-none-eabi-")
link.linker = link.GccLinker("/cross/arm_cortex/bin/arm-none-eabi-")
c.flags += ["-march=armv6-m", "-mthumb", "-ffunction-sections", "-fdata-sections"]
link.local_flags += ["-march=armv6-m", "-mthumb", "-Wl,--gc-sections"]
c.flags.extend(["-mcpu=cortex-m0", "-mthumb", "-ffunction-sections", "-fdata-sections", "-fno-builtin-fprintf", "-fno-builtin-printf"])
c.defines["LPC11XX"] = 1
link.local_flags.extend(["-mcpu=cortex-m0", "-mthumb", "-nostartfiles", "-nostdlib", "-Wl,--gc-sections"])
link.local_flags.extend(["-Tflash.lds", "-L/Projects/lpc11xx/core", "/Projects/lpc11xx/core/" + emk.build_dir + "/board_cstartup.o"])
link.local_syslibs += ["gcc"]
link.depdirs += ["/Projects/lpc11xx/stdlib"]
def do_objcopy(produces, requires):
utils.call("/cross/arm_cortex/bin/arm-none-eabi-objcopy", "-O", "binary", requires[0], produces[0])
def handle_exe(path):
emk.depend(path, "/Projects/lpc11xx/core/" + emk.build_dir + "/board_cstartup.o")
emk.rule(do_objcopy, path + ".bin", path, cwd_safe=True, ex_safe=True)
emk.autobuild(path + ".bin")
link.exe_funcs.append(handle_exe)
link.strip = True
emk.recurse("/Projects/lpc11xx/core")
setup_build_dir()
+32
View File
@@ -5,6 +5,29 @@
#include <stdio.h>
#include <string.h>
#if LPC11XX
#include "/Projects/lpc11xx/peripherals/uart.h"
#include "/Projects/lpc11xx/peripherals/time.h"
static uint64_t g_rand = 88172645463325252ull;
int fake_rng(uint8_t *p_dest, unsigned p_size)
{
while(p_size)
{
g_rand ^= (g_rand << 13);
g_rand ^= (g_rand >> 7);
g_rand ^= (g_rand << 17);
unsigned l_amount = (p_size > 8 ? 8 : p_size);
memcpy(p_dest, &g_rand, l_amount);
p_size -= l_amount;
}
return 1;
}
#endif
void vli_print(uint8_t *p_vli, unsigned int p_size)
{
while(p_size)
@@ -16,6 +39,13 @@ void vli_print(uint8_t *p_vli, unsigned int p_size)
int main()
{
#if LPC11XX
uartInit(BAUD_115200);
initTime();
uECC_set_rng(&fake_rng);
#endif
int i;
uint8_t l_private1[uECC_BYTES];
@@ -32,7 +62,9 @@ int main()
for(i=0; i<256; ++i)
{
printf(".");
#if !LPC11XX
fflush(stdout);
#endif
if(!uECC_make_key(l_public1, l_private1) || !uECC_make_key(l_public2, l_private2))
{
+32
View File
@@ -5,8 +5,38 @@
#include <stdio.h>
#include <string.h>
#if LPC11XX
#include "/Projects/lpc11xx/peripherals/uart.h"
#include "/Projects/lpc11xx/peripherals/time.h"
static uint64_t g_rand = 88172645463325252ull;
int fake_rng(uint8_t *p_dest, unsigned p_size)
{
while(p_size)
{
g_rand ^= (g_rand << 13);
g_rand ^= (g_rand >> 7);
g_rand ^= (g_rand << 17);
unsigned l_amount = (p_size > 8 ? 8 : p_size);
memcpy(p_dest, &g_rand, l_amount);
p_size -= l_amount;
}
return 1;
}
#endif
int main()
{
#if LPC11XX
uartInit(BAUD_115200);
initTime();
uECC_set_rng(&fake_rng);
#endif
uint8_t l_public[uECC_BYTES*2];
uint8_t l_private[uECC_BYTES];
@@ -21,7 +51,9 @@ int main()
for(i=0; i<256; ++i)
{
printf(".");
#if !LPC11XX
fflush(stdout);
#endif
if(!uECC_make_key(l_public, l_private))
{