Customize firmware

this page will be refined in future.

flash memory layout

TBD

firmware files

TBD

preparing tools

$ git clone https://github.com/naobsd/tccutils.git
$ cd tccutils/
$ cc -o tccpack tccpack.c
$ cc -o tccunpack.c tccunpack.c
$ cd ../

$ git clone -b ics-telechips-naobsd https://github.com/naobsd/cm_system_core.git
$ cd cm_system_core/mkbootimg/
$ cc -o mkbootimg mkbootimg.c -lcrypto
$ cc -o unpackbootimg unpackbootimg.c
$ cd ../../

(header file in cm_system_core is needed to compile mkyaffs2image. please clone both repo on same directory)
$ git clone -b ics-telechips-naobsd https://github.com/naobsd/cm_external_yaffs2.git
$ cd cm_external_yaffs2/yaffs2/utils/
$ make mkyaffs2image
$ cd ../../../

$ git clone https://github.com/ehlers/unyaffs.git
$ cd unyaffs/
$ make
$ cd ../

copy compiled binaries to somewhere you like.

using tools

MTD image

$ tccunpack MTD.img
(boot.img, system.img, and recovery.img will be extracted)
$ tccpack boot.img system.img recovery.img MTD_new.img

boot.img/recovery.img

$ unpackbootimg -i boot.img
$ mkdir ramdisk
$ cd ramdisk
$ gzip -cd ../boot.img-ramdisk.gz | cpio -i
(modify files)
$ find * | cpio -o -H newc | gzip -9 > ../boot.img-ramdisk_new.gz
$ cd ../
$ mkbootimg --kernel boot.img-zImage --ramdisk boot.img-ramdisk_new.gz --cmdline `boot.img-cmdline` --base 0x`boot.img-base` --pagesize `boot.img-pagesize` -o boot_new.img

system.img

$ unyaffs -d system.img
(check page(chunk) size and spare size)
$ sudo unyaffs system.img system
$ cd system
(modify files)
$ cd ../
$ sudo mkyaffs2image -c (PAGESIZE, e.g. 4096(not 4)) -s (SPARESIZE, e.g. 128) system system_new.img