Skip to content

Net BootDIR825C1

Sean Bruno edited this page May 22, 2014 · 1 revision

MFSRoot booting for the DLINK DIR825C1 via TFTP

Introduction

Working on this router led me to a process of building a valid image that seems to be useful for netbooting without touching the onboard flash.

The kernel image and mfsroot will exceed 16MB when uncompressed and uboot will error out with lzma compression errors. You'll need to load the image at a higer default memaddress so there is no chance of stomping atop uboot and other bits during the bootup process.

kernel conf and build

  • You'll need to add mfs root options to your kernel configuration and remove the current rootdev entry. I've left the entries I used for this in the DIR-825C1 kernconf

    Boot off of the rootfs, as defined in the geom_map setup.

    options ROOTDEVNAME="ufs:map/rootfs.uncompress"

    In order to netboot, you have to build the mfsroot into the kernel

    #options MD_ROOT # md device usable as a potential root device #options MD_ROOT_SIZE= # ~20Mthing supports #makeoptions MFS_IMAGE=/tftpboot/mfsroot-dir825c1.img.ulzma #options ROOTDEVNAME="ufs:md0.uncompress"

  • once you'e made these changes, you need to remove the ramdisk/fsimage from the dlink build script. Since we're cramming the rootfs into the kernel and not building an image to flash onto the device, we don't want to add it to he final stage of building the image. I haven't thought through how to do this automatically yet. Index: build/bin/build_dlink

    --- build/bin/build_dlink (revision 271) +++ build/bin/build_dlink (working copy) @@ -46,7 +46,6 @@

    ( dd if=/tftpboot/kernel.${KERNCONF}.lzma.uImage bs=1572864 conv=sync;

    • dd if=${X_FSIMAGE}${X_FSIMAGE_SUFFIX} ; echo -n "${X_DLINK_SIGNATURE}" ) > /tftpboot/${CFGNAME}.factory.img
  • Increase the size of the kernel image as specified in the board config file. Our actual kernel image will be pretty big: Index: build/cfg/dir825c1

    --- build/cfg/dir825c1 (revision 271) +++ build/cfg/dir825c1 (working copy) @@ -20,8 +20,8 @@ UBOOT_KERN_STARTADDR="0x80050100"

    Dlink image stuff

    -X_DLINK_MAX_KERN_SIZE=1572864 -X_DLINK_MAX_ROOTFS_SIZE=6553600 +X_DLINK_MAX_KERN_SIZE=15728640 +X_DLINK_MAX_ROOTFS_SIZE=12582912

    This is a required end of image signature for this hardware

    X_DLINK_SIGNATURE=00DB120AR9344-RT-101214-00

  • Build the image, with a different order of operations. We build the fsimage before the kernel now so the buildkernel phase can find the image in our home dir. /path/to/build/bin/build dir825c1 buildworld installworld distribution mfsroot fsimage buildkernel installkernel dlink

  • The netbootable image is now located in /tftpboot on your machine:

  • copy that file to the magically named 0100A8C0.img and now you are ready for your first pass of the Install process below.

Install

  • This process needs a serial console. The serial console for the dlink dir825c1 is 115200, 8n1. This requires soldering pins onto the mainboard, so break out a soldering iron and attach pins.

http://freebsd-wifi-build.googlecode.com/svn/wiki/images/dir825c1_pins.jpg

  • from left to right, Unconnected VCC, TX, RX, Ground

  • Once you can view the serial console of the router, press and hold the reset button on the rear of the device when powered on.

  • Hit ctrl-c to get to the uboot menu. U-Boot 1.1.4 Rev: 322 (Feb 24 2012 - 16:52:02)

    U-boot DB120

    DRAM: 128 MB Top of RAM usable for U-Boot at: 88000000 Reserving 152k for U-Boot at: 87fd8000 Reserving 192k for malloc() at: 87fa8000 Reserving 44 Bytes for Board Info at: 87fa7fd4 Reserving 36 Bytes for Global Data at: 87fa7fb0 Reserving 128k for boot params() at: 87f87fb0 Stack Pointer at: 87f87f98 Now running in RAM - U-Boot at: 87fd8000 id read 0x100000ff flash size 16MB, sector count = 256 Flash: 16 MB Using default environment

    In: serial Out: serial Err: serial Net: ag934x_enet_initialize... Fetching MAC Address from 0x87ff1f38 wasp reset mask:c03300 WASP ----> S17 PHY * : cfg1 0x7 cfg2 0x7114 eth0: 02:20:00:a0:00:01 athrs17_reg_init: complete eth0 up eth0 Hit any key to stop autoboot: 0 Reset Button Push down ! Trying eth0 dup 1 speed 1000 httpd start: DIAGNOSTIC_LED=14

    hostaddr = 0xc0a8 1

    set diagnostic led on ar7240> help ? - alias for 'help' boot - boot default, i.e., run 'bootcmd' bootd - boot default, i.e., run 'bootcmd' bootm - boot application image from memory cp - memory copy erase - erase FLASH memory help - print online help md - memory display mm - memory modify (auto-incrementing) mtest - simple RAM test mw - memory write (fill) nm - memory modify (constant address) ping - send ICMP ECHO_REQUEST to network host printenv- print environment variables progmac - Set ethernet MAC addresses reset - Perform RESET of the CPU run - run commands in an environment variable setenv - set environment variables tftpboot- boot image via network using TFTP protocol version - print monitor version ar7240>

  • setup tftp on your computer and configure it to be ip address 192.168.0.107, the router will pretend to be 192.168.0.1

  • inetd.conf

  • tftp dgram udp wait root /usr/libexec/tftpd tftpd -l -s /tftpboot

  • tftpboot will load the image into ram ar7240> tftpboot 0x84000000 Trying eth0 *** Warning: no boot file name; using '0100A8C0.img' Using eth0 device TFTP from server 192.168.0.107; our IP address is 192.168.0.1 Filename '0100A8C0.img'. Load address: 0x84000000 Loading: ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ########################################################### done Bytes transferred = 6291482 (60001a hex)

  • bootm will boot this image from memory as though it were on flash ar7240> bootm 0x84000000

    Booting image at 84000000 ...

     Image Name:   FreeBSD
     Created:      2014-03-30  18:00:25 UTC
     Image Type:   MIPS Linux Kernel Image (lzma compressed)
     Data Size:    5993491 Bytes =  5.7 MB
     Load Address: 80050000
     Entry Point:  80050100
     Verifying Checksum at 0x84000040 ...OK
     Uncompressing Kernel Image ... OK
    

    No initrd

    Transferring control to Linux (at address 80050100) ...

    bootargs 0: console=ttyS0,115200 root=31:03 rootfstype=squashfs,jffs2 init=/sbin/init mtdparts=ath-nor0:128k(u-boot),64k(nvram),1536k(linux),6144k(rootfs),192k(LANG),64k(MAC),64k(ART)...

    bootargs @A7F87FB0: console=ttyS0,115200 root=31:03 rootfstype=squashfs,jffs2 init=/sbin/init mtdparts=ath-nor0:64k(u-boot),64k(nvram),15936k(linux),10048k@0x005e0000(rootfs),192k(LANG),64k(MAC),64k(ART)...

    Giving linux memsize in bytes, 134217728

    Starting kernel ...

    CPU platform: Atheros AR9344 rev 1 CPU Frequency=560 MHz CPU DDR Frequency=480 MHz CPU AHB Frequency=240 MHz platform frequency: 560 MHz CPU reference clock: 40 MHz CPU MDIO clock: 100 MHz arguments: a0 = 00000007 a1 = a7f87fb0 a2 = a7f88480 a3 = 00000010 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 v76.151 MMU: Standard TLB, 32 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=0xbee3519e<PerfCount,WatchRegs,MIPS16,EJTAG> Config3=0x2c20 ar934x_chip_init_gmac: gmac_cfg=0x00000001 ar934x_configure_gmac: ETH_CFG=0x00000001 KDB: debugger backends: ddb KDB: current backend: ddb Copyright (c) 1992-2014 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 11.0-CURRENT #5 r263921M: Sun Mar 30 11:00:17 PDT 2014 [email protected]:/home/sbruno/bsd/obj/mips/mips.mips/home/sbruno/bsd/head/sys/DIR-825C1 mips gcc version 4.2.1 20070831 patched [FreeBSD] real memory = 134217728 (131072K bytes) avail memory = 106004480 (101MB) random device not loaded; using insecure entropy random: <Software, Yarrow> initialized nexus0: clock0: on nexus0 Timecounter "MIPS32" frequency 280000000 Hz quality 800 Event timer "MIPS32" frequency 280000000 Hz quality 800 argemdio0: <Atheros AR71xx built-in ethernet interface, MDIO controller> at mem 0x19000000-0x19000fff on nexus0 mdio0: on argemdio0 mdioproxy0: <MII/MDIO proxy, MDIO side> on mdio0 arswitch0: on mdio0 miibus0: 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: 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: 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: 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 miibus4: on arswitch0 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 etherswitch0: on arswitch0 mdio1: on arswitch0 mdioproxy1: <MII/MDIO proxy, MDIO side> on mdio1 apb0 at irq 4 on nexus0 uart0: <16550 or compatible> at mem 0x18020003-0x1802001a irq 3 on apb0 uart0: console (115200,n,8,1) gpio0: at mem 0x18040000-0x18040fff irq 2 on apb0 gpio0: [GIANT-LOCKED] gpio0: gpio pinmask=0x0 gpioc0: on gpio0 gpiobus0: on gpio0 ehci0: <AR71XX Integrated USB 2.0 controller> at mem 0x1b000100-0x1b0010ff irq 1 on nexus0 usbus0: set host controller mode usbus0: EHCI version 1.0 usbus0: set host controller mode usbus0 on ehci0 pcib0 at irq 0 on nexus0 pcib0: found EEPROM at 0x1fff4000 on 0.0.0 pcib0: EEPROM firmware: 0x1fff4000 @ 16384 bytes pcib0: device EEPROM 'pcib.0.bus.0.0.0.eeprom_firmware' registered pci0: on pcib0 ath1: at device 0.0 on pci0 ath1: ath_pci_attach: EEPROM firmware @ 0xc085b000 ar9300_set_stub_functions: setting stub functions ar9300_set_stub_functions: setting stub functions ar9300_attach: calling ar9300_hw_attach ar9300_hw_attach: calling ar9300_eeprom_attach ar9300_flash_map: unimplemented for now Restoring Cal data from DRAM ar9300_hw_attach: ar9300_eeprom_attach returned 0 ath1: RX status length: 48 ath1: RX buffer size: 4096 ath1: TX descriptor length: 128 ath1: TX status length: 36 ath1: TX buffers per descriptor: 4 ar9300_freebsd_setup_x_tx_desc: called, 0x0/0, 0x0/0, 0x0/0 ath1: ath_edma_setup_rxfifo: type=0, FIFO depth = 16 entries ath1: ath_edma_setup_rxfifo: type=1, FIFO depth = 128 entries ath1: [HT] enabling HT modes ath1: [HT] enabling short-GI in 20MHz mode ath1: [HT] 1 stream STBC receive enabled ath1: [HT] 1 stream STBC transmit enabled ath1: [HT] 2 RX streams; 2 TX streams ath1: AR9380 mac 448.3 RF5110 phy 1218.15 ath1: 2GHz radio: 0x0000; 5GHz radio: 0x0000 arge0: at mem 0x19000000-0x19000fff irq 2 on nexus0 arge0: arge_fetch_pll_config: pll_1000 = 0x6000000 arge0: arge_attach: overriding MII mode to 'RGMII' arge0: finishing attachment, phymask 0000, proxy null arge0: Ethernet address: 62:73:64:57:30:4c arge1: at mem 0x1a000000-0x1a000fff irq 3 on nexus0 arge1: No PHY specified, using mask 15 arge1: finishing attachment, phymask 000f, proxy null arge1: unable to attach PHY 0: 6 device_attach: arge1 attach returned 6 ath0: Vendor=0x168c, Device=0x0031 ath0: Vendor=0x168c, Device=0x0031 ath0: at mem 0x18100000-0x1811ffff irq 0 on nexus0 ath0: eeprom @ 0x1fff0000 (16384 bytes) ath0: eeprom data @ 0xbfff0000 ar9300_set_stub_functions: setting stub functions ar9300_set_stub_functions: setting stub functions Bootstrap clock 40MHz Enterprise mode: 0x00000000 ar9300_attach: calling ar9300_hw_attach ar9300_hw_attach: calling ar9300_eeprom_attach ar9300_flash_map: unimplemented for now Restoring Cal data from DRAM ar9300_hw_attach: ar9300_eeprom_attach returned 0 ath0: RX status length: 48 ath0: RX buffer size: 4096 ath0: TX descriptor length: 128 ath0: TX status length: 36 ath0: TX buffers per descriptor: 4 ar9300_freebsd_setup_x_tx_desc: called, 0x0/0, 0x0/0, 0x0/0 ath0: ath_edma_setup_rxfifo: type=0, FIFO depth = 16 entries ath0: ath_edma_setup_rxfifo: type=1, FIFO depth = 128 entries ath0: [HT] enabling HT modes ath0: [HT] enabling short-GI in 20MHz mode ath0: [HT] 1 stream STBC receive enabled ath0: [HT] 1 stream STBC transmit enabled ath0: [HT] 2 RX streams; 2 TX streams ath0: AR9340 mac 768.1 RF5110 phy 332.2 ath0: 2GHz radio: 0x0000; 5GHz radio: 0x0000 spi0: at mem 0x1f000000-0x1f00000f on nexus0 spibus0: on spi0 mx25l0: at cs 0 on spibus0 mx25l0: mx25ll128, sector 65536 bytes, 256 sectors ar71xx_wdog0: on nexus0 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 arswitch0port5: link state changed to DOWN usbus0: 480Mbps High Speed USB v2.0 ugen0.1: at usbus0 uhub0: <Atheros EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus0 md0.uncompress: GEOM_ULZMA image found md0.uncompress: 297 x 65536 blocks random: unblocking device. Root mount waiting for: usbus0 uhub0: 1 port with 1 removable, self powered Trying to mount root from ufs:/dev/md0 []... Mounting from ufs:/dev/md0 failed with error 22. Trying to mount root from ufs:md0.uncompress []... warning: no time-of-day clock registered, system time will not be set accurately Mar 30 17:59:57 init: login_getclass: unknown class 'daemon' arswitch0: arswitch_miipollstat: port 3: port -> UP arswitch0port4: link state changed to UP *** Populating /var .. *** Loading configuration files .. *** Restoring from /dev/map/cfg .. dd: /dev/map/cfg: No such file or directory gunzip: (stdin): unexpected end of file 0 blocks *** Completed. *** setting up hostname *** Load kernel modules kldload: can't load bridgestp: module already loaded or in kernel kldload: can't load if_bridge: No such file or directory kldload: can't load random: module already loaded or in kernel *** bringing up loopback .. *** Starting networking via /etc/rc.d/base/net dev.ath.0.txq_mcastq_maxdepth: 512 -> 32 dev.ath.1.txq_mcastq_maxdepth: 512 -> 32 *** Interface: arge0: start *** Interface: arge0: done *** Interface: bridge0: start bridge0: Ethernet address: d6:f9:11:a8:0d:f3 arge0: promiscuous mode enabled bridge0: link state changed to UP *** Interface: bridge0: done *** Default password/login databases .. *** inetd *** Done!

    FreeBSD/mips (freebsd-wifi-build) (ttyu0)

    login:

Clone this wiki locally