Wednesday, February 11, 2015

OpenWRT on Pogoplug Mobile

Booting OpenWRT from internal flash on Pogoplug Mobile

In this tutorial we're replacing the original Pogoplug OS on the internal flash with OpenWRT. OpenWRT is a lightweight but feature rich Linux distribution for embedded devices. 


The Pogoplug is arguably one of the best OpenWRT platform for the price and performance. You can use OpenWRT on the Pogoplug as your main Linux distro skipping the need for a USB flash drive or SD Card, or just use it as a Rescue System (for fixing corrupt disk or reinstallation) if something goes wrong with your ALARM or Debian installation.


This tutorial assumes you have completed my previous tutorial - Hacking the Pogoplug v4 (Series 4 and Mobile) with Linux (Debian or Arch) - and already running Debian or ArchLinuxARM (from a USB drive or SD Card) on the Pogoplug Mobile.


Note that for the Series 4, the USB3 ports does not work properly yet with OpenWRT. Hopefully this will get resolved in the near future. [Edit] - Looks like the USB3 ports work with USB3 devices and if you plug in a USB3 device, the other USB3 port will work with a USB2 device.


WARNING: There is no going back to the Pogoplug OS. You will not be able to use the my.pogoplug.com service. Please proceed at your own risk.


LETS GET STARTED:

Boot up Debian or ArchLinuxARM on your Pogoplug. All commands below assumes you're running Debian or ALARM.

#Update mtdparts so we have one continuous partition to work with.
cd /tmp
wget http://download.qnology.com/pogoplug/v4/fw_setenv
chmod +x fw_setenv

#setup fw_env.config
echo "/dev/mtd0 0xc0000 0x20000 0x20000">/etc/fw_env.config

#1MB for the uBoot, the rest for rootfs (~122MB)
/tmp/fw_setenv mtdparts 'mtdparts=orion_nand:1M(u-boot),-(rootfs)'



#This reboot is important
reboot

After rebooting double check the mtdpart is correct.

cat /proc/mtd

#root@debian:~# cat /proc/mtd
#dev: size erasesize name
#mtd0: 00100000 00020000 "u-boot"
#mtd1: 07f00000 00020000 "rootfs"
#mtd2: 00010000 00008000 "spi0.0"


#download firmware/nand utilities
cd /tmp
wget http://download.qnology.com/pogoplug/v4/fw_printenv
wget http://download.qnology.com/pogoplug/v4/fw_setenv
wget http://download.qnology.com/pogoplug/v4/ubiattach
wget http://download.qnology.com/pogoplug/v4/ubimkvol
wget http://download.qnology.com/pogoplug/v4/ubiformat

#make executable
chmod +x fw_printenv fw_setenv ubiattach ubimkvol ubiformat   

#format mtd1 (rootfs)
#Will be prompted for confirmation three times.
/tmp/ubiformat /dev/mtd1

/tmp/ubiattach -p /dev/mtd1
/tmp/ubimkvol /dev/ubi0 -m -N rootfs

#mount ubi rootfs to /tmp/ubi
mkdir /tmp/ubi
mount -t ubifs ubi0:rootfs /tmp/ubi

#Chaos Calmer 15.05
cd /tmp
wget http://downloads.openwrt.org/chaos_calmer/15.05/kirkwood/generic/openwrt-15.05-kirkwood-generic-rootfs.tar.gz
wget http://downloads.openwrt.org/chaos_calmer/15.05/kirkwood/generic/openwrt-15.05-kirkwood-zImage   
wget http://downloads.openwrt.org/chaos_calmer/15.05/kirkwood/generic/md5sums

#Trunk release.
#Note that Barrier Breaker 14.07 doesn't work.
#cd /tmp
#wget http://downloads.openwrt.org/snapshots/trunk/kirkwood/generic/openwrt-kirkwood-generic-rootfs.tar.gz
#wget http://downloads.openwrt.org/snapshots/trunk/kirkwood/generic/openwrt-kirkwood-zImage
#wget http://downloads.openwrt.org/snapshots/trunk/kirkwood/generic/md5sums


#check that zImage and rootfs.tar.gz are OK
md5sum -c md5sums

#extract rootfs.tar.gz to ubi rootfs at 
/tmp/ubi
cd /tmp/ubi
tar xvzf /tmp/openwrt*rootfs.tar.gz

mkdir boot
mv /tmp/openwrt*kirkwood-zImage ./boot/zImage

#FDT from http://forum.doozan.com/read.php?2,12096
cd boot

wget http://download.qnology.com/pogoplug/v4/kirkwood-pogoplug_v4.dtb

sync
cd /

umount /tmp/ubi


#Setup uBoot Environment

#Cut and Paste this whole section
/tmp/fw_setenv fdt_file '/boot/kirkwood-pogoplug_v4.dtb'
/tmp/fw_setenv loadaddr '0x800000'
/tmp/fw_setenv zimage '/boot/zImage'
/tmp/fw_setenv fdt_addr '0x1c00000'
/tmp/fw_setenv loadubi 'echo Trying to boot from NAND ...;if run mountubi; then run loadubizimage;run loadubifdt;ubifsumount;run bootzubi;fi'
/tmp/fw_setenv mountubi 'ubi part rootfs; ubifsmount ubi0:rootfs'
/tmp/fw_setenv loadubizimage 'ubifsload ${loadaddr} ${zimage}'
/tmp/fw_setenv loadubifdt 'ubifsload ${fdt_addr} ${fdt_file}'
/tmp/fw_setenv bootzubi 'echo Booting from nand ...; run setargsubi; bootz ${loadaddr} - ${fdt_addr};'
/tmp/fw_setenv setargsubi 'setenv bootargs console=${console},${baudrate} ${optargs} ubi.mtd=1 root=ubi0:rootfs rw rootfstype=ubifs rootwait ${mtdparts}'

#Setup boot order.
#USB->SD->SATA->UBI/NAND
/tmp/fw_setenv bootcmd 'run bootcmd_usb; run bootcmd_mmc; run bootcmd_sata; run loadubi; reset'

#poweroff Pogoplug and remove SD Card and USB flash drive.
poweroff

At this point, we're ready to boot into OpenWRT. Note that by default, OpenWRT will default to 192.168.1.1 and will act as a DHCP Server. Plug a network cable from your computer directly into the Pogoplug and power it on. You should now be able to Telnet into the Pogoplug at 192.168.1.1 (username and password not required). Note that SSH is disabled and will automatically start after a root password is set.

#####Initial Boot via Telnet######
#set passwd and enable ssh
passwd

#Reconfigure Network to DHCP Client

#disable dhcp server on lan
uci set dhcp.lan.ignore=1
uci commit dhcp
/etc/init.d/dnsmasq restart

#set wired ethernet interface to dhcp client
uci set network.lan.proto=dhcp
uci commit network
reboot


Plug the Pogoplug and your computer back into your network. Check your router for the IP Address assigned to your Pogoplug. You should now be able to SSH into the Pogoplug.

Note that since we're using the daily snapshot trunk build of OpenWRT, you'll need to install your kernel packages right away (kmod-xxx), otherwise it will get out of sync.



#####Initial OpenWRT configuration#####
opkg update

#Install some essential packages
opkg install nano wget luci uboot-envtools pciutils usbutils 
kmod-usb2 kmod-usb3 kmod-mmc kmod-usb-storage block-mount kmod-fs-ext4 kmod-fs-vfat kmod-fs-ntfs kmod-nls-cp437 kmod-nls-iso8859-1 e2fsprogs fdisk 

#SAMBA - configure via luci web gui
opkg install samba36-server samba36-client luci-app-samba



Major credit goes to @moonman on the ArchLinuxArm Forum - http://archlinuxarm.org/forum/viewtopic.php?f=30&t=8383

42 comments :

  1. Would this also work on Pogoplug E02?

    ReplyDelete
    Replies
    1. No. This tutorial is designed specifically for the Pogoplug V4. I'll publish a OpenWRT on E02 tutorial in the future there is interest.

      Delete
    2. Yeah, that would be great. Thanks!

      Delete
    3. Qui, any plans to release a guide similar to this for the E02 soon? I purchased a E02 a while back, and it's been laying in my storage collecting dust. I'm now wanting to install OpenWRT on it, but there aren't any comprehensive guides available. I tried (http://blog.loetzimmer.de/2012/12/openwrt-auf-pogoplug.html), but many of the commands aren't found, such as mtdparts & fw_setenv. Thanks, and much appreciated.

      Delete
    4. I'll work on this in the near future. Currently the uBoot for the E02 is in a little bit of a flux. My preference is Jeff's uBoot, but it's a little outdated and the archlinuxarm uBoot has some issues.

      Delete
    5. Hello Qui, did you ever get a chance to work on the tutorial for the Pogoplug E02?
      Seems like there is definitely some interest for it.
      Thank!

      Delete
    6. Bumping to request a tutorial on the Pogoplug E02 or the Seagate Dockstar. I'm curious to see if the OpenVPN performance is better than my consumer grade routers running OpenWRT since these two appear to have faster CPUs.

      Delete
    7. Since had already done the mods to boot Debian off a USB drive, I was able to install the relevant OpenWRT files from http://downloads.openwrt.org/chaos_calmer/15.05/kirkwood/generic/ using the instructions at the end of http://wiki.openwrt.org/doc/howto/dockstar_sandbox

      The Pogoplug boots up with the Ethernet port as a DHCP client and you can add USB Ethernet and WiFi interfaces if desired.

      Delete
  2. thankyou, this works perfectly with Chaos Calmer RC2

    ReplyDelete
    Replies
    1. Thank you for letting me know. Once CC is final, I'll give it a test and update the tutorial as appropriate.

      Delete
  3. Did you try an USB wireless adapter? I cannot get any of mine to work. Never have wlan0.

    ReplyDelete
    Replies
    1. Yes, I've successfully used the RT5730 USB Wireless Adapter. From my other blog - http://blog.qnology.com/2015/04/openwrt-on-pogoplug-v3oxnas-proclassic.html

      #Pogoplug has 128MB flash
      #No need to be stingy on the packages
      opkg install nano wget luci uboot-envtools pciutils usbutils htop wireless-tools kmod-rt2x00-pci kmod-usb-storage block-mount kmod-fs-ext4 kmod-fs-vfat kmod-fs-ntfs kmod-nls-cp437 kmod-nls-iso8859-1 e2fsprogs fdisk kmod-usb2 samba36-server samba36-client luci-app-samba kmod-rtl8187 wireless-tools kmod-usb-net-asix-ax88179 kmod-rt2800-lib kmod-rt2800-usb kmod-rt2x00-lib kmod-rt2x00-usb kmod-usb-serial-pl2303 kmod-usb-serial-cp210x kmod-usb-serial-ftdi picocom screen

      #Assume you're using the USB RT5370 Wi-Fi below
      #Regenerate Wi-Fi configuration
      #Verify if Wi-Fi is working properly
      rm -f /etc/config/wireless
      wifi detect > /etc/config/wireless

      #If wireless is working properly, you should see something
      cat /etc/config/wireless

      Delete
    2. Thanks, I was almost there but need the extra packages. My PCUSBW1150 USB Wireless Adapter needed kmod-rtl8192cu to work. Now my Pogoplug is an AP for my network. I'm working on making eth0 (WAN) and wlan0 (br-lan) . I have a TL-WR841N V9 with OpenWRT so the Pogoplug will be a great learning tool.

      This is a great tutorial on make the pogoplug v4 and wireless router!

      Thanks again,

      Delete
  4. learnt today that running mtd -r erase rootfs is not a good idea

    ReplyDelete
  5. With a dockstar booting to pogoplug original nand, I successfully followed your guide for installing debian to usb, changing file names as necessary.

    Now I'd like to install openWrt to nand on the dockstar following this guide. My flash layout looks as follows.

    cat /proc/mtd
    dev: size erasesize name
    mtd0: 00200000 00020000 "u-boot"
    mtd1: 00300000 00020000 "uImage"
    mtd2: 00300000 00020000 "uImage2"
    mtd3: 00800000 00020000 "failsafe"
    mtd4: 07000000 00020000 "root"
    mtd5: 00010000 00008000 "spi0.0"

    What do I do to use this guide to install to nand (changing openWrt filenames to "kirkwood-dockstar" as needed?

    ReplyDelete
  6. Hi,Thank you first.
    I was stuck at
    #poweroff Pogoplug and remove SD Card and USB flash drive.
    poweroff
    when i powed off ,Pluged a network cable from my computer directly into the Pogoplug and powed on. I saw my computer ip was 169.254.184.226 , i was used mac and turned the wifi off, i don't konw telnet what ip.
    If you know,please help me. Thank you for you time.

    ReplyDelete
    Replies
    1. Hi Yang, I'm having the exact same problem. I diagnosed with serial console and it looks that cannot connect to ubi0:rootfs and hangs. I'll post later the exact error message since I was not able to capture the console output yet. Is it possible that the current trunk of OpenWRT could have introduced incompatibilities? (Since these instructions are way back from earlier 2015). Maybe somebody has stored the old trunk version that worked.

      Delete
    2. Sorry for the late reply.

      Try setting a static IP Address on your computer. Something like 192.168.1.10 and then try telneting into the Pogoplug at 192.168.1.1.

      Delete
  7. Though the problem not resolved after i did it as you said, but thank you for your reply.

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. I broke my nand installation of openWrt 15.05 that I had made following these instruction (from a debian SD). I decided to replace it with trunk. I followed these instructions three times, but each time it failed with this:
    [ 1.450182] UBI: background thread "ubi_bgt0d" started, PID 778
    [ 1.456509] VFS: Cannot open root device "ubi0:rootfs" or unknown-block(31,1): error -2
    [ 1.464500] Please append a correct "root=" boot option; here are the available partitions:
    [ 1.472836] 1f00 1024 mtdblock0 (driver?)
    [ 1.477873] 1f01 130048 mtdblock1 (driver?)
    [ 1.482923] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,1)
    [ 1.491236] ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,1)
    I was able to install CC 15.05 again. Any idea why the trunk installation would have failed?

    ReplyDelete
  10. Great tutorial! Is there a way to boot openwrt sd card or hard drive? I tried booting from sd card with the openwrt rootfs and uImage and I tried to get bootz working with the openwrt zImage but it just will not start. Thanks for the help!

    ReplyDelete
    Replies
    1. I'm sure it's possible, but it's not something I care to do or research.

      Delete
  11. Thanks for this tutorial - I was trying to setup openwrt on my zyxel nsa320 for couple of days and it really was so easy. The only difference was different dtb file.
    Last thing - can you paste your uboot config - my is so messed up that I don't even know where to start fixing it ;)

    ReplyDelete
  12. Wow that's a wonderfull blog having all details & helpful. Saa Power Cord

    ReplyDelete
  13. This comment has been removed by the author.

    ReplyDelete
  14. Hi,

    Just updated the uboot to 2016.05 U-Boot Kirkwood
    Anyone has experience with installing OpenWRT onto the PogoPlug E02's nand flash or external USB?

    I've tried to follow this instructin, by replacing the rootfs, zImage and dtb file using the Pogoplug E02's one,
    it seems to boot fine but I can't get access to the box either via dhcp or static ip.
    Here's the boot log:

    Trying to boot from NAND ...
    invalid partition number 2 for device nand0 (orion_nand)
    no such partition
    ubi0: attaching mtd1
    ubi0: scanning is finished
    ubi0: attached mtd1 (name "mtd=1", size 127 MiB)
    ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 129024 bytes
    ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 512
    ubi0: VID header offset: 512 (aligned 512), data offset: 2048
    ubi0: good PEBs: 1014, bad PEBs: 2, corrupted PEBs: 0
    ubi0: user volume: 1, internal volumes: 1, max. volumes count: 128
    ubi0: max/mean erase counter: 3/1, WL threshold: 4096, image sequence number: 1535965568
    ubi0: available PEBs: 0, total reserved PEBs: 1014, PEBs reserved for bad PEB handling: 18
    Loading file '/boot/zImage' to addr 0x00800000...
    Done
    Loading file '/boot/openwrt-15.05-kirkwood-pogo_e02.dtb' to addr 0x01c00000...
    Done
    Unmounting UBIFS volume rootfs!
    Booting from nand ...
    Kernel image @ 0x800000 [ 0x000000 - 0x181e40 ]
    ## Flattened Device Tree blob at 01c00000
    Booting using the fdt blob at 0x1c00000


    Starting kernel ...


    Thanks in advance.

    ReplyDelete
    Replies
    1. I'm encountering the same problem. Pogoplug v4 appears to boot from sdcard or USB and using most current Bodhi uBoot and turns green but no access. Not sure which combo to use to get the zImage to work correctly.

      Delete
  15. Downloads links are down ?

    cd /tmp
    wget http://download.qnology.com/pogoplug/v4/fw_printenv
    wget http://download.qnology.com/pogoplug/v4/fw_setenv
    wget http://download.qnology.com/pogoplug/v4/ubiattach
    wget http://download.qnology.com/pogoplug/v4/ubimkvol
    wget http://download.qnology.com/pogoplug/v4/ubiformat

    ReplyDelete
    Replies
    1. Yes seems down, is there a way to get this working again?

      Delete
    2. You guys can get the nand tools here:
      http://forum.doozan.com/read.php?3,27280

      Delete
    3. MeesterWu

      Thanks for the link however

      these are still mising ?
      ubiattach
      ubimkvol
      ubiformat

      Delete
    4. ubiattach
      ubimkvol
      ubiformat

      you should do a `apt-get update; apt-get install mtd-utils` to get those tools and run `fw_setenv` as is without the `/tmp/` path prefix. I just give some magic to three boxes. Using http://downloads.openwrt.org/chaos_calmer/15.05.1/kirkwood/generic/, it works better, less bugs than BB 14 or Reboot 17.

      Delete
  16. Norton.com/setup 01444-390-866.Norton Support Phone Number, Norton 360 Phone Support, Norton Security Phone Number, Norton Helpline ,Norton Tech Support Number, Norton Tech Support, Norton antivirus customer service, support for Norton, Norton toll free number, Norton Tech Support phone number, Norton antivirus tech support phone number ,Norton antivirus tech support number, Norton antivirus technical support number ,Norton technical support number, Norton tech support number, Norton tech support phone number us, Norton tech support telephone number, Norton 360 phone support, Norton 360 telephone number, Norton 360 helpline, Norton 360 support phone number, Norton security phone number ,Norton support phone number ,Norton support phone number us, Norton helpline, Norton helpline phone number . Norton.com/setup 01444-390-866.

    ReplyDelete
  17. Hi, How can I have a rootfs (or "extroot") on an SD card?, I want to do some test without breaking the main root fs. As there is no /overlay partition or squashfs (it seems that ubifs is more like jffs), the usual extroot steps will not work. Thanks in advance.

    ReplyDelete
    Replies
    1. Ok, I think I am near to achieve it but it doesn't work yet... any clues? Help will be really useful! https://gist.github.com/braian87b/7a50f5634b6b39748cf72d42ff7d4476

      Delete
    2. Tried that steps with ext4 and ext3, it doesn't work...
      but at least I can play with the status LEDs (LEDs works on Luci web-ui too)


      echo 0 > /sys/class/leds/status:green:health/brightness
      echo 1 > /sys/class/leds/status:red:fault/brightness
      sleep 1
      echo 0 > /sys/class/leds/status:red:fault/brightness
      sleep 1
      echo 1 > /sys/class/leds/status:green:health/brightness

      Delete
  18. With newer and newer mobile devices out in the market, testing of these devices assume significance as vendors and enterprises look at reducing time-to-market cycles, cost and effort while adhering to the latest standards in the world.SuperSu Apk

    ReplyDelete
  19. Sugar, spice and everything nice! That’s what the blog is about.
    augmented reality advertising

    ReplyDelete
  20. Once the business organizations are convinced about the potential of the technology to benefit the pubic and to earn them profits, the businesses reach an agreement in the technology transfer office.generatore capacitivo alta frequenza

    ReplyDelete