GCW Zero Build firmware from source and flash to device - jquenee/gcw0-guide GitHub Wiki

Based on: lubuntu-19.10 64bit

Introduction

For updating GCW Zero, we need to generate lot of different binary files as

  • gcw0-toolchain : libraries and binaries that allow us to compile application targeted for GCW0 device
  • rootfs.squashfs : applications on top of linux kernel
  • uzImage.bin : linux kernel for GCW0 device
  • modules.squashfs : linux drivers for GCW0 device
  • ubiboot-*.bin : boot system to start linux kernel
  • mininit-syspart : filesystem tool for reading squashfs files

Buildroot compilation

That step will output gcw0-toolchain and rootfs.squashfs

Install tools for doing the compilation

sudo apt install python mercurial make gcc g++ patch git curl m4

Clone buildroot OpenDingux repository

git clone --depth 1 -b opendingux https://github.com/jquenee/buildroot.git

Start the compilation

cd buildroot
sudo chmod 777 /opt
export CONFIG=gcw0
./rebuild.sh

Check rootfs.squashfs compression and structure

unsquashfs -s ./output/images/rootfs.squashfs
unsquashfs -l ./output/images/rootfs.squashfs

Linux kernel compilation

That step will output uzImage.bin and modules.squashfs

Install tools for doing the compilation

sudo apt install flex bison openssl libssl-dev u-boot-tools

Clone linux kernel OpenDingux repository

git clone --depth 1 -b jz-5.3-gcw0 https://github.com/OpenDingux/linux.git

Include gcw0-toolchain into PATH

export PATH=/opt/gcw0-toolchain/usr/bin/:$PATH

Compile the kernel

cd linux
make ARCH=mips gcw0_defconfig
make ARCH=mips CROSS_COMPILE=mipsel-gcw0-linux-uclibc- uzImage.bin

Add device tree into boot kernel image

mv uzImage.bin uzImage.bin.org
cat uzImage.bin.org ./arch/mips/boot/dts/ingenic/gcw0.dtb > uzImage.bin

Compile the modules (drivers)

make ARCH=mips CROSS_COMPILE=mipsel-gcw0-linux-uclibc- modules

Package modules

./create_modules_fs.sh

Check rootfs.squashfs structure

unsquashfs -l modules.squashfs

UBIBoot compilation

That step will output ubiboot-*.bin

Clone UBIBoot repository

git clone https://github.com/gcwnow/UBIBoot.git

Compile

cd UBIBoot
make ARCH=mips CROSS_COMPILE=mipsel-gcw0-linux-uclibc- CONFIG=gcw0

Mininit compilation

That step will output mininit-syspart

Clone Mininit repository

git clone https://github.com/OpenDingux/mininit.git

Compile

cd mininit
make CC=mipsel-gcw0-linux-uclibc-gcc

Build opk updater

That step will output gcw0-update-*.opk

Clone updater repository

git clone https://github.com/gcwnow/updater.git

Build opk

cd updater
cp ../UBIBoot/output/gcw0/*bin .
cp ../mininit/mininit-syspart .
cp ../linux/uzImage.bin .
cp ../linux/modules.squashfs .
cp ../buildroot/output/images/rootfs.squashfs .
./create_updater.sh

Check gcw0-update-*.opk structure

unsquashfs -l output/gcw0-update-*.opk

Upgrade GCW Zero

  • plug gcw0 in usb to your computer
  • backup your files
scp -r [email protected]:/media/data gcw0-backup
  • upload the updater
scp gcw0-update-*.opk [email protected]:/media/data/apps
  • restart gcw0 console
  • open OS Update app

Known Issues

  • buildroot compilation failed where filesystem is hosted in remote (e.g. sshfs)
  • GCW USB communication is not stable from VMWare OS (e.i. ingenic-boot)
  • Opendingux lower than 4.5 needs to be upgraded manually, see the following procedure: https://github.com/gcwnow/linux/wiki
  • Low level GCW battery can crash USB update procedure (e.i. ingenic-boot). Plug to power-supply.
  • squashfs zstd compression is not yet supported

Recovery GCW Zero

Soft procedure

  • press reset button
  • hold X+Y buttons
  • upload working updater

Hardcore procedure

Very Hardcore procedure

Useful links and resources