MPC-2000 Series Linux Software
User’s Manual
Version 1.0, August 2019
www.moxa.com/product
© 2019 Moxa Inc. All rights reserved.
MPC-2000 Series Linux Software
Moxa China (Shanghai office)
User’s Manual
The software described in this manual is furnished under a license agreement and may be used only in accordance with
the terms of that agreement.
Copyright Notice
© 2019 Moxa Inc. All rights reserved.
Trademarks
The MOXA logo is a registered trademark of Moxa Inc.
All other trademarks or registered marks in this manual belong to their respective manufacturers.
Disclaimer
Information in this document is subject to change without notice and does not represent a commitment on the part of
Moxa.
Moxa provides this document as is, without warranty of any kind, either expressed or implied, including, but not limited
to, its particular purpose. Moxa reserves the right to make improvements and/or changes to this manual, or to the
products and/or the programs described in this manual, at any time.
Information provided in this manual is intended to be accurate and reliable. However, Moxa assumes no responsibility for
its use, or for any infringements on the rights of third parties that may result from its use.
This product might include unintentional technical or typographical errors. Changes are periodically made to the
information herein to correct such errors, and these changes are incorporated into new editions of the publication.
Technical Support Contact Information
www.moxa.com/support
-free: 1-888-669-2872
+1-714-528-6777
+1-714-528-6778
+49-89-3 70 03 99-0
+49-89-3 70 03 99-99
+91-80-4172-9088
+91-80-4132-1045
-free: 800-820-5036
+86-21-5258-9955
+86-21-5258-5505
+886-2-8919-1230
-Pacific
+886-2-8919-1231
Table of Contents
1. Introduction ...................................................................................................................................... 1-1
Overview ........................................................................................................................................... 1-2
Software Specifications........................................................................................................................ 1-2
Software Components .................................................................................................................. 1-2
2. System Configuration ........................................................................................................................ 2-1
Getting Started .................................................................................................................................. 2-2
Connecting From an SSH Console ......................................................................................................... 2-4
Windows Users ........................................................................................................................... 2-5
Linux Users ................................................................................................................................ 2-5
Adjusting the System Time .................................................................................................................. 2-6
Setting the Time Manually ............................................................................................................ 2-6
systemd-timesyncd Service .......................................................................................................... 2-7
NTP Client .................................................................................................................................. 2-8
Manage the Service by systemd script ........................................................................................... 2-9
Setting the Time Zone ............................................................................................................... 2-10
Cron—Daemon for Executing Scheduled Commands .............................................................................. 2-13
The Partition in the System ................................................................................................................ 2-14
Adding Swap Space in the System ...................................................................................................... 2-14
Resizing and Adding a Partition .......................................................................................................... 2-15
Inserting a USB Storage into the Computer .......................................................................................... 2-20
Inserting a SD Storage into the Computer ........................................................................................... 2-21
Checking the Linux Version ................................................................................................................ 2-22
Checking Moxa’s Control Version ........................................................................................................ 2-23
APT—Installing and Removing Packages .............................................................................................. 2-23
Audio Player ..................................................................................................................................... 2-24
Video Player ..................................................................................................................................... 2-27
Web Browser .................................................................................................................................... 2-27
Brightness control ............................................................................................................................. 2-27
Introduction.............................................................................................................................. 2-27
Auto-brightness control mode ..................................................................................................... 2-29
Manual brightness control mode .................................................................................................. 2-31
3. Managing Communications ............................................................................................................... 3-1
Changing the Network Settings ............................................................................................................ 3-2
Changing the “interfaces” Configuration File ................................................................................... 3-2
Configure the VLAN tag in “interfaces” ........................................................................................... 3-3
Adjusting IP Addresses with “ifconfig” ............................................................................................ 3-3
DNS Client ......................................................................................................................................... 3-4
/etc/hostname ............................................................................................................................ 3-4
/etc/resolv.conf ........................................................................................................................... 3-4
/etc/nsswitch.conf ....................................................................................................................... 3-5
Apache Web Server ............................................................................................................................. 3-5
Install the apache web server ....................................................................................................... 3-5
Default Homepage ....................................................................................................................... 3-5
Disabling the CGI Function ........................................................................................................... 3-6
Saving Web Pages to a USB Storage Device.................................................................................... 3-6
IPTABLES .......................................................................................................................................... 3-8
IPTABLES Hierarchy ..................................................................................................................... 3-9
IPTABLES Modules ....................................................................................................................... 3-9
Observe and Erase Chain Rules ................................................................................................... 3-10
Define Policy for Chain Rules....................................................................................................... 3-11
Append or Delete Rules .............................................................................................................. 3-11
NAT (Network Address Translation) ..................................................................................................... 3-12
NAT Example ............................................................................................................................ 3-13
Enabling NAT at Bootup ............................................................................................................. 3-13
NFS (Network File System) Client ....................................................................................................... 3-14
Wireless Management ....................................................................................................................... 3-14
Device Driver for WPEA-172GN – rt5572sta.ko ............................................................................. 3-14
Device Driver for WPEA-172GN - rt2800usb.ko ............................................................................. 3-16
iw ............................................................................................................................................ 3-17
wpasupplicant ........................................................................................................................... 3-17
Celluar Management – cell_mgnt ........................................................................................................ 3-18
4. Programming Guide .......................................................................................................................... 4-1
The Device Driver Source .................................................................................................................... 4-2
Getting Product Serial Number ............................................................................................................. 4-2
Multi-arch Development Tools .............................................................................................................. 4-2
Year 2038 Problem – Recompile the Program with 64-bits glibc ................................................................ 4-3
Device IOCTL ..................................................................................................................................... 4-3
RTC (Real Time Clock) ......................................................................................................................... 4-3
UART ................................................................................................................................................ 4-4
Digital I/O.......................................................................................................................................... 4-4
WDT (Watch Dog Timer) ...................................................................................................................... 4-5
Introduction................................................................................................................................ 4-5
Watchdog Usage ......................................................................................................................... 4-5
WDT IOCTL Commands ................................................................................................................ 4-5
How the WDT Works .................................................................................................................... 4-5
Brightness Control Programming .......................................................................................................... 4-6
Introduction................................................................................................................................ 4-6
Programming the Brightness ......................................................................................................... 4-6
Programming Example - br-setbrightness-example.c ..................................................................... 4-10
Qt Programming ............................................................................................................................... 4-12
Introduction.............................................................................................................................. 4-12
Qt5 Tutorial Using Qt Creator ...................................................................................................... 4-12
Qt Programming Reference ......................................................................................................... 4-19
mtdev (multitouch protocol translation library) ..................................................................................... 4-19
Introduction.............................................................................................................................. 4-19
The multitouch and evdev .......................................................................................................... 4-20
Examples ................................................................................................................................. 4-21
5. System Restore ................................................................................................................................. 5-1
Embedded Computer Restore Environment 1 ......................................................................................... 5-2
Embedded Computer Restore Environment ..................................................................................... 5-2
Embedded Computer Restore Procedure ......................................................................................... 5-2
Saving the System to the USB Drive ................................................................................................... 5-10
Brightness Controller Firmware Upgrade .............................................................................................. 5-12
A. Software Components ....................................................................................................................... A-1
1
1. Introduction
Thank you for purchasing the Moxa MPC-2000 Series x86, ready-to-run embedded computers. This manual
introduces the software configuration and management of the MPC-2070/2120-LX and MPC-2101/2121-LX
computers (referred to as the “MPC-2000 Series Linux-based computers”), which run the Linux operating
system. For hardware installation, connector interfaces, setup, and upgrading the BIOS, please refer to the
“Hardware User’s Manual.”
Linux is an open, scalable operating system that allows you to build a wide range of innovative, small footprint
devices. Software written for desktop PCs can be easily ported to the embedded computer with a GNU cross
compiler and a minimum of source code modifications. A typical Linux-based device is designed for a specific
use, and is often not connected to other computers, or a number of such devices connect to a centralized,
front-end host. Examples include enterprise tools such as industrial controllers, communications hubs,
point-of-sale terminals, and display devices that include HMIs, advertisement appliances, and interactive
panels.
The following topics are covered in this chapter:
Overview
Software Specifications
Software Components
MPC-2000 Series Linux Software Introduction
Overview
The MPC-2000 Series Linux-based computers are based on the Intel® Atom(TM) CPU and feature
RS-232/422/485 serial ports, dual LAN ports, and USB 2.0 hosts. The serial ports make it ideal for connecting
a wide range of serial devices to the panel computers, and the dual 10/100 Mbps Ethernet ports offer a reliable
solution for network redundancy, which taken together promises continuous data communication and
management operations. For added convenience, the panel computers have DI/DO for connecting digital
input/output devices. In addition, the SD and USB ports provide the MPC-2000 Series Linux-based computers
with data buffering and storage expansion capabilities, which in turn provide the necessary reliability for
industrial applications.
Preinstalled with Linux, the MPC-2000 Series Linux-based panel computers provide programmers with a
friendly environment for developing sophisticated, bug-free application software at a lower cost.
The MPC-2000 Series Linux-based panel computers support a wide operating temperature range of -40 to 70°C,
making them suitable for use in harsh industrial environments.
Software Specifications
The Linux operating system, preinstalled on the MPC-2000 Series Linux-based panel computers, is the Debian
Stretch distribution. The Debian project involves a worldwide group of volunteers who endeavor to produce an
operating system distribution composed entirely of free software. The Debian GNU/Linux follows the standard
Linux architecture, making it easy to use programs that meet the POSIX standard. Program porting can be
done with the GNU Tool Chain provided by Moxa. In addition to Standard POSIX APIs, device drivers for the
Moxa UART and other special peripherals are also included. An example software architecture is shown below.
The above software architecture is only an example. Different models or different build revisions of the Linux
operating system may include components not shown in the above illustration. For information and
documentation related to Debian GNU/Linux and the free software concept, refer to http://www.debian.org/
and http://www.gnu.org/
Software Components
The MPC-2000 Series Linux-based panel computers come preinstalled with the Debian Stretch Linux
distribution.
2
2. System Configuration
In this chapter, we explain how to operate a MPC-2000 Series Linux-based panel computer using your desktop.
There are three ways to connect to the panel computer: through a Touch Panel monitor, from a Windows or
Linux machine via SSH over the network console. This chapter describes basic Linux operating system
configurations. Advanced network management and configuration instructions will be described in the Chapter
3, Managing Communications .
The following topics are covered in this chapter:
Getting Started
Connecting From an SSH Console
Windows Users
Linux Users
Adjusting the System Time
Setting the Time Manually
systemd-timesyncd Service
NTP Client
Manage the Service by systemd script
Setting the Time Zone
Cron—Daemon for Executing Scheduled Commands
The Partition in the System
Adding Swap Space in the System
Resizing and Adding a Partition
Inserting a USB Storage into the Computer
Inserting a SD Storage into the Computer
Checking the Linux Version
Checking Moxa’s Control Version
APT—Installing and Removing Packages
Audio Player
Video Player
Web Browser
Brightness control
Introduction
Auto-brightness control mode
Manual brightness control mode
MPC-2000 Series Linux Software System Configuration
Getting Started
1. Power up the panel computer by connecting it to the power adaptor.
It takes approximately 30 seconds for the system to boot up. Once the system is ready, a XFCE desktop
screen will appear on your touch panel.
2. Click the virtual keyboard icon on the upper corner.
The virtual keyboard will be displayed on the desktop.
MPC-2000 Series Linux Software System Configuration
support user authentication before using the device.
moxa@Moxa:~# sudo xfce4-panel -V
lightdm function is configured in automatic login mode. You can comment out the
-user=moxa and autologin-user-timeout=0 in the /etc/lightdm/lightdm.conf file to
moxa@Moxa:~# sudo vi /etc/lightdm/lightdm.conf
...
# autologin-user=moxa
# Autologin-user-timeout=0
3. Right-click to open the desktop menu.
If you are not using a mouse device, the virtual keyboard supports the right-click function as follows:
a. Press the virtual keyboard icon .
b. Press the Menu key on the virtual keyboard.
The pop-up menu will be displayed on the desktop.
The XFCE4 and Xorg version:
xfce4-panel 4.12.1 (Xfce 4.12)
Copyright (c) 2004-2011
The Xfce development team. All rights reserved.
Please report bugs to <http://bugzilla.xfce.org/>.
moxa@Moxa:~# sudo Xorg -version
X.Org X Server 1.19.2
Release Date: 2017-03-02
X Protocol Version 11, Revision 0
Build Operating System: Linux 4.9.0-8-amd64 x86_64 Debian
...
xorg-server 2:1.19.2-1+deb9u4 (https://www.debian.org/support)
MPC-2000 Series Linux Software System Configuration
ATTENTION
For security concern, the system is set up to log out if the SSH remote console or serial console is inactive for
5 minutes. If you don’t need this setting in the development phase, you can comment the con
The sshd automatic logout is configured in
Connecting From an SSH Console
The embedded computers support the SSH console to offer users better network security compared to Telnet.
The default IP addresses and netmasks of the network interfaces are as follows:
Default IP Address Netmask
LAN 2 192.168.4.127 255.255.255.0
Before using the SSH client, you should change the IP address of your development workstation so that the
network ports are on the same subnet as the IP address for the LAN port that you will connect to. For example,
if you will connect to LAN1, you could set your PC’s IP address to 192.168.3.126, and the netmask to
255.255.255.0. If you will connect to LAN2, you could set your PC’s IP address to 192.168.4.126, and the
netmask to 255.255.255.0.
Use a cross-over Ethernet cable to connect your development workstation directly to the target computer, or
use a straight-through Ethernet cable to connect the computer to a LAN hub or switch. Next, use a SSH client
on your development workstation to connect to the target computer. After a connection has been established,
type the login name and password as requested to log on to the computer. The default values are both moxa.
Login: moxa
Password: moxa
...
# Remote session termination
ClientAliveInterval 300
ClientAliveCountMax 0
figuration.
/etc/ssh/sshd_config
MPC-2000 Series Linux Software System Configuration
[root@Jim_notebook root]# ssh moxa@192.168.3.127
Are you sure you want to continue connection (yes/no)? yes_
Windows Users
Click on the link http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html to download PuTTY
(free software) to set up an SSH console for the embedded computer in a Windows environment. The following
screen shows an example of the configuration that is required.
Linux Users
From a Linux machine, use the ssh command to access the embedded computer’s console utility via SSH.
Select yes to open the connection.
The authenticity of host ‘192.168.3.127 (192.168.3.127)’ can’t be established.
RSA key fingerprint is 8b:ee:ff:84:41:25:fc:cd:2a:f2:92:8f:cb:1f:6b:2f.
In addition, use sudo -i to login as root to have more privileges.
[sudo] password for moxa:
MPC-2000 Series Linux Software System Configuration
ATTENTION
To enable sudo on your computer, you must first add a user to the sudo group. To add a user to the sudo group,
use the useradd command, as below
Using the sudoers file, sudo may be carefully tailored on a user
privileges that can be tailored to individual computers within the network. For more information on
Linux.com; introduction to sudo:
http://www.linux.com/learn/tutor
Debian introduction to the sudo command:
https://wiki.debian.org/sudo
https://help.ubuntu.com/community/Sudoers
A sample sudoers file for an extended network:
http://www.sudo.ws/sudo/sample.sudoers
-ACCOUNT-NAME-HERE] sudo
iguration, usage, and best practices with the sudo command, you may refer to the following websites:
-distribution) documentation for the sudoers file:
:
ials/306766:linux-101-introduction-to-sudo
.
Adjusting the System Time
The MPC-2070/2120-LX or MPC-2101/2121-LX has two time settings. One is the system time, and the other is
provided by an RTC (Real Time Clock) built into the MPC-2000 hardware.
-by-user basis to allow a specific hierarchy of
Setting the Time Manually
Use the date command to query the current system time or to set a new system time. Use hwclock to query
the current RTC time or to set a new RTC time.
Use the following command to set the system time.
# date MMDDhhmmYYYY
MM: Month
DD: Date
hhmm: Hour and Minute
YYYY: Year
Use the following command to write the current system time to the RTC.
# hwclock -w
Tue Jul 17 10:59:33 CST 2018
root@Moxa:~# hwclock
2018-07-17 11:01:06.233615+0800
root@Moxa:~# date 071711102018
Tue Jul 17 11:10:00 CST 2018
root@Moxa:~# hwclock –w
root@Moxa:~# date ; hwclock
Tue Jul 17 11:10:12 CST 2018
2018-07-17 11:10:12.233615+0800
MPC-2000 Series Linux Software System Configuration
root@Moxa:~# systemctl start systemd-timesyncd
root@Moxa:~# systemctl enable systemd-timesyncd
root@Moxa:~# reboot
root@Moxa:~# systemctl status systemd-timesyncd
Mar 12 05:12:47 Moxa systemd[1]: Started Network Time Synchronization.
root@Moxa:~# systemctl restart systemd-timesyncd
root@Moxa:~# timedatectl set-ntp true
root@Moxa:~# timedatectl status
systemd-timesyncd Service
The systemd-timesyncd daemon has been added for synchronizing the system clock across the network. This
service default is disabled. You can start this service manually by this command.
You can enable this service and reboot. It would be start after boot.
After reboot, the systemd-timesyncd service should run in background.
● systemd-timesyncd.service - Network Time Synchronization
Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor
preset: enabled)
Drop-In: /lib/systemd/system/systemd-timesyncd.service.d
└─disable -with-time-daemon.conf
Active: active (running) since Mon 2018-03-12 05:12:47 EDT; 31min ago
Docs: man:systemd-timesyncd.service(8)
Main PID: 297 (systemd-timesyn)
Status: "Idle."
Tasks: 2 (limit: 4915)
CGroup: /system.slice/systemd-timesyncd.service
└─297 /lib/systemd/systemd -timesyncd
Mar 12 05:12:47 Moxa systemd[1]: Starting Network Time Synchronization...
When the systemd-timesyncd starting, it reads the configurations from /etc/systemd/timesyncd.conf.
Choosing from the NTP server pool
to configure.
NTP=jp.pool.ntp.org
FallbackNTP=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org
Restart the systemd-timesyncd service.
If NTP is not enabled, you can enable it by this command.
Once that’s done, the time should be kept correctly.
Local time: Wed 2018-07-04 14:55:00 CST
Universal time: Wed 2018-07-04 06:55:00 UTC
RTC time: Wed 2018-07-04 06:55:00
Time zone: Asia/Taipei (CST, +0800)
Network time on: yes
NTP synchronized: yes
MPC-2000 Series Linux Software System Configuration
root@Moxa:~# date ; hwclock
ATTENTION
Before using the NTP client utility, check your IP address and ne
sure an Internet connection is available.
root@Moxa:~# systemctl status systemd-timesyncd
Docs: man:systemd-timesyncd.service(8)
root@Moxa:~# systemctl enable systemd-timesyncd
root@Moxa:~# reboot
ATTENTION
Before using the time sync utility, check your IP address and network settings (gateway and DNS) to make sure
an Internet connection is available.
NTP Client
You can use NTP (Network Time Protocol) client that is used to initialize a time request to a remote NTP server.
Use ntpdate to update the system time.
# ntpdate time.stdtime.gov.tw
# hwclock –w
Visit http://www.ntp.org
for more information about NTP and NTP server addresses.
root@Moxa Mar 12 05:58:42 EDT 2018
root@Moxa:~# hwclock
2018-03-12 05:59:23.436777-0400
root@Moxa:~# date 031217592018.30
Mon Mar 12 17:59:30 EDT 2018
root@Moxa:~# hwclock –w
root@Moxa:~# date ; hwclock
Mon Mar 12 18:00:42 EDT 2018
2018-03-12 18:00:42.468011-0400
The Debian Linux system has a built-in system-timesyncd that is used for Network Time Synchronization. This
service default is disabled.
twork settings (gateway and DNS) to make
● systemd -timesyncd.service - Network Time Synchronization
Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; disabled; vendor
preset: enabled)
Drop-In: /lib/systemd/system/systemd-timesyncd.service.d
└─disable -with-time-daemon.conf
Active: inactive (dead)
Enable the system-timesyncd service by the systemctl enable command and reboot.
MPC-2000 Series Linux Software System Configuration
moxa@Moxa:~# sudo vi /usr/local/bin/networking-check.sh
root@Moxa:~# chmod a+x /usr/local/bin/networking-check.sh
root@Moxa:~# systemctl start networking-check
root@Moxa:~# ps aux|grep networking-check
root 2276 0.0 0.0 12784 980 pts/0 S+ 14:49 0:00 grep networking-check
root@Moxa:~# cat /var/log/networking-check.log
Manage the Service by systemd script
Linux services can be started or stopped using system script. If you want to start up some service, you can use
systemctl to enable or disable the service.
You can follow this example to add or remove your service in the system. First, you should write a system
service unit. This example creates a systemd service unit at /etc/systemd/system/networking-check.service.
After=snmpd.service
[Service]
ExecStart=/usr/local/bin/networking-check.sh
[Install]
After: Instructs systemd on when the script should be run. In our case the script will run after snmpd.service
has started.
ExecStart: This field provides a full path the actual script to be execute
WantedBy: Into what boot target the systemd unit should be installed
This is minimum example of a system script. More information please check systemd.service. Next create
/usr/local/bin/networking-check.sh script to check the network status. This example will ping a global DNS
server to check if network is available and write the results in /var/log/networking-check.log.
#!/bin/sh
while [ 1 ]; do
date >> /var/log/networking-check.log
ping -q -w 1 8.8.8.8
if [ $? -eq 0 ]; then
echo "Network is available" >> /var/log/networking-check.log
else
echo "Network is not available" >> /var/log/networking-check.log
fi
sleep 1
Before we launch this service, we need to make this script executable:
Then we can start the networking-check service by this command.
The networking-check.sh should run in background.
root 2260 0.0 0.0 4288 1500 ? Ss 14:49 0:00 /bin/sh /usr/local/bin/networking-check.sh
The /var/log/networking-check.log should be created.
Wed Mar 14 14:49:09 EDT 2018
Network is available
MPC-2000 Series Linux Software System Configuration
root@Moxa:~# systemctl stop networking-check
root@Moxa:~# systemctl enable networking-check
root@Moxa:~# reboot
root@Moxa:~# systemctl disable networking-check
root@Moxa:~# export TZ=America/Los_Angeles
Tue Jan 29 01:37:22 PST 2019
Tue Jan 29 17:39:54 CST 2019
Remember use this command to stop this service to prevent the log of this example occupied too much disk
space.
Finally, you can enable this service at boot time by this command and reboot the system.
To disable this service by the systemctl disable command.
Setting the Time Zone
You can choose one of these methods to change the time zone.
• Environment variable - TZ
• dpkg-reconfigure tzdata
• timedatectl
• xfce4-panel clock widget
Using the Environment variable - TZ
You can export the TZ environment variable to change the time zone.
root@Moxa:~# date
Unset the TZ before using another method to configure the time zone.
root@Moxa:~# date
MPC-2000 Series Linux Software System Configuration
Current default time zone: 'US/Central'
Universal Time is now: Tue Jan 29 09:44:29 UTC 2019.
Using the dpkg-reconfigure tzdata.
This is the example on how to use dpkg-reconfigure to change the time zone.
root@Moxa:~# dpkg-reconfigure tzdata
Local time is now: Tue Jan 29 03:44:29 CST 2019.
MPC-2000 Series Linux Software System Configuration
moxa@Moxa:~# timedatectl list-timezones
moxa@Moxa:~# sudo timedatectl set-timezone Asia/Tokyo
Using timedatectl
Display the time zone list using the timedatectl command.
Africa/Abidjan
Africa/Accra
…
Set timezone by timedatectl
Show the settings
Local time: Tue 2019-01-22 16:05:47 JST
Universal time: Tue 2019-01-22 07:05:47 UTC
RTC time: Tue 2019-01-22 07:05:46
Time zone: Asia/Tokyo (JST, +0900)
Network time on: no
NTP synchronized: no
Using the xfce4-panel Clock Widget
To set the time zone in the XFCE window, right-click on the Clock on the icon tray at the top right of your
computer screen.
MPC-2000 Series Linux Software System Configuration
#minute hour date month dow user command
* 8 * * * root /path/to/your/program
This should show the Time Settings, Appearance, and Clock Options. Enter the time zone in the text box and
click the Close button to change the time zone in the system.
Cron—Daemon for Executing Scheduled
Commands
The Cron daemon will search /etc/crontab for crontab files.
Cron wakes up every minute and checks each command to see if it should be run at that time. When executing
commands, output is mailed to the owner of the crontab (or to the user named in the MAILTO environment
variable in the crontab, if such a user exists).
Modify the file /etc/crontab to set up your scheduled applications. Crontab files have the following format:
Mm H dom mon Dow user command
Minute Hour date month Week user command
0-59 0-23 1-31 1-12 0-6 (0 is Sunday)
For example, issue the following command if you want to launch a program at 8:00 every day:
The following example demonstrates how to use Cron to update the system time and RTC time every day at
8:00.
1. Write a shell script named fixtime.sh and save it to /home/.
#!/bin/sh
ntpdate time.stdtime.gov.tw
hwclock –w
exit 0
2. Change the mode of fixtime.sh
# chmod 755 fixtime.sh
3. Modify the /etc/crontab file to run fixtime.sh at 8:00 every day.
Add the following line to the end of crontab:
* 8 * * * root /home/fixtime.sh
MPC-2000 Series Linux Software System Configuration
moxa@Moxa:~# sudo vi /etc/fstab
#usbfs /proc/bus/usb usbfs defaults 0 0
moxa@Moxa:~# sudo dd if=/dev/zero of=/var/swapfile bs=512 count=2097156
moxa@Moxa:~# sudo mkswap /var/swapfile
moxa@Moxa:~# sudo vi /etc/fstab
/var/swapfile none swap sw 0 0
/var/swapfile file 1048572 0 -1
The Partition in the System
The storage size installed in the Linux operating system is at least 8 GB. The kernel, grub, /, /etc, /home, and
/var are installed in one partition.
The / is mounted by label configured in /etc/fstab.
...
LABEL=root / ext4 noatime,errors=remount-ro 0 1
The label naming is checked using the blkid command.
...
/dev/sda1: LABEL="root" UUID="3a5039b5-4002-4865-9a53-e0eb2326bd84" TYPE="ext4"
PARTUUID="20f4f528-01"
Adding Swap Space in the System
The memory is large and cheap in the embedded computer system. We don’t plan the swap space in the
operating system. If your applications need more memory, in addition to add more RAM, setting swap space
solve the problem of insufficient memory. You can follow these steps to adding the swap file to support swap
in the system.
Create a swap file. This example creates a 4G size swap file located at /var/swapfile.
Set up a Linux swap space.
Update /etc/fstab to use the swap file in booting.
Then reboot the system for the swap space to be active. The swapon -s command shows a summary of the
swap space.
<...Wait the system reboot...>
moxa@Moxa:~# sudo swapon -s
Filename Type Size Used Priority
The free shows the free shows the memory and swap usage information.
total used free shared buff/cache available
Mem: 12191600 1600412 9787112 219100 804076 10112868
MPC-2000 Series Linux Software System Configuration
Resizing and Adding a Partition
1. Download the GParted Live ISO from the GParted’s website.
Then format a FAT16/FAT32 filesystem USB flash driver at least with 300MB size.
2. Use Tuxboot to create the GParted USB driver.
The latest Tuxboot can be downloaded from the Tuxboot’s website.
3. Unmount, remove and insert the GParted USB driver to boot in Moxa embedded computer. After boot into
GParted USB driver, it shows the disk partition information in a graphic dialog.
This example resizes and creates a new partition labeled as data and mount the new partition at
/media/data.
MPC-2000 Series Linux Software System Configuration
4. Right click on partition #1, /dev/sda1 to Resize or Move it.
5. Use the slider bar to resize partition #1.
MPC-2000 Series Linux Software System Configuration
6. Right-click on the unallocated space to New a partition.
7. Add this partition.
MPC-2000 Series Linux Software System Configuration
8. Apply the New Partition Creation.
9. Set the label of the partition by right-click on Label File System menu item.
MPC-2000 Series Linux Software System Configuration
Don’t change the /dev/sda1 label name because we mount the root
10. The label we set is data.
The OS partition, /dev/sda1, we named it as root. The second partition, /dev/sda2, we called it as data.
-filesystem by label for mass-production
11. Close the GParted dialog.
MPC-2000 Series Linux Software System Configuration
[ 564.762273] sd 6:0:0:0: [sdb] Attached SCSI removable disk
root@Moxa:~# cat /proc/partitions
12. Double-click the Terminal, we need to edit /etc/fstab in the CFast storage, /dev/sda1.
a. Change to root as follows:.
# sudo -i
Then mount /dev/sda1 at a path
# mount /dev/sda1 /mnt
b. Create /mnt/media/data as the mount point for partition #2, data.
# mkdir -p /mnt/media/data
c. Edit /mnt/etc/fstab to mount the partition, data, at boot time.
# vi /mnt/etc/fstab
…
LABEL=data /media/data ext4 errors=remount-ro 0 1
…
d. Reboot the system to boot from CFast card to check these setting.
# umount /mnt
# reboot
Inserting a USB Storage into the Computer
This system doesn’t support auto mounting USB storage devices automatically. In a Linux system, you should
mount the USB devices manually. Before mounting the USB storage, you should check the name of the USB
storage using the dmesg command.
...
[ 564.751226] sd 6:0:0:0: Attached scsi generic sg1 type 0
[ 564.752400] sd 6:0:0:0: [sdb] 3973118 512-byte logical blocks: (2.03 GB/1.89 GiB)
[ 564.753008] sd 6:0:0:0: [sdb] Write Protect is off
[ 564.753013] sd 6:0:0:0: [sdb] Mode Sense: 03 00 00 00
[ 564.753674] sd 6:0:0:0: [sdb] No Caching mode page found
[ 564.753797] sd 6:0:0:0: [sdb] Assuming drive cache: write through
[ 564.759333] sdb: sdb1
Or check /proc/partitions
major minor #blocks name
8 0 7824600 sda
8 1 7823576 sda1
8 16 1986559 sdb
MPC-2000 Series Linux Software System Configuration
root:~# mount –t vfat /dev/sdb1 /mnt
/dev/sdb1 /mnt vfat defaults, nofail 0 0
ATTENTION
Remember to type the command # sync before you disconnect the USB storage device. If you do not issue the
command, you may lo
External devices that are to be mounted when present but ignored if absent may require the nofail option. This
prevents errors being reported at boot.
#KERNEL!="mmcblk[0-9]p[0-9]", GOTO="media_by_label_auto_mount_end"
#LABEL="media_by_label_auto_mount_end"
moxa@Moxa:~# sudo sed -i s/^#//
/etc/udev/rules.d/11-media-by-label-auto-mount.rules
Mount the USB storage partition 1, /dev/sdb1, on /mnt.
Mount the USB storage partition 1, /dev/sdb1, on /mnt.
...
/dev/sdb1 on /mnt type vfat
(rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,u
If you want to automatic mount the USB storage at boot time, you can add it in /etc/fstab
LABEL=root / ext4 noatime,errors=remount-ro 0 1
#usbfs /proc/bus/usb usbfs defaults 0 0
se data.
Inserting a SD Storage into the Computer
The SD slot supports the SD, SDHC, and SDXC formats, and is used as the extend storage in the system. The
SD auto-mounting is disabled in the system but we prepared an udev rule to support the auto-mounting feature.
You can remove the comment, #, which is the first character in
/etc/udev/rules.d/11-media-y-label-auto-mount.rules to support the SD auto-mounting feature.
## Import FS infos
#IMPORT{program}="/sbin/blkid -o udev -p %N"
## Get a label if present, otherwise specify one
#ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
#ENV{ID_FS_LABEL}=="", ENV{dir_name}="sd-%k"
## Global mount options
#ACTION=="add", ENV{mount_options}="relatime"
# Filesystem-specific mount options
#ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs",
ENV{mount_options}="$env{mount_options},utf8,gid=100,umask=002"
## Mount the device
#ACTION=="add", RUN+="/bin/mkdir -p /media/%E{dir_name}", RUN+="/bin/mount -o
%E{mount_options} /dev/%k /media/%E{dir_name}"
## Clean up after removal
#ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l /media/%E{dir_name}",
RUN+="/bin/rmdir /media/%E{dir_name}"
## Exit
You can use the sed command to remove all beginning # matched from lines.
MPC-2000 Series Linux Software System Configuration
root@Moxa:~# blkid /dev/mmcblk0p1
/dev/mmcblk0p1: LABEL="MySD " UUID="70CC-82A8" TYPE="vfat"
t=ascii,shortname=mixed,utf8,errors=remount-ro)
root@Moxa:~# blkid /dev/mmcblk0p1
/dev/mmcblk0p1: UUID="70CC-82A8" TYPE="vfat"
(rw,nosuid,nodev,relatime,size=807264k,mode=700,uid=1000,gid=1000)
moxa@MOXA:~# uname –a
Linux Moxa 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-28) x86_64 GNU/Linux
moxa@MOXA:~# lsb_release -a
This is the SD auto-mounting rule. It mounts the media by label at first. This means that If the SD card has a
label name, it will be auto-mounted at this path, /media/LABEL_NAME. If the SD card doesn’t have a label
name, it will be auto-mounted to /media/sd-mmcblk0pX, where X is the partition number. Both these cases of
mounting the SD card to the system are covered in the examples below:
Case #1, the SD card auto-mounted to /media/LABEL_NAME
Use blkid to read the SD card’s label name.
The inserted SD card will be auto-mounted to /media/MySD
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
...
/dev/mmcblk0p1 on /media/MySD type vfat
(rw,relatime,gid=100,fmask=0002,dmask=0002,allow_utime=0020,codepage=437,iocharse
Case #2, the SD card auto-mounted to /media/sd-mmcblk0pX
Use blkid to read the SD card’s label name.
Check the mounted storage by mount command.
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
...
/dev/mmcblk0p1 on /media/sd-mmcblk0p1 type vfat
(rw,relatime,gid=100,fmask=0002,dmask=0002,allow_utime=0020,codepage=437,iocharse
t=ascii,shortname=mixed,utf8,errors=remount-ro)
tmpfs on /run/user/1000 type tmpfs
Checking the Linux Version
The program uname , which stands for “Unix Name” and is part of the UNIX operating system, prints the name,
version, and other details about the operating system running on the computer. Use the -a option to generate
a response similar to the one shown below:
Check the distribution specification.
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 9.8 (stretch)
Release: 9.8
MPC-2000 Series Linux Software System Configuration
moxa@MOXA:~# sudo apt-get update
moxa@MOXA:~#
moxa@MOXA:~# sudo apt-get install IPsec-tools
moxa@MOXA:~#
moxa@MOXA:~# sudo apt-get remove IPsec-tools
moxa@MOXA:~#
moxa@MOXA:~# sudo apt-get remove IPsec-tools --purge
moxa@MOXA:~#
ATTENTION
You can free up the cache space with the command
Checking Moxa’s Control Version
The program kversion determines the Linux system released version. Use the -a option to check the built date.
The built date format is YYMMDDHH. You can use kversion to check the released image version in
troubleshooting. This example shows the built date, 19030611, which means it was built at 2019/03/06 11:00.
MPC-2121 firmware version 1.0 Build 19030611
APT—Installing and Removing Packages
APT is the Debian tool used to install and remove packages. Before installing a package, you need to configure
the apt source file, /etc/apt/sources.list.
Next, use vi editor to configure /etc/apt/sources.list.
root@Moxa:~# vi /etc/apt/sources.list
deb http://ftp.us.debian.org/debian/ stretch main
deb-src http://ftp.us.debian.org/debian/ stretch main
deb http://security.debian.org/ stretch/updates main
deb-src http://security.debian.org/ stretch/updates main
# Stretch-updates, previously known as 'volatile'
deb http://ftp.us.debian.org/debian/ stretch-updates main
deb-src http://ftp.us.debian.org/debian/ stretch-updates main
#deb http://ftp.debian.org/debian stretch-backports main
#deb-src http://ftp.debian.org/debian stretch-backports main
Update the source list after you configure it.
Once you indicate which package you want to install (IPsec-tools, for example), type:
Use one of the following commands to remove a package:
For a complete package removal:
# apt-get clean.
MPC-2000 Series Linux Software System Configuration
moxa@MOXA:~# sudo apt-get clean
moxa@MOXA:~#
moxa@MOXA:~# sudo apt-mark hold linux-image-4.9.0-8-amd64
moxa@MOXA:~# sudo apt-get upgrade
moxa@Moxa:~$ sudo alsamixer
ATTENTION
The audio output sets the headphone as default playback interface. If you used speaker, you should select the
output device as speakers.
The Linux system software is continuous updated and available in Debian repository. If you want to use the
latest released software, you can upgrade it by apt command. This example holds the Linux kernel package
because if the kernel upgraded, the kernel module might need to rebuild and install again. So we upgrade the
whole system except the kernel image package was hold.
moxa@MOXA:~# sudo apt-get update
Audio Player
The MPC-2101/2121-LX has an audio playback interface. The system default installs the command-line
playback utility alsa-utils. The alsamixer is the soundcard mixer for ALSA soundcard driver. You can use the
alsamixer to control the audio output or use it to control the volume.
Press F3 or TAB to select the soundcard output interface in the alsamixer playback view. In this case, we choose
headphone as the soundcard output interface. The volume can control by Master, headphone or PCM interface.