Skip to content
vajdagyorgy edited this page Jan 24, 2017 · 20 revisions

#ix4-300d - mainline linux kernel support

The objective was to create a device tree for this device on mainline linux.

Lenovo ix4-300d is a small 4 bay NAS based on armada XP dual core 78230 armv7 cpu.

The device has dual port ethernet, lcd screen, gpio buttons, usb 2.0 (2 rear) & 3.0 (1 front)

Chips used in the NAS

  • CPU: Marvell xxxxxx (identifies as Marvell PJ4Bv7 Processor rev 2 (v7l))
  • Flash: K9K8G08U0E Samsung 8 GBit = 1GByte SLC flash (48-pin TSOP-1)
  • RAM: 2x Nanya NT5CB128M16FP-DI DDR3 SDRAM, 2 GBit = 256 MByte each, total 512MB
  • SATA chipset: Marvell 88SX7042-BDU1
  • Ethernet PHY: 2x Marvell 88E1318-NNB2 GBit Ethernet
  • USB 3.0: Renesas D720200AF1 PCI-E controller, serving the front port (back port
  • RTC: NXP 8563T (identifies to Linux as pcf8563), at I2C address 0-0051
  • Fan/LED brightness control and monitor: ADT7473ARQZ, at I2C address 0-002e (identifies to Linux as adt7473)
  • LED control for front panel: NXP 74HC165D (according to devicetree it's connected to the SPI bus, but does not appear in /proc/sys/bus/spi). Controls power, sys, sys-fail and hdd-fail LEDs; the hdd LED is controlled by a CPU GPIO instead.

##what is supported so far:

  • full armada xp cpu feature from mvebu linux mainline
  • i2c (mv64xxx-i2c) bus connected component : rtc pcf8563 module, adt7473 pwm/sensor managment
  • dual gigabit, full duplex mode
  • pcie two ports : one lane connected to the USB3.0 NEC D720200F1 controller, one to the 4 sata Marvell 88SX7042 adapter
  • both USB2.0 & USB3.0 working full & high speed
  • power, reset, select & scroll button support as gpio-key recognized as keyboard entry (working with acpid)
  • 74hc164 8-shift as gpio extender for power, sysfail, sys, hddfail gpio-led (note hdd led is gpio independant)
  • gpio-poweroff setup yet it requires that both ethernet phy are configured at least once.
  • the integrated LCD is a gpio 8-bit 128x64 monchrome GLCD, in this projet is a small driver that create a /dev/lcm device to right byte graphics or ascii text to it.
  • UART on connector CN9 (four pins, outer side of board) provides Vcc at pin 1 (marked). Connect Pin 2 to the RX pin of your serial adapter, Pin 3 is GND and Pin 4 is TX. Connection parameters are 115200/8N1. Vcc can be controlled by the adjacent JP1 (pin 1 marked); bridging 1/2 provides 3V3, bridging 2/3 provides 5V - but beware that this does NOT change the I/O voltage.
  • JTAG may be at the pad U39 on the inner side of the board (above SATA bay 3 connector), but is not really accessible when the board is installed in the cage. Needs more research.
  • Edit 22/07: added nand definition in dts file manageable from linux mtd-utils

###how to compile a kernel: Edit 30/08/14: the Device tree is now part of the 3.17 mainline, so simply git the current 3.17 git and compil your dts ! Edit 28/07/14: the DTS was submited for 3.17 mainline ! thanks to the linux MVebu team Jason, Russel, Andrew & Arnd... for now:

  • just download a mainline kernel 3.15 or 3.16
  • patch the kernel with *.patch from git
  • apply the git ix4-300d_defconfig as .config in the kernel path (for debian jessie enable CONFIG_DEVTMPFS and CONFIG_CGROUPS in the config)
  • make zImage (or cross compil it)
  • then copy the bb.sh and adapt it to your path, it will generate a uImage file which can be used by the firmware u-boot

###booting from USB:

  • format a flash USB with 2 partition one VFAT big enough for a kernel 10-20Mb, one with a bootstrap linux a ext2,3 or 4
  • connect UART to the lenovo
  • hit a key to stop auto boot
  • then on the promt you can boot by typing:
  • usb reset;fatload usb 0:1 $loadaddr uImage;setenv bootargs $console $mtdparts root=/dev/sda2 rw rootdelay=10; bootm $loadaddr;

PLEASE NOTE this line is very specific to booting the lenovo with USB key plugged in on the rear upper usb port (I was not able to boot using the second USB or front USB connector)

PLEASE NOTE that the original firmware is a quite complete u-boot version with tft, nand, fat, ubi etc... boot support, you can look into u-boot documentation

PLEASE NOTE lenovo is making the u-boot and kernel source/patch they use available as part of the GPL

###Flashing for booting custom kernel from nand through serial line:

  • tftp uImage -> this should load your kernel from you TFTP server, only proceed if this step is OK
  • nand erase 0x120000 0x400000 -> this erase the nand from now you no more have kernel on nand
  • nand write.e $loadaddr 0x120000 0x400000 -> this flash the custom kernel loaded at first line

###Using led: since all leds are gpio-led ocnfigured you can use all the standard linux gpio-led interface and triggers (see /sys/class/led). The hdd led needs mv_sata patch available on Internet. ex:

  • echo 1 > /sys/class/leds/ix4-300d:sysfail:red/brightness

###Controlling brightness: the whole front panel brightness (includng lcd and all leds) are pwm brightness crontoled through pwm3 on the i2C (see /sys/class/i2c-0/0-0ée/pwm3 where you can simply cat 0..255 > pwm3))

  • dim the lights echo 30 > /sys/class/i2c-adapter/i2c-0/0-002e/pwm3

###Checking temperature: the hmon0 & hmon1 contains sensors and temps value for differents part of the nas. or you can reach the i2c, ex for cpu:

  • echo "scale=0; cat /sys/class/i2c-adapter/i2c-0/0-002e/temp1_input/1000" | bc

###Controlling fans: fan is controlled though i2C using pwm1 NOTE: the original fan is quite noisy, compared to some noctua or other quality brand you can found, I've swicth mine to a 92mm PWM notcua one with great gain from a noise perspecitive. The automatic pwm works out of the box.

My compromise is (keeping the HDD <42°C, case <32°C & CPU<63°C):

  • auto PWM for fan speed *only react to cpu temp & auto pwm echo 1 > /sys/class/i2c-adapter/i2c-0/0-002e/pwm1_auto_channels_temp echo 2 > /sys/class/i2c-adapter/i2c-0/0-002e/pwm1_enable
  • min temp for pwm start echo 57000 > /sys/class/i2c-adapter/i2c-0/0-002e/temp1_auto_point1_temp
  • max temp for pwm echo 90000 > /sys/class/i2c-adapter/i2c-0/0-002e/temp1_auto_point2_temp
  • pwm start echo 75 > /sys/class/i2c-adapter/i2c-0/0-002e/pwm1_auto_point1_pwm
  • pwm max echo 180 > /sys/class/i2c-adapter/i2c-0/0-002e/pwm1_auto_point2_pwm

###lcd screen: The lcd is a 128x64 pixel monchrome lcd drivers through RS, E, RW, S, and 8 bit gpio. I was able to code a ery light alpha driver for the kernel tha allow graphics and ascii display cat /dev/lcm give you the syntax for wriiting to the device

power-off:

The current DTS include the handling of the poweroff by pulling up GPIO24. Yet the nas look at eth phy status to decide on wether to reboot or halt the system. Since the neta driver only initialize eth phy when used, It took me ages to understand the difference with original firmware, in the end just configure BOTH eth phy at boot and power down just works ! (I did a static inet setting to 169.254.x.x ip)

Clone this wiki locally