In the process of learning embedded development , Especially at the beginning , Including all kinds of tutorials , It's all about learning linux, Seldom talk about how to use linux To develop their own embedded projects , That is, there is no concept of a global situation , Simple understanding , The general process is as follows ：
One 、 Build the development environment
The operating system, of course, is LInux, Or in win Install virtual machine under the system , Download the corresponding GCC Cross compiler installation , Or install the cross compiler provided by the manufacturer .
This step , It's equivalent to win Under the system , To install a IDE development environment , Such as MDK,IAR etc. .
Two 、 Configure the development host
Mainly configuration minicom, The serial assistant ,minicom The software is used as a monitor and keyboard input tool to debug the information output of embedded development board , It's a very convenient tool , When we develop other embedded programs , In fact, a lot of time also uses serial port debugging , So the ultimate principles are interlinked .
configure network , Mainly configuration NFS Network file system , This is mainly used to download programs , Of course, it can be done without configuration , There are many other ways .
3、 ... and 、 Set up the bootstrap installed in the program's bootloader
frequently-used bootloader There are mainly u-boot、vivi etc. , It seems that the mainstream is u-boot, This chip is transplanted and modified according to its own specific chip . Some chips have no built-in bootloader , This requires the development board to write Flash Fewer procedures , You can also use it windows The passage of the next JTAG Fewer parallel ports and emulators Flash Chip program , Also have linux Open source code under J-Flash Program , So when designing your own hardware , There are many ways to reserve .
Simple speak , In fact, it's about making your own board u-boot, Initialization complete , Kernel boot , download 、 Burning and writing, etc .
Four 、 Porting embedded Linux operating system
If there's one for you CPU Of Linux be perfect , such as uCLinux、ARM-Linux、PPC-Linux etc. , without , Try to transplant your own linux 了 , Then add your own specific hardware driver , Debug and modify , For band MMU Of CPU You can debug the driver in a modular way , And for uCLinux Such a system needs to be compiled into the kernel , Integrated with the kernel , Then debug .
5、 ... and 、 Set up the root file system
The previous article talked about , No root file system Linux It doesn't work , You also need the root file system . So you need to download and use busybox Software to make the root file system .
Then according to their own application needs to add other programs , The default startup script generally does not meet the requirements of the application （ Because all embedded development is freely customized ）, So you need to modify the startup script in the root file system , Its storage location is as follows /etc Under the table of contents , Include ：/etc/init.d/rc.S、/etc/profile、/etc/.profile etc. , Automatically mount the configuration file of the file system /etc/fstab, In fact, it is to customize the program you want to start , The specific situation will vary with the system , The root file system is usually set as read-only in embedded system , Need to use mkcramfs、genromfs And other tools to generate fewer image files .
6、 ... and 、 Build the application Flash Disk partition
You usually use jffs2 perhaps YAFF file system , This requires drivers for these file systems to be provided in the kernel , Some systems use NOR FLASH, Some systems use NAND FLASH, There are also two systems flash All use , that jffs2 What is the function of ？
The introduction in the encyclopedia is ：jffs2 Full name journalling flash filesystem version2（ Flash log file system version 2 ）, Its function is to manage MTD Log file system implemented on device , The log system is also necessary for a complete system , Whether it's windows still linux, With these, it's not a hooligan , Hey .jffs2 It is not intended to provide functions similar to traditional file systems , It will only be directly in MTD A file system that implements a log structure on the device , In addition to providing a log structured file system with outage reliability ,jffs2 It will also be managed in it MTD On the device " Loss balance " and “ data compression ” Other characteristics .
MTD(memory technology device Memory technology devices ), Is a variety of flash.
7、 ... and 、 Developing applications
Applications can be put into the root file system , You can also put it in yaffs、jffs2 File system , Some applications don't use the root file system , Design applications and kernels directly together , It's like uCOS-II The way .
Actually , Wrote this , This step is the ultimate goal , The previous steps are all for this step , My own understanding , There are three ways to develop application presentation ：
（1） Let's talk about application and kernel design together , Similar to uCOS-II The way , This kind of way belongs to private customization , The types of functions implemented are relatively few , It's just exclusive , But the stability requirements are high , For example, complex switches 、 Firewall, etc , Maybe more interested in linux The stability of the system and all kinds of excellent peripheral resources .
（2） be based on qt etc. GUI Developing applications , I always thought qt yes linux You can't get around it , In fact, with the understanding of , Not always ,qt It's actually a desktop system , for instance ubuntu, For a master , It doesn't matter whether there is a desktop or not , Because everything can pass through shell To complete , Use qt It's user-friendly , So for those that need to operate , Embedded device with screen , This is a good plan . For example, there are various handheld instruments with screens on the industrial touch screen , It's all in this way .
（3） No screen , Just a simple human-computer interface , For example, serial port , Key , Nixie tube , It can also realize complex function development , for instance , It's possible to develop one based on linux Of PLC, Programmable solutions , By scripting , This is also a good solution to achieve .
8、 ... and 、 Burning the kernel 、 The root file system 、 Applications
No matter how you load , Modules are good , All these developments , Process information , It's all about burning flash Medium , And then what the application needs , Just load the corresponding function program .
Nine 、 Launch product
Wrote last , Find out , I was superstitious before linux, Not to say that linux Not good. , But rather , For embedded development engineers , No best , Only the most suitable , Develop a product , What kind of , No need to , It's all local .
For example, a simple running Lantern , You have to use embedded linux programme , That's Shaobao , Just a simple 2051, Bare metal programs can be developed , It's cheap , Easy to use .
Develop a small controller device , If the function is not too complicated , You can use a little more advanced CPU, Bare metal or ucos Wait to develop , Very convenient also , Also can do many custom version of small industrial controller .
Development of a high type controller device , The function is complex , It even requires complex screen interaction , Like mobile phone. （ Android is linux My son ,OS yes linux My cousin ）, ATM , Server trading system , that linux It's perfect .
That's all Liangxu tutorial website For all of you Linux Related knowledge .