New IT forum
25 June 2022, 10:23:56 pm *
Welcome, %1$s. Please login or register.

: PiHub now in stock.
 
Pages: [1]

Author Topic: Bricked my Tonidoplug2 & recovered it - HOWTO  (Read 14723 times)

bigbear59

  • Full Member
  • ***
  • Posts: 118
Bricked my Tonidoplug2 & recovered it - HOWTO
« on: 01 January 2014, 01:45:09 am »

It's better to be Lucky than Good!!

The other day I was looking at Techie2017's Tonidoplug2 page and I saw this entry
Quote
Backup original setup
backup all partitions - not sure how useful this will be but I did it anyways.
 dd if=/dev/mtd0ro of=/mnt/u-boot.mtd0
 dd if=/dev/mtd1ro of=/mnt/u-boot-env.mtd1
 dd if=/dev/mtd2ro of=/mnt/kernel.mtd2
 dd if=/dev/mtd3ro of=/mnt/rootfs.mtd3
So I did it, not sure why, but it saved me later.
If you are reading this & your Tonidoplug2 is working, do the above NOW & store in a safe place(burning to a CD would be good)  :D

Got a new USB to TTL cable (see: TTL Adaptor topic)

I decided to try to load Debian on the SATA drive which had ARCHLinux on it.  I couldn't get the plug to boot from NAND, so like any average idiot, I tried the command "initializeKernelRamdisk" from the u-boot prompt.  That didn't help my problem, so I cut & pasted from the line, well it is amazing what dropping a "0" can do.
Quote
Marvell>> nand erase clean 0x20000  0x600000

NAND erase: device 0 offset 0x20000, size 0x600000
Erasing at 0x600000 -- 100% complete. Cleanmarker written at 0x600000.
OK
Marvell>> nand write.e 0x1200000 0x20000 0x30000

NAND write: device 0 offset 0x20000, size 0x30000

Writing data at 0x4f800 -- 100% complete.
 196608 bytes written: OK
Marvell>> reset
There was a moment of silence for my DEAD plug.  
 :o
No more Blue LED, so I checked if it was actually dead.  I unplugged it for about 20 minutes, it was now cool to the touch.  I plugged it in, still no Blue LED, but it warmed up again.  I attached a Network cable & it's LED flashed, but that was it, no other signs of life.
I thought that was it, no recovery,so left it for the day.
The next day I was Googling and found this page: UART Booting HowTo for Selected Kirkwood Devices

Here is what caught my eye:
Quote
0. What is this and why do it? UART-booting provides a way to test a U-Boot uboot.kwb image before actually flashing to NAND.
It also provides a non-JTAG method of unbricking any compatible device that has a working serial connection.
 It has been tested quite a bit, and it works well for me, but YMMV and there is no warranty, express or implied. Use at your own risk.


Here are my steps to recovery:

On the recovery system, The system that the USB is plugged into --- S T A R T

A precompiled binary of kwboot (built on a 64-bit Ubuntu system) is attached, in a tarball w/ man page.

Entered the following, did not press RETURN, pushed the reset button, waited about 3 seconds & hit RETURN
kwboot-tool# ./kwboot -t -B 115200 /dev/ttyUSB0 -b /backup/u-boot.mtd0 -p
Sending boot message. Please reboot the target...\

Sending boot image...
  0 % [......................................................................]
  0 % [......................................................................]
  1 % [......................................................................]
  1 % [......................................................................]
  2 % [......................................................................]
  2 % [......................................................................]
  3 % [......................................................................]

 96 % [......................................................................]
 97 % [......................................................................]
 97 % [......................................................................]
 98 % [......................................................................]
 99 % [......................................................................]
 99 % [......................................]
[Type Ctrl-\ + c to quit]

         __  __                      _ _
        |  \/  | __ _ _ ____   _____| | |
        | |\/| |/ _` | '__\ \ / / _ \ | |
        | |  | | (_| | |   \ V /  __/ | |
        |_|  |_|\__,_|_|    \_/ \___|_|_|
 _   _     ____              _
| | | |   | __ )  ___   ___ | |_
| | | |___|  _ \ / _ \ / _ \| __|
| |_| |___| |_) | (_) | (_) | |_
 \___/    |____/ \___/ \___/ \__|
 ** MARVELL BOARD: DB-88F6282A-BP LE

U-Boot 1.1.4 (Sep 13 2011 - 13:25:05) Marvell version: 3.4.27
USISH-SMB Ver: topkick1281p2-001-008-20110913-codelathe

U-Boot code: 00600000 -> 0067FFF0  BSS: -> 006D0120

Soc: MV88F1155 Rev 1 (DDR2)
CPU running @ 800Mhz L2 running @ 400Mhz
SysClock = 400Mhz , TClock = 200Mhz

DRAM unknown CAL  tRP = 8 tRAS = 20 tRCD=8
DRAM CS[0] base 0x00000000   size 512MB
DRAM Total size 512MB  16bit width
Addresses 8M - 0M are saved for the U-Boot usage.
Mem malloc Initialization (8M - 7M): Done
NAND:512 MB
*** Warning - bad CRC or NAND, using default environment

Flash:  0 kB

CPU : Marvell Feroceon (Rev 1)

Streaming disabled
Write allocate disabled


USB 0: host mode
PEX 0: interface detected no Link.
Net:   egiga0 [PRIME]
Hit any key to stop autoboot:  0

NAND read: device 0 offset 0x200000, size 0x600000

Reading data from 0x7ff800 -- 100% complete.
 6291456 bytes read: OK

NAND read: device 0 offset 0x800000, size 0x1000000

Reading data from 0x17ff800 -- 100% complete.
 16777216 bytes read: OK
** Booting image at 01200000 ...
Bad Magic Number
Saving Environment to NAND...
Erasing Nand...Writing to Nand... done


Flashing Blue LED, after boot Flashing red LED
IT'S A LIVE!!!
 

setenv mtdpartitions 'mtdparts=nand_mtd:[email protected](u-boot),[email protected](u-boot-env),[email protected](uImage),[email protected](rootfs)'
setenv bootargs_usb 'root=/dev/sdb1 rw rootdelay=10'

    see Booting TonidoPlug 2 from an External USB Disk with an Internal SATA Disk Installed
setenv bootargs_sata 'root=/dev/sda1 rw rootdelay=10'
setenv bootargs_nand 'ubi.mtd=3 root=ubi0:rootfs rootfstype=ubifs rootdelay=10'
setenv bootcmd 'run bootcmd_usb; run bootcmd_sata; run bootcmd_nand'
setenv bootargs_console 'console=ttyS0,115200;version=topkick1281p2-001-008-20110913-codelathe'
setenv bootcmd_usb 'setenv bootargs $(bootargs_console) $(mtdpartitions) $(bootargs_usb); usb start;  ext2load usb 0 0x800000 /boot/uImage; bootm 0x800000'
setenv bootcmd_sata 'setenv bootargs $(bootargs_console) $(mtdpartitions) $(bootargs_sata); ide reset;  ext2load ide 0:1 0x800000 /boot/uImage; bootm 0x800000'
setenv bootcmd_nand 'setenv bootargs $(bootargs_console) $(mtdpartitions) $(bootargs_nand); nand read.e 0x1200000 0x200000 0x600000;bootm 0x1200000'
saveenv

Saving Environment to NAND...
Erasing Nand...Writing to Nand... done


run bootcmd_usb
 To boot from USB, see: Booting a TonidoPlug from an External USB or Internal SATA Drive


(Re)start USB...
USB:   scanning bus for devices... 2 USB Device(s) found
Waiting for storage device(s) to settle before scanning...
1 Storage Device(s) found
....
...

3121472 bytes read
** Booting image at 00800000 ...
   Image Name:   Linux-2.6.31.8-topkick1281p2-001
   Created:      2011-11-10   3:58:11 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    3121408 Bytes =  3 MB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
OK

Starting kernel ...

Uncompressing Linux... done, booting the kernel.
Linux version 2.6.31.8-topkick1281p2-001-004-20101214 ([email protected]) (gcc version 3.4.4 (release) (CodeSourcery ARM 2005q3-2)) #2 Thu Nov 10 11:58:07 CST 2011
CPU: Feroceon 88FR131 [56251311] revision 1 (ARMv5TE), cr=00053977


TonidoPlug2 login:
root
Password:
nosoup4u
Linux TonidoPlug2 2.6.31.8-topkick1281p2-001-004-20101214 #2 Thu Nov 10 11:58:07 CST 2011 armv5tel




On the recovery system, The system that the USB is plugged into --- E N D


On the Tonidoplug2

apt-get update
apt-get install uboot-envtools
apt-get install ubi-tools


ubiattach /dev/ubi_ctrl -m 0

Gives an error
If we don't fix this error the plug will brick again
[   86.537482] UBI: attaching mtd0 to ubi0
[   86.537500] UBI: physical eraseblock size:   131072 bytes (128 KiB)
[   86.537513] UBI: logical eraseblock size:    129024 bytes
[   86.537523] UBI: smallest flash I/O unit:    2048
[   86.537533] UBI: sub-page size:              512
[   86.537544] UBI: VID header offset:          512 (aligned 512)
[   86.537556] UBI: data offset:                2048
[   86.539454] UBI: max. sequence number:       0
[   86.539471] UBI error: ubi_read_volume_table: the layout volume was not found


cd /usr/local/bin
wget http://www.tonido.com/downloads/plug2/flash_eraseall
wget http://www.tonido.com/downloads/plug2/nandwrite

OR  
http://git.infradead.org/mtd-utils.git?a=tree


Download uImage & rootfs:
http://www.tonido.com/downloads/plug2/

Index of /downloads/plug2

[ICO]   Name   Last modified   Size   Description
[DIR]   Parent Directory        -   
[   ]   flash_eraseall   19-Feb-2012 20:29    34K   
[   ]   nandwrite   19-Feb-2012 20:29    25K   
[   ]   rootfs.tar.gz   29-Aug-2011 18:40   109M   
[   ]   u-boot-1.1.4-topkick1281p2-codelathe-20110913.tar.bz2   22-Jan-2013 09:09   6.6M   
[   ]   uImage   19-Feb-2012 20:23   3.0M   

So to fix the UBI errors we do the following:

flash_eraseall /dev/mtd0
nandwrite -p /dev/mtd0 u-boot.mtd0

flash_eraseall /dev/mtd1
nandwrite -p /dev/mtd1 u-boot-env.mtd1

flash_eraseall /dev/mtd2
nandwrite -p /dev/mtd2 uImage

ubiformat /dev/mtd3 -e 0
ubiattach /dev/ubi_ctrl -m 3
ubimkvol /dev/ubi0 -m -N rootfs
mount -t ubifs ubi0:rootfs /mnt
cd /mnt
tar xzvf /backup/rootfs.tar.gz

OR don't do the last 6 lines & you could try a flash_eraseall /dev/mtd3; nandwrite -p /dev/mtd3 rootfs.mtd3 to get back to your original system

cat /proc/mtd

dev:    size   erasesize  name
mtd0: 00180000 00020000 "u-boot"
mtd1: 00020000 00020000 "u-boot-env"
mtd2: 00600000 00020000 "uImage"
mtd3: 1f800000 00020000 "rootfs"

Create the fw_env.config file
vi  /etc/fw_env.config

# Configuration file for fw_(printenv/saveenv) utility.
# Up to two entries are valid, in this case the redundant
# environment sector is assumed present.
# Notice, that the "Number of sectors" is ignored on NOR.

# MTD device name       Device offset   Env. size       Flash sector size       Number of sectors
/dev/mtd1               0x0000          0x20000         0x20000

If you want to set all the u-boot variables to default, cut & paste the following:
Code: [Select]
fw_setenv baudrate '115200'
fw_setenv loads_echo '0'
fw_setenv ipaddr '192.168.58.21'
fw_setenv serverip '192.168.58.135'
fw_setenv rootpath '/mnt/ARM_FS/'
fw_setenv netmask '255.255.255.0'
fw_setenv run_diag 'yes'
fw_setenv console 'console=ttyS0,115200 mtdparts=nand_mtd:[email protected](uboot)ro,[email protected](root)'
fw_setenv CASset 'min'
fw_setenv ethprime 'egiga0'
fw_setenv bootargs_root 'root=/dev/nfs rw'
fw_setenv bootargs_end ':::DB88FXX81:eth0:none'
fw_setenv image_name 'uImage'
fw_setenv standalone 'fsload 0x2000000 $(image_name);setenv bootargs $(console) root=/dev/mtdblock0 rw ip=$(ipaddr):$(serverip)$(bootargs_end) $(mvPhoneCon                                                         fig); bootm 0x2000000;'
fw_setenv ethmtu '1500'
fw_setenv mvPhoneConfig 'mv_phone_config=dev0:fxs,dev1:fxs'
fw_setenv mvNetConfig 'mv_net_config=(00:11:88:0f:62:81,0:1:2:3),mtu=1500'
fw_setenv usb0Mode 'host'
fw_setenv yuk_ethaddr '00:00:00:EE:51:81'
fw_setenv nandEcc '1bit'
fw_setenv netretry 'no'
fw_setenv rcvrip '169.254.100.100'
fw_setenv loadaddr '0x02000000'
fw_setenv autoload 'no'
fw_setenv ethact 'egiga0'
fw_setenv initializeKernelRamdisk 'nand erase clean 0x200000 0x600000; nand write.e 0x1200000 0x200000 0x300000; nand erase clean 0x800000 0x1000000; nand                                                          write.e 0x1800000 0x800000 0x800000'
fw_setenv initializeUSB 'usb start; fatload usb 0 0x1200000 uImage-topkick1281p2-001-003-20101103; fatload usb 0 0x1800000 cpio-initrd-topkick1281p2-v1.0.9                                                         .gz'
fw_setenv filesize '74A0A8'
fw_setenv mtdpartitions 'mtdparts=nand_mtd:[email protected](u-boot),[email protected](u-boot-env),[email protected](uImage),[email protected](rootfs)'
fw_setenv bootargs_console 'console=ttyS0,115200;version=topkick1281p2-001-006-20101103'
fw_setenv bootargs_usb 'root=/dev/sdb1 rw rootdelay=10'
fw_setenv bootcmd_usb 'setenv bootargs $(bootargs_console) $(mtdpartitions) $(bootargs_usb); usb start;  ext2load usb 0 0x800000 /boot/uImage; bootm 0x8000                                                         00'
fw_setenv bootargs_sata 'root=/dev/sda1 rw rootdelay=10'
fw_setenv bootcmd_sata 'setenv bootargs $(bootargs_console) $(mtdpartitions) $(bootargs_sata); ide reset;  ext2load ide 0:1 0x800000 /boot/uImage; bootm 0x                                                         800000'
fw_setenv bootargs_nand 'ubi.mtd=3 root=ubi0:rootfs rootfstype=ubifs rootdelay=10'
fw_setenv bootcmd_nand 'setenv bootargs $(bootargs_console) $(mtdpartitions) $(bootargs_nand); nand read.e 0x1200000 0x200000 0x600000;bootm 0x1200000'
fw_setenv bootcmd 'run bootcmd_usb; run bootcmd_sata; run bootcmd_nand'
fw_setenv bootargs 'console=ttyS0,115200;version=topkick1281p2-001-006-20101103 mtdparts=nand_mtd:[email protected](u-boot),[email protected](u-boot-env),[email protected]                                                         0x200000(uImage),[email protected](rootfs) root=/dev/sda1 rw rootdelay=10'
fw_setenv install_mode 'true'
fw_setenv stdin 'serial'
fw_setenv stdout 'serial'
fw_setenv stderr 'serial'
fw_setenv mainlineLinux 'no'
fw_setenv enaMonExt 'no'
fw_setenv enaCpuStream 'no'
fw_setenv enaWrAllo 'no'
fw_setenv pexMode 'RC'
fw_setenv disL2Cache 'no'
fw_setenv setL2CacheWT 'yes'
fw_setenv disL2Prefetch 'yes'
fw_setenv enaICPref 'yes'
fw_setenv enaDCPref 'yes'
fw_setenv sata_dma_mode 'yes'
fw_setenv netbsd_en 'no'
fw_setenv vxworks_en 'no'
fw_setenv bootdelay '3'
fw_setenv disaMvPnp 'no'
fw_setenv enaAutoRecovery 'yes'
fw_setenv pcieTune 'no'

reboot



System should be back from the DEAD & boot from nand, USB or Sata
 ;D

If, in the future, the above files disappear, send me a note & I will post where to find my copies
or if you didn't do the DD backup & need a copy of the u-boot/partition 0
« Last Edit: 01 January 2014, 05:42:25 pm by bigbear59 »
Logged
Cheers,
BigBear59

JeffreyDoujon

  • Newbie
  • *
  • Posts: 2
Re: Bricked my Tonidoplug2 & recovered it - HOWTO
« Reply #1 on: 31 December 2014, 12:37:38 pm »

Hi Bigbear

Is there any chance I can get a copy of your :-
u-boot.mtd0
u-boot-env.mtd1
kernel.mtd2
rootfs.mtd3

Files please, I have done almost exactly what you had done !
also what system did you run kwboot on ? I have tried a live Ubuntu but it will not run

Thanks in advance
Jeff
Logged

bigbear59

  • Full Member
  • ***
  • Posts: 118
Re: Bricked my Tonidoplug2 & recovered it - HOWTO
« Reply #2 on: 02 January 2015, 09:03:34 pm »

As of today the files:
   u-boot.mtd0
   u-boot-env.mtd1
   kernel.mtd2
   rootfs.mtd3

are in a zip file on DROPBOX @ https://www.dropbox.com/s/a859hckifi0q2jj/Backup%20Tonidoplug2.zip?dl=0

Let me know if they disappear

BigBear
Logged
Cheers,
BigBear59

JeffreyDoujon

  • Newbie
  • *
  • Posts: 2
Re: Bricked my Tonidoplug2 & recovered it - HOWTO
« Reply #3 on: 06 January 2015, 09:35:55 am »

Hi Bigbear

Thanks very much for that !

My Tonidoplug is alive again

Again thanks

Jeff
Logged
Pages: [1]
 
 

Powered by MySQL Powered by PHP SMF 2.0.10 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!