Welcome! Log In Create A New Profile

Advanced

Debian on Synology DS214

Posted by lonestar 
Re: debian on synology ds214 - periphery issues
December 01, 2022 03:32PM
Hi bodhi,

I have so far failed to boot debian from stock u-boot. Will have to try more tomorrow.

In stock u-boot:
Press Ctrl+C to abort autoboot in 3 second
Marvell>> md.l f1018000 8
f1018000: 00000000 00000000 00000000 00000000    ................
f1018010: 11110000 00004000 00000000 00000000    .....@..........
Marvell>> md.l f1018100 1
f1018100: 00000000    ....
Marvell>> md.l f1018140 1
f1018140: 00006400    .d..
Marvell>> ide reset

Reset IDE: 
Marvell Serial ATA Adapter
Integrated Sata device found
  Device 0 @ 0 0:
Model: SAMSUNG HD501LJ                          Firm: CR100-10 Ser#: S0MUJ13P735779      
            Type: Hard Disk
            Supports 48-bit addressing
            Capacity: 476940.0 MB = 465.7 GB (976773168 x 512)

Marvell>> md.l f1018000 8
f1018000: 00000000 00000000 00000000 00000000    ................
f1018010: 11110000 00004000 00000000 00000000    .....@..........
Marvell>> md.l f1018100 1
f1018100: 00000000    ....
Marvell>> md.l f1018140 1
f1018140: 00006400    .d..

===
moderator edit: please use code tags (formatted code) to post log.



Edited 1 time(s). Last edit at 12/01/2022 09:07PM by bodhi.
Re: debian on synology ds214 - periphery issues
December 01, 2022 09:17PM
Martin,

Quote

I have so far failed to boot debian from stock u-boot. Will have to try more tomorrow.

Now that's bad :) I thought I've asked to see Debian booting from stock u-boot, not your built u-boot. So what we observed in the last several tests were not what I was looking for or expected.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: debian on synology ds214 - periphery issues
December 02, 2022 07:59AM
Hi bodhi,

sorry, I apparently misunderstood you at that time.
I redid the last tests:

First of all: when using stock u-boot with self-built kernel+initrd ethernet WORKS!!!

With your latest patch, which added the regulators both drives are spinning (I did a ide reset in u-boot and at that time the SATA2 drive started)
Unfortunately there are still no disks detected in debian.
Thinking about this again - I did not check whether the two disks were spinning with the patch before the latest one when retesting today. Will have to do this this weekend.

attached the dmesgs.
Top line in the dmesg files shows the corresponding message with the patch from you.

thanks,
Martin



Edited 1 time(s). Last edit at 12/02/2022 02:54PM by lonestar.
Attachments:
open | download - stock-uboot-debian-dmesg-log (33.9 KB)
open | download - stock-uboot-debian-dmesg-regulators-log (32.7 KB)
Re: debian on synology ds214 - periphery issues
December 02, 2022 04:11PM
Martin,

> First of all: when using stock u-boot with
> self-built kernel+initrd ethernet WORKS!!!

That's what I expected to see with stock u-boot + the DTS patch!

> With your latest patch, which added the regulators
> both drives are spinning (I did a ide reset in
> u-boot and at that time the SATA2 drive started)
> Unfortunately there are still no disks detected in
> debian.

The disks spinning is a very good sign.

1. Wait for about 10 seconds after loging into Debian. If this box has hotplug capability, remove the disks and reinsert them. Wait a bit (upto 20 seconds) and see if they appear in dmesg.

2. If the box does not have hotplug capability, insert the HDDs before booting with USB. And then login into Debian, wait for 20 seconds and see if the disk appears in dmesg.

If both HDDs can be mounted OK in either tests, then I think the DTS regulators need further mods.

======

I noticed that the kernel uImage name is Linux-6.0.8-mvebu-tld-1, but the uInitrd name is initramfs-6.0.7-mvebu-tld-1.

- So you built the kernel with my kernel config and patch file as is? i.e. no additional changes?
- The source tree is 6.0.7 or 6.0.8 ?

A recommendation is if you've built your own kernel then put a marking in the local version, so that we can tell the difference. For example: 6.0.8-mvebu-tld-1-xxx-1 (where xxx is your initials, or abbreviation of something).

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: debian on synology ds214 - periphery issues
December 04, 2022 01:06PM
Hi bodhi,

my box supports hotplug of sata devices.
I tested with the 7200 drive:

In SATA1:
- drive starts without spinning
- ide reset in u-boot does not spin up
- in linux drive spins up but is not detected
- after unplugging, waiting, plugging the drive does not spin

In SATA2:
- drive starts without spinning
- ide reset in u-boot spins up drive
- in linux the drive is not detected
- after unplugging, waiting, plugging the drive does not spin

my kernel is self-build 6.0.8 I didn't update the mkimage command.
I added various modules at some earlier time to check whether this helps with device support.
Attached my current kernel config.

thanks,
Martin
Attachments:
open | download - .config (210.8 KB)
Re: debian on synology ds214 - periphery issues
December 04, 2022 04:03PM
Martin,

> my kernel is self-build 6.0.8 I didn't update the
> mkimage
command.
> I added various modules at some earlier time to
> check whether this helps with device support.

I see. That's not a good approach in developing or testing. We need to use a baseline (i.e. reference point), so we can eliminate all unkowns. In this case, the baseline is the kernel 6.0.7-mvebu-tld-1. Once you added more modules... and also run the kernel without installing it in the rootfs, it is no longer something I can rely on.

You should install and boot 6.0.7-mvebu-tld-1, then trouble shoot the SATA bringup with it. Actually, test everything with this baseline. After it's done, install your self-built kernel, and do regression testing.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: debian on synology ds214 - periphery issues
December 05, 2022 10:47AM
Hi bodhi,

ok I will do the tests with the original kernel.
Might take a few days as I will be rather busy this week.

thanks,
Martin
Re: debian on synology ds214 - periphery issues
December 07, 2022 01:06PM
Hi bodhi,

i did the tests again with the original 6.0.7 kernel.

Behavior is the same as previously in post from "December 04, 2022 01:06PM"

Attached the two logs. I used only one disk in either SATA 1 or SATA2.

thanks,
Martin
Attachments:
open | download - sata1.log (32.6 KB)
open | download - sata2.log (34.1 KB)
Re: debian on synology ds214 - periphery issues
December 07, 2022 03:57PM
Hi bodhi,

I did some experiments today and I am now able to compile and boot stock u-boot.

This means we can add traces wherever we like :)

As a first test I enabled the tracing in mvLog.h and partially enabled the REG_DEBUG tracing.
REG_DEBUG can't be fully enabled as u-boot won't boot any more afterwards. A comment mentions this only work with Lauterbach and I guess it is called before ram is initialized and then stuff happens...

I attached the log files and the diff which shows what I enabled.

thanks,
Martin
Attachments:
open | download - stock-uboot-with-log.txt (15.4 KB)
open | download - stock-uboot-enable-log.diff (7 KB)
Re: debian on synology ds214 - periphery issues
December 07, 2022 09:00PM
Martin,

It does not look like you are using the DTS patch I posted toghether with 6.0.7-mvebu-tld-1?

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: debian on synology ds214 - periphery issues
December 08, 2022 03:43AM
Hi bodhi,

very good news and I want to apologize for the additional work that I caused.

Both SATA work when using stock u-boot with your kernel and the new device tree.
Replug is a little strange as the device nodes in /dev don't get reliably updated, but replugging is not a requirement for me at least.

I tried to read and write from a file from one of the disks and it worked fine.

see also attached log.
I did not need to call "ide reset" in stock u-boot for it to work.

The first log with ide reset is the one where I did the replug tests.

thanks and sorry,
Martin
Attachments:
open | download - both-sata-working.txt (39.7 KB)
open | download - both-sata-working-noidereset.txt (35.1 KB)
Re: debian on synology ds214 - periphery issues
December 08, 2022 05:05PM
Martin,

Awesome!

it's OK. No big thing. This is just a hobby, so sometime we just get so far in the weeds and forget some good practice. I'm sure you knew all that and deal with your real works very differently :)

So I think now you can test or confirm other HW aspects. Things like LEDs control, RTC, hw moninoring, USB drives.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)



Edited 1 time(s). Last edit at 12/08/2022 05:06PM by bodhi.
Re: debian on synology ds214 - periphery issues
December 10, 2022 05:25AM
Hi bodhi,

I have for now recompiled the stock u-boot to change the default boot command to boot from the front usb (the only one that works on stock).
So I have a working NAS where I can do some experiments. For me the hardware support is sufficient for now.

Regarding your list:
- RTC works
- LEDs do not show up in /sys/class/led (not needed for me at the moment)
- hw monitoring: I didn't look into this yet.
- USB: in linux the two rear usb work, front doesn't.

If you want to do further tests just send any patches I will happily support by testing them. Yet as the device is rather old I am not sure how many wlll try to reproduce our experiment :)

thanks for all the work,
Martin
Re: debian on synology ds214 - periphery issues
December 10, 2022 03:58PM
Martin,

> I have for now recompiled the stock u-boot to
> change the default boot command to boot from the
> front usb (the only one that works on stock).
> So I have a working NAS where I can do some
> experiments. For me the hardware support is
> sufficient for now.

Cool!

>
> Regarding your list:
> - RTC works
> - LEDs do not show up in /sys/class/led (not
> needed for me at the moment)

This is very specific to each board. It's in the GPL source.

> - hw monitoring: I didn't look into this yet.
> - USB: in linux the two rear usb work, front
> doesn't.

Are they all USB 3.0 or which ones are USB 2.0?

>
> If you want to do further tests just send any
> patches I will happily support by testing them.
> Yet as the device is rather old I am not sure how
> many wlll try to reproduce our experiment :)

You will be surprised about that, if this old box is ever on fire sale!

I'll make another patch for the LEDs.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: debian on synology ds214 - periphery issues
December 13, 2022 12:07PM
Ah I missed the question in the last post :)

The front usb is the usb2 port. This doesn't work in linux
The back usbs are usb3 (connected to the pcie controller). These work.

Thanks,
Martin
Re: debian on synology ds214 - periphery issues
December 13, 2022 06:23PM
Martin,

1. LEDs

There is not much of LED controls that's worth adding. Only 2 that are exposed (HDD0 and HDD1 failure LEDs).

Can you describe the LED behavior on booting stock OS and also on booting Debian? i.e. which LEDs light up, flashing, if at all.

2. USB

The 2 USB 3.0 ports are usable because they are on PCIe bus. That's automatically enumerated by the new kernel 6.0.7-mvebu-tld-1.

I'll add some more DTS patches to see if the front USB can be activated by a regulator.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: debian on synology ds214 - periphery issues
December 13, 2022 08:51PM
Martin,

Here are 2 test patches for USB.

Try armada-xp-synology-ds214.dts.51000.patch first, if it does not work, try armada-xp-synology-ds214.dts.52000.patch

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Attachments:
open | download - armada-xp-synology-ds214.dts.51000.patch (4.5 KB)
open | download - armada-xp-synology-ds214.dts.52000.patch (4.5 KB)
Re: debian on synology ds214 - periphery issues
December 16, 2022 07:01AM
Hi bodhi,

front usb works using the first patch.
(I tested with my self-built kernel and initrd which is actually just your kernel config + enabling the bcache driver)

Cheers,
Martin
Attachments:
open | download - frontusb-work.log (35.1 KB)
Re: debian on synology ds214 - periphery issues
December 16, 2022 07:11AM
Hi bodhi,

I checked the led bahvior:
For debian:
- hdd leds are yellow on u-boot (regardless of whether a disk is in there)
- hdd leds turn off when kernel starts to load and never turn on again
- status led remain off all the time

For stock:
- hdd leds are yellow on u-boot (regardless of whether a disk is in there)
- hdd leds turn off when kernel starts
- hdd leds are still off when drive is detected and spins up (I only tested with one drive, as the other one is now in use)
- later in the boot process, somewhere around loading of synobios the leds start flashing on IO
- the status led is turned on very late in the boot-up

thanks,
Martin
Re: debian on synology ds214 - periphery issues
December 16, 2022 05:08PM
Martin,

> front usb works using the first patch.
> (I tested with my self-built kernel and initrd
> which is actually just your kernel config +
> enabling the bcache driver)

Cool! chalked it up another victory :) Front USB must work for us to complete hacking this box.

LEDs are nice to have. The stock LED behavior tells me that the LEDs are set by the kernel code proper, or a script in stock OS. That's why the original DS414 DTS did not have any LEDs definition. This is something we can take time to look for in the stock serial bootlog, and the kernel GPL patches.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: debian on synology ds214 - periphery issues
January 04, 2023 06:40PM
Hi Martin,

Could you post a summary to help future users looking for how to install Debian this box. It does not have to be too detailed. Just these information below.

Stock u-boot

What u-boot envs are used to boot Debian rootfs on USB 3.0 drive

Rootfs and Kernel

I've attched the latest DTB file in this post: armada-xp-synology-ds214.dtb. My next kernel release (6.1.x-mvebu-tld-1) will include the patch and this DTB in the tarball.

A description about starting with Debian-5.13.8-mvebu-tld-1-rootfs-bodhi.tar.bz2 and later installing kernel 6.0.7-mvebu-tld-1.

Boot log

Also post the serial boot log with stock u-boot and kernel 6.0.7-mvebu-tld-1 and the armada-xp-synology-ds214.dtb. This log should include output of printenv.

Thanks!

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)



Edited 1 time(s). Last edit at 01/04/2023 07:21PM by bodhi.
Attachments:
open | download - armada-xp-synology-ds214.dtb (17.3 KB)
Re: debian on synology ds214 - periphery issues
January 04, 2023 06:43PM
Oh, and please change the thread subject to:

Debian on Synology DS214

If you could not as a normal user, I'll change it for you.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: debian on synology ds214 - periphery issues
January 06, 2023 02:51AM
Hi bodhi,

I changed the message title.

I will create an installation guide somewhen in next few days.

regards,
Martin
Re: Debian on Synology DS214
January 15, 2023 07:30AM
Hi,

with a lot of help from bodhi I managed to get my own debian onto my Synologx DS214 NAS.
For those of you who want to repoduce this I created a small summary below. Note that I assume here that you know your way around linux. This is not intended to be a full beginners guide.

=== State ===
Currently the following periphery is working and tested on my NAS:
- two SATA ports
- front and backUSB ports
- Network port

Not fully working:
- LEDs

We used stock u-boot to boot our debian from front USB, as stock u-boot does not support the back USB ports. I just added the necessary files to a tiny usb stick which is not too annoying from an optical point of view.

=== Installation ===

*** getting a UART ***

As a first step you will want to attach a USB to UART Dongle to the debug serial of your synology device.

The bad news is that you can't easily open the case of the DS214. The good news is you don't have to. The PINs are accessible from the bottom of the device. It is a bit of work to connect them but it is certainly doable.
For the PIN-out see the following image:

https://forum.doozan.com/file.php?2,file=6592,filename=u-boot-serial-small.jpg

Note that the Rx/Tx needs to be connected to the Tx/Rx pins of the converter.

When you boot you should now see a boot log.

*** stock u-boot ***

do NOT execute saveenv on the stock u-boot firmware. This will brick your device as synology has misconfigured the location of the env on the flash in their u-boot configuration.

*** Installing debian ***
I basically followed the guide from https://forum.doozan.com/read.php?2,32146
  • first step is to install the system with kernel 5.13.8, as this is at the moment the last version where a rootfs has been created for.
  • use the guide from https://forum.doozan.com/read.php?2,32146 to get the kernel combined with the device tree (dtb). As dtb file use the armada-xp-synology-ds214.dtb which is attached to this post or even better the one that most likely is in the current release from bodhi at the time where you are trying this.
  • In the section for the rootfs you can find how to install this to the USB stick.
  • add the latest kernel to the usb stick, and make sure you have the .deb file from bodhi's tgz and the dtb file.
  • when you have prepared the USB stick and added the kernel make sure to create a backup before booting this as the 5.13.8 is a bit unstable on the DS214.
  • if the following steps fail because of kernel issues (I had some cpu stalls and such stuff) try again. If necessary use the backup from before. It might take a few tries.
  • use stock u-boot and the serial console to boot into the usb stick:
    setenv usbActive 1
    usb start
    ext2load usb 0:1 0x02000000 /boot/uImage
    ext2load usb 0:1 0x08000000 /boot/uInitrd
    setenv bootargs 'console=ttyS0,115200 ip=off root=/dev/sda1 rw syno_hw_version=DS214v10 ihd_num=2 netif_num=1 flash_size=8'
    bootm 0x02000000 0x08000000
  • in my case LABEL=rootfs couldn't be found. If you drop the the emergency console check whether sda1 is already mounted on / and if yes just exit the console again. Fix your fstab afterwards, before regenerating the initrd in the next step.
  • install the new kernel and let the initrd be generated
  • reapply the device tree to the new initrd and kernel as written in bodhi's guide.
  • reboot to the new kernel + initrd

See prepare-usb-rootfs.log and step1-kernel-5.13.8.log for the commands that I entered.

*** getting this to boot without manual interaction ***
As the stock u-boot can't save the environment we need to rebuild it. You can use the source from https://sourceforge.net/projects/dsgpl/files/Synology%20NAS%20GPL%20Source/24922branch/armadaxp-source/
You will need: armada375-gcc464_glibc215_softfp_armada375-GPL.txz, u-boot-armada-2011.12.txz

  • Edit "include/configs/syno_axp.h" to set the desired boot commands. See attached diff for my version (which boots from fat on usb).
  • edit build_ds214.pl to set the path to the extracted gcc sdk.
  • run build_214.pl
  • take u-boot-axp--clean-spi-ds214.bin and flash it to /dev/mtd0 (for example with flashcp)
I currently don't have a compiled variant of the u-boot which boots from ext2, as I have my kernel+initrd on an fat2 stick in front and the root fs on an usb in the back usb.

*** my installation ***

I have an SSD attached to the back usb and the front usb only serves for providing the kernel+initrd on an fat formatted usb stick.

Therefore my u-boot uses the following env:
bootargs=console=ttyS0,115200 ip=off root=/dev/disk/by-partlabel/rootfs rw syno_hw_version=/dev/md0 ihd_num=536378030 netif_num=2 flash_size=8
bootcmd=usb start; fatload usb 0:1 0x02000000 uImage; fatload usb 0:1 0x08000000 uInitrd; bootm 0x02000000 0x08000000

the ssd is found by partition label in this case and could therefore be anywhere (front usb, back usb or maybe even the SATA disks (didn't try that though)

*** Attachments ***
I added a tar with the following files:
  • armada-xp-synology-ds214.dts: device tree source
  • armada-xp-synology-ds214.dtb: compiled device tree
  • ds214-original.log: log of ds214 boot before I changed anything
  • prepare-usb-rootfs.log: steps on linux host where I prepared the usb rootfs
  • step1-kernel-5.13.8.log: Boot of the 5.13.8 kernel including the commands to install 6.0.7 and the u-boot env
  • step2-kernel-6.0.7.log: Boot of 6.0.7 including u-boot env
  • u-boot-stock.diff: my changes to the stock u-boot as indication where the boot commands can be changed.

Best luck to all of you,
Martin
Attachments:
open | download - dtb-and-logs.tgz (140 KB)
Re: Debian on Synology DS214
January 15, 2023 03:06PM
Thanks Martin! I will proof read it and add to the release thread for new kernel version.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Debian on Synology DS214
November 23, 2023 05:05PM
Impressive !
Would it be possible to launch Openmediavault ? I have a DS212+ and may be interested.
Anyway thank you for what you've have done both of you.
Re: Debian on Synology DS214
November 24, 2023 02:18PM
Sagittarius,

Your box is a Kirkwood 88F6282 SoC, not Armada XP SoC like the DS214.

DS212 is supported in mainline kernel with this DTB : kirkwood-ds212.dtb (looks like this DTB is for both 212 and 212+).

So the installation will not be quite the same as Martin described for the DS214. Of course, other useful info specific to Synplogy are still applicable.

You could just do a simple installation like this:

https://forum.doozan.com/read.php?2,102054,105374#msg-105374

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Debian on Synology DS214
April 15, 2024 04:48AM
Hi everyone,

Just a quick message to say that I dug a bit into the DS214 DTS and found several issues. The most important one probably being the RAM set to 1GB instead of 512MB.
I'll fix all I can and do some testing to validate my changes, and post a revised DTS later on this tread.
I also started a thread for mainline u-boot support on this device.



Edited 1 time(s). Last edit at 04/15/2024 04:55AM by Robin.
Re: Debian on Synology DS214
April 15, 2024 01:39PM
@Robin,

> Just a quick message to say that I dug a bit into
> the DS214 DTS and found several issues. The most
> important one probably being the RAM set to 1GB
> instead of 512MB.

While it's good to fix that RAM size, what's in the DTS should not impact how the kernel determines the RAM size. The RAM size is determined by u-boot and the kernel use that info, and ignore what's in the DTS.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: