HPM6750学习笔记

HPM6750学习笔记

资料

  1. 官网
  2. 【先楫HPM6750系列】HPM SDK开发环境搭建和Hello World
  3. 先辑高性能RISC-V MCU应用笔记
  4. RISC-V嵌入式开发入门篇1:RISC-V GCC工具链的介绍
  5. [先楫HPM6750测评之九]细说性能提升的优化方法

SEGGER Embedded Studio 常规配置

  1. 格式化等号对齐
    Tools->Options->Text Editor-> formatting 将Align Consecutive Assignments 修改成 Yes 。

  2. 显示每行行号

    Tools->Options->Text Editor-> Visual Appearance 将Line Numbers 修改成 All Lines 。

  3. 全局搜索大小写不敏感

    Tools->Options->Environment-> File Search -> Match Case

  4. 设置Ctrl + Left Click 动作

    在一些编辑器通常会有Ctrl + Left Click的动作,一般是跳转到定义,SES默认是没有这个动作的,可以通过设置来配置
    Tools->Options->Text Editor-> Mouse 将 Ctrl+Left Click Action 修改成 Go To Definition。

  5. 用户配置文件在%LOCALAPPDATA%\SEGGER目录,配置文件为settings.xml

启动方式

  1. BOOT拨码对应的启动模式,参考开发板使用手册:
拨码状态 启动模式 说明
00 XPI NOR启动 从连接在XPI0/1 上的串行NOR FLASH 启动
01 串行启动UART0/USB-HID 从UART0/USB0 上启动
10 在系统编程(ISP) 从UART0/USB0 上烧写固件,OTP
11 保留模式 保留模式
  1. generate_project的-t选项选择不同的值,编译后,内存使用统计图的显示也会不同(-t本身就是用于指定不同的存储设备配置的),经本人实验,发现-t选项的不同值的作用如下:
调试版 发布版(更小) 下载目标位置 程序运行内存
debug release 片内SRAM 片内SRAM
flash_xip flash_xip_release FLASH芯片 片内SRAM
flash_sdram_xip flash_sdram_xip_release FLASH芯片 DRAM芯片

​ 生成的类型里有flash的代表下载到flash,有sdram的代表外挂sdram,把一些缓存数据丢到sdram,有uf2的代表适配TinyUF2 bootloader例程,release比debug优化多一些。

  1. generate_project -t选项和BOOT拨码的对应关系
generate_project -t选项 BOOT拨码建议 说明
debug/release 10/01 下载到片内SRAM,速度较快
flash_xip/flash_xip_release 00 下载到FLASH芯片,速度较慢
flash_sdram_xip/flash_sdram_xip_release 00 下载到FLASH芯片,速度较慢;运行时使用DRAM,内存较大

大佬的聊天记录

1.硬件浮点

1. cmakelist

1
2
3
4
5
6
7
#单精度
sdk_ses_compile_options(-mabi=ilp32f)
sdk_ses_compile_options(-march=rv32imafc)
#双精度
sdk_ses_compile_options(-mabi=ilp32d)
##sdk_ses_compile_options(-march=rv32gc)
sdk_ses_compile_options(-march=rv32imafc)

测试代码 矩阵乘法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
void MatrixMultiply(uint8_t m1, uint8_t n1, uint8_t m2, uint8_t n2, 
double M1[], double M2[], double M3[])
{
uint8_t i, j, k;
double Sum;

for(i=0;i<m1;i++)
{
for(j=0;j<n2;j++)
{
Sum = 0.0;

for ( k=0; k<n1; k++)
{
Sum = Sum + *(M1+i*n1+k) * *(M2+k*n2+j);
}

*(M3+i*n2+j) = Sum;
}
}
}

double test_a[50][50];
double test_b[50][50];
double test_c[50][50];
uint32_t test_time2,test_time3,test_time1,system_time1;
void test_ecu(void)
{
uint8_t i=0,j=0,p=0;

test_time1= sysy_time;
for(i=0;i<50;i++)
{
for(j=0;j<50;j++)
{
test_a[i][j]=4.056424+0.1*j+0.2*i;
test_b[i][j]=3.015+0.1*j+0.2*i;
}
}
for(p=0;p<20;p++)
{
MatrixMultiply(50,50,50,50,&test_a[0][0],&test_b[0][0],&test_c[0][0]);
}
test_time2= sysy_time;
test_time3=test_time2-test_time1;
printf("%d\n",test_time3);
}

知识点

  1. 32位 long是4位

Linker文件

代码从FLASH->RAM

  1. 代码

    1
    2
    3
    void __attribute((section(".ramfunc"))) MyFunc(void) {
    ...
    }
  2. linker

    1
    2
    place in RAM { section .ramfunc };
    initialize by copy { section .ramfunc };

    initialize by copy 是必要的。

    The initialize by copy is required as the linker assumes that all sections containing readexecute code are implicitly present at system startup, even if they have been placed into
    RAM. The initialize by copy overrides the default handling of this particular section and
    instructs the linker to make an image of the section and copy it to its final destination on
    system startup.

  3. 注意点:高级别优化加noinline

    1
    void __attribute((section(“.ramfunc”), noinline)) MyFunc(void) …

    At high optimization levels the compiler may make an inline copy of a function even
    though it is declared to be in a nondefault section. To ensure that the function is indeed
    run from RAM the compiler must be told not to inline the function

作者

GWJ

发布于

2022-06-09

更新于

2023-03-16

许可协议

评论