Added support for the Rowley CrossWorks for ARM IDE. Added new "WOLFSSL_ROWLEY_ARM" setting define. Added a sample solution (wolfssl.hzp) for building the WolfSSL library and sample test/benchmark applications. The sample applications are written for the Freescale Kinetis K64, but easily be customized for any Kinetis or further extended to support other ARM micro-controllers.

This commit is contained in:
David Garske 2015-10-06 10:45:46 -07:00
parent 3dda2965bd
commit 16ba3138a1
16 changed files with 1131 additions and 5 deletions

View File

@ -0,0 +1,29 @@
<!DOCTYPE Linker_Placement_File>
<Root name="Flash Section Placement">
<MemorySegment name="$(FLASH_NAME:FLASH)">
<ProgramSection alignment="4" load="Yes" name=".vectors" inputsections="KEEP(*(.vectors .vectors.*))" start="$(FLASH_START:)" />
<ProgramSection alignment="4" load="Yes" name=".flashconf" inputsections="KEEP(*(.flashconf .flashconf.*))" start="$(FLASH_START:)+0x400" size="0xF"/>
<ProgramSection alignment="4" load="Yes" name=".init" />
<ProgramSection alignment="4" load="Yes" name=".init_rodata" />
<ProgramSection alignment="4" load="Yes" name=".text" />
<ProgramSection alignment="4" load="Yes" name=".dtors" />
<ProgramSection alignment="4" load="Yes" name=".ctors" />
<ProgramSection alignment="4" load="Yes" name=".rodata" />
<ProgramSection alignment="4" load="Yes" name=".ARM.exidx" address_symbol="__exidx_start" end_symbol="__exidx_end" />
<ProgramSection alignment="4" load="Yes" runin=".fast_run" name=".fast" />
<ProgramSection alignment="4" load="Yes" runin=".data_run" name=".data" />
<ProgramSection alignment="4" load="Yes" runin=".tdata_run" name=".tdata" />
</MemorySegment>
<MemorySegment name="$(RAM_NAME:RAM);SRAM">
<ProgramSection alignment="4" load="No" name=".vectors_ram" start="$(RAM_START:$(SRAM_START:))" />
<ProgramSection alignment="4" load="No" name=".fast_run" />
<ProgramSection alignment="4" load="No" name=".data_run" />
<ProgramSection alignment="4" load="No" name=".tdata_run" />
<ProgramSection alignment="4" load="No" name=".bss" />
<ProgramSection alignment="4" load="No" name=".tbss" />
<ProgramSection alignment="4" load="No" name=".non_init" />
<ProgramSection alignment="4" size="__HEAPSIZE__" load="No" name=".heap" />
<ProgramSection alignment="8" size="__STACKSIZE__" load="No" name=".stack" />
<ProgramSection alignment="8" size="__STACKSIZE_PROCESS__" load="No" name=".stack_process" />
</MemorySegment>
</Root>

View File

@ -0,0 +1,11 @@
<!DOCTYPE Board_Memory_Definition_File>
<Root name="Kinetis">
<MemorySegment size="0x80000" access="ReadOnly" start="0x00000000" name="FLASH" />
<MemorySegment size="0x80000/2" access="Read/Write" start="0x00000000" name="FLASH_L" />
<MemorySegment size="0x80000/2" access="Read/Write" start="0x00000000+0x80000/2" name="FLASH_H" />
<MemorySegment size="0x20000" access="Read/Write" start="0x1fff0000" name="SRAM" />
<MemorySegment size="0x10000" access="Read/Write" start="0x1fff0000" name="SRAM_L" />
<MemorySegment size="0x10000" access="Read/Write" start="0x20000000" name="SRAM_H" />
<MemorySegment size="0x100000" access="Read/Write" start="0x40000000" name="PERIPHERALS" />
<MemorySegment size="0x100000" access="Read/Write" start="0xE0000000" name="PPB" />
</Root>

View File

@ -0,0 +1,45 @@
# Rowley CrossWorks ARM Project for wolfSSL and wolfCrypt
This directory contains a CrossWorks solution named wolfssl.hzp.
Inside are three projects:
1. libwolfssl:
This generates a library file named "libwolfssl_ARM_Debug/libwolfssl_v7em_t_le_eabi.a"
2. benchmark:
This is a sample benchmark application. It runs the "benchmark_test" suite repeatedly until a failure occurs.
3. test:
This is a sample test application. It runs "wolfcrypt_test" suite suite repeatedly until a failure occurs.
# Prerequisits
You will need to install the "Freescale Kinetis CPU Support Package" in the
Rowley Package Manager under Tools -> Pacakge Manager.
# Harware Support
All hardware functions are defined in `kinetis_hw.c` and are currently setup for a Freescale Kinetis K64 Coretx-M4 microcontroller. This file can be customized to work with other Kinetis microcontrollers by editing the top part of the file. Testing for this project was done with the Freescale Kinetis `MK64FN1M0xxx12` using the `TWR-K64F120M`.
To create support for a new ARM microcontroller the functions in `hw.h` will need to be implemented.
Also you will need to configure the ARM Architecture and ARM Core Type in the "Solution Properties" -> "ARM".
Also the "Target Processor" in each of the projects ("Project Properties" -> "Target Processor")
## Hardware Crypto Acceleration
To enable Freescale MMCAU:
1. [Download the MMCAU library](http://www.freescale.com/products/arm-processors/kinetis-cortex-m/k-series/k7x-glcd-mcus/crypto-acceleration-unit-cau-and-mmcau-software-library:CAUAP).
2. Copy the `lib_mmcau.a` and `cau_api.h` files into the project.
3. Add `-L $(ProjectDir) -l lib_mmcau.a` to project "Additional Linker Options" OR goto "Build Configuration" and check "MMCAU".
4. Enable the "FREESCALE_MMCAU" define in "user_settings.h" and make sure its value is 1.
# Project Files
* `arm_startup.c`: Handles startup from `reset_handler`. Disabled watchdog, initializes sections, initializes heap, starts harware and starts main.
* `benchmark_main.c`: The main function entrypoint for benchmark application.
* `hw.h`: The hardware API interface. These hardware interface functions are required for all platforms.
* `kinetis_hw.c`: The most basic hardware implementation required for Kinetis.
* `test_main.c`: The main function entrypoint for test application.
* `user_libc.c`: Defines stubs for functions required by libc. It also wraps hardware functions for UART, RTC and Random Number Generator (RNG).
* `user_settings.h`: This is the custom user configuration file for WolfSSL.

View File

@ -0,0 +1,198 @@
/* arm_startup.c
*
* Copyright (C) 2006-2015 wolfSSL Inc.
*
* This file is part of wolfSSL. (formerly known as CyaSSL)
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#include "hw.h"
#include <stdio.h>
// Memory initialization
extern uint32_t __data_load_start__[];
extern uint32_t __data_start__[];
extern uint32_t __data_end__[];
extern uint32_t __bss_start__[];
extern uint32_t __bss_end__[];
extern uint32_t __fast_load_start__[];
extern uint32_t __fast_start__[];
extern uint32_t __fast_end__[];
extern uint32_t __stack_process_end__[];
extern uint32_t __heap_start__[];
extern uint32_t __heap_end__[];
// Copy memory: src=Source, dst_beg=Destination Begin, dst_end=Destination End
void memcpy32(uint32_t* src, uint32_t* dst_beg, uint32_t* dst_end)
{
while (dst_beg < dst_end) {
*dst_beg++ = *src++;
}
}
// Zero address in range
void meminit32(uint32_t* start, uint32_t* end)
{
while (start < end) {
*start++ = 0;
}
}
// Entry Point
void reset_handler(void)
{
// Disable Watchdog
hw_watchdog_disable();
// Init sections
memcpy32(__data_load_start__, __data_start__, __data_end__);
meminit32(__bss_start__, __bss_end__);
memcpy32(__fast_load_start__, __fast_start__, __fast_end__);
// Init heap
__heap_start__[0] = 0;
__heap_start__[1] = ((uint32_t)__heap_end__ - (uint32_t)__heap_start__);
// Init hardware
hw_init();
// Start main
extern void main(void);
main();
// Application has ended, so busy wait
while(1);
}
// Vector Exception/Interrupt Handlers
static void Default_Handler(void)
{
}
void HardFault_HandlerC( uint32_t *hardfault_args )
{
/* These are volatile to try and prevent the compiler/linker optimizing them
away as the variables never actually get used. If the debugger won't show the
values of the variables, make them global my moving their declaration outside
of this function. */
volatile uint32_t stacked_r0;
volatile uint32_t stacked_r1;
volatile uint32_t stacked_r2;
volatile uint32_t stacked_r3;
volatile uint32_t stacked_r12;
volatile uint32_t stacked_lr;
volatile uint32_t stacked_pc;
volatile uint32_t stacked_psr;
volatile uint32_t _CFSR;
volatile uint32_t _HFSR;
volatile uint32_t _DFSR;
volatile uint32_t _AFSR;
volatile uint32_t _BFAR;
volatile uint32_t _MMAR;
stacked_r0 = ((uint32_t)hardfault_args[0]);
stacked_r1 = ((uint32_t)hardfault_args[1]);
stacked_r2 = ((uint32_t)hardfault_args[2]);
stacked_r3 = ((uint32_t)hardfault_args[3]);
stacked_r12 = ((uint32_t)hardfault_args[4]);
stacked_lr = ((uint32_t)hardfault_args[5]);
stacked_pc = ((uint32_t)hardfault_args[6]);
stacked_psr = ((uint32_t)hardfault_args[7]);
// Configurable Fault Status Register
// Consists of MMSR, BFSR and UFSR
_CFSR = (*((volatile uint32_t *)(0xE000ED28)));
// Hard Fault Status Register
_HFSR = (*((volatile uint32_t *)(0xE000ED2C)));
// Debug Fault Status Register
_DFSR = (*((volatile uint32_t *)(0xE000ED30)));
// Auxiliary Fault Status Register
_AFSR = (*((volatile uint32_t *)(0xE000ED3C)));
// Read the Fault Address Registers. These may not contain valid values.
// Check BFARVALID/MMARVALID to see if they are valid values
// MemManage Fault Address Register
_MMAR = (*((volatile uint32_t *)(0xE000ED34)));
// Bus Fault Address Register
_BFAR = (*((volatile uint32_t *)(0xE000ED38)));
printf ("\n\nHard fault handler (all numbers in hex):\n");
printf ("R0 = %x\n", stacked_r0);
printf ("R1 = %x\n", stacked_r1);
printf ("R2 = %x\n", stacked_r2);
printf ("R3 = %x\n", stacked_r3);
printf ("R12 = %x\n", stacked_r12);
printf ("LR [R14] = %x subroutine call return address\n", stacked_lr);
printf ("PC [R15] = %x program counter\n", stacked_pc);
printf ("PSR = %x\n", stacked_psr);
printf ("CFSR = %x\n", _CFSR);
printf ("HFSR = %x\n", _HFSR);
printf ("DFSR = %x\n", _DFSR);
printf ("AFSR = %x\n", _AFSR);
printf ("MMAR = %x\n", _MMAR);
printf ("BFAR = %x\n", _BFAR);
// Break into the debugger
__asm("BKPT #0\n");
}
__attribute__( ( naked ) )
void HardFault_Handler(void)
{
__asm volatile
(
" tst lr, #4 \n"
" ite eq \n"
" mrseq r0, msp \n"
" mrsne r0, psp \n"
" ldr r1, [r0, #24] \n"
" ldr r2, handler2_address_const \n"
" bx r2 \n"
" handler2_address_const: .word HardFault_HandlerC \n"
);
}
// Vectors
typedef void (*vector_entry)(void);
const vector_entry vectors[] __attribute__ ((section(".vectors"),used)) =
{
/* Interrupt Vector Table Function Pointers */
// Address Vector IRQ Source module Source description
(vector_entry)__stack_process_end__, // ARM core Initial Supervisor SP
reset_handler, // 0x0000_0004 1 - ARM core Initial Program Counter
Default_Handler, // 0x0000_0008 2 - ARM core Non-maskable Interrupt (NMI)
HardFault_Handler, // 0x0000_000C 3 - ARM core Hard Fault
Default_Handler, // 0x0000_0010 4 -
HardFault_Handler, // 0x0000_0014 5 - ARM core Bus Fault
HardFault_Handler, // 0x0000_0018 6 - ARM core Usage Fault
Default_Handler, // 0x0000_001C 7 -
Default_Handler, // 0x0000_0020 8 -
Default_Handler, // 0x0000_0024 9 -
Default_Handler, // 0x0000_0028 10 -
Default_Handler, // 0x0000_002C 11 - ARM core Supervisor call (SVCall)
Default_Handler, // 0x0000_0030 12 - ARM core Debug Monitor
Default_Handler, // 0x0000_0034 13 -
Default_Handler, // 0x0000_0038 14 - ARM core Pendable request for system service (PendableSrvReq)
Default_Handler, // 0x0000_003C 15 - ARM core System tick timer (SysTick)
// Add specific driver interrupt handlers below
};

View File

@ -0,0 +1,69 @@
/* benchmark_main.c
*
* Copyright (C) 2006-2015 wolfSSL Inc.
*
* This file is part of wolfSSL. (formerly known as CyaSSL)
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <wolfssl/wolfcrypt/settings.h>
#include <stdio.h>
typedef struct func_args {
int argc;
char** argv;
int return_code;
} func_args;
static func_args args = { 0 } ;
extern double current_time(int reset) ;
extern int benchmark_test(void *args) ;
void main(void)
{
int test_num = 0;
do
{
printf("\nBenchmark Test %d:\n", test_num);
benchmark_test(&args);
printf("Benchmark Test %d: Return code %d\n", test_num, args.return_code);
test_num++;
} while(args.return_code == 0);
}
/*
SAMPLE OUTPUT: Freescale K64 running at 96MHz with no MMCAU:
Benchmark Test 1:
AES 25 kB took 0.073 seconds, 0.334 MB/s
ARC4 25 kB took 0.033 seconds, 0.740 MB/s
RABBIT 25 kB took 0.027 seconds, 0.904 MB/s
3DES 25 kB took 0.375 seconds, 0.065 MB/s
MD5 25 kB took 0.016 seconds, 1.526 MB/s
SHA 25 kB took 0.044 seconds, 0.555 MB/s
SHA-256 25 kB took 0.119 seconds, 0.205 MB/s
RSA 1024 encryption took 91.000 milliseconds, avg over 1 iterations
RSA 1024 decryption took 573.000 milliseconds, avg over 1 iterations
DH 1024 key generation 253.000 milliseconds, avg over 1 iterations
DH 1024 key agreement 311.000 milliseconds, avg over 1 iterations
Benchmark Test 1: Return code 0
*/

View File

@ -0,0 +1,13 @@
#pragma once
#include <__cross_studio_io.h>
#include <__libc.h>
#include <stdint.h>
// Generic HW API
void hw_init(void);
uint32_t hw_get_time_sec(void);
uint32_t hw_get_time_msec(void);
void hw_uart_printchar(int c);
void hw_watchdog_disable(void);
int hw_rand(void);

View File

@ -0,0 +1,15 @@
# vim:ft=automake
# included from Top Level Makefile.am
# All paths should be given relative to the root
EXTRA_DIST+= IDE/ROWLEY-CROSSWORKS-ARM/arm_startup.c
EXTRA_DIST+= IDE/ROWLEY-CROSSWORKS-ARM/benchmark_main.c
EXTRA_DIST+= IDE/ROWLEY-CROSSWORKS-ARM/hw.h
EXTRA_DIST+= IDE/ROWLEY-CROSSWORKS-ARM/kinetis_hw.c
EXTRA_DIST+= IDE/ROWLEY-CROSSWORKS-ARM/Kinetis_MemoryMap.xml
EXTRA_DIST+= IDE/ROWLEY-CROSSWORKS-ARM/Kinetis_FlashPlacement.xml
EXTRA_DIST+= IDE/ROWLEY-CROSSWORKS-ARM/README.md
EXTRA_DIST+= IDE/ROWLEY-CROSSWORKS-ARM/test_main.c
EXTRA_DIST+= IDE/ROWLEY-CROSSWORKS-ARM/user_lib.c
EXTRA_DIST+= IDE/ROWLEY-CROSSWORKS-ARM/user_settings.h
EXTRA_DIST+= IDE/ROWLEY-CROSSWORKS-ARM/wolfssl.hzp

View File

@ -0,0 +1,213 @@
/* kinetis_hw.c
*
* Copyright (C) 2006-2015 wolfSSL Inc.
*
* This file is part of wolfSSL. (formerly known as CyaSSL)
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#include "hw.h"
#if defined(FREESCALE) && defined(K_SERIES)
/**********************************************
* NOTE: Customize for actual hardware
**********************************************/
// CPU include for Rowley CrossWorks packages
// $(TargetsDir) location:
// On Mac OS/X: Users/USERNAME/Library/Rowley Associates Limited/CrossWorks for ARM/packages/targets/
// On Windows: C:/Users/USERNAME/Application Data/Local/Rowley Associates Limited/CrossWorks for ARM/packages/targets/
#include <MK64F12.h> // Located in $(TargetsDir)/Kinetis/CMSIS/
// System clock
#define SYS_CLK_KHZ 96000ul /* Core system clock in KHz */
#define SYS_CLK_DRS MCG_C4_DRST_DRS(0x03) /* DRS 0=24MHz, 1=48MHz, 2=72MHz, 3=96MHz */
#define SYS_CLK_DMX MCG_C4_DMX32_MASK /* 0=Disable DMX32 (lower actual speed), MCG_C4_DMX32_MASK=Enable DMX32 */
#define SYS_CLK_DIV 1 /* System clock divisor */
#define BUS_CLK_DIV 2 /* Bus clock divisor */
#define BUS_CLK_KHZ (SYS_CLK_KHZ/BUS_CLK_DIV) /* Helper to calculate bus speed for UART */
#define FLASH_CLK_DIV 4 /* Flash clock divisor */
// UART TX Port, Pin, Mux and Baud
#define UART_PORT UART5 /* UART Port */
#define UART_TX_PORT PORTE /* UART TX Port */
#define UART_TX_PIN 8 /* UART TX Pin */
#define UART_TX_MUX 0x3 /* Kinetis UART pin mux */
#define UART_BAUD 115200 /* UART Baud Rate */
/* Note: You will also need to update the UART clock gate in hw_uart_init (SIM_SCGC1_UART5_MASK) */
/* Note: TWR-K60 is UART3, PTC17 */
/***********************************************/
// Private functions
static void hw_mcg_init(void)
{
/* Adjust clock dividers (core/system=div/1, bus=div/2, flex bus=div/2, flash=div/4) */
SIM->CLKDIV1 = SIM_CLKDIV1_OUTDIV1(SYS_CLK_DIV-1) | SIM_CLKDIV1_OUTDIV2(BUS_CLK_DIV-1) |
SIM_CLKDIV1_OUTDIV3(BUS_CLK_DIV-1) | SIM_CLKDIV1_OUTDIV4(FLASH_CLK_DIV-1);
/* Configure FEI internal clock speed */
MCG->C4 = (SYS_CLK_DMX | SYS_CLK_DRS);
while((MCG->C4 & (MCG_C4_DRST_DRS_MASK | MCG_C4_DMX32_MASK)) != (SYS_CLK_DMX | SYS_CLK_DRS));
}
static void hw_gpio_init(void)
{
/* Enable clocks to all GPIO ports */
SIM->SCGC5 |= (SIM_SCGC5_PORTA_MASK | SIM_SCGC5_PORTB_MASK
#ifdef SIM_SCGC5_PORTC_MASK
| SIM_SCGC5_PORTC_MASK
#endif
#ifdef SIM_SCGC5_PORTD_MASK
| SIM_SCGC5_PORTD_MASK
#endif
#ifdef SIM_SCGC5_PORTE_MASK
| SIM_SCGC5_PORTE_MASK
#endif
);
}
static void hw_uart_init(void)
{
register uint16_t sbr, brfa;
uint8_t temp;
/* Enable UART core clock */
SIM->SCGC1 |= SIM_SCGC1_UART5_MASK;
/* Configure UART TX pin */
UART_TX_PORT->PCR[UART_TX_PIN] = PORT_PCR_MUX(UART_TX_MUX);
/* Disable transmitter and receiver while we change settings. */
UART_PORT->C2 &= ~(UART_C2_TE_MASK | UART_C2_RE_MASK );
/* Configure the UART for 8-bit mode, no parity */
UART_PORT->C1 = 0;
/* Calculate baud settings */
sbr = (uint16_t)((BUS_CLK_KHZ * 1000)/(UART_BAUD * 16));
temp = UART_PORT->BDH & ~(UART_BDH_SBR(0x1F));
UART_PORT->BDH = temp | UART_BDH_SBR(((sbr & 0x1F00) >> 8));
UART_PORT->BDL = (uint8_t)(sbr & UART_BDL_SBR_MASK);
/* Determine if a fractional divider is needed to get closer to the baud rate */
brfa = (((BUS_CLK_KHZ * 32000)/(UART_BAUD * 16)) - (sbr * 32));
temp = UART_PORT->C4 & ~(UART_C4_BRFA(0x1F));
UART_PORT->C4 = temp | UART_C4_BRFA(brfa);
/* Enable receiver and transmitter */
UART_PORT->C2 |= (UART_C2_TE_MASK | UART_C2_RE_MASK);
}
static void hw_rtc_init(void)
{
/* Enable RTC clock and oscillator */
SIM->SCGC6 |= SIM_SCGC6_RTC_MASK;
RTC->CR |= RTC_CR_OSCE_MASK;
}
static void hw_rand_init(void)
{
/* Enable RNG clocks */
SIM->SCGC6 |= SIM_SCGC6_RNGA_MASK;
SIM->SCGC3 |= SIM_SCGC3_RNGA_MASK;
/* Wake up RNG to normal mode (take out of sleep) */
RNG->CR &= ~RNG_CR_SLP_MASK;
/* Enable High Assurance mode (Enables notification of security violations via SR[SECV]) */
RNG->CR |= RNG_CR_HA_MASK;
/* Enable RNG generation to RANDOUT FIFO */
RNG->CR |= RNG_CR_GO_MASK;
}
/* Public Functions */
void hw_init(void)
{
hw_mcg_init();
hw_gpio_init();
hw_uart_init();
hw_rtc_init();
hw_rand_init();
}
uint32_t hw_get_time_sec(void)
{
/* Return RTC seconds */
return RTC->TSR;
}
uint32_t hw_get_time_msec(void)
{
/* RTC TPR precision register increments every 32.768 kHz clock cycle */
/* Convert with rounding crystal count (32768 or (1 << 15)) to milliseconds */
return ( ((uint32_t)RTC->TPR * 1000) + ((1 << 15) / 2) ) / (1 << 15);
}
void hw_uart_printchar(int c)
{
while(!(UART_PORT->S1 & UART_S1_TDRE_MASK)); /* Wait until space is available in the FIFO */
UART_PORT->D = (uint8_t)c; /* Send the character */
}
int hw_rand(void)
{
while((RNG->SR & RNG_SR_OREG_LVL(0xF)) == 0) {}; /* Wait until FIFO has a value available */
return RNG->OR; /* Return next value in FIFO output register */
}
// Watchdog
void hw_watchdog_disable(void)
{
WDOG->UNLOCK = 0xC520;
WDOG->UNLOCK = 0xD928;
WDOG->STCTRLH = WDOG_STCTRLH_ALLOWUPDATE_MASK;
}
// Flash configuration
#define FSEC_UNSECURE 2
#define FSEC_SECURE 0
#define FSEC_FSLACC_DENIED 2
#define FSEC_FSLACC_GRANTED 3
#define FSEC_KEY_ENABLED 2
#define FSEC_KEY_DISABLED 3
#define FSEC_MASS_ERASE_DISABLE 2
#define FSEC_MASS_ERASE_ENABLE 3
struct flash_conf {
uint8_t backdoor_key[8]; /* Backdoor Comparison Key */
uint8_t fprot[4]; /* Program flash protection bytes */
uint8_t fsec; /* Flash security byte */
uint8_t fopt; /* Flash nonvolatile option byte */
uint8_t feprot; /* FlexNVM: EEPROM protection byte */
uint8_t fdprot; /* FlexNVM: Data flash protection byte */
};
const struct flash_conf flash_conf __attribute__ ((section (".flashconf"),used)) =
{
.backdoor_key = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
.fprot = { 0xFF, 0xFF, 0xFF, 0xFF },
.fsec = NV_FSEC_SEC(FSEC_UNSECURE) | NV_FSEC_FSLACC(FSEC_FSLACC_GRANTED) |
NV_FSEC_MEEN(FSEC_MASS_ERASE_ENABLE) | NV_FSEC_KEYEN(FSEC_KEY_DISABLED),
.fopt = 0xFF,
.feprot = 0xFF,
.fdprot = 0xFF
};
#endif /* FREESCALE && K_SERIES */

View File

@ -0,0 +1,76 @@
/* test_main.c
*
* Copyright (C) 2006-2015 wolfSSL Inc.
*
* This file is part of wolfSSL. (formerly known as CyaSSL)
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfcrypt/test/test.h>
#include <stdio.h>
typedef struct func_args {
int argc;
char** argv;
int return_code;
} func_args;
static func_args args = { 0 } ;
void main(void)
{
int test_num = 0;
do
{
printf("\nCrypt Test %d:\n", test_num);
wolfcrypt_test(&args);
printf("Crypt Test %d: Return code %d\n", test_num, args.return_code);
test_num++;
} while(args.return_code == 0);
}
/* SAMPLE OUTPUT:
Crypt Test 1:
MD5 test passed!
MD4 test passed!
SHA test passed!
SHA-256 test passed!
HMAC-MD5 test passed!
HMAC-SHA test passed!
HMAC-SHA256 test passed!
ARC4 test passed!
HC-128 test passed!
Rabbit test passed!
DES test passed!
DES3 test passed!
AES test passed!
RANDOM test passed!
RSA test passed!
DH test passed!
DSA test passed!
PWDBASED test passed!
Crypt Test 1: Return code 0
*/

View File

@ -0,0 +1,106 @@
/* user_libc.c
*
* Copyright (C) 2006-2015 wolfSSL Inc.
*
* This file is part of wolfSSL. (formerly known as CyaSSL)
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#include "hw.h"
double current_time(int reset)
{
double time;
time = hw_get_time_sec();
time += (double)hw_get_time_msec() / 1000;
return time;
}
int custom_rand_generate(void)
{
return hw_rand();
}
// Debug print handler
int __putchar(int c, __printf_tag_ptr ctx)
{
hw_uart_printchar(c);
}
// Rowley CrossWorks, runtime support.
//
// Copyright (c) 2001-2015 Rowley Associates Limited.
//
// This file may be distributed under the terms of the License Agreement
// provided with this software.
//
// THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#include <__libc.h>
#if defined(__CROSSWORKS_ARM) || defined(__SES_ARM)
extern unsigned char __stack_process_start__[];
unsigned char * __aeabi_read_tp(void)
{
// thread-local storage addressing refers to the thread pointer
// This is returning start address of stack process
return (__stack_process_start__);
}
#elif defined(__CROSSWORKS_AVR) || defined(__CROSSWORKS_MSP430)
unsigned char * __RAL_read_tp(void)
{
return 0;
}
#endif
void __heap_lock(void)
{
}
void __heap_unlock(void)
{
}
void __printf_lock(void)
{
}
void __printf_unlock(void)
{
}
void __scanf_lock(void)
{
}
void __scanf_unlock(void)
{
}
void __debug_io_lock(void)
{
}
void __debug_io_unlock(void)
{
}

View File

@ -0,0 +1,28 @@
/* Configuration */
#define SINGLE_THREADED
#define WOLFSSL_SMALL_STACK
#define WOLFSSL_GENERAL_ALIGNMENT 4
#define NO_MAIN_DRIVER
#define NO_FILESYSTEM
#define NO_WRITEV
#define NO_DEV_RANDOM
#define NO_WOLFSSL_MEMORY
/* HW Crypto Acceleration */
// See README.md for instructions
//#define FREESCALE_MMCAU 1
/* Benchmark */
#define BENCH_EMBEDDED
#define USE_CERT_BUFFERS_2048
/* Custom functions */
extern int custom_rand_generate(void);
#define CUSTOM_RAND_GENERATE custom_rand_generate
#define WOLFSSL_USER_CURRTIME
/* Debugging - Optional */
#if 0
#define fprintf(file, format, ...) printf(format, ##__VA_ARGS__)
#define DEBUG_WOLFSSL
#endif

View File

@ -0,0 +1,317 @@
<!DOCTYPE CrossStudio_Project_File>
<solution Name="wolfssl" target="8" version="2">
<project Name="libwolfssl">
<configuration
Name="Common"
build_output_file_name="$(OutDir)/$(ProjectName)$(LibExt)$(LIB)"
c_preprocessor_definitions="WOLFSSL_ROWLEY_ARM;WOLFSSL_USER_SETTINGS"
c_user_include_directories=".;../;../../"
project_directory=""
project_type="Library" />
<folder Name="Source Files">
<configuration Name="Common" filter="c;cpp;cxx;cc;h;s;inc" />
<folder
Name="wolfcrypt"
exclude="*.asm;*.s"
filter=""
path="../../wolfcrypt"
recurse="Yes" />
<folder
Name="wolfssl"
exclude="*.asm;*.s"
filter=""
path="../../wolfssl"
recurse="Yes" />
<file file_name="user_settings.h" />
<file file_name="README.md" />
</folder>
</project>
<project Name="test">
<configuration
Name="Common"
Placement="Flash"
Target="MK64FN1M0xxx12"
arm_linker_fiq_stack_size="0"
arm_linker_heap_size="102800"
arm_linker_irq_stack_size="0"
arm_linker_stack_size="4096"
arm_simulator_memory_simulation_filename="$(TargetsDir)/Kinetis/KinetisSimulatorMemory.dll"
arm_simulator_memory_simulation_parameter="MK64FN1M0xxx12;0x100000;0x0;0x0;0x40000"
arm_target_loader_applicable_loaders="Flash"
arm_target_loader_default_loader="Flash"
c_preprocessor_definitions="WOLFSSL_ROWLEY_ARM;WOLFSSL_USER_SETTINGS"
c_user_include_directories=".;../;../../;$(TargetsDir);$(TargetsDir)/Kinetis;$(TargetsDir)/Kinetis/CMSIS;$(TargetsDir)/Kinetis/CMSIS/include;$(TargetsDir)/CMSIS_3/CMSIS/include"
linker_memory_map_macros="FLASHSIZE=0x80000;SRAMSIZE=0x20000"
linker_output_format="bin"
project_dependencies="libwolfssl"
project_type="Executable"
property_groups_file_path="$(TargetsDir)/Kinetis/propertyGroups.xml"
target_get_partname_script="GetPartName()"
target_match_partname_script="MatchPartName(&quot;$(Target)&quot;)"
target_reset_script="FLASHReset()"
target_script_file="$(TargetsDir)/Kinetis/Kinetis_Target.js" />
<folder Name="Source Files">
<configuration Name="Common" filter="c;cpp;cxx;cc;h;s;asm;inc" />
<file file_name="user_libc.c" />
<file file_name="kinetis_hw.c" />
<file file_name="hw.h" />
<file file_name="test_main.c" />
<file file_name="arm_startup.c" />
<file file_name="user_settings.h" />
<file file_name="README.md" />
</folder>
<folder Name="System Files">
<file file_name="Kinetis_FlashPlacement.xml" />
<file file_name="Kinetis_MemoryMap.xml" />
</folder>
</project>
<project Name="benchmark">
<configuration
Name="Common"
Placement="Flash"
Target="MK64FN1M0xxx12"
arm_linker_fiq_stack_size="0"
arm_linker_heap_size="102800"
arm_linker_irq_stack_size="0"
arm_linker_stack_size="4096"
arm_simulator_memory_simulation_filename="$(TargetsDir)/Kinetis/KinetisSimulatorMemory.dll"
arm_simulator_memory_simulation_parameter="MK64FN1M0xxx12;0x100000;0x0;0x0;0x40000"
arm_target_loader_applicable_loaders="Flash"
arm_target_loader_default_loader="Flash"
c_preprocessor_definitions="WOLFSSL_ROWLEY_ARM;WOLFSSL_USER_SETTINGS"
c_user_include_directories=".;../;../../;$(TargetsDir);$(TargetsDir)/Kinetis;$(TargetsDir)/Kinetis/CMSIS;$(TargetsDir)/Kinetis/CMSIS/include;$(TargetsDir)/CMSIS_3/CMSIS/include"
linker_memory_map_macros="FLASHSIZE=0x80000;SRAMSIZE=0x20000"
linker_output_format="bin"
project_dependencies="libwolfssl"
project_type="Executable"
property_groups_file_path="$(TargetsDir)/Kinetis/propertyGroups.xml"
target_get_partname_script="GetPartName()"
target_match_partname_script="MatchPartName(&quot;$(Target)&quot;)"
target_reset_script="FLASHReset()"
target_script_file="$(TargetsDir)/Kinetis/Kinetis_Target.js" />
<folder Name="Source Files">
<configuration Name="Common" filter="c;cpp;cxx;cc;h;s;asm;inc" />
<file file_name="user_libc.c" />
<file file_name="kinetis_hw.c" />
<file file_name="hw.h" />
<file file_name="benchmark_main.c" />
<file file_name="arm_startup.c" />
<file file_name="user_settings.h" />
<file file_name="README.md" />
</folder>
<folder Name="System Files">
<file file_name="Kinetis_FlashPlacement.xml" />
<file file_name="Kinetis_MemoryMap.xml" />
</folder>
</project>
<configuration
Name="ARM"
Platform="ARM"
arm_architecture="v7EM"
arm_core_type="Cortex-M4"
arm_instruction_set="ARM"
arm_library_instruction_set="ARM"
c_preprocessor_definitions="__ARM"
hidden="Yes" />
<configuration
Name="LE"
arm_endian="Little"
c_preprocessor_definitions="__LITTLE_ENDIAN"
hidden="Yes" />
<configuration
Name="BE"
arm_endian="Big"
c_preprocessor_definitions="__BIG_ENDIAN"
hidden="Yes" />
<configuration
Name="Soft"
arm_fp_abi="Soft"
c_preprocessor_definitions="__FP_ABI_SOFT__"
hidden="Yes" />
<configuration
Name="Small"
arm_library_optimization="Small"
c_preprocessor_definitions="__OPTIMIZATION_SMALL"
gcc_optimization_level="Optimize For Size"
hidden="Yes" />
<configuration Name="WCHAR16" gcc_wchar_size="16-Bit" hidden="Yes" />
<configuration
Name="Debug"
c_preprocessor_definitions="DEBUG"
gcc_debugging_level="Level 3"
gcc_optimization_level="None"
hidden="Yes" />
<configuration
Name="Float"
c_preprocessor_definitions="SHORT_FLOAT"
double_is_float="Yes"
hidden="Yes" />
<configuration
Name="Release"
c_preprocessor_definitions="NDEBUG"
gcc_debugging_level="Level 1"
gcc_optimization_level="Level 1"
hidden="Yes" />
<configuration
Name="Fast"
arm_library_optimization="Fast"
c_preprocessor_definitions="__OPTIMIZATION_FAST"
gcc_optimization_level="Level 1"
hidden="Yes" />
<configuration
Name="THUMB"
Platform="ARM"
arm_instruction_set="Thumb"
arm_library_instruction_set="Thumb"
c_preprocessor_definitions="__THUMB"
hidden="Yes" />
<configuration
Name="Hard"
arm_fp_abi="Hard"
c_preprocessor_definitions="__FP_ABI_HARD__"
hidden="Yes" />
<configuration
Name="Flash"
c_preprocessor_definitions="__FLASH_BUILD"
hidden="Yes" />
<configuration
Name="RAM"
c_preprocessor_definitions="__RAM_BUILD"
hidden="Yes" />
<configuration
Name="Kineits"
arm_target_debug_interface_type="ADIv5"
c_preprocessor_definitions="FREESCALE;K_SERIES"
hidden="Yes"
linker_memory_map_file="$(ProjectDir)/Kinetis_MemoryMap.xml"
linker_section_placement_file="$(ProjectDir)/Kinetis_FlashPlacement.xml" />
<configuration
Name="V4"
arm_architecture="v4T"
arm_interwork="No"
c_preprocessor_definitions="__ARCH_V4"
hidden="Yes" />
<configuration
Name="V4T"
arm_architecture="v4T"
c_preprocessor_definitions="__ARCH_V4T"
hidden="Yes" />
<configuration
Name="V5TE"
arm_architecture="v5TE"
c_preprocessor_definitions="__ARCH_V5TE"
hidden="Yes" />
<configuration
Name="V6"
arm_architecture="v6"
c_preprocessor_definitions="__ARCH_V6"
hidden="Yes" />
<configuration
Name="V7A"
arm_architecture="v7A"
c_preprocessor_definitions="__ARCH_V7A"
hidden="Yes" />
<configuration
Name="V7R"
arm_architecture="v7R"
c_preprocessor_definitions="__ARCH_V7R"
hidden="Yes" />
<configuration
Name="V6M"
arm_architecture="v6M"
c_preprocessor_definitions="__ARCH_V6M"
hidden="Yes" />
<configuration
Name="V7M"
arm_architecture="v7M"
c_preprocessor_definitions="__ARCH_V7M"
hidden="Yes" />
<configuration
Name="V7EM"
arm_architecture="v7EM"
c_preprocessor_definitions="__ARCH_V7EM"
hidden="Yes" />
<configuration
Name="V5TE VFP"
arm_architecture="v5TE"
arm_fpu_type="VFP"
c_preprocessor_definitions="__ARCH_V5TE;__FPU_VFP__"
hidden="Yes" />
<configuration
Name="SoftFP"
arm_fp_abi="SoftFP"
c_preprocessor_definitions="__FP_ABI_SOFT_FP__"
hidden="Yes" />
<configuration
Name="V6 VFP"
arm_architecture="v6"
arm_fpu_type="VFP"
c_preprocessor_definitions="__ARCH_V6;__FPU_VFP__"
hidden="Yes" />
<configuration
Name="V7A VFPv3-D32"
arm_architecture="v7A"
arm_fpu_type="VFPv3-D32"
c_preprocessor_definitions="__ARCH_V7A;__FPU_VFP__"
hidden="Yes" />
<configuration
Name="V7A VFPv4-D16"
arm_architecture="v7A"
arm_fpu_type="VFPv4-D16"
c_preprocessor_definitions="__ARCH_V7A;__FPU_VFP__"
hidden="Yes" />
<configuration
Name="V7A_IDIV VFPv4-D16"
arm_architecture="v7A"
arm_fpu_type="VFPv4-D16"
arm_v7_has_divide_instructions="Yes"
c_preprocessor_definitions="__ARCH_V7A;__FPU_VFP__"
hidden="Yes" />
<configuration
Name="V7R VFPv3-D16"
arm_architecture="v7R"
arm_fpu_type="VFPv3-D16"
c_preprocessor_definitions="__ARCH_V7R;__FPU_VFP__"
hidden="Yes" />
<configuration
Name="V7R_IDIV VFPv3-D16"
arm_architecture="v7R"
arm_fpu_type="VFPv3-D16"
arm_v7_has_divide_instructions="Yes"
c_preprocessor_definitions="__ARCH_V7R;__FPU_VFP__"
hidden="Yes" />
<configuration
Name="V7EM FPv4-SP-D16"
arm_architecture="v7EM"
arm_fpu_type="FPv4-SP-D16"
c_preprocessor_definitions="__ARCH_V7EM;__FPV4_SP_D16__"
hidden="Yes" />
<configuration
Name="V7EM FPv5-SP-D16"
arm_architecture="v7EM"
arm_fpu_type="FPv5-SP-D16"
c_preprocessor_definitions="__ARCH_V7EM;__FPV5_SP_D16__"
hidden="Yes" />
<configuration
Name="V7EM FPv5-D16"
arm_architecture="v7EM"
arm_fpu_type="FPv5-D16"
c_preprocessor_definitions="__ARCH_V7EM;__FPU_VFP__"
hidden="Yes" />
<configuration
Name="ARM_Debug"
batch_build_configurations="V7EM THUMB * Debug"
inherited_configurations="ARM;V7EM;Debug;Kineits;THUMB;Flash" />
<configuration
Name="ARM_Release"
batch_build_configurations="V7EM THUMB * Release"
inherited_configurations="ARM;V7EM;Release;Kineits;Flash;THUMB" />
<configuration
Name="MMCAU"
hidden="Yes"
linker_additional_options="-L $(ProjectDir) -l lib_mmcau.a" />
<configuration
Name="Common"
build_intermediate_directory="$(ProjectName)_$(Configuration)"
build_output_directory="$(ProjectName)_$(Configuration)" />
</solution>

View File

@ -102,7 +102,8 @@ int wc_RNG_GenerateByte(WC_RNG* rng, byte* b)
#include <wincrypt.h>
#else
#if !defined(NO_DEV_RANDOM) && !defined(CUSTOM_RAND_GENERATE) && \
!defined(WOLFSSL_GENSEED_FORTEST) && !defined(WOLFSSL_MDK_ARM) && !defined(WOLFSSL_IAR_ARM)
!defined(WOLFSSL_GENSEED_FORTEST) && !defined(WOLFSSL_MDK_ARM) && \
!defined(WOLFSSL_IAR_ARM) && !defined(WOLFSSL_ROWLEY_ARM)
#include <fcntl.h>
#ifndef EBSNET
#include <unistd.h>

View File

@ -946,7 +946,8 @@ WOLFSSL_API int wolfSSL_make_eap_keys(WOLFSSL*, void* key, unsigned int len,
#ifdef __PPU
#include <sys/types.h>
#include <sys/socket.h>
#elif !defined(WOLFSSL_MDK_ARM) && !defined(WOLFSSL_IAR_ARM) && !defined(WOLFSSL_PICOTCP)
#elif !defined(WOLFSSL_MDK_ARM) && !defined(WOLFSSL_IAR_ARM) && \
!defined(WOLFSSL_PICOTCP) && !defined(WOLFSSL_ROWLEY_ARM)
#include <sys/uio.h>
#endif
/* allow writev style writing */

View File

@ -109,7 +109,8 @@
/* HPUX doesn't use socklent_t for third parameter to accept, unless
_XOPEN_SOURCE_EXTENDED is defined */
#if !defined(__hpux__) && !defined(WOLFSSL_MDK_ARM) && !defined(WOLFSSL_IAR_ARM)
#if !defined(__hpux__) && !defined(WOLFSSL_MDK_ARM) && \
!defined(WOLFSSL_IAR_ARM) && !defined(WOLFSSL_ROWLEY_ARM)
typedef socklen_t* ACCEPT_THIRD_T;
#else
#if defined _XOPEN_SOURCE_EXTENDED

View File

@ -102,6 +102,9 @@
/* Uncomment next line if building for IAR EWARM */
/* #define WOLFSSL_IAR_ARM */
/* Uncomment next line if building for Rowley CrossWorks ARM */
/* #define WOLFSSL_ROWLEY_ARM */
/* Uncomment next line if using TI-RTOS settings */
/* #define WOLFSSL_TIRTOS */
@ -180,7 +183,7 @@
#define NO_FILESYSTEM
#endif
#if defined(WOLFSSL_IAR_ARM)
#if defined(WOLFSSL_IAR_ARM) || defined(WOLFSSL_ROWLEY_ARM)
#define NO_MAIN_DRIVER
#define SINGLE_THREADED
#define USE_CERT_BUFFERS_1024
@ -188,7 +191,7 @@
#define NO_FILESYSTEM
#define NO_WRITEV
#define WOLFSSL_USER_IO
#define BENCH_EMBEDDED
#define BENCH_EMBEDDED
#endif
#ifdef MICROCHIP_PIC32