Skip to content

Commit 633d6bf

Browse files
committed
Build virglrenderer and DirectFB2
1 parent 3a174df commit 633d6bf

File tree

5 files changed

+134
-3
lines changed

5 files changed

+134
-3
lines changed

configs/riscv-cross-file

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[binaries]
2+
c = 'riscv32-buildroot-linux-gnu-gcc'
3+
strip = 'riscv32-buildroot-linux-gnu-strip'
4+
pkgconfig = 'pkg-config'
5+
python = '/usr/bin/python3'
6+
7+
[properties]
8+
pkg_config_libdir = ['@GLOBAL_SOURCE_ROOT@' / '../buildroot/output/host/riscv32-buildroot-linux-gnu/sysroot/usr/local/lib/pkgconfig',
9+
'@GLOBAL_SOURCE_ROOT@' / '../buildroot/output/host/riscv32-buildroot-linux-gnu/sysroot/usr/share/pkgconfig/',
10+
'@GLOBAL_SOURCE_ROOT@' / '../buildroot/output/host/riscv32-buildroot-linux-gnu/sysroot/usr/lib/pkgconfig/'
11+
]
12+
sys_root = '@GLOBAL_SOURCE_ROOT@' / '../buildroot/output/host/riscv32-buildroot-linux-gnu/sysroot'
13+
14+
[host_machine]
15+
system = 'linux'
16+
cpu_family = 'riscv'
17+
cpu = 'riscv32-ima'
18+
endian = 'little'

scripts/build-image.sh

Lines changed: 78 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,24 @@ function do_buildroot
5353
ASSERT make $PARALLEL
5454
popd
5555

56+
if [[ $BUILD_PACKAGES -eq 1 ]]; then
57+
export PATH="$PWD/buildroot/output/host/bin:$PATH"
58+
export CROSS_COMPILE=riscv32-buildroot-linux-gnu-
59+
60+
rm -rf extras
61+
mkdir -p extras
62+
do_libepoxy && OK
63+
do_virglrenderer && OK
64+
do_directfb && OK
65+
66+
cp -r libepoxy_out/* extras
67+
cp -r virglrenderer_out/* extras
68+
cp -r directfb/* extras
69+
70+
mkdir -p extras/root
71+
cp target/run.sh extras/root/
72+
fi
73+
5674
if [[ $EXTERNAL_ROOT -eq 1 ]]; then
5775
echo "Copying rootfs.cpio to rootfs_full.cpio (external root mode)"
5876
cp -f buildroot/output/images/rootfs.cpio ./rootfs_full.cpio
@@ -77,21 +95,24 @@ function do_linux
7795
export PATH="$PWD/buildroot/output/host/bin:$PATH"
7896
export CROSS_COMPILE=riscv32-buildroot-linux-gnu-
7997
export ARCH=riscv
98+
export INSTALL_MOD_PATH="out"
8099
pushd linux
81100
ASSERT make olddefconfig
82101
ASSERT make $PARALLEL
102+
ASSERT make modules_install
83103
cp -f arch/riscv/boot/Image ../Image
84104
popd
85105
}
86106

87107
function show_help {
88108
cat << EOF
89-
Usage: $0 [--buildroot] [--linux] [--all] [--external-root] [--clean-build] [--help]
109+
Usage: $0 [--buildroot] [--linux] [--packages] [--all] [--external-root] [--clean-build] [--help]
90110
91111
Options:
92112
--buildroot Build Buildroot rootfs
93113
--linux Build Linux kernel
94-
--all Build both Buildroot and Linux
114+
--packages Build extra packages
115+
--all Build both Buildroot, Linux kernel, and extra packages
95116
--external-root Use external rootfs instead of initramfs
96117
--clean-build Remove entire buildroot/ and/or linux/ directories before build
97118
--help Show this message
@@ -101,6 +122,7 @@ EOF
101122

102123
BUILD_BUILDROOT=0
103124
BUILD_LINUX=0
125+
BUILD_PACKAGES=0
104126
EXTERNAL_ROOT=0
105127
CLEAN_BUILD=0
106128

@@ -112,9 +134,13 @@ while [[ $# -gt 0 ]]; do
112134
--linux)
113135
BUILD_LINUX=1
114136
;;
137+
--packages)
138+
BUILD_PACKAGES=1
139+
;;
115140
--all)
116141
BUILD_BUILDROOT=1
117142
BUILD_LINUX=1
143+
BUILD_PACKAGES=1
118144
;;
119145
--external-root)
120146
EXTERNAL_ROOT=1
@@ -133,7 +159,56 @@ while [[ $# -gt 0 ]]; do
133159
shift
134160
done
135161

136-
if [[ $BUILD_BUILDROOT -eq 0 && $BUILD_LINUX -eq 0 ]]; then
162+
function do_libepoxy
163+
{
164+
ASSERT git clone https://github.com/anholt/libepoxy.git
165+
pushd libepoxy
166+
cp ../configs/riscv-cross-file .
167+
ASSERT meson --cross-file riscv-cross-file build/riscv
168+
ASSERT meson compile -C build/riscv
169+
DESTDIR=../../../libepoxy_out meson install -C build/riscv
170+
DESTDIR=../../../buildroot/output/host/riscv32-buildroot-linux-gnu/sysroot meson install -C build/riscv
171+
popd
172+
}
173+
174+
function do_virglrenderer
175+
{
176+
ASSERT git clone https://gitlab.freedesktop.org/virgl/virglrenderer.git
177+
pushd virglrenderer
178+
cp ../configs/riscv-cross-file .
179+
ASSERT meson --cross-file riscv-cross-file build/riscv
180+
ASSERT meson compile -C build/riscv
181+
DESTDIR=../../../virglrenderer_out meson install -C build/riscv
182+
popd
183+
}
184+
185+
function do_directfb
186+
{
187+
export PATH=$PATH:$PWD/buildroot/output/host/bin
188+
export BUILDROOT_OUT=$PWD/buildroot/output/
189+
mkdir -p directfb
190+
191+
# Build DirectFB2
192+
ASSERT git clone https://github.com/directfb2/DirectFB2.git
193+
pushd DirectFB2
194+
cp ../configs/riscv-cross-file .
195+
ASSERT meson -Ddrmkms=true --cross-file riscv-cross-file build/riscv
196+
ASSERT meson compile -C build/riscv
197+
DESTDIR=$BUILDROOT_OUT/host/riscv32-buildroot-linux-gnu/sysroot meson install -C build/riscv
198+
DESTDIR=../../../directfb meson install -C build/riscv
199+
popd
200+
201+
# Build DirectFB2 examples
202+
ASSERT git clone https://github.com/directfb2/DirectFB-examples.git
203+
pushd DirectFB-examples/
204+
cp ../configs/riscv-cross-file .
205+
ASSERT meson --cross-file riscv-cross-file build/riscv
206+
ASSERT meson compile -C build/riscv
207+
DESTDIR=../../../directfb meson install -C build/riscv
208+
popd
209+
}
210+
211+
if [[ $BUILD_BUILDROOT -eq 0 && $BUILD_LINUX -eq 0 && $BUILD_PACKAGES -eq 0 ]]; then
137212
echo "Error: No build target specified. Use --buildroot, --linux, or --all."
138213
show_help
139214
fi

scripts/rootfs_ext4.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ echo "[*] Remove old rootfs directory..."
1111
rm -rf $DIR
1212
mkdir -p $DIR
1313

14+
cp -r extras/* $DIR
15+
1416
echo "[*] Extract CPIO"
1517
pushd $DIR
1618
cpio -idmv < ../$ROOTFS_CPIO

scripts/virt-disk-img.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/bash
2+
3+
IMG=ext4.img
4+
KERNEL_VER=$(git -C linux/ tag | sed "s/^v//")
5+
SRC=linux/out/lib/modules/$KERNEL_VER
6+
DEST=extras/lib/modules/$KERNEL_VER
7+
8+
# Add path of kernel modules to load with dependency file, for example:
9+
# FILES='kernel/drivers/gpu/drm/drm.ko
10+
# modules.dep'
11+
FILES=''
12+
13+
mkdir -p extras
14+
15+
for file in $FILES; do
16+
mkdir -p `dirname $DEST/$file`
17+
cp -f $SRC/$file $DEST/$file
18+
done
19+
20+
cp -r libepoxy_out/* extras
21+
cp -r virglrenderer_out/* extras
22+
cp -r directfb/* extras
23+
cp target/run.sh extras
24+
25+
# DirectFB-example requires ~60MiB of space
26+
#dd if=/dev/zero of=${IMG} bs=4k count=20000
27+
#mkfs.ext4 -F ${IMG} -d extras
28+
29+
#rm -rf extras
30+
31+
# show image size
32+
#du -h ${IMG}

target/run.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/bash
2+
3+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
4+
export PATH=$PATH:/usr/local/bin/

0 commit comments

Comments
 (0)