initial attempt for MDK-ARM/LPC43xx:

pull/1/head
kojo 2013-05-21 09:39:09 +09:00
parent c2a82bce3d
commit da342ea079
13 changed files with 5622 additions and 573 deletions

1
.gitignore vendored
View File

@ -81,3 +81,4 @@ cov-int
cyassl.tgz cyassl.tgz
*.log *.log
*.trs *.trs
IDE\MDK-ARM\Projects

View File

@ -78,7 +78,7 @@
// <h>STM32 Hardware Crypt // <h>STM32 Hardware Crypt
// <e>STM32F2 Hardware RNG // <e>STM32F2 Hardware RNG
#define MDK_CONF_STM32F2_RNG 1 #define MDK_CONF_STM32F2_RNG 0
#if MDK_CONF_STM32F2_RNG == 1 #if MDK_CONF_STM32F2_RNG == 1
#define STM32F2_RNG #define STM32F2_RNG
#else #else

View File

@ -76,7 +76,7 @@
// <h>STM32 Hardware Crypt // <h>STM32 Hardware Crypt
// <e>STM32F2 Hardware RNG // <e>STM32F2 Hardware RNG
#define MDK_CONF_STM32F2_RNG 1 #define MDK_CONF_STM32F2_RNG 0
#if MDK_CONF_STM32F2_RNG == 1 #if MDK_CONF_STM32F2_RNG == 1
#define STM32F2_RNG #define STM32F2_RNG
#else #else

View File

@ -99,7 +99,7 @@
// </h> // </h>
// <h>STM32 Hardware Crypt // <h>STM32 Hardware Crypt
// <e>STM32F2 Hardware RNG // <e>STM32F2 Hardware RNG
#define MDK_CONF_STM32F2_RNG 1 #define MDK_CONF_STM32F2_RNG 0
#if MDK_CONF_STM32F2_RNG == 1 #if MDK_CONF_STM32F2_RNG == 1
#define STM32F2_RNG #define STM32F2_RNG
#else #else
@ -127,19 +127,19 @@
// </e> // </e>
// <e>CertGen // <e>CertGen
#define MDK_CONF_CERT_GEN 0 #define MDK_CONF_CERT_GEN 1
#if MDK_CONF_CERT_GEN == 1 #if MDK_CONF_CERT_GEN == 1
#define CYASSL_CERT_GEN #define CYASSL_CERT_GEN
#endif #endif
// </e> // </e>
// <e>KeyGen // <e>KeyGen
#define MDK_CONF_KEY_GEN 0 #define MDK_CONF_KEY_GEN 1
#if MDK_CONF_KEY_GEN == 1 #if MDK_CONF_KEY_GEN == 1
#define CYASSL_KEY_GEN #define CYASSL_KEY_GEN
#endif #endif
// </e> // </e>
// <e>CRL // <e>CRL
#define MDK_CONF_DER_LOAD 0 #define MDK_CONF_DER_LOAD 1
#if MDK_CONF_DER_LOAD == 1 #if MDK_CONF_DER_LOAD == 1
#define CYASSL_DER_LOAD #define CYASSL_DER_LOAD
#endif #endif
@ -160,7 +160,7 @@
// <h>MD5, SHA, SHA-256, AES, RC4, ASN, RSA // <h>MD5, SHA, SHA-256, AES, RC4, ASN, RSA
// </h> // </h>
// <e>MD2 // <e>MD2
#define MDK_CONF_MD2 0 #define MDK_CONF_MD2 1
#if MDK_CONF_MD2 == 1 #if MDK_CONF_MD2 == 1
#define CYASSL_MD2 #define CYASSL_MD2
#endif #endif
@ -173,13 +173,13 @@
// </e> // </e>
// <e>SHA-384 // <e>SHA-384
// <i>This has to be with SHA512 // <i>This has to be with SHA512
#define MDK_CONF_SHA384 0 #define MDK_CONF_SHA384 1
#if MDK_CONF_SHA384 == 1 #if MDK_CONF_SHA384 == 1
#define CYASSL_SHA384 #define CYASSL_SHA384
#endif #endif
// </e> // </e>
// <e>SHA-512 // <e>SHA-512
#define MDK_CONF_SHA512 0 #define MDK_CONF_SHA512 1
#if MDK_CONF_SHA512 == 1 #if MDK_CONF_SHA512 == 1
#define CYASSL_SHA512 #define CYASSL_SHA512
#endif #endif
@ -197,7 +197,7 @@
#endif #endif
// </e> // </e>
// <e>HC128 // <e>HC128
#define MDK_CONF_HC128 0 #define MDK_CONF_HC128 1
#if MDK_CONF_HC128 == 1 #if MDK_CONF_HC128 == 1
#define HAVE_HC128 #define HAVE_HC128
#endif #endif
@ -210,7 +210,7 @@
// </e> // </e>
// <e>AEAD // <e>AEAD
#define MDK_CONF_AEAD 0 #define MDK_CONF_AEAD 1
#if MDK_CONF_AEAD == 1 #if MDK_CONF_AEAD == 1
#define HAVE_AEAD #define HAVE_AEAD
#endif #endif
@ -222,7 +222,7 @@
#endif #endif
// </e> // </e>
// <e>CAMELLIA // <e>CAMELLIA
#define MDK_CONF_CAMELLIA 0 #define MDK_CONF_CAMELLIA 1
#if MDK_CONF_CAMELLIA == 1 #if MDK_CONF_CAMELLIA == 1
#define HAVE_CAMELLIA #define HAVE_CAMELLIA
#endif #endif
@ -261,13 +261,13 @@
#endif #endif
// </e> // </e>
// <e>AESCCM (Turn off Hardware Crypt) // <e>AESCCM (Turn off Hardware Crypt)
#define MDK_CONF_AESCCM 0 #define MDK_CONF_AESCCM 1
#if MDK_CONF_AESCCM == 1 #if MDK_CONF_AESCCM == 1
#define HAVE_AESCCM #define HAVE_AESCCM
#endif #endif
// </e> // </e>
// <e>AESGCM (Turn off Hardware Crypt) // <e>AESGCM (Turn off Hardware Crypt)
#define MDK_CONF_AESGCM 0 #define MDK_CONF_AESGCM 1
#if MDK_CONF_AESGCM == 1 #if MDK_CONF_AESGCM == 1
#define HAVE_AESGCM #define HAVE_AESGCM
#define BUILD_AESGCM #define BUILD_AESGCM

View File

@ -59,7 +59,7 @@ unsigned long inet_addr(const char *cp)
/*** tcp_connect is actually associated with following syassl_tcp_connect. ***/ /*** tcp_connect is actually associated with following syassl_tcp_connect. ***/
int Cyassl_connect(int sd, const struct sockaddr* sa, int sz) int Cyassl_connect(int sd, const struct sockaddr* sa, int sz)
{ {
int ret ; int ret = 0 ;
#if defined(CYASSL_KEIL_TCP_NET) #if defined(CYASSL_KEIL_TCP_NET)
SOCKADDR_IN addr ; SOCKADDR_IN addr ;
@ -86,7 +86,7 @@ int Cyassl_connect(int sd, const struct sockaddr* sa, int sz)
int Cyassl_accept(int sd, struct sockaddr *addr, int *addrlen) int Cyassl_accept(int sd, struct sockaddr *addr, int *addrlen)
{ {
int ret ; int ret = 0 ;
#if defined(CYASSL_KEIL_TCP_NET) #if defined(CYASSL_KEIL_TCP_NET)
while(1) { while(1) {
@ -110,7 +110,7 @@ int Cyassl_accept(int sd, struct sockaddr *addr, int *addrlen)
int Cyassl_recv(int sd, void *buf, size_t len, int flags) int Cyassl_recv(int sd, void *buf, size_t len, int flags)
{ {
int ret ; int ret = 0;
#if defined(CYASSL_KEIL_TCP_NET) #if defined(CYASSL_KEIL_TCP_NET)
while(1) { while(1) {
#undef recv /* Go to KEIL TCPnet recv */ #undef recv /* Go to KEIL TCPnet recv */
@ -132,7 +132,7 @@ int Cyassl_recv(int sd, void *buf, size_t len, int flags)
int Cyassl_send(int sd, const void *buf, size_t len, int flags) int Cyassl_send(int sd, const void *buf, size_t len, int flags)
{ {
int ret ; int ret = 0 ;
#if defined(CYASSL_KEIL_TCP_NET) #if defined(CYASSL_KEIL_TCP_NET)
while(1) { while(1) {
@ -170,40 +170,6 @@ int Cyassl_tcp_select(int sd, int timeout)
} }
#endif #endif
struct tm *Cyassl_MDK_gmtime(const time_t *c)
{
RTC_TimeTypeDef RTC_Time ;
RTC_DateTypeDef RTC_Date ;
static struct tm date ;
RTC_GetTime(RTC_Format_BIN, &RTC_Time) ;
RTC_GetDate(RTC_Format_BIN, &RTC_Date) ;
date.tm_year = RTC_Date.RTC_Year + 100 ;
date.tm_mon = RTC_Date.RTC_Month - 1 ;
date.tm_mday = RTC_Date.RTC_Date ;
date.tm_hour = RTC_Time.RTC_Hours ;
date.tm_min = RTC_Time.RTC_Minutes ;
date.tm_sec = RTC_Time.RTC_Seconds ;
#if defined(DEBUG_CYASSL)
{
char msg[100] ;
sprintf(msg, "Debug::Cyassl_KEIL_gmtime(DATE=/%4d/%02d/%02d TIME=%02d:%02d:%02d)\n",
RTC_Date.RTC_Year+2000, RTC_Date.RTC_Month, RTC_Date.RTC_Date,
RTC_Time.RTC_Hours, RTC_Time.RTC_Minutes, RTC_Time.RTC_Seconds) ;
CYASSL_MSG(msg) ;
}
#endif
return(&date) ;
}
double current_time()
{
return ((double)TIM2->CNT/1000000.0) ;
}
extern int getkey(void) ; extern int getkey(void) ;
extern int sendchar(int c) ; extern int sendchar(int c) ;

View File

@ -95,13 +95,9 @@ extern int setsockopt(int sockfd, int level, int optname,
extern int select(int nfds, fd_set *readfds, fd_set *writefds, extern int select(int nfds, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, const struct timeval *timeout); fd_set *exceptfds, const struct timeval *timeout);
/* CyaSSL MDK-ARM time functions */
/** KEIL-RL gmtime ****/
#include <time.h> #include <time.h>
#include "stm32f2xx_rtc.h" struct tm *Cyassl_MDK_gmtime(const time_t *c) ;
extern struct tm *gmtime(const time_t *timer);
extern struct tm *Cyassl_MDK_gmtime(const time_t *timer);
extern double current_time(void) ; extern double current_time(void) ;
#endif /* CYASSL_KEIL_RL_H */ #endif /* CYASSL_KEIL_RL_H */

View File

@ -30,10 +30,6 @@
#include <stdio.h> #include <stdio.h>
#include "cyassl_MDK_ARM.h" #include "cyassl_MDK_ARM.h"
#include "stm32f2xx_tim.h"
#include "stm32f2xx_rcc.h"
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
* Initialize a Flash Memory Card * Initialize a Flash Memory Card
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
@ -87,77 +83,6 @@ __task void tcp_poll (void)
} }
#endif #endif
/*-----------------------------------------------------------------------------
* initialize RTC
*----------------------------------------------------------------------------*/
#include "stm32f2xx_rtc.h"
#include "stm32f2xx_rcc.h"
#include "stm32f2xx_pwr.h"
static init_RTC()
{
RTC_InitTypeDef RTC_InitStruct ;
RTC_TimeTypeDef RTC_Time ;
RTC_DateTypeDef RTC_Date ;
/* Enable the PWR clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
/* Allow access to RTC */
PWR_BackupAccessCmd(ENABLE);
/***Configures the External Low Speed oscillator (LSE)****/
RCC_LSEConfig(RCC_LSE_ON);
/* Wait till LSE is ready */
while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)
{
}
/* Select the RTC Clock Source */
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
/* Enable the RTC Clock */
RCC_RTCCLKCmd(ENABLE);
/* Wait for RTC APB registers synchronisation */
RTC_WaitForSynchro();
/* Calendar Configuration with LSI supposed at 32KHz */
RTC_InitStruct.RTC_AsynchPrediv = 0x7F;
RTC_InitStruct.RTC_SynchPrediv = 0xFF;
RTC_InitStruct.RTC_HourFormat = RTC_HourFormat_24;
RTC_Init(&RTC_InitStruct);
RTC_GetTime(RTC_Format_BIN, &RTC_Time) ;
RTC_GetDate(RTC_Format_BIN, &RTC_Date) ;
}
/*-----------------------------------------------------------------------------
* initialize TIM
*----------------------------------------------------------------------------*/
void init_timer()
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure ;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE) ;
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
TIM_TimeBaseStructure.TIM_Prescaler = 60;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseStructure.TIM_Period = 0xffffffff;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_RepetitionCounter = 0;
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure) ;
TIM_Cmd(TIM2, ENABLE) ;
}
#if defined(HAVE_KEIL_RTX) && defined(CYASSL_MDK_SHELL) #if defined(HAVE_KEIL_RTX) && defined(CYASSL_MDK_SHELL)
#define SHELL_STACKSIZE 1000 #define SHELL_STACKSIZE 1000
static unsigned char Shell_stack[SHELL_STACKSIZE] ; static unsigned char Shell_stack[SHELL_STACKSIZE] ;
@ -197,6 +122,7 @@ void main_task (void)
/************************************/ /************************************/
/*** USER APPLICATION HERE ***/ /*** USER APPLICATION HERE ***/
/************************************/ /************************************/
printf("USER LOGIC STARTED\n") ;
#endif #endif
@ -217,16 +143,19 @@ void main_task (void)
/*** main entry ***/ /*** main entry ***/
int main() { extern void init_time(void) ;
/* stm32_Init (); STM32 setup */ extern void SystemInit(void);
int main() {
SystemInit();
SER_Init() ;
#if !defined(NO_FILESYSTEM) #if !defined(NO_FILESYSTEM)
init_card () ; /* initializing SD card */ init_card () ; /* initializing SD card */
#endif #endif
init_RTC() ; init_time() ;
init_timer() ;
SER_Init() ;
#if defined(DEBUG_CYASSL) #if defined(DEBUG_CYASSL)
printf("Turning ON Debug message\n") ; printf("Turning ON Debug message\n") ;

View File

@ -384,39 +384,6 @@ static void ipaddr_comm(void *args)
#endif #endif
static void time_main(void *args)
{
char * datetime ;
RTC_TimeTypeDef RTC_Time ;
RTC_DateTypeDef RTC_Date ;
int year ;
if( args == NULL || ((func_args *)args)->argc == 1) {
RTC_GetTime(RTC_Format_BIN, &RTC_Time) ;
RTC_GetDate(RTC_Format_BIN, &RTC_Date) ;
printf("Date: %d/%d/%d, Time: %02d:%02d:%02d\n",
RTC_Date.RTC_Month, RTC_Date.RTC_Date, RTC_Date.RTC_Year+2000,
RTC_Time.RTC_Hours, RTC_Time.RTC_Minutes, RTC_Time.RTC_Seconds) ;
} else if(((func_args *)args)->argc == 3 &&
((func_args *)args)->argv[1][0] == '-' &&
((func_args *)args)->argv[1][1] == 'd' ) {
datetime = ((func_args *)args)->argv[2];
sscanf(datetime, "%d/%d/%d",
(int *)&RTC_Date.RTC_Month, (int *)&RTC_Date.RTC_Date, &year) ;
RTC_Date.RTC_Year = year - 2000 ;
RTC_Date.RTC_WeekDay = 0 ;
RTC_SetDate(RTC_Format_BIN, &RTC_Date) ;
} else if(((func_args *)args)->argc == 3 &&
((func_args *)args)->argv[1][0] == '-' &&
((func_args *)args)->argv[1][1] == 't' ) {
datetime = ((func_args *)args)->argv[2];
sscanf(datetime, "%d:%d:%d",
(int *)&RTC_Time.RTC_Hours,
(int *)&RTC_Time.RTC_Minutes,
(int *)&RTC_Time.RTC_Seconds
) ;
RTC_SetTime(RTC_Format_BIN, &RTC_Time) ;
} else printf("Invalid argument\n") ;
}
#if defined(HAVE_KEIL_RTX) #if defined(HAVE_KEIL_RTX)

View File

@ -3,10 +3,10 @@
*---------------------------------------------------------------------------- *----------------------------------------------------------------------------
* Name: FILE_CONFIG.C * Name: FILE_CONFIG.C
* Purpose: Configuration of RL FlashFS by user * Purpose: Configuration of RL FlashFS by user
* Rev.: V4.50 * Rev.: V4.70
*---------------------------------------------------------------------------- *----------------------------------------------------------------------------
* This code is part of the RealView Run-Time Library. * This code is part of the RealView Run-Time Library.
* Copyright (c) 2004-2012 KEIL - An ARM Company. All rights reserved. * Copyright (c) 2004-2013 KEIL - An ARM Company. All rights reserved.
*---------------------------------------------------------------------------*/ *---------------------------------------------------------------------------*/
#include <File_Config.h> #include <File_Config.h>
@ -23,10 +23,24 @@
// <i>Default: 8 // <i>Default: 8
#define N_FILES 6 #define N_FILES 6
// <o>FAT Name Cache Size <0-1000000>
// <i>Define number of cached FAT file or directory names.
// <i>48 bytes of RAM is required for each cached name.
#define FAT_NAME_CACNT 0
// <e>Relocate FAT Name Cache Buffer
// <i>Locate Cache Buffer at a specific address.
#define FAT_NAME_RELOC 0
// <o>Base address <0x0000-0xFFFFFE00:0x200>
// <i>Define the Cache buffer base address.
#define FAT_NAME_CADR 0x60000000
// </e>
// <o>CPU Clock Frequency [Hz]<0-1000000000> // <o>CPU Clock Frequency [Hz]<0-1000000000>
// <i>Define the CPU Clock frequency used for // <i>Define the CPU Clock frequency used for
// <i>flash programming and erasing. // <i>flash programming and erasing.
#define CPU_CLK 120000000 #define CPU_CLK 180000000
// </h> // </h>
// <e>Flash Drive // <e>Flash Drive
@ -131,7 +145,7 @@
// <i>Define System Cache buffer size for file IO. // <i>Define System Cache buffer size for file IO.
// <i>Increase this number for faster r/w access. // <i>Increase this number for faster r/w access.
// <i>Default: 4 kB // <i>Default: 4 kB
#define MC0_CASZ 16 #define MC0_CASZ 4
// <e>Relocate Cache Buffer // <e>Relocate Cache Buffer
// <i>Locate Cache Buffer at a specific address. // <i>Locate Cache Buffer at a specific address.
@ -216,7 +230,7 @@
// <q>Default Drive [U0:] // <q>Default Drive [U0:]
// <i>Used when Drive letter not specified // <i>Used when Drive letter not specified
#define USB0_DEF 1 #define USB0_DEF 0
// </e> // </e>
// <e>USB Flash Drive 1 // <e>USB Flash Drive 1
@ -238,7 +252,7 @@
// <q>Default Drive [U1:] // <q>Default Drive [U1:]
// <i>Used when Drive letter not specified // <i>Used when Drive letter not specified
#define USB1_DEF 1 #define USB1_DEF 0
// </e> // </e>
// <e>NAND Flash Drive 0 // <e>NAND Flash Drive 0

View File

@ -39,7 +39,7 @@
// <i> Set the stack size for tasks which is assigned by the system. // <i> Set the stack size for tasks which is assigned by the system.
// <i> Default: 512 // <i> Default: 512
#ifndef OS_STKSIZE #ifndef OS_STKSIZE
#define OS_STKSIZE 250 #define OS_STKSIZE 499
#endif #endif
// <q>Check for the stack overflow // <q>Check for the stack overflow

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -23,8 +23,6 @@
#include <config.h> #include <config.h>
#endif #endif
#include <cyassl/ctaocrypt/settings.h>
/* on HPUX 11 you may need to install /dev/random see /* on HPUX 11 you may need to install /dev/random see
http://h20293.www2.hp.com/portal/swdepot/displayProductInfo.do?productNumber=KRNG11I http://h20293.www2.hp.com/portal/swdepot/displayProductInfo.do?productNumber=KRNG11I
@ -39,6 +37,7 @@
#ifdef NO_INLINE #ifdef NO_INLINE
#include <cyassl/ctaocrypt/misc.h> #include <cyassl/ctaocrypt/misc.h>
#else #else
#define MISC_DUMM_FUNC misc_dummy_random
#include <ctaocrypt/src/misc.c> #include <ctaocrypt/src/misc.c>
#endif #endif
#endif #endif
@ -60,7 +59,6 @@
#endif #endif
#endif /* USE_WINDOWS_API */ #endif /* USE_WINDOWS_API */
#if !defined( NO_CYASSL_RANDOM )
#ifdef NO_RC4 #ifdef NO_RC4
@ -569,16 +567,20 @@ int GenerateSeed(OS_Seed* os, byte* output, word32 sz)
return 0; return 0;
} }
#elif defined(CYASSL_LPC43xx)
#warning "write a real random seed!!!!, just for testing now"
int GenerateSeed(OS_Seed* os, byte* output, word32 sz)
{
int i;
for (i = 0; i < sz; i++ )
output[i] = i;
return 0;
}
#elif defined(NO_DEV_RANDOM) #elif defined(NO_DEV_RANDOM)
#error "you need to write an os specific GenerateSeed() here" #error "you need to write an os specific GenerateSeed() here"
/* int GenerateSeed(OS_Seed* os, byte* output, word32 sz) { return(0) ; }
int GenerateSeed(OS_Seed* os, byte* output, word32 sz)
{
return 0;
}
*/
#else /* !USE_WINDOWS_API && !THREADX && !MICRIUM && !NO_DEV_RANDOM */ #else /* !USE_WINDOWS_API && !THREADX && !MICRIUM && !NO_DEV_RANDOM */
@ -622,4 +624,3 @@ int GenerateSeed(OS_Seed* os, byte* output, word32 sz)
#endif /* USE_WINDOWS_API */ #endif /* USE_WINDOWS_API */
#endif /* NO_CYASSL_RANDOM */