Category:ShareSpace

From NAS-Central Western Digital Wiki
Jump to: navigation, search
ShareSpace.jpg
ShareSpace
Board Manufacturer Wistron
CPU Marvell 88F5182 @ 500MHz
RAM 512 MB
Flash ROM 16 MB
Other
NIC 10/100/1000BASE-T, probably Marvell 88E8111 or 88E8118
USB 3 x USB 2.0 ports, Genesys GL850A USB Hub Controller
internal HDD
IDE Controller Marvell 88SX7042 4 Port SATA controller
Drive Capacity
Fan
OS Linux 2.6.12.6-arm1 #31 Wed Feb 25 11:58:13 CST 2009 armv5tejl unknown
Source code Provided by Western Digital

Contents


Boot process

The system boots on a flash disk, and uses U-Boot as a boot manager.

The u-boot environment is on /dev/mtd1 you can dump this to a file using 'dd if=/dev/mtd1 of=./u-boot.env' Use 'strings u-boot.env' to see the entries.

The environment suggests that u-boot on the device is capable of booting using tftp to retrieve a uImage and nfs to mount the root filesystem.

Flash disk

Note: After the system startup, the flash disk is still mounted on /old.

U-Boot first run /etc/rc.preroot, which does some checks on HDD and RAID states, and try to recover if something wrong is detected.
It also does a firmware update if requested to be done at this time.
If everything is fine, it mounts the root filesystem from the RAID, and starts its init.

Root filesystem

/etc/rc.preroot from the flash disk runs init here.

/etc/inittab

This file is read by init to know what it should do, here is the sequence we can find in it:

  • mount proc on /proc
  • mount usbfs on /proc/bus/usb
  • mount devpts on /dev/pts
  • mount trusteesfs on /trustees
  • Activate the swap from /dev/md1
  • Set the hostname
  • Run /etc/init.d/rcS
  • Loads module /lib/modules/2.6.12.6-arm1/usblp.ko
  • touch /var/log/messages
  • Run /etc/init.d/rcS (AGAIN???)

/etc/init.d/rcS

This file is responsible of the main startup process, here is the sequence we can find in it:

  • Reset the system state:
    • Removes /etc/.ready and /etc/.fw_is_updating
    • Set the status to "10@01"
  • Starts the network: /etc/init.d/S40network restart
  • Starts the webserver: /etc/init.d/S55mini_httpd restart
  • Check the system date to see if it's past year 2000, if not, set the date 01/01/2000 (why?)
  • Enables the HDD led blinking
  • Activate Data and Extend volumes
  • Starts system restoration if needed
  • Check if Mionet is installed, and install it if not
  • Update disks informations, and activate SMART on them
  • Create the filesystem and the default shares on Data volume if needed
  • Check the system state:
    • If it is "system_tested_ok", mount the filesystems (/etc/init.d/S01auto_mountd start), run /usr/bin/runin.sh, and exit.
    • If it is "runin_tested_ok", "runin_tested_failed", or "final_tested_failed", makes SYS ERROR led blinks as expected, start telnet, and exit.
  • Starts /proto/SxM_webui/admin/tools/coldswap.php
  • Loads module /lib/modules/2.6.12.6-arm1/wixbtn.ko
  • Makes SYS STATUS led blinks
  • Remove all usb storage setting
  • Run all the scripts which name starts with "S" in /etc/init.d/
  • Starts I/O Monitor for HDD standby
  • Check the existence of /etc/.shutdownflag:
    • If it exists, send the event "system abnormalshutdown"
    • Else, create it
  • Send the event "system startup"

Wistron tools

Wistron provides some kernel drivers to set and get events related to their board, as well as some tools to use them.

Sharespace leds

/proc/wixgpio

These files controls the GPIO provided by Wistron.
They are mainly used to control the leds.

Next you'll find a list of all the files in this directory, with what they're controlling, and what effect does its values have.

  • gpio00: ID led
    • 0 | "on": If gpio01 is 0, the led is off, else it's red
    • 1 | "off": If gpio01 is 0, the led is blue, else it's off
  • gpio01: SYS ERROR led
    • 0 | "on": If gpio00 is 0, the led is off, else it's blue
    • 1 | "off": If gpio00 is 0, the led is red, else it's off
  • gpio02: unused
  • gpio03: unused
  • gpio04: HDD 4 led
    • 0 | "on": orange
    • 1 | "off": green
  • gpio05: HDD 3 led
    • 0 | "on": orange
    • 1 | "off": green
  • 'gpio06: SYS STATUS led
    • 0 | "on": green
    • 1 | "off": off
  • gpio07: unused, according to the kernel source.
    But used in /etc/rc.preroot from the flash drive to do some stuff with the hard drives???
  • gpio08: unused
  • gpio09: unused
  • gpio10: USB led
    • 0 | "on": off
    • 1 | "off": green
  • gpio11: unused
  • gpio12: unused, according to the kernel source.
    But used in /usr/bin/ledtest.sh and /usr/bin/runin_preroot.sh from the flash drive???
  • gpio13: unused, according to the kernel source.
    But used in /usr/bin/ledtest.sh and /usr/bin/runin_preroot.sh from the flash drive;
    and in /etc/rc.preroot from the flash drive to do some stuff with the hard drives???
  • gpio14: HDD 2 led
    • 0 | "on": orange
    • 1 | "off": green
  • gpio15: HDD 1 led
    • 0 | "on": orange
    • 1 | "off": green
  • gpio16: unused
  • gpio17: unused
  • gpio18: unused
  • gpio19: unused

Events list

Next you'll find a description of the events, the format is:

  • Type: Description.
    • Id: Description.
      • State: Description.
  • 1 | "system": System events.
    • 1 | "startup": System is starting.
    • 2 | "abnormalshutdown": System has stopped badly.
    • 4 | "shutdown": System is shutting down.
    • 8 | "reboot": System is rebooting.
    • 16: Identify state.
      • 1: On.
      • 2: Off.
    • 32 | "softwareupdate": Firmware update state.
      • 0: Success.
      • 1: Failure.
    • 64 | "factoryreset": Factory reset state.
      • Same as before.
    • 128 | "configurationrestore": Config restore state.
      • Same as before.
    • 256: Administrator login state.
      • Same as before.
  • 2 | "ups": UPS events.
    Note: In /etc/apcupsd/ you'll find some scripts that send UPS event.
    Anyway they use ids like 3 or 7.
    So either i'm a bad C programmer, or these are bad scripts.
    • 1: Communciations restored with UPS.
    • 2: Communications lost with UPS.
    • 4: Power failure on UPS. Running on batteries.
    • 8: Power has returned. Running on power.
    • 16: Power has returned on UPS or run on power.
    • 32: Power loss detected on UPS.
    • 64: UPS Doing shutdown.
    • 128: Battery power exhaused on UPS.
  • 4: Fan events.
    • 1: Fan 1.
      • 0: Normal.
  • 8: Thermal events.
    • 1: Thermal 1.
      • 1: Overheated.
  • 16 | "hdd": HDD events.
    Same note as UPS events.
    See /proto/SxM_webui/admin/tools/hotAdd.php and /proto/SxM_webui/admin/tools/writeDiskInfo.php
    • 1: HDD 1.
      • 0: Found.
      • 1: Absent.
    • 2: HDD 2.
      • Same as before.
    • 4: HDD 3.
      • Same as before.
    • 8: HDD 4.
      • Same as before.
  • 32: HDD SMART events.
    • 1: HDD 1.
      • 0: OK.
      • 1: Failed.
    • 2: HDD 2.
      • Same as before.
    • 4: HDD 3.
      • Same as before.
    • 8: HDD 4.
      • Same as before.
  • 64: Volume events.
    • 1: Volume 1.
      • 0: RAID normal.
      • 1: RAID degraded.
      • 2: RAID resyncing.
      • 4: Recover failed.
      • 8: Volume doesn't exists.
      • 4096: Created.
      • 8192: Deleted.
      • 16384: Modified.
    • 2: Volume 2.
      • Same as before.
    • 4: Volume 3.
      • Same as before.
    • 8: Volume 4.
      • Same as before.
  • 128: Volume usage events.
    • 1: Volume 1.
      • 0: 25~100% free capacity.
      • 1: More than 10% free capacity.
      • 2: More than 5% free capacity.
      • 4: Reached 80% capacity.
      • 8: Reached 95% capacity.
      • 16: Reached full capacity.
      • 32: Not mounted.
    • 2: Volume 2.
      • Same as before.
    • 4: Volume 3.
      • Same as before.
    • 8: Volume 4.
      • Same as before.
  • 256: Network events.
    • 1: LAN 1.
      • 0: Link ON.
      • 1: Link DOWN.
      • 2: Use dynamic IP address got from DHCP.
      • 4: Can not get IP address from DHCP, use default IP address.
      • 8: Use static IP address.
    • 2: LAN 2.
      • Same as before.
    • 4: Wireless LAN.
      • Same as before.
  • 512 | "usb": USB events.
    • 1: USB 1.
      • 0: USB Insertion.
      • 1: USB Safely removal.
      • 2: USB unsafely removal.
      • 4: USB format OK.
      • 8: USB format fail.
      • 16: USB Printer Found.
      • 32: USB Printer Absent.
    • 2: USB 2.
      • Same as before.
    • 4: USB 3.
      • Same as before.
    • 8: USB 4.
      • Same as before.
  • 1024: User events.
    • UID: The user uid.
      • 0: Quota below 70% utilization.
      • 1: Quota exceed 75% utilization.
      • 2: Quota exceed 90% utilization.
      • 4: Quota reached 100% utilization.
      • 8: Login failed 3 times.
  • 2048: Group events.
    • GID: The group gid.
  • 4096 | "fsck": Filesystem check events.
    • 1: Volume 1.
      • 2: Check needed.
    • 2: Volume 2.
      • Same as before.
    • 4: Volume 3.
      • Same as before.
    • 8: Volume 4.
      • Same as before.
  • 8192: Volume extend events.
    • 1: Volume 1.
    • 2: Volume 2.
    • 4: Volume 3.
    • 8: Volume 4.
  • 16384: Internal events.
    • 1: USB backup.
    • 2: RAID check.

Related programs

  • /usr/sbin/wixalarmdaemon: Handle events.
    When an event occurs, it checks /etc/eventtable.conf to know the level of it.
    Events of level informative and warning are written to log.
    Events of level critical are writen to /etc/.criticalevents so that the GUI can inform the user about it, and makes the ID / SYS ERROR led blink.
  • /usr/sbin/wixhwmonitor: Monitor fan, thermal and hdd states, and send events corresponding.
  • /usr/bin/wixled_blink: Makes the led blink.
    Usage: /usr/bin/wixled_blink gpioNN
  • /usr/bin/wixled_blink_fast: Makes the led blink fast.
    Usage: /usr/bin/wixled_blink_fast gpioNN
  • /usr/bin/wixled_hdd_blink: Seems to be the same as /usr/bin/wixled_blink.
  • /usr/bin/wixled_raid_blink: Seems to be the same as /usr/bin/wixled_blink.
  • /usr/bin/wixled_rebuild.sh: Makes gpio06 blink and light gpio10 every 3 seconds.
  • /usr/bin/wixled_rebuild_kill.sh: Cancel the action of /usr/bin/wixled_rebuild.sh and set the leds state to what they should be (system restore, usb backup, or nothing).
  • /usr/sbin/wixsendevent: Send a wixevent.
    Usage: /usr/sbin/wixsendevent type id [state] [value]

Serial Access

It is possible to gain access to a serial port on the device by hooking up a line-levelling serial cable (such as one used to connect a laptop to an older nokia phone) to CN2. CN2 is a 10-pin connector that can be found on the upper right hand side of the board as viewed when the case is off the unit.

The cable was a CA-42 clone cable bought from ebay and prepared according to these instructions to prepare a cable for the linkstation

The pin guide for CN2 is as follows -


 Pin 01234
     .....
     .....
 Pin 56789
 
Pin 0:
Pin 1:
Pin 2: 0V - GND
Pin 3: TX. 3.3V, drops to 1.84 when data is sent to /dev/ttyS0 using 'yes'
Pin 4:
Pin 5: +3.3V
Pin 6:
Pin 7:
Pin 8:
Pin 9: RX - discovered as it has registered 0.01V on multimeter, and when connected to Pin 3 with cu -s 115200 -l /dev/ttyS0 running, the terminal echoes input

Soldering on the appropriate wires from the CA-42 you can interact with the u-boot bootloader and linux serial console over the serial connection. This is hopefully the first step to custom firmware.


Notes

  • dpkg is installed, it needs to be tested in order to know if it can be used to install software on the NAS.
    All its configuration has been erased, obviously it will need to be rebuild in order to work

This category currently contains no pages or media.