Buffalo NAS-Central Forums

Welcome to the Linkstation Wiki community
It is currently Sun Feb 18, 2018 6:04 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 55 posts ]  Go to page Previous 1 2 3 4 Next
Author Message
PostPosted: Sat May 08, 2010 5:17 pm 
Offline
Newbie

Joined: Fri Apr 09, 2010 10:22 am
Posts: 12
Hello fvdw

I've seen you have problems with fanctld on other HDD's as Hitachi.

I modified the fanctld (mvsata.c) for kernel 2.6.33 , there is no problem
on my WD5001AALS-00L3B2.

Only noflushd make problems, the disk spindown after 15 minutes because after
5-10 minutes it spins up without any activity, do you have an idea.

How do you activate the cpu-led, i am use the cpu-activity-trigger.


Top
   
PostPosted: Sun May 09, 2010 10:43 pm 
Offline
Regular Member

Joined: Tue Sep 09, 2008 10:28 pm
Posts: 201
No there is no problem with fan control, its only a matter of choice.
The fan works and also the control of it and it works as I designed it for the moment , it switches the fan off when the hdd has spin down and on when the HDD is spinning, it checks every 5 minutes if the disk is spinning or not. It will do that regardless of the brand of the disk. I use hdparm to get info from the drive. I don't fiddle with the sata driver. Too risky.
Now hdparm can also be use to get info from the drive regarding temperature but that only works for hitachi drives.
The original hdd in the nas were I use this kernel is an Hitachi disk but several persons exchanged it by a bigger one from another brand, so the original fan daemon won't work as it can not the HDD temp. I adapted it to let it look if the HDD is spinning or not. For Hitachi drives I will add the temp check as well again as some user like that as it makes the fan not unnecessary run. In fact it has nothing to do with the kernel.

Spin down disk
The reason why it spin up again is because some program or daemon is writing to disk, I found that the nmb daemon (used in the samba server) is one of the programs causing this. This can also not be solved in the kernel. I solved it by using a small ramdisk for certain files.

Cpu-led ? I don't use leds for cpu activity.
There are two leds on my system, one I use as power led and the other as hdd activity led.
To get the power led on is easy using the appropriate gpio pin settings, to get the other led work with activity of the sata disk is another story, to long to explain now, when I am finished with it I will publish what I have done.
The next issue you will encounter are reboot and standby commands. The standard commands of the linux kernel won't work for this system board, just try a reboot command and you will see that it fails, the system will halt.

On which system are you using your kernel ?


Top
   
PostPosted: Mon May 10, 2010 5:38 pm 
Offline
Newbie

Joined: Fri Apr 09, 2010 10:22 am
Posts: 12
I have a spd8020cc with a Western Digital 500Gb HDD
reboot and shutdown works fine, also the buttons
you are right, when disconnect the lan the hdd sleep

mvsata.c isn't the sata driver it is in the source of fanctld

Code:
diff -rNu fanctld.orig/mrvlsata.c fanctld/mrvlsata.c
--- fanctld.orig/mrvlsata.c   2007-06-05 12:08:06.000000000 +0200
+++ fanctld/mrvlsata.c   2010-05-07 16:12:41.000000000 +0200
@@ -24,12 +24,10 @@
 #include "mvsata.h"
 #include <stdio.h>
 
-typedef struct { 
-    int  inlen;
-    int  outlen;
-    char cmd[540];
-} mvsata_scsi_cmd;
-
+#ifndef HDIO_DRIVE_CMD_HDR_SIZE
+#define HDIO_DRIVE_CMD_HDR_SIZE    4
+#endif
+#define HDIO_DRIVE_CMD 0x031f
 
 
 // ATA Specification Command Register Values (Commands)
@@ -117,46 +115,51 @@
 //   byte 202: maximum hda temperature in celsius in 2'complement
 //   byte 204: maximum hda temperature in celsius in 2'complement seen for the life of the drive
 //   byte 10:  drive status
-//   
+//
+#define STRANGE_BUFFER_LENGTH (4+512*0xf8)
+
 int mvsataGetDriveInfo(int fd,int* currentTemp,int* maxTemp,int* maxTempLife,int* drive_status)
 {
-  mvsata_scsi_cmd  command;
-  unsigned char *buff = (unsigned char *)&command.cmd[6];
-  int ret=0;

-  // clear out buff.  Large enough for HDIO_DRIVE_CMD (4+512 bytes)
-  memset(&command, 0, sizeof(command));
-  command.inlen = 540;
-  command.outlen = 540;
-  command.cmd[0] = 0xC;  //Vendor-specific code
-  command.cmd[4] = 6;     //command length
+   unsigned char buff[STRANGE_BUFFER_LENGTH];
+     int ret=0;
+   // See struct hd_drive_cmd_hdr in hdreg.h
+     // buff[0]: ATA COMMAND CODE REGISTER
+     // buff[1]: ATA SECTOR NUMBER REGISTER
+     // buff[2]: ATA FEATURES REGISTER
+     // buff[3]: ATA SECTOR COUNT REGISTER
   
+     // clear out buff.  Large enough for HDIO_DRIVE_CMD (4+512 bytes)
+   memset(buff, 0, STRANGE_BUFFER_LENGTH);
+
+
   buff[0] = ATA_SMART_CMD;
-  buff[1] = 0xE0;
-  buff[2] = ATA_SMART_READ_LOG_SECTOR;
+  buff[1] = 0xE0;  //ATA_STANDBY_IMMEDIATE           
+  buff[2] = ATA_SMART_READ_LOG_SECTOR;
   buff[3] = 1;
 
 
-  if (ret=ioctl(fd, SCSI_IOCTL_SEND_COMMAND, (void *)&command)) {
+  if ((ret=ioctl(fd, HDIO_DRIVE_CMD, buff))) {
    return -1;
   }
-
-  if (buff[200] == 0x80) { // a value of 0x80 indicates an invalid temperature value


+  if (buff[204] == 0x80) { // a value of 0x80 indicates an invalid temperature value
+     printf("invalid temperature value");
    return -1;
   }   
 
   if (currentTemp) {
-     *currentTemp = buff[200];
+     *currentTemp = buff[204];
   }
 
   if (maxTemp) {
-     *maxTemp = buff[202];
+     *maxTemp = buff[206];
   }
   if (maxTempLife) {
-     *maxTempLife = buff[204];
+     *maxTempLife = buff[208];
   }
   if (drive_status) {
-     *drive_status = buff[10];
+     *drive_status = buff[14];
   }    
   return 0; 
 }
diff -rNu fanctld.orig/mvsata.c fanctld/mvsata.c
--- fanctld.orig/mvsata.c   2007-06-05 12:08:06.000000000 +0200
+++ fanctld/mvsata.c   2010-05-06 23:28:20.000000000 +0200
@@ -24,13 +24,10 @@
 #include "mvsata.h"
 #include <stdio.h>
 
-typedef struct { 
-    int  inlen;
-    int  outlen;
-    char cmd[540];
-} mvsata_scsi_cmd;
-
-
+#ifndef HDIO_DRIVE_CMD_HDR_SIZE
+#define HDIO_DRIVE_CMD_HDR_SIZE    4
+#endif
+#define HDIO_DRIVE_CMD 0x031f
 
 // ATA Specification Command Register Values (Commands)
 #define ATA_IDENTIFY_DEVICE             0xec                                             
@@ -130,27 +127,31 @@
 //   byte 202: maximum hda temperature in celsius in 2'complement
 //   byte 204: maximum hda temperature in celsius in 2'complement seen for the life of the drive
 //   byte 10:  drive status
-//   
+//
+#define STRANGE_BUFFER_LENGTH (4+512*0xf8)

 int mvsataGetDriveInfo(int fd,int* currentTemp,int* maxTemp,int* maxTempLife,int* drive_status)
 {
-  mvsata_scsi_cmd  command;
-  unsigned char *buff = (unsigned char *)&command.cmd[6];
-  int ret=0;

-  // clear out buff.  Large enough for HDIO_DRIVE_CMD (4+512 bytes)
-  memset(&command, 0, sizeof(command));
-  command.inlen = 540;
-  command.outlen = 540;
-  command.cmd[0] = 0xC;  //Vendor-specific code
-  command.cmd[4] = 6;     //command length
+   unsigned char buff[STRANGE_BUFFER_LENGTH];
+     int ret=0;
+   // See struct hd_drive_cmd_hdr in hdreg.h
+     // buff[0]: ATA COMMAND CODE REGISTER
+     // buff[1]: ATA SECTOR NUMBER REGISTER
+     // buff[2]: ATA FEATURES REGISTER
+     // buff[3]: ATA SECTOR COUNT REGISTER
   
+     // clear out buff.  Large enough for HDIO_DRIVE_CMD (4+512 bytes)
+   memset(buff, 0, STRANGE_BUFFER_LENGTH);
+
+
   buff[0] = ATA_SMART_CMD;
   buff[1] = 0xE0;  //ATA_STANDBY_IMMEDIATE           
+//  buff[2] = ATA_SMART_READ_LOG_SECTOR;
   buff[2] = ATA_SMART_READ_LOG_SECTOR;
   buff[3] = 1;
 
 
-  if (ret=ioctl(fd, SCSI_IOCTL_SEND_COMMAND, (void *)&command)) {
+  if ((ret=ioctl(fd, HDIO_DRIVE_CMD, buff))) {
    *currentTemp=42;
    fan_enable();
    DBG_PRINT("FANCTLD: SCSI_IOCTL_SEND_COMMAND, returned nonzero \n");
@@ -158,8 +159,10 @@
    exit(2);
 //      return -1;
   }

 
-  if (buff[200] == 0x80) { // a value of 0x80 indicates an invalid temperature value
+  if (buff[204] == 0x80) { // a value of 0x80 indicates an invalid temperature value
+  printf("invalid temperature value");
    *currentTemp=42;
    fan_enable();
 //   return -1;
@@ -167,19 +170,19 @@
 
   if (currentTemp) {
      if(!ret)
-        *currentTemp = buff[200];
+        *currentTemp = buff[204];
      if(*currentTemp == 0)
         *currentTemp=42;
      DBG_PRINT("CURRENT TEMPERATURE = %d \n", *currentTemp);
   }
   if (maxTemp) {
-     *maxTemp = buff[202];
+     *maxTemp = buff[206];
   }
   if (maxTempLife) {
-     *maxTempLife = buff[204];
+     *maxTempLife = buff[208];
   }
   if (drive_status) {
-     *drive_status = buff[10];
+     *drive_status = buff[14];
   }    
   return 0; 
 }


ps: Is it possible to write german, my english isn't very good


Top
   
PostPosted: Mon May 10, 2010 9:10 pm 
Offline
Regular Member

Joined: Tue Sep 09, 2008 10:28 pm
Posts: 201
Hi firemax

No problem, you can write german, i can read that perfectly.
I see what you mean regarding mvsata.c
Are you using my kernel or did you compile your own kernel ?


Top
   
PostPosted: Tue May 11, 2010 6:30 pm 
Offline
Newbie

Joined: Fri Apr 09, 2010 10:22 am
Posts: 12
Hallo fvdw

Ich benutze meinen eigenen Kernel, da deiner noch nicht so lange öffentlich ist.
Es hat mich auch interessiert, wie man Standby und Reboot für das SPD8020CC
realisiert, wie auch die Geschichte mit den Buttons.

Ja und du hast recht, es ist nicht viel code, aber bist man weiß, wie es
funktioniert dauert eine Weile.

Mich interessiert es natürlich, wie deine spd8020_cc-setup.c aussieht.
Gestern startete ich einen Versuch mit hdparm, leider kann dieses Programm nur
die Temperatur der Hitachi-HDD's auslesen, was mir mit meiner WD nicht hilft.
Mit dem Patch von mvsata.c funktiert es wunderbar, sogar der Status der HDD wir ausgelesen,
gleich wie bei der Hitachi-Platte.

Für noflushd hätte ich auch noch einen Patch auf Lager, aber in diesem Thread geht's ja eigentlich
nur um den orion-kernel.

Leider konnte ich bis jetzt die zweite Led(gpio 3) nur mit einer veränderten Version des led-cpu-triggers(Original von Thomas Tuttle) lösen,
aber ein kleiner Tip, wie du die HDD-Aktivität anzeigst wäre gut.


Top
   
PostPosted: Tue May 11, 2010 8:36 pm 
Offline
Regular Member

Joined: Tue Sep 09, 2008 10:28 pm
Posts: 201
You probably know the existence of the ide-trigger. Of course this doesn't work for a sata drive, to get it in the first place as option in the kernel config you need to set the config file that the ide drivers are compiled, then you can choose the ide-trigger option in the trigger section.
(config_ide=y config_ide_gd=y and config_ide_gd_ata=y)

of course you can also change some makefiles to let it be compiled

Now it will still not work as the sata drive doesn't use the ide driver. To make it work one line of code must be added in the marvell sata driver on the correct place. For this I tried several place and finally decided to put it at a certain place were it seems to do the job.
The driver you can find in the linux folder /drivers/ata and has name sata_mv.c

I did following
added in the top at the usual place for such an instruction, actually I inserted this at line 71

#include <linux/leds.h>

and I added at line 1143 in routine mv_start_edma the instruction

ledtrig_ide_activity();

copy from this part of the driver

Code:
static void mv_start_edma(struct ata_port *ap, void __iomem *port_mmio,
          struct mv_port_priv *pp, u8 protocol)
{
   int want_ncq = (protocol == ATA_PROT_NCQ);
        ledtrig_ide_activity();

   if (pp->pp_flags & MV_PP_FLAG_EDMA_EN) {


and last to make it work give at the command line following instruction to set the trigger
echo ide-disk > /sys/class/leds/sata0:blue/trigger

In my case I used the name sata0 in setup file for this second led

ps did you use my ext3 en ext2 file system driver fix as well, if you don't do that you might get oom errrors at large ext3 foiles system and slow response on large ext2 partitions, see some previous posts in this thread.


Top
   
PostPosted: Fri May 14, 2010 9:37 pm 
Offline
Regular Member

Joined: Tue Sep 09, 2008 10:28 pm
Posts: 201
@firemax

any idea were I can find some info on which byte contains what in buff array when using the HDIO_DRIVE_CMD as you described

I also interested in knowing what values the disk status byte can return and what they mean

could use that in my firmware to make a nice disk info tool
thks


Top
   
PostPosted: Sat May 15, 2010 8:54 am 
Offline
Newbie

Joined: Fri Apr 09, 2010 10:22 am
Posts: 12
@fvdw
Leider weiß ich nicht welche Werte noch im buffer-array stehen, ist aber eine gute Idee.
Als Disk-Info-Tool kann ich dir smartmontools 5.1-14 empfehlen, ist in den spd8020cc_Sourcen includiert.
Du brauchst nur am Ende der Datei smartctl.c diese Änderung machen.

Code:
  // now call appropriate ATA or SCSI routine
  if (tryata)
    retval = ataPrintMain(fd);
  else if (tryscsi)
   // retval = scsiPrintMain(device, fd);
      retval = ataPrintMain(fd);
  else {
    pout("Smartctl: specify if this is an ATA or SCSI device with the -d option.\n");
    Usage();
    return FAILCMD;
  }


Eventuell funktioniert eine neuere Version ohne Patch.

Disk-Activity mittels ide-disk hat super funktioniert, aber ich habe mir einen eigenen cpu-activity-trigger geschrieben,
der mir den cpu-idle Status aus arm/kernel/process.c liefert, gleich wie beim Original-Kernel.

Eine Frage noch zu deiner Firmware:
Funktioniert bei dir der RTC-Zeitgeber, da ich gesehen habe, dass du RTC_DRV_DS1307 als Modul kompilierst, aber dieses
nicht in der rcS einbindest.

Den ext3-patch muss ich erst einfügen, hatte bis jetzt noch keine Probleme, da ich noch keine großen Dateien
geschrieben habe.

Ich hätte noch 2 Sachen für deiner Firmeware:
> Mini-Printserver mittels p910nd (nur Weiterleitung von lan auf usb)
> Proftpd mit SSL-Verschlüsselung und Start mittels xinetd wegen Zugriff über dyndns (Masquerade)

Jetzt wäre noch interessant, ob bei anderen HDD's fanctld auch funktioniert, bis jetzt wissen wir ja nur, dass es bei Hitachi
und Western Digital 500Gb funktioniert.


Top
   
PostPosted: Sat May 15, 2010 10:11 am 
Offline
Newbie

Joined: Fri Apr 09, 2010 10:22 am
Posts: 12
@fvdw
Vielleicht hilft dir diese Beschreibung weiter.

http://www.hitachigst.com/tech/techlib.nsf/techdocs/85CC1FF9F3F11FE187256C4F0052E6B6/$file/80GNSpec2.0.pdf


Top
   
PostPosted: Sat May 15, 2010 12:06 pm 
Offline
Regular Member

Joined: Tue Sep 09, 2008 10:28 pm
Posts: 201
thks for the feedbacks firemax

I wrote a small c program that other can use form the command line to test if it works on anther HDD brands. I posted it on the convopit forum.

http://convopit.org/forum3/download/file.php?id=9868

It outputs the disk actual temp, max temp since start, max allowed temp and the disk status.
This binary should work on all platforms with same ARM9 processor and a recent kernel

I got already one reply from someone using a samsung drive and it worked ok.
I got also a reply from someone using a Hitachi drive, of course temp reading works fine but he got as disk status return the value "4" . No idea what that means. I get as response in for disk status 0 in case the disk is spinning/active and 1 when it is not spinning.
Maybe this hitachi document gives some info, need to read it.

About RTC. The system clock seems to run ok and can be adjusted, I also use some timers in the buttons daemon so I gues it is working, or do I miss the point ? I am not a trained C expert, my skills I build over the last year in playing with this little NAS by trial and error and reading from others. So how should I test if RTC is working as it should, do you have problems ?
Yes i compiled that DS1307 as module but I don't use it, it is a leftover from config settings in the old kernel. Think that chip is not on board, at least I can not find it on the system board.
In the spd8020 setup file the RTC ds1388a is defined and included (I did not change that part of the file from pbg4). Think it is included in the processor.

The ext2/ext3 patch you will really need when you have a larger file system.

Thks for the other tips as well, I will look at them, nice to see that also someone else is trying to get more out of this little device


Top
   
PostPosted: Sat May 15, 2010 2:24 pm 
Offline
Newbie

Joined: Fri Apr 09, 2010 10:22 am
Posts: 12
RTC ist die Hardware Uhr und ist auch vorhanden, sie wird benötigt,
um richtige Uhrzeit beim Systemstart anzuzeigen.
Mir ist es nur aufgefallen, als ich deine uImage.config verwendete und daraufhin
"date" 1.1.1970 lieferte.

Testen kan man mit dem Befehl "hwclock -r".

Mir gehts mit C auch nicht besser, viel lesen, viel probieren.


Top
   
PostPosted: Sat May 15, 2010 3:49 pm 
Offline
Regular Member

Joined: Tue Sep 09, 2008 10:28 pm
Posts: 201
well this command gives that it could not access RTC, but the date command shows a nice and correct time
The firmware sets it using an Internet server.
have to look into that

Code:
~ # hwclock -r
hwclock: Could not access RTC: No such file or directory
~ # date
Sat May 15 15:42:52 GMT+1 2010
~ #


ps I also succeeded to compile the latest busybox for this processor, the one included in the original version of Philips was limited in options. I also tried that one to see if this hwclock command works, it gave this result
Code:
~ # busybox2 hwclock -r
hwclock: can't open '/dev/misc/rtc': No such file or directory


Top
   
PostPosted: Sat May 15, 2010 8:40 pm 
Offline
Newbie

Joined: Fri Apr 09, 2010 10:22 am
Posts: 12
RTC wird benötigt, wenn die Zeit nicht via Internet aktualisiert wird, sondern
im Web-Interface einstellst, kommt sonst eine Fehlermeldung.

Im spd8020 setup file wird der RTC-Chip nur aktiviert, der Treiber ist trotzdem nötig.

Ist die busybox2 die Originale oder die neu Kompilierte, da /dev/rtc der richtige Device wäre.
Wenn du das RTC-Modul lädst, ist es auf /dev/rtc0 zugewiesen, dann ist noch ein symlink auf /dev/rtc
nötig, da hwclock darauf zugreift.

Ich kompilie den Treiber immer gleich in den Kernel, als Modul habe ich es noch nicht versucht.


Top
   
PostPosted: Sat May 15, 2010 9:16 pm 
Offline
Regular Member

Joined: Tue Sep 09, 2008 10:28 pm
Posts: 201
thats correct

I loaded the ds1307.ko kernel module and made /dev/rtc a sym link to /dev/rtc0

now the hwclock command works.
Code:
~ # hwclock -r
Sat May 15 21:13:08 2010  0.000000 seconds
~ #


the busybox2 is a full version of BusyBox v1.15.3, the original one seem to be version 1.01.
This hwclock in this newer version can find rtc devices at other locations as well, the version of hw clock in the old busybox only looks in /dev/rtc. But a simple sym link solves that problem

Agree that it is better to compile this driver in the kernel, thks for the tip

--edit
recompiled the kernel and now the RTC is found and system time is now set during boot.
thks firemax

Code:
i2c /dev entries driver
rtc-ds1307 0-0068: rtc core: registered ds1338 as rtc0
rtc-ds1307 0-0068: 56 bytes nvram
Registered led device: power:blue
Registered led device: sata0:blue
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
TCP cubic registered
NET: Registered protocol family 17
VFP support v0.3: not present
rtc-ds1307 0-0068: setting system clock to 2010-05-15 21:58:35 UTC (1273960715)


Top
   
PostPosted: Sun May 16, 2010 1:45 pm 
Offline
Newbie

Joined: Fri Apr 09, 2010 10:22 am
Posts: 12
@fvdw
HDD-Status:
Bei meiner Western Digital liefert hdstatus-spd
drive-status = 4
Das sollte eigentlich passen, da fanctld -d /dev/sda in der orig. Firmware
und orig. Hitachi-HDD
im Betrieb als drive-status "smartodc_bg" und
im Standby "standby" liefert.

drive-status Werte:
0 = "active"
1 = "standby"
2 = "sleep"
3 = "dst_bg"
4 = "smartodc_bg"
5 = "sct_bg"

Leider weiß ich nicht für was "smartodc_bg" steht.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 55 posts ]  Go to page Previous 1 2 3 4 Next

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Powered by phpBB® Forum Software © phpBB Limited