Skip to content

radekp/gta04-init

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
bin
 
 
pic
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Using this project you can generate initramfs with simple rootfs selector. This
initramfs can be compiled to linux kernel for your GTA04 (http://gta04.org)
phone.

Why not use u-boot menu?
========================

1/ UBIFS currently does not boot without initramfs
2/ In u-boot menu phone is not charging
3/ Easy customization - mounting and booting rootfs is simple shell script
4/ You can do nice tricks - like unpack distro tarball and run it from memory
5/ My GTA04 does not have AUX button needed to bring u-boot menu

How to build this?
==================

You need to build the menu selector. The resulting binary is called init.
Simple "make" should do it. Then you need to tell kernel where the initramfs
sources are:
 
CONFIG_INITRAMFS_SOURCE="gta04-init/files.txt"

Now build the uImage and boot it - you should see the rootfs selection menu.

How to build ubiattach?
=======================

Since we want to run from ubifs we need ubiattach utility. You have to build it
from this git:

    http://git.infradead.org/?p=mtd-utils.git;a=summary

Do make. After it's finished, rebuild statically linked ubiattach:

    gcc -static -O2 -g -Wall -Wextra -Wwrite-strings -Wno-sign-compare -ffunction-sections -fdata-sections -Wl,--gc-sections -g -o ubiattach ubi-utils/ubiattach.o ubi-utils/libubi.a ubi-utils/ubiutils-common.o lib/libmtd.a

You can check that it's really stacially linked with:

    ldd ubiattach

output should be:
    
    not a dynamic executable

How to build with klibc
=======================

Debian has klibc package, so install it. It ships with klcc command
which you can use instead of gcc for compiling against klibc. Compiling
the init is easy, just replace gcc with klcc.

Compiling ubiattach is more tricky. You should remove all unneeded tools
in mtd-utils, edit the common.mk and replace gcc with klcc.

Ubi lib will fail because of major() and minor() functions. So replace
them with __major() and __minor() macros defined in klibc's sys/sysmacros.h

Now compile ubiattach statically (like with gcc but use klcc).

How to use it?
==============

You can choose following rootfs in the menu:

SD   NAND
1    2

NAND/SD items are special, they are compiled in initramfs. They mount
UBIFS/EXT4 and executes /sbin/init on it.

You can customize 1 and 2 choices. The selector mounts first partition on SD
card (which is FAT partition) to /fat and executes gta04-init/1.sh or
gta04-init/2.sh scripts.

The script can use busybox commands to populate the rootfs and execute init.
E.g.:

    cd /
    tar xzvpf /fat/qtmoko-debian-gta04-v41.tar.gz
    exec /sbin/init

But you can do anything you want there. E.g. launch "sh" and use shell over
serial cable.

Can i skip the rootfs selection
===============================

Yes, you can use boodev file for straight boot to given partition.

Writing to the file should be implemented by distributions before they shutdown
the system.

The file is always deleted by gta04-init in order to bring the rootfs menu
in case that the booted rootfs does not work.

See also this mail:

    http://lists.goldelico.com/pipermail/gta04-owner/2012-March/002048.html

What is bootdev file format?
============================

The boodev should contain boot partition and optionally subdirectory on the
partition.

E.g.:

"/dev/mmcblk0p2 /" boots to 2nd partition on MMC
"ubi0:rootfs /" boots to "rootfs" UBI partition on NAND
"/dev/mmcblk0p2 /shr" boots 2nd partition on MMC and root will be /shr directory

The subdirectory option allows you to have multiple distribution on the same
partition.

How about kernels
=================

gta04-init checks /boot/uImage on partition from which we want to boot. If the
kernel does not match the kernel in /fat/uImage it updates it and reboots so that
the distribution kernel is always used.

Can i customize the logo
========================

Yes, simply provide /boot/logo.bmp in your distro's tarbal. It must be 32bit ARGB
bmp image.

Troubleshooting
===============

* Init is not launching but printing usage message like this:

    Usage: init {-e VAR[=VAL] | [-t SECONDS] {0|1|2|3|4|5|6|S|s|Q|q|A|a|B|b|C|c|U|u}}

  You probably forgot "exec" command when you launched init and init is because
  of that not process no. 1. In this case init is acting as telinit. You can
  find some info here:

    http://serverfault.com/questions/95037/custom-initrd-init-script-how-to-create-dev-initctl

About

Initramfs with rootfs menu selection for GTA04 phone

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published