有点好奇这个芯片的coremark跑分,STM手册里数据这个数据在56MHZ时是136,也就是取得了2.39coremark/MHZ的成绩,接着第一篇测评贴自己动手试试看看自己环境是不是编译环境是不是有差距。
clone coremark代码
git clone https://github.com/eembc/coremark
创建coremark工程
因coremark依赖printf,所以最好以Projects/NUCLEO-U083RC/Examples/UART/UART_Printf/为模板创建coremark工程
cp -a Projects/NUCLEO-U083RC/Examples/UART/UART_Printf/ Projects/NUCLEO-U083RC/Examples/coremark
拷贝coremark相关文件
把前面clone下的coremark中顶级目录下的*.c文件和*.h文件,以及simple目录下的*.c和*.h拷贝到Projects/NUCLEO-U083RC/Examples/coremark/
CMakeLists.txt修改
相对于点灯用的CMakelists.txt,这次改动如下
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 554b81a..e4e6c85 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,7 +17,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
add_compile_options(-mthumb -mcpu=cortex-m0plus)
-add_compile_options(-ffunction-sections -fdata-sections -fno-strict-aliasing -fno-builtin -fno-common -Wall -Wshadow -Wdouble-promotion -Werror -Wno-unused-parameter)
+add_compile_options(-ffunction-sections -fdata-sections -fno-builtin -fno-common -Wall -Wshadow -Wdouble-promotion -Werror -Wno-unused-parameter)
add_compile_options(-O3)
@@ -28,22 +28,23 @@ set(CMAKE_C_STANDARD 99)
include_directories(Drivers/CMSIS/Include/
Drivers/CMSIS/Device/ST/STM32U0xx/Include/
Drivers/STM32U0xx_HAL_Driver/Inc/
- Projects/NUCLEO-U083RC/Examples_LL/GPIO/GPIO_InfiniteLedToggling_Init/Inc/)
+ Drivers/BSP/STM32U0xx_Nucleo/
+ Projects/NUCLEO-U083RC/Examples/coremark/Inc/)
add_definitions(-DSTM32U083xx -DUSE_FULL_LL_DRIVER)
file(GLOB_RECURSE SOURCES
"Drivers/STM32U0xx_HAL_Driver/Src/*.c"
- "Projects/NUCLEO-U083RC/Examples_LL/GPIO/GPIO_InfiniteLedToggling_Init/Src/*.c"
- "Projects/NUCLEO-U083RC/Examples_LL/GPIO/GPIO_InfiniteLedToggling_Init/STM32CubeIDE/Application/User/*.c"
- "Projects/NUCLEO-U083RC/Examples_LL/GPIO/GPIO_InfiniteLedToggling_Init/STM32CubeIDE/Application/Startup/startup_stm32u083rctx.s"
+ "Projects/NUCLEO-U083RC/Examples/coremark/Src/*.c"
+ "Projects/NUCLEO-U083RC/Examples/coremark/STM32CubeIDE/Application/User/*.c"
+ "Projects/NUCLEO-U083RC/Examples/coremark/STM32CubeIDE/Application/Startup/startup_stm32u083rctx.s"
)
-set(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/Projects/NUCLEO-U083RC/Examples_LL/GPIO/GPIO_InfiniteLedToggling_Init/STM32CubeIDE/STM32U083RCTX_FLASH.ld)
+set(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/Projects/NUCLEO-U083RC/Examples/coremark/STM32CubeIDE/STM32U083RCTX_FLASH.ld)
add_link_options(
-mthumb -mcpu=cortex-m0plus
-Wl,--gc-sections,--print-memory-usage,-Map,${PROJECT_NAME}.map
- --specs=nano.specs
+ --specs=nano.specs -u_printf_float
--specs=nosys.specs)
add_link_options(-T ${LINKER_SCRIPT})
core_portme.c修改
时间相关的改成下面这样:
#define GETMYTIME(_t) (*_t = HAL_GetTick())
core_portme.h加入:
#define COMPILER_FLAGS "-O3"
uart的相关设置
UART_Printf工程的UART默认设置是UART_PARITY_ODD,所以要么PC机串口终端匹配设置,要么把它改成UART_PARITY_NONE,也即
MX_USART2_UART_Init(void)函数中
huart2.Init.Parity = UART_PARITY_NONE;
stm32u0xx_it.c的SysTick_Handler修改成这样
void SysTick_Handler(void)
{
/* USER CODE BEGIN SysTick_IRQn 0 */
/* USER CODE END SysTick_IRQn 0 */
HAL_IncTick();
/* USER CODE BEGIN SysTick_IRQn 1 */
/* USER CODE END SysTick_IRQn 1 */
}
跑分结果如下
数据分析
特意把SysClockFreq的频率给打印出来了,coremark/MHZ数据算下来只有官方的81.2%,个人分析编译器是一个影响因素,另外官方的数据是不是开了ART的cache?
|