OpenWrt Forum Archive

Topic: TP-Link MR3420v1 16M flash /64M Memory hardware mod with uboot bin

The content of this topic has been archived between 4 Apr 2018 and 5 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

OK, I have some more info, and maybe this will help someone help me.  Wow, has this been hard to sort out.

It appear that MR3220 uses AR9285 WLAN.

The board I have uses AR9281 WLAN.

So it would appear I need to change my standard build for MR3220 to support AR9281 instead of AR9285.

I assumed any AR WLAN card would work ok since they are all supported by ath9k drivers, but I think I am wrong.  That there must be something specific to the MR3220 config that knows what type of WLAN is installed.

Any comments?

#1 is so unreadable that i had to translate it :D
(Formatting post in progress)

• Compile guide
    ∘ Create new user for it - because you will run binaries from unknown source :D
    ∘ Download this half gig tarball, includes toolchain

       http://www.tp-link.com/resources/GPL/mr … 0v1.tar.gz
    ∘ Apply patch below to file mr3420_3220v1/ap99/boot/u-boot/include/configs/ap99.h

       https://gist.github.com/swiftgeek/6128eb9a6c9ad26f9fdf
       Edit it to your needs afterwards (eg. for 8MiB flash change #define FLASH_SIZE)
    ∘ Look into ar7240.h for device/setup specific changes (prompt, autoboot)
    ∘ cd to mr3420_3220v1/build
    ∘ mv Makefile Makefile.bak
    ∘ mv Makefile.ap99 Makefile
    ∘ make BOARD_TYPE=ap99 uboot
        ∘ Image will appear in mr3420_3220v1/images/ap99/
    ∘ Additional cosmetic changes:
        ∘  Compile in the future ! (set date to future so compilation timestamp will show future time)
• Dump guide
    ∘ In case of tplinks save u-boot and art partitions, cat /proc/mtd

dev:    size   erasesize  name

mtd0: 00020000 00010000 "u-boot"

mtd1: 00110600 00010000 "kernel"
mtd2: 002bfa00 00010000 "rootfs"
mtd3: 000a0000 00010000 "rootfs_data"
mtd4: 00010000 00010000 "art"

mtd5: 003d0000 00010000 "firmware"

    ∘ cat /dev/mtd0 > u-boot_orig.img
    ∘ cat /dev/mtd4 > art_orig.img
    ∘ check sizes with du (128KiB, 64KiB)
• Merge guide
    ∘ Since generated uboot image isn't round 131072 bytes - but has to be not bigger than 127KiB (do not attempt to continue if bigger) - append 0xFF to the end of space dedicated for binary (or instead of using dump, type in values manually like in post #1)
 Read about notrunc
    ∘ First remove original u-boot (0xFF it!)
       

dd if=/dev/zero bs=127K count=1 | tr '\000' '\377' | dd of=u-boot_16MiB.img conv=notrunc

    ∘ Then insert new u-boot (the binary that you have compiled, from mr3420_3220v1/images/ap99/)
       

dd if=u-boot_16MiB.bin of=u-boot_16MiB.img conv=notrunc


    ∘ Make sure that model/mac/pin prevailed!
        ∘  vim :%!xxd
• Flash guide
    ∘ flashrom layout preparation
        ∘ grep mtd name (like art) from dmesg

[    0.840000] 0x0000003f0000-0x000000400000 : "art"

        ∘ Or even grep like this:


# dmesg | grep \" | grep 0x
[    0.770000] 0x000000000000-0x000000020000 : "u-boot"
[    0.780000] 0x000000020000-0x000000130600 : "kernel"
[    0.800000] 0x000000130600-0x0000003f0000 : "rootfs"
[    0.830000] 0x000000350000-0x0000003f0000 : "rootfs_data"
[    0.840000] 0x0000003f0000-0x000000400000 : "art"
[    0.840000] 0x000000020000-0x0000003f0000 : "firmware"
 

Basically copy and paste starting points of partitions and "calculate" (size of dumps in bytes in hex -1 + starting point) endings as both addresses are included
            • For  4MiB (because why would you want more with programmer being so slow?), save as file eg. TODO
               

00000000:0001ffff u-boot

0003f000:0003fffff art

            • For 16MiB


00000000:0001ffff u-boot

00ff0000:00ffffff art

    ∘ arduino serprog as example programmer for everyone
        ∘ http://flashrom.org/Serprog/Arduino_flasher
        ∘ Prepare image of whole flash (even if you are only flashing one partitiion)

dd if=/dev/zero bs=16777216 count=1 | tr '\000' '\377' | dd of=total.img conv=notrunc
dd if=./u-boot_16MiB.img of=total.img conv=notrunc
dd if=./art_orig.img of=total.img conv=notrunc obs=16320k seek=1

        ∘ Either use buffers to get right voltage levels or power whole duino board from 3v3 (like eg. nanino) and connect flash directly

flashrom -p serprog:dev=/dev/ttyUSB0:2000000  -l nor-16MiB.layout -i art -i u-boot -w total.img

    ∘ the rest from uboot tftp method (or if something goes wrong and u-boot still woks)
        ∘ tftpgui is fastest to run/setup on linux desktop, but do not forget about disabling firewall/adding rules in firewall for it
        ∘ https://github.com/pepe2k/u-boot_mod#us … ftp-server
            • Only typing "tpl" string is needed - no need for pressing enter after it to break from autoboot
            • Mind correct offsets and sizes (eg. 3420v1 bootloader + config has 128KiB - 0x2000). Size is provided as result of tftpboot command. U-boot offsets are using ¿physical address space - not address space of mtd device!
            • Go first with tftpboot to get line:


"Bytes transferred = 3932160 (3c0000 hex)"


              just for double checking size for flash/erase
    ∘ Other ways than uboot¿?
        ∘ kermit is too slow (theretical max of ?14KiB/s)
         http://blackfin.uclinux.org/doku.php?id … ding_files

Varia:
ART partition can differ (very) slightly from board to board - same hwrev! (at least on hwrev1.2 of mr3420)

Autoboot with escape (ar7240.h)

#define CONFIG_AUTOBOOT_STOP_STR "\x1b"
#define CONFIG_AUTOBOOT_PROMPT   "Hit ESC key to stop autoboot: %d\n"

u-boot mod is not explicitly needed as long as you copy art partition properly - it will boot stock images just fine. You just won't be able to access anything past 4MiB from u-boot

(Last edited by swiftgeek on 19 Mar 2015, 08:48)

The discussion might have continued from here.