This shows you the differences between two versions of the page.
mission:tech:odyssey:mcu:os [2012/04/05 22:23] – created chrono | mission:tech:odyssey:mcu:os [2013/06/05 14:34] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== MCU Operating System ====== | ||
+ | |||
+ | Trace of a Gentoo Install on a Seagte Dockstar | ||
+ | |||
+ | ===== Prep ===== | ||
+ | |||
+ | USB Stick | ||
+ | |||
+ | p1: 25MB ext2 (kernel) * | ||
+ | p2: 1024MB swap | ||
+ | p3: 6G ext3 (rootfs) | ||
+ | |||
+ | ===== 1st Boot ===== | ||
+ | |||
+ | plugin in usb-stick, network cable then power | ||
+ | led blinks green, then blinks orange, goes off and goes steady orange when ready. | ||
+ | |||
+ | <code bash>$ ifconfig eth1 169.254.1.0</ | ||
+ | |||
+ | The fastest way to identify the dockstar' | ||
+ | |||
+ | <code bash>$ nmap -e eth1 -sP $(printf " | ||
+ | |||
+ | < | ||
+ | Starting Nmap 5.21 ( http:// | ||
+ | Nmap scan report for 169.254.188.74 | ||
+ | Host is up (0.00011s latency). | ||
+ | MAC Address: 00: | ||
+ | Nmap done: 1 IP address (1 host up) scanned in 0.10 seconds | ||
+ | </ | ||
+ | |||
+ | |||
+ | <code bash>$ nmap -e eth1 -sP 169.254.0.0/ | ||
+ | |||
+ | < | ||
+ | Nmap scan report for 169.254.188.74 | ||
+ | Host is up (0.000096s latency). | ||
+ | MAC Address: 00: | ||
+ | </ | ||
+ | |||
+ | Default dockstar firmware services: | ||
+ | |||
+ | <code bash>$ nmap -sS 169.254.188.74</ | ||
+ | |||
+ | < | ||
+ | Starting Nmap 5.21 ( http:// | ||
+ | Nmap scan report for 169.254.188.74 | ||
+ | Host is up (0.00022s latency). | ||
+ | Not shown: 996 closed ports | ||
+ | PORT STATE SERVICE | ||
+ | 22/ | ||
+ | 23/ | ||
+ | 80/ | ||
+ | 3333/tcp open dec-notes | ||
+ | MAC Address: 00: | ||
+ | |||
+ | Nmap done: 1 IP address (1 host up) scanned in 1.29 seconds | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== 1st Login ===== | ||
+ | |||
+ | ssh login user: root | ||
+ | default password: stxadmin | ||
+ | |||
+ | < | ||
+ | root@169.254.188.74' | ||
+ | -bash-3.2# | ||
+ | </ | ||
+ | |||
+ | ===== Backup Original Firmware ===== | ||
+ | |||
+ | |||
+ | <code bash> | ||
+ | < | ||
+ | dev: size | ||
+ | mtd0: 00100000 00020000 " | ||
+ | mtd1: 00400000 00020000 " | ||
+ | mtd2: 02000000 00020000 " | ||
+ | mtd3: 0db00000 00020000 " | ||
+ | </ | ||
+ | <code bash> | ||
+ | < | ||
+ | rootfs on / type rootfs (rw) | ||
+ | /dev/root on / type jffs2 (ro) | ||
+ | none on /proc type proc (rw) | ||
+ | none on /sys type sysfs (rw) | ||
+ | none on /dev/pts type devpts (rw) | ||
+ | none on /tmp type tmpfs (rw) | ||
+ | / | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | Plug in the power, wait until the LED is steadily orange and log in again. Because we need access to the Internet we are now disabling the startup of the Pogoplug software, so we are not risking that the device updates something when it can go online: | ||
+ | |||
+ | user@host ~ $ ssh root@ip_found # password is stxadmin | ||
+ | -bash-3.2# killall hbwd # stop the Pogoplug software | ||
+ | -bash-3.2# mount -o remount,rw / | ||
+ | -bash-3.2# chmod go+w /dev/null # fix a bug | ||
+ | -bash-3.2# vi / | ||
+ | Comment out the line which starts the Pogoplug software using a dash save and quit vi: | ||
+ | |||
+ | ... | ||
+ | #/ | ||
+ | ... | ||
+ | (Warning: As already mentioned above, don't disable hbmgr on devices with a firmware where you have to enable ssh through the Pogoplug software. This will disable ssh after reboot/ | ||
+ | |||
+ | Remount / again as read only and shutdown: | ||
+ | |||
+ | -bash-3.2# mount -o remount,ro / | ||
+ | -bash-3.2# /sbin/halt | ||
+ | Again, wait a minute and turn off the device. | ||
+ | |||
+ | |||
+ | when back online: | ||
+ | |||
+ | / | ||
+ | |||
+ | relogin and default routes: | ||
+ | |||
+ | ip route add default via 192.168.1.254 | ||
+ | echo " | ||
+ | |||
+ | |||
+ | <code bash> | ||
+ | bash-3.2# | ||
+ | -bash-3.2# mount /dev/sda2 /mnt/ | ||
+ | -bash-3.2# | ||
+ | -bash-3.2# cd /mnt/ | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | wget http:// | ||
+ | |||
+ | $ tar -xvjpf stage3-armv5tel-20110520.tar.bz2 | ||
+ | -bash-3.2# | ||
+ | -bash-3.2# mount -o bind /proc /mnt/proc | ||
+ | -bash-3.2# mount -o bind /sys /mnt/sys | ||
+ | -bash-3.2# mount /dev/sda1 /mnt/boot | ||
+ | -bash-3.2# tar -xvjpf stage3-armv5tel-20110520.tar.bz2 | ||
+ | -bash-3.2# cp / | ||
+ | -bash-3.2# hostname DockStar | ||
+ | -bash-3.2# | ||
+ | DockStar / # source / | ||
+ | DockStar / # env-update | ||
+ | >>> | ||
+ | DockStar / # | ||
+ | DockStar / # export PS1=" | ||
+ | </ | ||
+ | |||
+ | ===== Inside chroot tasks ===== | ||
+ | |||
+ | < | ||
+ | (chroot) DockStar / # mkdir / | ||
+ | (chroot) DockStar / # nano / | ||
+ | </ | ||
+ | |||
+ | |||
+ | make.conf | ||
+ | |||
+ | < | ||
+ | CFLAGS=" | ||
+ | |||
+ | CXXFLAGS=" | ||
+ | # Use one of the CXXFLAGS below if an ebuild won't compile with the above CXXFLAGS | ||
+ | # | ||
+ | # | ||
+ | |||
+ | LDFLAGS=" | ||
+ | |||
+ | # WARNING: Changing your CHOST is not something that should be done lightly. | ||
+ | # Please consult http:// | ||
+ | CHOST=" | ||
+ | |||
+ | PORTDIR_OVERLAY=/ | ||
+ | </ | ||
+ | |||
+ | Edit / | ||
+ | |||
+ | < | ||
+ | config_eth0=( " | ||
+ | If you want to use a static IP / | ||
+ | |||
+ | config_eth0=( " | ||
+ | routes_eth0=( " | ||
+ | Edit / | ||
+ | |||
+ | ... | ||
+ | / | ||
+ | #/ | ||
+ | / | ||
+ | / | ||
+ | ... | ||
+ | Edit / | ||
+ | |||
+ | ... | ||
+ | # TERMINALS | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | |||
+ | # SERIAL CONSOLES | ||
+ | s0: | ||
+ | # | ||
+ | ... | ||
+ | Edit / | ||
+ | |||
+ | ... | ||
+ | # "/ | ||
+ | echo default-on > / | ||
+ | |||
+ | |||
+ | DockStar / # cp / | ||
+ | |||
+ | Get the portage: | ||
+ | |||
+ | DockStar / # emerge --sync | ||
+ | ... | ||
+ | DockStar / # eselect profile list | ||
+ | ... | ||
+ | |||
+ | |||
+ | USE=" | ||
+ | |||
+ | |||
+ | |||
+ | Install newer linux-headers, | ||
+ | |||
+ | $ ACCEPT_KEYWORDS=~arm emerge linux-headers | ||
+ | |||
+ | Enable necessary boot services and a password for root: | ||
+ | |||
+ | $ ln -s / | ||
+ | $ rc-update add net.eth0 default | ||
+ | * net.eth0 added to runlevel default | ||
+ | $ rc-update add sshd default | ||
+ | * sshd added to runlevel default | ||
+ | $ rc-update add ntpd default | ||
+ | * ntpd added to runlevel default | ||
+ | $ passwd | ||
+ | |||
+ | Edit / | ||
+ | |||
+ | ... | ||
+ | TIMEZONE=" | ||
+ | ... | ||
+ | |||
+ | |||
+ | edit / | ||
+ | |||
+ | # we can speed up booting under these conditions: | ||
+ | # * using devtmpfs so kernel creates device nodes for us | ||
+ | # * only using kernel created device nodes at boot (in /etc/fstab and elsewhere) | ||
+ | # | ||
+ | ebegin " | ||
+ | udevadm settle --timeout=${udev_settle_timeout: | ||
+ | eend $? | ||
+ | |||
+ | ebegin " | ||
+ | # Take the newest time from the four times found through tune2fs to set the date. | ||
+ | # This avoids a fsck if rdate or ntpd doesn' | ||
+ | t=0 | ||
+ | for i in 'Last write time:' 'Last mount time:' ' | ||
+ | tt=$(/ | ||
+ | if [ $tt -gt $t ]; then | ||
+ | t=$tt | ||
+ | fi | ||
+ | done | ||
+ | /bin/date -s @$t | ||
+ | # Configure the network for ntp or rdate | ||
+ | / | ||
+ | /sbin/route add default gw 192.168.1.254 | ||
+ | #/ | ||
+ | / | ||
+ | #/ | ||
+ | eend $? | ||
+ | |||
+ | udevadm control --property=do_not_run_plug_service= | ||
+ | udevadm control --property=STARTUP= | ||
+ | return 0 | ||
+ | |||
+ | |||
+ | patch procps to avoid " | ||
+ | |||
+ | $ cd / | ||
+ | $ wget http:// | ||
+ | $ tar -xvjpf procps_ebuild.tar.bz2 | ||
+ | $ rm procps_ebuild.tar.bz2 | ||
+ | $ cd sys-process/ | ||
+ | $ ebuild procps-3.2.8-r1.ebuild digest | ||
+ | |||
+ | $ emerge -av procps | ||
+ | |||
+ | |||
+ | Installation of the kernel (Linux) | ||
+ | |||
+ | As kernel we are using the latest stable one and applying some patches. Depending on the time you read this you should change the version used in the URL for git clone to get the latest version. You might want to use screen for some of those steps below, if you want to turn your box off while the DockStar fetches or compiles the kernel. Again, go and drink a coffee or make your family happy after you've started this: | ||
+ | |||
+ | $ mkdir /usr/src | ||
+ | $ cd /usr/src | ||
+ | $ git clone git:// | ||
+ | $ ln -s linux-2.6.38.y linux | ||
+ | |||
+ | patches for the kernel (LEDs, MTD and to force the usage of the in-kernel commandline), | ||
+ | |||
+ | DockStar src # wget http:// | ||
+ | DockStar src # cp config-2.6.38-dockstar linux/ | ||
+ | DockStar src # cd linux | ||
+ | DockStar linux # wget http:// | ||
+ | DockStar linux # tar xpjf linux-2.6.38_patches_dockstar.tar.bz2 | ||
+ | DockStar linux # rm linux-2.6.38_patches_dockstar.tar.bz2 | ||
+ | DockStar linux # git am 000* | ||
+ | DockStar linux # rm 000* | ||
+ | DockStar linux # git describe | ||
+ | v2.6.38.2-3-gfddba4c | ||
+ | DockStar linux # make oldconfig | ||
+ | |||
+ | |||
+ | For not having to use the boot loader for changing the kernel command line, we are storing the command line in the kernel itself. If you want to use the netconsole you have to change the command line using "make menuconfig" | ||
+ | |||
+ | console=ttyS0, | ||
+ | With netconsole you should change it to something like this: | ||
+ | |||
+ | console=ttyS0, | ||
+ | The documentation for the kernel parameter netconsole can be found in the file Documentation/ | ||
+ | |||
+ | No other modifications are currently necessary, if you want to add some drivers for other USB-devices like WLAN-sticks or such, I suggest to do this after you've booted the new system. Now it's time to compile the kernel we want to use. And again, go and drink a coffee or make your family happy after you've started this: | ||
+ | |||
+ | DockStar linux # make clean uImage modules modules_install | ||
+ | |||
+ | Copy the kernel to the first partition (sda1, already mounted in a step above to /boot). If you have formatted the first partition as vfat, you have to skip the line where a symlink in /boot is created. This symlink is not really needed and just makes sure, that if someone (we don't) uses (partition1)/ | ||
+ | |||
+ | DockStar linux # ln -s . /boot/boot | ||
+ | DockStar linux # cp / | ||
+ | |||
+ | If you later want to upgrade to a new version, the sequence would be: | ||
+ | |||
+ | DockStar ~ # cd / | ||
+ | DockStar linux # git remote update | ||
+ | DockStar linux # git rebase v2.6.38.n | ||
+ | DockStar linux # make clean oldconfig uImage modules modules_install | ||
+ | DockStar linux # mount /boot | ||
+ | DockStar linux # mv / | ||
+ | DockStar linux # cp / | ||
+ | DockStar linux # umount /boot | ||
+ | |||
+ | </ | ||
+ | |||
+ | ===== Bootloader ===== | ||
+ | |||
+ | |||
+ | < | ||
+ | First get the actual sources for U-Boot: | ||
+ | |||
+ | DockStar linux # cd /usr/src | ||
+ | DockStar src # git clone git:// | ||
+ | |||
+ | patches are for a version of U-Boot which was current in February 2010 and don't apply cleanly to later versions. Reset the git tree to older version: | ||
+ | |||
+ | DockStar src # cd u-boot | ||
+ | DockStar u-boot # git reset --hard 77e7273c40315abd2f3c17ad8d46a78950e3e65f | ||
+ | |||
+ | Apply some patches: | ||
+ | |||
+ | DockStar u-boot # wget http:// | ||
+ | DockStar u-boot # tar xpjf uboot_patches_dockstar.tar.bz2 | ||
+ | DockStar u-boot # rm uboot_patches_dockstar.tar.bz2 | ||
+ | DockStar u-boot # git am 00* | ||
+ | DockStar u-boot # rm 00* | ||
+ | |||
+ | Edit / | ||
+ | |||
+ | ... | ||
+ | /* CHANGE THIS TO THE IPS YOU WANT TO USE! */ | ||
+ | #define CONFIG_PREBOOT " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ... | ||
+ | /* CHANGE THIS TO THE MAC FOUND ON THE BOTTOM OF YOUR DOCKSTAR! */ | ||
+ | #define CONFIG_ETHADDR 00: | ||
+ | ... | ||
+ | /* CHANGE THIS TO THE IPS YOU WANT TO USE! */ | ||
+ | #define CONFIG_EXTRA_ENV_SETTINGS \ | ||
+ | " | ||
+ | |||
+ | |||
+ | Currently there exists a small problem when enabling netconsole in U-Boot, the netconsole from the kernel won't work. If the netconsole in U-Boot is not enabled, the netconsole from the kernel will work. So choose your poison. My preference is to leave the netconsole enabled in both, so I can use at least the shell from U-Boot without having to attach a serial cable to the device. Maybe someone will come up with a patch for U-Boot or the kernel later. | ||
+ | |||
+ | If you don't want to use netconsole in U-Boot the entry for CONFIG_PREBOOT should just look like | ||
+ | |||
+ | #define CONFIG_PREBOOT " | ||
+ | To disable netconsole in the kernel the first line of CONFIG_EXTRA_ENV_SETTINGS should look like | ||
+ | |||
+ | " | ||
+ | In case you are wondering about the x_bootargs. Using my patches for the kernel they are not used and are just there if someone wants to use a vanilla kernel. This means to disable the netconsole in the kernel you have to change the commandline through menuconfig. | ||
+ | |||
+ | If you have formated the first partition which contains the kernel with fat, you have to change the line with ext2load in that file to fatload, so it reads like | ||
+ | |||
+ | " | ||
+ | Now commit your changes and build U-Boot: | ||
+ | |||
+ | DockStar u-boot # git commit -a -m " | ||
+ | DockStar u-boot # git describe | ||
+ | v2009.11-415-g388fcdc | ||
+ | DockStar u-boot # ./ | ||
+ | |||
+ | </ | ||