Code Monkey home page Code Monkey logo

hpmicro / hpm_sdk Goto Github PK

View Code? Open in Web Editor NEW
106.0 11.0 27.0 172.24 MB

No PR will be accepted for now, but feel free to submit issue, very appreciated.

Home Page: https://hpm-sdk.readthedocs.io/

License: BSD 3-Clause "New" or "Revised" License

CMake 0.27% C 91.78% Batchfile 0.01% Shell 0.02% Assembly 1.00% Roff 0.02% HTML 4.06% CSS 0.04% JavaScript 0.42% C++ 2.22% Java 0.10% Makefile 0.01% Python 0.05% Perl 0.01%
mcu motor-control riscv embedded real-time cherryusb eclipse-threadx freertos gpu hmi

hpm_sdk's People

Contributors

jhqian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hpm_sdk's Issues

sm4 算法的速度

测试 rom sm4 api 速度发现与软件计算的速度相差很小,芯片带的 sm4 只是内置一个软件函数,没有任何硬件加速吗?

some typing error in hpm_pwm_drv.c and hpm_pwm_drv.h

in hpm_pwm_drv.h line 696: the function "void pwm_get_captured_count(..."
in hpm_pwm_drv.c line 24: the function "void pwm_get_count(..."
I think they reffer to the same function, should be typing error, please check it

编译可变参函数的工具链问题

当函数为可变参形式时,比如
int func(char* buff, unsigned buffsize, const char* format, ...);

当可变参中有64位参数时,或者使用ilp32d的浮点参数时,调用这个函数会生成错误的calling convention。
例如:
int64_t v64 = 0x123456789ABCDEF0;
func(buff, sizeof(buff), "%lld", v64);

会为常量字符串生成32位地址加载指令对儿,
lui a2, 0x?????(HIGH20)
addi a2, a2, 0x???(LOW12)

当可变参数量稍微多几个时,出现分配寄存器错误,如
func(buff, sizeof(buff), "%d %lld %u", v32, v64, v32);
lui a5, 0x?????(HIGH20)
addi a2, a5, 0x???(LOW12) // a2 is the const char* format, global address in .rodata section
占用了 a5,而调用规约里的 a5 用于后面的可变参数,导致函数体内解析不到 a5 承载的参数。

此问题在 sdk1.4.0 附带工具链(gcc-11.1-2022.04.12-riscv32-unknown-elf)中发现,
经测试,sdk1.5.0 附带工具链中依然存在

在Linux环境下定义了HPM_SDK_BASE但是hpm-sdk-config.cmake依然报错

CMake 环境:

$ cmake --version
cmake version 3.25.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).

相关代码

if(NOT DEFINED $ENV{HPM_SDK_BASE})
message(FATAL_ERROR "HPM_SDK_BASE is not set yet")
endif()
经过测试,删除'$ENV'的'$'即可通过,不知是CMake的什么特性

vector.h 使用RTOS和中断向量模式Bug

vector.h文件25行,在使用RTOS,且中断使用向量模式时,中断向量表0位置应该放置RTOS的trap_handler 而不应该再放置irq_handler_trap,所以为了兼容是否使用RTOS、是否使用中断向量模式,是否应该修改为 " .set default_isr_trap, HANDLER_TRAP"

openocd_algo example compile out too big

compare exist openocd hpm_xpi algorithm small size. the openocd_algo example compile out about 41KB size. included C lib support APIs. the $(HPM_SDK)/drivers/*.c some vars.

HPM SDK version is 1.1.0.

How to remove these unused symbols? reduce the code size. the "-ffunction-sections", "-fdata-sections" seem already used. but "--gc-sections" seem the rv32imac-ilp32-multilib-win toolchain did not supported.

A missing bit in pla_filter_cfg

sdk versiong:hpm_sdk v1.1.0
file name: drivers/inc/hpm_pla_drv.h

typedef union pla_filter_cfg {
  struct {
      uint32_t sync_edge_filter_disable:1;
      uint32_t software_inject:2;
      uint32_t filter_reverse:1;
      uint32_t edge_dect_en:1;
      uint32_t nege_edge_dect_en:1;
      uint32_t pose_edge_dect_en:1;
      uint32_t filter_sync_level:1;
      uint32_t filter_ext_en:1;
      uint32_t reserved:3;
      uint32_t filter_ext_type:3;
      uint32_t filter_ext_counter:16;
  };
  uint32_t val;
} pla_filter_cfg_t;

This struct should have 32bit, but only 31bit here. There should be 1 reserved bit between filter_ext_type and filter_ext_counter according to UM. Please check.

Where to grab the toolchain?

I'm trying to get a Hello World sample project running for my HPM6200EVK_RevB board. Unfortunately, I got stuck.

I followed all the installation steps pointed out on https://github.com/hpmicro/hpm_sdk

The only step I could not understand completely, is this one:

Grab a copy of toolchain zip package and unzip to certain path, take TOOLCHAIN_PATH for example, (riscv32-unknown-elf-gcc is supposed to be found in TOOLCHAIN_PATH/bin)

This step does not explain where to grab a copy of the toolchain. I have no idea where that toolchain is. Perhaps this one:
https://github.com/hpmicro/riscv-gnu-toolchain/releases/tag/2022.05.15

But it has no build for Windows. Where can I find a Windows toolchain for HPMicro?

HPM6284IEP2的PWM0启用hrpwm后触发故障保护后无法恢复

如题,无论是使用hrpmw例程基础上添加故障保护还是自己写的程序都一样

使用hrpwm例程在generate_edge_aligned_waveform内做如下改动:

修改定义适配硬件

// hrpwm.c:17
#define HRPWM HPM_PWM0
#define PWM_CLOCK_NAME clock_mot0
#define PWM_OUTPUT_PIN1 0
#define PWM_OUTPUT_PIN2 1
#define TRGM HPM_TRGM0

// pinmux.c
void init_hrpwm_pins(PWM_Type *ptr)
{
    if (ptr == HPM_PWM0) {
        HPM_IOC->PAD[IOC_PAD_PB12].FUNC_CTL = IOC_PB12_FUNC_CTL_PWM0_P_0;
        HPM_IOC->PAD[IOC_PAD_PB13].FUNC_CTL = IOC_PB13_FUNC_CTL_PWM0_P_1;
        HPM_IOC->PAD[IOC_PAD_PB14].FUNC_CTL = IOC_PB14_FUNC_CTL_PWM0_P_2;
        HPM_IOC->PAD[IOC_PAD_PB15].FUNC_CTL = IOC_PB15_FUNC_CTL_PWM0_P_3;
        HPM_IOC->PAD[IOC_PAD_PB16].FUNC_CTL = IOC_PB16_FUNC_CTL_PWM0_P_4;
        HPM_IOC->PAD[IOC_PAD_PB17].FUNC_CTL = IOC_PB17_FUNC_CTL_PWM0_P_5;
    }
}

配置故障电平及恢复方式的代码

    pwm_config.fault_mode = pwm_fault_mode_force_output_0;
    pwm_config.fault_recovery_trigger = pwm_fault_recovery_on_reload;

配置故障保护的代码,添加在pwm_setup_waveform之后

    /* 开启debug故障保护模式 */
    pwm_fault_source_config_t fault_config = {};
    fault_config.source_mask = PWM_GCR_DEBUGFAULT_SET(1);
    pwm_config_fault_source(HRPWM, &fault_config);

函数末尾for循环内写一个死循环将程序卡住方便操作

现象:
进入调试后启动程序生成波形,点击暂停运行触发故障保护波形消失,继续运行波形不能恢复
若注释pwm_enable_hrpwm(HRPWM);不启用hrpwm功能则能正常恢复

关于RGMII的描述

手册里面是这么描述的:拨码开关的第 3 位是用来选择对应 IO 是当千兆网接口或电机接口。当拨到 ON 档,对应引脚是选择板上 PWM输出,当拨到 OFF 档,对应引脚是选择板上千兆网接口。
而在开发板正对SW1的丝印层上,左上角是“1”,左下角是“RGMII”,与手册描述相反。

是否考虑支持NuttX实时系统?

无人机飞行控制系统,特别需要高性能的MCU。而例如开源的PX4飞控,主要基于Nuttx RTOS,现在STM32H7和NXP RT1060都支持了,希望也能支持Hpmicro的芯片,多一个国产选择。

FOC例程在HPM5361环境中DMA缓冲区长度不对会产生DMA越界

如题,在HPM5361环境中DMA缓冲区长度不对会产生DMA越界
5361v03手册54.2.8中的描述是抢占模式的DMA会占用一块192字节的缓冲区,实际分配为160字节
手册中对DMA如何写入内存的方式描述不清楚,是特定触发写入特定区域内存还是192字节全部都会写入
https://github.com/hpmicro/hpm_sdk/blob/b612c6fda97a8d16de16b80bf06fa54f15043496/samples/motor_ctrl/bldc_foc/src/bldc_foc.c#L40C6-L40C6

HPM6750 SDK did not support disable compress instruction

Hi :
i did not want program generate 16bit compress instruction, change the ARCH to the "rv32ima". use gcc toolchain.
But found the SDK_DECLARE_EXT_ISR_M use Assembler 16 bit instruction doing optimization in board.c.
why did not add Assembler 32 bit instruction optimization?

SDK version: 1.2.0
Board: hpm6750evkmini.
toolchain: rv32imac-ilp32-multilib-win

hello_world编译没问题,试了一下cam,出了些链接错误

在cam目录下执行以下命令
hpm_sdk\samples\drivers\cam>generate_project -b hpm6750evk
segger es编译输出如下:
Building ‘cam_example’ from solution ‘cam_example’ in configuration ‘Debug’
Compiling ‘cam.c’
Compiling ‘hpm_uart_drv.c’
Compiling ‘hpm_dram_drv.c’
Compiling ‘hpm_sdp_drv.c’
Compiling ‘hpm_lcdc_drv.c’
Compiling ‘hpm_i2c_drv.c’
Compiling ‘hpm_pmp_drv.c’
Compiling ‘hpm_rng_drv.c’
Compiling ‘hpm_gpio_drv.c’
Compiling ‘hpm_spi_drv.c’
Compiling ‘hpm_pdma_drv.c’
Compiling ‘hpm_wdg_drv.c’
Compiling ‘hpm_dma_drv.c’
Compiling ‘hpm_gptmr_drv.c’
Compiling ‘hpm_pwm_drv.c’
Compiling ‘hpm_pllctl_drv.c’
Compiling ‘hpm_usb_drv.c’
Compiling ‘hpm_rtc_drv.c’
Compiling ‘hpm_acmp_drv.c’
Compiling ‘hpm_i2s_drv.c’
Compiling ‘hpm_dao_drv.c’
Compiling ‘hpm_pdm_drv.c’
Compiling ‘hpm_vad_drv.c’
Compiling ‘hpm_cam_drv.c’
Compiling ‘hpm_can_drv.c’
Compiling ‘hpm_jpeg_drv.c’
Compiling ‘hpm_enet_drv.c’
Compiling ‘hpm_sdxc_drv.c’
Compiling ‘hpm_adc12_drv.c’
Compiling ‘hpm_adc16_drv.c’
Compiling ‘hpm_pmu_drv.c’
Compiling ‘hpm_ptpc_drv.c’
Compiling ‘hpm_mchtmr_drv.c’
Compiling ‘hpm_debug_console.c’
Compiling ‘hpm_ov7725.c’
Compiling ‘hpm_camera_ov7725.c’
Compiling ‘pinmux.c’
Compiling ‘board.c’
Compiling ‘hpm_swap.c’
Compiling ‘hpm_ffssi.c’
Compiling ‘reset.c’
Compiling ‘trap.c’
Assembling ‘startup.s’
Compiling ‘system.c’
Compiling ‘hpm_sysctl_drv.c’
Compiling ‘hpm_l1c_drv.c’
Compiling ‘hpm_clock_drv.c’
Compiling ‘hpm_otp_drv.c’
Linking cam_example.elf
multiply defined global symbol _flash_size
defined by [ Linker created ]
and by [ Linker created ]
multiply defined global symbol _extram_size
defined by [ Linker created ]
and by [ Linker created ]
multiply defined global symbol _flash_size
defined by [ Linker created ]
and by [ Linker created ]
multiply defined global symbol _extram_size
defined by [ Linker created ]
and by [ Linker created ]
Build failed

1.0.0版本sdkCAN例程bug

  1. board_can_send_multiple_messages里 tx_buf.dlc = 8; 书写错误 应为can_payload_size_8 ; 其他几个测试demo也类似的问题
  2. hpm_can_drv.h里can_read_received_message 无法读空接收buffer. 会造成数据积压在缓冲区. 不建议在中断里配合CAN_EVENT_RECEIVE标志使用; 如果使用需要判断buff是否读空了. 否则建议使用can_receive_message_blocking

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.