The HPM SDK Project is a software development kit based on HPMicro's MCUs, which supports a wide range of MCUs, based on the BSD license, including drivers, middleware and RTOS, such as littlevgl/ lwIP/ TinyUSB/ FreeRTOS, etc. It supports a large number of Boards.
1. Grab a copy of toolchain zip package and unzip to certain path, take TOOLCHAIN_PATH for example, (riscv32-unknown-elf-gcc is supposed to be found in TOOLCHAIN_PATH/bin)
2. Declare a system environment variable of "GNURISCV_TOOLCHAIN_PATH" to the path of toolchain:
- Linux, taking zsh for example (replace TOOLCHAIN_PATH with the path of toolchain on your workstation):
```shell
export GNURISCV_TOOLCHAIN_PATH=TOOLCHAIN_PATH
export HPM_SDK_TOOLCHAIN_VARIANT=
```
- Windows command prompt:
```Batchfile
set GNURISCV_TOOLCHAIN_PATH=TOOLCHAIN_PATH
set HPM_SDK_TOOLCHAIN_VARIANT=
```
- nds-gcc:
1. Grab a copy of toolchain zip package and unzip to certain path, take TOOLCHAIN_PATH for example, (riscv32-elf-gcc is supposed to be found in TOOLCHAIN_PATH/bin)
2. Declare two system environment variables: "GNURISCV_TOOLCHAIN_PATH" to the path of toolchain; "HPM_SDK_TOOLCHAIN_VARIANT" to "nds-gcc":
- Linux, taking zsh for example (replace TOOLCHAIN_PATH with the path of toolchain on your workstation):
```shell
export GNURISCV_TOOLCHAIN_PATH=TOOLCHAIN_PATH
export HPM_SDK_TOOLCHAIN_VARIANT=nds-gcc
```
- Windows command prompt:
```Batchfile
set GNURISCV_TOOLCHAIN_PATH=TOOLCHAIN_PATH
set HPM_SDK_TOOLCHAIN_VARIANT=nds-gcc
```
Note: For windows, Andes compiler needs following libraries:
- cygwin1.dll
- cygncursesw-10.dll
make sure its path is appended to the system environment variable "PATH".
- Environment Variables:
- Using provided scripts to set the environment variable:
- Linux:
```shell
$ source env.sh
```
- Windows command prompt:
```Batchfile
env.cmd
```
- Manually declare a environment variable of "HPM_SDK_BASE" to the path of SDK root:
- Linux, taking zsh for example (assume SDK is located at $HOME/hpm_sdk):
```shell
export HPM_SDK_BASE=$HOME/hpm_sdk
```
- Windows command prompt (assume SDK is located at c:\hpm_sdk):
When it's done the elf and other application related files can be found in the directory of "output", like map file, assembly source or binary file
- Quick Guide to Run/Debug An Application (hello_world):
1. Wire up the board, including debug probe (by default it supports jlink) and serial port
2. power up the board
3. open console connecting to the debug console (target serial port) with baudrate of 115200
4. get a copy of openocd. it can be installed via package management system or downloaded from sourceforge or github. But please make sure its revision is > 0.11
5. Go to SDK root directory, run provided environment variable scripts:
- Linux:
```shell
$ source env.sh
```
- Windows command prompt:
```Batchfile
env.cmd
```
or setup environment variable OPENOCD_SCRIPTS manually:
6. Start openocd with several configuration files in order of type of probe, type of core, type of board. For example, the following command will setup an openocd gdb server with ft2232 to single core on hpm6750evk
Note: If using FTDI debugger and meet `Error: libusb_open() failed with LIBUSB_ERROR_NOT_FOUND` , please check the FTDI usb driver. If it is not installed correctly, use [zadig](https://github.com/pbatard/libwdi/releases/download/b730/zadig-2.5.exe) to update:
10. on the debug console, "hello_world" is printed.
- Build An Application with Segger Embedded Studio
- Segger Embedded Studio for RISC-V can be downloaded from https://www.segger.com/downloads/embedded-studio/
- Project file for Segger Embedded Studio will be generated while generating build files for Ninja mentioned in "Build An Application with GNU GCC toolchain"->"4. Generate build files for Ninja"
- The project file (.emProject) can be found at build/segger_embedded_studio/.
Note: openocd executable needs to be found in the PATH variable of current console, otherwise debug configuration will not be generated to project file and needs to be configured manually in Segger Embedded Studio later.