Driver Disk Installation Guide for ARC-11XX/ARC12XX/ARC16XX/18XX RAID Controller 
on Ubuntu 16.04.1 i686 and x86_64(kernel 4.4.0-31)
=================================================================================
=================================================================================
Linux SCSI driver technical support 
Mail address: support@areca.com.tw
Web site: www.areca.com.tw
==================================================================================
==================================================================================
 
**********************************************************************************   
1. Contents									**
**********************************************************************************

readme.txt	- the installation guide of ARC-11XX/12XX/16XX/18XX driver for Ubuntu
arcmsr-ubuntu-16.04.1.zip	- Areca RAID driver disk for system installation
arcmsr_1.50.0X.05-ubuntu16.04.1_k4.4.0-31_i386.deb
arcmsr_1.50.0X.05-ubuntu16.04.1_k4.4.0-31_x86_64.deb
arcmsr-1.50.00.05-source-only.dkms.tar.gz - DKMS enabled driver source code
arcmsr-1.50.0X.05-20210429.zip	- driver source code

**********************************************************************
2. First time Installation                                 	    **
**********************************************************************

A. Before Installation 

   Extract arcmsr-ubuntu-16.04.1.zip to an USB flash drive.

B. Install ubuntu server

	1) Insert the Areca driver USB flash disk to target system.
	2) Start Ubuntu installation by booting from Ubuntu installation DVD disc.
	3) On the Welcom screen, select "Install Ubuntu Server", then press Enter.
	4) At "Select a language" screen, Press "CTRL+ALT+F2" to switch to console.
	   Login with username 'ubuntu' and empty password.
	5) Type the following commands:
	   # mkdir /arcmsr /tmp/arcmsr
	   # mount /dev/sda1 /arcmsr
	   # cp -f /arcmsr/* /tmp/arcmsr
	   # umount /arcmsr
	6) Remove the USB flash drive from the USB port and then type:
	   # cd /tmp/arcmsr
	   # sh pre-install.sh
	7) Press "Alt+F1" back to installation screen.
	8) Continue the installation process. 
	9) Do not reboot after the installation is complete. press "Ctrl+Alt+F2" to
	   switch to console 2 and type the following commands:
	   # mkdir /target/tmp/arcmsr
	   # cp /tmp/arcmsr/* /target/tmp/arcmsr
	   # chroot /target
	   # cd /tmp/arcmsr
	   # sh post-install.sh
	   # exit
	10) Press "Alt+F1" to continue. 

C. Install ubuntu Desktop

	1) Insert the Areca driver USB flash disk to target system.
	2) Start Ubuntu installation by booting from Ubuntu installation DVD disc.
	3) On the Ubuntu menu, stay cursor at "Try Ubuntu without installing", then press Enter.
	4) At Ubuntu desktop, open a terminal console.
	5) Type the following commands:
	   # mount
	   Find the driver USB device /dev/sda1 mount point, and unmount it.
	   # sudo mkdir /arcmsr /tmp/arcmsr
	   # sudo mount /dev/sda1 /arcmsr
	   # sudo cp -f /arcmsr/* /tmp/arcmsr
	   # sudo umount /arcmsr
	6) Remove the USB flash drive from the USB port and then type:
	   # cd /tmp/arcmsr
	   # sudo sh pre-install.sh
	7) Click th "Install Ubuntu 16.04.1 LTS" icon, to start Ubuntu system installation.
	8) Do not reboot after the installation is complete.
	   Switch to terminal console and type the following commands:
	   # mkdir /target/tmp/arcmsr
	   # cp /tmp/arcmsr/* /target/tmp/arcmsr
	   # sudo chroot /target
	   # cd /tmp/arcmsr
	   # sudo sh post-install.sh
	   # exit
	9) Now you can restart the system. 

**********************************************************************
3. Installing raid driver on an Existing System	
**********************************************************************

	For x86_64 system:
	# sudo dpkg -i arcmsr_1.50.0X.05-ubuntu16.04.1_k4.4.0-31_x86_64.deb

	For i386, i686 system:
	# sudo dpkg -i arcmsr_1.50.0X.05-ubuntu16.04.1_k4.4.0-31_i386.deb

	# sudo depmod -a
	# sudo update-initramfs -u

	Reboot you system to make arcmsr driver take effect.

**********************************************************************************
4. To install DKMS enabled tarball of arcmsr driver on an Existing System.
**********************************************************************************
	Before using DKMS, you must install DKMS package. You can install dkms as following.
	# sudo apt-get install dkms

	Copy arcmsr DKMS enabled tarball to home directory.
	In order to load tarball into the DKMS tree, you must use the following command:

	# sudo dkms ldtarball --archive=./arcmsr-<module version>-source-only.dkms.tar.gz
	where <module version> could be, e.g., 1.50.00.05
	arcmsr source code will be added to DKMS tree.
	
	To build arcmsr driver module
	# sudo dkms build -m arcmsr -v <module version>
	
	To install arcmsr driver module
	# sudo dkms install -m arcmsr -v <module version>


	If you are upgrading linux kernel, then you have to install the corresponding linux-headers-<kernelver> before
	reboot your system. New kernel image can be find in /boot, corresponding new linux header can be find in /usr/src.
	If you can not find new linux header in /usr/src, you can install it as following.
	# sudo apt-get install linux-headers-<kernelver>
	where <kernelver> could be, e.g., 4.4.0-31-generic.
	
	After installed linux header files, DKMS service will build and install arcmsr driver for new kernel automatically.

**********************************************************************************
5. To compile arcmsr driver on an Existing System.
**********************************************************************************
	Unzip arcmsr-1.50.0X.05-20210429.zip to a directory and change to.
	# sudo make
	# sudo cp -f arcmsr.ko /lib/modules/$(uname -r)/kernel/drivers/scsi/arcmsr/
	# sudo depmod -a
	# sudo insmod arcmsr.ko

**********************************************************************************
6. To support thunderbolt cable hotplug
**********************************************************************************

You have to install intel tbtadm CLI utility, in order to support thunderbolt cable hotplug.
Before you install tbtadm you have to download the package source and build it.

NOTE!!! a. To support Areca thunderbolt devices, ARC-8050Tx, Linux kernel must be >= v4.13.
	b. The tbtadm utility need Linux system kernel >= 4.13.
        c. To support thunderbolt cable hotplug, arcmsr driver must be >= v1.40.0X.05-20180309.
           This version's driver was built-in in Linux kernel since v4.17.

A. To install a new kernel >= v4.13:
========================================================
Download kernel and headers file form http://kernel.ubuntu.com/~kernel-ppa/mainline/
You have to install linux-headers-..._all.deb, linux-headers-..._amd64.deb, linux-image-,,,_amd64.deb
e.g.:
   # wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.14.30/linux-headers-4.14.30-041430_4.14.30-041430.201803250538_all.deb
   # wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.14.30/linux-headers-4.14.30-041430-generic_4.14.30-041430.201803250538_amd64.deb
   # wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.14.30/linux-image-4.14.30-041430-generic_4.14.30-041430.201803250538_amd64.deb
   # sudo dpkg -i *.deb
   # sudo grub-mkconfig -o /boot/grub/grub.cfg

B. Build arcmsr driver for new kernel
========================================================
   Here we assume kernel version is 4.14.30-041430-generic(from step A. installed kernel).
   Extract arcmsr.1.40.0X.05-20180309.zip to ./arcmsr
   # cd arcmsr
   # apt-get install libelf-dev g++
   # make KVER=4.14.30-041430-generic
   # sudo cp -f arcmsr.ko /lib/modules/4.14.30-041430-generic/kernel/drivers/scsi/arcmsr
   # sudo depmod -a
   # sudo update-initramfs -u -k 4.14.30-041430-generic
   # sudo reboot

C. To build and install tbtadm utility:
========================================================
   # sudo apt-get install cmake libboost-filesystem-dev txt2tags pkg-config g++
   Download thunderbolt-software-user-space-master.zip from https://github.com/intel/thunderbolt-software-user-space
   (click the pull down menu of "Clone or download", then select 'Download ZIP')
   Extract thunderbolt-software-user-space-master.zip to thunderbolt-software-user-space-master.
   # cd thunderbolt-software-user-space-master
   # mkdir build
   # cd build
   # sudo cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr ..
   # sudo cmake --build . --target install

Now tbtadm utility was installed.
Following the instruction of readme file on tbtadm package source to make thunderbolt adapter in ACL.
i.e.	# tbtadm devices
	# tbtadm approve 0-1

NOTE!!! If you upgrade to Ubuntu higher version or kernel, you may need to remove both thunderbolt-software-user-space-master and build directories.
        And redo above step B. and C. to rebuild and install tbtadm utility, or tbtadm may not work.
