stm32f407 Coremark score:439
(2016-08-06 14:28:53)
https://www.eembc.org/coremark/login.php?url=download_coremark.php
GPIO_WriteBit(GPIOA,GPIO_Pin_0,
Bit_SET);
GPIO_WriteBit(GPIOB,GPIO_Pin_0,
Bit_SET);
GPIO_WriteBit(GPIOA,GPIO_Pin_0,
Bit_RESET);
GPIO_WriteBit(GPIOB,GPIO_Pin_0,
Bit_RESET);
#ifdef DEBUG
debug();
#endif
RCC_Configuration();
Timer_configuration ();
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOG, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOH, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOI, ENABLE);
GPIOA->BSRRH = 0xFFFFFFFF;
GPIOB->BSRRH = 0xFFFFFFFF;
GPIOC->BSRRH = 0xFFFFFFFF;
GPIOD->BSRRH = 0xFFFFFFFF;
GPIOE->BSRRH = 0xFFFFFFFF;
GPIOF->BSRRH = 0xFFFFFFFF;
GPIOG->BSRRH = 0xFFFFFFFF;
GPIOH->BSRRH = 0xFFFFFFFF;
GPIOI->BSRRH = 0xFFFFFFFF;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, DISABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, DISABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, DISABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, DISABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, DISABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF, DISABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOG, DISABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOH, DISABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOI, DISABLE);
// MCU_RX -> PB7
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource6,
GPIO_AF_USART1);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource7,
GPIO_AF_USART1);
GPIO_InitStructure.GPIO_OType =
GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd =
GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Mode =
GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Speed =
GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Mode =
GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
GPIO_Init(GPIOB,
&GPIO_InitStructure);
USART_InitTypeDef
USART_InitStructure;
USART_InitStructure.USART_BaudRate =
115200;
USART_InitStructure.USART_WordLength =
USART_WordLength_8b;
USART_InitStructure.USART_StopBits =
USART_StopBits_1;
USART_InitStructure.USART_Parity =
USART_Parity_No ;
USART_InitStructure.USART_HardwareFlowControl =
USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode =
USART_Mode_Rx | USART_Mode_Tx;
USART_Init(USART1,
&USART_InitStructure);
USART_Cmd(USART1, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2,
ENABLE);
TIM_TimeBaseStructure.TIM_Period =
0xffffffff;
TIM_TimeBaseStructure.TIM_Prescaler =
0;
TIM_TimeBaseStructure.TIM_ClockDivision =
0;
TIM_TimeBaseStructure.TIM_CounterMode =
TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM2,
&TIM_TimeBaseStructure);
TIM_PrescalerConfig(TIM2, 1,
TIM_PSCReloadMode_Immediate);
TIM_Cmd(TIM2, ENABLE);
while (1)
{
}
#ifdef __GNUC__
#define COMPILER_VERSION
"GCC"__VERSION__
#else
#define COMPILER_VERSION "uVision5.15 -
ARMCCV5.05 update 2 (build 169)"
#endif
#define COMPILER_FLAGS "--device DLM -O3
-Otime --apcs=interwork"
#define MEM_LOCATION "FLASH"
return (CmdLine);
// ToDo: Send Character to Terminal
if (ch=='\n') fputc('\r',f);
USART_SendData(USART1, (uint8_t) ch);
while(USART_GetFlagStatus(USART1,
USART_FLAG_TXE) == RESET)
{
}
return (ch);
先去下载Coremark, 添加core_list_join.c
,core_main.c,core_state.c,core_matrix.c,core_util.c到工程。在core_portme.c中配置
timer,uart,rcc. 在我自己的stm32f407 discovery板子上配置如下:
core_portme.c
#include "coremark.h"
#include "core_portme.h"
#define CODE_POSITION 1
#define IO_OFF_POLARIZED 0
#define MCO_ENABLE
0
#define ART_ON 1
#include "stm32f4xx.h"
#include "stm32f4xx_gpio.h"
#include "stm32f4xx_tim.h"
#include "stm32f4xx_usart.h"
RCC_ClocksTypeDef RCC_ClockFreq;
GPIO_InitTypeDef GPIO_InitStructure;
TIM_TimeBaseInitTypeDef
TIM_TimeBaseStructure;
ErrorStatus HSEStartUpStatus;
void RCC_Configuration(void);
void USART_Configuration(int BaudRate);
void Timer_configuration(void);
#if VALIDATION_RUN
volatile ee_s32 seed1_volatile=0x3415;
volatile ee_s32 seed2_volatile=0x3415;
volatile ee_s32 seed3_volatile=0x66;
#endif
#if PERFORMANCE_RUN
volatile ee_s32 seed1_volatile=0x0;
volatile ee_s32 seed2_volatile=0x0;
volatile ee_s32 seed3_volatile=0x66;
#endif
#if PROFILE_RUN
volatile ee_s32 seed1_volatile=0x8;
volatile ee_s32 seed2_volatile=0x8;
volatile ee_s32 seed3_volatile=0x8;
#endif
volatile ee_s32 seed4_volatile=ITERATIONS;
volatile ee_s32 seed5_volatile=0;
#define NSECS_PER_SEC CLOCKS_PER_SEC
#define CORETIMETYPE ee_u32
#define GETMYTIME(_t) (*_t=TIM_GetCounter(TIM2))
#define MYTIMEDIFF(fin,ini) ((fin)-(ini) )
#define TIMER_RES_DIVIDER 1
#define SAMPLE_TIME_IMPLEMENTATION 1
#define EE_TICKS_PER_SEC (NSECS_PER_SEC /
TIMER_RES_DIVIDER)
static CORETIMETYPE start_time_val, stop_time_val;
void start_time(void) {
GETMYTIME(&start_time_val );
}
void stop_time(void) {
GETMYTIME(&stop_time_val );
}
CORE_TICKS get_time(void) {
CORE_TICKS elapsed=(CORE_TICKS)(MYTIMEDIFF(stop_time_val,
start_time_val));
return elapsed;
}
secs_ret time_in_secs(CORE_TICKS ticks) {
secs_ret retval=((secs_ret)ticks) /
(secs_ret)EE_TICKS_PER_SEC;
return retval;
}
ee_u32 default_num_contexts=1;
void portable_init(core_portable *p, int *argc, char
*argv[])
{
if (sizeof(ee_ptr_int) != sizeof(ee_u8 *)) {
ee_printf("ERROR! Please define ee_ptr_int to a type that
holds a pointer!\n");
}
if (sizeof(ee_u32) != 4) {
ee_printf("ERROR! Please define ee_u32 to a 32b unsigned
type!\n");
}
p->portable_id=1;
#if IO_OFF_POLARIZED
#else
// MCU_TX -> PB6
USART_Configuration(115200);
#endif
}
void portable_fini(core_portable *p)
{
p->portable_id=0;
}
void USART_Configuration(int BaudRate)
{
}
void Timer_configuration(void)
{
}
void RCC_Configuration(void)
{
RCC_GetClocksFreq(&RCC_ClockFreq);
}
void assert_failed(uint8_t* file, uint32_t line)
{
}
core_portme.h
#ifndef CORE_PORTME_H
#define CORE_PORTME_H
#define ITERATIONS
2000
#define CLOCKS_PER_SEC 42000000
#define ee_printf
printf
#define ee_size_t
size_t
#ifndef HAS_FLOAT
#define HAS_FLOAT 1
#endif
#ifndef HAS_TIME_H
#define HAS_TIME_H 0
#endif
#ifndef USE_CLOCK
#define USE_CLOCK 0
#endif
#ifndef HAS_STDIO
#define HAS_STDIO 1
#endif
#ifndef HAS_PRINTF
#define HAS_PRINTF 0
#endif
#ifndef COMPILER_VERSION
#endif
#ifndef COMPILER_FLAGS
#endif
#ifndef MEM_LOCATION
#endif
typedef signed short ee_s16;
typedef unsigned short ee_u16;
typedef signed int ee_s32;
typedef double ee_f32;
typedef unsigned char ee_u8;
typedef unsigned int ee_u32;
typedef ee_u32 ee_ptr_int;
typedef ee_u32 CORE_TICKS;
#define align_mem(x) (void *)(4 + (((ee_ptr_int)(x) - 1) &
~3))
#ifndef SEED_METHOD
#define SEED_METHOD SEED_VOLATILE
#endif
#ifndef MEM_METHOD
#define MEM_METHOD MEM_STATIC
#endif
#ifndef MULTITHREAD
#define MULTITHREAD 1
#define USE_PTHREAD 0
#define USE_FORK 0
#define USE_SOCKET 0
#endif
#ifndef MAIN_HAS_NOARGC
#define MAIN_HAS_NOARGC 0
#endif
#ifndef MAIN_HAS_NORETURN
#define MAIN_HAS_NORETURN 0
#endif
#include "stm32f4xx_rcc.h"
extern ee_u32 default_num_contexts;
extern RCC_ClocksTypeDef RCC_ClockFreq;
typedef struct CORE_PORTABLE_S {
ee_u8 portable_id;
} core_portable;
void portable_init(core_portable *p, int *argc, char
*argv[]);
void portable_fini(core_portable *p);
#if !defined(PROFILE_RUN) && !defined(PERFORMANCE_RUN)
&& !defined(VALIDATION_RUN)
#if (TOTAL_DATA_SIZE==1200)
#define PROFILE_RUN 1
#elif (TOTAL_DATA_SIZE==2000)
#define PERFORMANCE_RUN 1
#else
#define VALIDATION_RUN 1
#endif
#endif
#endif
retarget.c
#include "stm32f4xx_usart.h"
#include "stm32f4xx.h"
#include
#include
#pragma import(__use_no_semihosting)
char CmdLine[] = "";
char * _sys_command_string(char *cmd, int len) {
}
void _ttywrch(int ch) {
}
void _sys_exit(int return_code) {
label: goto label;
}
struct __FILE { int handle; };
FILE __stdout;
FILE __stdin;
// simplified fputc version that only redirects STDOUT
int fputc(int ch, FILE *f) {
// redirect STDOUT
}
core_main.c
#include "coremark.h"
static ee_u16 list_known_crc[] =
{(ee_u16)0xd4b0,(ee_u16)0x3340,(ee_u16)0x6a79,(ee_u16)0xe714,(ee_u16)0xe3c1};
static ee_u16 matrix_known_crc[] =
{(ee_u16)0xbe52,(ee_u16)0x1199,(ee_u16)0x5608,(ee_u16)0x1fd7,(ee_u16)0x0747};
static ee_u16 state_known_crc[] =
{(ee_u16)0x5e47,(ee_u16)0x39bf,(ee_u16)0xe5a4,(ee_u16)0x8e3a,(ee_u16)0x8d84};
void *iterate(void *pres) {
ee_u32 i;
ee_u16 crc;
core_results *res=(core_results *)pres;
ee_u32 iterations=res->iterations;
res->crc=0;
res->crclist=0;
res->crcmatrix=0;
res->crcstate=0;
for (i=0; i
crc=core_bench_list(res,1);
res->crc=crcu16(crc,res->crc);
crc=core_bench_list(res,-1);
res->crc=crcu16(crc,res->crc);
if (i==0) res->crclist=res->crc;
}
return NULL;
}
#if (SEED_METHOD==SEED_ARG)
ee_s32 get_seed_args(int i, int argc, char *argv[]);
#define get_seed(x) (ee_s16)get_seed_args(x,argc,argv)
#define get_seed_32(x) get_seed_args(x,argc,argv)
#else
ee_s32 get_seed_32(int i);
#define get_seed(x) (ee_s16)get_seed_32(x)
#endif
#if (MEM_METHOD==MEM_STATIC)
ee_u8 static_memblk[TOTAL_DATA_SIZE];
#endif
char *mem_name[3] = {"Static","Heap","Stack"};
int main(int argc, char *argv[]) {
ee_u16 i,j=0,num_algorithms=0;
ee_s16 known_id=-1,total_errors=0;
ee_u16 seedcrc=0;
CORE_TICKS total_time;
core_results results[MULTITHREAD];
portable_init(&(results[0].port), &argc, argv);
if (sizeof(struct list_head_s)>128) {
ee_printf("list_head structure too big for comparable
data!\n");
return MAIN_RETURN_VAL;
}
results[0].seed1=get_seed(1);
results[0].seed2=get_seed(2);
results[0].seed3=get_seed(3);
results[0].iterations=get_seed_32(4);
results[0].iterations=0;
#if CORE_DEBUG
results[0].iterations=1;
#endif
results[0].execs=get_seed_32(5);
if (results[0].execs==0) {
results[0].execs=ALL_ALGORITHMS_MASK;
}
//#if (MEM_METHOD==MEM_STATIC)
results[0].memblock[0]=(void *)static_memblk;
results[0].size=TOTAL_DATA_SIZE;
results[0].err=0;
for (i=0; i
if ((1<<(ee_u32)i) & results[0].execs)
num_algorithms++;
}
for (i=0 ; i
results[i].size=results[i].size/num_algorithms;
for (i=0; i
ee_u32 ctx;
if ((1<<(ee_u32)i) & results[0].execs) {
for (ctx=0 ; ctx
results[ctx].memblock[i+1]=(char
*)(results[ctx].memblock[0])+results[0].size*j;
j++;
}
}
for (i=0 ; i
if (results[i].execs & ID_LIST) {
results[i].list=core_list_init(results[0].size,results[i].memblock[1],results[i].seed1);
}
if (results[i].execs & ID_MATRIX) {
core_init_matrix(results[0].size, results[i].memblock[2],
(ee_s32)results[i].seed1 | (((ee_s32)results[i].seed2) <<
16), &(results[i].mat) );
}
if (results[i].execs & ID_STATE) {
core_init_state(results[0].size,results[i].seed1,results[i].memblock[3]);
}
}
if (results[0].iterations==0) {
secs_ret secs_passed=0;
ee_u32 divisor;
results[0].iterations=1;
while (secs_passed < (secs_ret)1) {
results[0].iterations*=10;
start_time();
iterate(&results[0]);
stop_time();
secs_passed=time_in_secs(get_time());
}
divisor=(ee_u32)secs_passed;
if (divisor==0)
divisor=1;
results[0].iterations*=1+10/divisor;
}
start_time();
// #if (MULTITHREAD>1)
iterate(&results[0]);
stop_time();
total_time=get_time();
seedcrc=crc16(results[0].seed1,seedcrc);
seedcrc=crc16(results[0].seed2,seedcrc);
seedcrc=crc16(results[0].seed3,seedcrc);
seedcrc=crc16(results[0].size,seedcrc);
switch (seedcrc) {
case 0x8a02:
known_id=0;
ee_printf("6k performance run parameters for
coremark.\n");
break;
case 0x7b05:
known_id=1;
ee_printf("6k validation run parameters for
coremark.\n");
break;
case 0x4eaf:
known_id=2;
ee_printf("Profile generation run parameters for
coremark.\n");
break;
case 0xe9f5:
known_id=3;
ee_printf("2K performance run parameters for
coremark.\n");
break;
case 0x18f2:
known_id=4;
ee_printf("2K validation run parameters for
coremark.\n");
break;
default:
total_errors=-1;
break;
}
if (known_id>=0) {
for (i=0 ; i
results[i].err=0;
if ((results[i].execs & ID_LIST)
&&
(results[i].crclist!=list_known_crc[known_id])) {
ee_printf("[%u]ERROR! list crc 0xx - should be
0xx\n",i,results[i].crclist,list_known_crc[known_id]);
results[i].err++;
}
if ((results[i].execs & ID_MATRIX) &&
(results[i].crcmatrix!=matrix_known_crc[known_id])) {
ee_printf("[%u]ERROR! matrix crc 0xx - should be
0xx\n",i,results[i].crcmatrix,matrix_known_crc[known_id]);
results[i].err++;
}
if ((results[i].execs & ID_STATE) &&
(results[i].crcstate!=state_known_crc[known_id])) {
ee_printf("[%u]ERROR! state crc 0xx - should be
0xx\n",i,results[i].crcstate,state_known_crc[known_id]);
results[i].err++;
}
total_errors+=results[i].err;
}
}
total_errors+=check_data_types();
ee_printf("SYSCLK_Frequency : %lu\n",(unsigned
long)RCC_ClockFreq.SYSCLK_Frequency );
ee_printf("HCLK_Frequency :
%lu\n",(unsigned long)RCC_ClockFreq.HCLK_Frequency );
ee_printf("PCLK2_Frequency :
%lu\n",(unsigned long)RCC_ClockFreq.PCLK2_Frequency );
ee_printf("TIM2_Frequency :
%lu\n",(unsigned long)RCC_ClockFreq.PCLK1_Frequency );
ee_printf("CoreMark Size
: %lu\n",(ee_u32)results[0].size);
ee_printf("Total ticks
: %lu\n",(ee_u32)total_time);
//#if HAS_FLOAT
ee_printf("Total time (secs):
%f\n",time_in_secs(total_time));
if (time_in_secs(total_time) > 0)
ee_printf("Iterations/Sec :
%f\n",default_num_contexts*results[0].iterations/time_in_secs(total_time));
if (time_in_secs(total_time) < 10) {
ee_printf("ERROR! Must execute for at least 10 secs for a
valid result!\n");
total_errors++;
}
// ee_printf("Iterations
:
%lu\n",(ee_u32)default_num_contexts*results[0].iterations);
ee_printf("Compiler version : %s\n",COMPILER_VERSION);
ee_printf("Compiler flags :
%s\n",COMPILER_FLAGS);
ee_printf("Memory location :
%s\n",MEM_LOCATION);
ee_printf("seedcrc
:
0xx\n",seedcrc);
if (results[0].execs & ID_LIST)
for (i=0 ; i
ee_printf("[%d]crclist
: 0xx\n",i,results[i].crclist);
if (results[0].execs & ID_MATRIX)
for (i=0 ; i
ee_printf("[%d]crcmatrix
: 0xx\n",i,results[i].crcmatrix);
if (results[0].execs & ID_STATE)
for (i=0 ; i
ee_printf("[%d]crcstate
: 0xx\n",i,results[i].crcstate);
for (i=0 ; i
ee_printf("[%d]crcfinal
: 0xx\n",i,results[i].crc);
if (total_errors==0) {
ee_printf("Correct operation validated. See readme.txt for run
and reporting rules.\n");
#if HAS_FLOAT
if (known_id==3) {
ee_printf("CoreMark 1.0 : %f / %s
%s",default_num_contexts*results[0].iterations/time_in_secs(total_time),COMPILER_VERSION,COMPILER_FLAGS);
//#if defined(MEM_LOCATION) &&
!defined(MEM_LOCATION_UNSPEC)
ee_printf(" / %s",MEM_LOCATION);
ee_printf("\n");
}
#endif
}
if (total_errors>0)
ee_printf("Errors detected\n");
if (total_errors<0)
ee_printf("Cannot validate operation for these seed values,
please compare with results on a known platform.\n");
portable_fini(&(results[0].port));
return MAIN_RETURN_VAL;
}
后一篇:装XP系统