Embedded Linux C Language Primer tutorial

Source: Internet
Author: User
Tags posix

Suppose you have learned the basic C language grammar.
1. The general process of programming.

1) Design the framework of the entire program. Before you start writing your program source code, you need to design the entire program according to your needs. The program is usually composed of several modules, perhaps you are responsible for a program is only a module, of course, you can also divide the module into several sub-modules, until you think no need to divide. Modules are required to define interfaces with other modules, usually the. h header file. No need for meticulous design, can be added during the programming and debugging process.

2) write the source code according to the framework. It is generally found in the programming process that the unreasonable place of the previous design, to be modified. Sometimes after writing a (sub) module, write a simple test program to verify and debug this (sub) module.

3) Debug the source code. Everyone will make mistakes, the compiler will tell you a part of the program syntax errors or warnings, please try to ensure that the completion of the program without any warning. Debugging can be done through the debugger (typically gdb under Linux), or simply by printing (printf, etc.), which is usually used only by beginners. During the commissioning process, it is sometimes found that the omission of programming or even the unreasonable design, modification.

4) test. Leave the programs you think are no longer in question to others (testers/users), and usually they will find some problems that you don't anticipate.

2.linux Introduction

The Linux operating system refers to the operating system that uses the Linux kernel. The Linux kernel was first released by Linus Torvalds in 1991, it is a Unix-like kernel, and the Linux kernel is time-sharing, supporting multi-process, multi-threading, multiprocessor, multi-user.

The vast majority of applications used by the Linux operating system are also free open source, a significant portion of which is part of the GNU project, and some say Linux operating systems are gnu/linux.

3. Different from standard C.

The difference lies in the interface with the operating system. Standard C does not include interfaces for hardware operations and process/thread operations. The interfaces provided by different operating systems are not the same.

UNIX has two major branches: System V and BSD, each with an operating system interface that is incompatible with each other. The POSIX standard was later provided to provide source-level software portability across operating systems. Linux can support most system V and BSD operating system interfaces. Linux is also POSIX-based, although there may be a bit of a discrepancy in implementation. I personally use POSIX interface functions during the programming process.

4. The difference between Linux on embedded Linux and PC:

1) Hardware architecture. Embedded Linux is mostly run on the ARM processor, it is RISC, while the PC x86 processor is CISC. But for application development, there are only very small differences, such as arm majority using small-end storage, and x86 as the big-endian storage (explained behind). ARM's memory is usually also relatively small. Processing and memory chips are usually soldered directly to the motherboard, rather than using slots like a PC.

2) Guide. The difference between the bootloader is determined by the hardware architecture. Embedded Linux mostly uses uboot booting, and Linux on PCs usually uses grub.

3) kernel and driver. This is also the reason for the different hardware architectures. Devices on x86 typically use a variety of buses to minimize differences between devices, such as PCI-E. ARM, on the other hand, is often directly attached to the device's registers on the address bus, of course, now arm usually has a USB bus. While the kernel and driver (which may need to develop some device drivers themselves, the kernel also contains some device drivers) to encapsulate the hardware interface of the device as a software interface, and some drivers to provide the same interface as PC Linux. So for application development, the difference from Linux C programming on a PC is not very significant.

4) file system. Embedded systems typically use BusyBox to build file systems that provide limited functionality relative to the PC but can meet general requirements.

Introduction to the 5.linux File system catalog

  

Embedded Linux C Language Primer tutorial

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.