Way to recover SPI data without Jtag or external programmer.
==============================================
Warning, we are going to use uboot HUSH cmd parser,
this is a very powerful shell missuses will totally break your box ... use with caution!
Your system wont boot cause data in your SPI flash (macronix) is corrupted, also this problem prevent recovery switch to be read from uboot or sdcard to be read.
Some people are doing short between SPI flash pins, do not do that!!
making short between Serial Out Data (pin 2) and ground could lead your chip dead!!
Please better if you lift pin 1 ( Chip Select ) from board and put toggle switch between solder pad and pin (CS On/Off).
This way you boot with chip disabled and enable just to detect erase and flash.
Note: Use Short cables or noise will be catch !!
You will use a USB2TTL (3v3) console cable (GSM datacable) and terminal sw
baudrate 115200,8,N,1.
Also you will need a binary img with SPI contents, on my system I get one from inside update.zip you can use 2 type of files "uImage_recovery" or "SPI.img" need to be less than 4MB to fit flash.Put file inside a clean SD card formated in FAT32
Steps
====
1) Open CS switch (internal pullup will disable flash and put I/O in Hi Z).
2) Conect TTL console port to terminal program
3) Power on box ( in my case I need SD card inserted to boot )
4) Press any key to interrupt normal boot:
Code:
0x0001e4f1
0x00000fff
RSLR0=00000249 RDGR0=00000055
Stage 00 Result 00000000
Stage 01 Result 00000000
Stage 02 Result 00000000
Systemp Started
0x00000000
sdio read
0x12345678
ucl decompress
decompress finished
ready
U-Boot 2010.06 (Aug 30 2011 - 14:48:38)
DRAM: 256 MiB
NAND: Amlogic nand flash uboot driver for m1, Version 1.0 (
NAND device id: ad d7 94 9a 74 42
NAND device: Manufacturer ID: 0xad, Chip ID: 0xad (Hynix B r7UBG8T2A)
1 NAND chips detected
nand0 initialized ok
SF: Got idcode 00 00 00 [COLOR=Red]//<<- SF not detected (CS=off)[/COLOR]
SF: Unsupported manufacturer 00
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
KGDB: ready
MMC: SDIO Port A: 0
Net: select eth clk-1,source=400000000,out=50000000
Apollo EMAC
Dcache status 1
Icache status 1
ENTER U-BOOT SWITCH MODE !!!!
get_adc_sample(4): 0x3fe
get_adc_sample(4): 0x3fe
get_adc_sample(4): 0x3fe
get_key(): 0
Normal Start...
Hit any key to stop autoboot: 0 [COLOR=Red]// < -- Hit any key here !!!![/COLOR]
[I][B]8726M_DVBC #[/B][/I] [COLOR=Red]// <- uboot HUSH Shell[/COLOR]
5) Close CS switch to enable SPI flash
6) Detect SPI at uBoot HUSH prompt (note 1):
Code:
8726M_DVBC# [B][I]sf probe 2[/I][/B]
SF: Got idcode c2 20 16
SF: Detected M25X32 with sector size 4096, total 4194304 bytes
SPI NOR Flash have write protect!!!
7)Detect SD at uBoot HUSH prompt (note 2):
Code:
8726M_DVBC# [B][I]mmcinfo 0[/I][/B]
Partition Map for UNKNOWN device 0 -- Partition Type: DOS
Partition Start Sector Num Sectors Type
1 16065 481950 b
Device: SDIO Port A
Manufacturer ID: 0
OEM: 0
Name: Tran Speed: 40000000
Rd Block Len: 512
SD version 2.0
High Capacity: No
Capacity: 256376832
Bus Width: 4-bit
Partition Map for UNKNOWN device 0 -- Partition Type: DOS
Partition Start Sector Num Sectors Type
1 16065 481950 b
8) Load FAT partition 0 (note 3):
Code:
8726M_DVBC#[B][I] fatinfo mmc 0[/I][/B]
Interface: MMC
Device 0: Vendor: Man 134b47 Snr c300c5d7 Rev: 1.0 Prod: SD256
Type: Removable Hard Disk
Capacity: 244.5 MB = 0.2 GB (500736 x 512)
Partition 1: Filesystem: FAT32 "NO NAME "
9) Load file to ram (note 4):
Code:
8726M_DVBC# [B][I]fatload mmc 0 0x80000000 uImage_recovery[/I][/B]
4194304 bytes read: OK
10) erase and write loaded image to SPI flash (note 5):
Code:
8726M_DVBC#[B][I] sf erase 0[/I][/B]
4194304 bytes erased OK
8726M_DVBC# [B][I]sf write 0x80000000 0 0x400000[/I][/B]
4194304 bytes write OK
11) reset box
Code:
8726M_DVBC# [I][B]reset[/B][/I]
Documentation
--------------
(note 1)
sf - SPI flash sub-system
Usage:
sf probe [bus:]cs [hz] [mode] - init flash device on given SPI bus and chip select
sf read addr offset len - read `len' bytes starting at `offset' to memory at `addr'
sf write addr offset len - write `len' bytes from memory at `addr' to flash at `offset'
sf erase offset len - erase `len' bytes from `offset'
In my box SF device is 2 in some MX boards is 0
(note 2)
mmcinfo - mmcinfo <dev num>-- display MMC info of device number stated ex.> mmcinfo 0
(note 3)
fatinfo - <dev num> <partition> print information about filesystem ex.> fatinfo mmc 0
(note 4)
fatload - <dev><offset><$loadaddr><image.file> load binary file from a dos filesystem to <$loadaddr> in ram. 0x80000000 is beginning of ram on my board.
(note 5)
sf erase - <offset><len> if no len specified all chip will be erased
sf write - <$loadaddr><offset><len> len must be filesize in hex with 0x prefix ex.> 0x400000 to fill full 4MB flash.
Optional: you can check your recovery image after step 9 prior to burn in flash with this cmd:
Code:
8726M_DVBC#[I][B]bootm 0x80000000[/B][/I]