Monolinux
An embedded Linux distro with a single statically linked executable, because smaller is better!
Monolinux is primarily targeting the C programming language.
Features:
- Everything theLinux kernelprovides.
- File systems.
- Networking.
- Device drivers.
- …
- Libraries to statically link with your application.
ToDo:
- …
Build and run
Install all prerequisites:
$ sudo apt install curl qemu-system-x 86 flex bison gcovr $ wget https://musl.cc/x86 _ 64 - linux-musl-cross.tgz $ tar xf x (_) - linux-musl-cross.tgz#Only required for unit testing:$ sudo pip3 install pyinotify narmock
Source the development environment setup script.
Run the commands below to create a file system, build the Linux kernel and run everything in QEMU.
$ make -C examples / hello_world run ... Hello world!Hello world!Hello world!...
Exit QEMU with Ctrl-A C and then q
Unit testing
Execute all unit tests.
Automatically build and run a test suite when one of its files has been modified.
$ cd ml / tst / shell $ ml test ...============================================================CC main.c LD / home / erik / workspace / monolinux / ml / tst / shell / build / suite Running tests ... 1 - 6 | ...... Test results: PASS various_commands (50. (ms) PASS ls (50. (ms) PASS cat (50. (ms) PASS command_editing (50. (ms) PASS quotes (50. (ms) PASS history (50. (ms) Tests: 6 passed, 6 total Time: 352. 57 ms============================================================CC main.c LD / home / erik / workspace / monolinux / ml / tst / shell / build / suite Running tests ...
File tree
This is the file tree of the Monolinux repository.
monolinux / - this repository ├── bin / - executables ├── configs / - a few Linux kernel configs ├── examples / - example applications ├── LICENSE - license ├── make / - build system / └── packages / - packages build specifications ├── ml / - the Monolinux C library └── setup.sh - development environment setup script
User project file tree before build. These files are normally under version control.
SeeMonolinux Jiffyfor a real example project.
my-project / - my Monolinux project ├── app / ├── ├── main.c - application entry point Ef └── Makefile - project makefile ├── Makefile - top level makefile ├── monolinux / - Monolinux ├── README.rst - readme └── setup.sh - environment setup script
User project file tree after build.
my-project / ├── app / ├── ├── build / - all build output │ │ ├── app - the one and only executable ├── │ ├── initramfs / - unpacked ramfs Ram │ ├── initramfs.cpio - packed ramfs Ux │ ├── linux-5.1.3 / - Linux source and build output / │ ├── packages / - packages source and objects └── │ │ └── curl-7. 65. │ │ └── root / - headers and libraries container ├── │ ├── bin / ├── │ ├── include / - include files / │ │ └── curl / └── │ │ └── curl.h Ib │ ├── lib / - static libraries Ib │ │ └── libcurl.a │ │ └── share / ├── ├── main.c └── ef Makefile Ef Makefile ├── monolinux / ├── README.rst └── setup.sh
********
SeeMonolinux Jiffyfor an example project.
Tips and tricks
Seeman procfs
for details of the following commands.
$ cat / proc / devices $ cat / proc / meminfo $ cat / proc / modules $ cat / proc / net / arp $ cat / proc / net / dev $ cat / proc / net / protocols $ cat / proc / net / route $ cat / proc / uptime $ cat / proc / version
Disk commands.
$ ls / sys / block $ mount / dev / sda1 / mnt / disk ext4 $ ls / mnt / disk $ cat / mnt / disk / README
Configuration.
#DNS .$ cat /etc/resolv.conf
Device tree.
$ cat / sys / firmware / devicetree / base / ...
GIPHY App Key not set. Please check settings