Skip to content

Latest commit

 

History

History
1317 lines (1226 loc) · 87.3 KB

netgear-rn3138.org

File metadata and controls

1317 lines (1226 loc) · 87.3 KB

Netgear ReadyNAS RN3138

Hardware

The Netgear ReadyNAS 3138 is a 1U rack-mounted NAS server with 4 3.5” SATA drive slots. I have recently purchased such a device in order to use it as a small home fileserver and decided to play with it a small bit before placing it in production use on the network. The manufacturer part number on the sticker that I got was RN31843E which indicates, that the NAS was originally sold with 4 x 3TB disks inside (https://www.cdw.com/product/NETGEAR-ReadyNAS-Rackmount-4x3TB-Enterprise-Drives-RN31843E/3921155). I got it empty however so it’s just a plain RN3138.

All of the currently available information about the device has been moved to wikidevi.

Main board

netgear-rn3138/thumb-Netgear-RN3138-mainboard1.jpg

Connectors on the mainboard

DesignatorFootprintPinoutDescriptionNotes
J11x3 2.54mm DupontUnknownUnknown (possibly CMOS reset jumper)Unpopulated
J21x4 2.54mm Dupont1-3.3V, 2-RXD, 3-TXD, 4-GNDSerial console
J32x2 2mm DupontDocumented on WikideviSerial console
J4, J51x4 2.54mm DupontUnknownUnknownUnpopulated
LED1LEDUnknownUI LED (back)
S4microswitchWired to IT8732F pin 13 (GP35?)UnknownUnpopulated
S5microswitchWired to IT8732F pin 75 (GP43?)UnknownUnpopulated
S6microswitchUnknownUI button (back)
J132x5 2mm Dupontdocumented belowinternal USB port
J18,J19,J20JST-XH 3 pin3-wire PC fanChassis fans
J211x2 2.54mm DupontUnknownUnknownUnpopulated
J222x5 2.54mm Dupontdocumented belowLPC connectorUnpopulated
CN12x5 JSTdocumented belowFront panel
J151x5 JSTUnknownFront USB connector

LPC Connector

The mainboard contains an unpopulated 2x5 Dupont connector wired to the CPU and to the IT8732F Super I/O chip. Based on some trace routing together with a pinout of the IT8732F chip this looks to be an LPC connector. The pinout is the following:

J22 PinIT8732F PinPin Function (based on a related IT8782F chip pinout)Notes
1
242LAD1
349CLKINLCLK
441LAD0
540LFRAME#
6
744LAD3
8GND
943LAD2
10GND

One mandatory LPC pin missing is LRESET# but according to Wikipedia this can be connected to the PCIRST# so might not be wired directly to the Super I/O chip. Unfortunately, my logic analyzer is too slow to gather a trace of the signals on this connector (LCLK is 33.3 MHz).

Front panel connector

Pin numberFront board sideMainboard sideNotes
1+3.3V
2UI LED anode
3PWR buttonshort to GND when pressed
4⚠ LEDIT8732F pin 79 (GP40?)cathode, anode wired to +3.3V
5Reset buttonIT8732F pin 14 (GP34?)short to GND when pressed
6UI LED cathode
7UI buttonConnected to S6 on the backshort to GND when pressed, can be wired to IT8732F pin 57
8🖧 LAN LEDcathode, anode wired to +3.3V
9GND
10⏻ Power LED

Network traffic observed when NAS is booting

Software update mechanism

The NAS operating system contains an automatic software update mechanism which can be triggered from the Admin UI. The below is the documentation of reverse engineering efforts for this mechanism.

The update starts with a HTTPS GET request to the https://update.readynas.com/download/ReadyNASOS-x86_64/index URL in order to check the information about new firmware versions available. An example request observed is show below:

This request has a number of parameters:

ParameterValueNotes
keySCRUBBEDThis looks to be a “license key” assigned to the particular NAS
modelReadyNASSelf-explanatory
model_num3138Self-explanatory
current_version6.9.1Current version of the firmware installed on the device
channelltsIndicates whether we are interested in the LTS (Long-Term Support) channel or other channel names

From playing with the parameters is seems that only the ‘key’ and ‘channel’ change anything in the returned data at the moment which means that the logic behind the update selection on the backend is likely very simple. First, when the ‘key’ value is changed an empty HTTP response is returned which means, that this value is checked for validity. Next, when the ‘channel’ value is set to anything else than ‘lts’ a different software descriptor is returned:

This response describes a different version of the firmware - 6.10.5 which is currently the most recent version of ReadyNAS OS. The reception of this meassage shows a popup dialog box in the admin UI where the user can confirm software update. If confirmed, the update proceeds to a “license verification” request which looks like this:

Again, like in the previous requests only the ‘key’ parameter seems to be checked, you can put anything you like in the serial number and model number and the verification will always be successful. With the status there is also a URL returned which is where the actual firmware content will be downloaded in the next step:

The response is the firmware update blob. Here, the ‘key’ parameter is also checked, the ‘serial_number’ is not and the ‘requested_version’ needs to be correct, if it’s not a 404 error is returned. Now that we have the firmware file downloaded let’s see what is inside it.

We can see that the first 0x4000 bytes in the file is a kind of header followed by a tar file likely with the firmware contents. When we extract this tar file and calculate its MD5 hash we will find out that it matches the hash in the first “information” line confirming we are on the right track:

The tar file contains 4 files which are also present on the internal NAS USB drive serving as the boot device:

There is a kernel, initramfs as well as the rootfs which gets extracted onto the hard disks when the storage array is initialized. Before that happens all of these files are stored on an internal USB device from which the BIOS boots.

Booting an alternative operating system

The knowledge and access we gained on the serial console allows us to boot an alternative operating system on the NAS. We will use Alpine Linux x86_64 as a proof of concept as it’s one of the smallest Linux distributions out there (the internal USB drive is only 256 MB).

First we need to change the SYSLINUX configuration as the prompt is currently disabled unless we press one of the designated keys (Shift, Alt, Caps Lock or Scroll Lock). As the NAS has no keyboard we need the prompt to appear every time. We need to boot the NAS without any disks attached so that we end up in the “Emergency Mode” boot where the internal USB device is mounted on /media/boot. Then, we remount it read-write and edit the syslinux.cfg file:

By changing the default ‘prompt 0’ to ‘prompt 1’ the SYSLINUX prompt should appear after rebooting:

As we haven’t sent any characters through the serial console there will be a timeout after 3 seconds and SYSLINUX will boot the default entry landing us back in “Emergency Mode”. Now we will put Alpine Linux on the internal USB device and make an entry to boot it. First, we need to download a bootable Alpine Linux ISO for the x86_64 CPU architecture:

Now, in order to transfer the files needed we want to start an SSH server on the NAS:

We need the kernel and initramfs as a minimum:

Now we can stop dropbear on the serial console by pressing Ctrl-C and edit syslinux.cfg in order to create an entry for Alpine Linux:

The last ‘alpine’ entry was added referencing our kernel (alpine-v) and initramfs (alpine-i). The file names are different because the internal USB has an old-school MS-DOS filesystem with a limit of 8 characters file names. Now we can attempt to boot:

As you can see we have successfully booted Alpine Linux as an alternative OS on the device.

Mods

Additional hard disks

The NAS enclosure contains place for 3 additional 2.5” drives inside, the mainboard has 2 unused SATA connectors. The power supply also has 2 unused SATA power plugs. This setup is perfect for including ZFS L2ARC SSD drives or extra drives for the operating system. A setup like this is visible below:

netgear-rn3138/thumb-netgear-rn3138-additional-2-SFF-drives.jpg

Internal USB storage connector

The NAS is designed to boot from an internal USB storage device plugged directly into the mainboard using a 2mm pitch 9 pin male header. The pinout of this header is identical to the USB2.0 9-pin header found on many mainboards, with only port 1 wired. The header also uses a less standard 2mm pitch instead of the typical IDC (“dupont”) 2.54mm pitch.

netgear-rn3138/thumb-netgear-rn3138-J13-pinout.jpg

Based on this a simple breakout board can be built to provide a USB-A socket to plug in a different USB storage device. This can be used to quickly swap out different operating systems or boot arrangements when maintaining or fixing the device. What you need to keep in mind however is that the connector has a 2mm pitch not the typical 2.54mm. This makes it tricky to use a pre-made perfboard but it’s still possible to stick in a 2mm female header forming what is termed a “hedgehog pattern” by electronics professionals 😉.

netgear-rn3138/thumb-netgear-rn3138-2mm-pitch-in-breadboard.jpg

After some drilling, n USB-A connector and jumper wire the following result can be obtained:

netgear-rn3138/thumb-netgear-rn3138-internal-usb-breakout.jpg

Voltage, temperature and fan speed monitoring

The voltage rails, chassis fans and chassis temperature sensor seem to be monitored in the IT8732F chip on board. The BIOS Setup Utility can report the following readings:

When the it87 module is loaded into the linux kernel these stats are represented by files under /sys/class/hwmon/hwmon1. The fan and temperature inputs are pretty easy to figure out however the voltage rail to IT87 input mapping is currently unknown.

The IT87 chip provides PWM outputs for fan speed control. These are driven a bit differently than what pwmconfig and fancontrol assume. This is likely due to the fan driving circuitry granting us the following quirks:

  • the pwm<n>_enable file does not enable or disable just the PWM like pwmconfig assumes but enables or disables the fan entirely
  • the pwm<n> values are inverted, writing 0 spins up the fan to maximum speed, writing 255 stops the fan entirely

Chassis buttons and LEDs

The chassis contains a number of status indicator LEDs as well as “Unit Identification” and “Reset” buttons. These are used by the original firmware in order to execute factory reset, recovery and other special actions. There are also two leds per disk on the chassis. The dmesg of the original firmware hints that all of this can be driven using GPIOs or other device-specific kernel code:

The kernel code responsible for the handling of these has not been located yet.