1# HPMicro HPM5300EVK BSP(Board Support Package) Introduction 2 3[中文页](README_zh.md) | 4 5## Introduction 6 7This document provides brief introduction of the BSP (board support package) for the HPM5300EVK development board. 8 9The document consists of the following parts: 10 11- HPM5300EVK Board Resources Introduction 12- Quickly Getting Started 13- Refreences 14 15By 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. 16 17## Board Resources Introduction 18 19HPM5300EVK is a development board based on the RISC-V core launched by HPMicro, with rich on-board resources and on-chip resources for motor control, etc. 20 21 22 23## Peripheral Condition 24 25Each peripheral supporting condition for this BSP is as follows: 26 27 28| **On-board Peripherals** | **Support** | **Note** | 29| ------------------------ | ----------- | ------------------------------------- | 30| USB | √ | | 31| QSPI Flash | √ | | 32| GPIO | √ | | 33| SPI | √ | | 34| I2C | √ | | 35| CAN | √ | | 36| On-Board Debugger | √ | ft2232 | 37 38 39## Execution Instruction 40 41### Quickly Getting Started 42 43The BSP support being build via the 'scons' command, below is the steps of compiling the example via the 'scons' command 44 45#### Parpare Environment 46- Step 1: Prepare [RT-Thread ENV](https://www.rt-thread.org/download.html#download-rt-thread-env-tool) 47- Step 2: Prepare [toolcahin](https://github.com/helloeagleyang/riscv32-gnu-toolchain-win/archive/2022.04.12.zip) 48 - Download the package and extract it into a specified directory, for example: `C:\DevTools\riscv32-gnu-toolchain` 49- Step 3: Set environment variable `RTT_RISCV_TOOLCHAIN` to `<TOOLCHAIN_DIR>\bin` 50 - For example: `C:\DevTools\riscv32-gnu-toolchain\bin` 51- Step 4: Prepare [OpenOCD](https://github.com/hpmicro/rtt-debugger-support-package/archive/v0.4.0.zip) 52 - Download and extract it to specified directory, for example: `C:\DevTools\openocd-hpmicro` 53 - Add `OpenOCD` environment variable `OPENOCD_HPMICRO` to `<OPENOCD_HPMICRO_DIR>\bin` 54 - For example: `C:\DevTools\openocd-hpmicro\bin` 55 56#### Configure and Build project 57 58Open RT-Thread ENV command-line, and change directory to this BSP directory, then users can: 59 60- Configure the project via `menuconfig` in `RT-Thread ENV` 61- Build the project using `scons -jN`, `N` equals to the number of CPU cores 62- Clean the project using `scons -c` 63 64#### Hardware Connection 65 66- Switch BOOT pin to 2'b00 67- Connect the `PWR_DEBUG` port to PC via TYPE-C cable 68 69 70#### Dowload / Debug 71 72- Users can download the project via the below command: 73 ```console 74 %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" 75 ``` 76 77- Users can debug the project via the below command: 78 79 - Connect debugger via `OpenOCD`: 80 81```console 82%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 83``` 84 - Start Debugger via `GDB`: 85 86```console 87%RTT_EXEC_PATH%\riscv32-unknown-elf-gdb.exe rtthread.elf 88``` 89 - In the `gdb shell`, type the following commands: 90 91```console 92load 93c 94``` 95 96### **Running Results** 97 98Once the project is successfully downloaded, the system runs automatically. The LED on the board will flash periodically. 99 100Connect 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: 101 102``` 103 \ | / 104- RT - Thread Operating System 105 / | \ 5.1.0 build Aug 16 2023 18:18:18 106 2006 - 2024 Copyright by RT-Thread team 107``` 108 109## **References** 110 111- [RT-Thread Documnent Center](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/README) 112- [RT-Thread Env](https://github.com/RT-Thread/rtthread-manual-doc/blob/master/env/env.md) 113- [HPM5300EVK RT-Thread BSP Package](https://github.com/hpmicro/rtt-bsp-hpm5300evk)