lowlevelprogramming-university/README.md

142 lines
7.9 KiB
Markdown
Raw Normal View History

2017-01-02 02:13:20 +00:00
# Low-Level Programming University
2017-01-01 19:51:45 +00:00
## What is it?
This page is for beginners who want to be low-level programmers.
2017-01-03 14:37:21 +00:00
I'm inspired by [google-interview-university](https://github.com/jwasham/google-interview-university). I'd like to share my experience and show a roadmap to becoming a low-level programmer because I have found that these skills are not as common as they once were. In addition, many students and beginners ask me how they could become low-level programmers and Linux kernel engineers.
2017-01-03 14:37:21 +00:00
I have over 10 years of experience as a low-level programmer:
2017-01-01 19:51:45 +00:00
* 80x86 Assembly programming
* Hardware device with Atmel chip and firmware
* C language system programming for Unix
* Device driver in Linux
* Linux kernel: page allocation
* Linux kernel: block device driver and md module
2017-01-02 02:13:20 +00:00
## What Is the Low-Level?
I classify low-level programming as programming that is very close to the machine, using a lower level programming language like C or assembly. This is in contrast to higher-level programming, typical of user-space applications, using high level languages (e.g. Python, Java).
2017-01-03 18:34:39 +00:00
* [Wikipedia: Low-level programming language](https://en.wikipedia.org/wiki/Low-level_programming_language)
Yes, system programming is very close concept to the low-level programming. This page includes the hardware design and firmware development that is not included in system programming.
2017-01-03 18:34:39 +00:00
* [Wikipedia: System programming](https://en.wikipedia.org/wiki/System_programming)
Finally, this page includes topics ranging from hardware components to the Linux kernel. That is a huge range of layers. One page document can never cover the detail of all layers, so the aim of this document is to serve as a starting point for low-level programming.
2017-01-03 18:34:39 +00:00
2017-01-06 17:18:31 +00:00
## Theory
There are two background theories to low-level programming:
2017-01-06 17:18:31 +00:00
* Computer Architecture
* Operating System
You can find many good classes on online universities, for instance, Coursera.org and edx.org.
Theory is theory. I don't think you should get A+ in the class, just understand the big picture in the class.
You'll get better and better with experience.
2017-01-06 17:18:31 +00:00
## Languages
### Assembly
* [8086 assembly programming with emu8086(translation in progress)](https://github.com/gurugio/book_assembly_8086)
* basic concepts of CPU and computer architecture
* basic concepts of C programming language
* [64bit assembly programming(translation in progress)](https://github.com/gurugio/book_assembly_64bit)
* basic concepts of modern CPU and computer architecture
* basic concepts of disassembling and debugging of C code
### C language
2017-01-04 13:52:02 +00:00
There is no short-cut. Just read the entire book and solve all exercises.
* [C Programming: A Modern Approach, 2nd Edition](https://www.amazon.com/C-Programming-Modern-Approach-2nd/dp/0393979504)
* [The C Programming Language 2nd Edition](https://www.amazon.com/Programming-Language-Brian-W-Kernighan/dp/0131103628/ref=pd_sbs_14_t_0?_encoding=UTF8&psc=1&refRID=60R1D2CHBA8DHYT6JNMN)
* [Modern C](http://icube-icps.unistra.fr/img_auth.php/d/db/ModernC.pdf)
* For new standard of C
## Applications
2017-01-05 20:44:54 +00:00
### Hardware && Firmware
If you want to be an embedded system engineer, it would be best to start from a simple hardware kit, rather than starting with the latest ARM chipset.
2017-01-05 20:04:47 +00:00
2017-01-05 20:44:54 +00:00
* [Arduino Start Kit](https://www.arduino.cc/)
2017-01-06 22:33:51 +00:00
* There are various series of Arduino but "Arduino Start Kit" has the most simple processor(Atmega328P) and guide book
* Atmega328P has 8bit core that is the good to start "Digital circuit design" and "Firware development".
* You don't need to know how to draw schematics and layout, and assemble the chips.
* But you need to know how to read schematics and understand how the chips are connected.
* Firmware developers should be able to read the schematics and figure out how to send data to the target device.
2017-01-06 22:33:51 +00:00
* Follow the guide book!
2017-01-05 20:44:54 +00:00
* [8086 manual](https://edge.edx.org/c4x/BITSPilani/EEE231/asset/8086_family_Users_Manual_1_.pdf)
* If you're a beginner to x86 architecture, 8086 is also very good guide for processor architecture and 80x86 assembly
2017-01-05 20:44:54 +00:00
* [80386 manual](http://css.csail.mit.edu/6.858/2015/readings/i386.pdf)
2017-01-06 22:33:51 +00:00
* Best guide for protected mode and paging machanism of 80x86 processor
* Web version: https://pdos.csail.mit.edu/6.828/2011/readings/i386/toc.htm
2017-01-05 20:04:47 +00:00
At this point, you should be good to start the latest ARM or x86 processor.
2017-01-05 20:44:54 +00:00
* https://www.raspberrypi.org/
2017-01-05 21:24:19 +00:00
* https://beagleboard.org/
2017-01-06 22:33:51 +00:00
* https://www.arduino.cc/en/ArduinoCertified/IntelEdison
2017-01-05 21:24:19 +00:00
For example, the Raspberry Pi board has a Cortex-A53 Processor that supports a 64-bit instruction set.
This allows you to experience a modern processor architecture with rPi.
Yes, you can buy it... but... what are you going to do with it?
If you have no target project, you would be likely to throw the board into a drawer and forget it like other gadgets you may have bought before.
2017-01-05 21:24:19 +00:00
So, I recommend one project for you.
2017-01-05 21:24:19 +00:00
* [Making your own kernel](http://wiki.osdev.org/Getting_Started)
2017-01-06 09:32:06 +00:00
* Good references: https://www.reddit.com/r/osdev/
2017-01-05 21:24:19 +00:00
2017-01-06 09:41:22 +00:00
I've made [a toy kernel](https://github.com/gurugio/caos) that supports 64bit long mode, paging and very simple context switching. Making a toy kernel is good way to understand modern computer architecture and hardware control.
In fact, you have already the latest processor and the latest hardware devices.
2017-01-06 09:41:22 +00:00
Your laptop! Your desktop! You already have all to start!
2017-01-05 21:24:19 +00:00
You don't need to buy anything.
The qemu emulator can emulate the latest ARM processors and Intel processors.
So everything you need is already on hand.
There are so many toy kernel and documents you can refer to.
Just install qemu emulator and make a tiny kernel that just boots and turns on paging, and prints some messages.
2017-01-05 20:04:47 +00:00
2017-01-06 09:32:06 +00:00
Other toy kernels:
2017-01-06 09:27:57 +00:00
* https://littleosbook.github.io/
### Linux kernel and device driver
2017-01-05 21:32:47 +00:00
You don't need to make a complete operating system.
Join the Linux community and participate in development.
2017-01-05 20:44:54 +00:00
#### Read carefully
2017-01-04 09:59:39 +00:00
2017-01-05 21:24:19 +00:00
* Books: Read followings in order
2017-01-06 17:18:31 +00:00
* [The Design of the Unix Operating System](https://www.amazon.com/Design-UNIX-Operating-System/dp/0132017997)
* The basic concepts of Unix are applied into all operating system.
* This book is very good to get the concepts of operating system.
2017-01-05 21:39:09 +00:00
* [Linux Device Drivers](https://www.amazon.com/Linux-Device-Drivers-Jonathan-Corbet/dp/0596005903/ref=sr_1_4?ie=UTF8&qid=1483650712&sr=8-4&keywords=understanding+linux+kernel)
* Make all examples for yourself
* [Linux Kernel Development](https://www.amazon.com/Linux-Kernel-Development-Robert-Love/dp/0672329468/ref=sr_1_2?ie=UTF8&qid=1483650712&sr=8-2&keywords=understanding+linux+kernel)
* Understand the design of Linux Kernel
* [Understanding the Linux Kernel](https://www.amazon.com/Understanding-Linux-Kernel-Third-Daniel/dp/0596005652/ref=sr_1_1?ie=UTF8&qid=1483650712&sr=8-1&keywords=understanding+linux+kernel)
* Read this book and the kernel source v2.6 at the same time
* Never start with the latest version, v2.6 is enough!
* Use qemu and gdb to run the kernel source line by line
* http://stackoverflow.com/questions/11408041/how-to-debug-the-linux-kernel-with-gdb-and-qemu
* https://gurugio.kldp.net/wiki/wiki.php/howto_debug_kernel
* Use busybox to make the simplest filesystem that takes only 1-second to boot
* https://gurugio.kldp.net/wiki/wiki.php/qemu_kernel
2017-01-04 09:59:39 +00:00
* [The Eudyptula Challenge](http://eudyptula-challenge.org/)
2017-01-05 21:36:08 +00:00
* This is like an awesome private teacher who guide you what to do.
* If you don't know what to do, just start this.
* [Block layer and device driver(translation in progress)](https://github.com/gurugio/book_linuxkernel_blockdrv)
2017-01-05 21:36:08 +00:00
* start from a simple block device driver example (Ramdisk) with multi-queue mode
* go forward to block layer
* [md driver of Linux kernel(in progress)](https://github.com/gurugio/book_linuxkernel_md)
2017-01-05 21:36:08 +00:00
* how mdadm tool works and how it calls md driver
* how md driver works
2017-01-04 09:59:39 +00:00
#### References
Check when you need something
* [Free-electrons homepage](http://free-electrons.com/docs/)
* many slide files introducing good topics, specially ARM-linux