Welcome! Log In Create A New Profile

Advanced

Debian on Synology RS816 (Armada 385)

Posted by zifxify 
Re: Debian on Synology RS816 (Armada 385)
December 31, 2020 06:05PM
In order not to lose:

Marvell>> printenv
CASset=max
MALLOC_len=5
MPmode=SMP
ata_hdd_enable=syno_hdd_enable=15
autoload=no
baudrate=115200
boot_order=hd_scr usb_scr mmc_scr hd_img usb_img mmc_img pxe net_img net_scr
bootargs=
bootargs_dflt=$console $nandEcc $mtdparts_lgcy $bootargs_root nfsroot=$serverip:$rootpath ip=$ipaddr:$serverip$bootargs_end $mvNetConfig video=dovefb:lcd0:$lcd0_params clcd.lcd0_enable=$lcd0_enable clcd.lcd_panel=$lcd_panel
bootargs_end=:10.4.50.254:255.255.255.0:Armada38x:eth0:none
bootargs_root=root=/dev/nfs rw
bootcmd=mw 0xf10a2620 0x251;mw 0xf10a2e20 0x251;usb xhciinit; run bootspi
bootcmd_auto=stage_boot $boot_order
bootcmd_fdt=tftpboot 0x2000000 $image_name;tftpboot $fdtaddr $fdtfile;setenv bootargs $console $nandEcc $mtdparts $bootargs_root nfsroot=$serverip:$rootpath ip=$ipaddr:$serverip$bootargs_end $mvNetConfig video=dovefb:lcd0:$lcd0_params clcd.lcd0_enable=$lcd0_enable clcd.lcd_panel=$lcd_panel; bootz 0x2000000 - $fdtaddr;
bootcmd_fdt_boot=tftpboot 0x2000000 $image_name; setenv bootargs $console $nandEcc $mtdparts $bootargs_root nfsroot=$serverip:$rootpath ip=$ipaddr:$serverip$bootargs_end $mvNetConfig video=dovefb:lcd0:$lcd0_params clcd.lcd0_enable=$lcd0_enable clcd.lcd_panel=$lcd_panel; bootz 0x2000000 - $fdtaddr;
bootcmd_fdt_edit=tftpboot $fdtaddr $fdtfile; fdt addr $fdtaddr; setenv bootcmd $bootcmd_fdt_boot
bootcmd_lgcy=tftpboot 0x2000000 $image_name;setenv bootargs $console $nandEcc $mtdparts_lgcy $bootargs_root nfsroot=$serverip:$rootpath ip=$ipaddr:$serverip$bootargs_end  video=dovefb:lcd0:$lcd0_params clcd.lcd0_enable=$lcd0_enable clcd.lcd_panel=$lcd_panel;  bootm $loadaddr;
bootdelay=3
bootftp=run syno_bootargs;tftpboot $loadaddr_kernel $file_kernel;tftpboot $loadaddr_rootfs $file_rootfs;sf probe; sf read $loadaddr_dt $spi_pt_addr_dt $spi_pt_size_dt;fdt addr $loadaddr_dt;bootm $loadaddr_kernel $loadaddr_rootfs $loadaddr_dt;
bootspi=run syno_bootargs;sf probe 0 50000000;sf read $loadaddr_kernel $spi_pt_addr_kernel $spi_pt_size_kernel;sf read $loadaddr_rootfs $spi_pt_addr_rootfs $spi_pt_size_rootfs;sf read $loadaddr_dt $spi_pt_addr_dt $spi_pt_size_dt;bootm $loadaddr_kernel $loadaddr_rootfs $loadaddr_dt;
cacheShare=no
clean_env=sf probe; sf erase $spi_pt_addr_env $spi_pt_size_env;
console=console=ttyS0,115200
device_partition=0:1
disaMvPnp=no
eeeEnable=no
enaClockGating=no
enaCpuStream=no
enaFPU=yes
enaMonExt=no
enaWrAllo=no
eth1addr=00:50:43:78:0b:26
eth1mtu=1500
eth2addr=00:50:43:78:c6:26
eth2mtu=1500
eth3addr=00:50:43:0b:c6:78
eth3mtu=1500
ethact=egiga0
ethaddr=00:50:43:c6:0b:26
ethmtu=1500
ethprime=egiga0
fdt_addr=2040000
fdt_skip_update=yes
fdtaddr=0x1000000
fdtfile=armada-38x.dtb
file_flash=armada38x/flash.bin
file_kernel=armada38x/uImage
file_rootfs=armada38x/rd.bin
file_uboot=armada38x/uboot.bin
ide_path=/
image_name=uImage
initrd_high=8000000
initrd_name=uInitrd
kernel_addr_r=2080000
lcd0_enable=0
lcd0_params=640x480-16@60
lcd_panel=0
limit_dram_size=yes
loadaddr=0x02000000
loadaddr_dt=0x1000000
loadaddr_kernel=0x2000000
loadaddr_rootfs=0x3000000
loads_echo=0
mtdids=spi0=spi_flash
mtdparts=mtdparts=spi0.0:4m(boot),-(spi-rootfs)
mtdparts_lgcy=mtdparts=spi_flash:4m(boot),-(spi-rootfs)
mvNetConfig=mv_net_config=4,(00:50:43:11:11:11,0:1:2:3),mtu=1500
mv_pon_addr=00:50:43:26:c6:78
netbsd_en=no
netretry=no
pcieTune=no
pexMode=RC
pxe_files_load=:default.arm-armadaxp-db:default.arm-armadaxp:default.arm
pxefile_addr_r=3100000
ramdisk_addr_r=2880000
rootpath=/srv/nfs/
run_script=no
sata_delay_reset=0
sata_dma_mode=yes
script_addr_r=3000000
script_name=boot.scr
sd_detection_dat3=no
spi_pt_addr_dt=0x0E0000
spi_pt_addr_env=0x7e0000
spi_pt_addr_kernel=0x0F0000
spi_pt_addr_rootfs=0x3C0000
spi_pt_size_dt=0x010000
spi_pt_size_env=0x010000
spi_pt_size_kernel=0x2D0000
spi_pt_size_rootfs=0x410000
standalone=fsload 0x2000000 $image_name;setenv bootargs $console $nandEcc $mtdparts_lgcy root=/dev/mtdblock0 rw ip=$ipaddr:$serverip$bootargs_end; bootm 0x2000000;
stderr=serial
stdin=serial
stdout=serial
syno_boot_dev=/dev/sda1
syno_bootargs=setenv bootargs console=ttyS0,115200 ip=off initrd=$loadaddr_rootfs root=$syno_boot_dev rw $syno_extra_args syno_hw_version=$syno_hw_version hd_power_on_seq=$syno_hdd_powerup_seq ihd_num=$syno_hdd_powerup_seq netif_num=$syno_net_if_num $ata_hdd_detect $ata_hdd_enable flash_size=8
syno_hdd_powerup_seq=1
syno_hw_version=DS116
syno_net_if_num=1
upd_flash=setenv tftpfile $file_flash; tftpboot $loadaddr $tftpfile; if test $? -eq 0; then echo "This may take a while, please be patient..."; sf probe; sf erase 0 +$filesize; sf write $loadaddr 0 $filesize; echo "\
Flash Update Done"; fi;
upd_kernel=setenv tftpfile $file_kernel; mw.b $loadaddr 0xFF $spi_pt_size_kernel; tftpboot $loadaddr $tftpfile; if test $? -eq 0; then sf probe; sf erase $spi_pt_addr_kernel $spi_pt_size_kernel; sf write $loadaddr $spi_pt_addr_kernel $spi_pt_size_kernel; echo "\
Kernel Update Done"; fi;
upd_rootfs=setenv tftpfile $file_rootfs; mw.b $loadaddr 0xFF $spi_pt_size_rootfs; tftpboot $loadaddr $tftpfile; if test $? -eq 0; then sf probe; sf erase $spi_pt_addr_rootfs +$filesize; sf write $loadaddr $spi_pt_addr_rootfs $filesize; echo "\
Rootfs Update Done"; fi;
upd_uboot=setenv tftpfile $file_uboot; tftpboot $loadaddr $tftpfile; if test $? -eq 0; then sf probe; sf erase 0 +$filesize; sf write $loadaddr 0 $filesize; echo "\
Uboot Update Done"; fi;
usb0Mode=host
usbActive=0
usbType=2
vxworks_en=no
yuk_ethaddr=00:00:00:EE:51:81

Environment size: 5631/65532 bytes

root@debian:/# fw_printenv
Warning: Bad CRC, using default environment
bootcmd=run distro_bootcmd
bootdelay=2
baudrate=115200
stdin=serial,cros-ec-keyb,usbkbd
stdout=serial,vidconsole
stderr=serial,vidconsole
ethaddr=00:00:11:22:33:44
eth1addr=00:00:11:22:33:45
eth3addr=00:00:11:22:33:46
eth5addr=00:00:11:22:33:47
ipaddr=1.2.3.4
host_boot=if host dev ${devnum}; then setenv devtype host; run scan_dev_for_boot_part; fi
sata_boot=if sata dev ${devnum}; then setenv devtype sata; run scan_dev_for_boot_part; fi
scsi_init=if ${scsi_need_init}; then setenv scsi_need_init false; scsi scan; fi
scsi_boot=run scsi_init; if scsi dev ${devnum}; then setenv devtype scsi; run scan_dev_for_boot_part; fi
virtio_boot=if virtio dev ${devnum}; then setenv devtype virtio; run scan_dev_for_boot_part; fi
boot_prefixes=/ /boot/
boot_scripts=boot.scr.uimg boot.scr
boot_script_dhcp=boot.scr.uimg
boot_targets=host1 host0
boot_syslinux_conf=extlinux/extlinux.conf
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}${boot_syslinux_conf}
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${boot_syslinux_conf}; then echo Found ${prefix}${boot_syslinux_conf}; run boot_extlinux; echo SCRIPT FAILED: continuing...; fi
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script ${prefix}${script}; run boot_a_script; echo SCRIPT FAILED: continuing...; fi; done
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run scan_dev_for_scripts; done;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv devplist 1; for distro_bootpart in ${devplist}; do if fstype ${devtype} ${devnum}:${distro_bootpart} bootfstype; then run scan_dev_for_boot; fi; done
bootcmd_host1=setenv devnum 1; run host_boot
bootcmd_host0=setenv devnum 0; run host_boot
distro_bootcmd=setenv scsi_need_init; for target in ${boot_targets}; do run bootcmd_${target}; done
bootm_size=0x10000000
kernel_addr_r=0x1000000
fdt_addr_r=0xc00000
ramdisk_addr_r=0x2000000
scriptaddr=0x1000
pxefile_addr_r=0x2000
root@debian:/#



Edited 2 time(s). Last edit at 12/31/2020 06:48PM by bonk1990.
Re: Debian on Synology RS816 (Armada 385)
December 31, 2020 06:14PM
Steps 2.b

root@debian:~# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.33.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x6e5f77a4.

Command (m for help): g
Created a new GPT disklabel (GUID: 7004DF3A-A8B9-534A-9967-87A85CCB7697).

Command (m for help): n
Partition number (1-128, default 1):
First sector (2048-62533262, default 2048): 102400
Last sector, +/-sectors or +/-size{K,M,G,T,P} (102400-62533262, default 62533262):

Created a new partition 1 of type 'Linux filesystem' and of size 29.8 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read parti[  295.530662][ T3075]  sdb: sdb1
tion table.
Syncing disks.

root@debian:~#

Re: Debian on Synology RS816 (Armada 385)
December 31, 2020 06:21PM
Steps 3.c

root@debian:/# cd /media/sdb1/boot
root@debian:/media/sdb1/boot# dd if=uImage of=/dev/sdb bs=1MiB seek=10
4+1 records in
4+1 records out
5075485 bytes (5.1 MB, 4.8 MiB) copied, 0.0292306 s, 174 MB/s
root@debian:/media/sdb1/boot# dd if=uInitrd of=/dev/sdb bs=1MiB seek=20
9+1 records in
9+1 records out
9488618 bytes (9.5 MB, 9.0 MiB) copied, 0.0482732 s, 197 MB/s
root@debian:/media/sdb1/boot# sync
root@debian:/# umount /media/sdb1
root@debian:/# e2fsck /dev/sdb1
e2fsck 1.44.5 (15-Dec-2018)
rootfs: clean, 24099/1954064 files, 341006/7803857 blocks
root@debian:/#

But with this steps there is problem with:
[....] Starting OpenBSD Secure Shell server: sshd

Do you need a log with updating kernel as well?



Edited 1 time(s). Last edit at 12/31/2020 06:25PM by bonk1990.
Re: Debian on Synology RS816 (Armada 385)
January 01, 2021 04:01PM
bonk1990,

Thanks!

> Steps 3.c

> But with this steps there is problem with:
>
> [....] Starting OpenBSD Secure Shell server: sshd
>

That's OK. it should occur only if an SSD is used for rootfs.

> Do you need a log with updating kernel as well?

Yes, not crucial, but would be nice. That would be a post that we can refer to at the end of the installation.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Debian on Synology RS816 (Armada 385)
January 01, 2021 08:14PM
RS816/DS116 Installation Instruction Part II


II. Installion with HDD rootfs.

Credits:

- The draft instruction was written by richjn.
- Thanks eine for the original steps to install kernel images on HDD raw sectors.
- Thanks jdwl101 for another installation example on HDD raw sectors.
- Thanks bonk1990 for doing all the testing for this instruction.


Prerequisites:

a. All HDD drives must be removed from the RS816/DS116 when starting the installation.
b. Serial console must be connected during installation.
c. All installation steps must be performed while login as root (sudo will not work).


Steps:


1. Log in as root.

On another Linux box, or boot the RS816/DS116 into Debian USB rootfs (if you have installed it and running this box on USB).

2. Prepare the HDD

If installation is peformed on this box (running Debian USB rootfs), then insert the HDD into the 1st slot. If using another Linux box, then use USB adapter to connect it (if it does not have SATA slot).

Assuming this HDD is assigned as /dev/sdb. For sanity, use the mount command to list all mount points, and observe that the HDD was not mounted automatically. If it was mounted automatically then umount it.

Be extra careful here if using another Linux box to prepare the HDD. Ensure to see the disk you will wipe out is /dev/sdb. If the HDD drive was assigned a different drive letter, then adjust the drive letter accordingly in the next step and all following steps.

2.a. Zero out the first 50MiB of the HDD
dd if=/dev/zero of=/dev/sdb bs=1MiB count=50

2.b. Create a single partition that starts at 50MiB using fdisk. Below is the proper way to create a GPT partition at 50MiB on a large HDD:

fdisk /dev/sdb
Command (m for help): g
Command (m for help): n
Partition number (1-128, default 1):
First sector (2048-62533262, default 2048): 102400
Last sector, +/-sectors or +/-size{K,M,G,T,P} (102400-62533262, default 62533262):
Command (m for help): w

(Partition number and Last sector values are default).

This partition will become /dev/sdb1.

3. Create the rootfs on HDD

3.a. Format this partition with ext3 (or ext4), and label it rootfs.
mkfs.ext3 -L rootfs /dev/sdb1

Note: If Ext4 was used, then the partition must be "finalized" immediately (lazy_itable_init=0).


3.b. Install the rootfs Debian-5.2.9-mvebu-tld-1-rootfs-bodhi.tar.bz2 on this partition (see this thread for download link).

Note: if installing on DS116 then replace the DTB name armada-385-synology-rs816.dtb with armada-385-synology-ds116.dtb.
mount /dev/sdb1 /media/sdb1
cd /media/sdb1
tar -xjf Debian-5.2.9-mvebu-tld-1-rootfs-bodhi.tar.bz2
sync
cd /media/sdb1/boot
cp -a zImage-5.2.9-mvebu-tld-1 zImage.fdt 
cat dts/armada-385-synology-rs816.dtb  >> zImage.fdt
mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n Linux-5.2.9-mvebu-tld-1 -d zImage.fdt uImage
sync

3.c. Write uImage and uInitrd to raw sectors.

cd /media/sdb1/boot
dd if=uImage of=/dev/sdb bs=1MiB seek=10
dd if=uInitrd of=/dev/sdb bs=1MiB seek=20
sync

If it is prepared on the RS816/DS116 then shutdown the box. If the HHD is prepared on another Linux box then unmount it.

4. Booting with the HDD rootfs

Note that if an SDD is used in this rootfs installation (instead of spinning rust HDD), it will take a long time to build up entropy in this kernel version and therefore Debian booting will be delayed for several minutes by OpenSSH. With HDD rootfs, it should be faster. To help making it boot as fast as it can, you can plug in a non-rootfs USB drive, or a USB gadget at this point.

Attach the prepared HDD rootfs to the box 1st SATA slot. And remove any attached USB rootfs drive. Power up, interrupt u-boot at countdown. And execute

setenv load_image_addr 0x02000000
setenv load_initrd_addr 0x3000000
setenv load_image 'echo loading uImage from raw HDD ...; scsi device 0; scsi read $load_image_addr 0x5000 0x2F00'
setenv load_initrd 'echo loading uInitrd from raw HDD ...; scsi device 0; scsi read $load_initrd_addr 0xA000 0x4F00'
setenv set_bootargs 'setenv bootargs "console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 $mtdparts earlyprintk=serial"'
setenv bootcmd_exec 'echo Booting Debian ...; run set_bootargs; setenv fdt_skip_update yes; setenv initrd_high 0xffffffff; run load_image; run load_initrd; bootm $load_image_addr $load_initrd_addr'
setenv bootcmd 'scsi init; run bootcmd_exec; echo Booting Stock OS ...; run bootspi'

DS116 Note: if the installation is performed on Synology DS116, the bootcmd needs to be set to activate the SATA power:
setenv bootcmd 'mw.l f1018100 00008000; scsi init; run bootcmd_exec; echo Booting Stock OS ...; run bootspi'

and then

boot

Observe the serial console log, it should boot all the way to the Debian prompt (with up to a few minute delay due to entropy).

Log in using credential root/root.

After successfully logged in, check the serial log to see if there is any error messages output by the kernel.


5. In Debian, reboot the system.

Now we have booted into the HDD rootfs once, so reboot the system and make it permanent.

shutdown -r now


6. Make HDD installation permanent

Interrupt u-boot at countdown. And execute
setenv load_image_addr 0x02000000
setenv load_initrd_addr 0x3000000
setenv load_image 'echo loading uImage from raw HDD ...; scsi device 0; scsi read $load_image_addr 0x5000 0x2F00'
setenv load_initrd 'echo loading uInitrd from raw HDD ...; scsi device 0; scsi read $load_initrd_addr 0xA000 0x4F00'
setenv set_bootargs 'setenv bootargs "console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 $mtdparts earlyprintk=serial"'
setenv bootcmd_exec 'echo Booting Debian ...; run set_bootargs; setenv fdt_skip_update yes; setenv initrd_high 0xffffffff; run load_image; run load_initrd; bootm $load_image_addr $load_initrd_addr'
setenv bootcmd 'scsi init; run bootcmd_exec; echo Booting Stock OS ...; run bootspi'

DS116 Note: if the installation is performed on Synology DS116, the bootcmd needs to be set to activate the SATA power:
setenv bootcmd 'mw.l f1018100 00008000; scsi init; run bootcmd_exec; echo Booting Stock OS ...; run bootspi'

and then

saveenv
reset

Observe the serial console log, it should reboot all the way to the Debian prompt again. Log in as root/root.

END of Installation.


7. Post installation

7.1. Personalize the system

Follow the post install instruction in the rootfs Note1 to regenerate SSH key. And also read Note3 to see how to ensure the MAC address will be persistent.

7.2. Using USB drives

If another USB drive is plugged in during boot, this USB drive must not contain a rootfs and its partition must be labeled to something other than rootfs. The label rootfs must be solely used for the HDD partition to ensure successful booting.

While the system is running, a USB rootfs can be plugged in and mounted as normally would be.

If you have a USB rootfs already installed and running before, you can set it up to boot with this USB rootfs as a fallback rescue system (More changes in u-boot envs needed to do this) .

7.3 Kernel upgrade

After the install is done, and the box is running normally, upgrade the kernel to the latest version. Later kernel version will have better entropy and will enable Debian booting without an extra USB attached to the box (as a way to gain entropy).

7.3.1 Kernel upgrade example

TBD

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Debian on Synology RS816 (Armada 385)
January 01, 2021 08:37PM
bonk1990,

I've posted the final HDD Installation Instruction above (and remove the old post content). Please proof read it to see if I missed anything!

-bodhi
===========================
Forum Wiki
bodhi's corner
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: