Skip to content

Commit

Permalink
Support for HiFive Unmatched (#386)
Browse files Browse the repository at this point in the history
This PR adds board support for HiFive Unmatched. (#384)
You can generate SD card image for unmatched using buildroot by single
`make` command.
It will not be available for production, but it will allow for easy
testing.

I checked that almost all example runs correctly, but only `attestor.ke`
throw runtime error bacause the package does not include firmware image
(`fw_jump.elf`) correctly. Same thing is happening with qemu target.

## New items/Changes
- Add buildroot config for unmatched in `overlays/keystone/configs`
- Add board specific configs/patches in `overlays/keystone/board`
- Some patches in `freedom-u-sdk` & `meta-sifive` (2023.08) are included
- Implement secureboot same as bootrom in u-boot. This is applied via a
patch.
- Unmatched's platform overrides in upstream OpenSBI is added to
`sm/plat`
- Add make target to flush SD card image
- Other minor modifications

## Known issue
Porting issue mentioned
[here](https://groups.google.com/g/keystone-enclave-forum/c/6vnr6pWPZjw/m/HBeq4a5OBAAJ)
is still remaining.
With default `SMM_SIZE` (`0x200000`), machine hangs when switching to
S-Mode entering u-boot proper (when function `sbi_hart_switch_mode` is
called).

In this PR, change `SMM_SIZE` to `0x80000` same as sbi domain region by
passing compile flag for unmatched target. This is temporary fix.

## Remarks
FU740 has waymasks same as FU540. Waymasking implemented for FU540 can
be ported to FU740, I think.
  • Loading branch information
Nanamiiiii authored Dec 13, 2023
1 parent 58a5151 commit a06b054
Show file tree
Hide file tree
Showing 52 changed files with 6,781 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
*~
*.swp
.venv/
build/
build*/
riscv/
riscv64/
riscv32/
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ include mkutils/log.mk
BUILDROOT_CONFIGFILE ?= qemu_riscv$(KEYSTONE_BITS)_virt_defconfig
ifeq ($(KEYSTONE_PLATFORM),mpfs)
EXTERNALS += microchip
else ifeq ($(KEYSTONE_PLATFORM),unmatched)
BUILDROOT_CONFIGFILE = riscv64_hifive_unmatched_defconfig
endif

# Highest priority external
Expand Down Expand Up @@ -114,3 +116,4 @@ linux-configure: $(BUILDROOT_BUILDDIR)/.config
#################

-include mkutils/plat/$(KEYSTONE_PLATFORM)/run.mk

25 changes: 25 additions & 0 deletions mkutils/plat/unmatched/run.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#########################
## Flush SD card image ##
#########################

DEVICE ?=
EXTEND ?= 0
FLUSH_IMAGE ?= $(BUILDROOT_BUILDDIR)/images/sdcard.img

flush:
ifeq ($(DEVICE),)
$(call log,error,Set target device to env DEVICE)
else
$(call log,info,Flushing SD image)
sudo dd if=$(FLUSH_IMAGE) of=$(DEVICE) bs=64k iflag=fullblock oflag=direct conv=fsync status=progress

ifeq ($(EXTEND),1)
$(call log,info,Extending rootfs end of the block device)
echo "w" | sudo fdisk $(DEVICE)
echo "- +" | sudo sfdisk -N 3 $(DEVICE)
sudo e2fsck -f $(DEVICE)3
sudo resize2fs $(DEVICE)3
endif

endif

5 changes: 5 additions & 0 deletions overlays/keystone/board/sifive/hifive-unmatched/extlinux.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
default buildroot
label buildroot
kernel /boot/Image.gz
fdt /boot/hifive-unmatched-a00.dtb
append root=/dev/mmcblk0p3 rootfstype=ext4 rootwait console=ttySIF0,115200 earlycon
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
image sdcard.img {
hdimage {
partition-table-type = "gpt"
}

partition u-boot-spl {
image = "u-boot-spl.bin"
offset = 17K
partition-type-uuid = 5b193300-fc78-40cd-8002-e86c45580b47
}

partition u-boot {
image = "u-boot.itb"
offset = 1041K
partition-type-uuid = 2e54b353-1271-4842-806f-e436d6af6985
}

partition rootfs {
image = "rootfs.ext4"
partition-type-uuid = 0fc63daf-8483-4772-8e79-3d69d8477de4
bootable = true
}
}
Loading

0 comments on commit a06b054

Please sign in to comment.