niedziela, 26 maja 2013

custom kernel + rootfs

Custom firmware

 

The current test firmware version supports 16MB ram / 4MB flash units only. Following features are available:

- Based on Linux version 2.6.38.2
- rt2800usb wifi network support (Ralink idVendor=148f, idProduct=3070)
- PixArt cmos usb camera (idVendor=1d0f, idProduct=1801)
- jffs2 writable root filesystem (2MB)
- jffs2 writeble user/data filesystem (~500KB)
- experimental software spi bus + sd/mmc, slow but enough to save camera snapshots, stream mp3 files etc.
- v4l camera interface
- mathopd http server (with cgi support)
- simple login subsystem (users account / passwords)
- inetd
- telnetd
- ftpd
- userspace binary to controll horizontal/vertical stepper motors


The complete camera firmware is divided into 3 images:


  •  linux kernel image

md5sum: d4433c1c74a45650602ef3dfcb86df5a  zImage


  • root filesystem

md5sum: da562a3fc82655ea4d25d4ceadff1865  romjffs2.img


  • user filesystem (empty/pre-allocated fs mounted over /data, useful if you haven't done the sd/mmc mod yet)

md5sum: 4d4fe44522508b09381ddb39ad9a61f8  userfsjffs2.img


Warning: Proceed at your own risk, ONLY if you are 100% sure that you have a valid backup and know how to perform the restore operation. There are many variants of those so-called ipcam/foscam clone cameras and not all are compatible. Also, this firmware is an early test version only, I can NOT be held responsible if something breaks, melts, burns as a result of using it !


So delete existing flash partitions (except the Image 0), setup a DHCP server on your host machine and upload each new image using the following commands:

Kernel image:

ft 1 linux 0x7F020000 0x00008000 -acx

Root fs:

ft 2 root 0x7F170000 0x7F170000 -f

User fs:

ft 3 userfs 0x7F380000 0x7F380000 -f

Instead of using dhcp/tftp "ft" you can use "fx" command and upload via serial cable - it's much slower (helps in case you don't have dhcp/tftp utilities)


When uploading individual images, one should see messages like below:

bootloader > ft 2 root 0x7F170000 0x7F170000 -f
Wait for auto-negotiation complete...
OK
100MB - Full
DHCP DISCOVER...
DHCP REQUEST...
DHCP ACKed...
IP Address. . . . . . . . . . . . : 172.16.72.4
Subnet Mask . . . . . . . . . . . : 255.255.248.0
Default Gateway . . . . . . . . . : 172.16.72.1
Waiting for download ...
TFTP client: 172.16.72.5
Download OK, file size:2097152       

Flash programming ... 
................................


When all files are successfully uploaded, the bootloader image table should look like this:

bootloader > ls
Image: 0 name:BOOT INFO base:0x7F010000 size:0x00000048 exec:0x7F010000 -f
Image: 1 name:linux base:0x7F020000 size:0x0013B358 exec:0x00008000 -acx
Image: 2 name:root base:0x7F170000 size:0x00200000 exec:0x7F170000 -f
Image: 3 name:userfs base:0x7F380000 size:0x00070000 exec:0x7F380000 -f


If that's the case, issue the "boot" command, hopefully after a while on the console the boot messages should be visible:

usb 1-1: new full speed USB device using nuc700-ohci and address 2
usb 1-1: New USB device found, idVendor=1d0f, idProduct=1801
usb 1-1: New USB device strings: Mfr=16, Product=96, SerialNumber=0
usb 1-1: Product: USB2.0_Camera
usb 1-1: Manufacturer: PixArt Imaging Inc.
uvcvideo: Found UVC 1.00 device USB2.0_Camera (1d0f:1801)
VFS: Mounted root (jffs2 filesystem) on device 31:2.
devtmpfs: mounted
Freeing init memory: 76K
input: USB2.0_Camera as /devices/platform/nuc700-ohci/usb1/1-1/1-1:1.0/input/input0
usb 1-2: new full speed USB device using nuc700-ohci and address 3
usb 1-2: New USB device found, idVendor=148f, idProduct=3070
usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-2: Product: 802.11 n WLAN
usb 1-2: Manufacturer: Ralink
usb 1-2: SerialNumber: 1.0
********************************************************
starting userspace: custom_cam  kernel v1.0, rootfs v1.0
news/updates: http://customcam.blogspot.com/
********************************************************


At boot time both eth0 and wlan0 are enabled with these ip parameters:

 / $ ifconfig
eth0      Link encap:Ethernet  HWaddr 00:02:AC:55:88:A8 
          inet addr:172.16.72.111  Bcast:172.16.79.255  Mask:255.255.248.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1 errors:0 dropped:1 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:16
          RX bytes:60 (60.0 B)  TX bytes:0 (0.0 B)

wlan0     Link encap:Ethernet  HWaddr 00:E0:4C:B4:61:01 
          inet addr:172.16.72.112  Bcast:172.16.79.255  Mask:255.255.248.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:397 (397.0 B)  TX bytes:423 (423.0 B)






 The wlan0 interface will try to associate with a wireless network (WPA) sid="wifi1" using password="secret123". All the network init can be adjusted by editing /etc/net.sh and /etc/wpa_supplicant.conf files. Pay attention to the non-standard network mask 255.255.248.0  (heh, yes that's my home setup).


If all went correctly, your camera system can be accesed by:

  • telnet / ftp - there're two initial accounts (root and pwoz, password is 1q2w3e for both users)
  • web browser - default URL: http://172.16.72.112/move.html - a test page to move the camera to a desired direction and get the image snapshot. (it's intended for test only, don't use it too much - every snapshot is saved to jffs filesystem so it might put additional strain on the flash chip)
To control the stepper motors directly, use "/bin/mygpio" binary, for example: "/bin/mygpio -r 10" to move 10 horizontal steps to the right (clockwise direction).
 


2 komentarze:

  1. I'm really impressed of your work , Any chance you provide your source files to this great implementation ? I'd like to add some more features to the kernel/user space
    regards!

    OdpowiedzUsuń
  2. Hi there, it's possible but could be bit complicated, I'd have to tar/zip the whole source tree - if I still mange find it :). Send me your contact email.

    cheers

    OdpowiedzUsuń