Skip to content

Commit

Permalink
xbuild rockchip
Browse files Browse the repository at this point in the history
  • Loading branch information
henkwiedig committed Nov 22, 2024
1 parent 1f07386 commit 8412273
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 51 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
./build.sh star6b0
./build.sh star6e
./build.sh x86
./build.sh rockchip
- name: Upload binary
uses: actions/upload-artifact@v4
Expand All @@ -36,6 +37,7 @@ jobs:
msposd_star6b0
msposd_star6e
msposd_x86
msposd_rockchip
- name: Versioned release
if: startsWith(github.ref, 'refs/tags/')
Expand All @@ -47,6 +49,7 @@ jobs:
msposd_star6b0
msposd_star6e
msposd_x86
msposd_rockchip
- name: Upload latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
Expand All @@ -59,3 +62,4 @@ jobs:
msposd_star6b0
msposd_star6e
msposd_x86
msposd_rockchip
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ toolchain/
majestic.yaml
/msposd
firmware/
aarch64/
disk.raw
msposd_goke
msposd_hisi
msposd_star6b0
msposd_star6e
msposd_x86
msposd_x86
msposd_rockchip
32 changes: 0 additions & 32 deletions Dockerfile_xcompile

This file was deleted.

6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ x86: version.h
$(eval BUILD = $(CC) $(SRCS) -I $(SDK)/include -L $(DRV) $(CFLAGS) $(LIB) -levent_core -O0 -g -o $(OUTPUT))
$(BUILD)

rockchip:
rockchip: version.h
$(eval SDK = ./sdk/gk7205v300)
$(eval CFLAGS += -D__ROCKCHIP__)
$(eval LIB = -levent_core -lcairo -lrt -lm)
$(eval LIB = `pkg-config --libs cairo x11` -lm -lrt)
$(eval BUILD = $(CC) $(SRCS) -I $(SDK)/include -L $(DRV) $(CFLAGS) $(LIB) -levent_core -O0 -g -o $(OUTPUT))
$(BUILD)
$(BUILD)
21 changes: 7 additions & 14 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/bin/bash
DL="https://github.com/openipc/firmware/releases/download/latest"
SUFFIX=tgz
TAR="tar -xf"
ARCH=arm-linux

if [[ "$1" == *"star6b0" ]]; then
CC=cortex_a7_thumb2_hf-gcc13-musl-4_9
Expand All @@ -14,16 +11,15 @@ elif [[ "$1" == *"hisi" ]]; then
CC=cortex_a7_thumb2-gcc13-musl-4_9
fi

GCC=$PWD/toolchain/$CC/bin/$ARCH-gcc
GCC=$PWD/toolchain/$CC/bin/arm-linux-gcc
OUT=msposd_$1

if [[ "$1" != *"jetson"* && "$1" != *"x86"* ]]; then
fi
if [[ "$1" != *"jetson"* && "$1" != *"x86"* && "$1" != *"rockhip"* ]]; then
if [ ! -e toolchain/$CC ]; then
wget -c -q --show-progress $DL/$CC.$SUFFIX -P $PWD
wget -c -q --show-progress $DL/$CC.tgz -P $PWD
mkdir -p toolchain/$CC
$TAR $CC.$SUFFIX -C toolchain/$CC --strip-components=1 || exit 1
rm -f $CC.$SUFFIX
tar -xf $CC.tgz -C toolchain/$CC --strip-components=1 || exit 1
rm -f $CC.tgz
fi
fi

Expand All @@ -50,11 +46,8 @@ elif [ "$1" = "x86" ]; then
DRV=$PWD
make DRV=$DRV OUTPUT=$OUT $1
elif [ "$1" = "rockchip" ]; then
GCC=gcc
DRV=$PWD
make CC=$GCC DRV=$DRV TOOLCHAIN=$PWD/toolchain/$CC OUTPUT=$OUT $1

./build_rockchip.sh $1
else
echo "Usage: $0 [goke|hisi|star6b0|star6e|jetson|x86|rockchip]"
exit 1
fi
fi
58 changes: 58 additions & 0 deletions build_rockchip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/sh
output=aarch64

# We run arm binary's under x86, crazy, right ;)
which qemu-arm-static 2>/dev/null > /dev/null || sudo apt-get install -y qemu-user-static

# download and unpack debian arm image
host=https://cloud.debian.org/images/cloud/bullseye
release=latest
system=debian-11-generic-arm64.tar
if [ ! -f disk.raw ]; then
wget -nv ${host}/${release}/${system}.xz
tar -xf ${system}.xz
rm ${system}.xz
fi

# loop mount the image
if [ ! -d output/tmp ]; then
mkdir -p $output
device=$(sudo losetup -P --show -f disk.raw)
sudo mount ${device}p1 $output
sudo mkdir -p $output/usr/src/msposd
sudo mount -o bind $(pwd) $output/usr/src/msposd
fi

if [ ! -f $output/tmp/prepare_chroot.done ]; then
cat > prepare_chroot.sh << EOL
#!/bin/bash
cd /home
# install radxa APT repo, see https://radxa-repo.github.io/bullseye/
keyring="/home/keyring.deb"
version="\$(curl -L https://github.com/radxa-pkg/radxa-archive-keyring/releases/latest/download/VERSION)"
curl -L --output "\$keyring" "https://github.com/radxa-pkg/radxa-archive-keyring/releases/download/\${version}/radxa-archive-keyring_\${version}_all.deb"
dpkg -i \$keyring
echo 'deb [signed-by=/usr/share/keyrings/radxa-archive-keyring.gpg] https://radxa-repo.github.io/bullseye/ bullseye main' > /etc/apt/sources.list.d/70-radxa.list
echo 'deb [signed-by=/usr/share/keyrings/radxa-archive-keyring.gpg] https://radxa-repo.github.io/bullseye rockchip-bullseye main' > /etc/apt/sources.list.d/80-rockchip.list
apt-get update
apt-get install -y git gcc make pkg-config libspdlog-dev libevent-dev libcairo-dev
apt clean
touch /tmp/prepare_chroot.done
EOL
chmod +x prepare_chroot.sh
sudo cp prepare_chroot.sh $output/home
sudo rm $output/etc/resolv.conf
echo nameserver 1.1.1.1 | sudo tee $output/etc/resolv.conf
sudo chroot $output /home/prepare_chroot.sh
rm prepare_chroot.sh
fi

if [ "$(uname -m)" = "x86_64" ]; then
sudo chroot aarch64 make OUTPUT=msposd_$1 $1 -C /usr/src/msposd
else
make OUTPUT=$OUT $1
fi
sudo umount $output/usr/src/msposd
sudo umount $output
sudo losetup -d ${device}
1 change: 0 additions & 1 deletion msposd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,6 @@ int main(int argc, char **argv)
int r;
int long_index = 0;
int rc_channel_no = 0;
int r;

while ((opt = getopt_long_only(argc, argv, "", long_options, &long_index)) != -1) {
switch (opt) {
Expand Down

0 comments on commit 8412273

Please sign in to comment.