Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with old bootloader and recognizing disks in slot 1 & 2 for NAS440 #24

Open
bbuljan opened this issue Sep 28, 2024 · 13 comments
Open

Comments

@bbuljan
Copy link

bbuljan commented Sep 28, 2024

I was using the previous "hack" on BA440 with Lenny distribution; my setup is as follows:
Disk in slot 1 was booting Lenny, and slots 2, 3 and 4 were used for hot-swappable disks with a lot of media files on them (films, music, photos etc). A few convenient scripts and I was able to automatically mount any disk that was put in bays 2, 3 or 4 and use the two buttons and display to umount any one of them. I was using the OSMC media server on RPi to access the disks via NFS/CIFS.

But, recently it started to freeze, so I got my eyes on this project, and here I am, trying to create fresh nas with recent Debian on it...

So, the problems...

Old bootloader.

You should have seen my face after u-boot displayed the USB command not found...
Going through Help I could see there are no usb or fatload commands offered (there was ext2load, but to no avail since no USB was accessible). So, I was stuck and tried numerous other options to get files loaded. In the end, only TFTP was successful. I have installed the TFTP server on my Linux workstation, changed the env serverip variable to point to my box, and executed tftpload command.

Not recognized disk

As I said in the introduction, because of my setup and needs, I need as many free bays as possible. So I tried to install Debian on disk in slot 1 but to no avail. The solution I tried was to use Bookworm release in the hope that the new kernel supports this controller. And it did!
Changed the blackarmor-nas-debian-prep.sh script:
DEBDIST=${DEBDIST:-bullseye}
to
DEBDIST=${DEBDIST:-bookworm}

It successfully booted from bay 1!
I do not know the speed of the disks in bays 1 and 2, I haven't tested it yet.

Now on the task to try to automount disks and USB devices. And to control buttons and display...

Cheers!

@bbuljan
Copy link
Author

bbuljan commented Sep 29, 2024

I read about support for display and the buttons, and the nas440.c and nas440.h modules, but I cannot find them...
Any clue how to find either of them and how to control the display and/or buttons; is there a device I'm not aware of like it was in the original firmware?

Any help would be appreciated...

Cheers!

@hn
Copy link
Owner

hn commented Sep 29, 2024

You'll find them in the diff: https://github.com/hn/seagate-blackarmor-nas/blob/master/u-boot-2022.04-nas440.diff

If you update U-Boot, you'll have usb cmds and LCD support (within U-Boot, not Linux).

@hn
Copy link
Owner

hn commented Sep 30, 2024

From within Linux, you can control the LCD display with lcdproc.

When I tested it (roughly 3 years ago) something required to be manually compiled, because 'ugpio' or 'gpiod' was missing. This might have changed. In the end it worked, the LCD showed CPU load, network activity etc.

This is something I found in my copy-paste buffer, But beware, i have no idea whether it makes any sense:

[hd44780]
Backlight = yes
ConnectionType = gpio
DelayBus = true
KeyMatrix_4_1 = Enter
KeyMatrix_4_2 = Up
KeyMatrix_4_3 = Down
KeyMatrix_4_4 = Escape
Keypad = no
#OutputPort = no
Size = 16x2
#pin_D0=36
#pin_D1=37
#pin_D2=38
#pin_D3=39
pin_D4=40
pin_D5=41
pin_D6=42
pin_D7=43
pin_RW=44
pin_EN=45
pin_RS=35
pin_BL=7

If you get it working, please report back on how you did it.

@hn
Copy link
Owner

hn commented Sep 30, 2024

Please report the make, model and transport info of your drives in slot 1 and 2 (top lines of hdparm -I /dev/sdX).

@bbuljan
Copy link
Author

bbuljan commented Sep 30, 2024

Will do in a few days, I'm away this week.
But, thanks for the prompt answer!

@bbuljan
Copy link
Author

bbuljan commented Oct 8, 2024

Attached are the files from 3 disks:

  • Seagate 2TB - boot Linux
  • WD Enterprise 1TB
  • WD Green 2 TB

All disks are SATA3. Speeds are not the maximum 6 Gb/s but are more than 1.5Gb/s which is suggested (cca 2 Gb/s).

The tested speeds with hdparm are the same across the disks and in all bays (Seagate was tested only in bay 0):

Bay-0 - Seagate:  Timing cached reads:        506 MB in  2.01 seconds = 252.26 MB/sec
Bay-0 - Seagate:  Timing buffered disk reads: 160 MB in  3.01 seconds =  53.10 MB/sec

Bay-1 - WD Green: Timing cached reads:        484 MB in  2.00 seconds = 241.61 MB/sec
Bay-1 - WD Green: Timing buffered disk reads: 224 MB in  3.00 seconds =  74.64 MB/sec
Bay-2 - WD Green: Timing cached reads:        482 MB in  2.00 seconds = 240.64 MB/sec
Bay-2 - WD Green: Timing buffered disk reads: 232 MB in  3.01 seconds =  76.96 MB/sec
Bay-3 - WD Green: Timing cached reads:        456 MB in  2.00 seconds = 227.72 MB/sec
Bay-3 - WD Green: Timing buffered disk reads: 228 MB in  3.02 seconds =  75.45 MB/sec

Bay-2 - WD-Enter: Timing cached reads:        486 MB in  2.00 seconds = 242.56 MB/sec
Bay-2 - WD-Enter: Timing buffered disk reads: 232 MB in  3.02 seconds =  76.91 MB/sec
Bay-1 - WD-Enter: Timing cached reads:        490 MB in  2.00 seconds = 245.04 MB/sec
Bay-1 - WD-Enter: Timing buffered disk reads: 206 MB in  3.02 seconds =  68.15 MB/sec
Bay-3 - WD-Enter: Timing cached reads:        488 MB in  2.01 seconds = 243.10 MB/sec
Bay-3 - WD-Enter: Timing buffered disk reads: 234 MB in  3.02 seconds =  77.43 MB/sec

Seagate.txt
WD-Enterprise.txt
WD-Green.txt

@hn
Copy link
Owner

hn commented Oct 8, 2024

Thanks. Can you please post a full boot log (U-Boot and kernel, or just 'dmesg' if you do not have serial connected) as well?

@bbuljan
Copy link
Author

bbuljan commented Oct 9, 2024

Here it is: u-boot.log

@bbuljan
Copy link
Author

bbuljan commented Oct 9, 2024

By the way, funny story, after every boot, one of the network adapters doesn't work, they alternate between them. Both are on the same network, two different addresses, I have to try and find out on which I can ssh this time...

@hn
Copy link
Owner

hn commented Oct 9, 2024

Thanks for the boot log. There is a TOSHIBA DT01ACA100 connected to the sata_mv controller (Slot 3 or 4), working without problems (which is no surprise). And you have a ST2000DM008-2FR102 Seagate Barracuda connected to the PCIe controller (Slot 1 or 2), which (correctly) steps down link speed to 1.5G and works:

[    7.186077] ata3: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
[   12.258086] ata3.00: qc timeout after 5000 msecs (cmd 0xec)
[   12.263749] ata3.00: failed to IDENTIFY (I/O error, err_mask=0x4)
[   12.584417] ata3: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
[   22.754073] ata3.00: qc timeout after 10000 msecs (cmd 0xec)
[   22.759801] ata3.00: failed to IDENTIFY (I/O error, err_mask=0x4)
[   22.765949] ata3: limiting SATA link speed to 1.5 Gbps
[   23.084416] ata3: SATA link up 1.5 Gbps (SStatus 113 SControl 310)
[   23.119253] ata3.00: ATA-10: ST2000DM008-2FR102, 0001, max UDMA/133
[   23.125583] ata3.00: 3907029168 sectors, multi 16: LBA48 NCQ (depth 0/32)
[   23.184626] ata3.00: configured for UDMA/133
[   23.189473] scsi 2:0:0:0: Direct-Access     ATA      ST2000DM008-2FR1 0001 PQ: 0 ANSI: 5

I've never seen this (positive) behaviour, need to investigate that.

@bbuljan
Copy link
Author

bbuljan commented Oct 10, 2024

So, I was wrong...
It is not a new kernel that recognizes the disk in Slot1 or Slot2, it is the type of the disk...
It was pure coincidence that I was using one disk with the buster and another one with the bullseye.
Neither of the 27 Western Digital disks was recognized by the kernel. Just two ST1000DM and one ST2000DM.
But!
Sometimes, some of the WD disks was recognized by the U-Boot kernel; this is the same disk booted two times in a row:

When it wasn't recognized
U-Boot 2022.04 (Apr 11 2022 - 15:58:53 +0200)
NAS 440
. . .
Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 6.1.0-25-marvell ([email protected]) (gcc-12 (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #1 Debian 6.1.106-3 (2024-08-26)
. . .
[    6.617785] ata1: SATA max UDMA/133 irq 35
[    6.621946] ata2: SATA max UDMA/133 irq 35
[    6.797332] ata3: SATA max UDMA/133 abar m1024@0xe0000000 port 0xe0000100 irq 36
[    6.804814] ata4: SATA max UDMA/133 abar m1024@0xe0000000 port 0xe0000180 irq 36
[    6.812264] ata5: DUMMY
[    6.940425] ata1: SATA link down (SStatus 0 SControl F300)
[    7.259290] ata2: SATA link down (SStatus 0 SControl F300)
[    7.264885] ata3: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
[   12.514064] ata3.00: qc timeout after 5000 msecs (cmd 0xec)
[   12.519721] ata3.00: failed to IDENTIFY (I/O error, err_mask=0x4)
[   12.840401] ata3: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
[   23.010047] ata3.00: qc timeout after 10000 msecs (cmd 0xec)
[   23.015768] ata3.00: failed to IDENTIFY (I/O error, err_mask=0x4)
[   23.021916] ata3: limiting SATA link speed to 1.5 Gbps
[   23.340394] ata3: SATA link up 1.5 Gbps (SStatus 113 SControl 310)
[   54.242046] ata3.00: qc timeout after 30000 msecs (cmd 0xec)
[   54.247764] ata3.00: failed to IDENTIFY (I/O error, err_mask=0x4)
[   54.568395] ata3: SATA link up 1.5 Gbps (SStatus 113 SControl 310)
[   54.888394] ata4: SATA link down (SStatus 0 SControl 300)
. . .
done.
. . .
BusyBox v1.35.0 (Debian 1:1.35.0-4+b3) built-in shell (ash)
Enter 'help' for a list of built-in commands.

(initramfs) fdisk -l
Disk /dev/sda: 14 GB, 15489564672 bytes, 30253056 sectors
1883 cylinders, 255 heads, 63 sectors/track
Units: sectors of 1 * 512 = 512 bytes

Device  Boot StartCHS    EndCHS        StartLBA     EndLBA    Sectors  Size Id Type
/dev/sda1    0,32,33     1023,254,63       2048   30251007   30248960 14.4G  c Win95 FAT32 (LBA)
(initramfs)
When it was recognized
U-Boot 2022.04 (Apr 11 2022 - 15:58:53 +0200)
NAS 440
. . .
Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 6.1.0-25-marvell ([email protected]) (gcc-12 (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #1 Debian 6.1.106-3 (2024-08-26)
[    6.629790] ata1: SATA max UDMA/133 irq 36
[    6.633948] ata2: SATA max UDMA/133 irq 36
[    6.794307] ata3: SATA max UDMA/133 abar m1024@0xe0000000 port 0xe0000100 irq 35
[    6.801785] ata4: SATA max UDMA/133 abar m1024@0xe0000000 port 0xe0000180 irq 35
[    6.809236] ata5: DUMMY
[    7.182054] ata3: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
[    7.270128] ata2: SATA link down (SStatus 0 SControl F300)
[   12.258062] ata3.00: qc timeout after 5000 msecs (cmd 0xec)
[   12.263717] ata3.00: failed to IDENTIFY (I/O error, err_mask=0x4)
[   12.584394] ata3: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
[   13.082513] ata3.00: ATA-8: WDC WD15EARS-00Z5B1, 80.00A80, max UDMA/133
[   13.089194] ata3.00: 2930277168 sectors, multi 0: LBA48 NCQ (depth 0/32)
[   13.112734] ata3.00: configured for UDMA/133
[   13.452396] ata4: SATA link down (SStatus 0 SControl 300)
[   13.713305] sd 2:0:0:0: [sda] 2930277168 512-byte logical blocks: (1.50 TB/1.36 TiB)
[   13.730194] sd 2:0:0:0: [sda] Write Protect is off
[   13.736856] sd 2:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[   13.746137] sd 2:0:0:0: [sda] Preferred minimum I/O size 512 bytes
[   13.766262]  sda: sda1
[   13.769639] sd 2:0:0:0: [sda] Attached SCSI disk
[   14.659935] scsi 5:0:0:0: Direct-Access     Generic  STORAGE DEVICE   0819 PQ: 0 ANSI: 6
[   15.009538] sd 5:0:0:0: [sdb] 30253056 512-byte logical blocks: (15.5 GB/14.4 GiB)
[   15.018054] sd 5:0:0:0: [sdb] Write Protect is off
[   15.023779] sd 5:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[   15.041663]  sdb: sdb1
[   15.047500] sd 5:0:0:0: [sdb] Attached SCSI removable disk
[   44.328400] ata3: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
[   44.339972] ata3.00: configured for UDMA/133
. . .
BusyBox v1.35.0 (Debian 1:1.35.0-4+b3) built-in shell (ash)
Enter 'help' for a list of built-in commands.

(initramfs) fdisk -l
Disk /dev/sda: 1397 GB, 1500301910016 bytes, 2930277168 sectors
182401 cylinders, 255 heads, 63 sectors/track
Units: sectors of 1 * 512 = 512 bytes

Device  Boot StartCHS    EndCHS        StartLBA     EndLBA    Sectors  Size Id Type
/dev/sda1    0,32,33     1023,254,63       2048 2930274303 2930272256 1397G  7 HPFS/NTFS
Disk /dev/sdb: 14 GB, 15489564672 bytes, 30253056 sectors
1883 cylinders, 255 heads, 63 sectors/track
Units: sectors of 1 * 512 = 512 bytes

Device  Boot StartCHS    EndCHS        StartLBA     EndLBA    Sectors  Size Id Type
/dev/sdb1    0,32,33     1023,254,63       2048   30251007   30248960 14.4G  c Win95 FAT32 (LBA)
(initramfs)

I'm not sure, but I think that two Seagate ST1000DM 003-9YN162 came with BA440 when I bought it. It was a long time ago, but I'm positive that it came with four Seagate 1 TB drives...

This is a list of all disks that I could find to test:

Disks that work:
ST1000DM 003-9YN162
ST2000DM 008-2FR102
Disks that don't work
ST920042 0AS
TOSHIBA DT01ACA100
WDC WD10 02FAEX-00Z3A0
WDC WD10 03FBYX-01Y7B1
WDC WD10 EADS-00L5B1
WDC WD10 EARS-00Y5B1
WDC WD10 EZEX-00BN5A0
WDC WD10 JFCX-68N6GN0
WDC WD10 JPVX-00JC3T0
WDC WD15 EADS-00P8B0
WDC WD15 EARS-00MVWB0
WDC WD15 EARS-00Z5B1
WDC WD20 EARS-00J2GB0
WDC WD20 EARX-00PASB0
WDC WD20 EZRX-00D8PB0
WDC WD64 00AAKS-22A7B0

@bbuljan
Copy link
Author

bbuljan commented Oct 10, 2024

Also, when NAS is booted from the disk in Slot1, it recognizes WD and Toshiba disks in Slot2, Slot3 and Slot4.

Slot 3
[  188.488022] ata1: link is slow to respond, please be patient (ready=0)
[  191.371830] ata1: SATA link up 3.0 Gbps (SStatus 123 SControl F300)
[  191.519807] ata1.00: ATA-8: WDC WD1003FBYX-01Y7B1, 01.01V02, max UDMA/133
[  191.526668] ata1.00: 1953525168 sectors, multi 0: LBA48 NCQ (depth 31/32)
[  191.537185] ata1.00: configured for UDMA/133
[  191.542024] scsi 0:0:0:0: Direct-Access     ATA      WDC WD1003FBYX-0 1V02 PQ: 0 ANSI: 5
[  191.561384] sd 0:0:0:0: [sdb] 1953525168 512-byte logical blocks: (1.00 TB/932 GiB)
[  191.572161] sd 0:0:0:0: Attached scsi generic sg1 type 0
[  191.582700] sd 0:0:0:0: [sdb] Write Protect is off
[  191.591964] sd 0:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[  191.611976] sd 0:0:0:0: [sdb] Preferred minimum I/O size 512 bytes
[  191.641152]  sdb: sdb1
[  191.644063] sd 0:0:0:0: [sdb] Attached SCSI disk
blackarmor:~$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda      8:0    0   1.8T  0 disk
├─sda1   8:1    0   1.8T  0 part /
├─sda2   8:2    0     1K  0 part
└─sda5   8:5    0   480M  0 part [SWAP]
sdc      8:32   0 931.5G  0 disk
└─sdc1   8:33   0 931.5G  0 part
Slot2
[  308.710509] ata4: link is slow to respond, please be patient (ready=0)
[  311.714431] ata4: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
[  316.742664] ata4.00: qc timeout after 5000 msecs (cmd 0xec)
[  316.748358] ata4.00: failed to IDENTIFY (I/O error, err_mask=0x4)
[  317.068617] ata4: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
[  317.080115] ata4.00: ATA-8: WDC WD1003FBYX-01Y7B1, 01.01V02, max UDMA/133
[  317.086996] ata4.00: 1953525168 sectors, multi 0: LBA48 NCQ (depth 0/32)
[  317.096557] ata4.00: configured for UDMA/133
[  317.101433] scsi 3:0:0:0: Direct-Access     ATA      WDC WD1003FBYX-0 1V02 PQ: 0 ANSI: 5
[  317.123873] sd 3:0:0:0: [sdb] 1953525168 512-byte logical blocks: (1.00 TB/932 GiB)
[  317.131944] sd 3:0:0:0: Attached scsi generic sg1 type 0
[  317.142413] sd 3:0:0:0: [sdb] Write Protect is off
[  317.154456] sd 3:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[  317.170461] sd 3:0:0:0: [sdb] Preferred minimum I/O size 512 bytes
[  317.200396]  sdb: sdb1
[  317.203322] sd 3:0:0:0: [sdb] Attached SCSI disk
blackarmor:~$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda      8:0    0   1.8T  0 disk
├─sda1   8:1    0   1.8T  0 part /
├─sda2   8:2    0     1K  0 part
└─sda5   8:5    0   480M  0 part [SWAP]
sdb      8:16   0 931.5G  0 disk
└─sdb1   8:17   0 931.5G  0 part

@bbuljan
Copy link
Author

bbuljan commented Oct 23, 2024

So, an update...

I was able to get LCD working, using NAS440.c code, libgpiod2 library and python3-libgpiod library.
See: https://github.com/brgl/libgpiod/

sudo apt-get install gpiod libgpio2 python3-libgpiod

With gpiod you get a set of tools to check, set and get GPIOs from the command line.

Here is the current Python script: lcd-test.zip

What is working

  • writing text to both rows of LCD
  • turning the backlight on/off
  • clear screen

What is not working

  • turning the display on/off (not of any importance to me...)

In the script, there is a function to turn the LEDs on/off for disks and the front panel system. I need to upgrade further this because I need to turn on/off individual LEDs. On the previous system (Lenny) I was able to change the individual disk LED to red and flashing red. Do not know how to do that with GPIO. The previous system had drivers for the LCD and LED and it is obviously achievable.

TODO:

  • Add support for buttons (in this script for proof of concept, then as a service)
  • Dig deeper to find how LEDs can be made to flash
  • Rewrite the Python script(s) to c/c++

About the LEDs:

On my board, four disk LEDs are connected with one pin to the shift register (that can be turned on/off through the GPIO pins) and the other two pins (for red and green colour) to the four OR and four NAND gates output (two ICs; SN54LVC32A and 74LVC00A). I didn't trace the inputs to these ICs, maybe later. I guess they are used to set up flash behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants