View previous topic :: View next topic |
Author |
Message |
Whitewolf Fox Tux's lil' helper
Joined: 29 Aug 2004 Posts: 78 Location: Ratingen
|
Posted: Mon Nov 15, 2010 1:08 am Post subject: Installing Gentoo on an Seagate DockStar (Mini Server) |
|
|
Hi Everyone,
today I bought a "Seagate FreeAgent DockStar" for 40 €. It's a mini Linux based device, with the intended use to store files on attached USB devices and serving them within a cable based network, using an application to access them and also storing that files somewhere online in the net. I read this article (sorry: German), which describes how to install a custom Debian system on that device, found that whole thing _very_ cool and wanted to do the same thing with a Gentoo OS.
The Hardware is looking like this from the front
and like this from behind.
The Seagate FreeAgent DockStar is a very compact device with the following hardwarespecs:
- 1,2 Ghz Marvell CPU
- 128 MB RAM
- 256 MB Flash (contains the preinstalled PlugOS)
- 1x Gigabit Ethernet
- 4 USB Ports (with one being an mini USB - dock-plug)
It seems to consume just 3-4 watts being idle and max. 8 watts under high load, with an attached USB HDD. The device don't have and don't need an mechanical cooling. So it doesn't produce any noise, which does make it very attractive for private use.
This all also makes it very interesting for serving as an mini-home-server, to download things while you are away, serving files, being an dhcp server, etc., for example. You can attach nearly every device by USB, so it's quite easy to upgrade the device with bigger hdds or even a wlan module.
There is quite a good manual to bring a Debian to this box. But (and yes: I know that Gentoo has to become compiled and this will take very long in this hardware) I'd like to use Gentoo instead! This thread shall serve as an central point of collecting ideas, opinions, experience and to become a manual to do this.
I'd like to start with a summary of the described way to go I found so far for using Debian for this purpose, since not everyone is capable of understandung German. My plan is to use this as some kind of reference to convert the whole thing to a Gentoo - Howto.
I'd like to make one thing clear: The Debian - Guide is in no way some work of my own! I don't want to earn the glory for this; I merely did more than to translate this article to english and added some sitenotes. The glory for this (and the idea itself) has to go to the user "stronzo" of the german "hardwareluxx.de - Forum".
Also big glory has to go to Falk Husemann, who described the way to go to get a Debian up and running on his site http://falkhusemann.de .
The Debian guide:
!! ATTENTION !!
As soon you are connecting the device to the network and the power supply, it will boot up, trying to connect to an onlineservice and apply a firmware upgrade, which uses an still unknown SSH password. It may be possible to reset this password online, after you registered the device under the product registering site, but this is still untested and the alternate way is recommended, which is described here.
So, the very first goal should be to disable the device's need to "call home", which means that it automatically connects to an online ressource, registers itself to a service and searches for (and automatically installing) an updated firmware version. To disable this function, you have to determine the IP which the device is using after bootup first. I'm running a DHCP managed network, but the device didn't seem to get an IP from the DHCP Server. It used it's default IP.
The default IP of each device is individual and can be determined as follows:
It always starts with "169.254.X.Y". The rest bases on the MAC adress of that device, while X is the penultimate, and Y the ultimate byte of the MAC. For example:
If the MAC of your DockStar (it's written on the bottom of the device) is "00:10:75:1B:1A:CB", then X is "26" and Y is "203". The default IP of the device will be: 169.254.26.203 then. You can use this online tool to calculate easily from HEX to Decimal.
Before we start, here are some infos about the front LED, which determines the device's status, to help you understanding what's going on:
- Off: Device is switched off, the new uBoot or Plugbox is running
- Green, flashing: Old bootloader is starting
- Orange, flashing: Plugbox is booting
- Green, steady: Plugbox is running, Internet is active, Device can connect "home"
- Orange, steady / Orange, flashing: Plugbox is running, Internet is active, Device can not connect "home" (also true, if the line has been commented out as descibed with the following)
After you have determined the device's correct IP, you have to connect to it by using SSH. Therefore, you first have to configure your computer to be within the right net, or have that one routed correctly. I recommend to use a crossover networking cable between your computer and the DockStar, to make sure, that there will be no route to the internet for the DockStar available.
Once so far, you are asked for a username and password. The defaults are:
User: root
Pass: stxadmin
Once logged in, you have to edit the file "/etc/init.d/rcS". You can use the vi for doing this. Within that file, you have to comment the line Quote: | /etc/init.d/hbmgr.sh start |
Save that one and reboot the device by issuing
I suggest to wait 30 seconds after saving, disconnect the power chord, reattach it, re-connect by SSH and make sure, that the line is still commented out. Then you can be 100% sure the setting has been saved and you can attach the device to the normal net without the risk to have the device flashing itself with an unwanted firmware. My device kept flashing orange after that. So I would call this the normal behavior after commenting out the described line and reboot the device. Practically I'd suggest to let the device connected as it is for the first time, since mine hasn't used the DHCP informations and still used it's default IP.
I'd suggest, the first thing to do should be to set an appropriate IP for your network, to not having to use the crossover-solution anymore. To do this, you have to know how your network is structured, first. Please also note, that these changes won't be permanent. This means, that the device starts up with its default networking config after a power loss or eaqual reboots.
Once you're logged into the device by SSH, you should issue the following commands:
Please make sure to change this to something valid for your network!
Quote: | -bash-3.2# /sbin/ifconfig eth0 netmask 255.255.255.0
-bash-3.2# /sbin/route add default gw 192.168.1.10
-bash-3.2# /sbin/ifconfig eth0 192.168.1.200
-bash-3.2# |
The device won't answer anymore from this point, since the IP changes instead. Now attach your DockStar to the consigured network, without pulling the powerchord.
Now, the Debian guide recommends to attach an pre-partitioned and -formated USB media, containing an at least 512 MB , type 83 (Linux) partition (first) and a second partition of type 82 (swap) with 256 MB of size. The first one shall contain the new OS and the second shall expand the device's internal RAM with (just) 128 MB of size.
I attached an 8 GB USB Stick with the first primary partition containing an ext3 fs and 7,5 GB of size and a second partition, containing a swap fs and being 512 MB of size. It's referenced as /dev/sda1 and /dev/sda2 on the DockStar then.
Code: | -bash-3.2# fdisk -l
Disk /dev/sda: 8005 MB, 8005787648 bytes
32 heads, 63 sectors/track, 7756 cylinders
Units = cylinders of 2016 * 512 = 1032192 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 7234 7291840+ 83 Linux
/dev/sda2 7235 7756 526176 82 Linux swap
-bash-3.2# |
The original guide doesn't say anything about the fs to use. I think that, since the original OS of the device does not support ext4 or ReiserFS, the best filesystem to use for this is ext3. The device supports the following FS:
Code: | -bash-3.2# cat /proc/filesystems
nodev sysfs
nodev rootfs
nodev bdev
nodev proc
nodev sockfs
nodev usbfs
nodev pipefs
nodev anon_inodefs
nodev futexfs
nodev tmpfs
nodev inotifyfs
nodev devpts
ext3
ext2
squashfs
nodev ramfs
nodev nfs
jffs2
nodev rpc_pipefs
-bash-3.2# |
The Debian guide now uses a custom script to install either "Lenny" (current stable - 5.0) or "Squeeze" (current testing - 6.0). I'm posting the "Squeeze" - one as reference here:
The script has to be used as follows:
Code: | cd /tmp
wget http://jeff.doozan.com/debian/dockstar.debian-squeeze.sh
chmod +x dockstar.debian-squeeze.sh
export PATH=$PATH:/usr/sbin:/sbin
./dockstar.debian-squeeze.sh
|
The script "dockstar.debian-squeeze.sh" contains the following:
Code: | #!/bin/sh
#
# Install Debian Squeeze on DockStar
# Copyright (c) 2010 Jeff Doozan
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# Version 1.0 [8/8/2010] Initial Release
# Definitions
# Download locations
MIRROR="http://jeff.doozan.com/debian"
DEB_MIRROR="http://ftp.us.debian.org/debian"
MKE2FS_URL="$MIRROR/mke2fs"
PKGDETAILS_URL="$MIRROR/pkgdetails"
URL_UBOOT="$MIRROR/uboot/install_uboot_mtd0.sh"
URL_DEBOOTSTRAP="$DEB_MIRROR/pool/main/d/debootstrap/debootstrap_1.0.25_all.deb"
URL_FW_CONFIG="$MIRROR/uboot/fw_env.config"
# Default binary locations
MKE2FS=/sbin/mke2fs
PKGDETAILS=/usr/share/debootstrap/pkgdetails
# Where should the temporary 'debian root' be mounted
ROOT=/tmp/debian
# debootstrap configuration
RELEASE=squeeze
VARIANT=minbase
# if you want to install additional packages, add them to the end of this list
EXTRA_PACKAGES=linux-image-2.6-kirkwood,flash-kernel,module-init-tools,udev,netbase,ifupdown,iproute,openssh-server,dhcpcd,iputils-ping,wget,net-tools,ntpdate,uboot-mkimage,uboot-envtools,vim-tiny
KERNEL_VERSION=2.6.32-5-kirkwood
#########################################################
# There are no user-serviceable parts below this line
#########################################################
RO_ROOT_=0
TIMESTAMP=$(date +"%d%m%Y%H%M%S")
touch /sbin/$TIMESTAMP
if [ ! -f /sbin/$TIMESTAMP ]; then
RO_ROOT=1
else
rm /sbin/$TIMESTAMP
fi
verify_md5 ()
{
local file=$1
local md5=$2
local check_md5=$(cat "$md5" | cut -d' ' -f1)
local file_md5=$(md5sum "$file" | cut -d' ' -f1)
if [ "$check_md5" = "$file_md5" ]; then
return 0
else
return 1
fi
}
download_and_verify ()
{
local file_dest=$1
local file_url=$2
local md5_dest="$file_dest.md5"
local md5_url="$file_url.md5"
# Always download a fresh MD5, in case a newer version is available
if [ -f "$md5_dest" ]; then rm -f "$md5_dest"; fi
wget -O "$md5_dest" "$md5_url"
# retry the download if it failed
if [ ! -f "$md5_dest" ]; then
wget -O "$md5_dest" "$md5_url"
if [ ! -f "$md5_dest" ]; then
return 1 # Could not get md5
fi
fi
# If the file already exists, check the MD5
if [ -f "$file_dest" ]; then
verify_md5 "$file_dest" "$md5_dest"
if [ "$?" -ne "0" ]; then
rm -f "$md5_dest"
return 0
else
rm -f "$file_dest"
fi
fi
# Download the file
wget -O "$file_dest" "$file_url"
# retry the download if it failed
verify_md5 "$file_dest" "$md5_dest"
if [ "$?" -ne "0" ]; then
# Download failed or MD5 did not match, try again
if [ -f "$file_dest" ]; then rm -f "$file_dest"; fi
wget -O "$file_dest" "$file_url"
verify_md5 "$file_dest" "$md5_dest"
if [ "$?" -ne "0" ]; then
rm -f "$md5_dest"
return 1
fi
fi
rm -f "$md5_dest"
return 0
}
install ()
{
local file_dest=$1
local file_url=$2
local file_pmask=$3 # Permissions mask
echo "# checking for $file_dest..."
# Install target file if it doesn't already exist
if [ ! -s "$file_dest" ]; then
echo ""
echo "# Installing $file_dest..."
# Check for read-only filesystem by testing
# if we can delete the existing 0 byte file
# or, if we can create a 0 byte file
local is_readonly=0
if [ -f "$file_dest" ]; then
rm -f "$file_dest" 2> /dev/null
else
touch "$file_dest" 2> /dev/null
fi
if [ "$?" -ne "0" ]; then
local is_readonly=0
mount -o remount,rw /
fi
rm -f "$file_dest" 2> /dev/null
download_and_verify "$file_dest" "$file_url"
if [ "$?" -ne "0" ]; then
echo "## Could not install $file_dest from $file_url, exiting."
if [ "$is_readonly" = "1" ]; then
mount -o remount,ro /
fi
exit 1
fi
chmod $file_pmask "$file_dest"
if [ "$is_readonly" = "1" ]; then
mount -o remount,ro /
fi
echo "# Successfully installed $file_dest."
fi
return 0
}
if ! which chroot >/dev/null; then
echo ""
echo ""
echo ""
echo "ERROR. CANNOT CONTINUE."
echo ""
echo "Cannot find chroot. You need to update your PATH."
echo "Run the following command and then run this script again:"
echo ""
echo 'export PATH=$PATH:/sbin:/usr/sbin'
echo ""
exit 1
fi
echo ""
echo ""
echo "!!!!!! DANGER DANGER DANGER DANGER DANGER DANGER !!!!!!"
echo ""
echo "This script will replace the bootloader on /dev/mtd0."
echo ""
echo "If you lose power while the bootloader is being flashed,"
echo "your device could be left in an unusable state."
echo ""
echo ""
echo "This script will configure your Dockstar to boot Debian Squeeze"
echo "from a USB device. Before running this script, you should have"
echo "used fdisk to create the following partitions:"
echo ""
echo "/dev/sda1 (Linux ext2, at least 400MB)"
echo "/dev/sda2 (Linux swap, recommended 256MB)"
echo ""
echo ""
echo "This script will DESTROY ALL EXISTING DATA on /dev/sda1"
echo "Please double check that the device on /dev/sda1 is the correct device."
echo ""
echo "By typing ok, you agree to assume all liabilities and risks"
echo "associated with running this installer."
echo ""
echo -n "If everything looks good, type 'ok' to continue: "
read IS_OK
if [ "$IS_OK" != "OK" -a "$IS_OK" != "Ok" -a "$IS_OK" != "ok" ];
then
echo "Exiting..."
exit
fi
# Stop the pogoplug engine
killall -q hbwd
ROOT_DEV=/dev/sda1 # Don't change this, uboot expects to boot from here
SWAP_DEV=/dev/sda2
# Create the mount point if it doesn't already exist
if [ ! -f $ROOT ];
then
mkdir -p $ROOT
fi
# Get the source directory
SRC=$ROOT
##########
##########
#
# Install uBoot on /dev/mtd0
#
##########
##########
# Get the uBoot install script
if [ ! -f /tmp/install_uboot_mtd0.sh ];
then
wget -P /tmp $URL_UBOOT
chmod +x /tmp/install_uboot_mtd0.sh
fi
echo "Installing Bootloader"
/tmp/install_uboot_mtd0.sh --noprompt
##########
##########
#
# Format /dev/sda
#
##########
##########
umount $ROOT > /dev/null 2>&1
if ! which mke2fs >/dev/null; then
install "$MKE2FS" "$MKE2FS_URL" 755
else
MKE2FS=$(which mke2fs)
fi
$MKE2FS $ROOT_DEV
/sbin/mkswap $SWAP_DEV
mount $ROOT_DEV $ROOT
if [ "$?" -ne "0" ]; then
echo "Could not mount $ROOT_DEV on $ROOT"
exit 1
fi
##########
##########
#
# Download debootstrap
#
##########
##########
if [ ! -e /usr/sbin/debootstrap ]; then
mkdir /tmp/debootstrap
cd /tmp/debootstrap
wget -O debootstrap.deb $URL_DEBOOTSTRAP
ar xv debootstrap.deb
tar -xzvf data.tar.gz
if [ "$RO_ROOT" = "1" ]; then
mount -o remount,rw /
fi
mv ./usr/sbin/debootstrap /usr/sbin
mv ./usr/share/debootstrap /usr/share
install "$PKGDETAILS" "$PKGDETAILS_URL" 755
if [ "$RO_ROOT" = "1" ]; then
mount -o remount,ro /
fi
fi
##########
##########
#
# Run debootstrap
#
##########
##########
echo ""
echo ""
echo "# Starting debootstrap installation"
# Squeeze
/usr/sbin/debootstrap --verbose --arch=armel --variant=$VARIANT --include=$EXTRA_PACKAGES $RELEASE $ROOT $DEB_MIRROR
if [ "$?" -ne "0" ]; then
echo "debootstrap failed."
echo "See $ROOT/debootstrap/debootstrap.log for more information."
exit 1
fi
cat <<END > $ROOT/etc/apt/apt.conf
APT::Install-Recommends "0";
APT::Install-Suggests "0";
END
chroot /tmp/debian /usr/bin/mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n Linux-$KERNEL_VERSION -d /boot/vmlinuz-$KERNEL_VERSION /boot/uImage
chroot /tmp/debian /usr/bin/mkimage -A arm -O linux -T ramdisk -C gzip -a 0x00000000 -e 0x00000000 -n initramfs-$KERNEL_VERSION -d /boot/initrd.img-$KERNEL_VERSION /boot/uInitrd
echo debian > $ROOT/etc/hostname
echo LANG=C > $ROOT/etc/default/locale
cat <<END > $ROOT/etc/fw_env.config
# MTD device name Device offset Env. size Flash sector size Number of sectors
/dev/mtd0 0xc0000 0x20000 0x20000
END
cat <<END > $ROOT/etc/network/interfaces
auto lo eth0
iface lo inet loopback
iface eth0 inet dhcp
END
cat <<END > $ROOT/etc/fstab
# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/root / ext2 noatime,errors=remount-ro 0 1
$SWAP_DEV none swap sw 0 0
tmpfs /tmp tmpfs defaults 0 0
END
cat <<END > $ROOT/etc/kernel/postinst.d/zz-flash-kernel
#!/bin/sh
version="$1"
bootopt=""
# passing the kernel version is required
[ -z "${version}" ] && exit 0
echo "Running flash-kernel ${version}"
flash-kernel ${version}
END
chmod +x $ROOT/etc/kernel/postinst.d/zz-flash-kernel
echo 'T0:2345:respawn:/sbin/getty -L ttyS0 115200 linux' >> $ROOT/etc/inittab
sed -i 's/^\([1-6]:.* tty[1-6]\)/#\1/' $ROOT/etc/inittab
echo HWCLOCKACCESS=no >> $ROOT/etc/default/rcS
echo CONCURRENCY=shell >> $ROOT/etc/default/rcS
if [ -e $ROOT/etc/blkid.tab ]; then
rm $ROOT/etc/blkid.tab
fi
ln -s /dev/null $ROOT/etc/blkid.tab
if [ -e $ROOT/etc/mtab ]; then
rm $ROOT/etc/mtab
fi
ln -s /proc/mounts $ROOT/etc/mtab
echo "root:\$1\$XPo5vyFS\$iJPfS62vFNO09QUIUknpm.:14360:0:99999:7:::" > $ROOT/etc/shadow
##### All Done
cd /
umount $ROOT > /dev/null 2>&1
echo ""
echo ""
echo ""
echo ""
echo "Installation complete"
echo ""
echo "You can now reboot your device into Debian."
echo "If your device does not start Debian after rebooting,"
echo "you may need to restart the device by disconnecting the power."
echo ""
echo "The new root password is 'root' Please change it immediately after"
echo "logging in."
echo ""
echo -n "Reboot now? [Y/n] "
read IN
if [ "$IN" = "" -o "$IN" = "y" -o "$IN" = "Y" ];
then
/sbin/reboot
fi
|
The script seems to me to not doing anything besides:
- Download some files onto the device
- Replaces the device's bootloader with one contained within that downloaded files (uBoot)
- Unattended installing a Debian OS
- Setting the root password to "root"
- Rebooting
So, the todos for doing the same with gentoo seem to be:
- Making a backup of the default OS
- Replacing the bootloader in device /dev/mtd0
- getting the gentoo sources
- installing gentoo like a "normal" USB Bootable install
which seems to be possible to me
That's the plan folks!
I'd like to hear your opinion to this plans. Perhaps even some solutions or suggestions? And I'll describe my effords to this task in this thread, too. The next few days I'll spend in re-reading the guides to install gentoo on ARM and USB sticks again to not break that precious thing _________________ http://www.marc-richter.info |
|
Back to top |
|
|
Whitewolf Fox Tux's lil' helper
Joined: 29 Aug 2004 Posts: 78 Location: Ratingen
|
Posted: Mon Nov 15, 2010 3:33 pm Post subject: |
|
|
I've made some progress yesterday:
I've updated the uBoot bootloader of the device by just issuing the following part of the previous posted script by Jeff Doozan:
Code: |
MIRROR="http://jeff.doozan.com/debian"
URL_UBOOT="$MIRROR/uboot/install_uboot_mtd0.sh"
##########
##########
#
# Install uBoot on /dev/mtd0
#
##########
##########
# Get the uBoot install script
if [ ! -f /tmp/install_uboot_mtd0.sh ];
then
wget -P /tmp $URL_UBOOT
chmod +x /tmp/install_uboot_mtd0.sh
fi
echo "Installing Bootloader"
/tmp/install_uboot_mtd0.sh --noprompt |
It worked like a charm, but I think this can be handled better: Currently, all the files, the script /tmp/install_uboot_mtd0.sh is downloading, are fetched from a single server, located at http://jeff.doozan.com/debian . Jeff strongly recommends to keep that source, but I somehow find this a little confusing to know, that each file can easily become modified in the future without anyone noticing it and to know, that this whole thing will not work anymore, once the server crashes or something.
Because of this two reasons, my next step will be to get all related files from there and fine-tune the process for geting the files by making it more transparent for a user. It could be managed by publically making the list of MD5 sums available on a different server for giving everyone a chance to check those checksums against that list, for example. Currently, the data files and the files, containing those checksums, reside on the same server.
Additionally, I will put those files onto different netstores, to ensure that they won't go offline anytime in the future.
This is what the script install_uboot_mtd0.sh contains:
Code: | #!/bin/sh
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Dockstar u-Boot mtd0 Installer v0.4
# by Jeff Doozan
#
# Based on Pogoplug u-Booter Installer v0.2
# by IanJB, original method and inspiration from aholler:
# http://ahsoftware.de/dockstar/
#
# This is a script to write a newer u-boot to mtd0
# It is NOT a good idea to start your own mirror
# You should leave this as-is
MIRROR=http://jeff.doozan.com/debian
UBOOT_MTD0_BASE_URL=$MIRROR/uboot/files/uboot/uboot.mtd0 # .platform.version.kwb will be appended to this
UBOOT_ENV_URL=$MIRROR/uboot/files/environment/uboot.environment
VALID_UBOOT_MD5=$MIRROR/uboot/valid-uboot.md5
BLPARAM_URL=$MIRROR/uboot/blparam
NANDDUMP_URL=$MIRROR/uboot/nanddump
NANDWRITE_URL=$MIRROR/uboot/nandwrite
FLASH_ERASE_URL=$MIRROR/uboot/flash_erase
FW_PRINTENV_URL=$MIRROR/uboot/fw_printenv
FW_CONFIG_URL=$MIRROR/uboot/fw_env.config
UBOOT_MTD0=/tmp/uboot.mtd0.kwb
UBOOT_ORIGINAL=/uboot-original-mtd0.kwb
UBOOT_ENV=/tmp/uboot.environment
BLPARAM=/usr/sbin/blparam
NANDDUMP=/usr/sbin/nanddump
NANDWRITE=/usr/sbin/nandwrite
FLASH_ERASE=/usr/sbin/flash_erase
FW_PRINTENV=/usr/sbin/fw_printenv
FW_SETENV=/usr/sbin/fw_setenv
FW_CONFIG=/etc/fw_env.config
verify_md5 ()
{
local file=$1
local md5=$2
local check_md5=$(cat "$md5" | cut -d' ' -f1)
local file_md5=$(md5sum "$file" | cut -d' ' -f1)
if [ "$check_md5" = "$file_md5" ]; then
return 0
else
return 1
fi
}
download_and_verify ()
{
local file_dest=$1
local file_url=$2
local md5_dest="$file_dest.md5"
local md5_url="$file_url.md5"
# Always download a fresh MD5, in case a newer version is available
if [ -f "$md5_dest" ]; then rm -f "$md5_dest"; fi
wget -O "$md5_dest" "$md5_url"
# retry the download if it failed
if [ ! -f "$md5_dest" ]; then
wget -O "$md5_dest" "$md5_url"
if [ ! -f "$md5_dest" ]; then
return 1 # Could not get md5
fi
fi
# If the file already exists, check the MD5
if [ -f "$file_dest" ]; then
verify_md5 "$file_dest" "$md5_dest"
if [ "$?" -ne "0" ]; then
rm -f "$md5_dest"
return 0
else
rm -f "$file_dest"
fi
fi
# Download the file
wget -O "$file_dest" "$file_url"
# retry the download if it failed
verify_md5 "$file_dest" "$md5_dest"
if [ "$?" -ne "0" ]; then
# Download failed or MD5 did not match, try again
if [ -f "$file_dest" ]; then rm -f "$file_dest"; fi
wget -O "$file_dest" "$file_url"
verify_md5 "$file_dest" "$md5_dest"
if [ "$?" -ne "0" ]; then
rm -f "$md5_dest"
return 1
fi
fi
rm -f "$md5_dest"
return 0
}
install ()
{
local file_dest=$1
local file_url=$2
local file_pmask=$3 # Permissions mask
echo "# checking for $file_dest..."
# Install target file if it doesn't already exist
if [ ! -s "$file_dest" ]; then
echo ""
echo "# Installing $file_dest..."
# Check for read-only filesystem by testing
# if we can delete the existing 0 byte file
# or, if we can create a 0 byte file
local is_readonly=0
if [ -f "$file_dest" ]; then
rm -f "$file_dest" 2> /dev/null
else
touch "$file_dest" 2> /dev/null
fi
if [ "$?" -ne "0" ]; then
local is_readonly=0
mount -o remount,rw /
fi
rm -f "$file_dest" 2> /dev/null
download_and_verify "$file_dest" "$file_url"
if [ "$?" -ne "0" ]; then
echo "## Could not install $file_dest from $file_url, exiting."
if [ "$is_readonly" = "1" ]; then
mount -o remount,ro /
fi
exit 1
fi
chmod $file_pmask "$file_dest"
if [ "$is_readonly" = "1" ]; then
mount -o remount,ro /
fi
echo "# Successfully installed $file_dest."
fi
return 0
}
# Parse command line
for i in $*
do
case $i in
--force-platform=*)
FORCE_PLATFORM=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
echo "Forcing platform to [$FORCE_PLATFORM]"
;;
--no-uboot-check)
NO_UBOOT_CHECK=1
;;
--noprompt)
NOPROMPT=1
;;
*)
;;
esac
done
if [ "$NOPROMPT" != "1" ]; then
echo ""
echo ""
echo "!!!!!! DANGER DANGER DANGER DANGER DANGER DANGER !!!!!!"
echo ""
echo "If you lose power to your device while running this script,"
echo "it could be left in an unusable state."
echo ""
echo "This script will replace the bootloader on /dev/mtd0."
echo ""
echo "This installer will only work on the following devices:"
echo " Seagate GoFlex Net"
echo " Seagate Dockstar"
echo " Pogoplug Pink"
echo "Do not run this installer on any other device."
echo ""
echo "By typing ok, you agree to assume all liabilities and risks "
echo "associated with running this installer."
echo ""
echo -n "If you agree, type 'ok' and press ENTER to continue: "
read IS_OK
if [ "$IS_OK" != "OK" -a "$IS_OK" != "Ok" -a "$IS_OK" != "ok" ];
then
echo "Exiting. uBoot was not installed."
exit 1
fi
fi
install "$NANDWRITE" "$NANDWRITE_URL" 755
install "$NANDDUMP" "$NANDDUMP_URL" 755
install "$FLASH_ERASE" "$FLASH_ERASE_URL" 755
install "$FW_PRINTENV" "$FW_PRINTENV_URL" 755
install "$FW_CONFIG" "$FW_CONFIG_URL" 644
if [ ! -f "$FW_SETENV" ]; then
ln -s "$FW_PRINTENV" "$FW_SETENV" 2> /dev/null
if [ "$?" -ne "0" ]; then
mount -o remount,rw /
ln -s "$FW_PRINTENV" "$FW_SETENV"
mount -o remount,ro /
fi
fi
# Dump existing uBoot and compare it to a database of known versions
echo ""
echo "# Validating existing uBoot..."
# dump the first 512k of mtd0 to /tmp
$NANDDUMP -no -l 0x80000 -f /tmp/uboot-mtd0-dump /dev/mtd0
wget -O "/tmp/valid-uboot.md5" "$VALID_UBOOT_MD5"
UPDATE_UBOOT=1
UBOOT_PLATFORM=
CURRENT_UBOOT_MD5=$(md5sum "/tmp/uboot-mtd0-dump" | cut -d' ' -f1)
UBOOT_DETAILS=$(grep $CURRENT_UBOOT_MD5 /tmp/valid-uboot.md5)
if [ "$UBOOT_DETAILS" != "" ]; then
UBOOT_PLATFORM=$(echo $UBOOT_DETAILS | sed 's/^\w* \(\w*\) .*$/\1/')
UBOOT_VERSION=$(echo $UBOOT_DETAILS | sed 's/^\w* \w* \(.*\)$/\1/')
echo "## Valid uBoot detected: [$UBOOT_PLATFORM $UBOOT_VERSION]"
else
echo "## Unknown uBoot detected on mtd0: $CURRENT_UBOOT_MD5"
echo "##"
if [ "$NO_UBOOT_CHECK" != "1" ]; then
echo "## The installer could not detect the version of your current uBoot"
echo "## This may happen if you have installed a different uBoot on"
echo "## /dev/mtd0 or if you have bad blocks on /dev/mtd0"
echo "##"
echo "## If you have bad blocks on mtd0, you should not try to install uBoot."
echo "##"
echo "## If you have installed a diffirent uBoot on mtd0, and understand the"
echo "## risks, you can re-run the installer with the --no-uboot-check parameter"
echo "##"
echo "## Installation cancelled."
rm "/tmp/valid-uboot.md5"
exit 1
else
echo "## --no-uboot-check flag detected, continuing installation"
while [ "$UBOOT_PLATFORM" = "" ]; do
echo ""
echo "############################################"
echo "Your device could not be auto-detected."
echo ""
echo "You must be using a device listed below to run this installer."
echo ""
echo "What device are you using? Type the number of your device and press ENTER."
echo "1 - Seagate Dockstar"
echo "2 - Seagate GoFlex Net"
echo "3 - Pogoplug v2 - Pink"
echo "4 - Other"
read device
if [ "$device" = "1" ]; then
echo "Selected Dockstar"
UBOOT_PLATFORM="dockstar"
UBOOT_VERSION="unknown"
elif [ "$device" = "2" ]; then
echo "Selected Seagate GoFlex Net"
UBOOT_PLATFORM="goflexnet"
UBOOT_VERSION="unknown"
elif [ "$device" = "3" ]; then
echo "Selected Pogoplug v2 - Pink"
UBOOT_PLATFORM="pinkpogo"
UBOOT_VERSION="unknown"
elif [ "$device" = "4" ]; then
echo "Selected Other Device, exiting"
echo "This installer is only compatible with the listed devices."
exit 1
else
echo "Invalid Input"
fi
done
fi
fi
if [ "$FORCE_PLATFORM" != "" -a "$FORCE_PLATFORM" != "$UBOOT_PLATFORM" ]; then
echo "## --force-platform paramater [$FORCE_PLATFORM] does not match detected platform [$UBOOT_PLATFORM]."
echo -n "Are you sure your device is a "$FORCE_PLATFORM"? [y/N] "
read FORCE
if [ "$FORCE" = "y" -o "$FORCE" = "Y" ]; then
echo "## Forcing installation of [$FORCE_PLATFORM] platform"
UBOOT_PLATFORM=$FORCE_PLATFORM
UBOOT_VERSION="unknown"
else
echo "## Exiting. No changes were made to mtd0."
exit 1
fi
fi
UBOOT_IS_CURRENT=$(echo $UBOOT_VERSION | grep -c current)
if [ "$UBOOT_IS_CURRENT" = "1" ]; then
echo "## The newest uBoot is already installed on mtd0."
UPDATE_UBOOT=0
else
UBOOT_CURRENT=$(grep $UBOOT_PLATFORM /tmp/valid-uboot.md5 | grep current | sed 's/^\w* \w* \(.*\)-current$/\1/')
fi
rm "/tmp/valid-uboot.md5"
# If this is the first time this installer has been run in the
# original Pogoplug enviroment, check if the user wants to disable
# the Pogoplug services
if [ -d /usr/local/cloudengines/ -a ! -e $UBOOT_ORIGINAL ]; then
killall hbwd
echo ""
echo ""
echo ""
echo "DISABLE POGOPLUG SERVICES"
echo ""
echo "The pogoplug service includes an auto-update feature which could"
echo "be used to cripple or disable your device. It is recommended"
echo "that you disable this service."
echo ""
echo "NOTE: The pogoplug service is proprietary software"
echo "created by Cloud Engines. It is not available for use"
echo "in other distributions and will not be available in"
echo "your new linux installation even if you choose not to disable it."
echo ""
echo -n "Would you like to disable the pogoplug services? [Y/n] "
read DISABLE
if [ "$DISABLE" = "" -o "$DISABLE" = "y" -o "$DISABLE" = "Y" ];
then
echo "Applying fixes to the pogoplug environment..."
mount -o rw,remount /
# Add /sbin to the path and cleanup the shell prompt
if [ ! -f /root/.bash_profile ]; then
echo -e \
"export PS1='\h:\w\$ '
export PATH='/usr/bin:/bin:/sbin'
" > /root/.bash_profile
fi
chmod go+w /dev/null
# Re-enable dropbear (updated dockstars only)
sed -i 's/^#\/usr\/sbin\/dropbear/\/usr\/sbin\/dropbear/' /etc/init.d/db > /dev/null 2>&1
echo "Disabling the pogoplug service..."
# Comment out the line that starts hmbgr.sh
sed -i 's/^\/etc\/init.d\/hbmgr.sh start/#Uncomment the line below to enable the pogoplug service\n#\/etc\/init.d\/hbmgr.sh start/' /etc/init.d/rcS
mount -o ro,remount /
echo "Done fixing pogoplug environment."
echo ""
fi
UBOOT_ORIGINAL_URL="$UBOOT_MTD0_BASE_URL.$UBOOT_PLATFORM.original.kwb"
install "$UBOOT_ORIGINAL" "$UBOOT_ORIGINAL_URL" 644
install "$BLPARAM" "$BLPARAM_URL" 755
if [ "$UBOOT_PLATFORM" = "pinkpogo" ]; then BOOTCMD='nand read.e 0x800000 0x100000 0x200000; setenv bootargs $(console) $(bootargs_root); bootm 0x800000'
# dockstar and goflex have the same bootcmd
else BOOTCMD='nand read.e 0x800000 0x100000 0x300000; setenv bootargs $(console) $(bootargs_root); bootm 0x800000'
fi
$BLPARAM "bootcmd=$BOOTCMD" > /dev/null 2>&1
# Preserve the MAC address
ENV_ETHADDR=`$BLPARAM | grep "^ethaddr=" | cut -d'=' -f 2-`
fi
# Download and install the latest uBoot
if [ "$UPDATE_UBOOT" = "1" ]; then
echo ""
echo "# Installing uBoot"
UBOOT_MTD0_URL="$UBOOT_MTD0_BASE_URL.$UBOOT_PLATFORM.$UBOOT_CURRENT.kwb"
echo "## Installing $UBOOT_PLATFORM $UBOOT_CURRENT"
if [ -f "$UBOOT_MTD0" ]; then rm "$UBOOT_MTD0"; fi
download_and_verify "$UBOOT_MTD0" "$UBOOT_MTD0_URL"
if [ "$?" -ne "0" ]; then
echo "## uBoot could not be downloaded, or the MD5 does not match."
echo "## Exiting. No changes were made to mtd0."
exit 1
fi
# Write new uBoot to mtd0
# Erase the first 512k
$FLASH_ERASE /dev/mtd0 0 4
$NANDWRITE /dev/mtd0 $UBOOT_MTD0
# dump mtd0 and compare the checksum, to make sure it installed properly
$NANDDUMP -no -l 0x80000 -f /tmp/mtd0.uboot /dev/mtd0
echo "## Verifying new uBoot..."
if [ -f "$UBOOT_MTD0.md5" ]; then rm "$UBOOT_MTD0.md5"; fi
wget -O "$UBOOT_MTD0.md5" "$UBOOT_MTD0_URL.md5"
verify_md5 "/tmp/mtd0.uboot" "$UBOOT_MTD0.md5"
if [ "$?" -ne "0" ]; then
rm -f "$UBOOT.md5"
echo "##"
echo "##"
echo "## VERIFICATION FAILED!"
echo "##"
echo "## uBoot was not properly installed to mtd0."
echo "##"
echo "##"
echo "## YOUR DEVICE MAY BE IN AN UNUSABLE STATE."
echo "## DO NOT REBOOT OR POWER OFF YOUR DEVICE"
echo "##"
echo "##"
echo "## Make a backup of /tmp/uboot-mtd0-dump someplace safe and"
echo "## then re-run this installer."
exit 1
else
echo "# Verified successfully!"
fi
rm -f "$UBOOT_MTD0.md5"
fi
UPDATE_UBOOT_ENVIRONMENT=$UPDATE_UBOOT
if [ "$UPDATE_UBOOT" != "1" -a "$1" != "--noprompt" ]; then
echo ""
echo ""
echo "You are already running the latest uBoot."
echo -n "Would you like to reset the uBoot environment? [N/y] "
read PROMPT
if [ "$PROMPT" = "y" -o "$PROMPT" = "Y" ]; then
UPDATE_UBOOT_ENVIRONMENT=1
fi
fi
if [ "$UPDATE_UBOOT_ENVIRONMENT" = "1" ]; then
echo ""
echo "# Installing uBoot environment"
# Preserve the MAC address
if [ "$ENV_ETHADDR" = "" ]; then
ENV_ETHADDR=`$FW_PRINTENV ethaddr 2> /dev/null | cut -d'=' -f 2-`
fi
# Preserve the 'rescue_installed' setting
ENV_RESCUE_INSTALLED=`$FW_PRINTENV rescue_installed 2> /dev/null | cut -d'=' -f 2-`
if [ "$ENV_RESCUE_INSTALLED" = "" ]; then
ENV_BOOTCMD_RESCUE=`$FW_PRINTENV bootcmd_rescue 2> /dev/null`
if [ "$ENV_BOOTCMD_RESCUE" != "" ]; then
ENV_RESCUE_INSTALLED=1
fi
fi
# Preserve the arcNumber value
ENV_ARCNUMBER=`$FW_PRINTENV arcNumber 2> /dev/null | cut -d'=' -f 2-`
# Preserve the custom kernel parameters
ENV_RESCUE_CUSTOM=`$FW_PRINTENV rescue_custom_params 2> /dev/null | cut -d'=' -f 2-`
ENV_USB_CUSTOM=`$FW_PRINTENV usb_custom_params 2> /dev/null | cut -d'=' -f 2-`
ENV_UBIFS_CUSTOM=`$FW_PRINTENV ubifs_custom_params 2> /dev/null | cut -d'=' -f 2-`
# Install the uBoot environment
download_and_verify "$UBOOT_ENV" "$UBOOT_ENV_URL"
if [ "$?" -ne "0" ]; then
echo "## Could not install uBoot environment, exiting"
exit 1
fi
$FLASH_ERASE /dev/mtd0 0xc0000 1
$NANDWRITE -s 786432 /dev/mtd0 "$UBOOT_ENV"
echo ""
echo "# Verifying uBoot environment"
# Verify the uBoot environment
$NANDDUMP -nof "/tmp/uboot.environment" -s 0xc0000 -l 0x20000 /dev/mtd0
wget -O "$UBOOT_ENV.md5" "$UBOOT_ENV_URL.md5"
verify_md5 "/tmp/uboot.environment" "$UBOOT_ENV.md5"
if [ "$?" -ne "0" ]; then
rm -f "$UBOOT_ENV.md5"
echo "## VERIFICATION FAILED!"
echo "## uBoot environment was not properly written to mtd0. Please re-run this installer."
exit 1
fi
rm -f "$UBOOT_ENV.md5"
$FW_SETENV ethaddr $ENV_ETHADDR
if [ "$ENV_RESCUE_INSTALLED" = "1" ]; then $FW_SETENV rescue_installed $ENV_RESCUE_INSTALLED; fi
if [ "$ENV_RESCUE_CUSTOM" != "" ]; then $FW_SETENV rescue_custom_params $ENV_RESCUE_CUSTOM; fi
if [ "$ENV_USB_CUSTOM" != "" ]; then $FW_SETENV rescue_usb_params $ENV_USB_CUSTOM; fi
if [ "$ENV_UBIFS_CUSTOM" != "" ]; then $FW_SETENV rescue_ubifs_params $ENV_UBIFS_CUSTOM; fi
if [ "$ENV_ARCNUMBER" != "" ]; then
$FW_SETENV arcNumber $ENV_ARCNUMBER
# If there was no arcNumber set, then this is probably a new install.
# Set the default arcNumber for the platform
# Note: As of 10/24/2010 everything will default to the SHEEVAPLUG arcNumber (2097)
# at some point, they should start using the newer dockstar ID (2998) but currently the most
# common kernels do not support the Dockstar machine ID
else
$FW_SETENV arcNumber 2097
echo ""
echo ""
echo "# Setting arcNumber to 2097 (SheevaPlug)"
echo "# Note: if you have a kernel that supports your platform, you should use the proper arcNumber."
echo "# You can set the correct arcNumber by running the following command:"
if [ "$UBOOT_PLATFORM" = "dockstar" ]; then echo $FW_SETENV arcNumber 2998
elif [ "$UBOOT_PLATFORM" = "goflexnet" ]; then echo $FW_SETENV arcNumber 3089
elif [ "$UBOOT_PLATFORM" = "pinkpogo" ]; then echo $FW_SETENV arcNumber 2998
fi
fi
fi
echo ""
echo "# uBoot installation has completed successfully."
|
The script worked well for me; so should it in all devices.
Second, I started with the Gentoo Handbook for ARM. The was a small problem, since the device doesn't have neither "bzip2" available, nor is it capable of copying files with scp. So everything has to be converted to gzip or plaint tar, first. You can copy it onto the device with another USB device; I copied it to an alternate HTTP - Dir and used wget instead.
Another problem was, that the device doesn't have "chroot" available. But it's available within the "armv5tel-softfloat-linux-gnueabi" - stage3 under "bin/chroot", so you can easily issue "/mnt/gentoo/bin/chroot" (or where else you are working in) to change the root.
Once inside the chroot, you've to set the PATH variable by hand:
Code: | export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.4.4 |
That's how far I get, yesterday. I'll inform you about my further progress with this - I think that the kernel might get difficult to build, since this is my very first ARM architecture ... _________________ http://www.marc-richter.info |
|
Back to top |
|
|
b0nafide Apprentice
Joined: 17 Feb 2008 Posts: 171 Location: ~/
|
|
Back to top |
|
|
tomk Bodhisattva
Joined: 23 Sep 2003 Posts: 7221 Location: Sat in front of my computer
|
Posted: Mon Nov 15, 2010 8:24 pm Post subject: |
|
|
Moved from Installing Gentoo to Gentoo on Alternative Architectures as it fits better here. _________________ Search | Read | Answer | Report | Strip |
|
Back to top |
|
|
Whitewolf Fox Tux's lil' helper
Joined: 29 Aug 2004 Posts: 78 Location: Ratingen
|
Posted: Tue Nov 16, 2010 6:54 pm Post subject: |
|
|
Hi b0nafide,
this is totally awesome! Thank you a lot for the link! Especially the tipp, that this device seems to not have a RTC and time/date has to be set very soon in the startup process would have caused me a serious headache ...
I'll try the guide; currently I'm stuck with the fact, that I won't use a statical IP but DHCP, which has to be set early during bootup somehow .. but I guess I'll find something _________________ http://www.marc-richter.info |
|
Back to top |
|
|
b0nafide Apprentice
Joined: 17 Feb 2008 Posts: 171 Location: ~/
|
Posted: Wed Nov 17, 2010 4:46 am Post subject: |
|
|
You're welcome. I confess I've got debian running on it now just to test-drive it.
However, gentoo is my ultimate plan... it will be my first ARM-based gentoo and I am approaching it with caution. At the moment I am learning as much as I can about uboot so I don't mess anything up when my kernel is ready. |
|
Back to top |
|
|
avion23 n00b
Joined: 20 Jul 2009 Posts: 8
|
Posted: Fri Jan 13, 2012 8:04 pm Post subject: |
|
|
Hi guys,
i also have managed to run gentoo on the seagate dockstar. I'm posting my kernel config and make.conf to make it easier for everybody to setup a new system. Feel free to correct any of my errors.
Code: | #CFLAGS="-O2 -pipe -march=armv5te"
#CXXFLAGS="${CFLAGS}"
#CFLAGS="-Os -march=armv5te -pipe -fomit-frame-pointer"
# doesn't work with gcc-4.4
#CFLAGS="-Os -march=armv5te -mtune=marvell-f -funit-at-a-time -pipe -fomit-frame-pointer"
# possibly makes things worse
CFLAGS="-Os -march=armv5te -mtune=xscale -funit-at-a-time -pipe -fomit-frame-pointer"
CXXFLAGS="-std=gnu++0x -fvisibility-inlines-hidden ${CFLAGS}"
# Use one of the CXXFLAGS below if an ebuild won't compile with the above CXXFLAGS
#CXXFLAGS="-fvisibility-inlines-hidden ${CFLAGS}"
#CXXFLAGS="${CFLAGS}"
LDFLAGS="${LDFLAGS} -Wl,-O1 -Wl,--enable-new-dtags -Wl,--sort-common"
# WARNING: Changing your CHOST is not something that should be done lightly.
# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.
CHOST="armv5tel-softfloat-linux-gnueabi"
FEATURES="distcc"
PORTAGE_NICENESS="19"
PORTAGE_IONICE_COMMAND="ionice -c 3 -p \${PID}"
PORTDIR_OVERLAY=/usr/local/ebuilds
#GENTOO_MIRRORS="http://gentoo.inf.elte.hu/ ftp://mirror.its.uidaho.edu/gentoo"
SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"
USE="-ldap -openmp -acl dhcp -mudflap -fortran bzip2 lzma lzo zlib wifi \
wps python -consolekit -cups usb server ftpd rrdtool perl"
|
EDIT: kernel config is too long to post here. pastebin instead: http://pastebin.com/rUSvfQQJ |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|