Introduction
============
This document describes in depth how to prepare your Synology
Diskstation for installing OS/sandpoint. The following models are
supported:

Model

CPU

Clock

Disk

RAM

DS-101g+

MPC8241

266MHz

SATA

64MB

DS-106

MPC8241

266MHz

SATA

64MB

DS-106e

MPC8241

266MHz

SATA

32MB

DS-106j

MPC8241

200MHz

PATA

32MB

DS-106x

MPC8241

266MHz

SATA

128MB

CS/RS-406

MPC8245

400MHz

SATA

128MB

CS-406e

MPC8241

266MHz

SATA

64MB

DS-107

MPC8241

266MHz

SATA

64MB

DS-107e

MPC8241

266MHz

SATA

32MB

DS-207

MPC8241

266MHz

SATA

64/128MB

CS-407e

MPC8241

266MHz

SATA

64MB

DS-108j

MPC8241

200MHz

SATA

32MB

DS-109j

MPC8241

266MHz

SATA

32MB

DS-209j

MPC8241

266MHz

SATA

64MB

To install OS/sandpoint you will have to open the case, to get access to
the serial console, and connect a serial converter from TTL to RS232
signal levels.
Accessing the serial interface
==============================
Locate the serial header
------------------------
Open the case and search for a 6-pin header, which is labeled `COM1` or
`JP2`. The left photo shows a DS-101g+ and the right photo a DS-106j.
Note that the serial header is rotated by 180 degrees between these two
models:

**Serial header pin assignments:**

Pin number

Function

1

3.3V

2

GND

4

TX

6

RX

Watch out for the thick, white angle, which marks pin 1.
Connect a serial cable
----------------------
The serial port on Synology NAS boxes is using 3.3V TTL levels, which
have to be converted into regular RS232 levels by a level shifter
circuit. If you are not anxious using a soldering iron you find detailed
instructions how to build such a converter here:
- Serial adapter for 3.3V TTL
This picture shows the installed serial adapter. When the installation
is completed, and the Diskstation is available over the network, you can
remove the serial adapter again. You will only need it in emergency
situations.
Another option is to buy such a converter. There are solutions for a
standard RS232 interface and for an USB interface. Look out for:
- RS232 level shifter / breakout board (MAX3232 based)
- USB to TLL serial level shifter / breakout board (FT232 based)
First installation
==================
Accessing the Firmware
----------------------
Provided the serial converter is installed and working correctly you
should be able to connect to the firmware's serial console. Synology is
using [PPCBoot](http://ppcboot.sourceforge.net/). Most models have
version `2.0.0` installed, but the newer ones have network support and
limited functionality ([read below](#post_install)).
Now you can connect with any terminal program to the Diskstation's
serial console. The easiest approach may be to use OS's `tip(1)` command
to make a direct console connection at 115200bps.
# tip -115200 console
Note that when using a serial connection via USB you may have to make an
entry for `/dev/ttyU0` in `/etc/remote`. Immediately after switching
your Diskstation on it will beep shortly, and you should see the
following messages. Type CTRL-C within one second to avoid autobooting.
In old firmwares (2005) you have three seconds and may press any key.
PPCBoot 2.0.0 (Jan 30 2007 - 14:27:41)
CPU: MPC8245 Revision 1.4 at 199.999 MHz: 16 kB I-Cache 16 kB D-Cache
I2C: ready
DRAM: DRAM BANK = 1
MAX_DRAM_SIZE = 2000000
MCCR1 = 75a80000
MCCR4 = 35363331
MSAR1 = 0
EMSAR1 = 0
MEAR1 = 1f
EMEAR1 = 0
MSAR2 = 0
EMSAR2 = 0
MEAR2 = 0
EMEAR2 = 0
MBER = 32000001
PICR1 = 141b98
PICR2 = 40604
32 MB
addr_sp=1f2ff78, id=1f2ff98, addr=1fc0000
FLASH: flash id = 49
vendor = 1, flash id = 49 (flash_id:49)
2 MB
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
Net: SK98#0
Press Ctrl+C to abort autoboot in 1 second
altboot
-------
The `altboot(8)` utility functions as a bridge between the Synology
firmware and the OS kernel startup environment. NAS firmware often
provides no means to boot a kernel from disk or from the network and
doesn't initialize all hardware correctly. We will also use it to pass a
bootinfo list to the kernel.
The `altboot` boot loader has to be loaded into RAM at `0x1000000` and
started using PPCBoot / U-Boot. Usually there are three ways to invoke
it:
- loadb
to load a binary file via serial line in
kermit
mode
- tftpboot
to load a binary file over the network with TFTP protocol
- start it from the flash memory
The last option is prefered once the installation is completed, but
obviously it is not possible for the first time boot. Newer firmwares
(2007) support the use of the network interface by setting the `ipaddr`
and `serverip` environment variables with `setenv`. Once you have set up
TFTP and DHCP ([read below](#altboot_install)) you can download
`altboot` like this:

The old firmware (2005) doesn't activate the network at all, so we have
to download `altboot` into RAM with Kermit protocol over the serial
line.
Install `kermit(1)` from `pkgsrc(7)` or compile and install it yourself.
To set up the file transfer you have to provide the following commands
to `kermit`:
set line /dev/tty00
set speed 115200
set carrier-watch off
set flow-control none
robust
set file type bin
For convenience you can write them into a file which you can pass as an
argument to `kermit`.
Load `altboot` into memory using Kermit protocol. The binary is
relocated at `0x1000000`, so type:

_MPC824X > loadb 1000000
## Ready for binary (kermit) download ...

Now quit your terminal program and launch `kermit cmdfile`. When you are
already running `kermit`, enter the command mode by typing `CTRL-\`
followed by `C`. Then send `altboot.bin`. Reconnect when the transfer is
finished.
C-Kermit 8.0.211, 10 Apr 2004, for NetBSD 1.6
Copyright (C) 1985, 2004,
Trustees of Columbia University in the City of New York.
Type ? or HELP for help.
(/tmp/) C-Kermit>
Boot the INSTALL kernel with altboot
------------------------------------
Now you can use `altboot` to launch the `netbsd-INSTALL` kernel for
installing OS. You may choose to load it with TFTP or from NFS. For TFTP
you have to enable `tftpd(8)` in `/etc/inetd.conf`, and for NFS there is
a documentation at [The Network File
System](http://www.NetBSD.org/docs/guide/en/chap-net-services.html#chap-net-services-nfs).
But in both cases you have to set up a DHCP server, which is explained
in the [DHCP Howto](http://www.NetBSD.org/docs/network/dhcp.html). An
appropriate `dhcpd.conf` entry could look like this:
host ds101g {
hardware ethernet 00:11:32:xx:xx:xx;
fixed-address 192.168.0.101;
next-server 192.168.0.1;
option root-path "/export/ds101g/root";
}
The `root-path` option is only needed when using NFS and should match
your exported NFS directory. Uncompress `netbsd-INSTALL.gz` from the
OS/sandpoint distribution and copy it into the NFS or TFTP directory.
Then start the DHCP, NFS or TFTP server and boot the installation kernel
from the firmware either with

The `\` is important for `setenv` not to misinterpret the `;` as the end
of the command.
New firmware (2007)
-------------------
Without a working `saveenv` command the only way to make your system
automatically boot OS is to replace the Linux kernel on flash by
`altboot.img`, which is our bootloader in PPCBoot image format, faking a
Linux kernel.
When viewing the environment variables with `printenv` you can see that
the `bootcmd` is calling `bootm` to load the Linux kernel. The first
address is the location which we have to overwrite with `altboot.img`.
Here it is `0xffc00000`, which you have to replace in all the following
commands, in case your `bootcmd` differs.
bootcmd=bootm FFC00000 FFE00000
Load `altboot.img` into memory, for example at `0x1000000` again, as
explained [above](#altboot). You might want to backup the Linux kernel
image first. Then execute the following commands to overwrite it with
`altboot.img`:

Optionally you may think about replacing the Linux RAM disk image at the
second address (`0xffe00000` in the example above) by an empty PPCBoot
image, like [this](dummy.img.gz) one (do not forget to uncompress it
with `gunzip(1)`). Or use `mkubootimage` to make your own dummy. Write
it to flash as shown above. This will speed up the boot process, but is
not really required.
Have fun with your mini OS server!