Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update readme #113

Merged
merged 7 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 42 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ Penglai uses Docker for building and uses submodules to track different componet
**For openEuler version $\lt$ 23:**

There is no need to compile uboot.
```
# Fetch the uboot submodule
git submodule update --init --recursive
```

**For openEuler version $\ge$ 23:**

Expand All @@ -52,7 +56,7 @@ Follow the instructions in openeuler riscv gitee to compile uboot for OE-23.X.
# Fetch the uboot submodule
git submodule update --init --recursive
cd ./u-boot
make qemu-riscv64_defconfig
make qemu-riscv64_smode_defconfig
make ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- -j$(nproc)
```

Expand Down Expand Up @@ -81,18 +85,16 @@ For oe versions greater than 23, you can access the source code after [Run openE
cd /home/penglai/penglai-enclave/opensbi-0.9
mkdir -p build-oe/qemu-virt
CROSS_COMPILE=riscv64-unknown-linux-gnu- make O=build-oe/qemu-virt PLATFORM=generic FW_PAYLOAD=y FW_PAYLOAD_PATH=/home/penglai/penglai-enclave/Image

Note: the /home/penglai/penglai-enclave/Image is the image compiled openEuler Kernel Image.

**For openEuler version $\ge$ 23:**

```
cp ../Penglai-Enclave-sPMP/u-boot/u-boot.bin .
docker run -v $(pwd):/home/penglai/penglai-enclave -w /home/penglai/penglai-enclave --rm -it ddnirvana/penglai-enclave:v0.5 bash
cd /home/penglai/penglai-enclave/opensbi-1.2
rm -rf build-oe/qemu-virt
mkdir -p build-oe/qemu-virt
CROSS_COMPILE=riscv64-unknown-linux-gnu- make O=build-oe/qemu-virt PLATFORM=generic FW_PAYLOAD=y FW_PAYLOAD_PATH=/home/penglai/penglai-enclave/u-boot.bin -j$(nproc)
CROSS_COMPILE=riscv64-unknown-linux-gnu- make O=build-oe/qemu-virt PLATFORM=generic FW_PAYLOAD=y FW_PAYLOAD_PATH=/home/penglai/penglai-enclave/u-boot/u-boot.bin -j$(nproc)
```

A simpler way:
Expand All @@ -106,7 +108,7 @@ A simpler way:

**Note**: if you use the simpler way, please **copy** your latest kernel *Image* file to the root dir of the repo.

### Build Penglai SDK
### Build Penglai driver module

**For openEuler version $\lt$ 23:**

Expand All @@ -122,7 +124,7 @@ It will generate penglai.ko in the penglai-enclave-driver dir.

When openEuler version is >= 23, you need to start openEuler in qemu as the next step [Run openEuler with Penglai Supports](#run-openeuler-with-penglai-supports) finished before compiling penglai-driver.


### Build Penglai sdk

When penglai.ko is completed,following the commnads to build user-level sdk and demos:

Expand Down Expand Up @@ -166,7 +168,7 @@ Run VM in QEMU:

- The test qemu version is 5.2.0 or 8.0.0.
- The fw_payload.elf is the opensbi file.
- The openEuler-preview.riscv64.qcow2 is the disk image for openEuler (You can download from https://repo.openeuler.org/openEuler-preview/RISC-V/Image/).
- The openEuler-preview.riscv64.qcow2 is the disk image for openEuler (You can download from https://repo.openeuler.org/openEuler-preview/RISC-V/).
- To login, username is "root", passwd is "openEuler12#$"

Note: a script, run_openeuler.sh is provided to execute the above command easily
Expand Down Expand Up @@ -195,6 +197,13 @@ qemu-system-riscv64 -nographic -machine virt \
-netdev user,id=usernet,hostfwd=tcp::12055-:22 \
-device qemu-xhci -usb -device usb-kbd -device usb-tablet
```
Once started, you should execut the following command to obtain the kernel module compilation environment. Execute the following commands and the kernel source code will be downloaded locally, the path is `/usr/lib/modules/6.1.19-2.oe2303.riscv64`(For openEuler 2303).
```
#in VM
cd ~/
dnf install -y kernel-devel kernel-source
```


a simple way:

Expand All @@ -204,53 +213,54 @@ a simple way:
./run_openeuler.sh -k 2303 -o 1.2
```

### RUN demo

**For openEuler version $\lt$ 23:**

**Copy files to openEuler Qemu**

You can copy any files to the VM using *scp*.

For example, to run the following demo, you should:

#For version 23, there is no need to copy penglai.ko
scp -P 12055 penglai-enclave-driver/penglai.ko root@localhost:~/
scp -P 12055 sdk/demo/host/host root@localhost:~/
scp -P 12055 sdk/demo/prime/prime root@localhost:~/

The passwd is "openEuler12#$"

**For openEuler version $\ge$ 23:**

After starting the VM, you need to get the source code in the qemu VM and execute compile kernel moudle with penglai-driver for openEuler version $\ge$ 23.

Copy penglai-enclave-driver to the root/ directory of the oe VM:

```
#in host
scp -P 12055 penglai-enclave-driver root@localhost:~/
scp -P -r 12055 penglai-enclave-driver root@localhost:~/
scp -P 12055 sdk/demo/host/host root@localhost:~/
scp -P 12055 sdk/demo/prime/prime root@localhost:~/
```

Execute the following commands and the kernel source code will be downloaded locally, the path is `/usr/lib/modules/6.1.19-2.oe2303.riscv64`.

```
#in VM
cd ~/
sudo dnf install -y kernel-devel kernel-source
```

Go into the penglai-enclave-driver directory and modify the original kernel source path openeuler-kernel in the Makefile from `../openeuler-kernel/`to `/usr/lib/modules/6.1.19-2.oe2303.riscv64/build/`.
Go into the penglai-enclave-driver directory and modify the original kernel source path openeuler-kernel in the Makefile from `../openeuler-kernel/`to `/usr/lib/modules/$(shell uname -r)/build/`.

Compile and install the kernel module:

```
cd ~/penglai-enclave-driver
vim Makefile #modify source path
#modify source path
sed -i 's|make -C ../openeuler-kernel/ ARCH=riscv M=$(PWD) modules|make -C /usr/lib/modules/$(shell uname -r)/build ARCH=riscv M=$(PWD) modules|' Makefile > /dev/null 2>&1
make -j$(nproc)
insmod penglai.ko
```

### RUN demo

**Copy files to openEuler Qemu**

You can copy any files to the VM using *scp*.

For example, to run the following demo, you should:

scp -P 12055 penglai-enclave-driver/penglai.ko root@localhost:~/
scp -P 12055 sdk/demo/host/host root@localhost:~/
scp -P 12055 sdk/demo/prime/prime root@localhost:~/

The passwd is "openEuler12#$"

**Insmod the enclave-driver**

If you already installed in the previous step, you don't need to repeat it

```
cd ~/
insmod penglai.ko
```

Expand Down
8 changes: 4 additions & 4 deletions docker_cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function print_usage() {
# no arguments
if [ $# == 0 ]; then
echo "Default: building penglai demo image"
docker run -v $(pwd):/home/penglai/penglai-enclave -w /home/penglai/penglai-enclave --rm -it ddnirvana/penglai-enclave:v0.1 bash scripts/build_opensbi.sh
docker run -v $(pwd):/home/penglai/penglai-enclave -w /home/penglai/penglai-enclave --rm -it fly0307/penglai-enclave:v0.1 bash scripts/build_opensbi.sh -v 1.2 -k 2203
exit 0
fi

Expand All @@ -30,7 +30,7 @@ fi
# build penglai
if [[ $1 == *"build"* ]]; then
echo "Build: building penglai demo image"
docker run -v $(pwd):/home/penglai/penglai-enclave -w /home/penglai/penglai-enclave --rm -it ddnirvana/penglai-enclave:v0.1 bash scripts/build_opensbi.sh
docker run -v $(pwd):/home/penglai/penglai-enclave -w /home/penglai/penglai-enclave --rm -it fly0307/penglai-enclave:v0.1 bash scripts/build_opensbi.sh
exit 0
fi

Expand All @@ -45,14 +45,14 @@ fi
if [[ $1 == *"docker"* ]]; then
echo "Run: run docker"
#sudo docker run --privileged --cap-add=ALL -v $(pwd):/home/penglai/penglai-enclave -w /home/penglai/penglai-enclave --rm -it ddnirvana/penglai-enclave:v0.1
docker run -v $(pwd):/home/penglai/penglai-enclave -w /home/penglai/penglai-enclave --network=host --rm -it ddnirvana/penglai-enclave:v0.5 bash
docker run -v $(pwd):/home/penglai/penglai-enclave -w /home/penglai/penglai-enclave --network=host --rm -it fly0307/penglai-enclave:v0.1 bash
exit 0
fi

# make clean
if [[ $1 == *"clean"* ]]; then
echo "Clean: make clean"
docker run -v $(pwd):/home/penglai/penglai-enclave -w /home/penglai/penglai-enclave --rm -it ddnirvana/penglai-enclave:v0.1 make clean
docker run -v $(pwd):/home/penglai/penglai-enclave -w /home/penglai/penglai-enclave --rm -it fly0307/penglai-enclave:v0.1 make clean
exit 0
fi

Expand Down
2 changes: 1 addition & 1 deletion scripts/build_opensbi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function build_opensbi_2() {
cd /home/penglai/penglai-enclave/opensbi-${1}
rm -rf build-oe/qemu-virt
mkdir -p build-oe/qemu-virt
CROSS_COMPILE=riscv64-unknown-linux-gnu- make O=build-oe/qemu-virt PLATFORM=generic FW_PAYLOAD=y FW_PAYLOAD_PATH=/home/penglai/penglai-enclave/u-boot.bin -j$(nproc)
CROSS_COMPILE=riscv64-unknown-linux-gnu- make O=build-oe/qemu-virt PLATFORM=generic FW_PAYLOAD=y FW_PAYLOAD_PATH=/home/penglai/penglai-enclave/u-boot/u-boot.bin -j$(nproc)
}

function print_usage() {
Expand Down
Loading