GetLoader2Args

From iPodLinux

Jump to: navigation, search

Contents

Description

getLoader2Args is a new feature in iPodLoader2 (version 2.2 and later) that allows you to append command line arguments to the config file you can use with Loader 2. The arguments from the bootloader are placed in memory for access from the Userland. Currently there are two methods to retrieve the cmdline args. The first with getLoader2Args, the other with /proc/cmdline.

Note: In order to be able to use the techniques described on this page you have to have the improved minix shell installed and not only the simple sash shell. How to tell the difference? Well, if the code below leads just to syntax error messages, you've got the wrong one installed.
The minix-sh shell is the default shell in Userland ipod_fs_220606 and later.'

The maximum length of the command line that can be passed is currently (as of loader 2.3) 119 characters.

Using getLoader2Args

Downloads

getLoader2args is included in the latest release of Loader 2 (download it from there).

Compiling

% svn co https://ipodlinux.svn.sourceforge.net/svnroot/ipodlinux/apps/ipod/ipodloader2/getLoader2Args/
% cd getLoader2Args
% make

Installation

Put the getLoader2Args binary into /bin on the Linux partition if you have a WinPod or in /bin in the root of your HFS partition if you have a MacPod.

Then make the binary executable (chmod +x).

Example of Use

Change your /etc/rc file by removing the last line reading "podzilla" and add instead these lines:

Note: This is not necessary anymore with Userland ipod_fs_220606 and later. So don't touch the /etc/rc file if you don't have to.

if [ -f /bin/getLoader2Args ] ; then
  args=`/bin/getLoader2Args`
  echo "Args: $args"
fi
if [ "$args" = "" ]; then
  podzilla
else
  eval $args
fi

Make sure the /etc/rc file is still executable (chmod +x).

Now, you can define a shell command in the loader2 configuration file and it will be executed instead of podzilla. E.g, you could have now these lines inside your config file:

PodZilla @ (hd0,1)/kernel.bin     podzilla
Linux shell @ (hd0,1)/kernel.bin  cat /proc/meminfo

Choosing the first in the loader's boot menu will launch podzilla, while the other one will show the memory (RAM) info of your Linux OS.

Note: You have to have at least 2 white spaces between the location of the kernel and the argument.

Using /proc/cmdline

An alternate method of retrieving cmdline args from ipodloder2 requires you to build a custom kernel. Instead of using getLoader2arg to retrieve the cmdline args, arguments can be retrieved via 'cat /proc/cmdline'. This is where linux normally looks for cmdline args. To build the custom kernel:

Either follow these instructions for the Experimental Kernel

Or do these:

% wget -P /tmp http://www.so2.sys-techs.com/ipod/linux/iPL_2.4.32-ipod2_loader2_cmdline_support.patch
% cd linux-2.4.24-ipod2
% patch -p1 < /tmp/iPL_2.4.32_loader2_cmdline_support.patch
% make boot

Note: the built kernel file is the file name Image inside arch/armnommu/boot/. Rename it into "kernel.bin" and place it onto your ipod where Loader 2 finds it.

Example of Use

Recompile the Kernel with the following options:

% cd linux-2.4.24-ipod2
% make menuconfig
       [*] Sysctl support
       [ ] NWFPE math emulation
       (ELF) Kernel core (/proc/kcore) format
       [*] Support uClinux FLAT format binaries                    
       [ ]   Support FLAT format compressed binaries             
       [ ] Power Management support                                
       [ ] RISC OS personality                                     
    -> [ ] Compiled-in Kernel Boot Parameter                       
   |   [ ] Kernel-mode alignment trap handler
   |   [ ] m68knommu-style attached romfs in RAM support
   |
  Disable this! (Compiled-in Kernel Boot Parameter)
% make boot

Now you could launch hd-demo from the cmdline modifying your loader.conf file like this:

iPodLinux Podzilla @ (hd0,2)/boot/vmlinux root=/dev/hda3
iPodLinux HD-Demo @ (hd0,2)/boot/vmlinux root=/dev/hda3 hd-demo

and add the lines below to /etc/rc (see the note about minix shell above):

if [ -n "`grep hd-demo < /proc/cmdline`" ]; then
  hd-demo
else
  podzilla
fi 

In the example above, if you choose the boot option "iPodLinux HD-Demo" from Loader2, hd-demo will get executed instead of podzilla. If you choose "iPodLinux Podzilla", podzilla will get excuted. The above example uses the grep tool - you can get it from Gnutools.