martes, 29 de diciembre de 2009

WRT54GL v1.1 sd card mod with openwrt

Here is the colors I used to connect the ssd card




The blue cable, that goes with the pin of the DMZ led.

The yellow,green an red cables.

The brown and white cables

Here is the mini sd with the adapter


Now everything is fine, you should install mmc driver and then format to mount it.

download this driver and then run the following commands


tar xzvf mmc-v1.3.4-gpio2.tgz
cp mmc-v1.3.4-gpio2/mmc-v1.3.4-gpio2/mmc /lib/modules/2.4.35.4
insmod mmc (comment: at this point check with dmesg if every thing is ok)
mkfs.ext3 dev/mmc/disc0/part1






LEDS blink while using the sd card :D


mount the ssd

[ -d /mnt ] || mkdir /mnt
mount -t ext3 -o noatime /dev/mmc/disc0/part1 /mnt
grep /mnt /proc/mounts

Now this is for using the sd card as root (/)
First, copy everything in the sd card.


mkdir /tmp/orig
mount -o bind / /tmp/orig  
tar -c -C /tmp/orig -f - . | tar -xv -C /mnt -f -
umount /tmp/orig
rmdir /tmp/orig
rm -r /mnt/etc/* 
umount /mnt

Next step is to create the following script at /etc/init.d/bootext

#!/bin/sh /etc/rc.common

START=11
STOP=91

bootext_cleanup() { # [cleanup_level]
[ "$1" -ge 3 ] && grep -q '^[^ ]* /rom ' /proc/mounts && mount -o move /rom $putold/rom
[ "$1" -ge 2 ] && { . $putold/bin/firstboot ; pivot $putold $target ; }
[ "$1" -ge 1 ] && umount -l $target/etc
return 0
}

bootext_fail() { #  [cleanup_level]
echo "$1" >&2
[ ! "$2" ] || bootext_cleanup $2
exit 1
}

bootext_quit() { # 
echo "$1" >&2
exit 0
}

bootext_start() {
! grep -q "^$device / " /proc/mounts || bootext_quit "$name already on /"

if ! grep -q "^$device $target " /proc/mounts
then
! grep -q "^$device " /proc/mounts || bootext_fail "$name already mounted"

for module in $modules
do
if ! grep -q "^$module " /proc/modules
then
[ $module != mmc ] || [ ! "$gpiomask" ] || echo "$gpiomask" > /proc/diag/gpiomask || bootext_fail "could not set gpiomask"
insmod $module || bootext_fail "could not insert $module module"
fi
done

while [ ! -b $device ]
do
[ "$waitdev" -gt 0 ] || bootext_fail "$device does not exist"
waitdev=$(( $waitdev - 1 ))
sleep 1
done

[ -d $target ] || mkdir $target || bootext_fail "could not create mountpoint $target"
mount ${filesys:+-t $filesys} ${mountopt:+-o $mountopt} $device $target || bootext_fail "could not mount $name on $target"
fi

[ -d $target$putold ] || mkdir $target$putold || bootext_fail "could not create mountpoint $putold"
[ -d $target/etc ] || mkdir $target/etc || bootext_fail "could not create mountpoint /etc"
mount -o bind /etc $target/etc || bootext_fail "could not bind mount /etc"

. /bin/firstboot
pivot $target $putold || bootext_fail "could not pivot to $target" 1

! grep -q "^[^ ]* $putold/rom " /proc/mounts || { [ -d /rom ] || mkdir /rom && mount -o move $putold/rom /rom ; }

return 0
}

bootext_stop() {
grep -q "^$device / " /proc/mounts || bootext_quit "$name not on /"

bootext_cleanup 999
}

bootext_config() { # 
local section=$1 local action=$2 local enabled device name target putold modules gpiomask waitdev filesys mountopt config_get_bool enabled $section enabled 1 [ "$enabled" -gt 0 ] || return 0 config_get device $section device [ "$device" ] || bootext_fail "external boot device not configured" config_get name $section name config_get target $section target config_get putold $section putold config_get modules $section modules config_get gpiomask $section gpiomask config_get waitdev $section waitdev config_get filesys $section filesys config_get mountopt $section mountopt [ "$name" ] || name="$device" [ "$putold" ] || putold="${target:-/old}" [ "$target" ] || target="/${filesys:-new}" bootext_$action } start() { config_load bootfromexternalmedia config_foreach bootext_config bootfromexternalmedia start } stop() { config_load bootfromexternalmedia config_foreach bootext_config bootfromexternalmedia stop }

chmod a+x /etc/init.d/bootext

Also you will need the configuration file /etc/config/bootfromexternalmedia with the following contents


config bootfromexternalmedia
        option enabled  '1'
        option device   '/dev/mmc/disc0/part1'
        option name     'mmc'
        option target   '/mnt'
        option putold   '/mnt'
        option modules  'mmc jbd ext3'
        option gpiomask '0x9c'
        option waitdev  '0'
        option filesys  'ext3'
        option mountopt 'noatime'

For reference of the configuration parameters go to openwrt wiki .

now execute /etc/init.d/bootext start and if everythig is ok you shoul be using the sd card at root (/) . Try df to see this.

3 comentarios:

Anónimo dijo...

Hi, I'm trying to add the SD memory to the router WRT54GL, but some errors appear when I'm installing the MOD. I'd like to know if you know what this is dued to, and if you could tell me which kind of memory did you use... thanks, bye
my mail is chiguire2000@hotmail.com

Leonardo dijo...

I just send you an email!

Anónimo dijo...

Hello my friend.
Which version of OpenWRT did you use?
( /lib/modules/2.4.35.4 )

Google Analytics Alternative