Skip to content

Commit

Permalink
Merge pull request #509 from antmicro/dt_generation
Browse files Browse the repository at this point in the history
Add dynamic DT generation for Linux
  • Loading branch information
mithro authored Aug 26, 2020
2 parents 60305b6 + 7163ceb commit 690901d
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 53 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ build
third_party/qemu-litex
third_party/micropython
third_party/linux
third_party/litex-devicetree
third_party/buildroot
third_party/linux-on-litex-vexriscv
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ addons:
- gnupg
- realpath
- util-linux
- device-tree-compiler

git:
submodules: false
Expand Down
52 changes: 12 additions & 40 deletions scripts/build-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,11 @@ if [ ${CPU} = mor1kx ]; then
ROOTFS=or1k-rootfs.cpio
DTB=mor1kx.dtb
ROOTFS_MD5="c9ef89b45b0d2c34d14978a21f2863bd"
DTB_MD5="0271bc8f63f2d928dc9536ac31a2c6b9"
elif [ ${CPU} = vexriscv ]; then
export ARCH=riscv
ROOTFS=riscv32-rootfs.cpio
DTB=rv32.dtb
ROOTFS_MD5="7b1a7fb52a1ba056dffb351a036bd0fb"
DTB_MD5="cd6d23543808988fd97447c4ff97392a"
else
echo "Linux is only supported on mor1kx or vexriscv at the moment."
exit 1
Expand Down Expand Up @@ -114,41 +112,6 @@ LINUX_CLONE_FROM="${LINUX_LOCAL:-$LINUX_REMOTE}"
fi
)

# Get litex-devicetree
LITEX_DT_SRC="$TOP_DIR/third_party/litex-devicetree"
LITEX_DT_REMOTE="${LITEX_DT_REMOTE:-https://github.com/timvideos/litex-devicetree.git}"
LITEX_DT_REMOTE_BIT=$(echo $LITEX_DT_REMOTE | sed -e's-^.*://--' -e's/.git$//')
LITEX_DT_REMOTE_NAME=timvideos-litex-devicetree
LITEX_DT_BRANCH=master
(
# Download the Linux source for the first time
if [ ! -d "$LITEX_DT_SRC" ]; then
(
cd $(dirname $LITEX_DT_SRC)
echo "Downloading LiteX devicetree code."
git clone $LITEX_DT_REMOTE $LITEX_DT_SRC
)
fi

# Change into the dir
cd $LITEX_DT_SRC

# Add the remote if it doesn't exist
CURRENT_LITEX_DT_REMOTE_NAME=$(git remote -v | grep fetch | grep "$LITEX_DT_REMOTE_BIT" | sed -e's/\t.*$//')
if [ x"$CURRENT_LITEX_DT_REMOTE_NAME" = x ]; then
git remote add $LITEX_DT_REMOTE_NAME $LITEX_DT_REMOTE
CURRENT_LITEX_DT_REMOTE_NAME=$LITEX_DT_REMOTE_NAME
fi

# Get any new data
git fetch $CURRENT_LITEX_DT_REMOTE_NAME

# Checkout or1k-linux branch it not already on it
if [ "$(git rev-parse --abbrev-ref HEAD)" != "$LITEX_DT_BRANCH" ]; then
git checkout $LITEX_DT_BRANCH || \
git checkout "$CURRENT_LITEX_DT_REMOTE_NAME/$LITEX_DT_BRANCH" -b $LITEX_DT_BRANCH
fi
)

# Build VexRiscv's emulator
if [ ${CPU} = vexriscv ]; then
Expand Down Expand Up @@ -219,14 +182,13 @@ LLV_SRC="$TOP_DIR/third_party/linux-on-litex-vexriscv"
mkdir -p $TARGET_LINUX_BUILD_DIR

fetch_file $RESOURCES_LOCATION/$ROOTFS_MD5-$ROOTFS $ROOTFS_MD5 $TARGET_LINUX_BUILD_DIR/$ROOTFS
fetch_file $RESOURCES_LOCATION/$DTB_MD5-$DTB $DTB_MD5 $TARGET_LINUX_BUILD_DIR/$DTB

if [ ${CPU} = mor1kx ]; then
KERNEL_BINARY=vmlinux.bin

cat << EOF > $TARGET_LINUX_BUILD_DIR/boot.json
{
"mor1kx.dtb": "0x01000000",
"$DTB": "0x01000000",
"Image": "0x00000000",
"bootargs": {
"r1": "0x01000000"
Expand All @@ -240,7 +202,7 @@ EOF
{
"Image": "0x40000000",
"rootfs.cpio": "0x40800000",
"rv32.dtb": "0x41000000",
"$DTB": "0x41000000",
"emulator.bin": "0x41100000"
}
EOF
Expand All @@ -256,3 +218,13 @@ EOF
ls -l $TARGET_LINUX_BUILD_DIR/arch/${ARCH}/boot/${KERNEL_BINARY}
ln -sf $TARGET_LINUX_BUILD_DIR/arch/${ARCH}/boot/${KERNEL_BINARY} $TOP_DIR/$FIRMWARE_FILEBASE.bin
)

# Generate the device tree file
LITEX_CONFIG_JSON="$TARGET_BUILD_DIR/test/csr.json"
LITEX_DT_GENERATOR_FILE="$TOP_DIR/third_party/litex/litex/tools/litex_json2dts.py"
if [ ! -f "$LITEX_CONFIG_JSON" ]; then
make firmware
fi

python $LITEX_DT_GENERATOR_FILE $LITEX_CONFIG_JSON | dtc -I dts -O dtb - > $TARGET_LINUX_BUILD_DIR/$DTB

2 changes: 1 addition & 1 deletion scripts/settings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ BINUTILS_VERSION=2.32
GCC_VERSION=9.1.0
SDCC_VERSION=3.5.0
OPENOCD_VERSION=0.10.0
RENODE_VERSION=v1.9.0
RENODE_VERSION=v1.10.1

# Other tools versions
ZEPHYR_SDK_VERSION=0.11.1
Expand Down
2 changes: 1 addition & 1 deletion tests/renode/BIOS.robot
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ BIOS boots
Wait For Line On Uart BIOS CRC passed

# CPU_TYPE variable is passed by the test-renode.sh script
Wait For Line On Uart CPU:\\s* ${CPU_TYPE} @ [0-9]+MHz treatAsRegex=true
Wait For Line On Uart CPU:\\s*${CPU_TYPE}.* @ [0-9]+MHz treatAsRegex=true

2 changes: 1 addition & 1 deletion third_party/litedram
Submodule litedram updated 63 files
+2 −13 README.md
+264 −0 bench/arty.py
+258 −0 bench/genesys2.py
+254 −0 bench/kcu105.py
+5 −2 examples/arty.yml
+6 −3 examples/genesys2.yml
+6 −3 examples/kcu105.yml
+5 −2 examples/nexys4ddr.yml
+5 −2 examples/versa_ecp5.yml
+19 −8 litedram/common.py
+6 −0 litedram/core/__init__.py
+7 −4 litedram/core/bandwidth.py
+6 −3 litedram/core/bankmachine.py
+6 −3 litedram/core/controller.py
+8 −5 litedram/core/crossbar.py
+7 −4 litedram/core/multiplexer.py
+6 −3 litedram/core/refresher.py
+6 −3 litedram/dfii.py
+0 −324 litedram/frontend/adaptation.py
+364 −0 litedram/frontend/adapter.py
+5 −2 litedram/frontend/axi.py
+6 −3 litedram/frontend/bist.py
+8 −5 litedram/frontend/dma.py
+5 −2 litedram/frontend/ecc.py
+6 −3 litedram/frontend/fifo.py
+51 −56 litedram/frontend/wishbone.py
+6 −5 litedram/gen.py
+24 −11 litedram/init.py
+16 −13 litedram/modules.py
+5 −1 litedram/phy/dfi.py
+6 −3 litedram/phy/ecp5ddrphy.py
+32 −47 litedram/phy/gensdrphy.py
+6 −3 litedram/phy/model.py
+6 −3 litedram/phy/s6ddrphy.py
+6 −3 litedram/phy/s7ddrphy.py
+5 −2 litedram/phy/usddrphy.py
+5 −2 test/benchmark.py
+72 −25 test/common.py
+6 −0 test/gen_access_pattern.py
+6 −0 test/gen_config.py
+2 −0 test/reference/ddr3_init.h
+2 −0 test/reference/ddr4_init.h
+2 −0 test/reference/sdr_init.h
+5 −2 test/run_benchmarks.py
+261 −136 test/test_adaptation.py
+408 −0 test/test_adapter.py
+5 −2 test/test_axi.py
+5 −2 test/test_bandwidth.py
+5 −2 test/test_bankmachine.py
+7 −4 test/test_bist.py
+5 −2 test/test_command_chooser.py
+39 −33 test/test_crossbar.py
+5 −2 test/test_dma.py
+6 −3 test/test_ecc.py
+5 −2 test/test_examples.py
+6 −3 test/test_fifo.py
+5 −2 test/test_init.py
+5 −2 test/test_modules.py
+5 −2 test/test_multiplexer.py
+5 −2 test/test_refresh.py
+5 −2 test/test_steerer.py
+5 −2 test/test_timing.py
+21 −10 test/test_wishbone.py
2 changes: 1 addition & 1 deletion third_party/liteeth
Submodule liteeth updated 68 files
+5 −2 examples/make.py
+5 −2 examples/targets/base.py
+5 −2 examples/targets/etherbone.py
+5 −2 examples/targets/stream.py
+5 −2 examples/targets/udp.py
+5 −2 examples/targets/udp_loopback/listener.py
+5 −2 examples/targets/udp_loopback/sender.py
+6 −3 examples/targets/udp_loopback/versa_ecp5.py
+5 −2 examples/test/test_analyzer.py
+5 −2 examples/test/test_etherbone.py
+5 −2 examples/test/test_regs.py
+5 −2 examples/test/test_stream.py
+5 −2 examples/test/test_udp.py
+5 −2 examples/udp_s7phyrgmii.yml
+5 −2 examples/wishbone_mii.yml
+5 −2 liteeth/common.py
+6 −0 liteeth/core/__init__.py
+5 −2 liteeth/core/arp.py
+5 −2 liteeth/core/icmp.py
+5 −2 liteeth/core/ip.py
+5 −2 liteeth/core/udp.py
+5 −2 liteeth/crossbar.py
+5 −2 liteeth/frontend/etherbone.py
+5 −2 liteeth/frontend/stream.py
+11 −27 liteeth/gen.py
+6 −0 liteeth/mac/__init__.py
+5 −2 liteeth/mac/common.py
+7 −4 liteeth/mac/core.py
+8 −5 liteeth/mac/crc.py
+7 −4 liteeth/mac/gap.py
+7 −4 liteeth/mac/last_be.py
+7 −4 liteeth/mac/padding.py
+7 −4 liteeth/mac/preamble.py
+7 −4 liteeth/mac/sram.py
+6 −3 liteeth/mac/wishbone.py
+6 −3 liteeth/phy/a7_1000basex.py
+6 −3 liteeth/phy/a7_gtp.py
+5 −2 liteeth/phy/common.py
+6 −3 liteeth/phy/ecp5rgmii.py
+5 −2 liteeth/phy/gmii.py
+5 −2 liteeth/phy/gmii_mii.py
+5 −2 liteeth/phy/k7_1000basex.py
+6 −3 liteeth/phy/ku_1000basex.py
+5 −2 liteeth/phy/mii.py
+5 −2 liteeth/phy/model.py
+121 −26 liteeth/phy/pcs_1000basex.py
+5 −2 liteeth/phy/rmii.py
+5 −2 liteeth/phy/s6rgmii.py
+5 −2 liteeth/phy/s7rgmii.py
+5 −2 liteeth/phy/usrgmii.py
+5 −2 test/model/arp.py
+5 −2 test/model/dumps.py
+5 −2 test/model/etherbone.py
+5 −2 test/model/icmp.py
+5 −2 test/model/ip.py
+5 −2 test/model/mac.py
+5 −2 test/model/phy.py
+5 −2 test/model/udp.py
+5 −2 test/test_arp.py
+5 −2 test/test_etherbone.py
+5 −2 test/test_examples.py
+5 −2 test/test_gen.py
+5 −2 test/test_icmp.py
+5 −2 test/test_ip.py
+5 −2 test/test_mac_core.py
+5 −2 test/test_mac_wishbone.py
+5 −2 test/test_model.py
+5 −2 test/test_udp.py
2 changes: 1 addition & 1 deletion third_party/litex
Submodule litex updated 199 files
2 changes: 1 addition & 1 deletion third_party/litex-boards
Submodule litex-boards updated 104 files
2 changes: 1 addition & 1 deletion third_party/litex-renode
2 changes: 1 addition & 1 deletion third_party/nmigen
Submodule nmigen updated 1 files
+4 −3 nmigen/test/utils.py

0 comments on commit 690901d

Please sign in to comment.