GetLoader2Args

From wikiPodLinux

Table of 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 iPodLoader2. The arguments from the bootloader are placed in memory for access from the userland. Currently there are two methods to retrieve the cmdline args.

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.

Downloads

iPodLoader2: Latest official release or Work in progress
getLoader2args: pre-built binary (http://ipodlinux.org/Image:Loader2argswindows.zip) (plus some other files you might want or not)

Usage

Method 1 (getLoader2Args)

The default way to retrieve cmdline args from ipodloader2 is to use getLoader2Args. getLoader2Args is part of ipodloader2 but you can get it like this:

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

Example of Use

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

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

Note: This is not necessary anymore with userland ipod_fs_220606 and later.

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.

Method 2 (/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

% 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

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.

More installation tutorials in the Forums

fiftyfour123's tutorial for Mac OS X users (http://ipodlinux.org/forums/viewtopic.php?t=9616).
KyleV's tutorial for Windows/Linux users (http://ipodlinux.org/forums/viewtopic.php?t=9615).

Navigation



  • Google Search (http://www.google.com/custom?sa=Google+Search&cof=S%3Ahttp%3A%2F%2Fwww.ipodlinux.org%3BVLC%3Apurple%3BAH%3Acenter%3BBGC%3Awhite%3BLH%3A141%3BLC%3Ablue%3BL%3Ahttp%3A%2F%2Fipodlinux.org%2Fstylesheets%2Fimages%2Fwiki.png%3BALC%3Ablue%3BLW%3A128%3BT%3Ablack%3BAWFID%3A70a74ab66f4d59ae%3B&domains=ipodlinux.org&sitesearch=ipodlinux.org)