Flash Fonera 2100 with OpenWrt by console port and redboot

De Wiki de Romain RUDIGER
Aller à : navigation, rechercher

Setup

The network setup is very basic:

       ISP-router    <->      PC        <->     FONERA
    192.168.0.254/24     192.168.0.1/24     192.168.0.17/24

Get the console port of the fonera

Open the fonera (two screws under the rubber pads) to get the serial pin-out :

+-------------------+
|GND| . |TXD|RXD| . |
|VCC| . | . | . | . |
+-------------------+
+-----+ +--------+    +---+
|Power| |Ethernet|    |Ant|

The Fonera out a 3.3v signal, so you need to adapt this signal. You can use a max232 integrated circuit or use this simple electronic circuit (source):

RS232 - 3.3v adapter
Fonera 2100 pinout (source).


Here is my setup:

FONERA with the RS232 adapter

setup the tftpd server

With tftpd-hpa tftpd server :

root:/var/lib/tftpboot# /usr/sbin/in.tftpd -s /var/lib/tftpboot -4 -l -a 192.168.0.1
root:/var/lib/tftpboot# netstat -lnp | grep 69
udp        0      0 192.168.0.1:69          0.0.0.0:*            4601/in.tftpd

get the kamikaze version of OpenWRT

root:/var/lib/tftpboot# wget http://downloads.openwrt.org/kamikaze/8.09.2/atheros/openwrt-atheros-vmlinux.lzma 
--2011-02-06 13:03:14--  http://downloads.openwrt.org/kamikaze/8.09.2/atheros/openwrt-atheros-vmlinux.lzma
Résolution de downloads.openwrt.org... 78.24.191.177
Connexion vers downloads.openwrt.org|78.24.191.177|:80...connecté.
requête HTTP transmise, en attente de la réponse...200 OK
Longueur: 786432 (768K) [text/plain]
Sauvegarde en : «openwrt-atheros-vmlinux.lzma»

100%[=====================================>] 786 432      697K/s   ds 1,1s    

2011-02-06 13:03:15 (697 KB/s) - «openwrt-atheros-vmlinux.lzma» sauvegardé [786432/786432]

root:/var/lib/tftpboot# wget http://downloads.openwrt.org/kamikaze/8.09.2/atheros/openwrt-atheros-root.squashfs
--2011-02-06 13:03:21--  http://downloads.openwrt.org/kamikaze/8.09.2/atheros/openwrt-atheros-root.squashfs
Résolution de downloads.openwrt.org... 78.24.191.177
Connexion vers downloads.openwrt.org|78.24.191.177|:80...connecté.
requête HTTP transmise, en attente de la réponse...200 OK
Longueur: 1703936 (1,6M) [text/plain]
Sauvegarde en : «openwrt-atheros-root.squashfs»

100%[=====================================>] 1 703 936   1,33M/s   ds 1,2s    

2011-02-06 13:03:23 (1,33 MB/s) - «openwrt-atheros-root.squashfs» sauvegardé [1703936/1703936]

root:/var/lib/tftpboot# ll -h
total 2,4M
-rw-r--r-- 1 root root 1,7M 29 déc.   2009 openwrt-atheros-root.squashfs
-rw-r--r-- 1 root root 768K 29 déc.   2009 openwrt-atheros-vmlinux.lzma

flash the fonera

+PHY ID is 0022:5521                                                           
Ethernet eth0: MAC address 00:18:84:1e:a7:28                                   
IP: 0.0.0.0/255.255.255.255, Gateway: 0.0.0.0                                  
Default server: 0.0.0.0                                                        
                                                                               
RedBoot(tm) bootstrap and debug environment [ROMRAM]                           
Non-certified release, version v1.3.0 - built 16:57:58, Aug  7 2006            
                                                                               
Copyright (C) 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.                       
                                                                               
Board: ap51                                                                    
RAM: 0x80000000-0x81000000, [0x80040450-0x80fe1000] available                  
FLASH: 0xa8000000 - 0xa87f0000, 128 blocks of 0x00010000 bytes each.           
== Executing boot script in 1.000 seconds - enter ^C to abort                  
^C                                                                             
RedBoot> ip_addr -l 192.168.0.17/24 -h 192.168.0.1                             
IP: 192.168.0.17/255.255.255.0, Gateway: 0.0.0.0                               
Default server: 192.168.0.1                                                    
RedBoot> fis init                                                              
About to initialize [format] FLASH image system - continue (y/n)? y            
*** Initialize FLASH Image System                                              
... Erase from 0xa87e0000-0xa87f0000: .                                        
... Program from 0x80ff0000-0x81000000 at 0xa87e0000: .                                             
RedBoot> lo -r -b %{FREEMEMLO} openwrt-atheros-vmlinux.lzma                    
Using default protocol (TFTP)                                                  
Raw file loaded 0x80040800-0x801007ff, assumed entry at 0x80040800             
RedBoot> fi cr -e 0x80041000 -r 0x80041000 vmlinux.bin.l7                      
... Erase from 0xa8030000-0xa80f0000: ............                             
... Program from 0x80040800-0x80100800 at 0xa8030000: ............             
... Erase from 0xa87e0000-0xa87f0000: .                                        
... Program from 0x80ff0000-0x81000000 at 0xa87e0000: .                        
RedBoot> lo -r -b %{FREEMEMLO} openwrt-atheros-root.squashfs                   
Using default protocol (TFTP)                                                  
Raw file loaded 0x80040800-0x801e07ff, assumed entry at 0x80040800             
RedBoot> fi cr -l 0x6F0000 rootfs                                              
... Erase from 0xa80f0000-0xa87e0000: .........................................
... Program from 0x80040800-0x801e0800 at 0xa80f0000: .........................
... Erase from 0xa87e0000-0xa87f0000: .                                        
... Program from 0x80ff0000-0x81000000 at 0xa87e0000: .

Load and init the kernel:

RedBoot> fis load -l vmlinux.bin.l7                                                                                                                
RedBoot> exec                                                                  
Now booting linux kernel:                                                      
 Base address 0x80030000 Entry 0x80041000                                      
 Cmdline :                                                                     
Linux version 2.6.26.8 (agb@arrakis) (gcc version 4.1.2) #4 Tue Dec 29 14:55:59
CPU revision is: 00019064 (MIPS 4KEc)                                          
Determined physical RAM map:                                                   
 memory: 01000000 @ 00000000 (usable)                                          
Initrd not found or empty - disabling initrd                                   
Zone PFN ranges:                                                               
  Normal          0 ->     4096                                                
Movable zone start PFN for each node                                           
early_node_map[1] active PFN ranges                                            
    0:        0 ->     4096                                                    
Built 1 zonelists in Zone order, mobility grouping off.  Total pages: 4064     
Kernel command line: console=ttyS0,9600 rootfstype=squashfs,jffs2 init=/etc/prt
Primary instruction cache 16kB, VIPT, 4-way, linesize 16 bytes.                
Primary data cache 16kB, 4-way, VIPT, no aliases, linesize 16 bytes            
PID hash table entries: 64 (order: 6, 256 bytes)                               
console [ttyS0] enabled                                                        
Dentry cache hash table entries: 2048 (order: 1, 8192 bytes)                   
Inode-cache hash table entries: 1024 (order: 0, 4096 bytes)                    
Memory: 13548k/16384k available (1898k kernel code, 2836k reserved, 304k data,)
SLUB: Genslabs=6, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1         
Mount-cache hash table entries: 512                                            
net_namespace: 644 bytes                                                       
NET: Registered protocol family 16                                             
Radio config found at offset 0xf8(0x1f8)                                       
AR531x PCI init...                                                             
done                                                                           
PCI: fixing up device 0,3,0                                                    
PCI: Failed to allocate mem resource #1:4000000@84000000 for 0000:00:00.0      
PCI: Failed to allocate mem resource #1:4000000@84000000 for 0000:00:03.0      
NET: Registered protocol family 2                                              
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)                 
TCP established hash table entries: 512 (order: 0, 4096 bytes)                 
TCP bind hash table entries: 512 (order: -1, 2048 bytes)                       
TCP: Hash tables configured (established 512 bind 512)                         
TCP reno registered                                                            
NET: Registered protocol family 1                                              
ar531x: Registering GPIODEV device                                             
squashfs: version 3.0 (2006/03/15) Phillip Lougher                             
Registering mini_fo version $Id$                                               
JFFS2 version 2.2. (NAND) (SUMMARY)  © 2001-2006 Red Hat, Inc.                
msgmni has been set to 26                                                      
io scheduler noop registered                                                   
io scheduler deadline registered (default)                                     
gpiodev: gpio device registered with major 254                                 
gpiodev: gpio platform device registered with access mask FFFFFFFF             
Serial: 8250/16550 driver $Revision: 1.90 $ 1 ports, IRQ sharing disabled      
serial8250: ttyS0 at MMIO 0xb1100003 (irq = 37) is a 16550A                    
eth0: Atheros AR231x: 00:18:84:1e:a7:28, irq 4                                 
ar2313_eth_mii: probed                                                         
eth0: attached PHY driver [Generic PHY] (mii_bus:phy_addr=0:00)                
cmdlinepart partition parsing not available                                    
Searching for RedBoot partition table in spiflash at offset 0x7d0000           
Searching for RedBoot partition table in spiflash at offset 0x7e0000           
6 RedBoot partitions found on MTD device spiflash                              
eth0: Configuring MAC for full duplex                                          
Creating 6 MTD partitions on "spiflash":                                       
0x00000000-0x00030000 : "RedBoot"                                              
0x00030000-0x000f0000 : "vmlinux.bin.l7"                                       
0x000f0000-0x007e0000 : "rootfs"                                               
mtd: partition "rootfs" set to be root filesystem                              
mtd: partition "rootfs_data" created automatically, ofs=270000, len=570000     
0x00270000-0x007e0000 : "rootfs_data"                                          
0x007e0000-0x007ef000 : "FIS directory"                                        
0x007ef000-0x007f0000 : "RedBoot config"                                       
0x007f0000-0x00800000 : "boardconfig"                                          
TCP vegas registered                                                           
NET: Registered protocol family 17                                             
802.1Q VLAN Support v1.8 Ben Greear <greearb@candelatech.com>                  
All bugs added by David S. Miller <davem@redhat.com>                           
VFS: Mounted root (squashfs filesystem) readonly.                              
Freeing unused kernel memory: 124k freed                                       
Please be patient, while OpenWrt loads ...                                     
Algorithmics/MIPS FPU Emulator v1.5                                            
- preinit -                                                                    
Press CTRL-C for failsafe                                                      
jffs2 not ready yet; using ramdisk                                             
mini_fo: using base directory: /                                               
mini_fo: using storage directory: /tmp/root                                    
- init -                                                                       
                                                                               
Please press Enter to activate this console.
device eth0 entered promiscuous me
br-lan: port 1(eth0) entering learning state                                   
br-lan: topology change detected, propagating                                  
br-lan: port 1(eth0) entering forwarding state                                 
PPP generic driver version 2.4.2                                               
ip_tables: (C) 2000-2006 Netfilter Core Team                                   
nf_conntrack version 0.5.0 (1024 buckets, 4096 max)                            
ath_hal: module license 'Proprietary' taints kernel.                           
ath_hal: 2009-05-08 (AR5212, AR5312, RF5111, RF5112, RF2316, RF2317, REGOPS_FU)
ath_ahb: trunk                                                                 
wlan: trunk                                                                    
wlan: mac acl policy registered                                                
ath_rate_minstrel: Minstrel automatic rate control algorithm 1.2 (trunk)       
ath_rate_minstrel: look around rate set to 10%                                 
ath_rate_minstrel: EWMA rolloff level set to 75%                               
ath_rate_minstrel: max segment size in the mrr set to 6000 us                  
Atheros HAL provided by OpenWrt, DD-WRT and MakSat Technologies                
wifi0: 11b rates: 1Mbps 2Mbps 5.5Mbps 11Mbps                                   
wifi0: 11g rates: 1Mbps 2Mbps 5.5Mbps 11Mbps 6Mbps 9Mbps 12Mbps 18Mbps 24Mbps s
wifi0: turboG rates: 6Mbps 12Mbps 18Mbps 24Mbps 36Mbps 48Mbps 54Mbps           
wifi0: H/W encryption support: WEP AES AES_CCM TKIP                            
ath_ahb: wifi0: Atheros 2315 WiSoC: mem=0xb0000000, irq=3                      
jffs2_scan_eraseblock(): End of filesystem marker found at 0x0                 
jffs2_build_filesystem(): unlocking the mtd device... done.                    
jffs2_build_filesystem(): erasing all blocks after the end marker... done.     
mini_fo: using base directory: /                                               
mini_fo: using storage directory: /jffs                                        
                                                                               
                                                                               
                                                                               
BusyBox v1.11.2 (2009-12-02 11:25:47 UTC) built-in shell (ash)                 
Enter 'help' for a list of built-in commands.                                  
                                                                               
  _______                     ________        __                               
 |       |.-----.-----.-----.|  |  |  |.----.|  |_                             
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|                            
 |_______||   __|_____|__|__||________||__|  |____|                            
          |__| W I R E L E S S   F R E E D O M                                 
 KAMIKAZE (8.09.2, r18961) -------------------------                           
  * 10 oz Vodka       Shake well with ice and strain                           
  * 10 oz Triple sec  mixture into 10 shot glasses.                            
  * 10 oz lime juice  Salute!                                                  
 ---------------------------------------------------                           
root@OpenWrt:/#

Configure OpenWrt

Enable SSH from the lan:

root@OpenWrt:/etc/rc.d# vi /etc/init.d/dropbear
start() {                                                                            
        [ -f /etc/dropbear/dropbear_rsa_host_key -a \                                
          -f /etc/dropbear/dropbear_dss_host_key ] || keygen                         
                                                                                     
        config_load dropbear                                                         
        /usr/sbin/dropbear $DROPBEAR_ARGS                                            
        iptables -A input_rule -i eth0 -p tcp  -j ACCEPT                             
}
root@OpenWrt:/etc/rc.d# cd /etc/rc.d/
root@OpenWrt:/etc/rc.d# ln -s ../init.d/dropbear S51dropbear
root@OpenWrt:/etc/rc.d# ./S51dropbear start


Hostname:

root@OpenWrt:/# passwd                                                         
Changing password for root                                                     
New password:                                                                  
Retype password:                                                               
Password for root changed by root
root@OpenWrt:/# uci show system                                                
system.@system[0]=system                                                       
system.@system[0].hostname=OpenWrt                                             
system.@system[0].timezone=UTC                                                 
system.@button[0]=button                                                       
system.@button[0].button=reset                                                 
system.@button[0].action=released                                              
system.@button[0].handler=logger reboot                                        
system.@button[0].min=0                                                        
system.@button[0].max=4                                                        
system.@button[1]=button                                                       
system.@button[1].button=reset                                                 
system.@button[1].action=released                                              
system.@button[1].handler=logger factory default                               
system.@button[1].min=5                                                        
system.@button[1].max=30                                                       
root@OpenWrt:/# uci set system.@system[0].hostname=fonera                      
root@OpenWrt:/# uci commit


Network configuration to get an access point with SNMP:

root@fonera:/etc/rc.d# cat /etc/config/network 
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
        option hostname fonera
root@fonera:/etc/rc.d# cat /etc/config/wireless  
config wifi-device wifi0
        option type atheros
        option channel auto
        option disabled 0

config wifi-iface
        option device   wifi0
        option network  lan
        option mode     ap
        option ssid     novalan-fr
        option encryption psk
        option key private-wifi
root@fonera:/# /etc/init.d/network restart                                     
device eth0 entered promiscuous mode                                           
br-lan: port 1(eth0) entering learning state                                   
br-lan: topology change detected, propagating                                  
br-lan: port 1(eth0) entering forwarding state                                 
device ath0 entered promiscuous mode                                           
br-lan: port 2(ath0) entering learning state                                   
br-lan: topology change detected, propagating                                  
br-lan: port 2(ath0) entering forwarding state                                 
Configuration file: /var/run/hostapd-ath0.conf                                 
Using interface ath0 with hwaddr 00:18:84:1e:a7:29 and ssid 'novalan-fr'     
root@fonera:/# opkg update
root@fonera:/# opkg install snmpd  
root@fonera:/# cd /etc/rc.d/
root@fonera:/etc/rc.d# ln -s ../init.d/snmpd S98snmpd

Links

Fonera by OpenWrt

How to flash the Fonera with kamikaze (FR)