User Tools

Site Tools


doc:howtobuild:sheevaplug

SheevaPlug

I have installed OpenWrt BARRIER BREAKER on the NAND memory of a SheevaPlug with success.

Hope these notes will help to explain how reproduce it.

There are a lot of advantages to put OpenWrt on a SheevaPlug NAND, for example:

  • Have a system it can be shutdown as a modem.
  • Use an external USB hard drive and spin it down for noise reduction.
  • Have fast restart of the system, very good thing for a PBX
  • Etc …

Unfortunately, there aren't any pre-built images offered for download for the SheevaPLug device.

In fact the port is simple. It just needs to regenerate a openwrt-kirkwood-uImage file after having enabled the SheevaPlug motherboard support.

What You Need To Know

  1. The jffs2-nand support file system is only available on the BARRIER BREAKER version.
  2. The rootfs size reserved by u-boot will be too small by default.
  3. Never use /snapshots/trunk/kirkwood/uboot-kirkwood-sheevaplug/ to update your u-boot.

Preparations

Might look like a bad joke, but in fact when I started the SheevaPlug port I had only read the Wiki documentation. All the necessary info for building it on your own devices is there.

  1. You will be using OpenWrt Buildroot for this, so read about it
  2. Pull OpenWrt Buildroot per svn/git and install its prerequisites on your system: OpenWrt Buildroot – Installation
  3. See howto use it OpenWrt Buildroot – Usage
  4. In case questions pop up, cf. OpenWrt Buildroot – Technical Reference (Work in Progress)

Debian 7 :

sudo apt-get install libncurses5-dev zlib1g-dev gawk subversion build-essential libncurses5-dev zlib1g-dev gawk git ccache gettext libssl-dev xsltproc

Note: If you simply and swiftly want to cross compile a program, see crosscompile.

Procedure

1. Pull OpenWrt Buildroot and install its dependencies

2. Pull sources for BARRIER BREAKER

cd ~
mkdir -p ~/openwrt
cd ~/openwrt
svn co svn://svn.openwrt.org/openwrt/branches/barrier_breaker
cd barrier_breaker

Configure Target system

make menuconfig
  - Target System ---> Marvell Kirkwood
  - Target Profile ---> Generic (default)
  - Target Images  ---> 
     [*] jffs2 for NAND
  - Save and Exit
make kernel_menuconfig
System Type  ---> 
  Marvell Kirkwood Implementations  --->
   [*] Marvell eSATA SheevaPlug Reference Board
   [*] Marvell SheevaPlug Reference Board
  Device Drivers  ---> 
   [*] USB support  --->
     <*>   Support for Host-side USB
  [*] Network device support  --->
    USB Network Adapters  --->
      <*> Multi-purpose USB Networking Framework
      <*>   CDC NCM support
      <*>   Host for RNDIS and ActiveSync devices
      <*>   QMI WWAN driver for Qualcomm MSM based 3G and LTE modems
      <*> USB-to-WWAN Driver for Sierra Wireless modems
      -*-   CDC Ethernet support (smart devices such as cable modems)
  - Save and Exit
We add feeds after having declared the System Type, then generate default configuration
./scripts/feeds update -a
./scripts/feeds install -a
make defconfig
make prereq
make oldconfig

It's time to add necessary packages for configuring the SheevaPlug via Luci.

I have tried many times and many things without success, but finally found that http://ofmodemsandmen.com/build.html describes very well the necessary things for having USB working well with OpenWrt. That's why the settings proposed here are the same as Ofmodemsandmen, since i haven't the required skills for makeing it better. Apologize for that.

make menuconfig
Kernel modules  --->
  USB Support  --->
    <*> kmod-usb-acm......................... Support for modems/isdn controllers
    <*> kmod-usb-net............... Kernel modules for USB-to-Ethernet convertors
    <*> kmod-usb-net-sierrawireless.......... Support for Sierra Wireless devices
    <*> kmod-usb-ohci............................... Support for OHCI controllers
    <*> kmod-usb-serial..................... Support for USB-to-Serial converters
    <*> kmod-usb-serial-option................... Support for Option HSDPA modems
    <*> kmod-usb-serial-qualcomm................. Support for Qualcomm USB serial
    <*> kmod-usb-serial-sierrawireless....... Support for Sierra Wireless devices
    <*> kmod-usb-uhci............................... Support for UHCI controllers
    <*> kmod-usb2................................... Support for USB2 controllers
LuCI  ---> 
  1. Collections  ---> <*> luci-ssl
    -*- luci
    <*> luci-ssl......................... Standard OpenWrt set with HTTPS support
  6. Protocols  --->
    <*> luci-proto-3g............................................. Support for 3G
    <*> luci-proto-relay....................... Support for relayd pseudo bridges
  3. Applications  --->
    <*> luci-app-qos..................... Quality of Service configuration module
    <*> luci-app-ddns........................... Dynamic DNS configuration module
    <*> luci-app-ntpc.............. NTP time synchronisation configuration module
Network  --->
  <*> ppp........................................................... PPP daemon
  <*> ppp-mod-pppoe............................................... PPPoE plugin
  <*> wpad-mini............ IEEE 802.1x Authenticator/Supplicant (WPA-PSK only)
Utilities  --->
  <*> usb-modeswitch................................ USB mode switching utility
  <*> procps.................................................... proc utilities  ---> (ALL)
Base system  --->
  <*> wireless-tools.......... Tools for manipulating Linux Wireless Extensions 
- Save and Exit

Then we start the compilation

make V=s

It results in a minimalistic functioning system, but you shouldn't stop you work here. Instead, build all other available packages as module, especially the kernel-modules. That because a lot of packages can depend on kernel sign. It can take days to generate all packages as opkg format, but that's a good way for never having to recompile anything.

It has 512M of NAND memory

It's time to save your configuration via ./scripts/env script and configure special things. Storage space will be no problem. VPN, PBX, Tvheadend with IPTV tuner, who knows …

user@youhost:~/openwrt/barrier_breaker$rmdir ./env/files
user@youhost:~/openwrt/barrier_breaker$./script/env save
Initialized empty Git repository in /home/hts/openwrt/barrier_breaker/env/.git/
[master 14ece99] Update at jeudi 8 mai 2014, 21:51:48 (UTC+0200)
 1 file changed, 4045 insertions(+)
./scripts/env new sheevaplug_strongswan
Switched to a new branch 'sheevaplug_strongswan'
Do you want to start your configuration repository with the current configuration? (Y/n): y
# On branch sheevaplug_strongswan
nothing to commit (working directory clean)
user@youhost:~/openwrt/barrier_breaker$ ./scripts/env list
  master
* sheevaplug_strongswan

StrongSwan

StrongSwan is a IPV6/IPV4 IPsec-based VPN solution.

Start by enabling the required StrongSwan Original source: http://wiki.strongswan.org/projects/strongswan/wiki/KernelModules

make kernel_menuconfig
Networking  --->
  [*] Networking support  --->
        Networking options  --->
          <*> Transformation user configuration interface
          <*> PF_KEY sockets
          [*] TCP/IP networking
          [*]   IP: advanced router
          [*]   IP: policy routing
          <*>   IP: AH transformation
          <*>   IP: ESP transformation
          <*>   IP: IPComp transformation
          <*>   IP: IPsec transport mode
          <*>   IP: IPsec tunnel mode
          <*>   IP: IPsec BEET mode
          <*>   The IPv6 protocol  --->
            <*>   IPv6: AH transformation
            <*>   IPv6: ESP transformation
            <*>   IPv6: IPComp transformation
            <*>   IPv6: IPsec transport mode
            <*>   IPv6: IPsec tunnel mode
            <*>   IPv6: IPsec BEET mode
            [*]   IPv6: Multiple Routing Tables
         [*] Network packet filtering framework (Netfilter)  --->
               Core Netfilter Configuration  --->
                 <*> Netfilter Xtables support (required for ip_tables)
                 <*>   IPsec "policy" match support

 Cryptographic API
   Select algorithms you want to use... ???

make menuconfig

<*> luci-proto-ipv6................. Support for DHCPv6/6in4/6to4/6rd/DS-Lite
<*> strongswan.................................................... StrongSwan
<*> strongswan-charon................... StrongSwan IKEv1/IKEv2 keying daemon
<*> strongswan-default.................................. StrongSwan (default)
<*> strongswan-mod-uci................ StrongSwan UCI config interface plugin

3. Prepare a TFTP server

Unfortunately for you I have use a TFTP server to inject both kernel and rootfs image on the SheevaPlug NAND. I use Debian 7 host for all my test, then the example is for GNU/Linux system. For other OS it should be possible, you just have to put openwrt-kirkwood-uImage and openwrt-kirkwood-generic-jffs2-nand-2048-128k.img on the "root" of you TFTP server.

apt-get install tftpd-hpa

Take a look on /etc/default/tftpd-hpa file, it should look like that:

# /etc/default/tftpd-hpa
RUN_DAEMON="yes"
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/srv/tftp"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="--secure --verbose"
then
/etc/init.d/tftpd-hpa restart
[ ok ] Restarting HPA's tftpd: in.tftpd.

copy openwrt-kirkwood-uImage and openwrt-kirkwood-generic-jffs2-nand-2048-128k.img on /srv/tftp/ directory

cp ./bin/kirkwood/openwrt-kirkwood-uImage /srv/tftp/
cp ./bin/kirkwood/openwrt-kirkwood-generic-jffs2-nand-2048-128k.img /srv/tftp/

4. Deal with u-boot

You probably have to update your u-boot, you can find it here: http://people.debian.org/~tbm/u-boot/

Follow this howto http://www.cyrius.com/debian/kirkwood/sheevaplug/uboot-upgrade/

Never use the u-boot file generated by OpenWrt SDK, or found on anywhere of OpenWrt, that will simply break your device. Prefer Debian u-boot file.

  1. Connect the sheevaPlug MiniUSB to a USB port of you computer
  2. Open a terminal session
  3. Use screen or Minicom

screen /dev/ttyUSB0 115200

Start by creating a backup of your u-boot environment variables by printenv, then copy&paste the result inside your favorite text editor.

Marvell>> printenv

Unset almost every variables by using: sentenv VARIABLE_NAME.

When it's pretty clean, inject these environment settings:

 setenv loadaddr '0x6400000'
 setenv console 'console=ttyS0,115200 panic=20'
 setenv bootargs_root 'root=/dev/mtdblock2 rootfstype=jffs2'
 setenv kernel_name 'openwrt-kirkwood-uImage'
 setenv rootfs_name 'openwrt-kirkwood-generic-jffs2-nand-2048-128k.img'
 setenv download_kernel 'mw $(loadaddr) 0xffff 0x300000; tftp $(loadaddr) $(kernel_name);'
 setenv flash_kernel 'nand erase 0x100000 0x400000; nand write.e $(loadaddr) 0x100000 0x400000;'
 setenv download_rootfs 'mw $(loadaddr) 0xffff 0x200000; tftp $(loadaddr) $(rootfs_name);'
 setenv flash_rootfs 'nand erase 0x500000 0xfb00000; nand write.e $(loadaddr) 0x500000 0x900000;'
 setenv load_openwrt 'setenv bootargs $(console) $(bootargs_root); nand read $(loadaddr) 0x100000 0x400000; bootm $(loadaddr)'
 setenv bootcmd 'run load_openwrt'
 saveenv

Set the correct arcNumber for the SheevaPlug

 setenv arcNumber '2097'

If you have an eSATA SheevaPlug you have to inform u-boot by typing:

setenv machid a76

Find ethaddr and replace 'XX:XX:XX:XX:XX:XX' by your true MAC address, which can be found on a sticker on the back of your device

 setenv ethaddr 'XX:XX:XX:XX:XX:XX'

Save your settings now

saveenv

If you have DHCP, inject TFTP information:

 dhcp;run download_kernel;run flash_kernel;run download_rootfs;run flash_rootfs;reset;
Else:
 setenv ipaddr '192.168.1.100'
 setenv serverip '192.168.1.10'
 run download_kernel;run flash_kernel;run download_rootfs;run flash_rootfs;reset;
where ipaddr is you IP address on you network, and serverip the TFTP server IP address on you network.

5. First boot

At first boot, the filesytem will take a moment to grow the rootfs partition to MAX size. Be patient, this can take quite a while (5 minutes).

Troubleshooting

Download a valid u-boot from here http://people.debian.org/~tbm/u-boot/

cd $HOME
wget http://people.debian.org/~tbm/u-boot/2013.10-2/sheevaplug/u-boot.kwb
wget http://people.debian.org/~tbm/u-boot/2013.10-2/sheevaplug/uboot.elf

Install openocd for unbricking your SheevaPlug device.

sudo apt-get update && apt-get install openocd telnet screen

Connect power to the SheevaPlug and connect the miniusb port to you computer.

Open a terminal session and initialize openocd:

#openocd -f /usr/share/openocd/scripts/board/sheevaplug.cfg -s /usr/share/openocd/scripts

Open On-Chip Debugger 0.5.0 (2011-08-09-08:45)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.berlios.de/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'jtag'
2000 kHz
trst_and_srst separate srst_gates_jtag trst_push_pull srst_open_drain
adapter_nsrst_delay: 200
jtag_ntrst_delay: 200
dcc downloads are enabled
Warn : use 'feroceon.cpu' as target identifier, not '0'
sheevaplug_load_uboot
Info : clock speed 2000 kHz
Error: JTAG scan chain interrogation failed: all zeroes
Error: Check JTAG interface, timings, target power, etc.
Error: Trying to use configured scan chain anyway...
Error: feroceon.cpu: IR capture error; saw 0x00 not 0x01
Warn : Bypassing JTAG setup events due to errors
Info : Embedded ICE version 0
Info : feroceon.cpu: hardware has 1 breakpoint/watchpoint unit
Error: unexpected Feroceon EICE version signature

Download a valid u-boot.elf

Copy it on you home

Open a other terminal session and connect you with telnet on localhost 4444.

user@youhost:~$ telnet localhost 4444
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
>

When you obtain the above prompt, inject a valid u-boot and write it on the NAND.

reset;sheevaplug_init;load_image u-boot.elf;resume 0x00600000

Now you can see Uboot starting to run "screen /dev/ttyUSB0 115200" you are ready to start restoring your plug.

Reference Documents: https://newit.co.uk/forum/index.php?topic=2835.0;wap2

Notes

I don't provide any image, because my images don't respect default OpenWrt configuration. I have totally made my own thing, via the amazing OpenWrt SDK. It's still an OpenWrt, but it's ready out of the box for my own personal usage. Here is what I have done:

 Compile natively the entire GNU Core Utilities, and not install busybox
 Compile natively NTPD
 Compile natively SSHD and not install dropbear
 Compile natively Asterisk 11 - chan_sscp-b (for Cisco support)
 Compile natively DJBDNS and not dnsmasq then not install dhcp server thing
 Compile natively StrongSwan an IPSEC thing
 Not install Luci
 Inject all my default config files, via the ./script/env and ./file/ directory

doc/howtobuild/sheevaplug.txt · Last modified: 2015/02/03 20:18 by tmomas