
Driver Installation Guide of ARC-11XX/ARC12XX/ARC16XX/18XX RAID Controller 
         for RHEL 8.3 or CentOS 8.3-2011(kernel 4.18.0-240.el8.x86_64)
=================================================================================
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 8.3 or CentOS 8.3-2011
arcmsr-1.50.0X.09-rhel8.3.iso	- Areca RAID driver for Linux system installation
kmod-arcmsr-1.50.0X.09_rhel8.3-1.x86_64.rpm  - arcmsr driver in rpm format
arcmsr-1.50.0X.09-20220304.zip               - arcmsr driver source code
arcmsr-1.50.00.09-source-only.dkms.tar.gz    - arcmsr DKMS enabled driver source code
genkey.cfg	- configuration file for generating public and private key pair
public_key.der	- public key of pre-compiled driver arcmsr.ko.xz in for first time installation

**********************************************************************************
2. First installation
**********************************************************************************
  A. Before Installation 
  ======================
    Copy arcmsr-1.50.0X.09-rhel8.3.iso and public_key.der to top(/) directory of an USB flash drive .
    Give a label to this USB flash drive, said ARECA.

    If you would like system boots with UEFI Secure Boot, following condition must be satisfied in BIOS setup.
    Or system may not boot properly.
	1. Set "Secure Boot" to "Enabled".
	2. Set "Secure Boot Mode" to "Custom".
	3. Set "Csm support" to "Disabled".
	4. Install all manufacture defaults to Platform Key(PK), Key Exchange Key(KEK), Authorized Signatures(DB), 
	   Forbidden Signatures(DBX).
	5. Set "CPU slot PCI-E Device OPROM (Option ROM)" to "EFI" or "UEFI", if any.
	6. Areca Raid controller System controls->Advanced configuration->BISO selection set to UEFI or AUTO. 
	  (This can be done by web browser through Raid controller Ethernet port. Please refer to areca Raid controller user manual.)
	7. Add Areca Linux driver's public key to Authorized signature database(DB) or Machine Owner Key(MOK) database.
	8. OS is 64 bits version, CPU is 64 bits, and both support UEFI specification.

	 
    You must add Areca Linux driver's public key to the MOKbefore installing operation system. 
    If Areca Linux driver's public key has been in theMOK of system NVRAM, it is not necessary to do it again.

    To add Areca Linux driver's public key to the MOK database, select one of two method to do.

    =============================================================
    1. Enroll public_key.der to MOK database by "mmx64.efi"
    =============================================================
	Copy Areca public_key.der to an USB flash drive with label name ARECA.
	a. Insert the USB flash drive to the target system.
	b. Insert Installation DVD disc to DVD drive.
	c. Booting from UEFI: CD/DVD drive.
	d. When grub2 boot menu show up, type c to get into grub CLI.
	   At grub console, input following command.

		grub> chainloader /EFI/BOOT/mmx64.efi
		grub> boot

	e. When "shim EFI key management" page show up, press Enter.
	f. When "Perform MOK management" menu show up, move cursor to "Enroll key from disk", then press Enter.
	g. When "Seclect Key" menu show up, move cursor to "ARECA", then press Enter.
	   Move cursor to "publick_key.der", then press Enter.
	h. When "[Enroll MOK]" menu show up, move cursour to "continue", then press Enter.
	i. When "Enroll the key(s)?" menu show up, move cursor to "Yes", then press Enter.
	j. When "Perform MOK management" menu show up again, move cursor to "continue to boot", then press Enter.
	k. When back to grub CLI, press Esc.

	The public key is added to the MOK list now, which is persistent.
	Once a key is on the MOK list, it is propagated automatically to the system key ring for this and subsequent 
	reboots, when uEFI Secure Boot is enabled.

    ======================================================
    2. Enroll public_key.der to MOK database by "mokutil"
    ======================================================
	Copy Areca public_key.der to home directory.
	a. In OS, open a terminal console.
	   # sudo mokutil --import public_key.der
	   
	   When prompted, enter a password of your choice. 
	   This password will be used when enrolling the key into the MOK list(at step g.).

	b. Reboot your system.

	c. Upon rebooting, the "Shim UEFI key management" screen appears. 
	   Press Enter to proceed.

	d. Perform MOK management
	   Select: Enroll MOK

	e. [Enroll MOK]
	   Select: View key 0
	   Select: Continue

	f. Enroll the key(s)?
	   Select: Yes

	g. Enroll the key(s)?
	   Password:      <------ give the password that previously requested by mokutil(at step a.)

	h. Reboot the system?
	   Select: OK

	The key is now enrolled.


  B. Installation
  ===============
	a. Insert the USB flash drive to the target system.
	b. Booting from Installation DVD disc.

    For choice legacy DVD drive to install:
    =======================================
	c. When the Installation screen appears, move cursor UP to "Install Red Hat Enterprise Linux 8.3" for RHEL,
	   or move cursor to "Install CentOS Linux 8" for CentOS.

	   Press Tab to edit boot command line option.

	   At the end of command line, append " inst.dd"
	   (double quotation marks are not include).

	   Press Enter to start system installation.

    For choice UEFI DVD drive to install:
    =====================================
	c. When the Installation screen appears, move cursor UP to "Install Red Hat Enterprise Linux 8.3" for RHEL,
	   or move cursor to "Install CentOS Linux 8" for CentOS.

	   type e to edit kernel boot option.

	   At the end of command line that include "linuxefi /images/pxeboot/vmlinuz" append " inst.dd"
	   (double quotation mark are not include).

	   Press Ctrl-x to start system installation.


	d. When following messages show up, type the line number that line with the LABEL of USB flash drive.
	   If you only can see REHL/CentOS install disc, type r and press Enter to refresh devices list.

	   (Page 1 of 1) Driver disk device selection
	         /DEVICE  TYPE     LABEL                UUID
	   RHEL:
	     1)  sr0      iso9660  RHEL-8-3-0-BaseOS-x8 2020-10-09-06-04-38-00
	   CentOS:
	     1)  sr0      iso9660  CentOS-8-3-2011-x86_ 2020-11-18-21-00-12-00

	     2)  sda1     vfat     ARECA                60A4-83FC

	   In this example, type 2 and press Enter
	   
	   (Page 1 of 1) Choose driver disk ISO file
	     1) /media/DD-1/arcmsr-1.50.0X.09-rhel8.3.iso
	     
	   In this example, type 1 and press Enter
	   
	   (Page 1 of 1) Select drivers to install
	     1) [ ] /media/DD-2/rpms/x86_64/kmod-arcmsr-1.50.0X.09_rhel8.3-1.x86_64.rpm
	     
	   In this example, type 1 and press Enter
		   
	   (Page 1 of 1) Select drivers to install
	     1) [x] /media/DD-2/rpms/x86_64/kmod-arcmsr-1.50.0X.09_rhel8.3-1.x86_64.rpm
		     
	   In this example, type c and press Enter
		   
	e. After driver installation, type c and press Enter to continue the system installation. 


**********************************************************************************
3. Installing raid driver on an existed System.
**********************************************************************************
	login as root

	============= For UEFI Secure Boot Only ==========================================
	If you had ever added areca public key to MOK list on this PC, do not do it again.
	# mokutil --import public_key.der
	# reboot
	==================================================================================

	# rpm -ivh kmod-arcmsr-1.50.0X.09_rhel8.3-1.x86_64.rpm
	# depmod -a

	If your system was booted from Areca volume, you have to rebuild initial ramdisk.
	# dracut --kver $(uname -r)

	# 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 8.3 DVD installation disc /BaseOS/Packages.

        if your target kernel version is not (uname -r), then replace following
	$(uname -r) by target kernel version

	# 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 KDIR=/lib/modules/$(uname -r)/build

	============================ For UEFI Secure Boot Only ===========================================================
	For "UEFI Secure Boot" was Enabled in M/B BIOS, you have to generate a pair of public and private key by yourself.
	If you had ever generated key pair and added public key to MOK list once, do not do it again.

	Copy genkey.cfg to current directory, run following to generate key pair and add public key to MOK list.
	# openssl req -x509 -new -nodes -utf8 -sha256 -days 36500 -batch -config genkey.cfg -outform DER -out public_key.der -keyout private_key.priv
	# mokutil --import public_key.der

	Signing driver module with the private/public key for each time you build new driver.
	# /usr/src/kernels/$(uname -r)/scripts/sign-file sha256 ./private_key.priv ./public_key.der ./arcmsr.ko
	==================================================================================================================

	# xz arcmsr.ko
	# mkdir -p /lib/modules/$(uname -r)/extra/arcmsr
	# cp -f arcmsr.ko.xz /lib/modules/$(uname -r)/extra/arcmsr
	# depmod -a $(uname -r)

	If your system was booted from Areca volume, you have to rebuild initial ramdisk.
	# dracut --kver $(uname -r)

	# 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 8.3 DVD installation disc /BaseOS/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., 4.18.0-240.el8.$(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
**********************************************************************************
	RHEL 8.3/CentOS 8.3-2011 has been build-in support thunderbolt 2, 3 devices.
	To support Areca thunderbolt devices, like ARC-8050Tx, 
	arcmsr driver version must be >= v1.40.0X.05-20190309.
	This version's driver was built-in in Linux kernel since v4.17.

	The first time of connection thunderbolt device to system, it may need to authorize the device to system.
	From GNOME Settings->Devices->Thunderbolt, click the 'connected' but not yet authorized device,
	confirm the 'authorize and connect' to make it 'authorized'.

**********************************************************************************
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.xz 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)/extra/arcmsr/arcmsr.ko.xz 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  ($root) /boot/vmlinux-4.18.0-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/vmlinux-4.18.0-xx..... ... ... quiet LANG=en_US.UTF-8 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, ...
