For PIC32MZ

This commit is contained in:
Takashi Kojo
2013-11-10 20:42:21 +09:00
parent 25e2117a84
commit a4e61cbdbb
23 changed files with 288 additions and 83 deletions

10
mplabx/PIC32MZ-Putc.c Normal file
View File

@@ -0,0 +1,10 @@
#ifdef MICROCHIP_PIC32
#if defined (__32MZ2048ECH144__) || defined (__32MZ2048ECM144__)
void _mon_putc (char c)
{
while (U2STAbits.UTXBF);
U2TXREG = c;
}
#endif
#endif

28
mplabx/PIC32MZ-serial.h Normal file
View File

@@ -0,0 +1,28 @@
void _mon_putc(char c);
static void init_serial() {
#ifdef MICROCHIP_PIC32
#if defined (__32MZ2048ECH144__) || (__32MZ2048ECM144__)
/* Set up PB2 divisor for UART2 */
SYSKEY = 0x00000000;
SYSKEY = 0xAA996655;
SYSKEY = 0x556699AA;
PB2DIV = 0x00008018;
SYSKEY = 0x33333333;
/* UART2 Init */
// U2BRG = 0x0C;
U2BRG = 0x7;
ANSELBCLR = 0x4000;
ANSELGCLR = 0x0040;
RPB14R = 0x02;
U2RXR = 0x01;
U2MODE = 0x8000;
U2STA = 0x400;
#elif defined __PIC32MX__
SYSTEMConfigPerformance(80000000);
DBINIT();
#endif
#endif
}

View File

@@ -1,4 +1,4 @@
/* main.c
/* benchmark_main.c
*
* Copyright (C) 2006-2013 wolfSSL Inc.
*
@@ -18,12 +18,20 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#define PIC32_STARTER_KIT
#include <p32xxxx.h>
#include <plib.h>
#include <sys/appio.h>
#if defined(CYASSL_MICROCHIP_PIC32MZ)
#define MICROCHIP_PIC32
#include <xc.h>
#pragma config ICESEL = ICS_PGx2
/* ICE/ICD Comm Channel Select (Communicate on PGEC2/PGED2) */
#include "PIC32MZ-serial.h"
#define SYSTEMConfigPerformance /* void out SYSTEMConfigPerformance(); */
#else
#define PIC32_STARTER_KIT
#include <p32xxxx.h>
#include <plib.h>
#include <sys/appio.h>
#define init_serial() /* void out init_serial() ; */
#endif
void bench_des(void);
void bench_arc4(void);
@@ -50,11 +58,14 @@ void bench_eccKeyAgree(void);
* Main driver for CTaoCrypt benchmarks.
*/
int main(int argc, char** argv) {
SYSTEMConfigPerformance(80000000);
volatile int i ;
int j ;
init_serial() ; /* initialize PIC32MZ serial I/O */
SYSTEMConfigPerformance(80000000);
DBINIT();
printf("CTaoCrypt Benchmark:\n");
printf("wolfCrypt Benchmark:\n");
#ifndef NO_AES
bench_aes(0);
@@ -110,7 +121,7 @@ int main(int argc, char** argv) {
bench_eccKeyGen();
bench_eccKeyAgree();
#endif
printf("End of wolfCrypt Benchmark:\n");
return 0;
}

View File

@@ -12,8 +12,8 @@
<logicalFolder name="SourceFiles"
displayName="Source Files"
projectFiles="true">
<itemPath>main.c</itemPath>
<itemPath>../../ctaocrypt/benchmark/benchmark.c</itemPath>
<itemPath>../benchmark_main.c</itemPath>
</logicalFolder>
<logicalFolder name="ExternalFiles"
displayName="Important Files"
@@ -21,6 +21,9 @@
<itemPath>Makefile</itemPath>
</logicalFolder>
</logicalFolder>
<sourceRootList>
<Elem>..</Elem>
</sourceRootList>
<projectmakefile>Makefile</projectmakefile>
<confs>
<conf name="default" type="2">
@@ -31,8 +34,8 @@
<targetPluginBoard></targetPluginBoard>
<platformTool>SKDEPIC32PlatformTool</platformTool>
<languageToolchain>XC32</languageToolchain>
<languageToolchainVersion>1.10</languageToolchainVersion>
<platform>4</platform>
<languageToolchainVersion>1.30</languageToolchainVersion>
<platform>3</platform>
</toolsSet>
<compileType>
<linkerTool>
@@ -44,8 +47,8 @@
AC="true"
BL="true"
WD="../cyassl.X"
BC="${MAKE} -f Makefile CONF=default"
DBC="${MAKE} -f Makefile CONF=default TYPE_IMAGE=DEBUG_RUN"
BC="${MAKE} MAKE_OPTIONS=&quot;&quot; -f Makefile CONF=default"
DBC="${MAKE} MAKE_OPTIONS=&quot;&quot; -f Makefile CONF=default TYPE_IMAGE=DEBUG_RUN"
CC="rm -rf &quot;build/default&quot; &quot;dist/default&quot;"
OP="dist/default/production/cyassl.X.a"
DOP="dist/default/debug/cyassl.X.a"
@@ -81,7 +84,7 @@
<property key="generate-16-bit-code" value="false"/>
<property key="isolate-each-function" value="false"/>
<property key="make-warnings-into-errors" value="false"/>
<property key="optimization-level" value="-O3"/>
<property key="optimization-level" value="-O1"/>
<property key="place-data-into-section" value="false"/>
<property key="post-instruction-scheduling" value="default"/>
<property key="pre-instruction-scheduling" value="default"/>
@@ -90,6 +93,7 @@
<property key="strict-ansi" value="false"/>
<property key="support-ansi" value="false"/>
<property key="use-cci" value="false"/>
<property key="use-iar" value="false"/>
<property key="use-indirect-calls" value="false"/>
</C32>
<C32-AS>
@@ -123,6 +127,7 @@
<property key="linker-symbols" value=""/>
<property key="map-file" value=""/>
<property key="no-startup-files" value="false"/>
<property key="oXC32ld-extra-opts" value=""/>
<property key="optimization-level" value="-O3"/>
<property key="preprocessor-macros" value=""/>
<property key="remove-unused-sections" value="false"/>
@@ -158,9 +163,10 @@
</C32CPP>
<C32Global>
<property key="legacy-libc" value="false"/>
<property key="save-temps" value="false"/>
<property key="wpo-lto" value="false"/>
</C32Global>
<SKDEPIC32PlatformTool>
<property key="whatToProgram" value="all"/>
</SKDEPIC32PlatformTool>
</conf>
</confs>

View File

@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://www.netbeans.org/ns/project/1">
<type>com.microchip.mplab.nbide.embedded.makeproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/make-project/1">

View File

@@ -13,8 +13,8 @@
<logicalFolder name="SourceFiles"
displayName="Source Files"
projectFiles="true">
<itemPath>main.c</itemPath>
<itemPath>../../ctaocrypt/test/test.c</itemPath>
<itemPath>../test_main.c</itemPath>
</logicalFolder>
<logicalFolder name="ExternalFiles"
displayName="Important Files"
@@ -22,6 +22,9 @@
<itemPath>Makefile</itemPath>
</logicalFolder>
</logicalFolder>
<sourceRootList>
<Elem>..</Elem>
</sourceRootList>
<projectmakefile>Makefile</projectmakefile>
<confs>
<conf name="default" type="2">
@@ -32,8 +35,8 @@
<targetPluginBoard></targetPluginBoard>
<platformTool>SKDEPIC32PlatformTool</platformTool>
<languageToolchain>XC32</languageToolchain>
<languageToolchainVersion>1.10</languageToolchainVersion>
<platform>4</platform>
<languageToolchainVersion>1.30</languageToolchainVersion>
<platform>3</platform>
</toolsSet>
<compileType>
<linkerTool>
@@ -45,8 +48,8 @@
AC="true"
BL="true"
WD="../cyassl.X"
BC="${MAKE} -f Makefile CONF=default"
DBC="${MAKE} -f Makefile CONF=default TYPE_IMAGE=DEBUG_RUN"
BC="${MAKE} MAKE_OPTIONS=&quot;&quot; -f Makefile CONF=default"
DBC="${MAKE} MAKE_OPTIONS=&quot;&quot; -f Makefile CONF=default TYPE_IMAGE=DEBUG_RUN"
CC="rm -rf &quot;build/default&quot; &quot;dist/default&quot;"
OP="dist/default/production/cyassl.X.a"
DOP="dist/default/debug/cyassl.X.a"
@@ -82,7 +85,7 @@
<property key="generate-16-bit-code" value="false"/>
<property key="isolate-each-function" value="false"/>
<property key="make-warnings-into-errors" value="false"/>
<property key="optimization-level" value="-Os"/>
<property key="optimization-level" value="-O3"/>
<property key="place-data-into-section" value="false"/>
<property key="post-instruction-scheduling" value="default"/>
<property key="pre-instruction-scheduling" value="default"/>
@@ -91,6 +94,7 @@
<property key="strict-ansi" value="false"/>
<property key="support-ansi" value="false"/>
<property key="use-cci" value="false"/>
<property key="use-iar" value="false"/>
<property key="use-indirect-calls" value="false"/>
</C32>
<C32-AS>
@@ -124,6 +128,7 @@
<property key="linker-symbols" value=""/>
<property key="map-file" value=""/>
<property key="no-startup-files" value="false"/>
<property key="oXC32ld-extra-opts" value=""/>
<property key="optimization-level" value="-Os"/>
<property key="preprocessor-macros" value=""/>
<property key="remove-unused-sections" value="true"/>
@@ -159,9 +164,10 @@
</C32CPP>
<C32Global>
<property key="legacy-libc" value="false"/>
<property key="save-temps" value="false"/>
<property key="wpo-lto" value="false"/>
</C32Global>
<SKDEPIC32PlatformTool>
<property key="whatToProgram" value="all"/>
</SKDEPIC32PlatformTool>
</conf>
</confs>

View File

@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://www.netbeans.org/ns/project/1">
<type>com.microchip.mplab.nbide.embedded.makeproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/make-project/1">

View File

@@ -49,6 +49,7 @@
<itemPath>../../ctaocrypt/src/sha256.c</itemPath>
<itemPath>../../ctaocrypt/src/sha512.c</itemPath>
<itemPath>../../ctaocrypt/src/tfm.c</itemPath>
<itemPath>../../ctaocrypt/src/port.c</itemPath>
</logicalFolder>
<logicalFolder name="ExternalFiles"
displayName="Important Files"
@@ -58,6 +59,8 @@
</logicalFolder>
<sourceRootList>
<Elem>..</Elem>
<Elem>../../cyassl/ctaocrypt</Elem>
<Elem>../../ctaocrypt/src</Elem>
</sourceRootList>
<projectmakefile>Makefile</projectmakefile>
<confs>
@@ -69,8 +72,8 @@
<targetPluginBoard></targetPluginBoard>
<platformTool>SKDEPIC32PlatformTool</platformTool>
<languageToolchain>XC32</languageToolchain>
<languageToolchainVersion>1.10</languageToolchainVersion>
<platform>4</platform>
<languageToolchainVersion>1.30</languageToolchainVersion>
<platform>3</platform>
</toolsSet>
<compileType>
<archiverTool>
@@ -92,11 +95,11 @@
<property key="enable-symbols" value="false"/>
<property key="enable-unroll-loops" value="false"/>
<property key="exclude-floating-point" value="false"/>
<property key="extra-include-directories" value="../../"/>
<property key="extra-include-directories" value="../../;..\"/>
<property key="generate-16-bit-code" value="false"/>
<property key="isolate-each-function" value="false"/>
<property key="make-warnings-into-errors" value="false"/>
<property key="optimization-level" value="-Os"/>
<property key="optimization-level" value="-O3"/>
<property key="place-data-into-section" value="false"/>
<property key="post-instruction-scheduling" value="default"/>
<property key="pre-instruction-scheduling" value="default"/>
@@ -105,6 +108,7 @@
<property key="strict-ansi" value="false"/>
<property key="support-ansi" value="false"/>
<property key="use-cci" value="false"/>
<property key="use-iar" value="false"/>
<property key="use-indirect-calls" value="false"/>
</C32>
<C32-AS>
@@ -138,6 +142,7 @@
<property key="linker-symbols" value=""/>
<property key="map-file" value=""/>
<property key="no-startup-files" value="false"/>
<property key="oXC32ld-extra-opts" value=""/>
<property key="optimization-level" value="-Os"/>
<property key="preprocessor-macros" value=""/>
<property key="remove-unused-sections" value="true"/>
@@ -173,6 +178,8 @@
</C32CPP>
<C32Global>
<property key="legacy-libc" value="false"/>
<property key="save-temps" value="false"/>
<property key="wpo-lto" value="false"/>
</C32Global>
<SKDEPIC32PlatformTool>
<property key="whatToProgram" value="all"/>

View File

@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://www.netbeans.org/ns/project/1">
<type>com.microchip.mplab.nbide.embedded.makeproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/make-project/1">

View File

@@ -19,13 +19,24 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#define PIC32_STARTER_KIT
#include <stdio.h>
#include <stdlib.h>
#include <p32xxxx.h>
#include <plib.h>
#include <sys/appio.h>
#if defined(CYASSL_MICROCHIP_PIC32MZ)
#define MICROCHIP_PIC32
#include <xc.h>
#pragma config ICESEL = ICS_PGx2
/* ICE/ICD Comm Channel Select (Communicate on PGEC2/PGED2) */
#include <stdio.h>
#include <stdlib.h>
#include "PIC32MZ-serial.h"
#define SYSTEMConfigPerformance /* void out SYSTEMConfigPerformance(); */
#else
#define PIC32_STARTER_KIT
#include <stdio.h>
#include <stdlib.h>
#include <p32xxxx.h>
#include <plib.h>
#include <sys/appio.h>
#define init_serial() /* void out init_serial() */
#endif
/* func_args from test.h, so don't have to pull in other junk */
typedef struct func_args {
@@ -38,12 +49,12 @@ typedef struct func_args {
* Main driver for CTaoCrypt tests.
*/
int main(int argc, char** argv) {
int i ;
init_serial() ; /* initialize PIC32MZ serial I/O */
SYSTEMConfigPerformance(80000000);
DBINIT();
printf("CTaoCrypt Test:\n");
func_args args;
args.argc = argc;