Making Picostation m2HP work

Aleksandr Rybalko ray at ddteam.net
Mon Jul 29 12:19:27 UTC 2013


On Sun, 28 Jul 2013 11:51:09 -0700
hiren panchasara <hiren.panchasara at gmail.com> wrote:

> On Fri, Jul 19, 2013 at 12:41 PM, Adrian Chadd <adrian at freebsd.org> wrote:
> > So here's the fun bit:
> >
> > mtdparts=mtdparts=ar7240-nor0:256k(u-boot),64k(u-boot-env),1024k(kernel),5760k(rootfs),256k(cfg),64k(EEPROM)
> >
> > Now, strictly speaking, you don't _have_ to obey the kernel/rootfs
> > split. But the default 'boot' line executes a boot image from the
> > offset in flash where 'kernel' is.
> >
> > What I tend to do, if I can:
> >
> > * leave uboot and uboot-env where they are
> > * kernel is the first partition, good, so start it there but make it
> > 1.5mb so you have a chance in hell of fitting an lzma'ed uboot kernel
> > image in there
> > * you don't need a 256kb cfg partition, only 64k
> > * the last 64k (EEPROM) _MUST NEVER BE OVERWRITTEN_ as it contains the
> > calibration/config data for the wifi chip.
> >
> > So look at an existing hints file with the 'map' entries, and write up
> > a new set of map entries for the agreed flash layout.
> >
> > Once you've done that, post it here for sanity checking.
> Here is the hints file I am using:
> 
> # mtdparts=ar7240-nor0:256k(u-boot),64k(u-boot-env),1024k(kernel),6528k(rootfs),256k(cfg),64k(EEPROM)
> 
> hint.map.0.at="flash/spi0"
> hint.map.0.start=0x00000000
> hint.map.0.end=0x00040000       # 256k u-boot
> hint.map.0.name="u-boot"
> hint.map.0.readonly=1
> 
> hint.map.1.at="flash/spi0"
> hint.map.1.start=0x00040000
> hint.map.1.end=0x00050000       # 64k u-boot-env
> hint.map.1.name="u-boot-env"
> hint.map.1.readonly=1
> 
> hint.map.2.at="flash/spi0"
> hint.map.2.start=0x00050000
> hint.map.2.end=0x00150000       # 1024k kernel
> hint.map.2.name="kernel"
> hint.map.2.readonly=1
> 
> hint.map.3.at="flash/spi0"
> hint.map.3.start=0x00150000
> hint.map.3.end=0x006f0000       # 6528k rootfs
> hint.map.3.name="rootfs"
> hint.map.3.readonly=0
> 
> hint.map.4.at="flash/spi0"
> hint.map.4.start=0x006f0000
> hint.map.4.end=0x00730000       # 256k config
> hint.map.4.name="config"
> hint.map.4.readonly=1
> 
> hint.map.5.at="flash/spi0"
> hint.map.5.start=0x00730000
> hint.map.5.end=0x00740000       # 64k EEPROM
> hint.map.5.name="art"
> hint.map.5.readonly=1

Looks like you have mistake somewhere. Sum of mtd sizes give us 8M, but
last block you define end on 0x00740000, but must be 0x00800000

# 256k(u-boot)
start=0x00000000
  end=0x00040000
# 64k(u-boot-env)
start=0x00040000
  end=0x00050000
# 1024k(kernel)
start=0x00050000
  end=0x00150000
# 6528k(rootfs)
start=0x00150000
  end=0x007b0000
# 256k(cfg)
start=0x007b0000
  end=0x007f0000
# 64k(EEPROM)
start=0x007f0000
  end=0x00800000

Also, to not depend on kernel size limit you can back kernel and rootfs
into single image, but align rootfs offset to block size (64k here)
Than you will be able to replace kernel.end and rootfs.start with
"search" value:
hint.map.2.end="search:0x00100000:0x10000:.!/bin/sh"
hint.map.3.start="search:0x00100000:0x10000:.!/bin/sh"

In that case geom_map will search for ".!/bin/sh" ("." is single-char
wildcard) starting at offset 0x00100000 (1MB) with 0x10000 (64k) step
til end of media.

kernel must be packed, but format depend on what is supported by loader.
uboot can be compiled with gzip, bzip2 and lzma support, but every
compressor is optional.

If everything too bad with loader uncompressor, you can use un-gzip
support in out trampoline. Maybe even extend it with embedded lzma which
already in sys/contrib.

> >
> > (Then the next trick will be building a kernel and rootfs image that
> > will fit in those flash partitions.. then you write up a config file
> > for adrian's build scripts that enforce those size limits so you don't
> > generate overly large images, then we do a test erase/flash.)
> 
> Kernel that is being generated is of 3.5M. Need to understand how to
> prepare complete image with your scripts.
> 
> Thanks a lot,
> Hiren
> >
> >
> >
> > -adrian
> >
> > On 19 July 2013 11:13, hiren panchasara <hiren.panchasara at gmail.com> wrote:
> >> On Fri, Jul 19, 2013 at 12:02 AM, Adrian Chadd <adrian at freebsd.org> wrote:
> >>> Cool, so next is populating the MAP device fields in a kernel config
> >>> hints file with the relevant flash offsets.
> >>>
> >>> That way you can setup the rootfs right.
> >> alright!!
> >>>
> >>> What's 'printenv' from uboot show?
> >> ar7240> printenv
> >> bootdelay=1
> >> baudrate=115200
> >> ethaddr=00:15:6d:0d:00:00
> >> mtdids=nor0=ar7240-nor0
> >> partition=nor0,0
> >> mtddevnum=0
> >> mtddevname=u-boot
> >> filesize=10000
> >> fileaddr=81000000
> >> serverip=192.168.1.254
> >> ethact=eth0
> >> mtdparts=mtdparts=ar7240-nor0:256k(u-boot),64k(u-boot-env),1024k(kernel),5760k(rootfs),256k(cfg),64k(EEPROM)
> >> bootcmd=bootm 0x9f050000
> >> bootargs=console=tty0 root=31:03 rootfstype=squashfs init=/init
> >> ipaddr=192.168.1.20
> >> stdin=serial
> >> stdout=serial
> >> stderr=serial
> >>
> >> Environment size: 452/65532 bytes
> >> ar7240>
> >>
> >> Thanks for your help :-)
> >>
> >> cheers,
> >> Hiren
> >>
> >>>
> >>>
> >>> -adrian
> >>>
> >>> On 17 July 2013 16:54, hiren panchasara <hiren.panchasara at gmail.com> wrote:
> >>>> On Tue, Jul 16, 2013 at 6:48 AM, Luiz Otavio O Souza <lists.br at gmail.com> wrote:
> >>>>> On 16 July 2013 00:52, Adrian Chadd <adrian at freebsd.org> wrote:
> >>>>>>
> >>>>>> Right,
> >>>>>>
> >>>>>> you have to get the mdio bus configured up right, then attach arswitch to
> >>>>>> it.
> >>>>>>
> >>>>>> Then you tell arge0/arge1 what PHY it speaks to, via Stefan's mdioproxy
> >>>>>> stuff.
> >>>>>>
> >>>>>> _then_ arge0/arge1 will come up.
> >>>>>>
> >>>>>> Now, as for how you do that - i'd have to re-read the datasheet and
> >>>>>> write some documentation:
> >>>>>>
> >>>>>> * one of them (I think arge0) is directly glued to arswitch with no
> >>>>>> PHY per se - it's hard-programmed with a MIIbus mode (RMGII I think?)
> >>>>>> and 100/full or 1000/full
> >>>>>
> >>>>>
> >>>>> It's usually the arge1 which is dedicated to switch and it's hard-programmed
> >>>>> as 1000/full (even when the switch ports are just 10/100).
> >>>>>
> >>>>> arge0 is the 'WAN' port (using the dedicated PHY 4).
> >>>>>
> >>>>> The MDIO is at arge0 on ar7240 and at arge1 on ar7241.
> >>>>>
> >>>>> [...]
> >>>>>>
> >>>>>>
> >>>>>> I'll follow this up with a post explaining how the miibus, mdiobus,
> >>>>>> mdioproxy stuff and how arswitch is configured. Then I'll braindump
> >>>>>> that into the wiki.
> >>>>>
> >>>>>
> >>>>> Thanks Adrian!
> >>>>>
> >>>>> Stefan also has a nice documentation about how this stuff fits together:
> >>>>>
> >>>>> https://wiki.freebsd.org/StefanBethke/EtherSwitch
> >>>>> http://www.bsdcan.org/2012/schedule/attachments/201_BSDCan-2012-Bethke-Ethernet-Switch-Framework.pdf
> >>>>>
> >>>>
> >>>> Thanks a lot Adrian and Luiz for the explanation.
> >>>>
> >>>> I've built just the kernel with in-tree (-head) kernconf AP91 and
> >>>> hints file from Luiz: http://pastebin.com/Z647yiZh
> >>>>
> >>>> And I am seeing arge0/1 attaching:
> >>>>
> >>>> ar7240> go 80050100
> >>>> ## Starting application at 0x80050100 ...
> >>>> CPU platform: Atheros AR7241 rev 1
> >>>> CPU Frequency=390 MHz
> >>>> CPU DDR Frequency=390 MHz
> >>>> CPU AHB Frequency=195 MHz
> >>>> platform frequency: 390000000
> >>>> CPU reference clock: 5 MHz
> >>>> arguments:
> >>>>   a0 = 00000001
> >>>>   a1 = 81f4fcbc
> >>>>   a2 = 00000010
> >>>>   a3 = fffffffe
> >>>> Cmd line:argv is invalid
> >>>> Environment:
> >>>> envp is invalid
> >>>> Cache info:
> >>>>   picache_stride    = 4096
> >>>>   picache_loopcount = 16
> >>>>   pdcache_stride    = 4096
> >>>>   pdcache_loopcount = 8
> >>>> cpu0: MIPS Technologies processor v116.147
> >>>>   MMU: Standard TLB, 16 entries
> >>>>   L1 i-cache: 4 ways of 512 sets, 32 bytes per line
> >>>>   L1 d-cache: 4 ways of 256 sets, 32 bytes per line
> >>>>   Config1=0x9ee3519e<PerfCount,WatchRegs,MIPS16,EJTAG>
> >>>>   Config3=0x20
> >>>> KDB: debugger backends: ddb
> >>>> KDB: current backend: ddb
> >>>> Copyright (c) 1992-2013 The FreeBSD Project.
> >>>> Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
> >>>>         The Regents of the University of California. All rights reserved.
> >>>> FreeBSD is a registered trademark of The FreeBSD Foundation.
> >>>> FreeBSD 10.0-CURRENT #1 r252757M: Wed Jul 17 16:45:15 PDT 2013
> >>>>     root at flymockour-l7.corp.yahoo.com:/usr/home/hirenp/head/obj/mips.mips/usr/home/hirenp/head/sys/AP91
> >>>> mips
> >>>> gcc version 4.2.1 20070831 patched [FreeBSD]
> >>>> real memory  = 16777216 (16384K bytes)
> >>>> avail memory = 11968512 (11MB)
> >>>> random device not loaded; using insecure entropy
> >>>> nexus0: <MIPS32 root nexus>
> >>>> clock0: <Generic MIPS32 ticker> on nexus0
> >>>> Timecounter "MIPS32" frequency 195000000 Hz quality 800
> >>>> Event timer "MIPS32" frequency 195000000 Hz quality 800
> >>>> argemdio0: <Atheros AR71xx built-in ethernet interface, MDIO
> >>>> controller> at mem 0x1a000000-0x1a000fff on nexus0
> >>>> mdio0: <MDIO> on argemdio0
> >>>> mdioproxy0: <MII/MDIO proxy, MDIO side> on mdio0
> >>>> arswitch0: <Atheros AR7240 Ethernet Switch> on mdio0
> >>>> miibus0: <MII bus> on arswitch0
> >>>> ukphy0: <Generic IEEE 802.3u media interface> PHY 0 on miibus0
> >>>> ukphy0:  none, 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX,
> >>>> 1000baseT-FDX, 1000baseT-FDX-master, auto
> >>>> miibus1: <MII bus> on arswitch0
> >>>> ukphy1: <Generic IEEE 802.3u media interface> PHY 1 on miibus1
> >>>> ukphy1:  none, 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX,
> >>>> 1000baseT-FDX, 1000baseT-FDX-master, auto
> >>>> miibus2: <MII bus> on arswitch0
> >>>> ukphy2: <Generic IEEE 802.3u media interface> PHY 2 on miibus2
> >>>> ukphy2:  none, 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX,
> >>>> 1000baseT-FDX, 1000baseT-FDX-master, auto
> >>>> miibus3: <MII bus> on arswitch0
> >>>> ukphy3: <Generic IEEE 802.3u media interface> PHY 3 on miibus3
> >>>> ukphy3:  none, 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX,
> >>>> 1000baseT-FDX, 1000baseT-FDX-master, auto
> >>>> mdio1: <MDIO> on arswitch0
> >>>> mdioproxy1: <MII/MDIO proxy, MDIO side> on mdio1
> >>>> etherswitch0: <Switch controller> on arswitch0
> >>>> apb0 at irq 4 on nexus0
> >>>> uart0: <16550 or compatible> on apb0
> >>>> uart0: console (115200,n,8,1)
> >>>> pcib0 at irq 0 on nexus0
> >>>> pcib0: found EEPROM at 0x1fff1000 on 0.0.0
> >>>> pcib0: EEPROM firmware: 0x1fff1000 @ 4096 bytes
> >>>> pcib0: device EEPROM 'pcib.0.bus.0.0.0.eeprom_firmware' registered
> >>>> pci0: <PCI bus> on pcib0
> >>>> pci0: <network> at device 0.0 (no driver attached)
> >>>> arge0: <Atheros AR71xx built-in ethernet interface> at mem
> >>>> 0x19000000-0x19000fff irq 2 on nexus0
> >>>> arge0: Overriding MAC from EEPROM
> >>>> miiproxy0: <MII/MDIO proxy, MII side> on arge0
> >>>> miiproxy0: attached to target mdio1
> >>>> arge0: finishing attachment, phymask 0010, proxy set
> >>>> miibus4: <MII bus> on miiproxy0
> >>>> ukphy4: <Generic IEEE 802.3u media interface> PHY 4 on miibus4
> >>>> ukphy4:  none, 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX,
> >>>> 1000baseT-FDX, 1000baseT-FDX-master, auto
> >>>> arge0: Ethernet address: 8e:42:00:5c:3c:04
> >>>> arge1: <Atheros AR71xx built-in ethernet interface> at mem
> >>>> 0x1a000000-0x1a000fff irq 3 on nexus0
> >>>> arge1: finishing attachment, phymask 0000, proxy null
> >>>> arge1: Ethernet address: 8e:42:00:5c:3c:05
> >>>> spi0: <AR71XX SPI> at mem 0x1f000000-0x1f00000f on nexus0
> >>>> spibus0: <spibus bus> on spi0
> >>>> mx25l0: <M25Pxx Flash Family> at cs 0 on spibus0
> >>>> mx25l0: w25q64, sector 65536 bytes, 128 sectors
> >>>> ar71xx_wdog0: <Atheros AR71XX watchdog timer> on nexus0
> >>>> ar71xx_wdog0: Previous reset was due to watchdog timeout
> >>>> Timecounters tick every 1.000 msec
> >>>> arswitch0port1: link state changed to DOWN
> >>>> arswitch0port2: link state changed to DOWN
> >>>> arswitch0port3: link state changed to DOWN
> >>>> arswitch0port4: link state changed to DOWN
> >>>> Trying to mount root from ufs:/dev/map/rootfs.uncompress []...
> >>>> mountroot: waiting for device /dev/map/rootfs.uncompress ...
> >>>> Mounting from ufs:/dev/map/rootfs.uncompress failed with error 19.
> >>>>
> >>>> Loader variables:
> >>>>
> >>>> Manual root filesystem specification:
> >>>>   <fstype>:<device> [options]
> >>>>       Mount <device> using filesystem <fstype>
> >>>>       and with the specified (optional) option list.
> >>>>
> >>>>     eg. ufs:/dev/da0s1a
> >>>>         zfs:tank
> >>>>         cd9660:/dev/acd0 ro
> >>>>           (which is equivalent to: mount -t cd9660 -o ro /dev/acd0 /)
> >>>>
> >>>>   ?               List valid disk boot devices
> >>>>   .               Yield 1 second (for background tasks)
> >>>>   <empty line>    Abort manual input
> _______________________________________________
> freebsd-embedded at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-embedded
> To unsubscribe, send any mail to "freebsd-embedded-unsubscribe at freebsd.org"

Good luck!

WBW
-- 
Aleksandr Rybalko <ray at ddteam.net>


More information about the freebsd-embedded mailing list