Accidentaly erased nand flash and uboot wont load
November 17, 2023 12:24PM
hello everyone

i accidentaly erased nand flash by this command nand erase 0x20000 and now the uboot wont upload , is there any way to recover it ?? please

by the way its a board of a zkteco F18 after doing a nand flash erase the it wont boot anymore

here is my entire log :

NAND Secondary Program Loader
REG_CPM_CPMPCR = 28080000
===> REG_CPM_DDCDR = 60000002
mpll init over
CPAPCR = B1000120
REG_CPM_CPCCR = 55794410
REG_CPM_CPAPCR = B1008520
PHY-DQ ODT is enabled
PHY-DQS ODT is enabled
16 bit DDR2 SDRAM
DDR2 PHY Init
DDR2 Hardware Init
DDR2 Hardware Train
DDR-ODT is enabled
sdram init ok
CFG_NAND_U_BOOT_OFFS00060000
CFG_NAND_U_BOOT_SIZE00080000
CFG_NAND_U_BOOT_DST80101000
CFG_NAND_U_BOOT_START80101000


U-Boot 1.1.6 (Jun 28 2014 - 17:07:31)

Board: ZMM210 (4775 SOC CPU Speed 1200 MHz)
MEM Clock: 400 MHz
DRAM: 64 MB
Error: Unknown flash ID, force set to 'SST_ID_39SF040'
Flash: 512 kB
NAND: Device ID: [dev id: 0x01f1] [ext_id 0xf1011d00]
128 MiB
In: serial
Out: serial
Err: serial
Net: JZ ETHERNET
Hit ESC key to stop autoboot: 0

NAND read: device 0 offset 0x100000, size 0x60000
393216 bytes read: OK

NAND read: device 0 offset 0x160000, size 0xa0000
655360 bytes read: OK

NAND read: device 0 offset 0x200000, size 0x300000
3145728 bytes read: OK
## Booting image at 80600000 ...
Image Name: Linux-3.0.8-svn226
Image Type: MIPS Linux Kernel Image (gzip compressed)
Data Size: 2937974 Bytes = 2.8 MB
Load Address: 80010000
Entry Point: 8045a080
Verifying Checksum ... Bad Data CRC



AVAILABLE COMMAND IN MY SHELL :

ZMM210 # help
? - alias for 'help'
askenv - get environment variables from stdin
autoscr - run script from memory
base - print or set address offset
bdinfo - print Board Info structure
boot - boot default, i.e., run 'bootcmd'
bootd - boot default, i.e., run 'bootcmd'
bootm - boot application image from memory
bootp - boot image via network using BootP/TFTP protocol
cmp - memory compare
coninfo - print console devices and information
cp - memory copy
crc32 - checksum calculation
dhcp - invoke DHCP client to obtain IP/boot params
diag - perform board diagnostics
echo - echo args to console
erase - erase FLASH memory
flinfo - print FLASH memory information
go - start application at address 'addr'
help - print online help
iminfo - print header information for application image
imls - list all images found in flash
itest - return true/false on integer compare
loadb - load binary file over serial line (kermit mode)
loads - load S-Record file over serial line
loady - load binary file over serial line (ymodem mode)
loop - infinite loop on address range
md - memory display
mm - memory modify (auto-incrementing)
msc - MMC/SD sub-system
mtest - simple RAM test
mw - memory write (fill)
nand - NAND sub-system
nboot - boot from NAND device
nfs - boot image via network using NFS protocol
nm - memory modify (constant address)
ping - send ICMP ECHO_REQUEST to network host
printenv- print environment variables
protect - enable or disable FLASH write protection
rarpboot- boot image via network using RARP/TFTP protocol
regread - user special read register command
regwrite - user special write register command
reset - Perform RESET of the CPU
run - run commands in an environment variable
saveenv - save environment variables to persistent storage
setenv - set environment variables
sleep - delay execution for some time
tftpboot- boot image via network using TFTP protocol
version - print monitor version

thank you very much
Re: Accidentaly erased nand flash and uboot wont load
November 17, 2023 01:50PM
salahbr,

nand erase 0x20000
Was that the exact command you run? i.e. no 2nd parameter?

Power up, interrupt the countdown, and get the env listing:
printenv
And then see what parameters these 2 commands need:
nand
crc32
or
help nand
help crc32

And post the log here.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Accidentaly erased nand flash and uboot wont load
November 17, 2023 02:15PM
hello mister bodhi for you help and reply

for printenv command here is the log :

ZMM210 # printenv
bootargs=mem=64M console=ttyS3,57600n8 ubi.mtd=4 root=ubi0:ubifs rootfstype=ubifs rw
bootcmd=nand read 0x80e00000 0x100000 0x60000;nand read 0x80e80000 0x160000 0xa0000;nand read 0x80600000 0x200000 0x300000;bootm
bootdelay=1
baudrate=57600
loads_echo=1
ethaddr=00:2a:c6:2c:bd:fc
ipaddr=192.168.4.58
serverip=192.168.3.56
autoload=n
bootfile="tjiang/uImage"
ethact=JZ ETHERNET
default=-a
stdin=serial
stdout=serial
stderr=serial
filesize=377B8


For the help nand here is the log :

ZMM210 # help nand
nand info                  - show available NAND devices
nand device [dev]     - show or set current device
nand read[.jffs2]     - addr off|partition size
nand write[.jffs2]    - addr off|partiton size - read/write `size' bytes starting
    at offset `off' to/from memory address `addr'
nand write[.yaffs[1]] addr off size - read/write `size' bytes starting
    at offset `off' to memory address `addr' [yaffs1 or yaffs2 format]
nand erase [clean] [off size] - erase `size' bytes from
    offset `off' (entire device if not specified)
nand bad - show bad blocks
nand dump[.oob] off - dump page
nand scrub - really clean NAND erasing bad blocks (UNSAFE)
nand markbad off - mark bad block at offset (UNSAFE)
nand biterr off - make a bit error at offset (UNSAFE)
nand lock [tight] [status] - bring nand to lock state or display locked pages
nand unlock [offset] [size] - unlock section

and finaly for the help crc32 here is the log

ZMM210 # help crc32
crc32 address count [addr]
    - compute CRC32 checksum [save at addr]

==========
moderator edit: please use code tags (formatted code button) to post log



Edited 1 time(s). Last edit at 11/17/2023 02:19PM by bodhi.
Re: Accidentaly erased nand flash and uboot wont load
November 17, 2023 02:47PM
salahbr,

It does not look like the erase command you ran was
nand erase 0x20000
Note the address you posted above is 20 thousand hex.

Did you run
nand erase 0x200000
(200 thousand hex)

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Accidentaly erased nand flash and uboot wont load
November 17, 2023 03:23PM
thank you mister bodhi for you time and reply

sorry for the mistake here is what i exaclty did

nand erase 0x260000 0x20000

please can you help me to resolve that problem a recovery or anything else ??? to correct that mistake
Re: Accidentaly erased nand flash and uboot wont load
November 17, 2023 03:59PM
salahbr,

Note the kernel image was loaded like this:
NAND read: device 0 offset 0x200000, size 0x300000 
3145728 bytes read: OK 
## Booting image at 80600000 ... 
Image Name: Linux-3.0.8-svn226 
Image Type: MIPS Linux Kernel Image (gzip compressed) 
Data Size: 2937974 Bytes = 2.8 MB 
Load Address: 80010000 
Entry Point: 8045a080 
Verifying Checksum ... Bad Data CRC

And you did:
nand erase 0x260000 0x20000

By doing that, you have erased 0x20000 (128K) in the middle of the kernel image stored on NAND.

If you can find the backup of this kernel image (usually called uImage) somewhere then you can flash it back to the location 0x200000. This is the only way to fix it. There is no other way to retrieve that 128K.

Good luck in finding the image. And when you found it, I'll happy to help you flashing it.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Accidentaly erased nand flash and uboot wont load
November 17, 2023 04:34PM
mister bodhi i don't now where i can find the backup of this image kernel but i have an other working device with similar configuration and similar image kernel 100% similar can i get image from it and flash it to that corrupted one ???? if yes can you show me how to exract image kernel from working device to the bad one ?????
Re: Accidentaly erased nand flash and uboot wont load
November 17, 2023 05:13PM
salahbr,

> but i have an other
> working device with similar configuration and
> similar image kernel 100% similar can i get image
> from it and flash it to that corrupted one

Oh yes! definitely. If both are using the same kernel then you can backup the kernel image on the good one and flash to this device.

> can you show me how to exract image kernel
> from working device to the bad one ?????

Boot up that working device, log in. And run,
dmesg
cat /proc/mtd

And post the log here.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Accidentaly erased nand flash and uboot wont load
November 17, 2023 05:41PM
here is the log of the 2 commands :

dmesg
cat /proc/mtd

# dmesg 
[    0.000000] Linux version 3.0.8-svn226 (root@ubuntu) (gcc version 4.1.2) #313 PREEMPT Thu May 19 00:55:36 PDT 2016
[    0.000000] CPU0 RESET ERROR PC:DFFFCFCE
[    0.000000] bootconsole [early0] enabled
[    0.000000] CPU revision is: 2ed1024f (Ingenic Xburst)
[    0.000000] FPU revision is: 00330000
[    0.000000] setup_priority: BUS--0x13000000, TARGET--0x6, VALUE--0x3
[    0.000000] setup_priority: VALUE after setup--0xc0
[    0.000000] setup_priority: BUS--0x13400000, TARGET--0xa, VALUE--0x3
[    0.000000] setup_priority: VALUE after setup--0xc00
[    0.000000] CCLK:1200MHz L2CLK:600Mhz H0CLK:240MHz H2CLK:240Mhz PCLK:120Mhz
[    0.000000] Determined physical RAM map:
[    0.000000] User-defined physical RAM map:
[    0.000000]  memory: 04000000 @ 00000000 (usable)
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] Zone PFN ranges:
[    0.000000]   Normal   0x00000000 -> 0x00004000
[    0.000000]   HighMem  empty
[    0.000000] Movable zone start PFN for each node
[    0.000000] early_node_map[1] active PFN ranges
[    0.000000]     0: 0x00000000 -> 0x00004000
[    0.000000] On node 0 totalpages: 16384
[    0.000000] free_area_init_node: node 0, pgdat 80762b60, node_mem_map 81000000
[    0.000000]   Normal zone: 128 pages used for memmap
[    0.000000]   Normal zone: 0 pages reserved
[    0.000000]   Normal zone: 16256 pages, LIFO batch:3
[    0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[    0.000000] pcpu-alloc: [0] 0
[    0.000000] Built 1 zonelists in Zone order, mobility grouping off.  Total pages: 16256
[    0.000000] Kernel command line: mem=64M console=ttyS3,57600n8 ubi.mtd=4 root=ubi0:ubifs rootfstype=ubifs rw
[    0.000000] PID hash table entries: 256 (order: -2, 1024 bytes)
[    0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
[    0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
[    0.000000] Primary instruction cache 16kB, VIPT, 4-way, linesize 32 bytes.
[    0.000000] Primary data cache 16kB, 4-way, VIPT, no aliases, linesize 32 bytes
[    0.000000] Memory: 56756k/65536k available (4424k kernel code, 8780k reserved, 3079k data, 216k init, 0k highmem)
[    0.000000] SLUB: Genslabs=9, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] Preemptible hierarchical RCU implementation.
[    0.000000] NR_IRQS:289
[    0.000000] clockevents_config_and_register success.
[    0.000000] Console: colour dummy device 80x25
[    0.009057] Calibrating delay loop... 1196.85 BogoMIPS (lpj=5984256)
[    0.055620] pid_max: default: 32768 minimum: 301
[    0.065180] Mount-cache hash table entries: 512
[    0.076352] print_constraints: dummy:
[    0.084025] NET: Registered protocol family 16
[    0.092918] gpemc: SoC-jz4775 gpemc support functions initilized.
[    0.105448] jz4780-bch jz4780-bch.0: SoC-jz4780 HW ECC-BCH support functions initialized.
[    0.123021] redlight on gpio request failed
[    0.132032] GPIO sleep states:
[    0.138048] OH:00000000 OL:20000000 IP:9700ff00 IN:080200ff
[    0.149370] OH:00000000 OL:5013ff58 IP:0fcc0000 IN:a00000a4
[    0.160662] OH:00000000 OL:0fffffff IP:f0000000 IN:00000000
[    0.171963] OH:00000000 OL:3c008000 IP:00013fff IN:c3fe4000
[    0.183264] OH:00000000 OL:30f00402 IP:0f0ffbf0 IN:c000000d
[    0.194566] OH:00000000 OL:00007fff IP:ffff0000 IN:00008000
[    0.205867] OH:00000000 OL:00037fc0 IP:fffc003f IN:00008000
[    0.217341] cs4344 audio codec register success
[    0.229712] bio: create slab <bio-0> at 0
[    0.238078] [GET LOGO]:LOGO LCDType = [2401] rotate =[4] lcdfunction = [0]
[    0.253671] jz-fb jz-fb.0: Frame buffer size: 466944 bytes
[    0.265059] jz-fb jz-fb.0: LCDC: PixClock:6007000
[    0.274465] jz-fb jz-fb.0: LCDC: PixClock:6000000(real)
[    0.285043] test lcd lcd_special_on_ST7789V_normal
[    1.598194]
[    1.598197]
[    1.598200] [__lcd_ST7789V_Rotate_270][1254]
[    1.598204]
[    1.760214] ---------------x:0, y:0, w:320, h:240, d:16
[    1.770684] show logo for nand flash
[    1.780734] screen_w = 320, screen_h = 240, bpp = 16
[    1.790790] barH = 20, barw = 320, barsize = 51200
[    1.803558] jz-dma jz-dma: JZ SoC DMA initialized
[    1.813437] SCSI subsystem initialized
[    1.821726] usbcore: registered new interface driver usbfs
[    1.832810] usbcore: registered new interface driver hub
[    1.844194] usbcore: registered new device driver usb
[    1.854742] i2c-gpio i2c-gpio.0: using pins 126 (SDA) and 127 (SCL)
[    1.868072] i2c-gpio i2c-gpio.1: using pins 158 (SDA) and 159 (SCL)
[    1.882886] print_constraints: TF: 3000 mV
[    1.891830] cfg80211: Calling CRDA to update world regulatory domain
[    1.904950] print_constraints: Touch Screen: 3000 mV
[    1.915907] print_constraints: VCC5V: 5000 mV
[    1.925066] print_constraints: Wi-Fi: 3300 mV
[    1.934698] print_constraints: VBus: 3000 mV
[    1.943706] print_constraints: Vlcd: 3300 mV
[    1.953250] print_constraints: Cim: 3300 mV
[    1.961977] print_constraints: Cim: 3300 mV
[    1.971066] rdev_init_debugfs: Cim: Failed to create debugfs directory
[    1.984454] print_constraints: vbklight: 3300 mV
[    1.994509] Switching to clocksource jz_clocksource
[    2.010006] DWC IN OTG MODE
[    2.054993] dwc2 dwc2: Keep PHY ON
[    2.061721] dwc2 dwc2: Using Buffer DMA mode
[    2.276531] dwc2 dwc2: Core Release: 3.00a
[    2.284787] dwc2 dwc2: DesignWare USB2.0 High-Speed Host Controller
[    2.298058] dwc2 dwc2: new USB bus registered, assigned bus number 1
[    2.312238] hub 1-0:1.0: USB hub found
[    2.320289] hub 1-0:1.0: 1 port detected
[    2.328429] dwc2 dwc2: DWC2 Host Initialized
[    2.337991] NET: Registered protocol family 2
[    2.346813] IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
[    2.361539] TCP established hash table entries: 2048 (order: 2, 16384 bytes)
[    2.376399] TCP bind hash table entries: 2048 (order: 3, 40960 bytes)
[    2.389599] TCP: Hash tables configured (established 2048 bind 2048)
[    2.402907] TCP reno registered
[    2.409169] UDP hash table entries: 128 (order: 0, 6144 bytes)
[    2.421570] UDP-Lite hash table entries: 128 (order: 0, 6144 bytes)
[    2.435124] NET: Registered protocol family 1
[    2.445499] ashmem: initialized
[    2.457546] fuse init (API version 7.16)
[    2.465939] msgmni has been set to 110
[    2.475293] io scheduler noop registered
[    2.483079] io scheduler deadline registered
[    2.492062] io scheduler cfq registered (default)
[    2.505935] jz-uart.3: ttyS3 at MMIO 0x10033000 (irq = 56) is a uart3
[    2.538879] brd: module loaded
[    2.547023] loop: module loaded
[    2.553635] jz4775-efuse jz4775-efuse.0: ingenic efuse interface module registered.
[    2.570027] jz4775 SADC driver registeres over!
[    2.579891] dma dma0chan30: Channel 30 have been requested.(phy id 1,type 0x08)
[    2.595189] jz4780-nand jz4780-nand.0: enable DMA special channel<0, 1>
[    2.660383] NAND device: Manufacturer ID: 0x01, Chip ID: 0xf1 (AMD/Spansion AFA1G08T), 128MiB, page size: 2048, OOB size: 64
[    2.735420] Scanning device for bad blocks
[    2.809164] Creating 6 MTD partitions on "jz4780-nand.0":
[    2.820565] 0x000000000000-0x000000100000 : "uboot"
[    2.831263] 0x000000100000-0x000000160000 : "lcdcfg"
[    2.841226] ------------[ cut here ]------------
[    2.850545] WARNING: at drivers/gpio/gpiolib.c:101 gpio_ensure_requested+0xa4/0x1dc()
[    2.866415] autorequest GPIO-129
[    2.872950] Modules linked in:
[    2.879130] Call Trace:
[    2.884084] [<800207a8>] dump_stack+0x8/0x34
[    2.892736] [<80043bc0>] warn_slowpath_common+0x78/0xa4
[    2.903326] [<80043c74>] warn_slowpath_fmt+0x2c/0x38
[    2.913391] [<801ccd1c>] gpio_ensure_requested+0xa4/0x1dc
[    2.924339] [<801ccf30>] gpio_direction_output+0xdc/0x25c
[    2.935297] [<801ee5c8>] zk_fb_show_progress_bar+0x1fc/0x544
[    2.946770] [<8005214c>] call_timer_fn+0x40/0x184
[    2.956301] [<8005246c>] run_timer_softirq+0x1dc/0x29c
[    2.966723] [<8004aa68>] __do_softirq+0xcc/0x26c
[    2.976078] [<8004ac9c>] do_softirq+0x94/0x9c
[    2.984907] [<8004ad00>] irq_exit+0x5c/0x74
[    2.993387] [<80016ed0>] plat_irq_dispatch+0x134/0x144
[    3.003804] [<8001af20>] ret_from_irq+0x0/0x4
[    3.012630] [<80044e8c>] vprintk+0x1d8/0x520
[    3.021282] [<800451f8>] printk+0x24/0x30
[    3.029412] [<8024b174>] allocate_partition+0x344/0x9f4
[    3.040001] [<8024b8b8>] add_mtd_partitions+0x94/0x120
[    3.050421] [<80247810>] mtd_device_parse_register+0x48/0xe4
[    3.061902] [<8025c874>] jz4780_nand_probe+0x1084/0x1110
[    3.072676] [<8021c1b4>] driver_probe_device+0x14c/0x1e8
[    3.083442] [<8021c560>] __driver_attach+0xa8/0xb0
[    3.093154] [<8021aff4>] bus_for_each_dev+0x5c/0xc8
[    3.103042] [<8021bb0c>] bus_add_driver+0xc8/0x2dc
[    3.112755] [<8021cbdc>] driver_register+0x74/0x190
[    3.122643] [<80010588>] do_one_initcall+0x188/0x1f0
[    3.132702]
[    3.135730] ---[ end trace 948ad9426f59f0ed ]---
[    3.146464] 0x000000160000-0x000000200000 : "logo"
[    3.156851] 0x000000200000-0x000000500000 : "kernel"
[    3.168203] 0x000000500000-0x000001e00000 : "rootfs"
[    3.178987] 0x000001e00000-0x000008000000 : "userdata"
[    3.190770] jz4780-nand jz4780-nand.0: Successfully registered JZ4780 SoC NAND controller driver.
[    3.209616] UBI: attaching mtd4 to ubi0
[    3.217292] UBI: physical eraseblock size:   131072 bytes (128 KiB)
[    3.230440] UBI: logical eraseblock size:    126976 bytes
[    3.241291] UBI: smallest flash I/O unit:    2048
[    3.251267] UBI: VID header offset:          2048 (aligned 2048)
[    3.263354] UBI: data offset:                4096
[    3.408626] UBI: max. sequence number:       15747
[    3.427650] UBI: attached mtd4 to ubi0
[    3.435141] UBI: MTD device name:            "rootfs"
[    3.445840] UBI: MTD device size:            25 MiB
[    3.455631] UBI: number of good PEBs:        200
[    3.465445] UBI: number of bad PEBs:         0
[    3.474426] UBI: number of corrupted PEBs:   0
[    3.483296] UBI: max. allowed volumes:       128
[    3.493249] UBI: wear-leveling threshold:    4096
[    3.502640] dwc2 dwc2:  ++OTG Interrupt: A-Device Timeout Change++
[    3.515789] UBI: number of internal volumes: 1
[    3.524721] UBI: number of user volumes:     1
[    3.533639] UBI: available PEBs:             10
[    3.543405] UBI: total number of reserved PEBs: 190
[    3.553185] UBI: number of PEBs reserved for bad PEB handling: 2
[    3.565915] UBI: max/mean erase counter: 187/79
[    3.575022] UBI: image sequence number:  0
[    3.583245] UBI: background thread "ubi_bgt0d" started, PID 43
[    3.803159] Bus Mode Reg after reset: 0x00020101, cnt=0
[    3.816064] jz4775_mii_bus: probed
[    3.822958] =========>gmacdev->MacBase = 0xb34b0000 DmaBase = 0xb34b1000
[    3.836927] Bus Mode Reg after reset: 0x00020101, cnt=0
[    3.848569] MAC addr read from nand is :00:17:61:12:88:A7
[    3.860187] jz4775_mac jz4775_mac.0: JZ4775 on-chip Ethernet MAC driver, Version 1.0
[    3.876469] PPP generic driver version 2.4.2
[    3.885271] PPP Deflate Compression module registered
[    3.895971] PPP BSD Compression module registered
[    3.906097] PPP MPPE Compression module registered
[    3.916247] NET: Registered protocol family 24
[    3.925319] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    3.939339] arch/mips/xburst/soc-4775/common/clk.c: Clock to USB host has been enabled
[    3.939363] jz-ohci jz-ohci.0: JZ OHCI
[    3.946903] jz-ohci jz-ohci.0: new USB bus registered, assigned bus number 2
[    3.961771] jz-ohci jz-ohci.0: irq 13, io mem 0x134a0000
[    4.028916] hub 2-0:1.0: USB hub found
[    4.036924] hub 2-0:1.0: 1 port detected
[    4.045298] usbcore: registered new interface driver uas
[    4.056530] Initializing USB Mass Storage driver...
[    4.066470] usbcore: registered new interface driver usb-storage
[    4.079107] USB Mass Storage support registered.
[    4.088411] i2c /dev entries driver
[    4.096270] Linux video capture interface: v2.00
[    4.106147] device-mapper: uevent: version 1.0.3
[    4.116368] device-mapper: ioctl: 4.20.0-ioctl (2011-02-02) initialised: dm-devel@redhat.com
[    4.133689] jzmmc jzmmc.2: vmmc.2 regulator miss
[    4.145212] usbcore: registered new interface driver usbhid
[    4.156982] usbhid: USB HID core driver
[    4.164646] 476: time:4120319
[    4.170592] Driver for AUTHEN
[    4.177562] i2s init success.
[    4.184232] Netfilter messages via NETLINK v0.30.
[    4.193853] NF_TPROXY: Transparent proxy support initialized, version 4.1.0
[    4.208437] NF_TPROXY: Copyright (c) 2006-2007 BalaBit IT Ltd.
[    4.220538] ip_tables: (C) 2000-2006 Netfilter Core Team
[    4.231956] TCP cubic registered
[    4.239081] NET: Registered protocol family 10
[    4.249300] Mobile IPv6
[    4.254115] ip6_tables: (C) 2000-2006 Netfilter Core Team
[    4.265846] IPv6 over IPv4 tunneling driver
[    4.274788] NET: Registered protocol family 17
[    4.283654] lib80211: common routines for IEEE802.11 drivers
[    4.295742] lib80211_crypt: registered algorithm 'NULL'
[    4.295761] Registering the dns_resolver key type
[    4.305448] turn off boot console early0
[    4.315158] jz_nor spi0.0: max_speed_hz: 12000000
[    4.315175] jz_nor spi0.0: bits_per_word: 8
[    4.315260] jz_nor spi0.0: spi-nor id: 0x831331a1, status: 0
[    4.315304] jz_nor spi0.0: spi-nor id: 0x001331a1, status: 0
[    4.315760] Warning: unable to open an initial console.
[    4.359883] UBIFS: recovery needed
[    4.487482] UBIFS: recovery completed
[    4.487505] UBIFS: mounted UBI device 0, volume 0, name "ubifs"
[    4.487516] UBIFS: file system size:   22093824 bytes (21576 KiB, 21 MiB, 174 LEBs)
[    4.487528] UBIFS: journal size:       3555328 bytes (3472 KiB, 3 MiB, 28 LEBs)
[    4.487538] UBIFS: media format:       w3/r0 (latest is w4/r0)
[    4.487547] UBIFS: default compressor: lzo
[    4.487555] UBIFS: reserved for root:  0 bytes (0 KiB)
[    4.489086] VFS: Mounted root (ubifs filesystem) on device 0:11.
[    4.489890] Freeing unused kernel memory: 216k freed
[    4.753033] Bus Mode Reg after reset: 0x00020101, cnt=0
[    4.935852] udevd (75): /proc/75/oom_adj is deprecated, please use /proc/75/oom_score_adj instead.
[    5.501368] UBI: attaching mtd5 to ubi1
[    5.501386] UBI: physical eraseblock size:   131072 bytes (128 KiB)
[    5.501395] UBI: logical eraseblock size:    126976 bytes
[    5.501403] UBI: smallest flash I/O unit:    2048
[    5.501411] UBI: VID header offset:          2048 (aligned 2048)
[    5.501420] UBI: data offset:                4096
[    6.180365] UBI: max. sequence number:       29543
[    6.198677] UBI: attached mtd5 to ubi1
[    6.198696] UBI: MTD device name:            "userdata"
[    6.198704] UBI: MTD device size:            98 MiB
[    6.198711] UBI: number of good PEBs:        784
[    6.198719] UBI: number of bad PEBs:         0
[    6.198725] UBI: number of corrupted PEBs:   0
[    6.198733] UBI: max. allowed volumes:       128
[    6.198741] UBI: wear-leveling threshold:    4096
[    6.198749] UBI: number of internal volumes: 1
[    6.198756] UBI: number of user volumes:     1
[    6.198763] UBI: available PEBs:             29
[    6.198771] UBI: total number of reserved PEBs: 755
[    6.198778] UBI: number of PEBs reserved for bad PEB handling: 7
[    6.198788] UBI: max/mean erase counter: 63/38
[    6.198795] UBI: image sequence number:  0
[    6.198922] UBI: background thread "ubi_bgt1d" started, PID 196
[    6.320539] UBIFS: recovery needed
[    6.442317] UBIFS: recovery completed
[    6.442341] UBIFS: mounted UBI device 1, volume 0, name "ubifs"
[    6.442351] UBIFS: file system size:   93073408 bytes (90892 KiB, 88 MiB, 733 LEBs)
[    6.442364] UBIFS: journal size:       9023488 bytes (8812 KiB, 8 MiB, 72 LEBs)
[    6.442374] UBIFS: media format:       w3/r0 (latest is w4/r0)
[    6.442383] UBIFS: default compressor: lzo
[    6.442391] UBIFS: reserved for root:  0 bytes (0 KiB)
[    6.854466] PHY: 0:10 - Link is Up - 100/Full
[    7.361309]  KEY VERSION =  1.0.2 May  4 2014
[    7.363442] input: 74hc164-keys as /devices/platform/74hc164-keys/input/input0
[    7.365572] 74hc164_keys driver register success.
[    7.441528]  GPIO VERSION =  1.0.1 Apr  3 2014
[    7.447446] ZK gpio driver registered.
[    7.512265] ZK Camera1 driver loaded, use cim1.
[    7.572629]  NAND VERSION =  1.0.0 May 20 2014
[    7.578528] ZK nand driver registered.
[    7.638507] ZK sensor1 driver registered, use i2c-1.
[    7.701165]  RTC  VERSION =  1.0.1 Apr 22 2014
[    7.701191] zt-c08803a 0-0032: chip found, driver version 0.1.0
[    7.706585] zt-c08803a 0-0032: rtc core: registered zt-c08803a as rtc0
[    7.789814] usbcore: registered new interface driver uvcvideo
[    7.789833] USB Video Class driver (v1.0.0)
[    7.841661]  WDT VERSION =  1.0.2 Jun 20 2014
[    7.845818] JZ47XX watchdog driver registered.
[    7.905799]  WIEGAND OUT VERSION =  1.0.1 ZMM220May 30 2014
[    7.907904] Weigand out driver register success.
[    7.969420] Vboard Driver Modify By Seven...
[    7.969459] ZkBoard Regist Ok!
[    7.970044] input: pkbd as /devices/virtual/input/input1
[   10.164753] wait stable.[583][cgu_aic]
[   10.166815] dma dma0chan25: Channel 25 have been requested.(phy id 6,type 0x06)
[   10.182175] wait stable.[583][cgu_aic]
[   10.347369] request gpio-1 fail.
[   10.347389] request gpio-1 fail.
[   10.494069] request gpio129 fail.
[   10.494110] request gpio129 fail.
[   15.254386] eth0: no IPv6 routers present
[   16.581744] request gpio129 fail.
#


dev:    size   erasesize  name
mtd0: 00100000 00020000 "uboot"
mtd1: 00060000 00020000 "lcdcfg"
mtd2: 000a0000 00020000 "logo"
mtd3: 00300000 00020000 "kernel"
mtd4: 01900000 00020000 "rootfs"
mtd5: 06200000 00020000 "userdata"
mtd6: 01648000 0001f000 "ubifs"
mtd7: 05a18000 0001f000 "ubifs"



Edited 3 time(s). Last edit at 11/17/2023 06:42PM by salahbr.
Re: Accidentaly erased nand flash and uboot wont load
November 18, 2023 02:16AM
salahbr,

Below I lay out the steps you need to do.

It is not complete yet. But it will give you some idea about the process.


===========


This is the kernel image.

mtd3: 00300000 00020000 "kernel"

So check your system to see if there is nanddump command.
which nanddump
If nanddump is available

cd /tmp
nanddump --noecc --omitoob -f mtd3.kernel /dev/mtd3

And copy the file mtd3.kernel to another Linux box. Set up tftp server on that box. Copy the mtd3.kernel file to /tftproot folder.

And power up this box. Interrupt serial console. And load the file over tftp. Asuming the Linux box (that runs tftp server) IP address is 192.168.0.100, and this box is 192.168.0.200.

setenv serverip 192.168.0.100
setenv ipaddr 192.168.0.200
tftp 0x80600000 mtd3.kernel


and then do nand write from memory address 0x80600000

--- To be continued.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Accidentaly erased nand flash and uboot wont load
November 18, 2023 05:20AM
here is the log of the command you provided mister Bodhi :

is there any to install it

# nanddump --noecc --omitoob -f mtd3.kernel /dev/mtd3
-sh: nanddump: not found
#

but i did use this command and it was succefull :

dd if=/dev/mtd3 of=/tmp/mtd3.kernel

# dd if=/dev/mtd3 of=/tmp/mtd3.kernel
6144+0 records in
6144+0 records out
3145728 bytes (3.0MB) copied, 1.271531 seconds, 2.4MB/s


is it the same command same result ???



Edited 5 time(s). Last edit at 11/18/2023 09:44AM by salahbr.
Re: Accidentaly erased nand flash and uboot wont load
November 18, 2023 01:49PM
> is it the same command same result ???

Ideally we would want to use nanddump. But for emergency, using dd is OK.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Accidentaly erased nand flash and uboot wont load
November 18, 2023 03:48PM
i did transfert the file via TFTPF and write to the nand flash but without succes :( the device wont boot

ZMM210 # tftp 0x80600000 mtd3.kernel
====>phy 16 Autonegotiation Complete
====>found PHY 16
GMAC init finish
Using JZ ETHERNET device
TFTP from server 192.168.2.10; our IP address is 192.168.2.11
Filename 'mtd3.kernel'.
Load address: 0x80600000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ###################
done
Bytes transferred = 2089472 (1fe200 hex)


ZMM210 # nand write 0x80600000 0x200000 0x300000

NAND write: device 0 offset 0x200000, size 0x300000
 3145728 bytes written: OK
ZMM210 # boot

NAND read: device 0 offset 0x100000, size 0x60000
 393216 bytes read: OK

NAND read: device 0 offset 0x160000, size 0xa0000
 655360 bytes read: OK

NAND read: device 0 offset 0x200000, size 0x300000
 3145728 bytes read: OK
## Booting image at 80600000 ...
   Image Name:   Linux-3.0.8-svn226
   Image Type:   MIPS Linux Kernel Image (gzip compressed)
   Data Size:    2937974 Bytes =  2.8 MB
   Load Address: 80010000
   Entry Point:  8045a080
   Verifying Checksum ... Bad Data CRC
ZMM210 #
Re: Accidentaly erased nand flash and uboot wont load
November 18, 2023 06:52PM
salahbr,

Indeed bad news!

In case the NAND flash is bad.

Try booting the image directly without writing to NAND.
nand read 0x80e00000 0x100000 0x60000
nand read 0x80e80000 0x160000 0xa0000
tftp 0x80600000 mtd3.kernel
bootm

You can also dump the other mtds and load each on over tftp, and boot without writing to NAND, too.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Accidentaly erased nand flash and uboot wont load
November 19, 2023 05:44AM
nand read 0x80e00000 0x100000 0x60000
nand read 0x80e80000 0x160000 0xa0000
tftp 0x80600000 mtd3.kernel
bootm

Log of the commands :


ZMM210 # nand read 0x80e00000 0x100000 0x60000

NAND read: device 0 offset 0x100000, size 0x60000
 393216 bytes read: OK
ZMM210 # nand read 0x80e80000 0x160000 0xa0000

NAND read: device 0 offset 0x160000, size 0xa0000
 655360 bytes read: OK
ZMM210 # tftp 0x80600000 mtd3.kernel
====>phy 16 Autonegotiation Complete
====>found PHY 16
GMAC init finish
Using JZ ETHERNET device
TFTP from server 192.168.2.10; our IP address is 192.168.2.11
Filename 'mtd3.kernel'.
Load address: 0x80600000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ###################
done
Bytes transferred = 2089472 (1fe200 hex)
ZMM210 # bootm
## Booting image at 80600000 ...
   Image Name:   Linux-3.0.8-svn226
   Image Type:   MIPS Linux Kernel Image (gzip compressed)
   Data Size:    2937974 Bytes =  2.8 MB
   Load Address: 80010000
   Entry Point:  8045a080
   Verifying Checksum ... Bad Data CRC
ZMM210 #



Edited 1 time(s). Last edit at 11/19/2023 05:45AM by salahbr.
Re: Accidentaly erased nand flash and uboot wont load
November 19, 2023 02:02PM
salahbr,

To do it properly, find a nanddump binary for MIPS. And back up the mtd again.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Accidentaly erased nand flash and uboot wont load
November 19, 2023 10:11PM
salahbr,

OpenWrt does have nandutils package that I seem to recall contains the nanddump binary. So you might try to see if there is an OpenWrt device similar to you device.

Ray
Re: Accidentaly erased nand flash and uboot wont load
November 20, 2023 01:13AM
> OpenWrt does have nandutils package that I seem to
> recall contains the nanddump binary. So you might
> try to see if there is an OpenWrt device similar
> to you device.
>
> Ray

+1

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: