Recent Changes - Search:

edit SideBar

Firmware / Bootloader

Bootloader, kernel and initrd in an Evo T20 firmware image

Contributed by Frank Boehm

Your own kernel

Have you have done your homework and read the previous articles?

OK, fine, let's start.

The brand new kernel is ready, or the kernel of a normal distribution, this doesn't matter. I hope you have included the patch against the natsemi bug, resulting in clogged syslog.

We need three things to make a cake: wheat flour, sugar and eggs. Oops, sorry, wrong wiki.

Three things to boot linux: a bootloader, kernel and initrd

A bootloader for our kernel

I know of three bootloaders, reported to have been working.

  • the original NT boot loader
  • make-nk is mentioned in the bundle-tools, but never used by me
  • a patched grub

Won't make notes of the first one public, I do prefer the open source way. Grub is a tried and proven boot loader, so this has been the way to go for me.

Go to http://www.kazak.ws/evo/step2.html and get a patched version of grub.

Find out the correct size

For our cake we need the quantum of the ingredients. Oops wrong wiki again, we need the sizes of our grub stage1 and stage2, kernel and initrd.

  #!/bin/sh
  #
  # detect length of files
  #
  # grub
  dd if=./stage1 of=/dev/null bs=512
  dd if=./stage2 of=/dev/null bs=512
  # dsl kernel
  dd if=./linux24 of=/dev/null bs=512
  # dsl initrd
  dd if=./minirt24.gz of=/dev/null bs=512

  frank@hela:/home/frank/src/Compaq_Evo_T20/bundle-tools/y_grub_dsl-4.0 >   # grub
  frank@hela:/home/frank/src/Compaq_Evo_T20/bundle-tools/y_grub_dsl-4.0 >   dd if=./  stage1 of=/dev/null bs=512
  1+0 records in
  1+0 records out
  frank@hela:/home/frank/src/Compaq_Evo_T20/bundle-tools/y_grub_dsl-4.0 >   dd if=./stage2 of=/dev/null bs=512
  172+1 records in
  172+1 records out
  frank@hela:/home/frank/src/Compaq_Evo_T20/bundle-tools/y_grub_dsl-4.0 >   # dsl kernel
  frank@hela:/home/frank/src/Compaq_Evo_T20/bundle-tools/y_grub_dsl-4.0 >   dd if=./linux24 of=/dev/null bs=512
  4164+1 records in
  4164+1 records out
  frank@hela:/home/frank/src/Compaq_Evo_T20/bundle-tools/y_grub_dsl-4.0 >   # dsl initrd
  frank@hela:/home/frank/src/Compaq_Evo_T20/bundle-tools/y_grub_dsl-4.0 >   dd if=./minirt24.gz of=/dev/null bs=512

Don't even think about using preconfigure older values!

My examples for a DSL firmware.

  frank@hela:/home/frank/src/Compaq_Evo_T20/grub > cat presetmenu.dsl-4.0
  prompt 0
  default 0
  timeout 0
  title Damn Small Linux, a.k.a. DSL
  kernel 300+4165 ramdisk_size=100000 init=/etc/init lang=us apm=power-off vga=791 initrd=initrd.gz nomce noapic BOOT_IMAGE=knoppix pnpbios=off noacpi
  initrd 8000+117093
  prompt 0

  frank@hela:/home/frank/src/Compaq_Evo_T20/grub > cat compile-with-dsl-4.0.sh
  #!/bin/sh
  ./configure \
       --enable-preset-menu=presetmenu.dsl-4.0 \
       --enable-natsemi \
       --enable-pci-direct \
       --disable-ext2fs --disable-fat --disable-ffs --disable-ufs2 \
       --disable-minix --disable-reiserfs --disable-vstatfs --disable-jfs \
       --disable-xfs --disable-iso9660\
       --disable-md5-password --disable-serial

  make

My examples for a DSL firmware.

  frank@hela:/home/frank/src/Compaq_Evo_T20/grub > cat presetmenu.dsl-4.0
  prompt 0
  default 0
  timeout 0
  title Damn Small Linux, a.k.a. DSL
  kernel 300+4165 ramdisk_size=100000 init=/etc/init lang=us apm=power-off vga=791 initrd=initrd.gz nomce noapic BOOT_IMAGE=knoppix pnpbios=off noacpi
  initrd 8000+117093
  prompt 0

  frank@hela:/home/frank/src/Compaq_Evo_T20/grub > cat compile-with-dsl-4.0.sh
  #!/bin/sh
  ./configure \
       --enable-preset-menu=presetmenu.dsl-4.0 \
       --enable-natsemi \
       --enable-pci-direct \
       --disable-ext2fs --disable-fat --disable-ffs --disable-ufs2 \
       --disable-minix --disable-reiserfs --disable-vstatfs --disable-jfs \
       --disable-xfs --disable-iso9660\
       --disable-md5-password --disable-serial

  make

Putting it together

If you have carefully read my notes above, you may have detected that I cheated. (But I know I have cheated and where it is working.)

My initrd does not start right after the kernel. It's too bothersome to compile again for each test. There is some free unused space between my kernel and initrd in my firmwares.

There are now 2 ways to create the firmware.

For smaller firmwares (less than 32MB), use bundletools

Remember the output of fwextract and use the same order, but your own content

../fwpack pre_bootp.bin ulc_code.ce k ulc_code.bin os.ver poweron.bmp filesys0.img

You will get a resulting image that is smaller than the original file. That's OK.

For bigger firmwares (32MB or more), dd your content via loopback device to the right place.

The bundle tools won't work for firmwares larger than 32MB for me.

Put grub stage 1&2, kernel and initrd right after one another in filesys0.img using a script. The extra lines with "dd if=./blafoo of=/dev/null bs=512" are not necessary and leftover from some tests.

frank@hela:/home/frank/src/Compaq_Evo_T20/bundle-tools/y_grub_dsl-4.0 > cat M
  #!/bin/sh

  echo copy original filesys0.img
  dd if=../x/filesys0.img of=filesys0.img bs=1M count=4

  echo stage1
  dd if=./stage1 of=/dev/null bs=512
  dd if=./stage1 of=./filesys0.img bs=512 seek=1 conv=notrunc

  echo stage2
  dd if=./stage2 of=/dev/null bs=512
  dd if=./stage2 of=./filesys0.img bs=512 seek=2 conv=notrunc

  echo linux24
  dd if=./linux24 of=/dev/null      bs=512
  dd if=./linux24 of=./filesys0.img bs=512 seek=300 conv=notrunc

  echo minirt24.gz
  dd if=./minirt24.gz of=/dev/null      bs=512
  dd if=./minirt24.gz of=./filesys0.img bs=512 seek=8000 conv=notrunc

Make sure you never ever get a bigger file.

Flash your firmware.

Edit - History - Print - Recent Changes - Search
Page last modified on April 29, 2008, at 04:45 AM