[bsp][hpmicro] upgrade hpm_sdk to v1.13.0 and add hpm5100evk support

Sync the HPMicro BSPs with hpm_sdk v1.13.0 and add the HPM5100EVK
(HPM5151) board.

- add the hpm5100evk BSP (board/startup/applications/Kconfig/docs) and
  register it in .github/ALL_BSP_COMPILE.json, bsp/README.md and the
  HPMicro READMEs
- re-sync the 11 existing boards (board/startup/debug scripts/linker
  scripts/applications) with hpm_sdk v1.13.0, keeping the RT-Thread
  specific parts: clock_time based drv_timer, CXX wired into the scons
  environment, SConscript outputs under build/, named Kconfig choices,
  rt_hw_us_delay in board_delay_*, board local codec files
- sync the shared driver layer with hpm_sdk v1.13.0 (GPTMRv2/PTMR,
  PUART, soft I2C/SPI and the remaining peripheral driver updates)
- select the hpm_sdk v1.13.0 online package (PKG_USING_HPM_SDK_V113)
- use -Og instead of -O0 for the debug builds and print floats with the
  RT-Thread klibc implementation instead of newlib nano
- initialize the RT-Thread heap before the SDK console init: the SDK
  console_init() calls setvbuf(), which allocates through the C library
  malloc() and tripped RT_ASSERT() in rt_smem_alloc() on the boards
  built with RT_USING_DEBUG
- keep only ram_rtt.ld/flash_rtt.ld per board, align the DLM origin to
  4KB on hpm5300evk/hpm5301evklite (the unaligned origin made the
  linker emit a file backed PT_LOAD for the RAM area, which broke
  "program rtthread.elf"), and anchor the generated .bin at the flash
  base address 0x80000000
- sync the hpm6750evk openocd debug scripts with the new style used by
  the other boards (hpm_common.cfg/hpm_reset.cfg with arp_halt)

- keep the upstream synced board/startup/libraries trees of bsp/hpmicro out of the
  changed-file cppcheck run (same policy as bsp/hpmicro/.clang-format-ignore): the
  check runs without the hpm_sdk include paths, so it reports ATTR_PLACE_AT and the
  linker script symbol arithmetic in c_startup() as errors

- give the hpmicro boards in the changed-file scons trigger list the RV32 toolchain
  they need (RISC-V-GCC-RV32) and add the matching installation step to that
  workflow: the entries used sourcery-arm, which only provides the ARM toolchain,
  so those legs could not find riscv32-unknown-elf-gcc

- keep hpm5100evk's ram_rtt.ld identical to the hpm_sdk v1.13.0
  reference: the .fast_ram sections belong in DLM there (the DLM has
  enough headroom), and that also makes its RAM and flash layouts agree
- skip the dependency pre-check when cleaning (scons -c): it runs from
  DoBuilding() unconditionally, so a clean request with packages/ not
  fetched yet was aborted with exit code 1 instead of cleaning

- make the manual scons trigger workflow runnable: it aborted while still
  downloading actions because actions/upload-artifact@v3 is deprecated,
  and scons was not on PATH because ~/.env/env.sh was never sourced.
  Install tools/requirements.txt and source the Env PATH script in the
  build step, and use @main action versions, as bsp_buildings.yml does
- start the LED demo thread only when rt_thread_create() succeeded

Tested:
- 12 boards x {ram_debug, ram_release, flash_debug, flash_release}:
  48/48 clean builds
- flash boot + msh on hpm5100evk, hpm5300evk, hpm5e00evk, hpm6200evk,
  hpm6300evk, hpm6750evk, hpm6750evk2, hpm6750evkmini, hpm6800evk,
  hpm6e00evk, hpm6p00evk (list device/timer, ps, free, reset, rt_kprintf
  float formatting)

- re-ran .github/workflows/manual_trigger_scons_except_STM32_all.yml with
  the matrix reduced to the three hpmicro rows: all three legs build and
  scons --dist succeeds with no local workarounds
This commit is contained in:
Fan YANG authored and Rbb666 committed 2026-10-17 16:28:33 +08:00
1 parent 8d8dc96b67
commit fc64f78669
434 files changed
+23958 -16754

No files matched your search

+2 -1
View File
@@ -464,7 +464,8 @@
"hpmicro/hpm6800evk",
"hpmicro/hpm6e00evk",
"hpmicro/hpm6p00evk",
"hpmicro/hpm5e00evk"
"hpmicro/hpm5e00evk",
"hpmicro/hpm5100evk"
]
},
{
+14
View File
@@ -193,6 +193,20 @@
"bsp/hpmicro/tools"
]
},
{
"target_name": "hpmicro-hpm5100evk",
"toolchain": "riscv32-unknown-elf-multilib",
"bsp_path": "bsp/hpmicro/hpm5100evk",
"elf": "bsp/hpmicro/hpm5100evk/rtthread.elf",
"ld": "bsp/hpmicro/hpm5100evk/board/linker_scripts/gcc/flash_rtt.ld",
"map_file": "",
"linker_vars": "",
"watch_paths": [
"bsp/hpmicro/hpm5100evk",
"bsp/hpmicro/libraries",
"bsp/hpmicro/tools"
]
},
{
"target_name": "xuantie-e901plus",
"toolchain": "xuantie-elf-newlib",
@@ -124,8 +124,9 @@ jobs:
- {RTT_BSP_NAME: "hc32l196", RTT_TOOL_CHAIN: "sourcery-arm", RTT_BSP: "hc32l196"}
- {RTT_BSP_NAME: "hifive1", RTT_TOOL_CHAIN: "sourcery-riscv-none-embed", RTT_BSP: "hifive1"}
#- {RTT_BSP_NAME: "hk32_hk32f030c8-mini", RTT_TOOL_CHAIN: "sourcery-arm", RTT_BSP: "hk32/hk32f030c8-mini"} #scons dist有问题
- {RTT_BSP_NAME: "hpmicro_hpm6750evk", RTT_TOOL_CHAIN: "sourcery-arm", RTT_BSP: "hpmicro/hpm6750evk"}
- {RTT_BSP_NAME: "hpmicro_hpm6750evkmini", RTT_TOOL_CHAIN: "sourcery-arm", RTT_BSP: "hpmicro/hpm6750evkmini"}
- {RTT_BSP_NAME: "hpmicro_hpm5100evk", RTT_TOOL_CHAIN: "RISC-V-GCC-RV32", RTT_BSP: "hpmicro/hpm5100evk"}
- {RTT_BSP_NAME: "hpmicro_hpm6750evk", RTT_TOOL_CHAIN: "RISC-V-GCC-RV32", RTT_BSP: "hpmicro/hpm6750evk"}
- {RTT_BSP_NAME: "hpmicro_hpm6750evkmini", RTT_TOOL_CHAIN: "RISC-V-GCC-RV32", RTT_BSP: "hpmicro/hpm6750evkmini"}
- {RTT_BSP_NAME: "ht32f12366", RTT_TOOL_CHAIN: "sourcery-arm", RTT_BSP: "ht32/ht32f12366"}
- {RTT_BSP_NAME: "ht32f52352", RTT_TOOL_CHAIN: "sourcery-arm", RTT_BSP: "ht32/ht32f52352"}
#- {RTT_BSP_NAME: "imx_imx6ull-smart", RTT_TOOL_CHAIN: "sourcery-arm", RTT_BSP: "imx/imx6ull-smart"} # toolchain还没支持
@@ -294,7 +295,7 @@ jobs:
steps:
- uses: actions/checkout@main
- name: Set up Python
uses: actions/setup-python@v3
uses: actions/setup-python@main
with:
python-version: 3.8
@@ -305,9 +306,11 @@ jobs:
wget https://raw.githubusercontent.com/RT-Thread/env/master/install_ubuntu.sh
chmod 777 install_ubuntu.sh
./install_ubuntu.sh
pip install -r tools/requirements.txt
git config --global http.postBuffer 524288000
echo "RTT_ROOT=${{ github.workspace }}" >> $GITHUB_ENV
echo "RTT_CC=gcc" >> $GITHUB_ENV
echo "export PATH=~/.env/tools/scripts:$PATH" > ~/.env/env.sh
- name: Install Arm ToolChains
if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-arm' && success() }}
@@ -344,6 +347,14 @@ jobs:
/opt/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin/riscv64-unknown-elf-gcc --version
echo "RTT_EXEC_PATH=/opt/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin" >> $GITHUB_ENV
- name: Install riscv32-unknown-elf ToolChains
if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'RISC-V-GCC-RV32' && success() }}
run: |
wget -q https://github.com/hpmicro/riscv-gnu-toolchain/releases/download/2022.05.15/riscv32-unknown-elf-newlib-multilib_2022.05.15_linux.tar.gz
sudo tar zxf riscv32-unknown-elf-newlib-multilib_2022.05.15_linux.tar.gz -C /opt
/opt/riscv32-unknown-elf-newlib-multilib/bin/riscv32-unknown-elf-gcc --version
echo "RTT_EXEC_PATH=/opt/riscv32-unknown-elf-newlib-multilib/bin/" >> $GITHUB_ENV
- name: Install Riscv-none-embed ToolChains
if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-riscv-none-embed' && success() }}
run: |
@@ -373,7 +384,7 @@ jobs:
RTT_BSP: ${{ matrix.legs.RTT_BSP }}
RTT_TOOL_CHAIN: ${{ matrix.legs.RTT_TOOL_CHAIN }}
run: |
# source ~/.env/env.sh
source ~/.env/env.sh
echo $RTT_BSP
ls bsp/$RTT_BSP/Kconfig && scons -C bsp/$RTT_BSP --pyconfig-silent
sed -i "s/# ${{ github.event.inputs.bsp_config }} is not set/${{ github.event.inputs.bsp_config }}=y/g" bsp/$RTT_BSP/.config
@@ -386,7 +397,7 @@ jobs:
cp bsp/$RTT_BSP/dist/project.zip ${{ github.workspace }}/$RTT_BSP/
ls bsp/$RTT_BSP/dist
pwd
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@main
if: ${{ github.event.inputs.dist_flag }}
env:
RTT_BSP: ${{ matrix.legs.RTT_BSP }}
+1
View File
@@ -1 +1,2 @@
rtconfig.h
rtconfig_preinc.h
+1
View File
@@ -763,6 +763,7 @@ This document is based on the RT-Thread mainline repository and categorizes the
| [hpm6800evk](hpmicro/hpm6800evk) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | - | ✅ | ✅ | ✅ | - | ✅ | ✅ | ✅ |
| [hpm6e00evk](hpmicro/hpm6e00evk) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | - | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [hpm6p00evk](hpmicro/hpm6p00evk) | ✅ | ✅ | ✅ | ✅ | ✅ | - | - | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [hpm5100evk](hpmicro/hpm5100evk) | ✅ | ✅ | ✅ | ✅ | - | - | - | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
#### 🟢 K230 (RT-Smart)
+2 -1
View File
@@ -1,3 +1,4 @@
# clang-format ignore file
/**/startup/
/libraries/hpm_sdk/
/**/board/
/libraries/
+2
View File
@@ -0,0 +1,2 @@
# HPMicro SDK is fetched as an RT-Thread package into the shared libraries dir
/libraries/hpm_sdk-*/
+36
View File
@@ -0,0 +1,36 @@
# Exclude the files that are kept in sync with the upstream HPMicro sources
# (the all-in-one tree / hpm_sdk) from the changed-file checks, as already done
# for clang-format in .clang-format-ignore.
#
# tools/ci/cpp_check.py runs cppcheck with a minimal configuration (only
# '-I include -I thread/components/finsh'), so it cannot resolve the hpm_sdk
# macros used in these files (e.g. ATTR_PLACE_AT) and it reports the linker
# script symbol arithmetic in c_startup() as 'subtractPointers'; both are
# false positives for code that is not ours to restructure.
dir_path:
- hpm5100evk/board
- hpm5100evk/startup
- hpm5300evk/board
- hpm5300evk/startup
- hpm5301evklite/board
- hpm5301evklite/startup
- hpm5e00evk/board
- hpm5e00evk/startup
- hpm6200evk/board
- hpm6200evk/startup
- hpm6300evk/board
- hpm6300evk/startup
- hpm6750evk/board
- hpm6750evk/startup
- hpm6750evk2/board
- hpm6750evk2/startup
- hpm6750evkmini/board
- hpm6750evkmini/startup
- hpm6800evk/board
- hpm6800evk/startup
- hpm6e00evk/board
- hpm6e00evk/startup
- hpm6p00evk/board
- hpm6p00evk/startup
- libraries
+3 -1
View File
@@ -33,6 +33,7 @@ Below is a comprehensive list of HPMicro BSPs currently supported:
| hpm6800evk | HPM6800EVK | HPM6800 | Development board for HPM6800 series |
| hpm6e00evk | HPM6E00EVK | HPM6E00 | Development board for HPM6E00 series |
| hpm6p00evk | HPM6P00EVK | HPM6P00 | Development board for HPM6P00 series |
| hpm5100evk | HPM5100EVK | HPM5100 | Development board for HPM5100 series |
## Quick Start Guide
@@ -120,7 +121,7 @@ Additional peripherals may be supported depending on the specific board:
- HPM6E00EVK
- HPM6P00EVK
- HPM5E00EVK
- **CAN**: Available on HPM6750 series Development Boards, HPM5300EVK, HPM6800EVK, HPM6E00EVK, HPM6P00EVK and HPM5E00EVK
- **CAN**: Available on HPM6750 series Development Boards, HPM5300EVK, HPM6800EVK, HPM6E00EVK, HPM6P00EVK, HPM5E00EVK and HPM5100EVK
- **SDIO**: Available on HPM6300EVK, HPM6750EVKMINI, HPM6750EVK, HPM6750EVK2 and HPM6800EVK
- **Display/Audio**: Available on HPM6750EVK, HPM6800EVK, HPM6E00EVK,HPM6P00EVK
@@ -153,6 +154,7 @@ Please refer to the individual BSP directories for detailed documentation:
- `hpm6800evk/README.md`
- `hpm6e00evk/README.md`
- `hpm6p00evk/README.md`
- `hpm5100evk/README.md`
## Troubleshooting
+3 -1
View File
@@ -33,6 +33,7 @@
| hpm6800evk | HPM6800EVK | HPM6800 | HPM6800 系列开发板 |
| hpm6e00evk | HPM6E00EVK | HPM6E00 | HPM6E00 系列开发板 |
| hpm6p00evk | HPM6P00EVK | HPM6P00 | HPM6P00 系列开发板 |
| hpm5100evk | HPM5100EVK | HPM5100 | HPM5100 系列开发板 |
## 快速开始指南
@@ -120,7 +121,7 @@ msh >
- HPM6E00EVK
- HPM6P00EVK
- HPM5E00EVK
- **CAN**:HPM5300EVK、HPM6750系列开发板,HPM6300EVK,HPM6800EVK, HPM6E00EVK, HPM6P00EVK 和HPM5E00EVK
- **CAN**:HPM5300EVK、HPM6750系列开发板,HPM6300EVK,HPM6800EVK, HPM6E00EVK, HPM6P00EVK、HPM5E00EVK 和HPM5100EVK
- **SDIO**:HPM6300EVK、HPM6750EVK 系列可用
- **显示/音频**:HPM6750EVK 系列可用
@@ -152,6 +153,7 @@ msh >
- `hpm6800evk/README.md`
- `hpm6e00evk/README.md`
- `hpm6p00evk/README.md`
- `hpm5100evk/README.md`
## 故障排除
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+27
View File
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>blink_led</name>
<comment />
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.rt-thread.studio.rttnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>
@@ -0,0 +1,3 @@
content-types/enabled=true
content-types/org.eclipse.cdt.core.asmSource/file-extensions=s
eclipse.preferences.version=1
@@ -0,0 +1,20 @@
#RT-Thread Studio Project Configuration
# Fri Apr 25 13:53:29 2025
cfg_version=v3.0
board_name=
bsp_version=
bsp_path=
chip_name=
project_base_rtt_bsp=true
is_use_scons_build=true
hardware_adapter=
selected_rtt_version=latest
board_base_nano_proj=false
is_base_example_project=false
example_name=
project_type=rt-thread
os_branch=master
os_version=latest
project_name=blink_led
output_project_path=D:\oss\rt-thread\bsp\hpmicro\hpm5100evk
+12
View File
@@ -0,0 +1,12 @@
mainmenu "RT-Thread Configuration"
BSP_DIR := .
RTT_DIR := ../../..
PKGS_DIR := packages
source "$(RTT_DIR)/Kconfig"
osource "$PKGS_DIR/Kconfig"
rsource "../libraries/Kconfig"
rsource "board/Kconfig"
+115
View File
@@ -0,0 +1,115 @@
# HPMicro HPM5100EVK BSP(Board Support Package) Introduction
[中文页](README_zh.md) |
## Introduction
This document provides brief introduction of the BSP (board support package) for the HPM5100EVK development board.
The document consists of the following parts:
- HPM5100EVK Board Resources Introduction
- Quickly Getting Started
- Refreences
By reading the Quickly Get Started section developers can quickly get their hands on this BSP and run RT-Thread on the board. More advanced features will be introduced in the Advanced Features section to help developers take advantage of RT-Thread to drive more on-board resources.
## Board Resources Introduction
HPM5100EVK is a development board based on the RISC-V core launched by HPMicro, with rich on-board resources and on-chip resources for Connectivity, motor control,etc.
![board](figures/board.png)
## Peripheral Condition
Each peripheral supporting condition for this BSP is as follows:
| **On-board Peripherals** | **Support** | **Note** |
| ------------------------ | ----------- | ------------------------------------- |
| USB | √ | |
| QSPI Flash | √ | |
| CAN | √ | |
| AUDIO | √ | |
| GPIO | √ | |
| SPI | √ | |
| I2C | √ | |
| PWM | √ | |
| On-Board Debugger | √ | hslink-lite |
## Execution Instruction
### Quickly Getting Started
The BSP support being build via the 'scons' command, below is the steps of compiling the example via the 'scons' command
#### Parpare Environment
- Step 1: Prepare [RT-Thread ENV](https://www.rt-thread.org/download.html#download-rt-thread-env-tool)
- Step 2: Prepare [toolcahin](https://github.com/helloeagleyang/riscv32-gnu-toolchain-win/archive/2022.04.12.zip)
- Download the package and extract it into a specified directory, for example: `C:\DevTools\riscv32-gnu-toolchain`
- Step 3: Set environment variable `RTT_RISCV_TOOLCHAIN` to `<TOOLCHAIN_DIR>\bin`
- For example: `C:\DevTools\riscv32-gnu-toolchain\bin`
- Step 4: Prepare [OpenOCD](https://github.com/hpmicro/rtt-debugger-support-package/archive/v0.4.0.zip)
- Download and extract it to specified directory, for example: `C:\DevTools\openocd-hpmicro`
- Add `OpenOCD` environment variable `OPENOCD_HPMICRO` to `<OPENOCD_HPMICRO_DIR>\bin`
- For example: `C:\DevTools\openocd-hpmicro\bin`
#### Configure and Build project
Open RT-Thread ENV command-line, and change directory to this BSP directory, then users can:
- Configure the project via `menuconfig` in `RT-Thread ENV`
- Build the project using `scons -jN`, `N` equals to the number of CPU cores
- Clean the project using `scons -c`
#### Hardware Connection
- Switch BOOT pin to 2'b00
- Connect the `PWR_DEBUG` port to PC via TYPE-C cable
#### Dowload / Debug
- Users can download the project via the below command:
```console
%OPENOCD_HPMICRO%\openocd.exe -f board\debug_scripts\openocd\probes\cmsis_dap.cfg -f board\debug_scripts\openocd\soc\hpm5100.cfg -f board\debug_scripts\openocd\boards\hpm5100evk.cfg -c "init; halt; flash write_image erase rtthread.elf; reset; shutdown"
```
- Users can debug the project via the below command:
- Connect debugger via `OpenOCD`:
```console
%OPENOCD_HPMICRO%\openocd.exe -f board\debug_scripts\openocd\probes\cmsis_dap.cfg -f board\debug_scripts\openocd\soc\hpm5100.cfg -f board\debug_scripts\openocd\boards\hpm5100evk.cfg
```
- Start Debugger via `GDB`:
```console
%RTT_EXEC_PATH%\riscv32-unknown-elf-gdb.exe rtthread.elf
```
- In the `gdb shell`, type the following commands:
```console
load
c
```
### **Running Results**
Once the project is successfully downloaded, the system runs automatically. The LED on the board will flash periodically.
Connect the serial port of the board to the PC, communicate with it via a serial terminal tool(115200-8-1-N). Reset the board and the startup information of RT-Thread will be observed:
```
\ | /
- RT - Thread Operating System
/ | \ 5.2.2 build Aug 16 2025 18:18:18
2006 - 2025 Copyright by RT-Thread team
```
## **References**
- [RT-Thread Documnent Center](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/README)
- [RT-Thread Env](https://github.com/RT-Thread/rtthread-manual-doc/blob/master/env/env.md)
- [HPM5100EVK RT-Thread BSP Package](https://github.com/hpmicro/rtt-bsp-hpm5100evk)
+112
View File
@@ -0,0 +1,112 @@
# 先楫 HPM5100EVK BSP(板级支持包)说明
[English](README.md) |
## 简介
本文档为 HPM5100EVK 的 BSP (板级支持包) 说明。
本文包含如下部分:
- HPM5100EVK 板级资源介绍
- 快速上手指南
- 参考链接
通过阅读快速上手章节开发者可以快速地上手该 BSP,将 RT-Thread 运行在开发板上。在进阶使用指南章节,将会介绍更多高级功能,帮助开发者利用 RT-Thread 驱动更多板载资源。
## 板级资源介绍
HPM5100EVK 是由先楫半导体推出的一款基于RISCV内核的开发板,带有丰富的片上资源和板上资源,可用于网络互联和电机控制等应用。
开发板外观如下图所示:
![board](figures/board.png)
## 板载外设
本 BSP 目前对外设的支持情况如下:
| **板载外设** | **支持情况** | **备注** |
| ------------------------ | ----------- | ------------------------------------- |
| USB | √ | |
| QSPI Flash | √ | |
| GPIO | √ | |
| SPI | √ | |
| I2C | √ | |
| PWM | √ | |
| 板载调试器 | √ | hslink-lite |
## 使用说明
### 快速开始
本BSP支持通过`scons`命令来完成编译,在开始之前,需要先准备好开发所需的环境。
#### 准备环境
- 步骤 1: 准备 [RT-Thread ENV](https://www.rt-thread.org/download.html#download-rt-thread-env-tool)
- 步骤 2: 准备 [toolcahin](https://github.com/helloeagleyang/riscv32-gnu-toolchain-win/archive/2022.04.12.zip)
- 下载并解压到指定的目录,如: `C:\DevTools\riscv32-gnu-toolchain`
- 步骤 3: 设置环境变量: `RTT_RISCV_TOOLCHAIN` 为 `<TOOLCHAIN_DIR>\bin`, 如: `C:\DevTools\riscv32-gnu-toolchain\bin`
- 步骤 4: 准备 [OpenOCD](https://github.com/hpmicro/rtt-debugger-support-package/archive/v0.4.0.zip)
- 下载并解压到指定目录,如: `C:\DevTools\openocd-hpmicro`
- 将 `OPENOCD_HPMICRO`环境变量设置为 `<OPENOCD_HPMICRO_DIR>\bin`,如: `C:\DevTools\openocd-hpmicro\bin`
#### 配置和构建工程
通过 RT-Thread ENV 命令行切换目录到当前BSP所在目录后,用户可以:
- 通过 `menuconfig` 命令 配置RT-Thread BSP的功能
- 通过 `scons -jN` 命令完成构建, 其中`N` 最大值可以指定为CP拥有的物理内核数
- 通过 `scons -c` 命令清除构建
#### 硬件连接
- 将BOOT 引脚拨到2'b00
- 通过 TYPE-C线将板上的 `PWR_DEBUG` 连接到电脑
#### 下载 和 调试
- 通过如下命令完成下载:
```console
%OPENOCD_HPMICRO%\openocd.exe -f board\debug_scripts\openocd\probes\cmsis_dap.cfg -f board\debug_scripts\openocd\soc\hpm5100.cfg -f board\debug_scripts\openocd\boards\hpm5100evk.cfg -c "init; halt; flash write_image erase rtthread.elf; reset; shutdown"
```
- 通过如下命令实现调试:
- 通过 `OpenOCD` 来连接开发板:
```console
%OPENOCD_HPMICRO%\openocd.exe -f board\debug_scripts\openocd\probes\cmsis_dap.cfg -f board\debug_scripts\openocd\soc\hpm5100.cfg -f board\debug_scripts\openocd\boards\hpm5100evk.cfg
```
- 通过 `GDB` 实现调试:
```console
%RTT_EXEC_PATH%\riscv32-unknown-elf-gdb.exe rtthread.elf
```
- 在`GDB Shell`中使用如下命令来加载和运行:
```console
load
c
```
### **运行结果**
一旦成功下载,程序会自动运行并打印如下结果,板载LED灯会周期性闪烁。
配置好串口终端(串口配置为115200, 8-N-1),按复位键后,串口终端会打印如下日志:
```
\ | /
- RT - Thread Operating System
/ | \ 5.2.2 build Aug 16 2025 18:18:18
2006 - 2025 Copyright by RT-Thread team
```
## **参考链接**
- [RT-Thread 文档中心](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/README)
- [RT-Thread Env](https://github.com/RT-Thread/rtthread-manual-doc/blob/master/env/env.md)
- [HPM5100EVK RT-Thread BSP 包](https://github.com/hpmicro/rtt-bsp-hpm5100evk)
+16
View File
@@ -0,0 +1,16 @@
# for module compiling
import os
Import('RTT_ROOT')
from building import *
cwd = GetCurrentDir()
objs = []
list = os.listdir(cwd)
for d in list:
path = os.path.join(cwd, d)
if os.path.isfile(os.path.join(path, 'SConscript')):
objs = objs + SConscript(os.path.join(d, 'SConscript'))
Return('objs')
+83
View File
@@ -0,0 +1,83 @@
import os
import sys
import rtconfig
if os.getenv('RTT_ROOT'):
RTT_ROOT = os.getenv('RTT_ROOT')
else:
RTT_ROOT = os.path.normpath(os.getcwd() + '/../../..')
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
try:
from building import *
except:
print('Cannot found RT-Thread root directory, please check RTT_ROOT')
print(RTT_ROOT)
exit(-1)
def bsp_pkg_check():
if GetOption('clean'):
return
need_update = True
if os.path.isdir("packages"):
for p in os.listdir("packages"):
if p.startswith("hpm_sdk-"):
need_update = False
break
if need_update:
print("\n===============================================================================")
print("Dependency packages missing, please running 'pkgs --update'...")
print("If no packages are fetched, run 'pkgs --upgrade' first, then 'pkgs --update'...")
print("===============================================================================")
exit(1)
RegisterPreBuildingAction(bsp_pkg_check)
TARGET = 'rtthread.' + rtconfig.TARGET_EXT
AddOption('--run',
dest = 'run',
type='string',
nargs=1,
action = 'store',
default = "",
help = 'Upload or debug application using openocd')
DefaultEnvironment(tools=[])
env = Environment(tools = ['mingw'],
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
AR = rtconfig.AR, ARFLAGS = '-rc',
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS,
CXXCOM = '$CXX -o $TARGET -c $CXXFLAGS $_CCCOMCOM $SOURCES')
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
env['ASCOM'] = env['ASPPCOM']
Export('RTT_ROOT')
Export('rtconfig')
SDK_ROOT = os.path.abspath('./')
if os.path.exists(os.path.join(SDK_ROOT, 'libraries')):
libraries_path_prefix = os.path.join(SDK_ROOT, 'libraries')
else:
libraries_path_prefix = os.path.join(os.path.dirname(SDK_ROOT), 'libraries')
GDB = rtconfig.GDB
# prepare building environment
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
# includes rtt drivers
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'drivers', 'SConscript'), variant_dir='build/libraries/drivers', duplicate=0))
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'misc', 'SConscript'), variant_dir='build/libraries/misc', duplicate=0))
# make a building
DoBuilding(TARGET, objs)
@@ -0,0 +1,12 @@
from building import *
cwd = GetCurrentDir()
src = Glob('*.c')
CPPDEFINES=[]
CPPPATH = [cwd]
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES=CPPDEFINES)
Return('group')
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2021-2024 HPMicro
*
* Change Logs:
* Date Author Notes
* 2021-08-13 Fan YANG first version
*
*/
#include <rtthread.h>
#include <rtdevice.h>
#include "rtt_board.h"
void thread_entry(void *arg);
int main(void)
{
app_init_led_pins();
static uint32_t led_thread_arg = 0;
rt_thread_t led_thread = rt_thread_create("led_th", thread_entry, &led_thread_arg, 1024, 1, 10);
if (led_thread != RT_NULL)
{
rt_thread_startup(led_thread);
}
return 0;
}
void thread_entry(void *arg)
{
while (1)
{
app_led_write(0, APP_LED_ON);
rt_thread_mdelay(500);
app_led_write(0, APP_LED_OFF);
rt_thread_mdelay(500);
}
}
File diff suppressed because it is too large. Load diff
+19
View File
@@ -0,0 +1,19 @@
from building import *
cwd = GetCurrentDir()
# add the general drivers
src = Split("""
board.c
rtt_board.c
pinmux.c
fal_flash_port.c
fal_spi_flash_sfud_port.c
""")
CPPPATH = [cwd]
CPPDEFINES=['D25', 'HPM5151']
group = DefineGroup('Board', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES)
Return('group')
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,67 @@
# Copyright (c) 2026 HPMicro
# SPDX-License-Identifier: BSD-3-Clause
# openocd flash driver argument:
# - option0:
# [31:28] Flash probe type
# 0 - SFDP SDR / 1 - SFDP DDR
# 2 - 1-4-4 Read (0xEB, 24-bit address) / 3 - 1-2-2 Read(0xBB, 24-bit address)
# 4 - HyperFLASH 1.8V / 5 - HyperFLASH 3V
# 6 - OctaBus DDR (SPI -> OPI DDR)
# 8 - Xccela DDR (SPI -> OPI DDR)
# 10 - EcoXiP DDR (SPI -> OPI DDR)
# [27:24] Command Pads after Power-on Reset
# 0 - SPI / 1 - DPI / 2 - QPI / 3 - OPI
# [23:20] Command Pads after Configuring FLASH
# 0 - SPI / 1 - DPI / 2 - QPI / 3 - OPI
# [19:16] Quad Enable Sequence (for the device support SFDP 1.0 only)
# 0 - Not needed
# 1 - QE bit is at bit6 in Status Register 1
# 2 - QE bit is at bit1 in Status Register 2
# 3 - QE bit is at bit7 in Status Register 2
# 4 - QE bit is at bit1 in Status Register 2 and should be programmed by 0x31
# [15:8] Dummy cycles
# 0 - Auto-probed / detected / default value
# Others - User specified value, for DDR read, the dummy cycles should be 2 * cycles on FLASH datasheet
# [7:4] Misc.
# 0 - Not used
# 1 - SPI mode
# 2 - Internal loopback
# 3 - External DQS
# [3:0] Frequency option
# 1 - 30MHz / 2 - 50MHz / 3 - 66MHz / 4 - 80MHz / 5 - 100MHz / 6 - 120MHz / 7 - 133MHz / 8 - 166MHz
# - option1:
# [31:20] Reserved
# [19:16] IO voltage
# 0 - 3V / 1 - 1.8V
# [15:12] Pin group
# 0 - 1st group / 1 - 2nd group
# [11:8] Connection selection
# 0 - CA_CS0 / 1 - CB_CS0 / 2 - CA_CS0 + CB_CS0 (Two FLASH connected to CA and CB respectively)
# [7:0] Drive Strength
# 0 - Default value
# xpi0 configs
# - flash driver: hpm_xpi
# - flash ctrl index: 0xF00E0000
# - base address: 0x80000000
# - flash size: 0x2000000
# - flash option0: 0x5
# - flash option1: 0x1000
flash bank xpi0 hpm_xpi 0x80000000 0x2000000 1 1 $_TARGET0 0xF00E0000 0x5 0x1000
proc init_clock {} {
mww 0xF4000800 0xFFFFFFFF
mww 0xF4000810 0xFFFFFFFF
mww 0xF4000820 0xFFFFFFFF
mww 0xF4000830 0xFFFFFFFF
echo "clocks has been enabled!"
}
$_TARGET0 configure -event reset-init {
init_clock
}
$_TARGET0 configure -event gdb-attach {
reset halt
}
@@ -0,0 +1,17 @@
# Copyright (c) 2021-2026 HPMicro
# SPDX-License-Identifier: BSD-3-Clause
bindto 0.0.0.0
adapter speed 8000
adapter srst delay 500
source [find interface/cmsis-dap.cfg]
# Transport selection, defaults to jtag
# Override with e.g.: -c "set TRANSPORT cjtag" BEFORE -f options
if { ![info exists TRANSPORT] } {
set TRANSPORT jtag
}
transport select $TRANSPORT
reset_config srst_only
@@ -0,0 +1,15 @@
# Copyright 2021 hpmicro
# SPDX-License-Identifier: BSD-3-Clause
bindto 0.0.0.0
adapter speed 10000
reset_config trst_and_srst
adapter srst delay 50
adapter driver ftdi
ftdi_vid_pid 0x0403 0x6010
ftdi_layout_init 0x0208 0x020b
ftdi_layout_signal nTRST -data 0x0200 -noe 0x0400
ftdi_layout_signal nSRST -data 0x0100 -noe 0x0800
@@ -0,0 +1,14 @@
# Copyright 2021 hpmicro
# SPDX-License-Identifier: BSD-3-Clause
bindto 0.0.0.0
adapter speed 10000
reset_config trst_and_srst
adapter srst delay 50
adapter driver ftdi
ftdi_vid_pid 0x0403 0x6014
ftdi_layout_init 0x0018 0x001b
ftdi_layout_signal nTRST -data 0x0100 -noe 0x0400
ftdi_layout_signal nSRST -data 0x0200 -noe 0x0800
@@ -0,0 +1,11 @@
# Copyright 2021 hpmicro
# SPDX-License-Identifier: BSD-3-Clause
bindto 0.0.0.0
adapter speed 10000
adapter srst delay 500
source [find interface/jlink.cfg]
transport select jtag
reset_config srst_only
@@ -0,0 +1,14 @@
# Copyright 2021 hpmicro
# SPDX-License-Identifier: BSD-3-Clause
bindto 0.0.0.0
adapter speed 10000
adapter srst delay 500
reset_config srst_only
adapter driver ftdi
ftdi_vid_pid 0x0403 0x6010
ftdi_layout_init 0x0008 0x010b
ftdi_layout_signal nTRST -data 0x0100 -noe 0x0400
ftdi_layout_signal nSRST -data 0x0200 -noe 0x0800
@@ -1,7 +1,11 @@
# Copyright (c) 2021 HPMicro
# Copyright (c) 2025 HPMicro
# SPDX-License-Identifier: BSD-3-Clause
set _CHIP hpm5301
if { [info exists CHIPNAME] } {
set _CHIP $CHIPNAME
} else {
set _CHIP hpm5151
}
set _CPUTAPID 0x1000563D
jtag newtap $_CHIP cpu -irlen 5 -expected-id $_CPUTAPID
@@ -11,3 +15,10 @@ target create $_TARGET0 riscv -chain-position $_CHIP.cpu -coreid 0
$_TARGET0 configure -work-area-phys 0x00000000 -work-area-size 0x20000 -work-area-backup 0
targets $_TARGET0
source [file join [file dirname [info script]] hpm_common.cfg]
source [file join [file dirname [info script]] hpm_common_csr_lite.cfg]
proc reset_soc {} {
sba_write_mem 0xF410001C 24000000
}
@@ -0,0 +1,29 @@
# Copyright (c) 2025 HPMicro
# SPDX-License-Identifier: BSD-3-Clause
source [file join [file dirname [info script]] hpm_reset.cfg]
set dmsbcs 0x38
set dmsbaddress0 0x39
set dmsbdata0 0x3C
proc target0_dmi_write_reg {reg value} {
$::_TARGET0 riscv dmi_write ${reg} ${value}
}
proc target0_dmi_read_reg {reg} {
set v [$::_TARGET0 riscv dmi_read ${reg}]
return ${v}
}
proc sba_write_mem {addr value} {
target0_dmi_write_reg $::dmsbaddress0 ${addr}
target0_dmi_write_reg $::dmsbdata0 ${value}
}
proc sba_read_mem {addr} {
set sbcs [expr { 0x100000 | [target0_dmi_read_reg $::dmsbcs] }]
target0_dmi_write_reg $::dmsbcs ${sbcs}
target0_dmi_write_reg $::dmsbaddress0 ${addr}
set value [target0_dmi_read_reg $::dmsbdata0]
return ${value}
}
@@ -0,0 +1,101 @@
# Copyright (c) 2024 HPMicro
# SPDX-License-Identifier: BSD-3-Clause
# expose non-standard csr registers
# milmb
riscv expose_csrs 1984
# mdlmb
riscv expose_csrs 1985
# mecc_code
riscv expose_csrs 1986
# mnvec
riscv expose_csrs 1987
# mxstatus
riscv expose_csrs 1988
# mpft_ctl
riscv expose_csrs 1989
# mhsp_ctl
riscv expose_csrs 1990
# msp_bound
riscv expose_csrs 1991
# msp_base
riscv expose_csrs 1992
# mdcause
riscv expose_csrs 1993
# mcache_ctl
riscv expose_csrs 1994
# mcctlbeginaddr
riscv expose_csrs 1995
# mcctlcommand
riscv expose_csrs 1996
# mcctldata
riscv expose_csrs 1997
# mcounterwen
riscv expose_csrs 1998
# mcounterinten
riscv expose_csrs 1999
# mmisc_ctl
riscv expose_csrs 2000
# mcountermask_m
riscv expose_csrs 2001
# mcountermask_s
riscv expose_csrs 2002
# mcountermask_u
riscv expose_csrs 2003
# mcounterovf
riscv expose_csrs 2004
# mslideleg
riscv expose_csrs 2005
# mclk_ctl
riscv expose_csrs 2015
# dexc2dbg
riscv expose_csrs 2016
# ddcause
riscv expose_csrs 2017
# uitb
riscv expose_csrs 2048
# ucode
riscv expose_csrs 2049
# udcause
riscv expose_csrs 2057
# ucctlbeginaddr
riscv expose_csrs 2059
# ucctlcommand
riscv expose_csrs 2060
# slie
riscv expose_csrs 2500
# slip
riscv expose_csrs 2501
# sdcause
riscv expose_csrs 2505
# scctldata
riscv expose_csrs 2509
# scounterinten
riscv expose_csrs 2511
# scountermask_m
riscv expose_csrs 2513
# scountermask_s
riscv expose_csrs 2514
# scountermask_u
riscv expose_csrs 2515
# scounterovf
riscv expose_csrs 2516
# scountinhibit
riscv expose_csrs 2528
# shpmevent3
riscv expose_csrs 2531
# shpmevent4
riscv expose_csrs 2532
# shpmevent5
riscv expose_csrs 2533
# shpmevent6
riscv expose_csrs 2534
# micm_cfg
riscv expose_csrs 4032
# mdcm_cfg
riscv expose_csrs 4033
# mmsc_cfg
riscv expose_csrs 4034
# mmsc_cfg2
riscv expose_csrs 4035
@@ -0,0 +1,69 @@
# Copyright (c) 2024 HPMicro
# SPDX-License-Identifier: BSD-3-Clause
# expose non-standard csr registers
# milmb
riscv expose_csrs 1984
# mdlmb
riscv expose_csrs 1985
# mecc_code
riscv expose_csrs 1986
# mnvec
riscv expose_csrs 1987
# mxstatus
riscv expose_csrs 1988
# mpft_ctl
riscv expose_csrs 1989
# mhsp_ctl
riscv expose_csrs 1990
# msp_bound
riscv expose_csrs 1991
# msp_base
riscv expose_csrs 1992
# mdcause
riscv expose_csrs 1993
# mcache_ctl
riscv expose_csrs 1994
# mcctlbeginaddr
riscv expose_csrs 1995
# mcctlcommand
riscv expose_csrs 1996
# mcctldata
riscv expose_csrs 1997
# mcounterwen
riscv expose_csrs 1998
# mcounterinten
riscv expose_csrs 1999
# mmisc_ctl
riscv expose_csrs 2000
# mcountermask_m
riscv expose_csrs 2001
# mcountermask_s
riscv expose_csrs 2002
# mcountermask_u
riscv expose_csrs 2003
# mcounterovf
riscv expose_csrs 2004
# dexc2dbg
riscv expose_csrs 2016
# ddcause
riscv expose_csrs 2017
# uitb
riscv expose_csrs 2048
# ucode
riscv expose_csrs 2049
# udcause
riscv expose_csrs 2057
# ucctlbeginaddr
riscv expose_csrs 2059
# ucctlcommand
riscv expose_csrs 2060
# micm_cfg
riscv expose_csrs 4032
# mdcm_cfg
riscv expose_csrs 4033
# mmsc_cfg
riscv expose_csrs 4034
# mmsc_cfg2
riscv expose_csrs 4035
@@ -0,0 +1,9 @@
# Copyright (c) 2025 HPMicro
# SPDX-License-Identifier: BSD-3-Clause
$_TARGET0 configure -event reset-deassert-pre {
sleep 1
if {$halt} {
$::_TARGET0 arp_halt
}
}
+57
View File
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2025 HPMicro
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
#ifndef _FAL_CFG_H_
#define _FAL_CFG_H_
#include <rtconfig.h>
#include <board.h>
#ifdef RT_USING_FAL
#define NOR_FLASH_DEV_NAME "norflash0"
#define NOR_FLASH_MEM_BASE 0x80000000UL
#define NOR_FLASH_SIZE_IN_BYTES 0x100000UL
#define SPI_NOR_FLASH_DEV_NAME "spi_norflash0"
/* ===================== Flash device Configuration ========================= */
extern const struct fal_flash_dev stm32f2_onchip_flash;
extern struct fal_flash_dev nor_flash0;
#if defined(RT_USING_SFUD) && defined(BSP_USING_SPI)
extern struct fal_flash_dev spi_nor_flash0;
/* flash device table */
#define FAL_FLASH_DEV_TABLE \
{ \
&nor_flash0, \
&spi_nor_flash0, \
}
#else
/* flash device table */
#define FAL_FLASH_DEV_TABLE \
{ \
&nor_flash0, \
}
#endif
/* ====================== Partition Configuration ========================== */
#ifdef FAL_PART_HAS_TABLE_CFG
/* partition table */
// #ifdef (BSP_USING_SPI) && defined(RT_USING_SFUD) &&
#define FAL_PART_TABLE \
{ \
{FAL_PART_MAGIC_WORD, "app", NOR_FLASH_DEV_NAME, 0, 256*1024, 0}, \
{FAL_PART_MAGIC_WORD, "easyflash", NOR_FLASH_DEV_NAME, 256*1024, 256*1024, 0}, \
{FAL_PART_MAGIC_WORD, "download", NOR_FLASH_DEV_NAME, 512*1024, 256*1024, 0}, \
{FAL_PART_MAGIC_WORD, "flashdb", NOR_FLASH_DEV_NAME, 768*1024, 256*1024, 0}, \
{FAL_PART_MAGIC_WORD, "app", SPI_NOR_FLASH_DEV_NAME, 0, 6*1024*1024, 0}, \
{FAL_PART_MAGIC_WORD, "fs", SPI_NOR_FLASH_DEV_NAME, 6*1024*1024, 10*1024*1024, 0}, \
}
#endif /* FAL_PART_HAS_TABLE_CFG */
#endif /* RT_USING_FAL */
#endif /* _FAL_CFG_H_ */
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,86 @@
/*
* Copyright (c) 2022 hpmicro
*
* SPDX-License-Identifier: BSD-3-Clause
*
* Change Logs:
* Date Author Notes
* 2026-07-02 hpmicro First implementation
*
*/
#include <rtconfig.h>
#if defined(RT_USING_SFUD) && defined(BSP_USING_SPI) && defined(RT_USING_FAL)
#include <fal.h>
#include <sfud.h>
#include <dev_spi_flash_sfud.h>
static int init(void);
static int read(long offset, rt_uint8_t *buf, rt_size_t size);
static int write(long offset, const rt_uint8_t *buf, rt_size_t size);
static int erase(long offset, rt_size_t size);
static sfud_flash_t sfud_dev = NULL;
struct fal_flash_dev spi_nor_flash0 =
{
.name = SPI_NOR_FLASH_DEV_NAME,
.addr = 0,
.len = 16 * 1024 * 1024,
.blk_size = 4096,
.ops = {init, read, write, erase},
.write_gran = 1
};
static int init(void)
{
#ifdef RT_USING_SFUD
/* RT-Thread RTOS platform */
sfud_dev = rt_sfud_flash_find_by_dev_name(SPI_NOR_FLASH_DEV_NAME);
#endif
if (NULL == sfud_dev)
{
return -1;
}
/* update the flash chip information */
spi_nor_flash0.blk_size = sfud_dev->chip.erase_gran;
spi_nor_flash0.len = sfud_dev->chip.capacity;
return 0;
}
static int read(long offset, rt_uint8_t *buf, rt_size_t size)
{
RT_ASSERT(sfud_dev);
RT_ASSERT(sfud_dev->init_ok);
sfud_read(sfud_dev, spi_nor_flash0.addr + offset, size, buf);
return size;
}
static int write(long offset, const rt_uint8_t *buf, rt_size_t size)
{
RT_ASSERT(sfud_dev);
RT_ASSERT(sfud_dev->init_ok);
if (sfud_write(sfud_dev, spi_nor_flash0.addr + offset, size, buf) != SFUD_SUCCESS)
{
return -1;
}
return size;
}
static int erase(long offset, rt_size_t size)
{
RT_ASSERT(sfud_dev);
RT_ASSERT(sfud_dev->init_ok);
if (sfud_erase(sfud_dev, spi_nor_flash0.addr + offset, size) != SFUD_SUCCESS)
{
return -1;
}
return size;
}
#endif
@@ -1,24 +1,20 @@
/*
* Copyright 2021-2025 HPMicro
* Copyright 2025 HPMicro
* SPDX-License-Identifier: BSD-3-Clause
*/
ENTRY(_start)
STACK_SIZE = DEFINED(_stack_size) ? _stack_size : 0x4000;
HEAP_SIZE = DEFINED(_heap_size) ? _heap_size : 144K;
FLASH_SIZE = DEFINED(_flash_size) ? _flash_size : 16M;
NONCACHEABLE_SIZE = DEFINED(_noncacheable_size) ? _noncacheable_size : 0x4000;
HEAP_SIZE = DEFINED(_heap_size) ? _heap_size : 32K;
FLASH_SIZE = DEFINED(_flash_size) ? _flash_size : 1M;
MEMORY
{
XPI0 (rx) : ORIGIN = 0x80000000, LENGTH = FLASH_SIZE
ILM (wx) : ORIGIN = 0, LENGTH = 128K
DLM (w) : ORIGIN = 0x80000, LENGTH = 128K
NONCACHEABLE_RAM (wx) : ORIGIN = 0x01080000, LENGTH = 64K
AXI_SRAM (wx) : ORIGIN = 0x01090000, LENGTH = 176K
SHARE_RAM (w) : ORIGIN = 0x010BC000, LENGTH = 16K
AHB_SRAM (w) : ORIGIN = 0xF0300000, LENGTH = 32k
ILM (wx) : ORIGIN = 0x00000000, LENGTH = 256K
DLM (w) : ORIGIN = 0x00200000, LENGTH = 128K
AHB_SRAM (w) : ORIGIN = 0xF0200000, LENGTH = 32k
}
__nor_cfg_option_load_addr__ = ORIGIN(XPI0) + 0x400;
@@ -29,6 +25,15 @@ __app_offset__ = __app_load_addr__ - __boot_header_load_addr__;
SECTIONS
{
/* Anchor the lowest LMA at the flash base address (0x80000000): objcopy takes the
* lowest LMA as the start address of the generated .bin, so without this marker the
* .bin starts at .nor_cfg_option (0x80000400). The value is all ones (erased flash),
* so programming it does not change the flash state.
*/
.flash_base ORIGIN(XPI0) : {
LONG(0xFFFFFFFF)
} > XPI0
.nor_cfg_option __nor_cfg_option_load_addr__ : {
KEEP(*(.nor_cfg_option))
} > XPI0
@@ -53,7 +58,6 @@ SECTIONS
__vector_ram_start__ = .;
KEEP(*(.vector_table))
KEEP(*(.isr_vector))
. = ALIGN(16);
__vector_ram_end__ = .;
} > ILM
@@ -84,6 +88,9 @@ SECTIONS
KEEP(*mempool.o (.text .text* .rodata .rodata*))
/* RT-Thread Core End */
/* HPMicro Driver Wrapper */
KEEP(*drv_*.o (.text .text* .rodata .rodata*))
. = ALIGN(16);
__ramfunc_end__ = .;
} > ILM
@@ -171,10 +178,10 @@ SECTIONS
.fast_ram (NOLOAD) : {
KEEP(*(.fast_ram))
} > ILM
} > DLM
__fast_ram_init_load_addr__ = etext + SIZEOF(.data) + SIZEOF(.fast) + SIZEOF(.tdata) + SIZEOF(.noncacheable.init);
.fast_ram.init : AT(__fast_ram_init_load_addr__) {
__fast_ram_init_load_addr__ = __noncacheable_init_load_addr__ + SIZEOF(.noncacheable.init);
.fast_ram.init : AT(__fast_ram_init_load_addr__) {
. = ALIGN(8);
__fast_ram_init_start__ = .;
KEEP(*(.fast_ram.init))
@@ -183,19 +190,13 @@ SECTIONS
. = ALIGN(8);
} > DLM
.bss(NOLOAD) : {
.fast_ram.bss (NOLOAD) : {
. = ALIGN(8);
__bss_start__ = .;
*(.bss)
*(.bss*)
*(.sbss*)
*(.scommon)
*(.scommon*)
*(.dynsbss*)
*(COMMON)
__fast_ram_bss_start__ = .;
*(.fast_ram.bss)
*(.fast_ram.bss.*)
__fast_ram_bss_end__ = .;
. = ALIGN(8);
_end = .;
__bss_end__ = .;
} > DLM
/* Note: the .tbss and .tdata section should be adjacent */
@@ -274,18 +275,32 @@ SECTIONS
PROVIDE (_edata = .);
PROVIDE (edata = .);
} > DLM
__fast_load_addr__ = etext + SIZEOF(.data) + SIZEOF(.tdata);
__fast_load_addr__ = etext + SIZEOF(.data) + SIZEOF(.tdata) + SIZEOF(.fast);
__fw_size__ = SIZEOF(.start) + SIZEOF(.vectors) + SIZEOF(.rel) + SIZEOF(.text) + SIZEOF(.data) + SIZEOF(.fast) + SIZEOF(.tdata) + SIZEOF(.noncacheable.init) + SIZEOF(.fast_ram.init) + SIZEOF(.eh_frame) + SIZEOF(.eh_frame_hdr);
.bss(NOLOAD) : {
. = ALIGN(8);
__bss_start__ = .;
*(.bss)
*(.bss*)
*(.sbss*)
*(.scommon)
*(.scommon*)
*(.dynsbss*)
*(COMMON)
. = ALIGN(8);
_end = .;
__bss_end__ = .;
} > DLM
.heap(NOLOAD) : {
. = ALIGN(8);
__heap_start__ = .;
. += HEAP_SIZE;
__heap_end__ = .;
} > AXI_SRAM
} > DLM
.stack(NOLOAD) : {
. = ALIGN(8);
@@ -297,14 +312,14 @@ SECTIONS
PROVIDE( __rt_rvstack = . );
} > DLM
__noncacheable_init_load_addr__ = etext + SIZEOF(.data) + SIZEOF(.tdata) + SIZEOF(.fast);
__noncacheable_init_load_addr__ = __fast_load_addr__ + SIZEOF(.fast);
.noncacheable.init : AT(__noncacheable_init_load_addr__) {
. = ALIGN(8);
__noncacheable_init_start__ = .;
KEEP(*(.noncacheable.init))
__noncacheable_init_end__ = .;
. = ALIGN(8);
} > NONCACHEABLE_RAM
} > DLM
.noncacheable.bss (NOLOAD) : {
. = ALIGN(8);
@@ -316,15 +331,9 @@ SECTIONS
KEEP(*(.noncacheable.bss.*))
__noncacheable_bss_end__ = .;
. = ALIGN(8);
} > NONCACHEABLE_RAM
} > DLM
.ahb_sram (NOLOAD) : {
KEEP(*(.ahb_sram))
} > AHB_SRAM
__noncacheable_start__ = ORIGIN(NONCACHEABLE_RAM);
__noncacheable_end__ = ORIGIN(NONCACHEABLE_RAM) + LENGTH(NONCACHEABLE_RAM);
__share_mem_start__ = ORIGIN(SHARE_RAM);
__share_mem_end__ = ORIGIN(SHARE_RAM) + LENGTH(SHARE_RAM);
}
File diff suppressed because it is too large. Load diff
+64
View File
@@ -0,0 +1,64 @@
/*
* Copyright (c) 2026 HPMicro
*
* SPDX-License-Identifier: BSD-3-Clause
*
*
* Automatically generated by HPM Pinmux Tool
*
*
* Note:
* PY and PZ IOs: if any SOC pin function needs to be routed to these IOs,
* besides of IOC, PIOC/BIOC needs to be configured SOC_GPIO_X_xx, so that
* expected SoC function can be enabled on these IOs.
*/
#ifndef HPM_PINMUX_H
#define HPM_PINMUX_H
#ifdef __cplusplus
extern "C" {
#endif
void init_uart0_pins(void);
void init_uart2_pins(void);
void init_uart3_pins(void);
void init_uart3_pin_as_gpio(void);
void init_i2c0_pins(void);
void init_i2c1_pins(void);
void init_i2c2_pins(void);
void init_i2s0_pins(void);
void init_spi3_pins(void);
void init_spi3_pins_with_gpio_as_cs(void);
void init_gptmr0_pins(void);
void init_gpio_pins(void);
void init_butn_pins(void);
void init_acmp_pins(void);
void init_pwm0_pins(void);
void init_pwm1_pins(void);
void init_pwm2_pins(void);
void init_pwm3_pins(void);
void init_adc_pins(void);
void init_adc16_diff_pins(void);
void init_adc_bldc_pins(void);
void init_adc_qeiv2_pins(void);
void init_usb0_pins(void);
void init_mcan0_pins(void);
void init_led_pins_as_gpio(void);
void init_led_pins_as_pwm(void);
void init_opamp_pins(void);
void init_uart_break_signal_pin(void);
void init_gptmr0_channel0_pin_as_output(void);
void init_gptmr0_channel1_pin_as_output(void);
void init_gptmr0_channel3_pin_as_output(void);
void init_gptmr0_channel0_pin_as_capture(void);
void init_clk_ref_pin(void);
void init_brownout_indicate_pin(void);
void init_trgm_gptmr0_cap2_invert_pins(void);
void init_spi_nor_flash_pins(void);
void init_spi_nor_flash_pins_with_gpio_as_cs(void);
#ifdef __cplusplus
}
#endif
#endif /* HPM_PINMUX_H */
+187
View File
@@ -0,0 +1,187 @@
/*
* Copyright (c) 2023-2025 HPMicro
* SPDX-License-Identifier: BSD-3-Clause
*
*/
#include "board.h"
#include "rtt_board.h"
#include "hpm_uart_drv.h"
#include "hpm_gpio_drv.h"
#include "hpm_pmp_drv.h"
#include "assert.h"
#include "hpm_clock_drv.h"
#include "hpm_sysctl_drv.h"
#include <rthw.h>
#include <rtthread.h>
#include "hpm_dma_mgr.h"
#include "hpm_mchtmr_drv.h"
extern int rt_hw_uart_init(void);
void os_tick_config(void);
void rtt_board_init(void);
void rt_hw_board_init(void)
{
rtt_board_init();
/* Call the RT-Thread Component Board Initialization */
rt_components_board_init();
}
void os_tick_config(void)
{
sysctl_config_clock(HPM_SYSCTL, clock_node_mchtmr0, clock_source_osc0_clk0, 1);
sysctl_add_resource_to_cpu0(HPM_SYSCTL, sysctl_resource_mchtmr0);
mchtmr_set_compare_value(HPM_MCHTMR, BOARD_MCHTMR_FREQ_IN_HZ / RT_TICK_PER_SECOND);
enable_mchtmr_irq();
}
void rtt_board_init(void)
{
board_init_clock();
/* initialize memory system
* NOTE: this must happen before board_init_console(), because the SDK console_init()
* calls setvbuf(), which allocates through the C library malloc() -> rt_malloc() and
* therefore requires the RT-Thread heap to be ready. Otherwise RT_ASSERT() fires in
* rt_smem_alloc() whenever RT_USING_DEBUG is enabled.
*/
rt_system_heap_init(RT_HW_HEAP_BEGIN, RT_HW_HEAP_END);
board_init_console();
board_init_pmp();
dma_mgr_init();
/* Configure the OS Tick */
os_tick_config();
/* Configure the USB pins*/
board_init_usb(HPM_USB0);
/* Initialize the UART driver first, because later driver initialization may require the rt_kprintf */
rt_hw_uart_init();
/* Set console device */
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
}
void app_init_led_pins(void)
{
board_init_led_pins();
gpio_set_pin_output(APP_LED0_GPIO_CTRL, APP_LED0_GPIO_INDEX, APP_LED0_GPIO_PIN);
gpio_write_pin(APP_LED0_GPIO_CTRL, APP_LED0_GPIO_INDEX, APP_LED0_GPIO_PIN, APP_LED_OFF);
}
void app_led_write(uint32_t index, bool state)
{
switch (index)
{
case 0:
gpio_write_pin(APP_LED0_GPIO_CTRL, APP_LED0_GPIO_INDEX, APP_LED0_GPIO_PIN, state);
break;
default:
/* Suppress the toolchain warnings */
break;
}
}
void rt_hw_console_output(const char *str)
{
while (*str != '\0')
{
uart_send_byte(BOARD_APP_UART_BASE, *str++);
}
}
void app_init_usb_pins(void)
{
board_init_usb(HPM_USB0);
}
ATTR_PLACE_AT(".isr_vector") void mchtmr_isr(void)
{
HPM_MCHTMR->MTIMECMP = HPM_MCHTMR->MTIME + BOARD_MCHTMR_FREQ_IN_HZ / RT_TICK_PER_SECOND;
rt_tick_increase();
}
void rt_hw_cpu_reset(void)
{
HPM_PPOR->RESET_ENABLE |= (1UL << 31);
HPM_PPOR->SOFTWARE_RESET = 1000U;
while(1) {
}
}
MSH_CMD_EXPORT_ALIAS(rt_hw_cpu_reset, reset, reset the board);
#ifdef RT_USING_CACHE
void rt_hw_cpu_dcache_ops(int ops, void *addr, int size)
{
if (ops == RT_HW_CACHE_FLUSH) {
l1c_dc_flush((uint32_t)addr, size);
} else {
l1c_dc_invalidate((uint32_t)addr, size);
}
}
#endif
uint32_t rtt_board_init_adc16_clock(ADC16_Type *ptr, bool clk_src_ahb)
{
uint32_t freq = 0;
if (ptr == HPM_ADC0) {
if (clk_src_ahb) {
/* Configure the ADC clock from AHB (@200MHz by default)*/
clock_set_adc_source(clock_adc0, clk_adc_src_ahb0);
} else {
/* Configure the ADC clock from pll1_clk0 divided by 4 (@200MHz by default) */
clock_set_adc_source(clock_adc0, clk_adc_src_ana0);
clock_set_source_divider(clock_ana0, clk_src_pll1_clk0, 4U);
}
clock_add_to_group(clock_adc0, 0);
freq = clock_get_frequency(clock_adc0);
} else if (ptr == HPM_ADC1) {
if (clk_src_ahb) {
/* Configure the ADC clock from AHB (@200MHz by default)*/
clock_set_adc_source(clock_adc1, clk_adc_src_ahb0);
} else {
/* Configure the ADC clock from pll1_clk0 divided by 4 (@200MHz by default) */
clock_set_adc_source(clock_adc1, clk_adc_src_ana1);
clock_set_source_divider(clock_ana0, clk_src_pll1_clk0, 4U);
}
clock_add_to_group(clock_adc1, 0);
freq = clock_get_frequency(clock_adc1);
}
return freq;
}
uint32_t rtt_board_init_pwm_clock(PWM_Type *ptr)
{
uint32_t freq = 0;
if (ptr == HPM_PWM0) {
clock_add_to_group(clock_pwm0, 0);
freq = clock_get_frequency(clock_pwm0);
} else if (ptr == HPM_PWM1) {
clock_add_to_group(clock_pwm1, 0);
freq = clock_get_frequency(clock_pwm1);
} else if (ptr == HPM_PWM2) {
clock_add_to_group(clock_pwm2, 0);
freq = clock_get_frequency(clock_pwm2);
} else if (ptr == HPM_PWM3) {
clock_add_to_group(clock_pwm3, 0);
freq = clock_get_frequency(clock_pwm3);
} else {
}
return freq;
}
#ifdef CONFIG_CHERRYUSB_CUSTOM_IRQ_HANDLER
extern void hpm_isr_usb0(void);
RTT_DECLARE_EXT_ISR_M(IRQn_USB0, hpm_isr_usb0)
#endif
+80
View File
@@ -0,0 +1,80 @@
/*
* Copyright (c) 2021 HPMicro
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
#ifndef _RTT_BOARD_H
#define _RTT_BOARD_H
#include "hpm_common.h"
#include "hpm_soc.h"
#include "board.h"
/* gpio section */
#define APP_LED0 (0U)
#define APP_LED0_GPIO_CTRL HPM_GPIO0
#define APP_LED0_GPIO_INDEX GPIO_DI_GPIOA
#define APP_LED0_GPIO_PIN 18
#define APP_LED_ON (0)
#define APP_LED_OFF (1)
/* mchtimer section */
#define BOARD_MCHTMR_FREQ_IN_HZ (24000000UL)
/* gptmr as os_tick */
#define BOARD_OS_TIMER HPM_GPTMR0
#define BOARD_OS_TIMER_CH 1
#define BOARD_OS_TIMER_IRQ IRQn_GPTMR0
#define BOARD_OS_TIMER_CLK_NAME (clock_gptmr0)
/* UART section */
#define BOARD_UART_NAME "uart2"
#define BOARD_UART_RX_BUFFER_SIZE BSP_UART2_RX_BUFSIZE
/* PWM section */
#define BOARD_PWM_NAME "pwm3"
#define BOARD_PWM_CHANNEL (0U)
/* ADC section */
#define BOARD_ADC_NAME BOARD_APP_ADC16_NAME
#define BOARD_ADC_CHANNEL BOARD_APP_ADC16_CH_1
#define IRQn_PendSV IRQn_DEBUG0
/* CAN section */
#define BOARD_CAN_NAME "can0"
#define BOARD_CAN_HWFILTER_INDEX (1U)
/***************************************************************
*
* RT-Thread related definitions
*
**************************************************************/
extern unsigned int __heap_start__;
extern unsigned int __heap_end__;
#define RT_HW_HEAP_BEGIN ((void*)&__heap_start__)
#define RT_HW_HEAP_END ((void*)&__heap_end__)
typedef struct {
uint16_t vdd;
uint8_t bus_width;
uint8_t drive_strength;
}sdxc_io_cfg_t;
#if defined(__cplusplus)
extern "C" {
#endif /* __cplusplus */
void app_init_led_pins(void);
void app_led_write(uint32_t index, bool state);
void app_init_usb_pins(void);
#if defined(__cplusplus)
}
#endif /* __cplusplus */
#endif /* _RTT_BOARD_H */
Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

+6
View File
@@ -0,0 +1,6 @@
clean2:
-$(RM) $(CC_DEPS)$(C++_DEPS)$(C_UPPER_DEPS)$(CXX_DEPS)$(SECONDARY_FLASH)$(SECONDARY_SIZE)$(ASM_DEPS)$(S_UPPER_DEPS)$(C_DEPS)$(CPP_DEPS)
-$(RM) $(OBJS) *.elf
-@echo ' '
*.elf: $(wildcard board/linker_scripts/gcc/*.ld)
File diff suppressed because it is too large. Load diff
+131
View File
@@ -0,0 +1,131 @@
# Copyright 2021-2025 HPMicro
# SPDX-License-Identifier: BSD-3-Clause
import os
import sys
if os.getenv('RTT_ROOT'):
RTT_ROOT = os.getenv('RTT_ROOT')
else:
RTT_ROOT = os.path.normpath(os.getcwd() + '/../../..')
sys.path.insert(0, os.path.join(RTT_ROOT, 'tools'))
# toolchains options
ARCH='risc-v'
CPU='hpmicro'
SOC_FAMILY='HPM5100'
CHIP_NAME='HPM5151'
CROSS_TOOL='gcc'
# bsp lib config
BSP_LIBRARY_TYPE = None
# Fallback toolchain info
FALLBACK_TOOLCHAIN_VENDOR='RISC-V'
FALLBACK_TOOLCHAIN_PKG='RISC-V-GCC-RV32'
FALLBACK_TOOLCHAIN_VER='2022-04-12'
if os.getenv('RTT_CC'):
CROSS_TOOL = os.getenv('RTT_CC')
RTT_EXEC_PATH = os.getenv('RTT_EXEC_PATH')
if RTT_EXEC_PATH != None:
folders = RTT_EXEC_PATH.split(os.sep)
# If the `RT-Thread Env` is from the RT-Thread Studio, generate the RTT_EXEC_PATH using `FALLBACK_TOOLCHAIN_INFO`
if 'arm_gcc' in folders and 'platform' in folders:
RTT_EXEC_PATH = ''
for path in folders:
if path != 'platform':
RTT_EXEC_PATH = RTT_EXEC_PATH + path + os.sep
else:
break
RTT_EXEC_PATH = os.path.join(RTT_EXEC_PATH, 'repo', 'Extract', 'ToolChain_Support_Packages', FALLBACK_TOOLCHAIN_VENDOR, FALLBACK_TOOLCHAIN_PKG, FALLBACK_TOOLCHAIN_VER, 'bin')
# Override the 'RTT_RISCV_TOOLCHAIN' only if the `RT-Thread ENV` is from the RT-Thread Studio
if 'platform' in folders:
os.environ['RTT_RISCV_TOOLCHAIN'] = RTT_EXEC_PATH
# cross_tool provides the cross compiler
# EXEC_PATH is the compiler path, for example, GNU RISC-V toolchain, IAR
if CROSS_TOOL == 'gcc':
PLATFORM = 'gcc'
if os.getenv('RTT_RISCV_TOOLCHAIN'):
EXEC_PATH = os.getenv('RTT_RISCV_TOOLCHAIN')
elif RTT_EXEC_PATH:
EXEC_PATH = RTT_EXEC_PATH
else:
EXEC_PATH = r'/opt/riscv-gnu-gcc/bin'
else:
print("CROSS_TOOL = {} not yet supported, only gcc is supported".format(CROSS_TOOL))
exit(-1)
if os.getenv('RTT_BUILD_TYPE'):
BUILD = os.getenv('RTT_BUILD_TYPE')
else:
BUILD = 'flash_debug'
if PLATFORM == 'gcc':
PREFIX = 'riscv32-unknown-elf-'
CC = PREFIX + 'gcc'
CXX = PREFIX + 'g++'
AS = PREFIX + 'gcc'
AR = PREFIX + 'ar'
LINK = PREFIX + 'gcc'
GDB = PREFIX + 'gdb'
TARGET_EXT = 'elf'
SIZE = PREFIX + 'size'
OBJDUMP = PREFIX + 'objdump'
OBJCPY = PREFIX + 'objcopy'
STRIP = PREFIX + 'strip'
ARCH_ABI = ' -mcmodel=medlow '
DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 ' + ' -ffunction-sections -fdata-sections -fno-common '
CFLAGS = DEVICE
AFLAGS = CFLAGS
LFLAGS = ARCH_ABI + ' --specs=nano.specs --specs=nosys.specs -nostartfiles -Wl,--gc-sections '
CPATH = ''
LPATH = ''
if BUILD == 'ram_debug':
CFLAGS += ' -gdwarf-2'
AFLAGS += ' -gdwarf-2'
CFLAGS += ' -Og'
LFLAGS += ' -Og'
LINKER_FILE = 'board/linker_scripts/gcc/ram_rtt.ld'
elif BUILD == 'ram_release':
CFLAGS += ' -O2'
LFLAGS += ' -O2'
LINKER_FILE = 'board/linker_scripts/gcc/ram_rtt.ld'
elif BUILD == 'flash_debug':
CFLAGS += ' -gdwarf-2'
AFLAGS += ' -gdwarf-2'
CFLAGS += ' -Og'
LFLAGS += ' -Og'
CFLAGS += ' -DFLASH_XIP=1'
LINKER_FILE = 'board/linker_scripts/gcc/flash_rtt.ld'
elif BUILD == 'flash_release':
CFLAGS += ' -O2'
LFLAGS += ' -O2'
CFLAGS += ' -DFLASH_XIP=1'
LINKER_FILE = 'board/linker_scripts/gcc/flash_rtt.ld'
else:
CFLAGS += ' -O2'
LFLAGS += ' -O2'
LINKER_FILE = 'board/linker_scripts/gcc/flash_rtt.ld'
LFLAGS += ' -T ' + LINKER_FILE
POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n'
# module setting
CXXFLAGS = CFLAGS + ' -Woverloaded-virtual -fno-exceptions -fno-rtti '
CFLAGS = CFLAGS + ' -std=gnu11'
def dist_handle(BSP_ROOT, dist_dir):
import sys
cwd_path = os.getcwd()
sys.path.append(os.path.join(os.path.dirname(BSP_ROOT), 'tools'))
from sdk_dist import dist_do_building
dist_do_building(BSP_ROOT, dist_dir)
+21
View File
@@ -0,0 +1,21 @@
#ifndef RTCONFIG_PREINC_H__
#define RTCONFIG_PREINC_H__
/* Automatically generated file; DO NOT EDIT. */
/* RT-Thread pre-include file */
#define D25
#define HPM5151
#define HPMSOC_HAS_HPMSDK_DMAV2
#define HPM_SDK_L1C_NO_REENTRANT 1
#define HPM_SOC_ISR_NUM 59
#define RT_HW_ISR_NUM HPM_SOC_ISR_NUM
#define RT_USING_LIBC
#define RT_USING_NEWLIBC
#define USE_DMA_DECLARE_EXT_ISR_M 1
#define _POSIX_C_SOURCE 1
#define _REENT_SMALL
#define __RTTHREAD__
#endif /*RTCONFIG_PREINC_H__*/
@@ -0,0 +1,19 @@
Import('rtconfig')
from building import *
cwd = GetCurrentDir()
# add the startup files
src = Glob('*.c')
if rtconfig.PLATFORM == 'gcc':
src += [os.path.join('toolchains', 'gcc', 'start.S')]
src += [os.path.join('toolchains', 'gcc', 'port_gcc.S')]
CPPPATH = [cwd]
CPPDEFINES=['D25', rtconfig.CHIP_NAME]
group = DefineGroup('Startup', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES)
Return('group')
@@ -0,0 +1,148 @@
/*
* Copyright (c) 2021-2024 HPMicro
*
*
*/
#include "hpm_common.h"
#include "hpm_soc.h"
#include "hpm_l1c_drv.h"
#include <rtthread.h>
void system_init(void);
extern int entry(void);
extern void __libc_init_array(void);
extern void __libc_fini_array(void);
void system_init(void)
{
disable_global_irq(CSR_MSTATUS_MIE_MASK);
disable_irq_from_intc();
enable_irq_from_intc();
enable_global_irq(CSR_MSTATUS_MIE_MASK);
#ifndef CONFIG_NOT_ENABLE_ICACHE
l1c_ic_enable();
#endif
#ifndef CONFIG_NOT_ENABLE_DCACHE
l1c_dc_enable();
#endif
}
__attribute__((weak)) void c_startup(void)
{
#ifndef __SES_RISCV
uint32_t i, size;
#ifdef FLASH_XIP
extern uint8_t __vector_ram_start__[], __vector_ram_end__[], __vector_load_addr__[];
size = __vector_ram_end__ - __vector_ram_start__;
for (i = 0; i < size; i++) {
*(__vector_ram_start__ + i) = *(__vector_load_addr__ + i);
}
#endif
extern uint8_t __etext[];
extern uint8_t __bss_start__[], __bss_end__[];
extern uint8_t __tbss_start__[], __tbss_end__[];
extern uint8_t __tdata_start__[], __tdata_end__[];
extern uint8_t __fast_load_addr__[];
extern uint8_t __noncacheable_init_load_addr__[];
extern uint8_t __data_load_addr__[];
extern uint8_t __tdata_load_addr__[];
extern uint8_t __data_start__[], __data_end__[];
extern uint8_t __noncacheable_bss_start__[], __noncacheable_bss_end__[];
extern uint8_t __ramfunc_start__[], __ramfunc_end__[];
extern uint8_t __noncacheable_init_start__[], __noncacheable_init_end__[];
extern uint8_t __fast_ram_bss_start__[], __fast_ram_bss_end__[];
extern uint8_t __fast_ram_init_start__[], __fast_ram_init_end__[], __fast_ram_init_load_addr__[];
/* tbss section */
size = __tbss_end__ - __tbss_start__;
for (i = 0; i < size; i++) {
*(__tbss_start__ + i) = 0;
}
/* bss section */
size = __bss_end__ - __bss_start__;
for (i = 0; i < size; i++) {
*(__bss_start__ + i) = 0;
}
/* noncacheable bss section */
size = __noncacheable_bss_end__ - __noncacheable_bss_start__;
for (i = 0; i < size; i++) {
*(__noncacheable_bss_start__ + i) = 0;
}
/* tdata section LMA: etext */
size = __tdata_end__ - __tdata_start__;
for (i = 0; i < size; i++) {
*(__tdata_start__ + i) = *(__tdata_load_addr__ + i);
}
/* data section LMA: etext */
size = __data_end__ - __data_start__;
for (i = 0; i < size; i++) {
*(__data_start__ + i) = *(__data_load_addr__ + i);
}
/* ramfunc section LMA: etext + data length */
size = __ramfunc_end__ - __ramfunc_start__;
for (i = 0; i < size; i++) {
*(__ramfunc_start__ + i) = *(__fast_load_addr__ + i);
}
/* noncacheable init section LMA: etext + data length + ramfunc length */
size = __noncacheable_init_end__ - __noncacheable_init_start__;
for (i = 0; i < size; i++) {
*(__noncacheable_init_start__ + i) = *(__noncacheable_init_load_addr__ + i);
}
/* fast_ram bss section */
size = __fast_ram_bss_end__ - __fast_ram_bss_start__;
for (i = 0; i < size; i++) {
*(__fast_ram_bss_start__ + i) = 0;
}
/* fast_ram init section LMA: etext + data length + ramfunc length + tdata length */
size = __fast_ram_init_end__ - __fast_ram_init_start__;
for (i = 0; i < size; i++) {
*(__fast_ram_init_start__ + i) = *(__fast_ram_init_load_addr__ + i);
}
#endif
}
__attribute__((weak)) int main(void)
{
while(1);
}
void reset_handler(void)
{
/**
* Disable preemptive interrupt
*/
HPM_PLIC->FEATURE = 0;
/*
* Initialize LMA/VMA sections.
* Relocation for any sections that need to be copied from LMA to VMA.
*/
c_startup();
/* Call platform specific hardware initialization */
system_init();
#ifndef __SES_RISCV
/* Do global constructors */
__libc_init_array();
#endif
/* Entry function */
entry();
}
__attribute__((weak)) void _init(void)
{
}
@@ -0,0 +1,23 @@
/*
* Copyright (c) 2021-2023 HPMicro
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
#include "cpuport.h"
.section .text.entry, "ax"
.globl rt_hw_do_after_save_above
.type rt_hw_do_after_save_above,@function
rt_hw_do_after_save_above:
addi sp, sp, -4
STORE ra, 0 * REGBYTES(sp)
csrr t1, mcause
andi t1, t1, 0x3FF
/* get ISR */
la t2, trap_entry
jalr t2
LOAD ra, 0 * REGBYTES(sp)
addi sp, sp, 4
ret
@@ -0,0 +1,87 @@
/*
* Copyright (c) 2021-2023 HPMicro
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
#include <rtconfig.h>
#include "hpm_csr_regs.h"
.section .start, "ax"
.global _start
.type _start,@function
_start:
/* Initialize global pointer */
.option push
.option norelax
la gp, __global_pointer$
la tp, __thread_pointer
.option pop
/* Initialize stack pointer */
la t0, _stack
mv sp, t0
#ifdef __nds_execit
/* Initialize EXEC.IT table */
la t0, _ITB_BASE_
csrw uitb, t0
#endif
#ifdef __riscv_flen
/* Enable FPU */
li t0, CSR_MSTATUS_FS_MASK
csrrs t0, mstatus, t0
/* Initialize FCSR */
fscsr zero
#endif
#ifdef HPM_USING_VECTOR_PREEMPTED_MODE
/* Initial machine trap-vector Base */
la t0, __vector_table
csrw mtvec, t0
/* Enable vectored external PLIC interrupt */
csrsi CSR_MMISC_CTL, 2
#else
/* Initial machine trap-vector Base */
la t0, SW_handler
csrw mtvec, t0
/* Disable vectored external PLIC interrupt */
csrci CSR_MMISC_CTL, 2
#endif
/* System reset handler */
call reset_handler
/* Infinite loop, if returned accidently */
1: j 1b
.weak nmi_handler
nmi_handler:
1: j 1b
#ifndef HPM_USING_RTTHREAD_INTERRUPT_FRAMEWORK
.weak default_irq_handler
.align 2
default_irq_handler:
1: j 1b
.macro IRQ_HANDLER irq
.weak default_isr_\irq
.set default_isr_\irq, default_irq_handler
.long default_isr_\irq
.endm
#include "vectors.S"
#else
.section .vector_table, "a"
.global __vector_table
.align 9
__vector_table:
.rept RT_HW_ISR_NUM
.long handle_trap
.endr
#endif /* HPM_USING_RTTHREAD_INTERRUPT_FRAMEWORK */
@@ -0,0 +1,109 @@
/*
* Copyright (c) 2021-2023 HPMicro
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
.section .vector_table, "a"
.global __vector_table
.align 9
__vector_table:
.weak default_isr_trap
.set default_isr_trap, SW_handler
.long default_isr_trap
IRQ_HANDLER 1 /* GPIO0_A IRQ handler */
IRQ_HANDLER 2 /* GPIO0_B IRQ handler */
IRQ_HANDLER 3 /* GPIO0_C IRQ handler */
IRQ_HANDLER 4 /* GPIO0_D IRQ handler */
IRQ_HANDLER 5 /* GPIO0_X IRQ handler */
IRQ_HANDLER 6 /* GPIO0_Y IRQ handler */
IRQ_HANDLER 7 /* GPIO0_Z IRQ handler */
IRQ_HANDLER 8 /* GPIO1_A IRQ handler */
IRQ_HANDLER 9 /* GPIO1_B IRQ handler */
IRQ_HANDLER 10 /* GPIO1_C IRQ handler */
IRQ_HANDLER 11 /* GPIO1_D IRQ handler */
IRQ_HANDLER 12 /* GPIO1_X IRQ handler */
IRQ_HANDLER 13 /* GPIO1_Y IRQ handler */
IRQ_HANDLER 14 /* GPIO1_Z IRQ handler */
IRQ_HANDLER 15 /* ADC0 IRQ handler */
IRQ_HANDLER 16 /* ADC1 IRQ handler */
IRQ_HANDLER 17 /* ADC2 IRQ handler */
IRQ_HANDLER 18 /* SDFM IRQ handler */
IRQ_HANDLER 19 /* DAC0 IRQ handler */
IRQ_HANDLER 20 /* DAC1 IRQ handler */
IRQ_HANDLER 21 /* ACMP[0] IRQ handler */
IRQ_HANDLER 22 /* ACMP[1] IRQ handler */
IRQ_HANDLER 23 /* ACMP[2] IRQ handler */
IRQ_HANDLER 24 /* ACMP[3] IRQ handler */
IRQ_HANDLER 25 /* SPI0 IRQ handler */
IRQ_HANDLER 26 /* SPI1 IRQ handler */
IRQ_HANDLER 27 /* SPI2 IRQ handler */
IRQ_HANDLER 28 /* SPI3 IRQ handler */
IRQ_HANDLER 29 /* UART0 IRQ handler */
IRQ_HANDLER 30 /* UART1 IRQ handler */
IRQ_HANDLER 31 /* UART2 IRQ handler */
IRQ_HANDLER 32 /* UART3 IRQ handler */
IRQ_HANDLER 33 /* UART4 IRQ handler */
IRQ_HANDLER 34 /* UART5 IRQ handler */
IRQ_HANDLER 35 /* UART6 IRQ handler */
IRQ_HANDLER 36 /* UART7 IRQ handler */
IRQ_HANDLER 37 /* CAN0 IRQ handler */
IRQ_HANDLER 38 /* CAN1 IRQ handler */
IRQ_HANDLER 39 /* CAN2 IRQ handler */
IRQ_HANDLER 40 /* CAN3 IRQ handler */
IRQ_HANDLER 41 /* PTPC IRQ handler */
IRQ_HANDLER 42 /* WDG0 IRQ handler */
IRQ_HANDLER 43 /* WDG1 IRQ handler */
IRQ_HANDLER 44 /* TSNS IRQ handler */
IRQ_HANDLER 45 /* MBX0A IRQ handler */
IRQ_HANDLER 46 /* MBX0B IRQ handler */
IRQ_HANDLER 47 /* MBX1A IRQ handler */
IRQ_HANDLER 48 /* MBX1B IRQ handler */
IRQ_HANDLER 49 /* GPTMR0 IRQ handler */
IRQ_HANDLER 50 /* GPTMR1 IRQ handler */
IRQ_HANDLER 51 /* GPTMR2 IRQ handler */
IRQ_HANDLER 52 /* GPTMR3 IRQ handler */
IRQ_HANDLER 53 /* I2C0 IRQ handler */
IRQ_HANDLER 54 /* I2C1 IRQ handler */
IRQ_HANDLER 55 /* I2C2 IRQ handler */
IRQ_HANDLER 56 /* I2C3 IRQ handler */
IRQ_HANDLER 57 /* PWM0 IRQ handler */
IRQ_HANDLER 58 /* HALL0 IRQ handler */
IRQ_HANDLER 59 /* QEI0 IRQ handler */
IRQ_HANDLER 60 /* PWM1 IRQ handler */
IRQ_HANDLER 61 /* HALL1 IRQ handler */
IRQ_HANDLER 62 /* QEI1 IRQ handler */
IRQ_HANDLER 63 /* PWM2 IRQ handler */
IRQ_HANDLER 64 /* HALL2 IRQ handler */
IRQ_HANDLER 65 /* QEI2 IRQ handler */
IRQ_HANDLER 66 /* PWM3 IRQ handler */
IRQ_HANDLER 67 /* HALL3 IRQ handler */
IRQ_HANDLER 68 /* QEI3 IRQ handler */
IRQ_HANDLER 69 /* SDP IRQ handler */
IRQ_HANDLER 70 /* XPI0 IRQ handler */
IRQ_HANDLER 71 /* XDMA IRQ handler */
IRQ_HANDLER 72 /* HDMA IRQ handler */
IRQ_HANDLER 73 /* RNG IRQ handler */
IRQ_HANDLER 74 /* USB0 IRQ handler */
IRQ_HANDLER 75 /* PSEC IRQ handler */
IRQ_HANDLER 76 /* PGPIO IRQ handler */
IRQ_HANDLER 77 /* PWDG IRQ handler */
IRQ_HANDLER 78 /* PTMR IRQ handler */
IRQ_HANDLER 79 /* PUART IRQ handler */
IRQ_HANDLER 80 /* FUSE IRQ handler */
IRQ_HANDLER 81 /* SECMON IRQ handler */
IRQ_HANDLER 82 /* RTC IRQ handler */
IRQ_HANDLER 83 /* BUTN IRQ handler */
IRQ_HANDLER 84 /* BGPIO IRQ handler */
IRQ_HANDLER 85 /* BVIO IRQ handler */
IRQ_HANDLER 86 /* BROWNOUT IRQ handler */
IRQ_HANDLER 87 /* SYSCTL IRQ handler */
IRQ_HANDLER 88 /* DEBUG[0] IRQ handler */
IRQ_HANDLER 89 /* DEBUG[1] IRQ handler */
IRQ_HANDLER 90 /* LIN0 IRQ handler */
IRQ_HANDLER 91 /* LIN1 IRQ handler */
IRQ_HANDLER 92 /* LIN2 IRQ handler */
IRQ_HANDLER 93 /* LIN3 IRQ handler */
File diff suppressed because it is too large. Load diff
+12
View File
@@ -0,0 +1,12 @@
# for module compiling
import os
Import('rtconfig')
Import('RTT_ROOT')
from building import *
cwd = GetCurrentDir()
objs = []
objs = objs + SConscript(os.path.join(rtconfig.CHIP_NAME, 'SConscript'))
Return('objs')
File diff suppressed because it is too large. Load diff
+2 -2
View File
@@ -71,7 +71,7 @@ Open RT-Thread ENV command-line, and change directory to this BSP directory, the
- Users can download the project via the below command:
```console
%OPENOCD_HPMICRO%\openocd.exe -f boards\debug_scripts\probes\ft2232.cfg -f boards\debug_scripts\soc\hpm5300.cfg -f boards\debug_scripts\boards\hpm5300evk.cfg -c "init; halt; flash write_image erase rtthread.elf; reset; shutdown"
%OPENOCD_HPMICRO%\openocd.exe -f board\debug_scripts\openocd\probes\ft2232.cfg -f board\debug_scripts\openocd\soc\hpm5300.cfg -f board\debug_scripts\openocd\boards\hpm5300evk.cfg -c "init; halt; flash write_image erase rtthread.elf; reset; shutdown"
```
- Users can debug the project via the below command:
@@ -79,7 +79,7 @@ Open RT-Thread ENV command-line, and change directory to this BSP directory, the
- Connect debugger via `OpenOCD`:
```console
%OPENOCD_HPMICRO%\openocd.exe -f boards\debug_scripts\probes\ft2232.cfg -f boards\debug_scripts\soc\hpm5300.cfg -f boards\debug_scripts\boards\hpm5300evk.cfg
%OPENOCD_HPMICRO%\openocd.exe -f board\debug_scripts\openocd\probes\ft2232.cfg -f board\debug_scripts\openocd\soc\hpm5300.cfg -f board\debug_scripts\openocd\boards\hpm5300evk.cfg
```
- Start Debugger via `GDB`:
+2 -2
View File
@@ -71,14 +71,14 @@
- 通过如下命令完成下载:
```console
%OPENOCD_HPMICRO%\openocd.exe -f board\debug_scripts\probes\ft2232.cfg -f board\debug_scripts\soc\hpm5300.cfg -f board\debug_scripts\boards\hpm5300evk.cfg -c "init; halt; flash write_image erase rtthread.elf; reset; shutdown"
%OPENOCD_HPMICRO%\openocd.exe -f board\debug_scripts\openocd\probes\ft2232.cfg -f board\debug_scripts\openocd\soc\hpm5300.cfg -f board\debug_scripts\openocd\boards\hpm5300evk.cfg -c "init; halt; flash write_image erase rtthread.elf; reset; shutdown"
```
- 通过如下命令实现调试:
- 通过 `OpenOCD` 来连接开发板:
```console
%OPENOCD_HPMICRO%\openocd.exe -f board\debug_scripts\probes\ft2232.cfg -f board\debug_scripts\soc\hpm5300.cfg -f board\debug_scripts\boards\hpm5300evk.cfg
%OPENOCD_HPMICRO%\openocd.exe -f board\debug_scripts\openocd\probes\ft2232.cfg -f board\debug_scripts\openocd\soc\hpm5300.cfg -f board\debug_scripts\openocd\boards\hpm5300evk.cfg
```
- 通过 `GDB` 实现调试:
```console
-1
View File
@@ -7,7 +7,6 @@ cwd = GetCurrentDir()
objs = []
list = os.listdir(cwd)
ASFLAGS = ' -I' + cwd
for d in list:
path = os.path.join(cwd, d)
+10 -9
View File
@@ -16,13 +16,16 @@ except:
exit(-1)
def bsp_pkg_check():
import subprocess
if GetOption('clean'):
return
need_update = True
for p in os.listdir("packages"):
if p.startswith("hpm_sdk-"):
need_update = False
break
if os.path.isdir("packages"):
for p in os.listdir("packages"):
if p.startswith("hpm_sdk-"):
need_update = False
break
if need_update:
print("\n===============================================================================")
print("Dependency packages missing, please running 'pkgs --update'...")
@@ -64,9 +67,6 @@ if os.path.exists(os.path.join(SDK_ROOT, 'libraries')):
else:
libraries_path_prefix = os.path.join(os.path.dirname(SDK_ROOT), 'libraries')
SDK_LIB = libraries_path_prefix
Export('SDK_LIB')
GDB = rtconfig.GDB
@@ -76,6 +76,7 @@ objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
# includes rtt drivers
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'drivers', 'SConscript'), variant_dir='build/libraries/drivers', duplicate=0))
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'misc', 'SConscript'), variant_dir='build/libraries/misc', duplicate=0))
# make a building
DoBuilding(TARGET, objs)
@@ -1,5 +1,3 @@
import rtconfig
from building import *
cwd = GetCurrentDir()
+4 -1
View File
@@ -19,7 +19,10 @@ int main(void)
{
static uint32_t led_thread_arg = 0;
rt_thread_t led_thread = rt_thread_create("led_th", thread_entry, &led_thread_arg, 1024, 1, 10);
rt_thread_startup(led_thread);
if (led_thread != RT_NULL)
{
rt_thread_startup(led_thread);
}
return 0;
}
File diff suppressed because it is too large. Load diff
@@ -46,27 +46,15 @@
# - flash ctrl index: 0xF3000000
# - base address: 0x80000000
# - flash size: 0x2000000
# - flash option0: 0x7
flash bank xpi0 hpm_xpi 0x80000000 0x2000000 1 1 $_TARGET0 0xF3000000 0x6 0x1000
# - flash option0: 0x5
# - flash option1: 0x1000
flash bank xpi0 hpm_xpi 0x80000000 0x2000000 1 1 $_TARGET0 0xF3000000 0x5 0x1000
proc init_clock {} {
$::_TARGET0 riscv dmi_write 0x39 0xF4002000
$::_TARGET0 riscv dmi_write 0x3C 0x1
$::_TARGET0 riscv dmi_write 0x39 0xF4002000
$::_TARGET0 riscv dmi_write 0x3C 0x2
$::_TARGET0 riscv dmi_write 0x39 0xF4000800
$::_TARGET0 riscv dmi_write 0x3C 0xFFFFFFFF
$::_TARGET0 riscv dmi_write 0x39 0xF4000810
$::_TARGET0 riscv dmi_write 0x3C 0xFFFFFFFF
$::_TARGET0 riscv dmi_write 0x39 0xF4000820
$::_TARGET0 riscv dmi_write 0x3C 0xFFFFFFFF
$::_TARGET0 riscv dmi_write 0x39 0xF4000830
$::_TARGET0 riscv dmi_write 0x3C 0xFFFFFFFF
mww 0xF4000800 0xFFFFFFFF
mww 0xF4000810 0xFFFFFFFF
mww 0xF4000820 0xFFFFFFFF
mww 0xF4000830 0xFFFFFFFF
echo "clocks has been enabled!"
}
@@ -0,0 +1,24 @@
# Copyright (c) 2023,2025 HPMicro
# SPDX-License-Identifier: BSD-3-Clause
if { [info exists CHIPNAME] } {
set _CHIP $CHIPNAME
} else {
set _CHIP hpm5361
}
set _CPUTAPID 0x1000563D
jtag newtap $_CHIP cpu -irlen 5 -expected-id $_CPUTAPID
set _TARGET0 $_CHIP.cpu0
target create $_TARGET0 riscv -chain-position $_CHIP.cpu -coreid 0
$_TARGET0 configure -work-area-phys 0x00000000 -work-area-size 0x20000 -work-area-backup 0
targets $_TARGET0
source [file join [file dirname [info script]] hpm_common.cfg]
source [file join [file dirname [info script]] hpm_common_csr_lite.cfg]
proc reset_soc {} {
sba_write_mem 0xF410001C 24000000
}
@@ -0,0 +1,29 @@
# Copyright (c) 2025 HPMicro
# SPDX-License-Identifier: BSD-3-Clause
source [file join [file dirname [info script]] hpm_reset.cfg]
set dmsbcs 0x38
set dmsbaddress0 0x39
set dmsbdata0 0x3C
proc target0_dmi_write_reg {reg value} {
$::_TARGET0 riscv dmi_write ${reg} ${value}
}
proc target0_dmi_read_reg {reg} {
set v [$::_TARGET0 riscv dmi_read ${reg}]
return ${v}
}
proc sba_write_mem {addr value} {
target0_dmi_write_reg $::dmsbaddress0 ${addr}
target0_dmi_write_reg $::dmsbdata0 ${value}
}
proc sba_read_mem {addr} {
set sbcs [expr { 0x100000 | [target0_dmi_read_reg $::dmsbcs] }]
target0_dmi_write_reg $::dmsbcs ${sbcs}
target0_dmi_write_reg $::dmsbaddress0 ${addr}
set value [target0_dmi_read_reg $::dmsbdata0]
return ${value}
}
@@ -0,0 +1,101 @@
# Copyright (c) 2024 HPMicro
# SPDX-License-Identifier: BSD-3-Clause
# expose non-standard csr registers
# milmb
riscv expose_csrs 1984
# mdlmb
riscv expose_csrs 1985
# mecc_code
riscv expose_csrs 1986
# mnvec
riscv expose_csrs 1987
# mxstatus
riscv expose_csrs 1988
# mpft_ctl
riscv expose_csrs 1989
# mhsp_ctl
riscv expose_csrs 1990
# msp_bound
riscv expose_csrs 1991
# msp_base
riscv expose_csrs 1992
# mdcause
riscv expose_csrs 1993
# mcache_ctl
riscv expose_csrs 1994
# mcctlbeginaddr
riscv expose_csrs 1995
# mcctlcommand
riscv expose_csrs 1996
# mcctldata
riscv expose_csrs 1997
# mcounterwen
riscv expose_csrs 1998
# mcounterinten
riscv expose_csrs 1999
# mmisc_ctl
riscv expose_csrs 2000
# mcountermask_m
riscv expose_csrs 2001
# mcountermask_s
riscv expose_csrs 2002
# mcountermask_u
riscv expose_csrs 2003
# mcounterovf
riscv expose_csrs 2004
# mslideleg
riscv expose_csrs 2005
# mclk_ctl
riscv expose_csrs 2015
# dexc2dbg
riscv expose_csrs 2016
# ddcause
riscv expose_csrs 2017
# uitb
riscv expose_csrs 2048
# ucode
riscv expose_csrs 2049
# udcause
riscv expose_csrs 2057
# ucctlbeginaddr
riscv expose_csrs 2059
# ucctlcommand
riscv expose_csrs 2060
# slie
riscv expose_csrs 2500
# slip
riscv expose_csrs 2501
# sdcause
riscv expose_csrs 2505
# scctldata
riscv expose_csrs 2509
# scounterinten
riscv expose_csrs 2511
# scountermask_m
riscv expose_csrs 2513
# scountermask_s
riscv expose_csrs 2514
# scountermask_u
riscv expose_csrs 2515
# scounterovf
riscv expose_csrs 2516
# scountinhibit
riscv expose_csrs 2528
# shpmevent3
riscv expose_csrs 2531
# shpmevent4
riscv expose_csrs 2532
# shpmevent5
riscv expose_csrs 2533
# shpmevent6
riscv expose_csrs 2534
# micm_cfg
riscv expose_csrs 4032
# mdcm_cfg
riscv expose_csrs 4033
# mmsc_cfg
riscv expose_csrs 4034
# mmsc_cfg2
riscv expose_csrs 4035
@@ -0,0 +1,69 @@
# Copyright (c) 2024 HPMicro
# SPDX-License-Identifier: BSD-3-Clause
# expose non-standard csr registers
# milmb
riscv expose_csrs 1984
# mdlmb
riscv expose_csrs 1985
# mecc_code
riscv expose_csrs 1986
# mnvec
riscv expose_csrs 1987
# mxstatus
riscv expose_csrs 1988
# mpft_ctl
riscv expose_csrs 1989
# mhsp_ctl
riscv expose_csrs 1990
# msp_bound
riscv expose_csrs 1991
# msp_base
riscv expose_csrs 1992
# mdcause
riscv expose_csrs 1993
# mcache_ctl
riscv expose_csrs 1994
# mcctlbeginaddr
riscv expose_csrs 1995
# mcctlcommand
riscv expose_csrs 1996
# mcctldata
riscv expose_csrs 1997
# mcounterwen
riscv expose_csrs 1998
# mcounterinten
riscv expose_csrs 1999
# mmisc_ctl
riscv expose_csrs 2000
# mcountermask_m
riscv expose_csrs 2001
# mcountermask_s
riscv expose_csrs 2002
# mcountermask_u
riscv expose_csrs 2003
# mcounterovf
riscv expose_csrs 2004
# dexc2dbg
riscv expose_csrs 2016
# ddcause
riscv expose_csrs 2017
# uitb
riscv expose_csrs 2048
# ucode
riscv expose_csrs 2049
# udcause
riscv expose_csrs 2057
# ucctlbeginaddr
riscv expose_csrs 2059
# ucctlcommand
riscv expose_csrs 2060
# micm_cfg
riscv expose_csrs 4032
# mdcm_cfg
riscv expose_csrs 4033
# mmsc_cfg
riscv expose_csrs 4034
# mmsc_cfg2
riscv expose_csrs 4035
@@ -0,0 +1,9 @@
# Copyright (c) 2025 HPMicro
# SPDX-License-Identifier: BSD-3-Clause
$_TARGET0 configure -event reset-deassert-pre {
sleep 1
if {$halt} {
$::_TARGET0 arp_halt
}
}
@@ -14,7 +14,7 @@ MEMORY
{
XPI0 (rx) : ORIGIN = 0x80000000, LENGTH = FLASH_SIZE
ILM (wx) : ORIGIN = 0x00000000, LENGTH = 128K
DLM (w) : ORIGIN = 0x00080300, LENGTH = 128K - 768
DLM (w) : ORIGIN = 0x00080000, LENGTH = 128K
AHB_SRAM (w) : ORIGIN = 0xf0400000, LENGTH = 32K
}
@@ -26,6 +26,15 @@ __app_offset__ = __app_load_addr__ - __boot_header_load_addr__;
SECTIONS
{
/* Anchor the lowest LMA at the flash base address (0x80000000): objcopy takes the
* lowest LMA as the start address of the generated .bin, so without this marker the
* .bin starts at .nor_cfg_option (0x80000400). The value is all ones (erased flash),
* so programming it does not change the flash state.
*/
.flash_base ORIGIN(XPI0) : {
LONG(0xFFFFFFFF)
} > XPI0
.nor_cfg_option __nor_cfg_option_load_addr__ : {
KEEP(*(.nor_cfg_option))
} > XPI0
@@ -165,11 +174,19 @@ SECTIONS
PROVIDE (_etext = .);
PROVIDE (etext = .);
/* The first 0x300 bytes of DLM are reserved; keep them as an explicit NOLOAD
* placeholder. This also keeps the DLM region 4KB aligned so that the linker does
* not emit an extra file-backed PT_LOAD (which made "program rtthread.elf" fail).
*/
.dlm_reserved (NOLOAD) : {
. = . + 0x300;
} > DLM
.fast_ram (NOLOAD) : {
KEEP(*(.fast_ram))
} > DLM
__fast_ram_init_load_addr__ = etext + SIZEOF(.data) + SIZEOF(.fast) + SIZEOF(.tdata) + SIZEOF(.noncacheable.init);
__fast_ram_init_load_addr__ = __noncacheable_init_load_addr__ + SIZEOF(.noncacheable.init);
.fast_ram.init : AT(__fast_ram_init_load_addr__) {
. = ALIGN(8);
__fast_ram_init_start__ = .;
@@ -179,6 +196,15 @@ SECTIONS
. = ALIGN(8);
} > DLM
.fast_ram.bss (NOLOAD) : {
. = ALIGN(8);
__fast_ram_bss_start__ = .;
*(.fast_ram.bss)
*(.fast_ram.bss.*)
__fast_ram_bss_end__ = .;
. = ALIGN(8);
} > DLM
/* Note: the .tbss and .tdata section should be adjacent */
.tbss(NOLOAD) : {
. = ALIGN(8);
@@ -256,7 +282,7 @@ SECTIONS
PROVIDE (edata = .);
} > DLM
__fast_load_addr__ = etext + SIZEOF(.data) + SIZEOF(.tdata);
__fast_load_addr__ = etext + SIZEOF(.data) + SIZEOF(.tdata) + SIZEOF(.fast);
__fw_size__ = SIZEOF(.start) + SIZEOF(.vectors) + SIZEOF(.rel) + SIZEOF(.text) + SIZEOF(.data) + SIZEOF(.fast) + SIZEOF(.tdata) + SIZEOF(.noncacheable.init) + SIZEOF(.fast_ram.init) + SIZEOF(.eh_frame) + SIZEOF(.eh_frame_hdr);
@@ -295,7 +321,7 @@ SECTIONS
PROVIDE( __rt_rvstack = . );
} > DLM
__noncacheable_init_load_addr__ = etext + SIZEOF(.data) + SIZEOF(.tdata) + SIZEOF(.fast);
__noncacheable_init_load_addr__ = __fast_load_addr__ + SIZEOF(.fast);
.noncacheable.init : AT(__noncacheable_init_load_addr__) {
. = ALIGN(8);
__noncacheable_init_start__ = .;
@@ -112,6 +112,16 @@ SECTIONS
. = ALIGN(8);
} > ILM
.fast_ram.bss (NOLOAD) : {
. = ALIGN(8);
__fast_ram_bss_start__ = .;
*(.fast_ram.bss)
*(.fast_ram.bss.*)
__fast_ram_bss_end__ = .;
. = ALIGN(8);
} > ILM
.bss(NOLOAD) : {
. = ALIGN(8);
__bss_start__ = .;
@@ -213,7 +223,7 @@ SECTIONS
*(.fast)
. = ALIGN(8);
PROVIDE(__ramfunc_end__ = .);
} > DLM
} > ILM
__noncacheable_init_load_addr__ = etext + SIZEOF(.data) + SIZEOF(.tdata) + SIZEOF(.fast);
.noncacheable.init : AT(__noncacheable_init_load_addr__) {
+3 -2
View File
@@ -66,7 +66,7 @@ void init_uart_pin_as_gpio(UART_Type *ptr)
}
}
void init_i2c_pins(I2C_Type *ptr)
hpm_stat_t init_i2c_pins(I2C_Type *ptr)
{
if (ptr == HPM_I2C0) {
HPM_IOC->PAD[IOC_PAD_PB02].FUNC_CTL = IOC_PB02_FUNC_CTL_I2C0_SCL | IOC_PAD_FUNC_CTL_LOOP_BACK_MASK;
@@ -79,8 +79,9 @@ void init_i2c_pins(I2C_Type *ptr)
HPM_IOC->PAD[IOC_PAD_PB06].PAD_CTL = IOC_PAD_PAD_CTL_OD_SET(1) | IOC_PAD_PAD_CTL_PE_SET(1) | IOC_PAD_PAD_CTL_PS_SET(1);
HPM_IOC->PAD[IOC_PAD_PB07].PAD_CTL = IOC_PAD_PAD_CTL_OD_SET(1) | IOC_PAD_PAD_CTL_PE_SET(1) | IOC_PAD_PAD_CTL_PS_SET(1);
} else {
;
return status_invalid_argument;
}
return status_success;
}
void init_gpio_pins(void)
+1 -1
View File
@@ -14,7 +14,7 @@ extern "C" {
void init_py_pins_as_pgpio(void);
void init_uart_pins(UART_Type *ptr);
void init_uart_pin_as_gpio(UART_Type *ptr);
void init_i2c_pins(I2C_Type *ptr);
hpm_stat_t init_i2c_pins(I2C_Type *ptr);
void init_gpio_pins(void);
void init_spi_pins(SPI_Type *ptr);
void init_spi_pins_with_gpio_as_cs(SPI_Type *ptr);
+9 -3
View File
@@ -40,14 +40,20 @@ void os_tick_config(void)
void rtt_board_init(void)
{
board_init_clock();
/* initialize memory system
* NOTE: this must happen before board_init_console(), because the SDK console_init()
* calls setvbuf(), which allocates through the C library malloc() -> rt_malloc() and
* therefore requires the RT-Thread heap to be ready. Otherwise RT_ASSERT() fires in
* rt_smem_alloc() whenever RT_USING_DEBUG is enabled.
*/
rt_system_heap_init(RT_HW_HEAP_BEGIN, RT_HW_HEAP_END);
board_init_console();
board_init_pmp();
dma_mgr_init();
/* initialize memory system */
rt_system_heap_init(RT_HW_HEAP_BEGIN, RT_HW_HEAP_END);
/* Configure the OS Tick */
os_tick_config();
+6
View File
@@ -0,0 +1,6 @@
clean2:
-$(RM) $(CC_DEPS)$(C++_DEPS)$(C_UPPER_DEPS)$(CXX_DEPS)$(SECONDARY_FLASH)$(SECONDARY_SIZE)$(ASM_DEPS)$(S_UPPER_DEPS)$(C_DEPS)$(CPP_DEPS)
-$(RM) $(OBJS) *.elf
-@echo ' '
*.elf: $(wildcard board/linker_scripts/gcc/*.ld)
+53 -4
View File
@@ -7,6 +7,16 @@
/* rt_vsnprintf options */
#define RT_KLIBC_USING_VSNPRINTF_LONGLONG
#define RT_KLIBC_USING_VSNPRINTF_STANDARD
#define RT_KLIBC_USING_VSNPRINTF_DECIMAL_SPECIFIERS
#define RT_KLIBC_USING_VSNPRINTF_EXPONENTIAL_SPECIFIERS
#define RT_KLIBC_USING_VSNPRINTF_WRITEBACK_SPECIFIER
#define RT_KLIBC_USING_VSNPRINTF_INTEGER_BUFFER_SIZE 32
#define RT_KLIBC_USING_VSNPRINTF_DECIMAL_BUFFER_SIZE 32
#define RT_KLIBC_USING_VSNPRINTF_FLOAT_PRECISION 6
#define RT_KLIBC_USING_VSNPRINTF_MAX_INTEGRAL_DIGITS_FOR_DECIMAL 9
#define RT_KLIBC_USING_VSNPRINTF_LOG10_TAYLOR_TERMS 4
/* end of rt_vsnprintf options */
/* rt_vsscanf options */
@@ -102,7 +112,7 @@
#define RT_CONSOLEBUF_SIZE 128
#define RT_CONSOLE_DEVICE_NAME "uart0"
#define RT_USING_CONSOLE_OUTPUT_CTL
#define RT_VER_NUM 0x50300
#define RT_VER_NUM 0x50301
#define RT_BACKTRACE_LEVEL_MAX_NR 32
/* end of RT-Thread Kernel */
#define ARCH_RISCV
@@ -288,6 +298,10 @@
/* end of Kendryte SDK */
/* MM32 HAL & SDK Drivers */
/* end of MM32 HAL & SDK Drivers */
/* WCH HAL & SDK Drivers */
/* end of WCH HAL & SDK Drivers */
@@ -315,12 +329,24 @@
/* HPMicro SDK */
#define PKG_USING_HPM_SDK
#define PKG_USING_HPM_SDK_V110
#define PKG_USING_HPM_SDK_V113
/* end of HPMicro SDK */
/* FM33 Drivers */
/* end of FM33 Drivers */
/* FT32 HAL & SDK Drivers */
/* end of FT32 HAL & SDK Drivers */
/* NOVOSNS Drivers */
/* end of NOVOSNS Drivers */
/* N32 Drivers */
/* end of N32 Drivers */
/* end of HAL & SDK Drivers */
/* sensors drivers */
@@ -400,11 +426,11 @@
/* end of Arduino libraries */
/* end of RT-Thread online packages */
#define SOC_HPM5300_SERIES
#define SOC_SERIES_HPM5300
/* Hardware Drivers Config */
#define SOC_HPM5300
#define SOC_HPM5000
/* On-chip Peripheral Drivers */
@@ -416,6 +442,29 @@
#define BSP_UART0_TX_BUFSIZE 0
#define BSP_UART0_IRQ_PRIORITY 1
/* end of On-chip Peripheral Drivers */
/* HPMicro Interrupt Config */
/* HPMicro RT-Thread Interrupt Framework */
/* HPMicro Use Generic Startup Implementation */
/* end of HPMicro Use Generic Startup Implementation */
/* HPMicro RT-Thread backtrace configuration (experimental) */
/* end of HPMicro RT-Thread backtrace configuration (experimental) */
/* end of Hardware Drivers Config */
/* Third-Party Add-ons */
/* Segger SystemView Config */
/* end of Segger SystemView Config */
/* RT-Thread Insight Config */
/* end of RT-Thread Insight Config */
/* end of Third-Party Add-ons */
#endif
+12 -9
View File
@@ -3,7 +3,6 @@
import os
import sys
import rtconfig
if os.getenv('RTT_ROOT'):
@@ -11,7 +10,7 @@ if os.getenv('RTT_ROOT'):
else:
RTT_ROOT = os.path.normpath(os.getcwd() + '/../../..')
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
sys.path.insert(0, os.path.join(RTT_ROOT, 'tools'))
# toolchains options
@@ -60,9 +59,13 @@ if CROSS_TOOL == 'gcc':
else:
EXEC_PATH = r'/opt/riscv-gnu-gcc/bin'
else:
print("CROSS_TOOL = {} not yet supported" % CROSS_TOOL)
print("CROSS_TOOL = {} not yet supported, only gcc is supported".format(CROSS_TOOL))
exit(-1)
BUILD = 'flash_debug'
if os.getenv('RTT_BUILD_TYPE'):
BUILD = os.getenv('RTT_BUILD_TYPE')
else:
BUILD = 'flash_debug'
if PLATFORM == 'gcc':
PREFIX = 'riscv32-unknown-elf-'
@@ -82,7 +85,7 @@ if PLATFORM == 'gcc':
DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 ' + ' -ffunction-sections -fdata-sections -fno-common '
CFLAGS = DEVICE
AFLAGS = CFLAGS
LFLAGS = ARCH_ABI + ' --specs=nano.specs --specs=nosys.specs -u _printf_float -u _scanf_float -nostartfiles -Wl,--gc-sections '
LFLAGS = ARCH_ABI + ' --specs=nano.specs --specs=nosys.specs -nostartfiles -Wl,--gc-sections '
CPATH = ''
LPATH = ''
@@ -90,8 +93,8 @@ if PLATFORM == 'gcc':
if BUILD == 'ram_debug':
CFLAGS += ' -gdwarf-2'
AFLAGS += ' -gdwarf-2'
CFLAGS += ' -O0'
LFLAGS += ' -O0'
CFLAGS += ' -Og'
LFLAGS += ' -Og'
LINKER_FILE = 'board/linker_scripts/gcc/ram_rtt.ld'
elif BUILD == 'ram_release':
CFLAGS += ' -O2'
@@ -100,8 +103,8 @@ if PLATFORM == 'gcc':
elif BUILD == 'flash_debug':
CFLAGS += ' -gdwarf-2'
AFLAGS += ' -gdwarf-2'
CFLAGS += ' -O0'
LFLAGS += ' -O0'
CFLAGS += ' -Og'
LFLAGS += ' -Og'
CFLAGS += ' -DFLASH_XIP=1'
LINKER_FILE = 'board/linker_scripts/gcc/flash_rtt.ld'
elif BUILD == 'flash_release':
+20
View File
@@ -0,0 +1,20 @@
#ifndef RTCONFIG_PREINC_H__
#define RTCONFIG_PREINC_H__
/* Automatically generated file; DO NOT EDIT. */
/* RT-Thread pre-include file */
#define D25
#define HPM5361
#define HPMSOC_HAS_HPMSDK_DMAV2
#define HPM_SDK_L1C_NO_REENTRANT 1
#define HPM_SOC_ISR_NUM 73
#define RT_USING_LIBC
#define RT_USING_NEWLIBC
#define USE_DMA_DECLARE_EXT_ISR_M 1
#define _POSIX_C_SOURCE 1
#define _REENT_SMALL
#define __RTTHREAD__
#endif /*RTCONFIG_PREINC_H__*/
@@ -54,6 +54,8 @@
extern uint8_t __noncacheable_bss_start__[], __noncacheable_bss_end__[];
extern uint8_t __ramfunc_start__[], __ramfunc_end__[];
extern uint8_t __noncacheable_init_start__[], __noncacheable_init_end__[];
extern uint8_t __fast_ram_bss_start__[], __fast_ram_bss_end__[];
extern uint8_t __fast_ram_init_start__[], __fast_ram_init_end__[], __fast_ram_init_load_addr__[];
/* tbss section */
size = __tbss_end__ - __tbss_start__;
@@ -96,6 +98,18 @@
for (i = 0; i < size; i++) {
*(__noncacheable_init_start__ + i) = *(__noncacheable_init_load_addr__ + i);
}
/* fast_ram bss section */
size = __fast_ram_bss_end__ - __fast_ram_bss_start__;
for (i = 0; i < size; i++) {
*(__fast_ram_bss_start__ + i) = 0;
}
/* fast_ram init section LMA: etext + data length + ramfunc length + tdata length */
size = __fast_ram_init_end__ - __fast_ram_init_start__;
for (i = 0; i < size; i++) {
*(__fast_ram_init_start__ + i) = *(__fast_ram_init_load_addr__ + i);
}
#endif
}
@@ -19,14 +19,6 @@ _start:
la tp, __thread_pointer
.option pop
#ifdef __riscv_flen
/* Enable FPU */
li t0, CSR_MSTATUS_FS_MASK
csrrs t0, mstatus, t0
/* Initialize FCSR */
fscsr zero
#endif
/* Initialize stack pointer */
la t0, _stack
mv sp, t0
@@ -45,12 +37,20 @@ _start:
/* Initialize FCSR */
fscsr zero
#endif
/* Disable Vector mode */
csrci CSR_MMISC_CTL, 2
/* Initialize trap_entry base */
#ifdef HPM_USING_VECTOR_PREEMPTED_MODE
/* Initial machine trap-vector Base */
la t0, __vector_table
csrw mtvec, t0
/* Enable vectored external PLIC interrupt */
csrsi CSR_MMISC_CTL, 2
#else
/* Initial machine trap-vector Base */
la t0, SW_handler
csrw mtvec, t0
/* Disable vectored external PLIC interrupt */
csrci CSR_MMISC_CTL, 2
#endif
/* System reset handler */
call reset_handler
@@ -62,6 +62,7 @@ _start:
nmi_handler:
1: j 1b
#ifndef HPM_USING_RTTHREAD_INTERRUPT_FRAMEWORK
.weak default_irq_handler
.align 2
default_irq_handler:
@@ -74,3 +75,13 @@ default_irq_handler:
.endm
#include "vectors.S"
#else
.section .vector_table, "a"
.global __vector_table
.align 9
__vector_table:
.rept RT_HW_ISR_NUM
.long handle_trap
.endr
#endif /* HPM_USING_RTTHREAD_INTERRUPT_FRAMEWORK */
@@ -8,6 +8,5 @@ cwd = GetCurrentDir()
objs = []
objs = objs + SConscript(os.path.join(rtconfig.CHIP_NAME, 'SConscript'))
ASFLAGS = ' -I' + cwd
Return('objs')
File diff suppressed because it is too large. Load diff
+2 -2
View File
@@ -70,7 +70,7 @@ Open RT-Thread ENV command-line, and change directory to this BSP directory, the
- Users can download the project via the below command:
```console
%OPENOCD_HPMICRO%\openocd.exe -f boards\debug_scripts\probes\cmsis_dap.cfg -f boards\debug_scripts\soc\hpm5300.cfg -f boards\debug_scripts\boards\hpm5301evklite.cfg -c "init; halt; flash write_image erase rtthread.elf; reset; shutdown"
%OPENOCD_HPMICRO%\openocd.exe -f board\debug_scripts\openocd\probes\cmsis_dap.cfg -f board\debug_scripts\openocd\soc\hpm5300.cfg -f board\debug_scripts\openocd\boards\hpm5301evklite.cfg -c "init; halt; flash write_image erase rtthread.elf; reset; shutdown"
```
- Users can debug the project via the below command:
@@ -78,7 +78,7 @@ Open RT-Thread ENV command-line, and change directory to this BSP directory, the
- Connect debugger via `OpenOCD`:
```console
%OPENOCD_HPMICRO%\openocd.exe -f boards\debug_scripts\probes\cmsis_dap.cfg -f boards\debug_scripts\soc\hpm5300.cfg -f boards\debug_scripts\boards\hpm5301evklite.cfg
%OPENOCD_HPMICRO%\openocd.exe -f board\debug_scripts\openocd\probes\cmsis_dap.cfg -f board\debug_scripts\openocd\soc\hpm5300.cfg -f board\debug_scripts\openocd\boards\hpm5301evklite.cfg
```
- Start Debugger via `GDB`:
+2 -2
View File
@@ -70,14 +70,14 @@
- 通过如下命令完成下载:
```console
%OPENOCD_HPMICRO%\openocd.exe -f boards\debug_scripts\probes\cmsis_dap.cfg -f boards\debug_scripts\soc\hpm5300.cfg -f boards\debug_scripts\boards\hpm5301evklite.cfg -c "init; halt; flash write_image erase rtthread.elf; reset; shutdown"
%OPENOCD_HPMICRO%\openocd.exe -f board\debug_scripts\openocd\probes\cmsis_dap.cfg -f board\debug_scripts\openocd\soc\hpm5300.cfg -f board\debug_scripts\openocd\boards\hpm5301evklite.cfg -c "init; halt; flash write_image erase rtthread.elf; reset; shutdown"
```
- 通过如下命令实现调试:
- 通过 `OpenOCD` 来连接开发板:
```console
%OPENOCD_HPMICRO%\openocd.exe -f boards\debug_scripts\probes\cmsis_dap.cfg -f boards\debug_scripts\soc\hpm5300.cfg -f boards\debug_scripts\boards\hpm5301evklite.cfg
%OPENOCD_HPMICRO%\openocd.exe -f board\debug_scripts\openocd\probes\cmsis_dap.cfg -f board\debug_scripts\openocd\soc\hpm5300.cfg -f board\debug_scripts\openocd\boards\hpm5301evklite.cfg
```
- 通过 `GDB` 实现调试:
```console
-1
View File
@@ -7,7 +7,6 @@ cwd = GetCurrentDir()
objs = []
list = os.listdir(cwd)
ASFLAGS = ' -I' + cwd
for d in list:
path = os.path.join(cwd, d)
+10 -9
View File
@@ -16,13 +16,16 @@ except:
exit(-1)
def bsp_pkg_check():
import subprocess
if GetOption('clean'):
return
need_update = True
for p in os.listdir("packages"):
if p.startswith("hpm_sdk-"):
need_update = False
break
if os.path.isdir("packages"):
for p in os.listdir("packages"):
if p.startswith("hpm_sdk-"):
need_update = False
break
if need_update:
print("\n===============================================================================")
print("Dependency packages missing, please running 'pkgs --update'...")
@@ -64,9 +67,6 @@ if os.path.exists(os.path.join(SDK_ROOT, 'libraries')):
else:
libraries_path_prefix = os.path.join(os.path.dirname(SDK_ROOT), 'libraries')
SDK_LIB = libraries_path_prefix
Export('SDK_LIB')
GDB = rtconfig.GDB
@@ -78,6 +78,7 @@ objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
# includes rtt drivers
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'drivers', 'SConscript'), variant_dir='build/libraries/drivers', duplicate=0))
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'misc', 'SConscript'), variant_dir='build/libraries/misc', duplicate=0))
# make a building
DoBuilding(TARGET, objs)
@@ -1,5 +1,3 @@
import rtconfig
from building import *
cwd = GetCurrentDir()
@@ -19,7 +19,10 @@ int main(void)
{
static uint32_t led_thread_arg = 0;
rt_thread_t led_thread = rt_thread_create("led_th", thread_entry, &led_thread_arg, 1024, 1, 10);
rt_thread_startup(led_thread);
if (led_thread != RT_NULL)
{
rt_thread_startup(led_thread);
}
return 0;
}
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -11,7 +11,7 @@ src = Split("""
""")
CPPPATH = [cwd]
CPPDEFINES=['D25', 'HPM5361']
CPPDEFINES=['D25', 'HPM5301']
group = DefineGroup('Board', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES)
@@ -16,7 +16,7 @@
# 0 - SPI / 1 - DPI / 2 - QPI / 3 - OPI
# [19:16] Quad Enable Sequence (for the device support SFDP 1.0 only)
# 0 - Not needed
# 1 - QE bit is at bit 6 in Status Register 1
# 1 - QE bit is at bit6 in Status Register 1
# 2 - QE bit is at bit1 in Status Register 2
# 3 - QE bit is at bit7 in Status Register 2
# 4 - QE bit is at bit1 in Status Register 2 and should be programmed by 0x31
@@ -46,27 +46,15 @@
# - flash ctrl index: 0xF3000000
# - base address: 0x80000000
# - flash size: 0x2000000
# - flash option0: 0x7
flash bank xpi0 hpm_xpi 0x80000000 0x2000000 1 1 $_TARGET0 0xF3000000 0x6 0x1000
# - flash option0: 0x5
# - flash option1: 0x1000
flash bank xpi0 hpm_xpi 0x80000000 0x2000000 1 1 $_TARGET0 0xF3000000 0x5 0x1000
proc init_clock {} {
$::_TARGET0 riscv dmi_write 0x39 0xF4002000
$::_TARGET0 riscv dmi_write 0x3C 0x1
$::_TARGET0 riscv dmi_write 0x39 0xF4002000
$::_TARGET0 riscv dmi_write 0x3C 0x2
$::_TARGET0 riscv dmi_write 0x39 0xF4000800
$::_TARGET0 riscv dmi_write 0x3C 0xFFFFFFFF
$::_TARGET0 riscv dmi_write 0x39 0xF4000810
$::_TARGET0 riscv dmi_write 0x3C 0xFFFFFFFF
$::_TARGET0 riscv dmi_write 0x39 0xF4000820
$::_TARGET0 riscv dmi_write 0x3C 0xFFFFFFFF
$::_TARGET0 riscv dmi_write 0x39 0xF4000830
$::_TARGET0 riscv dmi_write 0x3C 0xFFFFFFFF
mww 0xF4000800 0xFFFFFFFF
mww 0xF4000810 0xFFFFFFFF
mww 0xF4000820 0xFFFFFFFF
mww 0xF4000830 0xFFFFFFFF
echo "clocks has been enabled!"
}
@@ -1,7 +1,11 @@
# Copyright (c) 2021 HPMicro
# Copyright (c) 2023,2025 HPMicro
# SPDX-License-Identifier: BSD-3-Clause
set _CHIP hpm5301
if { [info exists CHIPNAME] } {
set _CHIP $CHIPNAME
} else {
set _CHIP hpm5361
}
set _CPUTAPID 0x1000563D
jtag newtap $_CHIP cpu -irlen 5 -expected-id $_CPUTAPID
@@ -11,3 +15,10 @@ target create $_TARGET0 riscv -chain-position $_CHIP.cpu -coreid 0
$_TARGET0 configure -work-area-phys 0x00000000 -work-area-size 0x20000 -work-area-backup 0
targets $_TARGET0
source [file join [file dirname [info script]] hpm_common.cfg]
source [file join [file dirname [info script]] hpm_common_csr_lite.cfg]
proc reset_soc {} {
sba_write_mem 0xF410001C 24000000
}
Loaded 100 of 434 files, more files were not shown because too many files have changed in this diff. Show more