Driver Disk Installation Guide for ARC-11XX/ARC12XX/ARC16XX/18XX RAID Controller 
on RHEL 6.9 or CentOS 6.9(kernel 2.6.32-696.el6) x86_64 and i386 
=================================================================================
=================================================================================
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 RHEL 6.9 or CentOS 6.9
arcmsr-1.50.0X.09-rhel6.9.iso	- Areca RAID driver for Linux system installation
kmod-arcmsr-1.50.0X.09_rhel6.9-1.x86_64.rpm    - arcmsr driver in rpm format
kmod-arcmsr-1.50.0X.09_rhel6.9-1.i686.rpm
arcmsr-1.50.0X.09-20220304.zip  - arcmsr driver source code
arcmsr-1.50.00.09-source-only.dkms.tar.gz - DKMS enabled driver source code
**********************************************************************************
2. First installation
**********************************************************************************
A. Before Installation
   Copy arcmsr-1.50.0X.09-rhel6.9.iso to top(/) directory of an USB flash drive .
   Give a label to USB flash drive, said ARECA.

B. Installation
	a. Booting from Installation DVD disc.

    For choice legacy DVD drive to install:
    ---------------------------------------
	b. If "Welcom to CentOS 6.9" or "Welcom to Red Hat Enterprise Linux 6.9" Installation screen show up, 
	   highlight cursor on "Install or upgrade an existing system".

	   Press Tab to edit boot command line option.
	   At the end of command line, append " dd"
	   (double quotation mark are not include).

	   Press Enter to start system installation.

    For choice UEFI DVD drive to install:
    ----------------------------------------
	b. When boot "CentOS 6.9" or "Red Hat Enterprise Linux 6.9" start 5 seconds count down, press Enter.
	   Highlight cursor on "CentOS 6.9" or "Red Hat Enterprise Linux 6.9", type e.
	   Highlight cursor on "kernel /images/pxeboot/vmlinuz", type e.
	   Append dd to grub edit as below appearance,
	   
	   	grub edit> kernel /images/pxeboot/vmlinuz dd

	   Press Enter.
	   Now it back to highlight cursor on "kernel /images/pxeboot/vmlinuz", type b to boot.

	c. When ask for "Do you have a driver disk?", insert the USB flash drive, then select Yes.
	d. When ask for "Drive Disk Source", select sda
	e. When ask for "Drive Disk Source" again, select /dev/sda1
	f. When ask for "Select drive disk image", select arcmsr-rhel6.9.iso
	g. When ask for "More Driver Disks?", if you don't want to install other driver, say No.
	h. Continue to system installation.

**********************************************************************************
3. Installing raid driver on an existed System.
**********************************************************************************
	For x86_64 system:
	------------------
	# rpm -ivh kmod-arcmsr-1.50.0X.09_rhel6.9-1.x86_64.rpm
		or
	For i686 system:
	------------------
	# rpm -ivh kmod-arcmsr-1.50.0X.09_rhel6.9-1.i686.rpm

	If you are installing a new kmod-arcmsr to overwrite an old kmod-arcmsr.
	# rpm -ivh --force kmod-arcmsr-1.50.0X.09_rhel6.9-1....rpm

	# depmod -a
	# reboot

**********************************************************************************
4. To compile raid driver on an existed System.
**********************************************************************************

	Before you can compile a new driver, you have to install kernel-headers and kernel-devel.
	These two rpm packages are in RHEL 6.9 DVD installation disc /Packages.
	# rpm -ivh kernel-headers-$(uname -r).rpm
	# rpm -ivh kernel-devel-$(uname -r).rpm

	To compile arcmsr driver, extract driver source code to a new directory.
	# make
	# cp arcmsr.ko  /lib/modules/$(uname -r)/kernel/drivers/scsi/arcmsr/
	# depmod -a
	# dracut -f
	# reboot

**********************************************************************************
5. To install DKMS enabled tarball of arcmsr driver on an existed System.
**********************************************************************************
	Login as root or as superuser.
	Before you can compile a new driver, you have to install kernel-headers and kernel-devel.
	These two rpm packages are in RHEL 6 DVD installation disc /Packages.
	# rpm -ivh kernel-headers-$(uname -r).rpm
	# rpm -ivh kernel-devel-$(uname -r).rpm

	Download DKMS package dkms-<dkmsversion>.noarch.rpm from http://linux.dell.com/dkms/
	Before using DKMS, you must install DKMS package. You can install dkms as following.
	# rpm -ivh dkms-<dkmsversion>.noarch.rpm
	where <moduleversion> is dkms version could be, e.g., 2.2.0.3-1

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

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


	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.
	# rpm -ivh kernel-headers-<kernelver>.rpm
	where <kernelver> is kernel version could be, e.g., 2.6.32-696.el6.$(uname -m)
	
	After installed linux header files, DKMS service will build and install arcmsr driver for new kernel automatically.

**********************************************************************************
6. To support Areca thunderbolt device and cable hotplug
**********************************************************************************
    You have to install intel tbtadm CLI utility, in order to support Areca thunderbolt devices hotplug.
    Before you can install tbtadm, you have to download the tbtadm package source and build it by yourself.

    NOTE!!! a. To support Areca thunderbolt devices, ARC-8050Tx, Linux kernel must be >= v4.13.0.
            b. The tbtadm utility need Linux system kernel >= 4.13.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 kernel v4.17.0.

    The following operation should be run as root user.

  A. To install a new kernel >= v4.13.13:
  ========================================================
    There is most up-to-date kernel rpm package on http://elrepo.org/linux/kernel/el6/x86_64/RPMS
    You can get kernel-ml rpm that was build from mainline Linux kernel.
    They always have the most latest two version of kernel-ml rpm package equivalent to released mainline stable kernel at that time.
    Of course, you can get earlier version from 'https://elrepo.org/tiki/Download' mirror site,
    web site URL that with 'archive' at the end.
    Open a web site with archive, in path ~/archive/kernel/el6/x86_64/RPMS/, there have some earlier build kernel.
    At this moment, I get following two rpms, then install them.
    kernel-ml-devel is need to install for making arcmsr device driver.

    kernel-ml-4.17.0-1.el6.elrepo.x86_64.rpm
    kernel-ml-devel-4.17.0-1.el6.elrepo.x86_64.rpm

    # rpm -ivh kernel-ml-4.17.0-1.el6.elrepo.x86_64.rpm
    # rpm -ivh kernel-ml-devel-4.17.0-1.el6.elrepo.x86_64.rpm

    Reboot to kernel v4.17.0-1.el6.elrepo.x86_64

    Due to the pre-compiled kernel 4.17.0-1.el6.elrepo.x86_64 was configured with CONFIG_HOTPLUG_PCI_ACPI not set.
    So you have to rebuild a kernel with CONFIG_HOTPLUG_PCI_ACPI is set.
    
    Download linux-4.17.tar.xz from https://mirrors.edge.kernel.org/pub/linux/kernel/v4.x/
    # tar -xpvf linux-4.17.tar.xz -C /usr/src/kernels
    # cd /usr/src/kernels/linux-4.17
    # cp /boot/config-4.17.0-1.el6.elrepo.x86_64 .config
    # gedit .config

    Find the line '# CONFIG_HOTPLUG_PCI_ACPI is not set' and modify it to 'CONFIG_HOTPLUG_PCI_ACPI=y'

    # yum install gcc
    # yum install libelf-devel
    # yum install ncurses-devel
    # yum install bison
    # yum install flex
    # yum install openssl-devel
    # make menuconfig
      Save config data before exit.
    # make -j 4

    if you encounter 'arch/x86/Makefile:184: *** Compiler lacks asm-goto support..  Stop.' error,
    gedit arch/x86/Makefile, modify line 184 by add # at the head to '#  $(error Compiler lacks asm-goto support.)'
     
    # make modules_install
    # make install
    Reboot to kernel v4.17

  B. Build arcmsr driver for new kernel
  ========================================================
    If you have installed or build a kernel >= 4.17, then skip to step C., or you have to build arcmsr for new kernel. 

    Extract arcmsr-1.50.0X.09-20220304.zip to /root/arcmsr
    # cd /root/arcmsr

    The following $KERNEL_RELEASE is 4.17, or 'uname -r' get from your new kernel,
    it depends on which version of kernel you have installed or build.
    # make KVER=$KERNEL_RELEASE M=/root/arcmsr
    # cp -f arcmsr.ko /lib/modules/$KERNEL_RELEASE/kernel/drivers/scsi/arcmsr
    # depmod -a
    # cd /boot
    # mv initramfs-$KERNEL_RELEASE.img initramfs-$KERNEL_RELEASE.img.old
    # dracut -k /lib/modules/$KERNEL_RELEASE initramfs-$KERNEL_RELEASE.img $KERNEL_RELEASE 
    # reboot

  C. To build and install tbtadm utility:
  =======================================
    Before to compile tbtadm, you need to prepare txt2tags >= 2.5-16, cmake >= 3.6.0, libboost >= 1.63.0,
    gcc-c++ >= 7.3.0, libstdc++ >= 7.3.0.

   1. Prepare developing environment - txt2tags, cmake tools, libboost, ....

    Download txt2tags-2.6-1.el6.rf.noarch.rpm from https://centos.pkgs.org/6/repoforge-x86_64/txt2tags-2.6-1.el6.rf.noarch.rpm.html
    # rpm -ivh txt2tags-2.6-1.el6.rf.noarch.rpm

    Download cmake-3.6.0-Linux-x86_64.tar.gz from https://cmake.org/files/v3.6/
    extract cmake-3.6.0-Linux-x86_64.tar.gz
    # cd cmake-3.6.0-Linux-x86_64
    # cp -r * /usr/local

    # yum install centos-release-scl-rh
    # yum install devtoolset-7-gcc-c++
    # scl enable devtoolset-7 bash

    To build libboost, download boost_1_60_0.tar.gz from https://sourceforge.net/projects/boost/files/boost/1.60.0/
    extract boost_1_60_0.tar.gz
    # cd boost_1_60_0
    # ./bootstrap.sh --with-libraries=filesystem,system --libdir=/usr/lib64 --includedir=/usr/include
    # ./b2 install

   2. Build tbtadm utility by cmake tool

    To build tbtadm, 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
    # cd thunderbolt-software-user-space-master
    # mkdir build
    # cd build
    # cmake -DCMAKE_BUILD_TYPE=Release -DUDEV_BIN_DIR=/usr ..
    # 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.
    # tbtadm devices
    # tbtadm approve 0-1

**********************************************************************************
7. To set driver parameters value
**********************************************************************************
    arcmsr provided driver parameters setting since v1.30.0X.25.
    Multiple Driver parameters can be set at a time.
    e.g. # insmod arcmsr.ko host_can_queue=72 cmd_per_lun=16

    Setting parameter value out of range will be ignored, parameter remain default value.

    a. To list what driver parameter can be set, parameter default value and value range.
       # modinfo arcmsr

    b. To set driver parameter when you manually install driver.
       (This method will be infeasible if your system was boot from areca Raid volume.)
       e.g. to set parameter host_can_queue value to 64
       # sudo rmmod arcmsr
       # sudo insmod /lib/modules/$(uname -r)/kernel/drivers/scsi/arcmsr/arcmsr.ko host_can_queue=64

    c. To set driver parameter during booting from grub menu.
       When grub menu display, use UP and DOWN arrow key to move cursor to booting target.
       Type e to edit, move cursor to end of line that include "linux   /boot/vmlinuz-x.xx.xx ....."
       Append driver parameter to there.(e.g. to set parameter host_can_queue value to 64)

       linux   /boot/vmlinuz-2.6.32-xx..... ... ... rhgb quiet arcmsr.host_can_queue=64

    d. To set driver parameter for every boot up.
       e.g. to set parameter host_can_queue value to 64
       # sudo gedit /boot/grub2/grub.cfg
           or
       # sudo gedit /boot/efi/EFI/centos/grub.cfg
       Append driver parameter setting to end of line that include "linux   /boot/vmlinuz-x.xx.xx ....."

       linux   /boot/vmlinuz-2.6.32-xx..... ... ... rhgb quiet arcmsr.host_can_queue=64

    e. To verify parameter setting is correct.
       1. To locate adapter parameter directory
          Find Areca host number:
          # dmesg | grep 'scsi host'
          # cat /sys/class/scsi_host/hostX/proc_name
                where hostX could be host0, host1, ...
          The correct output should be arcmsr. If output is (null), check host_fw_model and host_driver_version.
          # cat /sys/class/scsi_host/hostX/host_fw_model
          # cat /sys/class/scsi_host/hostX/host_driver_version

       2. List host_can_queue value
          #  cat /sys/class/scsi_host/hostX/can_queue

       3. List cmd_per_lun value
          #  cat /sys/class/scsi_host/hostX/cmd_per_lun

       4. List cmd_timeout value
          #  cat /sys/block/sdX/device/cmd_timeout
             where sdX could be sda, sdb, ...
