Getting Started: Difference between revisions

[unchecked revision][unchecked revision]
Content deleted Content added
mNo edit summary
Line 42:
 
==Choosing your development environment==
You need a platform to develop your new system on. Following the trends of general computing, the two most popular are Windows andis GNU/Linux, but many use Windows too. Developers using a GNU/Linux system have a slight advantage in availability of tools, but this can be solved on Windows using a system such as [[Cygwin]] or [[MinGW]].
 
* '''Binutils''': Fundamental tools for manipulation of object files.
Line 54:
 
You might not use all of these tools, but it is best to have them on hand "just in case," and know how to use them, even at a basic level. But if you decided to use another [[Languages | language]] then the tooling is mostly up to you and maybe the list above just won't help you in any way. Below is the information mostly related to the C/C++ or Assembly developers.
 
===GNU/Linux===
 
The most recommended system for OS development is GNU/Linux. When using GNU/Linux, most of the GNU development tools are probably already present. If not, use your distribution's package management tools (APT, RPM, Portage, Pacman, Apk, etc.) to install them as needed. Again, making a [[GCC Cross-Compiler | cross-compiler]] is required, so as not to link in the development system's runtime files.
 
Common editors are [[Wikipedia:Vim (text editor)|Vim]], [[Wikipedia:Emacs|Emacs]], [[Wikipedia:KDevelop|KDevelop]], [[Wikipedia:Komodo_Edit|Komodo Edit]], etc. Some prefer lightweight editors instead of an IDE, such as [[Wikipedia:gedit|gedit]], [[Wikipedia:Geany|Geany]] and [[Wikipedia:SciTE|SciTE]]. Many like [[Wikipedia:Midnight_Commander|Midnight Commander]] which has a [[Text UI]] and a built-in editor (mcedit) and therefore extremely lightweight and lightning fast.
 
About which distributions you should use, consult the [https://en.wikipedia.org/wiki/List_of_Linux_distributions list of Linux distributions]. They came in every shape and sizes, and not all suited for kernel development. Do not use a distro that has a specific goal, like security (Kali, Qubes, BackTrack, Parrot etc.), science applications (eg. Scientific), firewalls and routing (eg. DD-WRT), system recovery or embedded environments (Knoppix, Rescatux, TinyCore) or specifically targeted toward beginners (like Linux Mint, Nitrux etc.) Although a beginner friendly Linux could do, choose one that's a general purpose distro. Also use a distro which has up-to-date packages, best to pick one which uses rolling-release. Debian is easy to use, but often ships ancient, and patched versions (the tools might not behave as described). Many beginners like Ubuntu, which is fine, but it is reported to have problems with some toolchains and compilation environments (if you compile your own [[GCC_Cross-Compiler|cross-compiler]] instead of using an installed one, this is a non-issue).
 
Best distros for kernel development are (but keep in mind this is also a matter of personal taste, so these distros are not required rather suggested, and they usually require some experience): Arch, Gentoo, Solus, Slackware, void etc. even Puppy.
 
If you are unsure, try Ubuntu or Manjaro.
 
===Windows===
 
In order to get the tools necessary, you should install the [[Cygwin]] environment. [[MinGW]] or [[DJGPP]] are alternatives, but Cygwin[https://www.msys2.org/ MSYS2] is strongly suggested as it is the most complete and compatible environment, and also includes a package manager to install libraries and tools.
 
Microsoft has recently (as of writing) released the Windows Subsystem for Linux as an optional feature for Windows 10. It is basically a real Ubuntu command line distribution running on top of Windows WITHOUT the use of a VM. The latest GCC and Binutils (6.1.0 and 2.27 as of writing) compile and work correctly in this environment. Using the Bash shell, you can access your Windows hard disks through /mnt/<drive letter>. The advantage of this solution is that you can work with whichever Windows or Linux tools that you require, without having to find out if they work in Cygwin. Many of the needed tools can be installed using "apt-get".
Line 63 ⟶ 75:
For all of the above, it is strongly suggested to build a cross-compiler, not only because the default compilers target different [[Executable Formats|executable format]]s, but because it's generally a good idea. Check the [[GCC Cross-Compiler]] page for details and instructions.
 
You will also need an editor. Using Notepad will work, but it's easier if you have a more complete editor. For example, [http://notepad-plus-plus.sourceforge.netorg/uk/site.htm Notepad++] or [http://www.flos-freeware.ch/notepad2.html Notepad2] are used by many people. If you are comfortable with Unix editors, you can pick one from the choice Cygwin provides (which includes e.g. Vim and Emacs, which take some getting-used-to but are very powerful).
 
It is also possible to use [[Visual Studio]], or the freely downloadable [http://www.microsoft.com/express/ Visual C++ Express Edition], to write and compile your operating system. You will require a special configuration file, and you will certainly be in the minority, but it does work quite well. You can even install the Windows SDK on top, enabling 64 bit development. The only pitfall is this doesn't support Inline Assembly.
Line 69 ⟶ 81:
Other tools such as [[Watcom]] or [[Borland]] can be used, too, but they each have specific requirements of their own, and are not widely used for this kind of work.
 
===GNU/LinuxMacOS===
 
When using GNU/Linux, most of the GNU development tools are probably already present. If not, use your distribution's package management tools (APT, RPM, Portage, Apk, etc) to install them as needed. Again, making a [[GCC Cross-Compiler | cross-compiler]] is required, so as not to link in the development system's runtime files.
Because under the hood it uses FreeBSD's userland, it is fully POSIX compatible. All the usual tools are available (vi, bash, dd, cat, sed, tar, cpio, etc.) Almost every tutorial works out-of-the-box. The missing tools are mostly file system related: no [[Loopback_Device|loopback device]], no fdisk, no mkfs.vfat nor mtools. But you can use diskutil for these purposes, or use [https://brew.sh/ brew] or [https://www.macports.org/ macports] to install those missing tools.
 
To get gcc, you had an mpkg on the 2nd Installation DVD for the older versions. Never MacOS versions can install command line XCode (not the IDE, just the toolchain) by running "xcode-select --install" from a Terminal. This will install gcc, binutils and make. This gcc is actually a masquaraded CLang, but featurefull enough to build your own [[GCC_Cross-Compiler|cross-compiler]] without problems. It is preferred to use the official compiler for bootstraping gcc than to install one from brew or macports.
Common editors are [[Wikipedia:Vim (text editor)|Vim]], [[Wikipedia:Emacs|Emacs]], and [[Wikipedia:KDevelop|KDevelop]].
 
===Testing your operating system===