This user guide describes how to run Wi-Fi on the ATWILC1000 SD card or the ATWILC3000 Shield
board on the SAMA5D4 Xplained Ultra running with the Linux® kernel 4.9.
Note: All references to the ATWILC module includes all the devices listed below unless otherwise noted:
• ATWILC1000
• ATWILC3000
The source codes are maintained on GitHub. For latest source codes, see GitHub Linux for ATWILC at
https://github.com/linux4wilc.
Figure 1. ATWILC1000 SD Card and ATWILC3000 Shield Board
The build prerequisite for Linux is a host PC with Linux operating system. The hardware prerequisites are
the following:
• Linux
– SAMA5D4 Xplained Ultra
– ATWILC1000 SD Pro card
– ATWILC3000 Shield board
– USB to Serial adapter (for DEBUG port)
• Common
– Micro-USB cable (Micro-A/Micro-B)
To avoid modifying kernel code, mount the resistor R312 with an approximate value of 120k Ohm in the
location shown below on the ATWILC3000 Shield board.
2. Building Linux for SAMA5D4 Xplained Ultra Board
This section describes how to build the root file system and kernel image to use for ATWILC devices
demo.
This user guide describes general information on the AT91Bootstrap and U-Boot information. For more
details on the AT91Bootstrap and U-Boot, see U-Boot of Linux & Open Source related information for
AT91 Smart ARM Microcontrollers.
2.1 Cloning a Kernel Source and Root File System
The demo uses buildroot to get the suitable toolchain, root file system, and Linux kernel.
The buildroot is cloned from linux4wilc github at the following address:
The buildroot is cloned at the following path in the current directory:
\buildroot4wilc
The current buildroot4wilc is copied from buildroot's repository at git://git.buildroot.net/
buildroot, branch 2017_08, modified with WILC config files (configs/sama5_wilc_defconfig),
and other config files that help run WILC examples.
2.2 Loading SAMA5D4 Configuration File
Use the predefined defconfig file to create the required .config configuration file. This defconfig
file is available in configs folder of the buildroot folder buildroot4wilc.
For SAMA5D4, the sama5_wilc_defconfig defconfig file is used.
To build the root file system for SAMA5D4 with Linux kernel 4.9 for the ATWILC board, browse to the
directory where the files are extracted and create the .config file, using the following commands:
$ cd buildroot4wilc
$ make sama5_wilc_defconfig
2.3 Buildroot File System and Linux Kernel
Start the build operation using $ make command from the buildroot directory.
This $ make command displays the build status on the terminal.
Note: Ensure that the host PC is connected to the internet before starting the build operation and do not
use any build options.
The rootfs.ubi file is generated in the buildroot/output/images directory when the build
operation is complete. The default build will include the WILC modules in the rootfs.ubi.
The driver source files are located at: https://github.com/linux4wilc/linux-at91/tree/master/drivers/staging/wilc1000 in the linux-at91 kernel.
Note: The driver directory name is wilc1000 for legacy reasons only. The driver supports both
ATWILC1000 and ATWILC3000.
Buildroot downloads the Linux kernel as per the buildroot configuration file from GitHub. The downloaded
kernel must be available in the buildroot4wilc/output/build/linux-xxxx path, and is built
automatically during the buildroot build operation.
However, if the kernel is modified after building the buildroot, the user must rebuild the kernel. The
following is the procedure to build the Linux kernel against the toolchain and ARM architecture:
1.Change the directory to the Linux kernel source folder, using the following command:
$ cd output/build/linux-xx
2.Create the kernel with the help of sama5_defconfig defconfig file, using the following command:
$ make ARCH=arm sama5_defconfig
3.Perform the required changes using the menuconfig tool, using the following command:
$ make ARCH=arm menuconfig
4.Build the Linux kernel against the toolchain and ARM architecture, using the following commands:
$ make ARCH=arm CROSS_COMPILE=../../../output/host/opt/ext-toolchain/bin/arm-linuxgnueabihf$ make ARCH=arm CROSS_COMPILE=../../../output/host/opt/ext-toolchain/bin/arm-linuxgnueabihf- zImage
$ make ARCH=arm CROSS_COMPILE=../../../output/host/opt/ext-toolchain/bin/arm-linuxgnueabihf- dtbs
2.After the AT91Bootstrap download, enter in to the cloned directory using the following command:
$ cd at91bootstrap/
3.Build the bootstrap using the following commands:
Assuming that the user is at the AT91Bootstrap root directory, a board/sama5d2_xplained
folder is available which contains several default configuration files. The AT91Bootstrap is
configured and U-Boot binary is loaded from the embedded Multi-Media Controller (eMMC).
4.For the boot ROM code to recognize the valid boot code in the SD card or embedded Multi-Media
3.1.2 U-Boot
Perform the following steps to build the u-boot.
Note: Make sure to install the mkenvimage tool on the Linux machine.
1.Clone the u-boot from github at the following address:
2.After the AT91Bootstrap download, enter in to the cloned directory using the following command:
3.Switch to a new branch u-boot-2018.07-at91, using the following commands:
$make mrproper
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- sama5d2_xplainedemmc_uboot_defconfig
Note: Make sure that the path of the toolchain is exported to PATH environment variable.
This generates the sama5d2_xplained-sdcardboot-uboot-3.8.12.bin binary which is
located in the binary folder.
Controller (eMMC) , rename the sama5d2_xplained-sdcardboot-uboot-3.8.12.bin
AT91bootstrap file to BOOT.bin.
5.Open the u-boot-at91/include/configs/sama5d2_xplained.h file and modify the
definitions for FAT_ENV_DEVICE_AND_PART and CONFIG_BOOTCOMMAND, using the following
commands:
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage
8.Build the .dtb file, using the following command:
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- at91-sama5d2_xplained.dtb
9.Build the modules, using the following command:
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules
When the building process is successful, the final kernel image is available in arch/arm/boot/
directory and the at91-sama5d2_xplained.dtb file is available in arch/arm/boot/dts folder.
3.1.4 Root File System
Use the build root to build the rootfs. For more information, see Building rootfs for SAMA5D2 Xplained
Pro Board.
3.2 Creating an Image for SAMA5D2_Xplained to Boot using eMMC
A single bootable image is required to write on eMMC of the SAMA5D2 Xplained target. This image must
contain all the images (AT91bootstrap, u-boot, kernel and rootfs) built (Cloning and Building Binaries). To
create the image, perform the following steps.
1.Create a directory called junk under home directory. Create a dummy image file sdcard.img,
using the following command:
2.>Move to the junk directory and partition the image file with two partitions, using the following
commands:
$sudo fdisk sdcard.img
Welcome to fdisk(util-linux 2.27.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 0x24d68b30.
Command (m for help): n
Partion type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-4194295, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-4194295, default 4194295):+64M
Created a new partition 1 of type 'Linux' and of size 64 MiB.
Command (m for help): t
Selected partion 1
Partition type (type L to list all types): b
Changed type of partition 'Linux' to 'W95 FAT32'.
Command (m for help): n
Partion type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p):
Using default response p.
Partition number (2-4, default 2):
First sector (133120-4194295, default 133120):
Last sector, +sectors or +size{K,M,G,T,P} (133120-4194295, default4194295):
Created a new partition 2 of type 'Linux' and of size 2 GiB.
Command (m for help): w
The partition table has been altered.
Syncing disks.
Two partitions in sdcard.img file are created successfully.
3.Mount the two partitions on two loop devices, using the following commands:
Note: The numbers 1048576 and 68157440 are the offsets of the partitions.
This partition can be verified using the following command:
fdisk -l sdcard.img
Disk linux4sam-yocto-sama5d2_xplained.img: 2 GiB, 2147479552 bytes, 4194296sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x24d68b30
Device Boot Start End Sectors Size Id Type
linux4sam-yocto-sama5d2_xplained.img1 2048 133119 131072 64M b W95 FAT
linux4sam-yocto-sama5d2_xplained.img2 133120 4194295 4061176 2G 83 Linux
Here, the first partition starts at “2048” location and its physical location is (512 bytes * 2048)
7.In the second partition (EXT4), copy the rootfs , using the following commands:
$ cd ../emmcmntp2
$ sudo tar -zxvf <path> <path to the newly build rootfs tar file>
eg: core-image-minimal-sama5d2-xplained-20181114120437.rootfs.tar.gz
8.Unmount the temporary mount points emmcmntp1, emmcmntp2, and loop device using the
following commands:
2.Download the Linux kernel 4.4.87 from https://www.kernel.org/.
3.Replace the existing WILC1000 driver directory from drivers/staging/wilc1000 directory with
the ATWILC driver available in www.github.com/linux4wilc/.
4.Modify the CONFIG_WILC1000 macro to CONFIG_WILC in the Makfile. This file is available in
drivers/staging/Makfile location.
5.Download the firmware binaries from https://github.com/linux4wilc/firmware and update the existing
firmware files in /firmware/mchp/ of the kernel directory.
6.Configure the kernel using the command make ARCH=arm sama5_defconfig.
7.Open the menuconfig using the command make ARCH=arm menucofig.
8.Select the ATWILC driver module, using the following steps:
8.1.Go to menuconfig.
8.2.Navigate to Device Drivers > Staging driver.
8.3.Select either Atmel WILC SDIO or Atmel WILC SPI based on the requirement.
Note: Ensure that the mmc1 node of arch/arm/boot/dts/at91-sama5d3_xplained.dts file
is similar to the node with the following:
11. Build the modules using the following command:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi modules
12. Build the zImage using the following command:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi zImage
13. Build the dtb file using the following command:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi at91-sama5d2_xplained.dtb
The ATWILC driver modules are built under /drivers/staging/wilc1000.
The wilc.ko, wilc-sdio.ko, and wilc-spi.ko modules are common for ATWILC1000 and
ATWILC3000.
14. Download the SAM-BA tool version SAM-BA 2.16 for Linux software from SAM-BA In-system
Building and Flashing the System Image into the SA...
5. Building and Flashing the System Image into the SAMA5D27-SOM1EK1
This section provides the instructions to build the components for running Linux on the SAMA5D27SOM1-EK1 board. This setup is configured to boot from the micro-SD card slot which leaves the standard
SD card slot open for the ATWILC1000 SDIO board.
Note: Since the reset and chip-enable signals are not brought across the SDIO connector to the
ATWILC1000 module, the SDIO board must be power cycled to reset it in the case of a system reset. If
this is not done then repeated errors will be displayed at the Linux prompt until the card is removed and
re-inserted. This behavior can be seen on a reset via NRST on the board or via a Linux reboot command.
The workaround for the demo board is to remove and re-insert the card. In a client application the reset
and chip enable signals to the ATWILC1000 must be controlled via I/O pins.
If the building process is successful, the final images can be found under the arch/arm/boot/
directory.
5.1 Building the Components
This section provides the procedure to build Bootstrap and U-Boot.
5.1.1 Bootstrap
This section provides the procedure to get source code from the git repository, configure with the default
configuration, customize the AT91Bootstrap based on the default configuration, and build the
AT91Bootstrap to generate the binary.
1.Clone the repository to get the source code, using the following commands:
git clone git://github.com/linux4sam/at91bootstrap.git
cd at91bootstrap/
2.Configure the AT91Bootstrap. It is assumed that the user is at AT91Bootstrap root directory,
board/sama5d27_som1_ek folder which contains several default configuration files:
Configure the AT91Bootstrap to load U-boot binary from SD card.
$ make mrproper
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-ama5d27_som1_eksd_uboot_defconfig
If the configuring process is successful, the .config file can be found at AT91Bootstrap root
directory.
3.Customize the AT91Bootstrap using the menuconfig.
Enter the following command and select SDHC1 as the SD card interface rather than the default
SDHC0.
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
4.Build the AT91Bootstrap using the following command:
On successful building process, the final .bin image can be found in binaries/at91bootstrap.bin folder.
User Guide
DS70005328C-page 15
ATWILC1000/ATWILC3000
Building and Flashing the System Image into the SA...
1.Get the SAMA5D2 default u-boot code by cloning the Linux4sam GitHub U-Boot repository, using
the following commands:
git clone git://github.com/linux4sam/u-boot-at91.git
cd u-boot-at91
2.The source code is fetched from the master branch which leads to the latest branch. If the user
wants to use the other branch, the user can list them and use one of branches by using the
following commands:
3.Compile the u-boot. The U-Boot environment variables can be stored in different media, the config
files specifies where to store the U-Boot environment. Use the following command to add the
environment variables in SD/MMC card:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- sama5d27_som1_ek_mmc1_defconfi
4.Build the U-boot, using the following command:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
The U-boot binary u-boot.bin file is generated.
5.2 Building Kernel
Perform the following steps to build the kernel.
1.Clone the repository to get the source code, using the following commands:
3.Replace the ATWILC1000 driver in drivers/staging/wilc with the content for the driver/
wilc directory on the ATWILC driver repository. The repository is available at: https://github.com/
linux4wilc.
Enter the following command to get the files from linux4wilc:
git clone git://github.com/linux4wilc/driver
4.Modify the following line in linux-at91/drivers/staging/Makefile so that the build finds
the correct directory:
FROM: obj-$(CONFIG_WILC1000) += wilc1000/
TO: obj-$(CONFIG_WILC) += wilc1000/
5.Configure the kernel using the following command:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- sama5_defconfig
6.Modify the default configuration using the menuconfig. Perform the following to open the
menuconfig:
– make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menucofig
– Select the ATWILC driver module, using the following steps: