amouiche / qnap_mtd_resize_for_bullseye

Script for resizing MTD partitions on a QNAP device in order to be able to upgrade from buster to bullseye
GNU General Public License v2.0
54 stars 11 forks source link

Maybe I destroyed the QNAP TS-219P+ #44

Closed paolocesari closed 1 year ago

paolocesari commented 1 year ago

Hi everyone, after running the script qnap_mtd_resize.py (the command sudo rm /etc/modprobe.d/local.conf was essential) I was able to update Debian to Bullseye and also to Bookworm.

Then, I don't know why, I decided to install Buster (kernel-6282 and initrd are files from Debian FTP repository).

~$ sudo dd if=/tmp/debian/kernel-6282 of=/dev/mtdblock1
~$ sudo dd if=/tmp/debian/initrd of=/dev/mtdblock2

And nothing, the NAS turns on but does not boot. Connecting by serial port to U-Boot I see the "kernel panic" error. Do you think there is a way to solve this problem? (I know, you do well to remind me that I should have read the guide Recovery.md). Thanks you all. Paolo


         __  __                      _ _
        |  \/  | __ _ _ ____   _____| | |
        | |\/| |/ _` | '__\ \ / / _ \ | |
        | |  | | (_| | |   \ V /  __/ | |
        |_|  |_|\__,_|_|    \_/ \___|_|_|
 _   _     ____              _
| | | |   | __ )  ___   ___ | |_
| | | |___|  _ \ / _ \ / _ \| __|
| |_| |___| |_) | (_) | (_) | |_
 \___/    |____/ \___/ \___/ \__|  ** LOADER **
 ** MARVELL BOARD: DB-88F6282A-BP LE TS-219P+ ,PHY=1.8v

U-Boot 1.1.4 (Sep 20 2010 - 15:17:40) Marvell version: 3.5.3

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

Soc: 88F6282 A0CPU running @ 1600Mhz L2 running @ 533Mhz
SysClock = 533Mhz , TClock = 200Mhz

DRAM (DDR3) CAS Latency = 7 tRP = 7 tRAS = 20 tRCD=7
DRAM CS[0] base 0x00000000   size 256MB
DRAM CS[1] base 0x10000000   size 256MB
DRAM Total size 512MB  16bit width
Addresses 8M - 0M are saved for the U-Boot usage.
Mem malloc Initialization (8M - 7M): Done
[16384kB@f8000000] Flash: 16 MB

CPU : Marvell Feroceon (Rev 1)
USB 0: host mode
PEX 0: PCI Express Root Complex Interface
PEX interface detected Link X1
PEX 1: interface detected no Link.

Reset IDE:
Marvell Serial ATA Adapter
Integrated Sata device found

Net:   egiga0 [PRIME]
Hit any key to stop autoboot:  0
Send Cmd : 0x68 to UART1
## Booting image at 00800000 ...
   Image Name:   Debian kernel
   Created:      2022-09-06  22:57:03 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2067738 Bytes =  2 MB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.19.0-21-marvell (debian-kernel@lists.debian.org) (gcc version 8.3.0 (Debian 8.3.0-6)) #1 Debian 4.19.249-2 (2022-06-30)
[    0.000000] CPU: Feroceon 88FR131 [56251311] revision 1 (ARMv5TE), cr=0005397f
[    0.000000] CPU: VIVT data cache, VIVT instruction cache
[    0.000000] OF: fdt: Machine model: QNAP TS219 family
[    0.000000] Memory policy: Data cache writeback
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 130048
[    0.000000] Kernel command line: console=ttyS0,115200 root=/dev/ram initrd=0xb00000,0xc00000 ramdisk=34816 cmdlinepart.mtdparts="spi0.0:512k@0(uboot)ro,3M@0x100000(Kernel),12M@0x400000(RootFS1),2M@0x200000(Kernel_legacy),256k@0x80000(U-Boot Config),256k@0xc0000(NAS Config)" mtdparts="spi0.0:512k@0(uboot)ro,3M@0x100000(Kernel),12M@0x400000(RootFS1),2M@0x200000(Kernel_legacy),256k@0x80000(U-Boot Config),256k@0xc0000(NAS Config)"
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] Memory: 501352K/524288K available (3988K kernel code, 339K rwdata, 1036K rodata, 312K init, 218K bss, 22936K reserved, 0K cma-reserved, 0K highmem)
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
[    0.000000]     vmalloc : 0xe0800000 - 0xff800000   ( 496 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xe0000000   ( 512 MB)
[    0.000000]     pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
[    0.000000]     modules : 0xbf000000 - 0xbfe00000   (  14 MB)
[    0.000000]       .text : 0x(ptrval) - 0x(ptrval)   (3989 kB)
[    0.000000]       .init : 0x(ptrval) - 0x(ptrval)   ( 312 kB)
[    0.000000]       .data : 0x(ptrval) - 0x(ptrval)   ( 340 kB)
[    0.000000]        .bss : 0x(ptrval) - 0x(ptrval)   ( 219 kB)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] ftrace: allocating 18996 entries in 56 pages
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000000] clocksource: orion_clocksource: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 9556302233 ns
[    0.000006] sched_clock: 32 bits at 200MHz, resolution 5ns, wraps every 10737418237ns
[    0.000029] Switching to timer-based delay loop, resolution 5ns
[    0.000148] Calibrating delay loop (skipped), value calculated using timer frequency.. 400.00 BogoMIPS (lpj=800000)
[    0.000167] pid_max: default: 32768 minimum: 301
[    0.000570] Security Framework initialized
[    0.000585] Yama: disabled by default; enable with sysctl kernel.yama.*
[    0.000732] AppArmor: AppArmor initialized
[    0.000914] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.000930] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.001974] CPU: Testing write buffer coherency: ok
[    0.002939] Setting up static identity map for 0x8200 - 0x823c
[    0.003119] mvebu-soc-id: MVEBU SoC ID=0x6282, Rev=0x0
[    0.004481] devtmpfs: initialized
[    0.007907] VFP support v0.3: not present
[    0.008095] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.008115] futex hash table entries: 256 (order: -1, 3072 bytes)
[    0.008385] pinctrl core: initialized pinctrl subsystem
[    0.009791] NET: Registered protocol family 16
[    0.010095] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.010653] audit: initializing netlink subsys (disabled)
[    0.011343] cpuidle: using governor ladder
[    0.011356] cpuidle: using governor menu
[    0.011633] Feroceon L2: Enabling L2
[    0.011664] Feroceon L2: Cache support initialised.
[    0.011838] [Firmware Info]: /ocp@f1000000/ethernet-controller@72000/ethernet0-port@0: local-mac-address is not set
[    0.015039] No ATAGs?
[    0.016069] audit: type=2000 audit(0.008:1): state=initialized audit_enabled=0 res=1
[    0.018894] clocksource: Switched to clocksource orion_clocksource
[    0.039747] VFS: Disk quotas dquot_6.6.0
[    0.039825] VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
[    0.040305] AppArmor: AppArmor Filesystem Enabled
[    0.041325] NET: Registered protocol family 2
[    0.041490] IP idents hash table entries: 8192 (order: 4, 65536 bytes)
[    0.042293] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes)
[    0.042324] TCP established hash table entries: 4096 (order: 2, 16384 bytes)
[    0.042375] TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
[    0.042425] TCP: Hash tables configured (established 4096 bind 4096)
[    0.042507] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.042528] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.042715] NET: Registered protocol family 1
[    0.042960] Unpacking initramfs...
[    0.437990] Initramfs unpacking failed: XZ-compressed data is corrupt
[    0.473461] Freeing initrd memory: 12288K
[    0.474140] Initialise system trusted keyrings
[    0.474194] Key type blacklist registered
[    0.474376] workingset: timestamp_bits=30 max_order=17 bucket_order=0
[    0.478495] zbud: loaded
[    0.480111] Key type asymmetric registered
[    0.480120] Asymmetric key parser 'x509' registered
[    0.480158] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251)
[    0.480310] io scheduler noop registered
[    0.480545] io scheduler cfq registered (default)
[    0.481874] kirkwood-pinctrl f1010000.pin-controller: registered pinctrl driver
[    0.483239] mvebu-pcie mbus@f1000000:pcie@82000000: PCI host bridge to bus 0000:00
[    0.483253] pci_bus 0000:00: root bus resource [bus 00-ff]
[    0.483263] pci_bus 0000:00: root bus resource [mem 0xe0000000-0xefffffff]
[    0.483271] pci_bus 0000:00: root bus resource [io  0x1000-0xeffff]
[    0.484411] PCI: bus0: Fast back to back transfers disabled
[    0.484424] pci 0000:00:01.0: bridge configuration invalid ([bus 00-00]), reconfiguring
[    0.484434] pci 0000:00:02.0: bridge configuration invalid ([bus 00-00]), reconfiguring
[    0.484867] pci 0000:01:00.1: [Firmware Bug]: reg 0x10: invalid BAR (can't size)
[    0.484882] pci 0000:01:00.1: [Firmware Bug]: reg 0x14: invalid BAR (can't size)
[    0.484895] pci 0000:01:00.1: [Firmware Bug]: reg 0x18: invalid BAR (can't size)
[    0.484907] pci 0000:01:00.1: [Firmware Bug]: reg 0x1c: invalid BAR (can't size)
[    0.484920] pci 0000:01:00.1: [Firmware Bug]: reg 0x20: invalid BAR (can't size)
[    0.485830] PCI: bus1: Fast back to back transfers disabled
[    0.486632] PCI: bus2: Fast back to back transfers enabled
[    0.486782] pci 0000:00:01.0: BAR 8: assigned [mem 0xe0000000-0xe00fffff]
[    0.486797] pci 0000:01:00.0: BAR 6: assigned [mem 0xe0000000-0xe000ffff pref]
[    0.486807] pci 0000:01:00.0: BAR 5: assigned [mem 0xe0010000-0xe0011fff]
[    0.486819] pci 0000:00:01.0: PCI bridge to [bus 01]
[    0.486829] pci 0000:00:01.0:   bridge window [mem 0xe0000000-0xe00fffff]
[    0.486839] pci 0000:00:02.0: PCI bridge to [bus 02]
[    0.486922] pcieport 0000:00:01.0: enabling device (0140 -> 0142)
[    0.487021] pci 0000:01:00.0: async suspend disabled to avoid multi-function power-on ordering issue
[    0.487044] pci 0000:01:00.1: async suspend disabled to avoid multi-function power-on ordering issue
[    0.487361] mv_xor f1060800.xor: Marvell shared XOR driver
[    0.515551] mv_xor f1060800.xor: Marvell XOR (Registers Mode): ( xor cpy intr )
[    0.515710] mv_xor f1060900.xor: Marvell shared XOR driver
[    0.543550] mv_xor f1060900.xor: Marvell XOR (Registers Mode): ( xor cpy intr )
[    0.543806] Serial: 8250/16550 driver, 2 ports, IRQ sharing disabled
[    0.544586] console [ttyS0] disabled
[    0.544631] f1012000.serial: ttyS0 at MMIO 0xf1012000 (irq = 27, base_baud = 12500000) is a 16550A
[    1.246564] console [ttyS0] enabled
[    1.250495] f1012100.serial: ttyS1 at MMIO 0xf1012100 (irq = 28, base_baud = 12500000) is a 16550A
[    1.260023] i2c /dev entries driver
[    1.264584] ledtrig-cpu: registered to indicate activity on CPUs
[    1.271470] registered taskstats version 1
[    1.275605] Loading compiled-in X.509 certificates
[    1.280971] Loaded X.509 cert 'Debian Secure Boot CA: 6ccece7e4c6c0d1f6149f3dd27dfcc5cbb419ea1'
[    1.290094] Loaded X.509 cert 'Debian Secure Boot Signer 2021 - linux: 4b6ef5abca669825178e052c84667ccbc0531f8c'
[    1.300420] AppArmor: AppArmor sha1 policy hashing enabled
[    1.307283] hctosys: unable to open rtc device (rtc0)
[    1.312451] OF: fdt: not creating '/sys/firmware/fdt': CRC check failed
[    1.322275] Freeing unused kernel memory: 312K
[    1.326764] This architecture does not have kernel memory protection.
[    1.333237] Run /init as init process
[    1.338077] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00007f00
[    1.338077]
[    1.347252] CPU: 0 PID: 1 Comm: init Not tainted 4.19.0-21-marvell #1 Debian 4.19.249-2
[    1.355286] Hardware name: Marvell Kirkwood (Flattened Device Tree)
[    1.361593] [<c001680c>] (unwind_backtrace) from [<c0013648>] (show_stack+0x18/0x1c)
[    1.369368] [<c0013648>] (show_stack) from [<c03e6ea4>] (panic+0xb8/0x250)
[    1.376278] [<c03e6ea4>] (panic) from [<c00228c8>] (do_exit+0x1b0/0x99c)
[    1.383008] [<c00228c8>] (do_exit) from [<c0023eac>] (do_group_exit+0x5c/0xc0)
[    1.390262] [<c0023eac>] (do_group_exit) from [<c0023f28>] (sys_exit_group+0x18/0x1c)
[    1.398127] [<c0023f28>] (sys_exit_group) from [<c0009000>] (ret_fast_syscall+0x0/0x50)
[    1.406160] Exception stack(0xdf4cbfa8 to 0xdf4cbff0)
[    1.411230] bfa0:                   be8e0f2b b6ef4b9c 0000007f be8e0100 0000000a 0000007f
[    1.419445] bfc0: be8e0f2b b6ef4b9c b6f06d6f 000000f8 b6f06d50 b6f06978 00000000 be8e0c14
[    1.427657] bfe0: be8e0338 be8e033c b6eed6b0 b6eef344
[    1.432727] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x00007f00
[    1.432727]  ]---
cavokz commented 1 year ago

It's not destroyed but if you want it back you have some work to do. Having already the console is a good start :)

What would you like to do now? Really install Buster or just restore the NAS to a working state? Do you have data in it that you might want to backup somewhere else?

lpaolini commented 1 year ago

Hi Paolo,

It's not destroyed, there might be better solutions, but you can still reinstall Debian "Buster" from scratch using a TFTP server. Just make the kernel-6282 and initrd files available to your TFTP server, then connect your serial console to the NAS, power it on and stop U-Boot when it says "Hit any key to stop autoboot".

Then issue the following commands for booting the Debian installer.

dhcp
tftp 0x800000 kernel-6282
tftp 0xb00000 initrd
bootm 0x800000

Now you should be able to connect to your NAS using ssh installer@IPADDRESS. You must take care NOT TO FORMAT the partitions you want to keep... :-)

At the end of the process you'll have to run again the upgrades to Bullseye and then to Bookworm...

@cavokz I got Bookworm installed on a TS-221, same 6282 cpu as TS-219P+. If I provided Paolo with my kernel and initrd, would he be able to boot? He should be able al least to get into maintenance mode, where he could mount his previous partitions from fstab (plus the bind mounts for dev, proc, sys and run) under a temporary root (e.g. /tmproot), chroot to it and then run update-initramfs -u. Would that work?

cavokz commented 1 year ago

I got Bookworm installed on a TS-221, same 6282 cpu as TS-219P+. If I provided Paolo with my kernel and initrd, would he be able to boot? He should be able al least to get into maintenance mode, where he could mount his previous partitions from fstab (plus the binf mounts for dev, proc, sys and run) under a temporary root (e.g. /tmproot), chroot to it and then run update-initramfs -u. Would that work?

I'm not sure, probably the dtb file is different. It's worth a try I think, at worst it does not boot.

@paolocesari you could also physically connect the booting drive of your NAS to another pc, via sata-to-usb adapter if you have it, and extract (and copy to your tftp server) the very same kernel and initrd images that were flashed with the upgrade to Bookworm.

amouiche commented 1 year ago

Hello,

On Tue, 2023-07-25 at 09:39 -0700, paolocesari wrote:

Hi everyone, after running the script qnap_mtd_resize.py (the command sudo rm /etc/modprobe.d/local.conf was essential) I was able to update Debian to Bullseye and also to Bookworm. Then, I don't know why, I decided to install Buster (kernel-6282 and initrd are files from Debian FTP repository). ~$ sudo dd if=/tmp/debian/kernel-6282 of=/dev/mtdblock1 ~$ sudo dd if=/tmp/debian/initrd of=/dev/mtdblock2

As fas as I remember, writing flash with "dd" into /dev/mtdblockN only turns "1" bits into "0", but "0" bits are stick to 0. You must use "flashcp" or "flash_erase" correctly for this. Consequently, you just write garbage to your flash...

The QNAP original firrmware has the "dd" of=/dev/mtdblockX  OK, but I suspect QNAP to have hack their kerner MTD driver to make this work.

If you have kept a /dev/mtd1 and /dev/mtd2 backup before screwed you flash, you still have the possibility to write them back from the uboot command line

Did you ?

Regards, Arnaud

And nothing, the NAS turns on but does not boot. Connecting by serial port to U-Boot I see the "kernel panic" error. Do you think there is a way to solve this problem? (I know, you do well to remind me that I should have read the guide Recovery.md). Thanks you all. Paolo

     __  __                      _ _
    |  \/  | __ _ _ ____   _____| | |
    | |\/| |/ _` | '__\ \ / / _ \ | |
    | |  | | (_| | |   \ V /  __/ | |
    |_|  |_|\__,_|_|    \_/ \___|_|_|

| | | | | ) __ | |_ | | | || \ / \ / | | | |_| || |) | () | () | | \/ |_/ \/ _/ \| LOADER ** MARVELL BOARD: DB-88F6282A-BP LE TS-219P+ ,PHY=1.8v

U-Boot 1.1.4 (Sep 20 2010 - 15:17:40) Marvell version: 3.5.3

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

Soc: 88F6282 A0CPU running @ 1600Mhz L2 running @ 533Mhz SysClock = 533Mhz , TClock = 200Mhz

DRAM (DDR3) CAS Latency = 7 tRP = 7 tRAS = 20 tRCD=7 DRAM CS[0] base 0x00000000 size 256MB DRAM CS[1] base 0x10000000 size 256MB DRAM Total size 512MB 16bit width Addresses 8M - 0M are saved for the U-Boot usage. Mem malloc Initialization (8M - 7M): Done @.*** Flash: 16 MB

CPU : Marvell Feroceon (Rev 1) USB 0: host mode PEX 0: PCI Express Root Complex Interface PEX interface detected Link X1 PEX 1: interface detected no Link.

Reset IDE: Marvell Serial ATA Adapter Integrated Sata device found

Net: egiga0 [PRIME] Hit any key to stop autoboot: 0 Send Cmd : 0x68 to UART1

Booting image at 00800000 ...

Image Name: Debian kernel Created: 2022-09-06 22:57:03 UTC Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 2067738 Bytes = 2 MB Load Address: 00008000 Entry Point: 00008000 Verifying Checksum ... OK OK

Starting kernel ...

[ 0.000000] Booting Linux on physical CPU 0x0 [ 0.000000] Linux version 4.19.0-21-marvell @.) (gcc version 8.3.0 (Debian 8.3.0-6)) #1 Debian 4.19.249-2 (2022-06-30) [ 0.000000] CPU: Feroceon 88FR131 [56251311] revision 1 (ARMv5TE), cr=0005397f [ 0.000000] CPU: VIVT data cache, VIVT instruction cache [ 0.000000] OF: fdt: Machine model: QNAP TS219 family [ 0.000000] Memory policy: Data cache writeback [ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 130048 [ 0.000000] Kernel command line: console=ttyS0,115200 root=/dev/ram initrd=0xb00000,0xc00000 ramdisk=34816 @*.**@*.**@*.**@*.**@.(U-Boot @.(NAS Config)" @*.**@*.**@*.**@*.**@.(U-Boot @.(NAS Config)" [ 0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes) [ 0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes) [ 0.000000] Memory: 501352K/524288K available (3988K kernel code, 339K rwdata, 1036K rodata, 312K init, 218K bss, 22936K reserved, 0K cma-reserved, 0K highmem) [ 0.000000] Virtual kernel memory layout: [ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB) [ 0.000000] fixmap : 0xffc00000 - 0xfff00000 (3072 kB) [ 0.000000] vmalloc : 0xe0800000 - 0xff800000 ( 496 MB) [ 0.000000] lowmem : 0xc0000000 - 0xe0000000 ( 512 MB) [ 0.000000] pkmap : 0xbfe00000 - 0xc0000000 ( 2 MB) [ 0.000000] modules : 0xbf000000 - 0xbfe00000 ( 14 MB) [ 0.000000] .text : 0x(ptrval) - 0x(ptrval) (3989 kB) [ 0.000000] .init : 0x(ptrval) - 0x(ptrval) ( 312 kB) [ 0.000000] .data : 0x(ptrval) - 0x(ptrval) ( 340 kB) [ 0.000000] .bss : 0x(ptrval) - 0x(ptrval) ( 219 kB) [ 0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1 [ 0.000000] ftrace: allocating 18996 entries in 56 pages [ 0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16 [ 0.000000] clocksource: orion_clocksource: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 9556302233 ns [ 0.000006] sched_clock: 32 bits at 200MHz, resolution 5ns, wraps every 10737418237ns [ 0.000029] Switching to timer-based delay loop, resolution 5ns [ 0.000148] Calibrating delay loop (skipped), value calculated using timer frequency.. 400.00 BogoMIPS (lpj=800000) [ 0.000167] pid_max: default: 32768 minimum: 301 [ 0.000570] Security Framework initialized [ 0.000585] Yama: disabled by default; enable with sysctl kernel.yama. [ 0.000732] AppArmor: AppArmor initialized [ 0.000914] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes) [ 0.000930] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes) [ 0.001974] CPU: Testing write buffer coherency: ok [ 0.002939] Setting up static identity map for 0x8200 - 0x823c [ 0.003119] mvebu-soc-id: MVEBU SoC ID=0x6282, Rev=0x0 [ 0.004481] devtmpfs: initialized [ 0.007907] VFP support v0.3: not present [ 0.008095] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns [ 0.008115] futex hash table entries: 256 (order: -1, 3072 bytes) [ 0.008385] pinctrl core: initialized pinctrl subsystem [ 0.009791] NET: Registered protocol family 16 [ 0.010095] DMA: preallocated 256 KiB pool for atomic coherent allocations [ 0.010653] audit: initializing netlink subsys (disabled) [ 0.011343] cpuidle: using governor ladder [ 0.011356] cpuidle: using governor menu [ 0.011633] Feroceon L2: Enabling L2 [ 0.011664] Feroceon L2: Cache support initialised. [ 0.011838] [Firmware Info]: **@.**@*.**@*.: local-mac-address is not set [ 0.015039] No ATAGs? [ 0.016069] audit: type=2000 audit(0.008:1): state=initialized audit_enabled=0 res=1 [ 0.018894] clocksource: Switched to clocksource orion_clocksource [ 0.039747] VFS: Disk quotas dquot_6.6.0 [ 0.039825] VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes) [ 0.040305] AppArmor: AppArmor Filesystem Enabled [ 0.041325] NET: Registered protocol family 2 [ 0.041490] IP idents hash table entries: 8192 (order: 4, 65536 bytes) [ 0.042293] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes) [ 0.042324] TCP established hash table entries: 4096 (order: 2, 16384 bytes) [ 0.042375] TCP bind hash table entries: 4096 (order: 2, 16384 bytes) [ 0.042425] TCP: Hash tables configured (established 4096 bind 4096) [ 0.042507] UDP hash table entries: 256 (order: 0, 4096 bytes) [ 0.042528] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes) [ 0.042715] NET: Registered protocol family 1 [ 0.042960] Unpacking initramfs... [ 0.437990] Initramfs unpacking failed: XZ-compressed data is corrupt [ 0.473461] Freeing initrd memory: 12288K [ 0.474140] Initialise system trusted keyrings [ 0.474194] Key type blacklist registered [ 0.474376] workingset: timestamp_bits=30 max_order=17 bucket_order=0 [ 0.478495] zbud: loaded [ 0.480111] Key type asymmetric registered [ 0.480120] Asymmetric key parser 'x509' registered [ 0.480158] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251) [ 0.480310] io scheduler noop registered [ 0.480545] io scheduler cfq registered (default) [ 0.481874] kirkwood-pinctrl f1010000.pin-controller: registered pinctrl driver [ 0.483239] mvebu-pcie @*.**@*.: PCI host bridge to bus 0000:00 [ 0.483253] pci_bus 0000:00: root bus resource [bus 00-ff] [ 0.483263] pci_bus 0000:00: root bus resource [mem 0xe0000000-0xefffffff] [ 0.483271] pci_bus 0000:00: root bus resource [io 0x1000-0xeffff] [ 0.484411] PCI: bus0: Fast back to back transfers disabled [ 0.484424] pci 0000:00:01.0: bridge configuration invalid ([bus 00-00]), reconfiguring [ 0.484434] pci 0000:00:02.0: bridge configuration invalid ([bus 00-00]), reconfiguring [ 0.484867] pci 0000:01:00.1: [Firmware Bug]: reg 0x10: invalid BAR (can't size) [ 0.484882] pci 0000:01:00.1: [Firmware Bug]: reg 0x14: invalid BAR (can't size) [ 0.484895] pci 0000:01:00.1: [Firmware Bug]: reg 0x18: invalid BAR (can't size) [ 0.484907] pci 0000:01:00.1: [Firmware Bug]: reg 0x1c: invalid BAR (can't size) [ 0.484920] pci 0000:01:00.1: [Firmware Bug]: reg 0x20: invalid BAR (can't size) [ 0.485830] PCI: bus1: Fast back to back transfers disabled [ 0.486632] PCI: bus2: Fast back to back transfers enabled [ 0.486782] pci 0000:00:01.0: BAR 8: assigned [mem 0xe0000000-0xe00fffff] [ 0.486797] pci 0000:01:00.0: BAR 6: assigned [mem 0xe0000000-0xe000ffff pref] [ 0.486807] pci 0000:01:00.0: BAR 5: assigned [mem 0xe0010000-0xe0011fff] [ 0.486819] pci 0000:00:01.0: PCI bridge to [bus 01] [ 0.486829] pci 0000:00:01.0: bridge window [mem 0xe0000000-0xe00fffff] [ 0.486839] pci 0000:00:02.0: PCI bridge to [bus 02] [ 0.486922] pcieport 0000:00:01.0: enabling device (0140 -> 0142) [ 0.487021] pci 0000:01:00.0: async suspend disabled to avoid multi-function power-on ordering issue [ 0.487044] pci 0000:01:00.1: async suspend disabled to avoid multi-function power-on ordering issue [ 0.487361] mv_xor f1060800.xor: Marvell shared XOR driver [ 0.515551] mv_xor f1060800.xor: Marvell XOR (Registers Mode): ( xor cpy intr ) [ 0.515710] mv_xor f1060900.xor: Marvell shared XOR driver [ 0.543550] mv_xor f1060900.xor: Marvell XOR (Registers Mode): ( xor cpy intr ) [ 0.543806] Serial: 8250/16550 driver, 2 ports, IRQ sharing disabled [ 0.544586] console [ttyS0] disabled [ 0.544631] f1012000.serial: ttyS0 at MMIO 0xf1012000 (irq = 27, base_baud = 12500000) is a 16550A [ 1.246564] console [ttyS0] enabled [ 1.250495] f1012100.serial: ttyS1 at MMIO 0xf1012100 (irq = 28, base_baud = 12500000) is a 16550A [ 1.260023] i2c /dev entries driver [ 1.264584] ledtrig-cpu: registered to indicate activity on CPUs [ 1.271470] registered taskstats version 1 [ 1.275605] Loading compiled-in X.509 certificates [ 1.280971] Loaded X.509 cert 'Debian Secure Boot CA: 6ccece7e4c6c0d1f6149f3dd27dfcc5cbb419ea1' [ 1.290094] Loaded X.509 cert 'Debian Secure Boot Signer 2021 - linux: 4b6ef5abca669825178e052c84667ccbc0531f8c' [ 1.300420] AppArmor: AppArmor sha1 policy hashing enabled [ 1.307283] hctosys: unable to open rtc device (rtc0) [ 1.312451] OF: fdt: not creating '/sys/firmware/fdt': CRC check failed [ 1.322275] Freeing unused kernel memory: 312K [ 1.326764] This architecture does not have kernel memory protection. [ 1.333237] Run /init as init process [ 1.338077] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00007f00 [ 1.338077] [ 1.347252] CPU: 0 PID: 1 Comm: init Not tainted 4.19.0-21-marvell #1 Debian 4.19.249-2 [ 1.355286] Hardware name: Marvell Kirkwood (Flattened Device Tree) [ 1.361593] [] (unwind_backtrace) from [] (show_stack+0x18/0x1c) [ 1.369368] [] (show_stack) from [] (panic+0xb8/0x250) [ 1.376278] [] (panic) from [] (do_exit+0x1b0/0x99c) [ 1.383008] [] (do_exit) from [] (do_group_exit+0x5c/0xc0) [ 1.390262] [] (do_group_exit) from [] (sys_exit_group+0x18/0x1c) [ 1.398127] [] (sys_exit_group) from [] (ret_fast_syscall+0x0/0x50) [ 1.406160] Exception stack(0xdf4cbfa8 to 0xdf4cbff0) [ 1.411230] bfa0: be8e0f2b b6ef4b9c 0000007f be8e0100 0000000a 0000007f [ 1.419445] bfc0: be8e0f2b b6ef4b9c b6f06d6f 000000f8 b6f06d50 b6f06978 00000000 be8e0c14 [ 1.427657] bfe0: be8e0338 be8e033c b6eed6b0 b6eef344 [ 1.432727] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x00007f00 [ 1.432727] ]--- — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.>

amouiche commented 1 year ago

Hi Paolo,

It's not destroyed, there might be better solutions, but you can still reinstall Debian "Buster" from scratch using a TFTP server. Just make the kernel-6282 and initrd files available to your TFTP server, then connect your serial console to the NAS, power it on and stop U-Boot when it says "Hit any key to stop autoboot".

Then issue the following commands for booting the Debian installer.

dhcp
tftp 0x800000 kernel-6282
tftp 0xb00000 initrd
bootm 0x800000

Now you should be able to connect to your NAS using ssh installer@IPADDRESS. You must take care NOT TO FORMAT the partitions you want to keep... :-)

At the end of the process you'll have to run again the upgrades to Bullseye and then to Bookworm...

@cavokz I got Bookworm installed on a TS-221, same 6282 cpu as TS-219P+. If I provided Paolo with my kernel and initrd, would he be able to boot? He should be able al least to get into maintenance mode, where he could mount his previous partitions from fstab (plus the bind mounts for dev, proc, sys and run) under a temporary root (e.g. /tmproot), chroot to it and then run update-initramfs -u. Would that work?

Yes, this is the best way to recover here.... especially since you tried to re-install debian buster.

Arnaud

paolocesari commented 1 year ago

Hi Paolo,

It's not destroyed, there might be better solutions, but you can still reinstall Debian "Buster" from scratch using a TFTP server. Just make the kernel-6282 and initrd files available to your TFTP server, then connect your serial console to the NAS, power it on and stop U-Boot when it says "Hit any key to stop autoboot".

Then issue the following commands for booting the Debian installer.

dhcp
tftp 0x800000 kernel-6282
tftp 0xb00000 initrd
bootm 0x800000

Now you should be able to connect to your NAS using ssh installer@IPADDRESS. You must take care NOT TO FORMAT the partitions you want to keep... :-)

At the end of the process you'll have to run again the upgrades to Bullseye and then to Bookworm...

@cavokz I got Bookworm installed on a TS-221, same 6282 cpu as TS-219P+. If I provided Paolo with my kernel and initrd, would he be able to boot? He should be able al least to get into maintenance mode, where he could mount his previous partitions from fstab (plus the bind mounts for dev, proc, sys and run) under a temporary root (e.g. /tmproot), chroot to it and then run update-initramfs -u. Would that work?

Hi, very very well, this solution worked perfectly! It was a bit hard because it was the first time I used tftp, but in the end everything went well. Unfortunately the command dhcp did not work: I solved by setting fixed IP

setenv serverip 192.168.1.10
setenv ipaddr 192.168.1.30

and then

tftp 0x800000 kernel-6282
tftp 0xb00000 initrd
bootm 0x800000

I want to thank @lpaolini for the advice, but also @amouiche and @cavokz for the alternative solutions. This project is really great! Thanks again to all, Paolo

lpaolini commented 1 year ago

Awesome. Just out of curiosity, did you reinstall Buster from scratch or were you able to chroot into your "old" root and run update-initramfs?

paolocesari commented 1 year ago

Awesome. Just out of curiosity, did you reinstall Buster from scratch or were you able to chroot into your "old" root and run update-initramfs?

Very simply I preferred to install Buster from scratch because I did not know how to work with chroot.

Conan179 commented 1 year ago

@paolocesari Which adapter do you use to access the serial console? I'm looking for my Ts-421.

paolocesari commented 1 year ago

@paolocesari Which adapter do you use to access the serial console? I'm looking for my Ts-421.

I used DSD TECH SH-U09C5 bought here https://www.amazon.it/gp/product/B07WX2DSVB (maybe you have to install driver)

Then:

Conan179 commented 1 year ago

Ok and which cable do you use to connect the adapter and the motherboard? I ordered this https://www.amazon.de/dp/B08HQYS3NQ?psc=1&ref=ppx_yo2ov_dt_b_product_details but the pins are thinner and the plugs don't fit.

paolocesari commented 1 year ago

Ok and which cable do you use to connect the adapter and the motherboard? I ordered this https://www.amazon.de/dp/B08HQYS3NQ but the pins are thinner and the plugs don't fit.

I had the same problem. Unfortunately I did not have the specific connector, so I soldered some extensions on the pins on which I connected the cables of the adapter. Alternatively you have to look for its male connector (I don't know the connector type/name - the distance between the pins is 2 mm).

Your adapter PL2303TA only seems to work on Windows, I hope it's not a problem (driver here: https://www.prolific.com.tw/US/ShowProduct.aspx?p_id=223&pcid=126 )

lpaolini commented 1 year ago

@Conan179 The serial connector is a JST PHR-4. I'd suggest buying one with pre-connected cables, like this one.

Also, make sure the serial adapter is 3.3v and not 5v, as it would destroy the serial port of your QNAP.

The safest choice, when it comes to connecting your computer to any serial port, is to use an optocoupled serial port adapter, which can protect your computer from expensive mistakes.

Conan179 commented 1 year ago

Thanks to you both, that helps me, I'll tackle it next month.

@lpaolini Danke für die Amazon links.

lpaolini commented 1 year ago

@Conan179 If you go for the optocoupled serial adapter, which I strongly recommend, follow the pinout below, as instructions provided are very not clear.

Put the jumper either on COM and 3.3v for selecting 3.3v, or COM and 5.0v for selecting 5v (and not where shown in the photo).

Also, in most cases (unless the device with the serial port is powered through the serial port itself) the V+ pin must not be connected. So, for connecting to your QNAP, use GND, TX and RX only.

I could not find any documentation for the P30 pin, which should be left disconnected.

optocoupled USB-serial adapter

If you're curious as to why I recommend the optoisolated one, the reason is that I fried an iMac i9 while trying to flash a smart plug that was inadvertently still connected to the mains...

lpaolini commented 1 year ago

@Conan179 Forgot to mention you can swap the cables pre-connected to the JST PHR-4 connector by slightly pulling up the plastic tabs (one at a time) with a cutter and then pulling the wire.

QNAP serial connector

When making the connections make sure that RX and TX are crossed between the two connectors (RX -> TX and TX -> RX).

Conan179 commented 1 year ago

My DSD TECH SH-U09C5 and the connecting cables arrived today. Because my soldering skills are not that great, I ordered these terminals https://www.amazon.de/gp/product/B07GPQ7VCF/ref=ppx_od_dt_b_asin_title_s00?ie=UTF8&psc=1 to connect the cables to the adapter. And I connected it to my notebook. Here is the beginning of the log:

     __  __                      _ _
    |  \/  | __ _ _ ____   _____| | |
    | |\/| |/ _` | '__\ \ / / _ \ | |
    | |  | | (_| | |   \ V /  __/ | |
    |_|  |_|\__,_|_|    \_/ \___|_|_|

| | | | | ) __ | |_ | | | || \ / \ / | | | |_| || |) | () | () | | \/ |_/ \/ _/ \| LOADER ** MARVELL BOARD: DB-88F6282A-BP LE TS-421 ,PHY=1.8v

U-Boot 1.1.4 (Nov 2 2012 - 10:46:48) Marvell version: 3.5.3

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

Soc: MV88F6282 Rev 1CPU running @ 2000Mhz L2 running @ 500Mhz SysClock = 500Mhz , TClock = 200Mhz

DRAM (DDR3) CAS Latency = 7 tRP = 7 tRAS = 20 tRCD=7 DRAM CS[0] base 0x00000000 size 512MB DRAM CS[1] base 0x20000000 size 512MB DRAM Total size 1GB 16bit width Addresses 8M - 0M are saved for the U-Boot usage. Mem malloc Initialization (8M - 7M): Done [16384kB@f8000000] Flash: 16 MB

CPU : Marvell Feroceon (Rev 1) USB 0: host mode PEX 0: PCI Express Root Complex Interface PEX interface detected Link X1 PEX 1: PCI Express Root Complex Interface PEX interface detected Link X1

Reset IDE: Marvell Serial ATA Adapter Integrated Sata device found Found adapter at bus 0, device 1 ... Scanning channels [1 0 0]: Enable DMA mode (6) Device 2 @ 1 0: Model: WDC WD30EZRX-00DC0B0 Firm: 80.00A80 Ser#: WD-WCC1T0827700 Type: Hard Disk Supports 48-bit addressing Capacity: 764436.4 MB = 746.5 GB (1565565872 x 512)

Net: egiga0 [PRIME], egiga1 Hit any key to stop autoboot: 1 0 Send Cmd : 0x68 to UART1

Booting image at 00800000 ...

Image Name: kernel 6.1.0-11-marvell Created: 2023-09-16 20:27:25 UTC Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 2689526 Bytes = 2.6 MB Load Address: 00008000 Entry Point: 00008000 Verifying Checksum ... OK OK

Starting kernel ...

This part is only intended to show that the connection is readable. So, but I can't type anything, nothing happens in the kitty window. What I noticed is that some characters can't be displayed: "[ OK ] Started rpc-statd.service▒▒atus monitor for NFSv2/3 locking.."

How come I can't type anything?

amouiche commented 1 year ago

On Wed, 2023-09-27 at 12:22 -0700, Conan179 wrote:

My DSD TECH SH-U09C5 and the connecting cables arrived today. Because my soldering skills are not that great, I ordered these terminals https://www.amazon.de/gp/product/B07GPQ7VCF/ref=ppx_od_dt_b_asin_title_s00?ie=UTF8&psc=1 to connect the cables to the adapter. And I connected it to my notebook. Here is the beginning of the log:


|  \/  | __ _ _ ____   _____| | |
| |\/| |/ _` | '__\ \ / / _ \ | |
| |  | | (_| | |   \ V /  __/ | |
|_|  |_|\__,_|_|    \_/ \___|_|_|

[...] OK Starting kernel ... This part is only intended to show that the connection is readable. So, but I can't type anything, nothing happens in the kitty window. What I noticed is that some characters can't be displayed: "[ OK ] Started rpc-statd.service▒▒atus monitor for NFSv2/3 locking.." How come I can't type anything? You can't type if:

  • your TX connection is not connected correctly (signal not received by qnap)
  • you didn't disable hardware control flow on your PC side (you PC may think the remote side is not ready to received)
  • It is also possible that your ground connection is not correctly connected.

Also, the voltage of the line must be equivalent on the Qnap and your adapter (for example if your QNAP is using 3.3V and your adapter is 1.8V, you will receive (even if too voltage is too high), but the QNAP may not). You should check this with a Voltmeter if you have one.

Arnaud

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.*** m>

Conan179 commented 1 year ago

You can't type if: - your TX connection is not connected correctly (signal not received by qnap)

OK, I'll check that.

you didn't disable hardware control flow on your PC side (you PC may think the remote side is not ready to received)

I turned off the flow control, I'm 100% sure, I checked it several times.

It is also possible that your ground connection is not correctly connected. Also, the voltage of the line must be equivalent on the Qnap and your adapter (for example if your QNAP is using 3.3V and your adapter is 1.8V, you will receive (even if too voltage is too high), but the QNAP may not). You should check this with a Voltmeter if you have one. Arnaud

I have a voltmeter at home and can use it. How should I check the voltage, from ground to Tx or Rx? From the USB adapter (the jumper is set to 3.3v.) or from the NAS?

amouiche commented 1 year ago

On Thu, 2023-09-28 at 00:26 -0700, Conan179 wrote:

You can't type if: - your TX connection is not connected correctly (signal not received by qnap) OK, I'll check that. you didn't disable hardware control flow on your PC side (you PC may think the remote side is not ready to received) I turned off the flow control, I'm 100% sure, I checked it several times. It is also possible that your ground connection is not correctly connected. Also, the voltage of the line must be equivalent on the Qnap and your adapter (for example if your QNAP is using 3.3V and your adapter is 1.8V, you will receive (even if too voltage is too high), but the QNAP may not). You should check this with a Voltmeter if you have one. Arnaud I have a voltmeter at home and can use it. How should I check the voltage, from ground to Tx or Rx? From the USB adapter (the jumper is set to 3.3v.) or from the NAS?

When no conenction between NAS and serial adapter, measure the voltage between ground and TX (or RX since there is a pull-up). The signal level is high when idle (for TX or RX) so you have the voltage used by the interface. The voltage should be the same in NAS and Adapter side (or less than 0.5V difference).

Also, with the voltmeter you should be able to see if there is an activity on the adapter TX line. Even if it is not a oscilloscope, you should see a drop of the "average" voltage when the line is transmitting continously with something like "cat /dev/zero > /dev/ttyUSB0" from your PC. If you only type your keyboard, it will not generate enough "zeros" to be detected with the voltmeter, but copy/paste of a large text content should also work.

Arnaud

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.*** m>

Conan179 commented 1 year ago

So, when measured, my multimeter shows 3.7v on the adapter and v on the qnas. When I insert a longer text, the voltage drops to ~ 1.5v and the tx LED on the adapter flashes. When I measure ground to the 3 wires on the qnap, it always shows me 5v.

amouiche commented 1 year ago

On Thu, 2023-09-28 at 05:36 -0700, Conan179 wrote:

So, when measured, my multimeter shows 3.7v on the adapter and v on the qnas. the value on QNAP is missing . When I insert a longer text, the voltage drops to ~ 1.5v and the tx LED on the adapter flashes. When I measure ground to the 3 wires on the qnap, it always shows me 5v. Why 4 wires ? you only need 3 : ground, TX, RX — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.*** m>

Conan179 commented 1 year ago

the value on QNAP is missing .

When I measure ground to the 3 wires on the qnap, it always shows me 5v.

I had already written that... (I write in German and have it translated via Google)

Why 4 wires ? you only need 3 : ground, TX, RX

http://www.cyrius.com/debian/kirkwood/qnap/ts-41x/serial/ TX VCC RX GND

lpaolini commented 1 year ago

@Conan179 VCC must not be connected. Even a small difference in voltage can cause a large enough current to break things.

Never ever connect VCC unless the device doesn't have its own power supply (i.e. it's powered via the serial).

amouiche commented 1 year ago

OK,

On Thu, 2023-09-28 at 05:54 -0700, Conan179 wrote:

the value on QNAP is missing . When I measure ground to the 3 wires on the qnap, it always shows me 5v. I had already written that... (I write in German and have it translated via Google) Why 4 wires ? you only need 3 : ground, TX, RX http://www.cyrius.com/debian/kirkwood/qnap/ts-41x/serial/ TX VCC RX GND — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.*** m>

lpaolini commented 1 year ago

@Conan179 I have both TS-219P and TS-221 and they both operate at 3.3v. I'm pretty sure the TS-219P+ uses the same voltage.

Conan179 commented 1 year ago

OK, - Don't connect VCC, it is not usefull here - If you QNAP is using 5V, and you adapter is configured (by jumpers as I understand) to 3.3V, It can explain what you experience.

So, I've now measured several times, the pins on my TS-421 definitely have 5V. I removed the vcc and tried first with 3.3v then with 5v jumper setting on the adapter, nothing changed, reading works, writing doesn't.

lpaolini commented 1 year ago

What software are you using?

Conan179 commented 1 year ago

kitty

lpaolini commented 1 year ago

If you can use a linux computer or a mac, the simplest thing you can do to connect is screen <serial_inteface> 115200. could be something like /dev/ttyUSB<...> on Debian or /dev/tty.usbserial-<...> on a Mac.

Conan179 commented 1 year ago

I don't have any Linux installed at the moment, with a live Linux there is an error that takes too long to fix in a live Linux. The instructions for the adapter say that you can test it by putting a jumper on RX and TX, and that works too.

lpaolini commented 1 year ago

Ok, so the adapter works. Can you repeat this test connecting the RX and TX pins on the JST connector instead? This way you can test the entire cable too.

Conan179 commented 1 year ago

Working

lpaolini commented 1 year ago

Hmm... there must be an issue with the serial port on the QNAP then.