diff --git a/ctaocrypt/src/port/pic32/pic32mz-hash.c b/ctaocrypt/src/port/pic32/pic32mz-hash.c index 7511725c7..4ee7eaf16 100644 --- a/ctaocrypt/src/port/pic32/pic32mz-hash.c +++ b/ctaocrypt/src/port/pic32/pic32mz-hash.c @@ -187,21 +187,23 @@ void Md5Final(Md5* md5, byte* hash) #endif #ifndef NO_SHA -void InitSha(Sha* sha) +int InitSha(Sha* sha) { CYASSL_ENTER("InitSha\n") ; XMEMSET((void *)sha, 0xcc, sizeof(Sha)) ; XMEMSET((void *)KVA0_TO_KVA1(sha), 0xcc, sizeof(Sha)) ; reset_engine(&(sha->desc), PIC32_ALGO_SHA1) ; + return 0; } -void ShaUpdate(Sha* sha, const byte* data, word32 len) +int ShaUpdate(Sha* sha, const byte* data, word32 len) { CYASSL_ENTER("ShaUpdate\n") ; update_engine(&(sha->desc), data, len, sha->digest) ; + return 0; } -void ShaFinal(Sha* sha, byte* hash) +int ShaFinal(Sha* sha, byte* hash) { CYASSL_ENTER("ShaFinal\n") ; start_engine(&(sha->desc)) ; @@ -209,16 +211,18 @@ void ShaFinal(Sha* sha, byte* hash) XMEMCPY(hash, sha->digest, SHA1_HASH_SIZE) ; InitSha(sha); /* reset state */ + return 0; } #endif /* NO_SHA */ #ifndef NO_SHA256 -void InitSha256(Sha256* sha256) +int InitSha256(Sha256* sha256) { CYASSL_ENTER("InitSha256\n") ; XMEMSET((void *)sha256, 0xcc, sizeof(Sha256)) ; XMEMSET((void *)KVA0_TO_KVA1(sha256), 0xcc, sizeof(Sha256)) ; reset_engine(&(sha256->desc), PIC32_ALGO_SHA256) ; + return 0; } int Sha256Update(Sha256* sha256, const byte* data, word32 len) diff --git a/mplabx/MZ-configBits.h b/mplabx/MZ-configBits.h new file mode 100644 index 000000000..6aac8113a --- /dev/null +++ b/mplabx/MZ-configBits.h @@ -0,0 +1,11 @@ + /* Config bits for PI32MZ, Starter Kit */ + #pragma config FPLLIDIV = DIV_1 // System PLL Input Divider (1x Divider) + #pragma config FPLLRNG = RANGE_5_10_MHZ + #pragma config FPLLICLK = PLL_FRC // System PLL Input Clock Selection (FRC is input to the System PLL) + #pragma config FPLLMULT = MUL_50 // System PLL Multiplier (PLL Multiply by 50) + #pragma config FPLLODIV = DIV_2 + // DEVCFG1 + #pragma config FNOSC = SPLL // Oscillator Selection (System PLL) + + #pragma config ICESEL = ICS_PGx2 + /* ICE/ICD Comm Channel Select (Communicate on PGEC2/PGED2) */ \ No newline at end of file diff --git a/mplabx/PIC32MZ-serial.h b/mplabx/PIC32MZ-serial.h index 323de525b..97bd1e0b5 100644 --- a/mplabx/PIC32MZ-serial.h +++ b/mplabx/PIC32MZ-serial.h @@ -7,12 +7,12 @@ static void init_serial() { SYSKEY = 0x00000000; SYSKEY = 0xAA996655; SYSKEY = 0x556699AA; - PB2DIV = 0x00008018; + PB2DIV = 0x00008808; SYSKEY = 0x33333333; /* UART2 Init */ // U2BRG = 0x0C; - U2BRG = 0x7; + U2BRG = 0x047; ANSELBCLR = 0x4000; ANSELGCLR = 0x0040; RPB14R = 0x02; diff --git a/mplabx/README b/mplabx/README index 715c227bf..ab1e70609 100644 --- a/mplabx/README +++ b/mplabx/README @@ -33,6 +33,8 @@ Included Project Files 3. CTaoCrypt Benchmark App (ctaocrypt_benchmark.X) This project builds the CTaoCrypt benchmark application. + For the benchmark timer, adjust CLOCK value under + "#elif defined MICROCHIP_PIC32" in ctaocrypt/benchmark/benchmark.c PIC32MX/PIC32MZ --------------- diff --git a/mplabx/benchmark_main.c b/mplabx/benchmark_main.c index 4d115de78..7610a3142 100644 --- a/mplabx/benchmark_main.c +++ b/mplabx/benchmark_main.c @@ -27,8 +27,9 @@ #if defined(CYASSL_MICROCHIP_PIC32MZ) #define MICROCHIP_PIC32 #include - #pragma config ICESEL = ICS_PGx2 - /* ICE/ICD Comm Channel Select (Communicate on PGEC2/PGED2) */ + + #include "MZ-configBits.h" + #include "PIC32MZ-serial.h" #define SYSTEMConfigPerformance /* void out SYSTEMConfigPerformance(); */ #else @@ -66,11 +67,18 @@ void bench_eccKeyAgree(void); int main(int argc, char** argv) { volatile int i ; int j ; - + + PRECONbits.PFMWS = 2; + PRECONbits.PREFEN = 0b11; + init_serial() ; /* initialize PIC32MZ serial I/O */ SYSTEMConfigPerformance(80000000); DBINIT(); + for(j=0; j<100; j++) { + for(i=0; i<10000000; i++); + printf("time=%f\n", current_time(0)) ; + } printf("wolfCrypt Benchmark:\n"); #ifndef NO_AES