Skip to content

Commit

Permalink
add hpmicro opensbi based linux support
Browse files Browse the repository at this point in the history
- add hpm6800evk support
  • Loading branch information
Zihan Xu committed Sep 18, 2024
1 parent 3a3ccfc commit 62baf2a
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 64 deletions.
30 changes: 3 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,20 @@
# Buildroot for HPMicro MCUs

[![Build](https://github.com/hpm-rs/buildroot/actions/workflows/build.yml/badge.svg)](https://github.com/hpm-rs/buildroot/actions/workflows/build.yml)

为 HPMicro MCUs 生成可启动的 Linux 镜像。

[![asciicast](https://asciinema.org/a/JY1MJ8BY5g77wwIlEk9NCYnWn.svg)](https://asciinema.org/a/JY1MJ8BY5g77wwIlEk9NCYnWn)

**考虑到 Buildroot 编译一次耗时过长,提供了 pre-built 镜像,可在最新的 [CI 构建](https://github.com/hpm-rs/buildroot/actions/workflows/build.yml) 中下载。**

如果你想在本地环境编译,请参考下列说明。

## 获取源码

```shell
git clone https://github.com/hpm-rs/buildroot.git
```

## 配置编译环境

### Ubuntu 22.04

```shell
sudo apt-get install bc bison build-essential flex libssl-dev unzip
# 安装 rust 编译环境
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```

## 编译

```shell
make hpmicro_hpm6360evk_defconfig
make hpmicro_hpm6800evk_defconfig
make all
```

## 烧录

生成的镜像路径为 `output/images/flash.img`。可使用 [hpm_isp](https://github.com/tfx2001/hpm_isp) 工具进行烧录。
生成的镜像路径为 `output/images/flash.img`。可使用 [hpm_manufacturing_tool](https://github.com/hpmicro/hpm_manufacturing_tool) 工具进行烧录。

修改启动模式选择管脚为 `BOOT_MODE[1:0]=0b10` 后将 USB0 连接至 PC,运行如下命令进行烧录。

```shell
hpm_isp flash 0 write 0x0 output/images/flash.img
```
修改启动模式选择管脚为 `BOOT_MODE[1:0]=0b10` 后将 USB0 连接至 PC,运行hpm_manufacturing_tool进行烧录。
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Minimal Flash image for HPMicro HPM6360 Evaluate Kit

flash w25q128 {
pebsize = 64K
numpebs = 256
Expand All @@ -12,18 +10,26 @@ image flash.img {

flashtype = "w25q128"

partition rustsbi {
image = "rustsbi.bin"
size = 64K
partition opensbiloader {
size = 64k
image = "opensbiloader.bin"
}

partition opensbi {
offset = 64K
image = "fw_jump.bin"
size = 192K
}

partition kernel {
image = "Image"
size = 3M
offset = 256K
size = 2880K
}

partition dtb {
image = "hpm6360-evk.dtb"
image = "hpm6800evk.dtb"
offset = 3136K
size = 64K
}

Expand Down
1 change: 1 addition & 0 deletions boot/Config.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ source "boot/mv-ddr-marvell/Config.in"
source "boot/mxs-bootlets/Config.in"
source "boot/optee-os/Config.in"
source "boot/opensbi/Config.in"
source "boot/hpmicro_loader/Config.in"
source "boot/rustsbi-hpm/Config.in"
source "boot/s500-bootloader/Config.in"
source "boot/shim/Config.in"
Expand Down
11 changes: 11 additions & 0 deletions boot/hpmicro_loader/Config.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
config BR2_TARGET_HPMICRO_LOADER
bool "hpmicro_opensbi_loader"
help
Lowlevel loader for hpmciro SOCs using OpenSBI

if BR2_TARGET_HPMICRO_LOADER
config BR2_TARGET_HPMICRO_BOARD_NAME
string "HPMicro Board Name"
help
Enter HPMicro Board Name. Example: hpm6800evk. This is passed to hpm_sdk's cmake arg "-DBOARD={}":"https://github.com/hpmicro/hpm_sdk"
endif
22 changes: 22 additions & 0 deletions boot/hpmicro_loader/hpmicro_loader.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
################################################################################
#
# ramspeed
#
################################################################################
HPMICRO_LOADER_VERSION = 5acfbb3dd810b56ea1e7837b00660c79d8975d9a
HPMICRO_LOADER_SITE = https://github.com/hpmicro/hpm_opensbi_loader.git
HPMICRO_LOADER_SITE_METHOD = git
HPMICRO_LOADER_GIT_SUBMODULES = YES
HPMICRO_LOADER_CMAKE_BACKEND = ninja
HPMICRO_LOADER_SUPPORTS_IN_SOURCE_BUILD = No

HPMICRO_LOADER_CONF_OPTS = -DBOARD=$(BR2_TARGET_HPMICRO_BOARD_NAME) -DHPM_BUILD_TYPE=flash_xip -DCMAKE_BUILD_TYPE=debug -DCMAKE_C_FLAGS="-g" -DCMAKE_EXE_LINKER_FLAGS="" -DCMAKE_SHARED_LINKER_FLAGS="" -DCMAKE_MODULE_LINKER_FLAGS=""
HPMICRO_LOADER_CONF_ENV = HPM_SDK_BASE=$(@D)/hpm_sdk HPM_SDK_TOOLCHAIN_VARIANT=gcc

define HPMICRO_LOADER_INSTALL_TARGET_CMDS
dd if=/dev/zero of=$(@D)/buildroot-build/output/temp.bin bs=1 count=1024
cat $(@D)/buildroot-build/output/temp.bin $(@D)/buildroot-build/output/demo.bin > $(@D)/buildroot-build/output/opensbiloader.bin
$(INSTALL) -D -m 0644 $(@D)/buildroot-build/output/opensbiloader.bin $(BINARIES_DIR)/opensbiloader.bin
endef

$(eval $(cmake-package))
30 changes: 0 additions & 30 deletions configs/hpmicro_hpm6360evk_defconfig

This file was deleted.

49 changes: 49 additions & 0 deletions configs/hpmicro_hpm6800evk_defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
BR2_riscv=y
BR2_riscv_custom=y

BR2_RISCV_ISA_RVI=y
BR2_RISCV_ISA_RVM=y
BR2_RISCV_ISA_RVA=y
BR2_RISCV_ISA_RVC=y
BR2_RISCV_32=y
BR2_RISCV_ABI_ILP32=y
BR2_BINFMT_FLAT=y
# BR2_RISCV_USE_MMU is not set
BR2_KERNEL_HEADERS_VERSION=y
BR2_DEFAULT_KERNEL_VERSION="6.10"
BR2_TOOLCHAIN_BUILDROOT_USE_SSP=y
BR2_ENABLE_LTO=y
BR2_ROOTFS_MERGED_USR=y
BR2_TARGET_GENERIC_GETTY_PORT="hvc0"
# BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW is not set
BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh"
BR2_ROOTFS_POST_IMAGE_SCRIPT_ARGS="-c board/hpmicro/hpm6800evk/genimage_opensbi.cfg"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_TARBALL=y
BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="$(call github,hpmicro,linux,5fe642640e65de232154bf1fbe479676494cac40)/linux-5fe642640e65de232154bf1fbe479676494cac40.tar.gz"
BR2_LINUX_KERNEL_DEFCONFIG="nommu_hpmicro"
BR2_LINUX_KERNEL_DTS_SUPPORT=y
BR2_LINUX_KERNEL_INTREE_DTS_NAME="hpmicro/hpm6800evk"
BR2_PACKAGE_BUSYBOX_CONFIG="board/hpmicro/hpm6800evk/busybox.config"
# BR2_PACKAGE_IFUPDOWN_SCRIPTS is not set
BR2_TARGET_ROOTFS_SQUASHFS=y
BR2_TARGET_ROOTFS_SQUASHFS4_LZ4=y
# BR2_TARGET_ROOTFS_TAR is not set
BR2_TARGET_OPENSBI=y
# BR2_TARGET_OPENSBI_LATEST_VERSION is not set
# BR2_TARGET_OPENSBI_CUSTOM_VERSION is not set
# BR2_TARGET_OPENSBI_CUSTOM_TARBALL is not set
BR2_TARGET_OPENSBI_CUSTOM_GIT=y
BR2_TARGET_OPENSBI_CUSTOM_REPO_URL="https://github.com/hpmicro/opensbi.git"
BR2_TARGET_OPENSBI_CUSTOM_REPO_VERSION="442c39695426da49740d33203c43dc2942d18633"
BR2_TARGET_OPENSBI_VERSION="442c39695426da49740d33203c43dc2942d18633"
BR2_TARGET_OPENSBI_PLAT="hpmicro"
# BR2_TARGET_OPENSBI_INSTALL_DYNAMIC_IMG is not set
BR2_TARGET_OPENSBI_INSTALL_JUMP_IMG=y
# BR2_TARGET_OPENSBI_INSTALL_PAYLOAD_IMG is not set
# BR2_TARGET_OPENSBI_LINUX_PAYLOAD is not set
BR2_TARGET_OPENSBI_ADDITIONAL_VARIABLES="HPMSOC=HPM6800"
BR2_TARGET_HPMICRO_LOADER=y
BR2_TARGET_HPMICRO_BOARD_NAME="hpm6800evk"
BR2_PACKAGE_HOST_GENIMAGE=y
BR2_PACKAGE_HOST_MKPASSWD=y

0 comments on commit 62baf2a

Please sign in to comment.