eerimoq/monolinux


buildstatus
codecov

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-x86 flex bison gcovr
$ wget https://musl.cc/x86_64-linux-musl-cross.tgz
$ tar xf x86_64-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.85ms)
    PASS ls (50.77ms)
    PASS cat (50.95ms)
    PASS command_editing (50.90ms)
    PASS quotes (50.73ms)
    PASS history (50.62ms)

Tests: 6 passed, 6 total
Time:  352.57ms
============================================================
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
│   └── 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
│   │   ├── initramfs.cpio       - packed ramfs
│   │   ├── linux-5.1.3/         - Linux source and build output
│   │   ├── packages/            - packages source and objects
│   │   │   └── curl-7.65.0/
│   │   └── root/                - headers and libraries container
│   │       ├── bin/
│   │       ├── include/         - include files
│   │       │   └── curl/
│   │       │       └── curl.h
│   │       ├── lib/             - static libraries
│   │       │   └── libcurl.a
│   │       └── share/
│   ├── main.c
│   └── Makefile
├── Makefile
├── monolinux/
├── README.rst
└── setup.sh

Configuration

In general, just modify any files in this repository to match your
project’s needs.

There are a few environment variables exported insetup.sh.

Cross compilation

SeeMonolinux Jiffyfor an example project.

Tips and tricks

Seeman procfsfor 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/...

Read More

LEAVE A REPLY

Please enter your comment!
Please enter your name here