How to compile drivers for Linux automation in Ghost Solution Suite
search cancel

How to compile drivers for Linux automation in Ghost Solution Suite

book

Article ID: 181055

calendar_today

Updated On:

Products

Ghost Solution Suite

Issue/Introduction

Question
How do I compile drivers for Linux automation in Ghost Solution Suite?

Resolution

Question
How do I compile drivers for Linux automation in Ghost Solution Suite?

Answer
Compiling drivers for Linux and adding them to your Linux Automation image

This article explains how to compile drivers for Linux automation and add them to your Linux image. Compiling drivers for Linux automation can be a daunting task, but once your environment is setup and you've done it a few times it becomes quite easy.

To complete this procedure, you will need access to a computer running Linux (most any distro will work; these steps were written using Centos 6.5). You will also need to access a Ghost Solution Suite server.  It is presumed you have a basic understanding of Linux and Ghost Solution Suite. Ghost Solution Suite 3.x , along with Linux kernel version 3.18.22/, were used in the creation of this document. 

Note: The Linux pre-boot environment shipping with Ghost Solution Suite uses kernel 3.18.22 . Compile drivers against this kernel version and source.

Preparing Your Linux Computer

NOTE: If using Centos or Redhat an account with sudo or root access is required.

First, you will need to setup your Linux computer to compile drivers for Linux automation. This involves installing the correct compiler, downloading the kernel source code, adding the configuration information from your Linux automation image, and compiling the source code. You should only have to do this part once; after you have everything setup you can skip to the Compiling Drivers section.

  1. Verify the Linux kernel version your are using for automation. You can do this using Boot Disk Creator. From the GSS console click Tools > Boot Disk Creator. From Boot Disk Creator, click Tools > Installed Pre-boot Operating Systems. In the box labeled Linux, the version number will be the kernel version you are using. Make sure you get the kernel version for the architecture you are using (that is, x86, x64). In Ghost Solution Suite 3.x the version number should be 3.18.22  for all architectures.
     
  2. Now go to https://mirrors.edge.kernel.org/pub/linux/kernel/v3.x/. Scroll down to the .zip file that corresponds to the kernel version you are using; it should be linux-3.18.22.tar.gz. Make sure you get the correct file—do not get one of the patch or changelog files.

  3. Copy the file to your Linux computer (if it isn't there already) and extract it to a permanent location. In this article we'll use /usr/src, Copy the file to /usr/src (or the place of your choosing) then type "tar xfz linux-3.18.22.tar.gz". You may need root access to use that directory, so if you don't have root access then you can put the files somewhere else (in your home directory, for example).


     
  4. There are some dependent packages to compile the drivers, you will need to do yum install on the following:
    1. ncurses
    2. ncurses-devel
    3. kernel-devel
    4. gcc
    5. make

Copy the config from the eXpress share or the linux pre boot. 

  1. Copy from eXpress Share
    1. mount the express share to a temp directory, I am going to use mnt for this article
    2. mount -t cifs //<GSS server ip>/eXpress /mnt -o username=<admin account>,password=<PASSWORD> (NOTE:change everything in <> to your environment)
    3. cp /mnt/BootWiz/platforms/Linux/x86_64/Build/config.x86_64 /usr/src/kernel-3.18.22/.config 
      1. NOTE if you want to do this for x86 drivers replace x86_64 with x86
  2. Copy config from linux pre boot.
    1. Now you need to boot a computer into Linux automation and copy the config file from it. You will need this so any drivers you compile are compiled with the same kernel options that the automation kernel has been compiled with. Create a simple Run Script task in DS with the following command:

      "cp /proc/config.gz /mnt/ds"

      The file config.gz will now be in at the root of your deployment share on your Deployment Solution server. Copy it to your Linux computer.

  3. With the config.gz file on your Linux computer, copy it into the directory where your kernel source files are located. So if you copied your kernel source to /usr/src, then you would copy the config.gz file to /usr/src/linux-3.18.22. Now change to that directory and unzip the file with the following command: "gzip -d config.gz". You should now have a file named confg. Rename it to .config (notice the period in front of config) with the command "mv config .config". If you do an ls, you'll notice that the config file has disappeared. In Linux, files with a period (.) prefix are hidden files, so they won't show up when you do an ls. If you really want to make sure it is there use "ls -a", and it will show up.

  4. Now you need to build the kernel; change to the directory you created the kernel in (in this example you would change to /usr/src/linux-2.6.18.8). Type one of the following commands (depending on your architecture): This will take awhile, depending on the speed of your computer.
     
    • "make oldconfig" (x86 and x64)
    • "make menuconfig"
    • enable the module you need under Device Driver>Network Device Support >Ethernet Driver Support> find the driver you want to compile and hit TAB till select is highlight and hit space bar to enable the driver to comple
    • Tab to Save and hit space bar to save config changes and save to .config
    • select exit till the menuconfig utility closes.

Compiling the Driver

Now everything should be set up and ready to go; from here on out you can skip the preparation steps and just compile drivers any time you like.

  • in a terminal run the following command "make modules" 
    • NOTE: first time compiling will take 10+ minutes depending on the hardware you are compiliing one
  • in the output after compiling done you should see the path to the drivers you need. See below
  • copy the compiled drivers to the eXpress share that is mounted to /mnt
 

Note: The compilation process may fail with errors. If you are sure you did everything correctly then it is possible the driver source code is not compatible with the kernel version you are using. In this case you will have to find a different version of the driver source code. It is not uncommon for a variable declaration or function call that the driver expects the kernel to provide to be missing in later kernel releases. Linux kernels are released very frequently and anything is fair game for changing each time. For a particular driver that was needed once, 20 different versions were gone through before the one was found that worked. Even when a driver compiles that doesn't mean it will load properly, it may still complain about missing variables/function calls when it is loaded. That is the joy of working in Linux—you just have to keep trying. The advantage is someone else has probably had your same problem, and you can find how to fix it using the Internet.

Note: If the compilation succeeds, but has warnings this may not be a problem, try loading the driver to see how it goes.

Adding Drivers to the Linux Automation Image

To use the drivers, you need to copy them to the correct location on your Deployment Solution server and then regenerate your image. To do so do the following:

  1. Copy the .ko files to the folder: ".\Boozwiz\platforms\Linux\x86\Drivers\CUSTOM\lib\modules\_ver_\kernel\opt\bdc"

    Note: The folders may have to be created. The paths above are relative to the deployment share. Change the x86 folder to correspond to the architecture you are using (x86, x64, IA64).
     
  2. Regenerate your Linux image, this can be done in PXE Configuration Manager. Edit the boot image and click next until the image regenerates. Then click Save on the main PXE Configuration Manager menu to save the changes.

If you don't want to add the driver to your image or want to load it using a script you can load it with the following commands:

  1. Copy the driver to the Linux automation local file system (after it boots).
  2. Change to the directory where you copied the driver to.
  3. Type depmod -ae.
  4. Type modprobe drivername, and omit the .ko extension, so for the bnx2 driver type "modprobe bnx2". If you get an error, you can try the -f parameter, which tries to force the driver to load. You may get a warning about a tainted kernel but this isn't a huge deal.

Important: The drivers you just compiled will only work with the kernel version they were compiled with. If you upgrade your Linux automation kernel, you will have to re-setup your Linux computer and recompile the drivers.

 

GSS 3.3 RU8 +

The following steps can be used for LinPE based on frm2 (6.9.11004+) file that was delivered with GSS 3.3 RU8 or newer release:

With new frm we recommend to build drivers directly on LinPe environment

 

Boot from LinPE (x86 or x64 correspondingly)

It will be more convenient to set up an SSH server and work over SSH. This step may be skipped

 

#install ssh

apt update
apt -y install ssh

#specify password 
echo 'root:<your password>'
sed -i 's/#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config
service ssh restart

#show IP address of your LinPe
ip a

 

Now you can connect to your LinPe over SSH

ssh root@<LinPe IP>

 

Prepare build environment

apt update
apt y --reinstall install gcc wget make binutils linux-headers-$(uname -r)

 

#Now you are ready to build your drivers. You can build mentioned brcm driver with following commands ( this is only example your drivers will vary )

 

#Download and build

mkdir /build && cd /build
wget https://dl.dell.com/FOLDER06347117M/1/Bcom_LAN_216.0.333.12_NX_Linux_Source_216.0.333.12.tar.gz
tar xvfz Bcom_LAN_216.0.333.12_NX_Linux_Source_216.0.333.12.tar.gz
tar xvfz Bcom_LAN_216.0.333.12_NX_Linux_Source_216.0.333.12/tg3-3.139a.tar.gz
cd tg3-3.139a
make

#verify compiled driver

cp tg3.ko /lib/modules/$(uname -r)/
modprobe -v tg3
lsmod