Friday, April 10, 2015

OpenWRT on Pogoplug v3/Oxnas (Pro/Classic)

This tutorial assumes you have completed my previous tutorial - Hacking the Pogoplug v3/Oxnas (Pro/Classic) with Debian
- and already running Debian from a USB drive on the Pogoplug V3.

OpenWRT will be installed on the internal flash (NAND) of the Pogoplug. You will still be able to boot Debian from USB when attached.

Known Issues:

 - RT3090 (PCIE) Wi-Fi in the Pro is not working. 
All commands below needs to be executed from Debian.

#Verify MTD partition
cat /proc/mtd
#root@debian:~# cat /proc/mtd
#dev: size erasesize name
#mtd0: 00e00000 00020000 "boot"
#mtd1: 07200000 00020000 "data"

#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 (data)
/tmp/ubiformat /dev/mtd1

#attach
/tmp/ubiattach /dev/ubi_ctrl -m 1
/tmp/ubimkvol /dev/ubi0 -m -N rootfs

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

#We're using the snapshot trunk release.

#There is no rootfs tarball, so we'll extract 
#it from the squashfs sysupgrade tar
cd /tmp
wget http://downloads.openwrt.org/snapshots/trunk/oxnas/generic/openwrt-oxnas-pogoplug-pro-squashfs-sysupgrade.tar

#extract
tar -xvf openwrt-oxnas-pogoplug-pro-squashfs-sysupgrade.tar

#unsquashfs
apt-get install squashfs-tools
unsquashfs sysupgrade-pogoplug-pro/root


#move extracted rootfs to ubi
mv squashfs-root/* /tmp/ubi

#download kernel zImage
mkdir -p /tmp/ubi/boot
cd /tmp/ubi/boot
wget http://downloads.openwrt.org/snapshots/trunk/oxnas/generic/openwrt-oxnas-zImage

#rename zImage file
mv openwrt-oxnas-zImage zImage


#download fdt
wget http://downloads.openwrt.org/snapshots/trunk/oxnas/generic/openwrt-oxnas-pogoplug-pro.dtb
wget http://download.qnology.com/pogoplug/oxnas/ox820-pogoplug-classic.dtb


sync
cd /
umount /tmp/ubi

#Setup uBoot Environment
#Cut and Paste this whole section
/tmp/fw_setenv zimage '/boot/zImage'
/tmp/fw_setenv loadaddr '0x60500000'
/tmp/fw_setenv fdt_addr '0x62c00000'
/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 data; ubifsmount ubi0:rootfs'
/tmp/fw_setenv loadubizimage 'ubifsload ${loadaddr} ${zimage}'
/tmp/fw_setenv loadubifdt 'ubifsload ${fdt_addr} ${fdt_file_ubi}'
/tmp/fw_setenv bootzubi 'echo Booting from nand ...; run setargsubi; bootz ${loadaddr} - ${fdt_addr};'
/tmp/fw_setenv setargsubi 'setenv bootargs console=ttyS0,115200n8 ubi.mtd=1 root=ubi0:rootfs rw rootfstype=ubifs rootwait ${mtdparts}'

#Select the appropriate fdt - Pro (Wi-Fi) versus regular.

#Pogoplug Pro
/tmp/fw_setenv fdt_file_ubi '/boot/openwrt-oxnas-pogoplug-pro.dtb'

#Non-Pro (use this if unsure)
/tmp/fw_setenv fdt_file_ubi '/boot/ox820-pogoplug-classic.dtb'

#S
etup boot order.
#USB first, then UBI/NAND
/tmp/fw_setenv dt_bootcmd_usb 'usb start; run dt_usb_bootcmd; usb stop'

/tmp/fw_setenv bootcmd 'run dt_bootcmd_usb; run loadubi; reset'

#poweroff Pogoplug and then remove USB flash drive.
poweroff

OpenWRT Initial Boot via Telnet

At this point, we're ready to boot into OpenWRT. During the bootup process the LED on the Pogoplug will blink. However once it successfully boots into OpenWRT the LED will be completely off.

Note that by default, OpenWRT will default to 192.168.1.1 and will (or should) act as a DHCP Server.  Plug a network cable from your computer directly into the Pogoplug and power it on (do not plug the Pogoplug into your router). You should now be able to Telnet into the Pogoplug at 192.168.1.1 (username and password not required). If you're not able to telnet into the Pogoplug try setting a static IP address of 192.168.1.2 on your computer.

Note that SSH is disabled and will automatically start after a root password is set.

#set passwd and enable ssh
passwd

#Reconfigure Network to DHCP Client
#disable dhcp server on lan
#Ignore if any error.
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
reboot

OpenWRT SSH and Initial Package Installation

Plug the Pogoplug and your computer back into your network/router. 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.

opkg update

#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

#Enable Wi-Fi
sed -i 's^option disabled 1^option disabled 0^' /etc/config/wireless
/etc/init.d/network restart

Note that the built in Wi-Fi (PCIE) on the Pogoplug Pro is not working.

If you need wireless, I would highly recommend a USB Wi-Fi card based on the RT5730 chipset for less than $8.

Mini Wireless 150Mbs USB Ralink RT5370 (or from Ebay)

12 comments :

  1. First of all, THANK YOU so much for this latest entry in your already awesome blog. I'm sure it was just a typo on the blog, but I believe the regenerate wi-fi config should be on 2 lines:
    rm -f /etc/config/wireless
    wifi detect > /etc/config/wireless

    ReplyDelete
  2. Any reason you decided to use the snapshot over the RC?

    http://downloads.openwrt.org/chaos_calmer/15.05-rc2/oxnas/generic/

    ReplyDelete
    Replies
    1. I wrote the tutorial prior to CC RC being released.

      Delete
  3. Hi
    Last time i try re-flash PogoPlug Pro, but received not working LAN
    [ 19.199979] eth0: Could not attach to PHY
    [ 19.203993] stmmac_open: Cannot attach to PHY (error: -16)
    [ 19.212884] stmmac_ethtool_getsettings: eth0: PHY is not registered
    [ 19.219499] device eth0 entered promiscuous mode
    [ 19.228293] IPv6: ADDRCONF(NETDEV_UP): br-lan: link is not ready

    May be any can help me ?

    ReplyDelete
  4. Hi,
    Would it be possible for you to write up a tutorial revert back to Debian or Pogoplug. Silly me, I swapped the command and made uboot to boot from nand first before usb. I try to get back into uboot environment but flash_erase command is not working. Keep getting "not found command". The current guide get you to "Bleeding Edge" and it is in non-operational stage. Luci is not working and the issue has been report in the earlier Bleeding Edge release. I really want to try Chaos Calmer.

    ReplyDelete
    Replies
    1. You should be able to adjust the uboot environment directly from OpenWRT. If you installed the recommended packages above, it should include the "fw_setenv" command. Not sure why you would need "flash_erase" (sounds dangerous).

      Delete
    2. I make all the downloads executeable and ./fw_printev doesn't even work. It is really weird. Anyway, I gave up on that effort. I got the Pogo Pro to boot off SATA. I had to use 2012-05 version. All of the newer version DDoS my network for some reason.

      Any recommendation for guide? I went into to NAND and try to format mtd2 but it says have to detach mtd2. I am clueless on how to detach so i went into mtd2 and delete everything manually. Follow the rest of this guide at

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

      I used the ubifs version instead of the squash since I cannot download squash-tools with the older version of archlinux. I got stuck in boot loop. light blink then stop 20 sec later light blink then stop and repeat. :-) Any recommendation?

      In addition, when running the command ./fw_setenv when booting off SATA. Does that set the environment on NAND or on the SATA drive? It seems the command is not passing to NAND.

      I also tried and update to 2015.10 U-boot and run this guide afterward but no success.

      Delete
    3. The above instructions is meant to be run from Debian. If you're already running it from OpenWRT, the binaries provided in this tutorial will not work.

      The uboot environment variables are stored on the NAND.

      Delete
    4. I got it fixed. A new uboot install from SATA should had fixed it but I had made two mistake. SATA boot assign NAND 'boot' partition as mtd1 instead of 0. I followed to the guide too close. Should used the output from 'cat /proc/mtd' ! In addition, the new uboot is case sensitive with partition label. I have to rename 'ROOTFS' to 'rootfs' and it boot right off usb. Netconsole is not working for some reason.

      Delete
  5. I read your site.This web site keeping an extremely distinctive and interesting information.Thanks for reveal.keep constant. golf gps watch

    ReplyDelete
  6. Hi,

    Unfortunately, the firmware/nand utilities files are not on your server anymore. Could you reupload them? I would love ti install openwrt to my pogoplug as well.

    ReplyDelete