Design of Smart home based on Linux (4)

Source: Internet
Author: User
Tags gz file file transfer protocol

3 Construction of the development environment

This topic uses the development environment is special, does not have a ready-made integrated development environment, needs oneself step by step to build the development environment, the development environment construction process is very complex, and if does not have this development environment this topic cannot carry on. Therefore, in the design, the development environment must be built.

3.1 Virtual machine installation and system installation

Install the VMware Workstation 10.0 virtual machine on the PC, change the virtual network to bridging mode, install the Ubuntu12.04 system in the virtual machine, and then install the Vm-tools.

Create a shared directory under Windows G:/share, enabling files to be copied between Windows and Linux for easy development, as long as the files you want to copy (arm-linux-gcc-4.3.2) are placed under G:/share, Under the Linux terminal, you can copy files to the/home folder in the virtual machine as long as you use Cp/mnt/hgfs/arm-linux-gcc-4.3.2/home.

3.2 Installing the ARM-LINUX-GCC Cross compiler

The specific steps are as follows:

⑴ Open terminal under Ubuntu12.04 (ctrl+alt+t shortcut key) Enter the following command:

#cd/Home

#mkdir/usr/local/arm (Create/usr/local/arm directory)

#tar –ZXVF arm-linux-gcc-4.3.2.tgz–c/(unzip the compiler ARM-LINUX-GCC to/usr/local/arm)

⑵ add an environment variable to the terminal input command:

#vim/etc/profile

Add the following content to the file

Export Path=/usr/local/arm/4.3.2/bin: $PATH

Export toolchain=/usr/local/arm/4.3.2

Export Tb_cc_prefix=arm-linux

Export pkg_config_prefix= $TOOLCHAIN/arm-none-linux-gnueabi

Save (Wq), exit.

⑶ Execute command: source/etc/profile (let cross compiler environment variable take effect)

Test the Cross-compilation environment press the table key after the terminal input arm-to see if a heap of arm-linux-is present. Or you can use the ARM-LINUX-GCC–V command to have cross-compiler-related information stating that the cross-compilation environment has been successfully installed.

3.3 Installing the TFTP service

TFTP protocol is a simple file transfer protocol, based on the User Datagram (UDP) protocol, does not need to consider the connection request, connection termination and traffic control characteristics, is a very real-time communication protocol [13]. TFTP is divided into server-side programs and client programs, which are usually configured at the same time on the host with the TFTP service side and client.

The default installed Ubuntu system does not contain the TFTP server and the client, you can download the installation from the command line, the command is as follows:

#apt-get Install TFTP (install client)

#apt-get Install TFTPD (Installation server)

#apt-get Install xinetd (Installation xinetd)

XINETD is a daemon that monitors some network requests and calls the appropriate service processes to process connection requests based on network requests.

Create a tftpboot in the "/" directory and change the property to 777.

Command #chmod–r 777/tftpboot

Setup/ETC/XINETD.D/TFTP configuration with #vim/etc/xinetd.d/tftp

Service TFTP

{

Socket_type = Dgram

protocol = UDP

Wait =yes

User =root

Server =/usr/sbin/in.tftpd

Server_args =-s/tftpboot

Disable = no

Per_source =11

CPS = 100 2

Flags =ipv4

}

#Service Xinetd.d Reload (reload xinetd process)

#ufw Disable (firewall disabled)

3.4 Installing NFS Services

NFS is the abbreviation for network filesystem, which allows different machines and different operating systems to share files (share file) over the Web [14]. This topic looks at it as a file system server, you can let the ARM board or remote PC clients on the shared remote file server. It is very convenient to use, this topic of NFS host shared directory and client mount structure is shown in Figure 3-1:


Figure 3-1 NFS Host shared directory and client mount structure diagram

The specific steps are as follows:

⑴ Preparing the NFS file system directory

⑵ the NFS shared directory must be ready on Ubuntu12.04 before starting the NFS service.

For example, the topic uses Ubuntu "/nfsroot" as the NFS shared directory, you need to copy the filesystem-yaffs2.tar.gz compressed files to this directory, and then extract the root file system to get the directory.

⑶ open a terminal on Ubuntu12.04, enter the following command:

#mkdir/nfsroot

⑷ Copy the filesystem-yaffs2.tar.gz file to this directory and unzip:

#tar –ZXF filesystem-yaffs2.tar.gz

⑸ Setting the host IP

Here we set the Ubuntu IP to 192.168.12.18, the command is:

#ifconfig eth0 192.168.12.18

#ifconfig eth0 up

⑹ Configuring NFS Services

To create a new terminal on Ubuntu, enter the following command in turn:

#apt-get Install Portmap

#apt-get Install Nfs-kernel-server

#vim/etc/exports

Edit the exports file in the pop-up text editor and add it on the last line:

/nfsroot/filesystem-yaffs2192.168.12.* (Rw,sync,no_root_squash)

The wildcard character here represents any IPv4 address between 192.168.12.1~192.168.12.255, RW represents a readable writable permission, no_root_squansh means that the user logged in to the NFS host using the shared directory, if it is root , it is the root privilege for this shared directory.

⑺ Start NFS Service

#/etc/init.d/portmap restart

#/etc/init.d/nfs-kernel-server restart

3.5 Mounting the Development Board onto the file system

The effect of a successful mount should be to be able to share all the files under the/NFSROOT/FILESYSTEM-YAFFS2 directory under Linux, and the directory on the OK6410 board is identical to the directory on the server, as shown in 3-2, 3-3:

Figure 3-2 files on the client ok6410


Figure 3-3 files on the server


3.6 Building a QT development environment

Enter Apt-getinstall libqt4-dev libqt4-debug libqt4-guilibqt4-sql qt4-dev-tools qt4-doc Qt4-designer in terminal Qt4-qtconfig can install QT-related development tools and then build a cross-QT development environment. The porting steps for the Tslib library are as follows:

(1) Download tslib-1.4.tar.gz

(2) Decompression and installation Tslib

# TAR-ZXVF Tslib-1.4.tar.gz

# CD Tslib

#./autogen.sh

echo "Ac_cv_func_malloc_0_nonnull=yes" >arm-linux.cache

#./configure--host=arm-linux--cache-file=arm-linux.cache--enable-inputapi=no-prefix=/usr/local/tslib

# make

# make Install

(3) Modify ts.conf content

# vi/usr/local/tslib/etc/ts.conf

Module_raw input

Module Pthres pmin=1

Module Variance delta=30

Module Dejitter delta=100

Module linear

The entire Tslib folder is then downloaded to the corresponding path (/usr/local) of the Development Board.

(4) Development Board configuration environment variables

Export Tslib_root=/usr/local/tslib

Export TSLIB_TSDEVICE=/DEV/INPUT/EVENT0//designated Touch screen device

Export tslib_calibfile=/etc/pointercal//Specify the location of the touch screen calibration file pintercal

Export tslib_conffile= $TSLIB _root/etc/ts.conf//Specify the location of the Tslib configuration file

Export tslib_plugindir= $TSLIB _root/lib/ts//Specify the path where the touchscreen plugin is located

Export TSLIB_FBDEVICE=/DEV/FB0//Specify frame buffer device

Export Tslib_consoledevice=none//settings console device is none, otherwise the default is/dev/tty, which avoids the "Openconsoledevice:no such file or directory KDS Etmode:bad File Descriptor "error

Exportld_library_path= $LD _library_path: $TSLIB _root/lib

In addition, to ensure that there are event0 device files in the/dev/input/directory, there are fb0 device files in the/dev/directory, if not, in the following. When/ts_calibrate, the "open *: No such file or directory "Error, the device file needs to be created manually:

# Mknod/dev/input/event0 C 13 64

# mknod/dev/fb0 C 29 0

(5) Execute Test command

Restart the Development Board, in the/usr/local/tslib/bin directory, enter./ts_calibrate, the tslib touch screen five-point calibration screen, so that the tslib installation of the transplant successfully completed.

3.7 Installing the MySQL Database

Installing the server using #apt-getinstall mysql-server

Installing the client using #apt-getinstall mysql-client

Log in to the database using the command:

#mysql –u root–p

Enter Password: 123456

If the MySQL database is successfully installed, the results shown in the following 3-4 appear:


Figure 3-4 Installing a successful database and logging in successfully

Join the link library file so that QT can connect to the MySQL database.

Use #apt-getinstall libqt4-sql-mysql to install the QT MySQL database driver, which is going to have files/usr/lib/i386-linux-gnu/qt4/plugins/sqldrivers/ Libqsqlmysql.so.


Figure 3-5 MySQL database driver for QT installation

Next, look at the Linux-based smart home Design (5).




Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Design of Smart home based on Linux (4)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.