26
septembre
2007
Fonera+ et le firmware Fon
posté dans Embarqué |
OpenWrt est un projet OpenSource dont beaucoup, sinon la plupart des éléments sont sous GPL. Les modifications apportées aux codes GPL par Fon doivent donc être rediffusées si le binaire l'est. Fon a donc mis à disposition les sources du firmware. Comme c'est souvent le cas, la documentation concernant les modifications apportées et la marche à suivre est pauvre, voir inexistante.
Voici quelques éléments spécifiques au firmware Fon pour La Fonera+ :
- Utilisation d'un bootloader stage2 Meraki : Redboot ne charge pas directement le noyau Linux mais un second bootloader (stage2) qui charge une image du système en mémoire :
Failsafe loader v0.2 Looking for board config data... found at offset 0xa87f0000 Reset button GPIO: 6 Reading flash from 0xa8040000 to 0xa81fe30a... done. Verifying CRC... OK - 0xc0d3c841
- L'image du système stockée en Flash n'est pas une image jffs2 mais une concaténation d'une somme de contrôle, du kernel compressé lzma et du système de fichier. L'image est produite avec un script Perl appelé
fonimage.pl. Celui-ci nécessite la présence du moduleDigest::CRC
- Le système de fichiers utilisé est squashfs.
- Les sources du firmware livrées par Fon utilisent un profile de plateforme différent d'atheros-2.6 : fonera-2.6. L'entrée dans le répertoire
target/linuxest un lien symbolique. Fon souhaiterait-il intégrer la Fonera comme plateforme dans le projet OpenWrt ? Ce répertoire contient les patchs, les pilotes, les Makefiles et les scripts permettant de produire une image à flasher sur la Fonera+. C'est donc là qu'il faut toucher pour obtenir un firmware Fon jffs2 sans Meraki. Cet essai a été fait mais la prise en charge de l'interface réseau bloque le boot tout comme l'intégration du pilote dans Kamikaze 7.07.
- Le firmware Fon intègre un grand nombre de codes propres au projet. Il s'agit, pour la plupart, de versions modifiées d'outils existant. C'est peut-être là qu'il faut chercher la solution au problème d'interface. Un script initialise ou configure sans doute eth0/eth1.
Board: FON 2201
RAM: 0x80000000-0x81000000, [0x80040290-0x80fe1000] available
FLASH: 0xa8000000 - 0xa87f0000, 128 blocks of 0x00010000 bytes each.
== Executing boot script in 2.000 seconds - enter ^C to abort
RedBoot> fis load -l vmlinux.bin.l7
Image loaded from 0x80041000-0x80285086
RedBoot> exec
Now booting linux kernel:
Base address 0x80030000 Entry 0x80041000
Cmdline :
Linux version 2.6.21.5 (denis@morgane) (gcc version 4.1.2)
#11 Tue Sep 25 15:53:12 CEST 2007
CPU revision is: 00019064
Determined physical RAM map:
memory: 01000000 @ 00000000 (usable)
Initrd not found or empty - disabling initrd
Built 1 zonelists. Total pages: 4064
Kernel command line: console=ttyS0,9600 rootfstype=squashfs,jffs2 init=/etc/preinit
Primary instruction cache 16kB, physically tagged, 4-way, linesize 16 bytes.
Primary data cache 16kB, 4-way, linesize 16 bytes.
Synthesized TLB refill handler (20 instructions).
Synthesized TLB load handler fastpath (32 instructions).
Synthesized TLB store handler fastpath (32 instructions).
Synthesized TLB modify handler fastpath (31 instructions).
PID hash table entries: 64 (order: 6, 256 bytes)
Using 92.000 MHz high precision timer.
Dentry cache hash table entries: 2048 (order: 1, 8192 bytes)
Inode-cache hash table entries: 1024 (order: 0, 4096 bytes)
Memory: 13548k/16384k available (1916k kernel code,
2836k reserved, 287k data, 116k init, 0k highmem)
Mount-cache hash table entries: 512
NET: Registered protocol family 16
Radio config found at offset 0xf8(0x1f8)
Time: MIPS clocksource has been installed.
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
squashfs: version 3.0 (2006/03/15) Phillip Lougher
Registering mini_fo version $Id$
JFFS2 version 2.2. (NAND) (C) 2001-2006 Red Hat, Inc.
io scheduler noop registered
io scheduler deadline registered (default)
Serial: 8250/16550 driver $Revision: 1.90 $ 1 ports, IRQ sharing disabled
serial8250: ttyS0 at MMIO 0xb1100003 (irq = 37) is a 16550A
PHY ID: 0000:0000
eth0: Dropping NETIF_F_SG since no checksum feature.
eth0: Atheros AR231x: 00:18:84:a0:5b:98, irq 4
Initialising Marvell switch...
L'initialisation du switch permettant d'avoir les deux interfaces gèle le kernel. Deux solutions, soit le code est naze (il est déjà brouillon) et inutilisable, soit le bootloader stage2 initialise d'une manière ou d'une autre les interfaces. Un coup d'oeil aux sources du bootloader meraki ne semble pas confirmer cette dernière hypothèse.
Moins amusant encore, si l'on cède à l'envie de restructurer encore la mémoire flash et la configuration de Redboot de manière à utiliser le bootloader stage2 et l'image concaténée, les résultats ne sont pas meilleurs. Il s'agit pourtant de construire le firmware Fon sans toucher à quoi que se soit, une simple compilation standard avec le profile "Developer" proposé. Résultat :
Failsafe loader v0.2 Looking for board config data... found at offset 0xa87f0000 Reset button GPIO: 6 Reading flash from 0xa8040000 to 0xa81fe30a... done. Verifying CRC... OK - 0xc0d3c841 Uncompressing Linux... Ok, booting the kernel. Linux version 2.6.19.2 (denis@morgane) (gcc version 4.1.2) #1 Wed Sep 26 10:38:57 CEST 2007 CPU revision is: 00019064 Determined physical RAM map: memory: 01000000 @ 00000000 (usable) Initrd not found or empty - disabling initrd Built 1 zonelists. Total pages: 4064 Kernel command line: console=ttyS0,9600 rootfstype=squashfs,jffs2 init=/etc/preinit Primary instruction cache 16kB, physically tagged, 4-way, linesize 16 bytes. Primary data cache 16kB, 4-way, linesize 16 bytes. Synthesized TLB refill handler (20 instructions). Synthesized TLB load handler fastpath (32 instructions). Synthesized TLB store handler fastpath (32 instructions). Synthesized TLB modify handler fastpath (31 instructions). PID hash table entries: 64 (order: 6, 256 bytes) Using 92.000 MHz high precision timer. Dentry cache hash table entries: 2048 (order: 1, 8192 bytes) Inode-cache hash table entries: 1024 (order: 0, 4096 bytes) Memory: 13500k/16384k available (1972k kernel code, 2884k reserved, 287k data, 112k init, 0k highmem) Mount-cache hash table entries: 512 Checking for 'wait' instruction... available. 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:01.0 PCI: Failed to allocate mem resource #1:4000000@84000000 for 0000:00:02.0 PCI: Failed to allocate mem resource #1:4000000@84000000 for 0000:00:03.0 PCI: Failed to allocate mem resource #2:400000@81400000 for 0000:00:03.0 NET: Registered protocol family 2 IP route cache hash table entries: 128 (order: -3, 512 bytes) TCP established hash table entries: 512 (order: -1, 2048 bytes) TCP bind hash table entries: 256 (order: -2, 1024 bytes) TCP: Hash tables configured (established 512 bind 256) TCP reno registered squashfs: version 3.0 (2006/03/15) Phillip Lougher Registering mini_fo version $Id$ JFFS2 version 2.2. (NAND) (SUMMARY) (C) 2001-2006 Red Hat, Inc. io scheduler noop registered io scheduler deadline registered (default) Serial: 8250/16550 driver $Revision: 1.90 $ 1 ports, IRQ sharing disabled serial8250: ttyS0 at MMIO 0xb1100003 (irq = 37) is a 16550A PHY ID: 0000:0000 eth0: Dropping NETIF_F_SG since no checksum feature. eth0: Atheros AR231x: 00:18:84:a0:5b:98, irq 4 Initialising Marvell switch... done. 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 8 RedBoot partitions found on MTD device spiflash Creating 8 MTD partitions on "spiflash": 0x00000000-0x00030000 : "RedBoot" 0x00030000-0x00040000 : "loader" 0x00040000-0x007e0000 : "image" 0x000eebe9-0x007d0000 : "rootfs" mtd: partition "rootfs" doesn't start on an erase block boundary -- force read-only 0x00200000-0x007d0000 : "rootfs_data" 0x007d0000-0x007e0000 : "config" 0x007e0000-0x007ef000 : "FIS directory" 0x007ef000-0x007f0000 : "RedBoot config" 0x007f0000-0x00800000 : "board_config" ip_conntrack version 2.4 (128 buckets, 1024 max) - 240 bytes per conntrack ip_tables: (C) 2000-2006 Netfilter Core Team TCP vegas registered NET: Registered protocol family 1 NET: Registered protocol family 17 802.1Q VLAN Support v1.8 Ben Greear All bugs added by David S. Miller Time: MIPS clocksource has been installed. VFS: Mounted root (squashfs filesystem) readonly. Freeing unused kernel memory: 112k freed Warning: unable to open an initial console. Algorithmics/MIPS FPU Emulator v1.5 [sighandler]: No more events to be processed, quitting. [cleanup]: Waiting for children. [cleanup]: All children terminated. Unlocking rootfs ... Could not open mtd device: rootfs /sbin/mount_root: .: 40: Can't open /bin/firstboot init started: BusyBox v1.4.1 (2007-09-26 10:18:29 CEST) multi-call binary Please press Enter to activate this console. : /sbin/hotplug-call: .: 7: Can't open /lib/fon/config.sh : /sbin/hotplug-call: .: 7: Can't open /lib/fon/config.sh PPP generic driver version 2.4.2 tun: Universal TUN/TAP device driver, 1.6 tun: (C) 1999-2004 Max KrasnyanskyIci, l'interface réseau semble fonctionner, au moins elle ne bloque pas le démarrage :: /sbin/hotplug-call: .: 7: Can't open /lib/fon/config.sh : /sbin/hotplug-call: .: 7: Can't open /lib/fon/config.sh xt_CHAOS: Could not find "TARPIT" target IPP2P v0.8.1_rc1 loading IMQ starting with 2 devices... : /sbin/hotplug-call: .: 7: Can't open /lib/fon/config.sh IMQ driver loaded successfully. Hooking IMQ before NAT on PREROUTING. Hooking IMQ after NAT on POSTROUTING. : /sbin/hotplug-call: .: 7: Can't open /lib/fon/config.sh ipt_time loading wlan: 0.8.4.2 (svn r2420) ath_hal: module license 'Proprietary' taints kernel. ath_hal: 0.9.17.1 (AR5212, AR5312, RF5112, RF2316, RF2317, TX_DESC_SWAP) ath_rate_minstrel: 1.2 (svn r2420) Minstrel automatic rate control algorithm. Look around rate set to 10% EWMA rolloff level set to 75% Max Segment size in the mrr set to 6000 us wlan: mac acl policy registered ath_ahb: 0.9.4.5 (svn r2420) ath_pci: switching rfkill capability off ath_pci: ath_pci: switching per-packet transmit power control off wifi0: 11b rates: 1Mbps 2Mbps 5.5Mbps 11Mbps wifi0: 11g rates: 1Mbps 2Mbps 5.5Mbps 11Mbps 6Mbps 9Mbps 12Mbps 18Mbps 24Mbps 36Mbps 48Mbps 54Mbps wifi0: H/W encryption support: WEP AES AES_CCM TKIP wifi0: mac 11.0 phy 4.8 radio 7.0 wifi0: Use hw queue 1 for WME_AC_BE traffic wifi0: Use hw queue 0 for WME_AC_BK traffic wifi0: Use hw queue 2 for WME_AC_VI traffic wifi0: Use hw queue 3 for WME_AC_VO traffic wifi0: Use hw queue 8 for CAB traffic wifi0: Use hw queue 9 for beacons wifi0: Atheros 2315 WiSoC: mem=0xb0000000, irq=3 gpio_proc: module loaded and /proc/gpio/ created : /sbin/hotplug-call: .: 7: Can't open /lib/fon/config.sh : /etc/rc.common: ./base-files: 1: uci: not found : /etc/rc.common: ./base-files: 2: uci: not found : /etc/rc.common: ./base-files: 3: uci: not found : /etc/rc.common: ./base-files: 4: uci: not found : /etc/rc.common: ./base-files: 5: uci: not found : /etc/rc.common: eval: 75: uci: not found : /sbin/wifi: .: 1: Can't open /lib/fon/config.sh : /etc/rc.common: .: 7: Can't open /lib/fon/config.sh : /etc/rc.common: .: 7: Can't open /lib/fon/config.sh : /usr/lib/qos/generate.sh: .: 7: Can't open /lib/fon/config.sh BusyBox v1.4.1 (2007-09-26 10:18:29 CEST) Built-in shell (ash) Enter 'help' for a list of built-in commands. ______ __ /\ ___\ /\ \ \ \ \__/ __ ___ __ _ __ __ \_\ \___ \ \ _\/ __`\ /' _ `\ /'__`\/\`'__\/'__`\ /\___ __\ \ \ \/\ \L\ \/\ \/\ \/\ __/\ \ \//\ \L\.\_ \/__/\ \_/ \ \_\ \____/\ \_\ \_\ \____\\ \_\\ \__/.\_\ \ \_\ \/_/\/___/ \/_/\/_/\/____/ \/_/ \/__/\/_/ \/_/ -------------- Fonera 1.5 Firmware (v1.1.1.1) ----------------- * Based on OpenWrt - http://openwrt.org * Powered by FON - http://www.fon.com ----------------------------------------------------- root@OpenWrt:/#
PHY ID: 0000:0000 eth0: Dropping NETIF_F_SG since no checksum feature. eth0: Atheros AR231x: 00:18:84:a0:5b:98, irq 4 Initialising Marvell switch... done.Cependant, ce n'est qu'une belle illusion :
root@OpenWrt:/# ifconfig eth0 192.168.0.112 root@OpenWrt:/# ping 192.168.0.10 PING 192.168.0.10 (192.168.0.10): 56 data bytes 4 packets transmitted, 0 packets received, 100% packet loss root@OpenWrt:/# arp IP address HW type Flags HW address Mask Device 192.168.0.1 0x1 0x0 00:00:00:00:00:00 * eth0 192.168.0.10 0x1 0x0 00:00:00:00:00:00 * eth0Voilà où j'en suis. Les investigations se poursuivent... PS mise à jour : Je viens de remarquer une chose étrange. Les sources du firmware Fon diponibles sur download.fon.com sont différentes de celle disponible sur download.francofon.fr. En effet, l'archive provenant du site Fon ne semble pas complète. Par exemple, l'absence du fichier
base64.c empêche la compilation le fonrsa. Plus j'avance sur le sujet plus je me dis que Fon comme d'autres ne fait aucun effort : les modifications ne sont pas documentées, le code ajouté est brouillon... il s'agit tout simplement de livrer, brut de fonderie, un tarball de sources... Une bonne impression de "Démerdez-vous avec ça, on fait ce que la GPL nous oblige à faire, pas plus. Ciao".
PS mise à jour encore : MAIS ?! CA MARCHE ! Parfois on cherche quelque part ailleurs ce qui se trouve juste sous nos yeux. Dans le cas présent, il est dit que le switch est supporté. Le switch ? Et oui, il n'y a pas réellement deux interfaces mais une seule (eth0) avec un switch. L'utilisation des deux pseudo-interfaces repose tout simplement sur l'implémentation Linux de VLAN 802.1Q. En regardant de plus près le script d'init boot on remarque un discret vconfig set_name_type DEV_PLUS_VID_NO_PAD. Par ailleurs, les scripts hotplug crées les interfaces eth0.0 (LAN) et eth0.1 (WAN). Du coup, on peut désactiver un gros paquet de scripts (presque tous) pour démarrer un firmware Fon fraîchement compilé et utiliser :
root@(none):/# ifconfig eth0 up root@(none):/# vconfig set_name_type DEV_PLUS_VID_NO_PAD root@(none):/# vconfig add eth0 0 root@(none):/# vconfig add eth0 1 root@(none):/# ifconfig eth0.0 192.168.0.12 root@(none):/# ping 192.168.0.1 PING 192.168.0.1 (192.168.0.1): 56 data bytes 64 bytes from 192.168.0.1: icmp_seq=0 ttl=64 time=11.9 ms 64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=2.3 ms 2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max = 2.3/7.1/11.9 ms root@(none):/# ping 192.168.0.10 PING 192.168.0.10 (192.168.0.10): 56 data bytes 64 bytes from 192.168.0.10: icmp_seq=0 ttl=64 time=4.2 ms 64 bytes from 192.168.0.10: icmp_seq=1 ttl=64 time=3.3 ms 2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max = 3.3/3.7/4.2 ms root@(none):/# arp IP address HW type Flags HW address Mask Device 192.168.0.10 0x1 0x2 00:0D:88:E7:E8:73 * eth0.0 192.168.0.1 0x1 0x2 00:13:8F:26:14:C0 * eth0.0Ça progresse, ça progresse... Prochaine étape, oublier le bootloader stage2 et le squashfs avec le firmware fon. Puis, appliquer les modifications Fon a Kamikaze 7.07.