Quantcast
Channel: Linux Device Hacking
Viewing all articles
Browse latest Browse all 3247

HowTo: OpenWrt on Kirkwood boxes (2 replies)

$
0
0
How to install OpenWrt on Kirkwood boxes

This thread is a new version of one started by joerg_999 since I did run into a few problems with that one and I wanted to suggest a way which seems slightly easier to me and is also more general, since it is not restricted to Pogo E02. Also, I believe Jörg's post is missing a crucial step in connection with bodhi's uBoot. But, a big "Thank you!" goes to Jörg for his original post.

The procedure described in this thread is confirmed to work for Dockstar, GoFlexNet, and Pogo E02, so I am confident it will also work for the other boxes OpenWrt/LEDE provides images for ;-)

Assumptions

I assume that the box in question has the latest uBoot and is able to boot a USB device with the latest kernel and rootfs according to the first two links in section Kirkwood plugs of the wiki.

Remark: The procedure described below also seems to work with older uBoots in connection with older kernels and rootfs, which I tested with a GoFlexNet.

However, it will be absolutely necessary to be able to reach the box via netconsole or serial console.

The plan

We now want to install OpenWrt (LEDE is now OpenWrt again ...) on our box. The steps we will need to take are
  1. Boot into debian and do some modifications to the uBoot environment variables
  2. Download, rename and copy to a FAT32 USB drive an OpenWrt Image
  3. Reboot the box without a USB device but with netconsole to interact with it <- this is crucial
  4. Use netconsole to boot from the USB drive created before
  5. SSH into OpenWrt/LEDE and make sure the uBoot environment is found <- this is crucial
  6. Install to NAND via sysupgrade OpenWrt/LEDE
  7. Enjoy!

Implementation
So, let us look at these steps in more detail.

1. Modify uBoot variables

First, we need to boot the box to debian, log in and then do the following:
fw_setenv mtdparts 'mtdparts=orion_nand:0x100000@0x0(u-boot),-@0x100000(ubi)'
fw_setenv partition 'nand0,0'
fw_setenv set_bootargs_lede 'setenv bootargs console=ttyS0,115200 $mtdparts'
fw_setenv bootcmd_lede 'run set_bootargs_lede; ubi part ubi; ubi read 0x800000 kernel; bootm 0x800000'

All the other variables can stay the way they were before, but we have to add the OpenWrt/LEDE boot option to the bootcmd. If we still have bodhi's environment variables as they came, this would be:
fw_setenv bootcmd 'run bootcmd_uenv; run scan_disk; run set_bootargs; run bootcmd_exec; run bootcmd_lede'

The important part is to add 'run bootcmd_lede' to the bootcmd you are currently using. So, if you changed something, e.g. to be able to boot with a separate boot partition or from SATA or anything like that, just append the OpenWrt/LEDE boot option to the one you are using.

2. Download an OpenWrt/LEDE image

Next, we need the appropriate image. Start on the release page of OpenWrt and choose the one you like best and then navigate to
targets/kirkwood/generic
Then, download the uImage appropriate for your box. Rename it to uImage and place it in the root of a FAT32 formatted USD device.

Hint: It makes sense to keep the browser tab open for the final step 6.

3. Reboot to NAND with (net)console

Then, we need to reboot the box without the debian USB device, but with a way of interacting with it, preferably via netconsole. The latter needs to be started on the server beforehand with
nc -l -u -p 6666
Wait until after a few error messages you see the prompt, e.g.
Dockstar>
in the console window.

4. Reboot with OpenWrt/LEDE image

Insert the drive you created in step 2 into the box and boot it by issuing the following command at the (net)console prompt:
usb reset; fatload usb 0 0x800000 uImage; bootm 0x800000
This should end with
Starting kernel ...
in the console output, meaning that OpenWrt/LEDE is now running in RAM.

5. Log in to OpenWrt/LEDE

Find the IP address of your box and ssh into it (user root without password). The following step is absolutely crucial (according to bodhi; see the first reply) in connection with bodhi's environment from the uBoot post, as I can tell from experience, since without it, I ran into problems when I first tried the procedure from Jörgs original post on a Dockstar (see my description there of how to remedy the issue if things have gone awry).

Generate or modify /etc/fw_env.config
Check whether the file /etc/fw_env.config has the following contents:
# MTD device name       Device offset   Env. size       Flash sector size       Number of sectors
/dev/mtd0 0xc0000 0x20000 0x20000
If not, modify it accordingly (e.g., using vim, which is available in OpenWrt/LEDE). If the file does not exist at all, the easiest way to generate it is
echo '/dev/mtd0 0xc0000 0x20000 0x20000' > /etc/fw_envs.config
(which you can also do after removing the original file, if you would rather not fiddle around with vim ...)

Afterwards, check that the uBoot environment is found by printing the variables to screen using
fw_printenv

6. Install to NAND

Finally, we can perform a sysupgrade of OpenWrt/LEDE either using the WIF (Web Interface) or the command line. Since we are already logged in via ssh, I only describe the latter option, while the former may be found, e.g., in step 4.b of Jörg's original post. We must do:
opkg update
opkg install ca-bundle ca-certificates libustream-openssl ubi-utils
cd /tmp
wget <URL of our desired sysupgrade file>
sysupgrade <name of our desired sysupgrade file>
The desired upgrade file may be found the same way as we found the image in step 2 above starting from the release page (but, ideally, you kept the browser tab open in step 2). There you can just copy the link address to the sysupgrade file (tar or bin depending on the release) and paste it into the ssh window.

The upgrade process will result in an automatic reboot (during which I removed the USB stick, but that may not be necessary).

7. Enjoy

Viewing all articles
Browse latest Browse all 3247

Trending Articles