-
Notifications
You must be signed in to change notification settings - Fork 21
Home
First install the GCW Zero toolchain, which you can find on the development page of the GCW Zero web site, including installation instructions and add the toolchain to your $PATH
.
Then issue the following commands:
git clone git://github.com/gcwnow/linux.git
cd linux
make ARCH=mips gcw0_defconfig
make ARCH=mips uzImage.bin -j4
Use a different -j<N>
depending on the system you're building on; something near the number of cores you have is typically good.
To build loadable driver modules:
make ARCH=mips modules -j4
./create_modules_fs.sh
Loadable modules are used for the WiFi driver, but can also be useful for testing new drivers without rebooting all the time.
In our Linux 4.5 kernel, we switched from raw binary vmlinuz.bin
kernel images to uzImage.bin
images which have a U-Boot header. To be able to boot these images, you have to update UBIBoot to April 2016 or later. See the firmware flashing instructions for how to update the boot loader. You don't need to flash anything other than the boot loader: use only the --boot
option (and --config
if necessary for your model GCW Zero).
Don't try building a vmlinuz.bin
with a 4.5 or higher kernel version: the kernel will assume a different load address than the boot loader uses and as a result it won't boot.
Add the following script to your Zero as /etc/local/init.d/S99mount-system.sh
:
#!/bin/sh
/bin/mount -o remount,rw /media
/bin/mkdir -p /media/system
/bin/mount -o ro /dev/mmcblk0p1 /media/system
/bin/mount -o remount,ro /media
/bin/mount -o remount,rw /media/system
Now reboot and the system partition will be mounted read/write at /media/system
.
We switched from having mininit in the initial ramdisk to having it on the system partition. This allows mininit to be updated without having to rebuild the kernel.
Build mininit and copy the mininit-syspart
executable to the system partition: /media/system/mininit-syspart
.
Then create empty directories named dev
and root
on the system partition, these will be used by mininit as mount points.
mkdir /media/system/dev
mkdir /media/system/root
Log in with SSH or telnet and check whether you have a backup kernel: in /media/system
there should be a file named uzImage.bak
. If it doesn't exist, make a copy the main kernel uzImage.bin
to create the backup kernel uzImage.bak
.
You can copy the kernel to the internal SD card of the Zero using FTP, SFTP or SCP. I recommend SCP since it is just one line on the command prompt. It does require setting up SSH keypair authentication though.
scp uzImage.bin [email protected]:/media/system
scp modules.squashfs [email protected]:/media/system/update_m.bin
Reboot the Zero to activate the new kernel. Don't use the reset button: part of the kernel may not have been flushed from the write cache yet.
When you start hacking the kernel, it's almost inevitable that at some point you install a non-working kernel.
The easiest way to recover is to boot the backup kernel: hold the X button, then wait for the unit to reset itself (if it's in a reset loop) or push the reset button (if it's stuck).
If the backup kernel isn't working either, you can reflash the system partition. For this, build the ingenic-boot tool:
git clone git://github.com/gcwnow/ingenic-boot.git
cd ingenic-boot
make
If you want to run ingenic-boot as a non-root user, set up a udev rule as explained in the README. The next time you plug the device in while it is in USB boot mode, your normal user account should have permission to access it.
You can download read-made firmware images from the firmware flashing page on the of the GCW Zero web site.
Finally, put your device in USB boot mode by holding SELECT on power-up or reset and run the tool:
cd ingenic-boot
./ingenic-boot --system=../imager/images/system.<date>.bin
After the new kernel partition is written, the Zero will boot and load the kernel that was just written.