BSP and embedded driver development notes
1. Basic concepts of Embedded Systems
An application-centered, computer-based system with configurable software and hardware, and a dedicated system with strict constraints on functions, reliability, cost, volume, and power consumption, the computer used is called an embedded computer.
Linux directory file
/Bin: Obviously, Bin is the abbreviation of binary.
/Boot: stores all the programs used when the system starts. Some information here will be used when you use grub or lilo to guide Linux.
/Dev: Dev is the abbreviation of device. This directory is very important to all users. This directory contains all external devices used in Linux. However, this is not the driver of the external device.
/Etc: The etc directory is one of the most important directories in Linux. This directory stores various configuration files and subdirectories used for system management. The network configuration file, file system, X system configuration file, device configuration information, and user information that we need to use are all in this directory.
/Sbin: This directory is used to store system management programs of the system administrator.
/Home: If you create a user with the username "JL", there is a corresponding/home/JL path in the/home directory to store the user's home directory.
/Lib: Lib is the abbreviation of library. This directory is used to store the system to dynamically connect to the shared library. Almost all applications use the shared libraries in this directory.
/Mnt: This directory is usually empty. You can temporarily Mount other file systems in this directory.
/Proc: You can obtain system information in this directory. This information is generated by the system itself in the memory.
/Root: if a user logs on as a Super User, this is the main directory of the Super User.
/Tmp: used to store temporary files generated during execution of different programs.
/Usr: This directory occupies the largest hard disk space in Linux.
Linux commands
1. ls, mkdir, rmdir, date, who relative path, and absolute path
2. file decompression command
Gzip *. jpg compressed gzip-D *. GZ unzip
Packaging command
. GZ
Decompress 1: gunzip filename.gz
Decompress 2: gzip -dfilename.gz
Compression: gzip filename
Package
.Tar.gz and. tgz
Decompress: Tar zxvffilename.tar.gz./dirname
Compression: Tar zcvffilename.tar.gz dirname
.Tar.bz2
Decompress: Tar xjf filename.tar.bz2./dirname
Compression: Tar CJF filename.tar.bz2 dirname
Fdisk-l view disk device information fdisk-L/dev/SDB view disk device information such as USB flash disk
Mount and mount a USB flash drive and NFS
Mount-t nfs Host IP: mount point of the shared directory Mount-t nfs 192.168.1.4:/arm2410s/mnt
-Onolock plus file lock Mount-T nfs-onolock 192.168.1.4:/home/test/mnt
Mount-T msdos/dev/sdb1 MNT/USB flash drive device is/dev/sdb1 mounted to/mnt/USB
Mount-T vfat/dev/sdb1/mnt/sdcard mount the USB flash disk
Msdos file system parameters such as FAT32 vfat fat16 msdos ext ext2
RedHat-config-Users
2nd introduction to the embedded cross-Development Environment
Embedded Linux development process
1. Establish a Development Environment
2. Configure the development host and mini-COM (equivalent to a Super Terminal in Windows)
3. Create a boot loader.
4. Download the Linux operating system that has been transplanted by others
5. Create a root file system
6. Create a flash partition for the Application
7. Develop applications
8. Run the kernel, root file system, and applications.
9. Release Products
Development Mode cross-Compilation
• Host is a system used to develop embedded software. The computer on which the virtual machine software is to be installed.
• Target is a developed embedded system. Indicates an arm device.
• Cross-compiler is the main software tool for cross-platform development. It is a compiler that runs on a processor architecture, but can generate the target code that runs on a different processor architecture.
Serial Port, network cable
Linux, arm, and PC
FTP can communicate with each other. NFS is the communication between Linux and Linux. Samba servers communicate with each other between Linux and Windows. NFS can load remote file systems to local file systems.
RedHat remote logon to Windows
Windows Remote logon to Linux enable the telnet service in Windows and Linux
Steps for adding a virtual machine to a local network
1. Disable Firewall
2. Enable and set the NIC
3. enable the Service
4. Set to Bridge Mode
5. Disable the wireless network.
Notes
1. The IP addresses of vmwarevirtual Ethernet adapter for vmnet1 and RedHat must be in the same network segment.
2. network settings in RedHat
3. Virtual Machine network settings host-only
1 Bridge: equivalent to connecting the host and virtual machine to the same hub. The virtual machine and the host must be configured on the same network segment.
2 NAT: Use vmnet8 to enable necessary VMware services on the host, such as vmvaredhcp. Set the VM to DHCP. Of course, you can also manually set it to the same network segment of vmnet1.
3host-only: Use vmnet1 to directly communicate with the host. You can use ifconfig to view the configuration.
Common editing and programming tools in Linux VI gedit kwrite Emacs kdevelop
3rd C Language Development in Linux
Cross-compilation tool Installation
First, the arm-linux-gcc-3.3.2.tgz, arm-linux-gcc-2.95.3.tgz, and
The arm-linux-gcc-3.4.1.tgz copies to a directory such as TMP \, and then enters the directory, execute the decompression command:
# Cd \ TMP
# Tar xvzf arm-linux-gcc-3.3.2.tgz-C/
# Tar xvzf arm-linux-gcc-2.95.3.tgz-C/
# Tar xvzf arm-linux-gcc-3.4.1.tgz-C/
# Mkdir-P/opt/friendlyarm/qq2440; Create a working directory for backup
Then run the command
# Gedit/root/. bashrc
Edit the/root/. bashrc file. In the last row, export Path = $ path:/usr/local/ARM/3.4.1/bin
(Arm and PC)
1. Write code
2. Compile (dual platforms)
3. Execution
GCC Execution Process
The process of using GCC to generate executable files from C-language source code files involves four steps:
1. Preprocessing (also known as preprocessing)
-- Analysis of the first object (include) and pre-compiled statements (such as define) [pre-processor CPP]
2. Compile (Compilation)
-- Convert the pre-processed file into an assembly language to generate the file. s [compiler CCL]
3. Assembly)
-- Change from assembly to target code (machine code) to generate. o file [assembler as]
4. Connection)
-- Connect the target code to generate an executable program [linker ld]
-I is used to specify the header file directory.
The/usr/include directory does not need to be specified. However, if the header file is not in the/usr/include directory, we must use the-I parameter to specify it. For example, the header file is placed in the/myinclude directory, the command line for compiling must contain
-I myinclude parameter. If this parameter is not added, you will get an error "XXXX. h: no such file or directory.
Eg.
-Includefile
The function is equivalent to using # include in the code.
Example usage:
Gcc-oexample example. C-include/usr/include/stdio. h
Makefile Basic Structure
Target: prerequisites dependency
<Tab> command
Overview of make tools and makefile
1. config generates the make File
2. Make generates executable files
3. Make install (copy the file to the System Path First) to install the file to the specified location
4. Make clean: the installation files generated by make
Makefile instance:
# Start With makefile
Myprog: Foo. O Bar. o
GCC Foo. O Bar. O-o myprog
Foo. O: Foo. c Foo. H bar. h
Gcc-C Foo. C-o Foo. o
Bar. O: bar. c bar. h
Gcc-C bar. C-o Bar. o
Clean:
-RM *. O myprog
# End of makefile
Environment variable:
A) List of stored file names.
B) Stores executable file names.
C) store the compiler identifier.
D) store the parameter list.
Makefile instance with Environment Variables
======= Makefile start =====
Objs = Foo. O Bar. o
Cc = gcc
Cflags =-wall-o-g #-wall enable warning information-O Optimization-G debuggable
Exec = myprog
$ (EXEC): $ (objs)
$ (CC) $ (objs)-o $ (EXEC)
Foo. O: Foo. c Foo. H bar. h
$ (CC) $ (cflags)-C Foo. C-o Foo. o
Bar. O: bar. cbar. h
$ (CC) $ (cflags) bar. C-o Bar. o
========= Makefile end ======
Internal variables:
$ @ --- Extend to the target file name of the current rule
$ <--- Extended to the first dependent file in the dependency list
$ ^ --- Extend to the entire dependent list
Makefile variable
===== Makefile start ======
Objs = Foo. O Bar. o
Cc = gcc
Cflag =-wall-o-g
Myprog: $ (objs)
$ (CC) $ ^-o $ @
Foo. O: Foo. cfoo. H bar. h
$ (CC) $ (cflag)-C $ <-o $ @
Bar. O: bar. cbar. h
$ (CC) $ (cflag)-C $ <-o $ @
===== Makefile end ======
4th introduction to Bootloader and Kernel
Bootloader: A small program that runs before the operating system kernel runs. Through this applet, You can initialize hardware devices and create a map of memory space to bring the system's hardware and software environment to a suitable state, in order to prepare the correct environment for the final call to the operating system kernel.
Functions of bootloader
1. Hardware Device initialization (CPU clock speed, SDRAM, interrupt, serial port, etc)
2. kernel startup parameters
3. Start the kernel
4. interact with the host, download image files from the serial port, USB port, or network port, and manage storage devices such as flash.
The first embedded system to execute bootloader
Bootloader burning mode
1. Through the JTAG Port
2. Ethernet port
3. Serial Port
4. The first two methods are much faster than the last one.
Operating mode of bootloader
1. Start the loading mode (product release)
2. Download mode (burning the Write System)
Vivi is a bootloader for compilation and configuration. Common bootloaders include Vivi and uboot.
Kernel reduction make menuconfig the kernel compilation result is to generate the zimage File
ARCH/ARM/boot/zimage, which can decompress the image file of the compressed Kernel
Build the root file system./mkyaffsimage root_nfs root. img
5th drivers and QT
Currently, Linux supports three device drivers:
Character device, such as serial port, touch screen, parallel port, virtual console, AD, etc.
Block deivce, such as disks, memory, and Flash.
Network interface ). Eth0.
Similar to character devices, Block devices also access data through file systems. The difference between Block devices and character devices is that they manage data in the kernel in different ways.
In traditional device management, in addition to the device type, the kernel also needs a pair of parameters called the Primary and Secondary device numbers to uniquely identify a device.
The same driver is used for devices with the same primary device number. The secondary device number is used to differentiate the instances of a specific device.
Create a device node for this module.The primary device number refers to the number of devices of a certain type.
Command: mknod/dev/TSC 254 0
Here,/dev/TS indicates that our device name Is ts, "C" indicates that it is a character device, "254" indicates the master device number, and "0" indicates the secondary device number.
Once a device file is created through mknod, it is retained until we delete it manually.
Linux driver compilation and Loading Methods
One is to directly compile the program to the kernel. After the kernel is started, the new driver runs;
Second, compile as a module and load and run it dynamically.
To operate a module, use module-utiles:
Insmod inserts the compiled module into the kernel directly.
Rmmod detaches a module from the kernel
Lsmod displays installed modules
Differences between drivers and Applications
An application generally has a main function that executes a task from start to end;
The driver is different. It does not have the main function. By using the macro module_init (initialization function name), the initialization function application can be connected to the glibc library, so it can contain standard header files, for example, <stdio. h>, <stdlib. h> ,;
The standard C library cannot be used in drivers. Therefore, all C library functions cannot be called, and only kernel functions <Linux/module. h> can be called.
QtIt is a cross-platform product produced by Norwegian trolltech.C ++ graphical user interface library.
Exam
Select 20
Fill in 20
Command operation 20
Programming 20
Analysis 20