Advantech FWA-1212VC User guide

Type
User guide
Copyright 2020 All rights reserved. Advantech Co. Ltd.
ADVANTECH
LINUX PLATFORM SOFTWARE GUIDE
FWA-1212VC
Revision 0.4
Copyright 2020. All rights reserved. Advantech Co. Ltd. Page 2
Revision History
Date [mm/dd/yyyy]
Revision
Modifications
12/24/2019
0.1
Initial version
06/15/2020
0.2
Update GPIO function and Software Define LED
Update BIOS version to V0.08
9/24/2020
0.3
Update Software Defined Button
12/15/2020
0.4
Update Software tools name mapping to
ServeriManager package name
Update Control HW GPIO and Control SW
defined LED
Copyright 2020. All rights reserved. Advantech Co. Ltd. Page 3
Table of Contents
1. INTRODUCTION .................................................................................... 5
1.1 OVERVIEW .......................................................................................................................... 5
1.2 TARGET AUDIENCE ............................................................................................................ 5
1.3 BIOS AND BMC VERSIONS .............................................................................................. 5
1.4 OS DISTRIBUTION AND KERNEL VERSION ........................................................................ 5
1.4.1 How to upgrade Linux Kernel............................................................................................................. 5
1.5 FILES AND SOFTWARE TOOLS ........................................................................................... 6
2. WATCHDOG FUNCTION ...................................................................... 7
2.1 WATCHDOG ON PCH ......................................................................................................... 7
2.2 WATCHDOG ON HWM ...................................................................................................... 8
3. GPIO FUNCTION ................................................................................. 11
3.1 HW GPIO PIN ................................................................................................................. 11
3.2 CONTROL HW GPIO ....................................................................................................... 11
3.2.1 Locate i2c bus of IO expander .......................................................................................................... 11
3.2.2 I2c raw command to control ............................................................................................................. 12
3.2.3 Kernel GPIO sysfs to control.............................................................................................................. 13
4. SOFTWARE DEFINED LED ............................................................... 16
4.1 LOCATE I2C BUS OF IO EXPANDER ................................................................................. 17
4.2 CONTROL SOFTWARE DEFINED LED ............................................................................ 18
4.2.1 I2c raw command to control ............................................................................................................. 18
4.2.2 Kernel GPIO sysfs to control.............................................................................................................. 19
4.2.3 Kernel LED sysfs to control ............................................................................................................... 21
5. SOFTWARE DEFINED BUTTON ..................................................... 24
5.1 LOAD SOFTWARE BUTTON WITH LINUX SERVICE ........................................................ 24
5.1.1 Set SW button access mode ............................................................................................................... 24
5.1.2 Install and configure acpid ................................................................................................................. 24
5.1.3 Configure systemd-logind .................................................................................................................. 26
5.2 LOAD SOFTWARE BUTTON WITH SW BUTTON DRIVER ................................................ 27
5.2.1 Set SW button access mode ............................................................................................................... 27
5.2.2 Load Software Button Interface Driver ........................................................................................ 27
5.2.3 Software Button Daemon ................................................................................................................... 27
5.2.4 Sample Config file and scripts .......................................................................................................... 29
6. AFRU (ADVANTECH FRU UTILITY) .............................................. 31
6.1 INTRODUCTION ................................................................................................................ 31
6.2 COMMAND EXAMPLE ....................................................................................................... 31
6.3 OTHER COMMAND OPTIONS ........................................................................................... 32
7. SENSORS ............................................................................................... 33
7.1 APM (ADVANTECH PLATFORM MONITOR) ................................................................. 33
7.2 LM-SENSORS ................................................................................................................... 34
Copyright 2020. All rights reserved. Advantech Co. Ltd. Page 4
8. NDI(NETWORK DEVICE IDENTIFIER) ......................................... 38
8.1 INTRODUCTION ................................................................................................................ 38
8.2 COMMAND AND USAGE ................................................................................................... 38
Copyright 2020. All rights reserved. Advantech Co. Ltd. Page 5
1. INTRODUCTION
1.1 Overview
In Advantech’s platform, there are several software interface for various usage, like software
defined LED/Button, hardware sensors and watchdog. Customer could leverage those
interfaces in their Linux or application, for example, reading hardware sensors to monitor
health of platform, defining operation triggered by software defined button, setting a
watchdog to reboot system when application getting stuck, or light on software defined LED
for application notification. This document describes the platform software components and
provides customer with an easy approach for software porting. Every component is
described in different chapter and also multiple approaches for different scenario.
1.2 Target Audience
The guide is for engineers at customer’s side, with software background and knowledge of
Linux, who knows how to use kernel module and device node in Linux, also knows how to
configure and compile Linux kernel.
1.3 BIOS and BMC Versions
The software components have been validated on the supported platforms using the
firmware versions below:
Platform
BMC Version
BIOS Version
FWA-1212VC
N/A
V0.08
1.4 OS distribution and kernel version
The software components will be demonstrated using the following OS distribution and
Linux kernel version:
Platform
Os distribution
Kernel Version
FWA-1212VC
Ubuntu 18.04
4.15.0
According Intel announced, it support kernel above 4.14, here this document is based on
Ubuntu 18.04 with updated kernel 4.15.0.
1.4.1 How to upgrade Linux Kernel
User can follow the steps below to upgrade Linux kernel:
1. Go to Ubuntu official main page http://kernel.ubuntu.com/~kernel-ppa/mainline/,
Choose the kernel version then download.
# wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v4.15.1/linux-headers-4.15.1-
041501_4.15.1-041501.201802031831_all.deb
# wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v4.15.1/linux-headers-4.15.1-
041501-generic_4.15.1-041501.201802031831_amd64.deb
Copyright 2020. All rights reserved. Advantech Co. Ltd. Page 6
# wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v4.15.1/linux-image-4.15.1-
041501-generic_4.15.1-041501.201802031831_amd64.deb
2. Install packages
# sudo dpkg -i linux-headers-4.15.1-041501_4.15.1-041501.201802031831_all.deb linux-
headers-4.15.1-041501-generic_4.15.1-041501.201802031831_amd64.deb linux-image-
4.15.1-041501-generic_4.15.1-041501.201802031831_amd64.deb
3. Reboot system and enter following command to check kernel version
# uname -sr
Linux 4.15.1-041501-generic
1.5 Files and Software tools
The followings are files and software tools which are needed for demonstration with this
guide, contact your local Advantech FAE for these files and software tools
Software Package
&driver
Version
Description
wdt_nct5523
0.04
Sample code to control
watchdog on HWM
FRU utility
02.36
Advantech FRU Utility
Sensor Reader
0.32
Advantech Platform Monitor
Network device identifier
1.20
Network Device Indentify
leds-pca9554
0.03
SW defined LED driver
File
Description
fwa-1212vc.yaml
Sensor-Reader config file for FWA-1212VC
sensors3_fwa1212.conf
lm-sensor config file for FWA-1212VC
Copyright 2020. All rights reserved. Advantech Co. Ltd. Page 7
2. WATCHDOG FUNCTION
There are two kinds of watchdogs on platform, and those could work separately. One is PCH
watchdog, the other is HWM, both could reset platform when watchdog is biting. In this
section, we will demonstrate watchdog functions on our platform.
2.1 Watchdog on PCH
PCH watchdog is supported by kernel’s driver module, wdat_wdt since kernel 4.9 and
itco_wdt before kernel 4.9. The driver populates a dev file /dev/watchdog when loading into
kernel, and timeout is set as a parameter of this module. The watchdog is triggered while
dev file is touched or opened. Use ‘modinfo wdat_wdt (‘modinfo itco_wdt for kernel before
4.9) to get more details about this module.
There is an open source software watchdog daemon to use watchdog easier. Watchdog
daemon manages kernel module and /dev/watchdog and keeps feeding it often enough to
keep the kernel from resetting. The configuration file is /etc/watchdog.conf which contains
feed interval and reset timeout options. The default reset timeout is 60 seconds, so platform
will be reset if not feeding watchdog in 60 seconds.
Please refer to the following website for more information:
https://linux.die.net/man/8/watchdog
https://linux.die.net/man/5/watchdog.conf
Here is how to verify watchdog functionality. In this demonstration, the watchdog
configuration file is configured in an abnormal way just for quick verification.
We will deliberately set our interval longer than the watchdog-timeout to force a
watchdog hardware reset. Please note that this hardware reset without graceful shutdown
might damage file system, so please don’t do it in a service online system.
Please follow the steps below to perform the test.
Step 1: Install watchdog software
# apt-get install watchdog
Step 2: Make sure the driver is probed
# sudo modprobe wdat_wdt
# lsmod |grep wdat_wdt
wdat_wdt 16384 0
Step 3: Add a line to the file /etc/watchdog.conf
watchdog-device = /dev/watchdog
Copyright 2020. All rights reserved. Advantech Co. Ltd. Page 8
Step 4: Make sure the watchdog device is not busy. The watchdog device will be occupied in
some cases, user need to free the device first to perform the test. The wd_identify is a
simplified software watchdog daemon, it can get the identification string from the watchdog
if it opens /dev/watchdog successfully.
# sudo wd_identify
wdat_wdt
If the command output is device or resource busy’, use the following command to free the
watchdog device
# pkill -9 watchdog
Step 5: For normal usage, interval should be shorter than the watchdog-timeout so that
the watchdog daemon will feed /dev/watchdog before the hardware reset. In such case,
user can configure file /etc/watchdog.conf as below.
watchdog-timeout = 60
interval = 30
Step 6: To test the functionality of watchdog hardware, we need to force a hardware reset
by setting interval longer than the watchdog-timeout. Firstly, copy the file
/etc/watchdog.conf to ~/watchdog_test.conf, then add two lines to the file
~/watchdog_test.conf.
cp /etc/watchdog.conf ~/watchdog_test.conf
watchdog-timeout = 5
interval = 30
Step 7: Enter following command and the system will reboot after 5 seconds (Please note
that this is not a graceful shutdown and might be detrimental to your file system.)
# sudo watchdog -f -c ~/watchdog_test.conf
2.2 Watchdog on HWM
HWM watchdog could be accessed by Linux io port 0x2E/0x2F. Advantech provides sample
code to demonstrate watchdog function on SuperIO. This sample code is written in C
language, nct5523.c, nct5523.h. Most important watchdog instructions are in
function nct5523.c.
Linux io port for HWM is singleton, sample code had not include semaphore to prevent
access confliction. Please avoid confliction in usage.
Copyright 2020. All rights reserved. Advantech Co. Ltd. Page 9
User can modify sample code to accomplish specific needs. A normal using example is shown
below and a test to force the hardware reset. Please note that ungraceful shutdown might
damage your file system, do not do it in a service online system.
Step 1: Enter the folder wdt_nct5523 and compile by following commands:
# make
Step 2: Enter following command to acquire utility usage
# sudo ./wdt_nct5523 -h
Test Watch dog function for nct5523
Version: v0.04
Usage:
wdt_nct5523 [time_count] [time_type]
[time_count]:
Timeout value, 0 =< time_count <= 255.
If the tiemout value is 0 then stop watchdog timer
[time_type]:
's' : second;
'm' : minute;
Example:
Help:
wdt_nct5523 -h
DEFAULT Setting(8 seconds timeout):
wdt_nct5523
Setting 10 seconds timeout:
wdt_nct5523 10 s
Setting 5 minutes timeout:
wdt_nct5523 5 m
Step 3: Watchdog has to be re-count once started during timeout, or system will be hard
reset while watchdog biting. The script on below is an example for showing how to feed
watchdog every 1 minutes.
#!/bin/bash
echo "start to run watchdog script!"
while [ 1 ]
Copyright 2020. All rights reserved. Advantech Co. Ltd. Page 10
do
./wdt_nct5523 10 s
sleep 60
done
The script will infinitely set the watchdog timeout to 10 seconds every 1 second, so that the
hardware reset will never occur unless the script is terminated.
Step 4: Enter following command and the system will reboot after 10 seconds (Please do not
do it in a service online system)
# sudo ./ wdt_nct5523 10 s
Copyright 2020. All rights reserved. Advantech Co. Ltd. Page 11
3. GPIO FUNCTION
There is a gpio(internal pin) on platform, it could use as general output/input. In this
section, we will demonstrate gpio functions on our platform.
3.1 HW GPIO pin
There is a GPIO controller provide 8 channel gpio for use.
They are controlled by the IO expander located at smbus, thus the i2c bus/device for IO
expander need to be located first then control LEDs.
There are two interfaces to control GPIO through same hardware path. One is i2c raw
commands which only depends on kernel’s i2c driver, however it requests a user space i2c
tool.
The other interface is kernel’s GPIO sysfs which provide file interface in user space, however,
it have to re-compile kernel if configuring kernel to enable it. Some modern Linux
distribution enabled GPIO sysfs by default like Ubuntu, and some are not like
Fedora/CentOS. Please check CONFIG_GPIO_SYSFS and CONFIG_GPIO_ICH in kernel config
to confirm if GPIO sysfs is enabled. For more details about kernel config and compile, please
refer to https://kernelnewbies.org/KernelBuild.
3.2 Control HW GPIO
3.2.1 Locate i2c bus of IO expander
How to locate i2c bus of IO expander is shown as below
Step 1: Make sure i2c driver is loaded
# modprobe i2c_i801
# modprobe i2c-dev
Use lsmod to check if driver is already loaded:
# sudo lsmod | grep i2c
Step 2: Install i2c-tools package
I2c tools could be installed from Ubuntu’s repository simply:
# sudo apt-get install i2c-tools
Or built from source package in website. please check README in package.
https://www.kernel.org/pub/software/utils/i2c-tools/
Step 3: Scan smbus in system by i2cdetect.
# sudo i2cdetect -l
i2c-0 smbus SMBus I801 adapter at e000 SMBus adapter
Copyright 2020. All rights reserved. Advantech Co. Ltd. Page 12
Here shows system smbus adapter is located at bus 0. Please note the bus number could be
different due to different hardware configuration, kernel version and driver of other devices.
Step 4: Confirm IO expander device appears on the smbus.
Scan the devices on smbus which is got in step 3, and smbus I/O expander appears at 0x23
# sudo i2cdetect -y 0
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- 08 -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- 23 -- -- -- -- -- -- -- -- -- -- -- --
30: 30 31 -- -- 34 35 36 -- -- -- -- -- -- -- -- --
40: -- -- -- -- 44 -- -- -- -- -- -- -- -- -- -- --
50: 50 -- -- -- -- -- 56 -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- 6c -- -- --
70: -- -- -- -- -- -- -- --
IO expander device address is 0x23 (7-bit address) in this system. Please note device address
might be different due to hardware configuration and product SKU, please contact
Advantech FAE if you have problem with this device address.
For FWA-1212VC, device address is defined as below.
Address (7-bit)
Usage
0x23
IO Expander
Now smbus number and device address of IO expander is ready, which will be used in
following controls.
3.2.2 I2c raw command to control
Here shows how to control GPIOs using i2c raw command, it will use smbus number and
device address of IO expander located in previous chapter.
Note: This usage cannot work if SW Defined LED accessed as section 4.2.3.
Step 1: Set pins to output mode, this need be done once every time Linux booted.
# sudo i2cset -y 0 0x23 0x06 0x00
Here “0” is smbus number and “0x23” is device address. “0x06” is offset and “0x00” is value,
combined to set GPIO pin 0 to pin 7 to output mode. “0x00” is hex of binary “0000 0000”,
which means pin 0 to 7 is set to bit “0” (output mode).
Please note pin number could be different due to hardware configuration, product SKU,
please contact Advantech FAE if you have problem with this pin mapping.
Copyright 2020. All rights reserved. Advantech Co. Ltd. Page 13
For FWA-1212VC, pin mapping are defined as below.
PIN
LED Name
1
GPIO_0
2
GPIO_4
3
GPIO_1
4
GPIO_5
5
GPIO_2
6
GPIO_6
7
GPIO_3
8
GPIO_7
Step 2: Control GPIOs
# sudo i2cset -y 0 0x23 0x02 0xff (all GPIO high)
# sudo i2cset -y 0 0x23 0x02 0x00 (all GPIO low)
# sudo i2cset -y 0 0x23 0x02 0x01 (GPIO0 high, other low)
# sudo i2cset -y 0 0x23 0x02 0x02 (GPIO1 high, other low)
# sudo i2cset -y 0 0x23 0x02 0x04 (GPIO2 high, other low)
# sudo i2cset -y 0 0x23 0x02 0x08 (GPIO3 high, other low)
# sudo i2cset -y 0 0x23 0x02 0x10 (GPIO4 high, other low)
# sudo i2cset -y 0 0x23 0x02 0x20 (GPIO5 high, other low)
# sudo i2cset -y 0 0x23 0x02 0x40 (GPIO6 high, other low)
# sudo i2cset -y 0 0x23 0x02 0x80 (GPIO7 high, other low)
0” is smbus number and “0x23” is device address. “0x02” is offset, 0xff and other values
are combined to control GPIO pin level.
3.2.3 Kernel GPIO sysfs to control
The other interface to control LED from user space is by kernel GPIO sysfs. GPIO sysfs also
depends on i2c driver thus i2c_i801 must be loaded. It will use smbus number and device
address of IO expander located in previous chapter.
For more detail, please refer to kernel document:
https://www.kernel.org/doc/Documentation/gpio/sysfs.txt.
Step 1: Enable GPIO Driver Mode
Copyright 2020. All rights reserved. Advantech Co. Ltd. Page 14
BIOS Setup Menu -> Advanced -> SW GPIO Configuration -> SW GPIO Driver Mode [GPIO
Driver Mode]
Step2: Probe i2c and gpio_ich drivers
# sudo modprobe i2c_i801
# sudo modprobe gpio_ich
Step 3: Add IO expander device to gpio sysfs
# sudo echo pca9555 0x23 > /sys/bus/i2c/devices/i2c-0/new_device
i2c-0” is target to smbus number 0 and 0x23” is device address. "pca9555" is name of this
IO expander.
Step 4: GPIO base-port file under /sys/class/gpio (gpiochip342) appears after device are
added. However there might be several other gpio base port file, so it’s necessary to locate
which gpio base-port file.
# for L in `ls /sys/class/gpio/gpio*/label`; do echo $L; cat $L; done
/sys/class/gpio/gpiochip342/label
pca9555
Please note gpio numbers like 342 depends on kernel and hardware platform, thus it could
be different.
Step 5: Expose the GPIO pins and set it to output mode
# echo 342 > /sys/class/gpio/export
# echo 343 > /sys/class/gpio/export
# echo 344 > /sys/class/gpio/export
# echo 345 > /sys/class/gpio/export
# echo 346 > /sys/class/gpio/export
# echo 347 > /sys/class/gpio/export
# echo 348 > /sys/class/gpio/export
# echo 349 > /sys/class/gpio/export
# echo out > /sys/class/gpio/gpio342/direction
# echo out > /sys/class/gpio/gpio343/direction
# echo out > /sys/class/gpio/gpio344/direction
# echo out > /sys/class/gpio/gpio345/direction
# echo out > /sys/class/gpio/gpio346/direction
# echo out > /sys/class/gpio/gpio347/direction
Copyright 2020. All rights reserved. Advantech Co. Ltd. Page 15
# echo out > /sys/class/gpio/gpio348/direction
# echo out > /sys/class/gpio/gpio349/direction
Step 6: Control output level
# echo 0 > /sys/class/gpio/gpio342/value (GPIO_0 low)
# echo 0 > /sys/class/gpio/gpio343/value (GPIO_1 low)
# echo 0 > /sys/class/gpio/gpio344/value (GPIO_2 low)
# echo 0 > /sys/class/gpio/gpio345/value (GPIO_3 low)
# echo 0 > /sys/class/gpio/gpio346/value (GPIO_4 low)
# echo 0 > /sys/class/gpio/gpio347/value (GPIO_5 low)
# echo 0 > /sys/class/gpio/gpio348/value (GPIO_6 low)
# echo 0 > /sys/class/gpio/gpio349/value (GPIO_7 low)
# echo 1 > /sys/class/gpio/gpio342/value (GPIO_0 high)
# echo 1 > /sys/class/gpio/gpio343/value (GPIO_1 high)
# echo 1 > /sys/class/gpio/gpio344/value (GPIO_2 high)
# echo 1 > /sys/class/gpio/gpio345/value (GPIO_3 high)
# echo 1 > /sys/class/gpio/gpio346/value (GPIO_4 high)
# echo 1 > /sys/class/gpio/gpio347/value (GPIO_5 high)
# echo 1 > /sys/class/gpio/gpio348/value (GPIO_6 high)
# echo 1 > /sys/class/gpio/gpio349/value (GPIO_7 high)
Copyright 2020. All rights reserved. Advantech Co. Ltd. Page 16
4. SOFTWARE DEFINED LED
The LEDs are controlled by the IO expander located at smbus. It can be controlled with i2c
raw command or via kernel GPIO sysfs or kernel led sysfs.
The i2c bus/device for IO expander need to be located first then control LEDs.
For FWA-1212vc, LEDs are defined as below (Fontpanel from left to right).
No.
LED
GPIO Name
Color
Software
Controllable
1
HDD
NA
Green
NO
2
PWR
NA
Green
NO
3
SYS Note1,2
GPIO_12
Green
Yes
GPIO_14
Orange
Yes
4
CLOUD Note3
GPIO_11
Green
Yes
5
WIFI
GPIO_13
Green
Yes
6
LTE
NA
Green
Yes
7
LTE/5G
NA
Green
NO
8
LTE-1
GPIO_8 (LED_PILOT1)
Green
Yes
9
LTE-2
GPIO_9 (LED_PILOT2)
Green
Yes
10
LTE-3
GPIO_10 (LED_PILOT3)
Green
Yes
Note1: This is dual color LED.
Note2: LED green is linked with the middle LED on rear panel.
LED orange is not linked with the middle LED on rear panel.
Note3: This LED is linked with the upper LED on rear panel.
Please note WiFi led and LTE(SSD) led could be controlled by WiFi/LTE module, please
make sure software don’t touch it in the case.
For more details about LED Defined, please refer to the FWA-1212VC User’s Manual.
Copyright 2020. All rights reserved. Advantech Co. Ltd. Page 17
There are three interfaces to control LEDs through same hardware path. One is i2c raw
commands which only depends on kernel’s i2c driver, however it requests a user space i2c
tool.
Another interface is kernel’s GPIO sysfs which provide file interface in user space, however,
it have to re-compile kernel if configuring kernel to enable it. Some modern Linux
distribution enabled GPIO sysfs by default like Ubuntu, and some are not like
Fedora/CentOS. Please check CONFIG_GPIO_SYSFS and CONFIG_GPIO_ICH in kernel config
to confirm if GPIO sysfs is enabled. For more details about kernel config and compile, please
refer to https://kernelnewbies.org/KernelBuild.
The other interface is kernel’s LED sysfs, which also provide file interface in user space. And
it is based on leds-pca9554 driver which is provided by Advantech.
4.1 Locate i2c bus of IO expander
How to locate i2c bus of IO expander is shown as below
Step 1: Make sure i2c driver is loaded
# modprobe i2c_i801
# modprobe i2c-dev
Use lsmod to check if driver is already loaded:
# sudo lsmod | grep i2c
Step 2: Install i2c-tools package
I2c tools could be installed from Ubuntu’s repository simply:
# sudo apt-get install i2c-tools
Or built from source package in website. please check README in package.
https://www.kernel.org/pub/software/utils/i2c-tools/
Step 3: Scan smbus in system by i2cdetect.
# sudo i2cdetect -l
i2c-0 smbus SMBus I801 adapter at e000 SMBus adapter
Here shows system smbus adapter is located at bus 0. Please note the bus number could be
different due to different hardware configuration, kernel version and driver of other devices.
Step 4: Confirm IO expander device appears on the smbus.
Scan the devices on smbus which is got in step 3, and smbus I/O expander appears at 0x23
# sudo i2cdetect -y 0
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- 08 -- -- -- -- -- -- --
Copyright 2020. All rights reserved. Advantech Co. Ltd. Page 18
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- 23 -- -- -- -- -- -- -- -- -- -- -- --
30: 30 31 -- -- 34 35 36 -- -- -- -- -- -- -- -- --
40: -- -- -- -- 44 -- -- -- -- -- -- -- -- -- -- --
50: 50 -- -- -- -- -- 56 -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- 6c -- -- --
70: -- -- -- -- -- -- -- --
IO expander device address is 0x23 (7-bit address) in this system. Please note device address
might be different due to hardware configuration and product SKU, please contact
Advantech FAE if you have problem with this device address.
For FWA-1212VC, device address is defined as below.
Address (7-bit)
Usage
0x23
IO Expander
Now smbus number and device address of IO expander is ready, which will be used in
following controls.
4.2 Control Software Defined LED
4.2.1 I2c raw command to control
Here shows how to control GPIOs using i2c raw command, it will use smbus number and
device address of IO expander located in previous chapter.
Note: This usage cannot work if SW Defined LED accessed as section 4.2.3.
Step 1: Set pins to output mode, this need be done once every time Linux booted.
# sudo i2cset -y 0 0x23 0x07 0x00
Here “0” is smbus number and “0x23” is device address. “0x07” is offset and “0x00” is value,
combined to set GPIO pin 0 to pin 7 to output mode. “0x00” is hex of binary “0000 0000”,
which means pin 0 to 7 is set to bit “0” (output mode).
Please note pin number could be different due to hardware configuration, product SKU,
please contact Advantech FAE if you have problem with this pin mapping.
Step 2: Control GPIOs
# sudo i2cset -y 0 0x23 0x03 0xff (all above SW controllable LED off)
# sudo i2cset -y 0 0x23 0x03 0xfe (LTE-1 LED on, other off)
# sudo i2cset -y 0 0x23 0x03 0xfd (LTE-2 LED on, other off)
# sudo i2cset -y 0 0x23 0x03 0xfb (LTE-3 LED on, other off)
# sudo i2cset -y 0 0x23 0x03 0xf7 (CLOUD LED on, other off)
Copyright 2020. All rights reserved. Advantech Co. Ltd. Page 19
# sudo i2cset -y 0 0x23 0x03 0xef (SYS LED Green on, other off)
# sudo i2cset -y 0 0x23 0x03 0xbf (SYS LED Orange on, other off)
# sudo i2cset -y 0 0x23 0x03 0xdf (WIFI LED on, other off)
0” is smbus number and “0x23” is device address. “0x03” is offset, 0xff and other values
are combined to control GPIO pin level.
Note:
“0xff” is hex of binary “1111 1111”, which means all bit is set to “1” (all off);
“0xfe” is hex of binary “1111 1110”, which means bit 0 is set to “0” (LTE-1/gpio_8 LED on);
….
4.2.2 Kernel GPIO sysfs to control
Another interface to control LED from user space is by kernel GPIO sysfs. GPIO sysfs also
depends on i2c driver thus i2c_i801 must be loaded. It will use smbus number and device
address of IO expander located in previous chapter.
For more detail, please refer to kernel document:
https://www.kernel.org/doc/Documentation/gpio/sysfs.txt.
Step 1: Enable GPIO Driver Mode
BIOS Setup Menu -> Advanced -> SW GPIO Configuration -> SW GPIO Driver Mode [GPIO
Driver Mode]
Step 2: Probe i2c and gpio_ich drivers
# modprobe i2c_i801
# modprobe i2c-dev
# modprobe gpio_ich
Step 3: Add IO expander device to gpio sysfs
# sudo echo pca9555 0x23 > /sys/bus/i2c/devices/i2c-0/new_device
i2c-0” is target to smbus number 0 and 0x23” is device address. "pca9555" is name of this
IO expander.
Step 4: GPIO base-port file under /sys/class/gpio (gpiochip342) appears after device are
added. However there might be several other gpio base port file, so it’s necessary to locate
which gpio base-port file.
# for L in `ls /sys/class/gpio/gpio*/label`; do echo $L; cat $L; done
/sys/class/gpio/gpiochip342/label
pca9555
Copyright 2020. All rights reserved. Advantech Co. Ltd. Page 20
Please note gpio numbers like 342 depends on kernel and hardware platform, thus it could
be different.
Step 5: Expose the GPIO pins and set it to output mode
# echo 350 > /sys/class/gpio/export
# echo 351 > /sys/class/gpio/export
# echo 352 > /sys/class/gpio/export
# echo 353 > /sys/class/gpio/export
# echo 354 > /sys/class/gpio/export
# echo 356 > /sys/class/gpio/export
# echo 355 > /sys/class/gpio/export
# echo out > /sys/class/gpio/gpio350/direction
# echo out > /sys/class/gpio/gpio351/direction
# echo out > /sys/class/gpio/gpio352/direction
# echo out > /sys/class/gpio/gpio353/direction
# echo out > /sys/class/gpio/gpio354/direction
# echo out > /sys/class/gpio/gpio356/direction
# echo out > /sys/class/gpio/gpio355/direction
Step 6: Control output level
# echo 0 > /sys/class/gpio/gpio350/value (LTE-1 LED on)
# echo 0 > /sys/class/gpio/gpio351/value (LTE-2 LED on)
# echo 0 > /sys/class/gpio/gpio352/value (LTE-3 LED on)
# echo 0 > /sys/class/gpio/gpio353/value (CLOUD LED on)
# echo 0 > /sys/class/gpio/gpio354/value (SYS Green LED on)
# echo 0 > /sys/class/gpio/gpio356/value (SYS Orange LED on)
# echo 0 > /sys/class/gpio/gpio355/value (WIFI LED on)
# echo 1 > /sys/class/gpio/gpio350/value (LTE-1 LED off)
# echo 1 > /sys/class/gpio/gpio351/value (LTE-2 LED off)
# echo 1 > /sys/class/gpio/gpio352/value (LTE-3 LED off)
# echo 1 > /sys/class/gpio/gpio353/value (CLOUD LED off)
# echo 1 > /sys/class/gpio/gpio354/value (SYS Green LED off)
# echo 1 > /sys/class/gpio/gpio356/value (SYS Orange LED off)
  • Page 1 1
  • Page 2 2
  • Page 3 3
  • Page 4 4
  • Page 5 5
  • Page 6 6
  • Page 7 7
  • Page 8 8
  • Page 9 9
  • Page 10 10
  • Page 11 11
  • Page 12 12
  • Page 13 13
  • Page 14 14
  • Page 15 15
  • Page 16 16
  • Page 17 17
  • Page 18 18
  • Page 19 19
  • Page 20 20
  • Page 21 21
  • Page 22 22
  • Page 23 23
  • Page 24 24
  • Page 25 25
  • Page 26 26
  • Page 27 27
  • Page 28 28
  • Page 29 29
  • Page 30 30
  • Page 31 31
  • Page 32 32
  • Page 33 33
  • Page 34 34
  • Page 35 35
  • Page 36 36
  • Page 37 37
  • Page 38 38
  • Page 39 39
  • Page 40 40

Advantech FWA-1212VC User guide

Type
User guide

Ask a question and I''ll find the answer in the document

Finding information in a document is now easier with AI