---
# System prepended metadata

title: temp2

---

temp2
===
qemu
```
#!/bin/bash

rm -rf build

mkdir build install

cd build

../configure  --prefix=`pwd`/../install --python=/usr/bin/python2.7 --target-list=riscv64-linux-user,riscv64-softmmu,riscv32-linux-user,riscv32-softmmu

```

```
#!/bin/bash

QEMU_SYSTEM=qemu-system-riscv64
MACHINE="virt"


DTB=xxx.dtb
BBL_PATH=bbl

set -x
if [[ $1 == 'gdb' ]]; then
  gdb --args \
    ${QEMU_SYSTEM} \
      -machine ${MACHINE} \
      -nographic \
      -m 1G
elif [[ $1 == 'free' ]]; then
  ${QEMU_SYSTEM} \
    -kernel ${BBL_PATH} \
    -machine ${MACHINE} \
    -dtb ${DTB} \
    -nographic \
    -m 1G \
    -smp 2 \
    -append "console=ttyS0" \
    -netdev type=user,id=net0,hostfwd=tcp::5588-:22 \
    -device virtio-net-device,netdev=net0
else
  ${QEMU_SYSTEM} \
    -kernel ${BBL_PATH} \
    -machine ${MACHINE} \
    -dtb ${DTB} \
    -nographic \
    -m 1G \
    -smp 1 \
    -append "console=ttyS0" \
    -netdev type=user,id=net0,hostfwd=tcp::5588-:22 \
    -device virtio-net-device,netdev=net0 \
    -gdb tcp::16977 \
    -S
fi
```

```
#!/bin/bash

riscv64-linux-gdb -x gdbrc

# gdbrc #
set confirm off
set pagination off

define filevm
  file /vmlinux
end

define filebbl
  file bbl
end

filebbl
#filevm

add-symbol-file vmlinux 0xffffffe0016bfe18

target remote :16977



```


For opensbi use
```
#!/bin/bash

QEMU_SYSTEM=./qemu-system-riscv64
MACHINE="virt"
FW_JUMP=/opensbi/build/platform/qemu/virt/firmware/fw_jump.elf
FW_PAYLOAD=/opensbi/build/platform/qemu/virt/firmware/fw_payload.elf
IMAGE=/linux/arch/riscv/boot/Image
ROOTFS=/buildroot-2019.05/output/images/rootfs.ext4

set -x
case "$1" in
  "payload")
    ${QEMU_SYSTEM} \
      -M ${MACHINE} \
      -nographic \
      -m 1G \
      -kernel ${FW_PAYLOAD} \
      -drive file=${ROOTFS},format=raw,id=hd0 \
      -device virtio-blk-device,drive=hd0 \
      -append "root=/dev/vda rw console=ttyS0"
    ;;
  "jump")
    ${QEMU_SYSTEM} \
      -M ${MACHINE} \
      -nographic \
      -m 1G \
      -kernel ${FW_JUMP} \
      -device loader,file=${IMAGE},addr=0x80200000 \
      -drive file=${ROOTFS},format=raw,id=hd0 \
      -device virtio-blk-device,drive=hd0 \
      -append "root=/dev/vda rw console=ttyS0"
    ;;
  "gdb")
    ${QEMU_SYSTEM} \
      -M ${MACHINE} \
      -nographic \
      -m 1G \
      -kernel ${FW_PAYLOAD} \
      -drive file=${ROOTFS},format=raw,id=hd0 \
      -device virtio-blk-device,drive=hd0 \
      -append "root=/dev/vda rw console=ttyS0" \
      -gdb tcp::16977 \
      -S
    ;;
  "debug")
    gdb --args ${QEMU_SYSTEM} -M ${MACHINE} -nographic -m 1G
    ;;
  *)
    echo "..."
    ;;
esac

# Network
'''
-netdev type=user,id=net0,hostfwd=tcp::5588-:22 \
-device virtio-net-device,netdev=net0 \
'''

```

