More OpenWRT progress and a few more issues resolved.
One of the issues I run into was the microSD cards becoming write protected. Even after removing the cards they were write protected on every other device I tried to connect then too. With full size SD cards there was a small switch to enable write protect but not with the microSD cards. I did read a few tricks like using a microSD to SD card adapter then disabling the write protect and formatting the cards but this did not work for me. Not wanting to run into this issue again I have just replaced the microSD cards with USB memory sticks.
Installing OpenWRT to a MR3020n.
Ok I have reinstalled openWRT a few times now and almost have it down to a fine art. This is not a full walk through but the key steps to get openWRT installed and working with a USB memory device. I did connect a TTL serial cable to the router so I did not have to play around with the networking side of things too much.
- Format the USB drive with the EXT2 file system, under Windows you can use Free EaseUS® Partition Master 9.1.1 Home Edition
- Flash the base image to the router. You can use the web interface to upload the firmware update of if you have a console and the router connected to the web you can use these two commands 
 wget http://downloads.openwrt.org/snapshots/trunk/ar71xx/openwrt-ar71xx-generic-tl-mr3020-v1-squashfs-factory.bin
 mtd -r write *mr3020*.bin firmware
- Now after the router reboots it will have the IP of 192.168.1.1
 before able to SSH to the router you will need to Telnet to it and using the passwd command set a password.
- Configure the network settings. You will need to edit /etc/config/network using vi to match the settings of your network. For me that is just enable DHCP so the settings will look this 
 config interface 'loopback'
 option ifname 'lo'
 option proto 'static' option ipaddr '127.0.0.1'
 option netmask '255.0.0.0'
 config interface 'lan' option ifname 'eth0'
 option type 'bridge'
 option proto 'dhcp'
- Now you need to reboot and reconnect using the new settings. If using the DHCP and you are not sure what IP the router has you can connect to your DHCP server for the lease details. I cheated and just used the serial console.
- Now we need to start installing support for the USB drive and filesystem. We want to install as little as possible until we have the USB driver mounted.
 opkg update
 This will download a list installable packages and needs to be done after every reboot.
 opkg install kmod-usb-storage block-mount kmod-fs-ext4
 This will download a list install the minimum kernel drivers and dependencies.
 
- Now to setup the overlay we need to copy the existing overlay files across. So we need to use the following commands
 mkdir /mnt/usb
 So we have somewhere to mount the drive
 mount -t ext2 /dev/sda1 /mnt/usb -o rw,sync
 To mount the drive
 tar -C /overlay -cvf - . | tar -C /mnt/usb -xf -
 To copy the data across
 Now to update fstab to use the sda1 as the overlay
 vi /etc/config/fstab
 and should look like this
 config mount
 option target /overlay
 option device /dev/sda1
 option fstype ext2
 option options rw,sync option enabled 1
 option enabled_fsck 0
 Now reboot
- If all when well if you df -h you should see that you have gone from just a few KB of free space to a few GB of space. Now we can install anything we want and not have to worry about space. So for most people the first thing to do is install and setup the web interface. Just type the following commands
 opkg updateopkg install luci/etc/init.d/uhttpd enable/etc/init.d/uhttpd start
 Now you should be able to open the web interface of the router.
- To install a webcam (Logitech c270) use the following command
 opkg install kmod-video-core kmod-video-uvc mjpg-streamer
 This will install the uvc camera driver which is supported by many different webcams and it will install mjpg-streamer which will allow you to stream the webcam.
 To get mjpg-streamer start automatically you need to enable the service ether in the web interface or by running
 /etc/init.d/mjpg-streamer enable
 You may also want to edit
 /etc/config/mjpg-streamer
 I found that some resolutions like the default 640x480@5fps showed a lot of JPG corruption so I tried a few other resolutions and found 1280x720 worked nice but ended up settling on 720x350@10fps
 After editing the settings you will need to stop/start/restart the service for the new settings to take effect
 /etc/init.d/mjpg-streamer stop
 /etc/init.d/mjpg-streamer start
 You should be able to view the webcam via
 http://%routerIP%:8080/?action=stream
 http://%routerIP%:8080/?action=snapshot

 
I think it should say "connecting" instead of "connection" lol
ReplyDeleteThanks Randy, The bigger issue I have been struggling with is trying to keep the code snippet formatting. It keeps removing the linefeeds after I post so a multi line code snippet turns into a single line mess.
Delete