Minibase, super-tiny static system
Thanks to sc0ttman on the Puppy Forum who discovered this, see post:
http://murga-linux.com/puppy/viewtopic.php?t=115255
Here is the Minibase project page:
https://github.com/arsv/minibase
I compiled like this:
# ./configure
# make
# make install
...and it compiled in, well, it seemed like a few seconds!
Installation is into folder 'out'. The utilities are statically-linked ...and wow, they are small!
Minibase is a complete Linux system, and can be used with Buildroot
to compile an X desktop. I downloaded a ready-made image from here:
https://github.com/arsv/minibase-br/
...file 'sys-1-plain.tar.xz' is only 17.7MB, what kind of desktop can that possibly be?
I expanded 'sys-1-plain.tar.gz' and inside is 'whole.img' which I
wrote to a USB stick. It actually booted to a desktop, on my HP
midi-tower PC, and I couldn't believe how fast -- under 5 seconds.
Nothing much on the desktop, just Fluxbox and urxvt. But hey, this is brilliant.
Xorg, fluxbox, urxvt etc., were compiled in Buildroot, using musl,
and it should be possible to add more apps, such as a browser.
I have a particular fascination for minimalist systems like this.
Also, I am interested in some of the utilities, for possible use in
Easy.
Tags: linux
Super Grub2 CD not so super
This looks interesting, detects the operating systems installed on a PC, creates a boot menu:
https://www.supergrubdisk.org/super-grub2-disk/
Downloaded version 2.02s10 hybrid iso, tried it on my "new" Compaq Presario...
Initial menu, chose "Detect and show boot methods"
...got blank screen, had to reboot.
Initial menu, chose "Enable all native disk drivers *experimental*"
...came back to initial menu, keyboard dead, had to press power button to reboot.
Initial menu, chose "Boot manually...", then "Operating systems"
...got blank screen, had to reboot.
Tags: linux
fbwhiptail, whiptail for the framebuffer
I have posted recently about tools to create GUIs that run on the Linux framebuffer:
http://bkhome.org/news/201808/gui-creation-for-the-linux-framebuffer.html
http://bkhome.org/news/201808/considering-ugfx.html
http://bkhome.org/news/201808/littlevgl-evaluation-part-3.html
Today, I was reading the latest blog post at the Purism site (the guys who are developing the Librem 5 phone):
https://puri.sm/posts/the-librem-key-makes-tamper-detection-easy/
Where they mentioned "fbwhiptail", which is whiptail modified to run
on the Linux framebuffer. Whiptail is like 'dialog', a tool to popup GUI
windows from shell scripts. They both create "text mode" GUIs, dialog
uses 'ncurses' and whiptail uses 'newt'.
Interesting, fbwhiptail compiles to 'fbwhiptail' and 'gtkwhiptail',
so will also work with cairo and gtk. Here is the project page:
https://source.puri.sm/coreboot/fbwhiptail/
The same developer also has it on github:
https://github.com/kakaroto/fbwhiptail
Conclusion: in it's current state, it probably suits their simple need, however, for me LittlevGL is way ahead -- just need to solve the non-functional evdev keyboard input.
EDIT 20180927:
Oh wow! I posted an "issue" to the fbwhiptail github page, and the developer, Youness, posted a very detailed reply:
https://github.com/kakaroto/fbwhiptail/issues/1
...yes, I see that fbwhiptail is tailored to their particular need. The extra info is good too, for anyone who might like to use it.
Tags: linux
Low-level container how-tos
I have accumulated some links with information about containers
at a low-level. Some are very grass-roots, DIY, tutorials, some are
simple implementations. These are in no particular order:
http://cesarvr.github.io/post/2018-05-22-create-containers/
https://blog.lizzie.io/linux-containers-in-500-loc.html
https://github.com/p8952/bocker
https://ericchiang.github.io/post/containers-from-scratch/
https://dev.to/napicellatwit/containers-from-scratch-in-18-lines-of-code-3pmn
https://www.brighttalk.com/webcast/15077/253233/containers-from-scratch
http://blog.z3bra.org/2016/03/hand-crafted-containers.html
https://github.com/arachsys/containers
https://github.com/ghedo/pflask
https://github.com/xemul/libct
https://github.com/subgraph/oz
The above are NOT about using Docker, LXC, LXD, or any of the mainstream container implementations! Also, I stayed away from implementions in languages other than C or shell script -- there are some sites with low-level code in Go for example.
Tags: linux
Linux containers in 580 lines of C
'contained' is an executable written in C, for chrooting into a filesystem, with maximum security:
https://blog.lizzie.io/linux-containers-in-500-loc.html
...as the author states, it did grow a bit beyond 500 lines! Here is the C code:
https://blog.lizzie.io/linux-containers-in-500-loc/contained.c
Using the 4.14.71 kernel, with cgroups support now enabled, I got
'contained' to work. Was able to "chroot" into a rootfs, and it is very
locked down. Too locked down to actually do anything useful.
However, it is very educational to study. It has given me an
introduction how cgroups can be used, and the intention is to apply
cgroups to EasyContainers.
Tags: linux
Goodbye uClibc-ng
I have used uClibc over the years, to created small static
executables. It is a competitor to musl, dietlibc and newlib. The
offical uClibc project died, and got forked as uClibc-ng. At that time,
just about everybody moved to musl -- Landley dropped it from Aboriginal
Linux, OpenEmbeded/Yocto dropped it -- Buildroot continue to offer a
choice of glibc, uClibc or musl, ditto OpenADK.
I have a fork of Landley Aboriginal, the last that supports uClibc:
http://bkhome.org/news/201803/aboriginal-linux-120x-resuscitated.html
Over the last few days, I have been playing with creating a native
toolchain based on uClibc-ng. I was checking out various projects, and
discovered 'pts-tcc', part of which has a utility that is a wrapper
around gcc, enabling to compile with uClibc library, rather then glibc.
This works like the 'diet' utility in dietlibc, that is, 'diet' is a
wrapper for gcc, to link with the diet libraries.
I used uClibc-ng version 1.0.30, the latest. I posted to the 'pts-tcc' project about a problem:
https://github.com/pts/pts-tcc/issues/1
However, the wrapper utility 'i386-uclibc-gcc' works. I even compiled
it for aarch64. Using it, I compiled a static "Hello World", which
after stripping was 262KB. Similar size for aarch64. Oh dear, it should
be down under 20KB -- that is the main reason for using this library, to
create small static executables. So, posted a report:
https://github.com/pts/pts-tcc/issues/2
...oh dear, another person reporting 107K and going up, this is not good!
I might try the most recent version from the original uClibc project, for comparison.
EDIT:
Yes, tested with the original uClibc, plus some patches, got a stripped
hello world 254KB. Hmmm, investigated the .config file, found the main
reason for the bloat, posted here:
https://github.com/pts/pts-tcc/issues/2
Now down to 86K, still big but a huge improvement. Will study the
.config file some more. And will go back to uclibc-ng, test that.
Tags: linux
Alpine aarch64 chrootable rootfs
I posted awhile back how easy it is to create an Alpine musl-based chrootable filesystem folder:
http://bkhome.org/news/201704/alpine-x8664-chrootable-rootfs.html
At the time, I created i686, x86_64 and armv7 root-filesystems.
Now that I am embracing aarch64, want a rootfs for compiling static executables. Hence:
http://distro.ibiblio.org/quirky/alpine/aarch64/developer/
After expansion of the tarball, instructions are inside. You will of
course need to be running a aarch64 host OS, in my case on the new
Rock64 board.
I compiled squashfs-tools 4.3, and it needs a patch for musl:
For good measure, I also applied all the patches from Debian. My rootfs does not have zlib-dev, so had to install that:
# apk add zlib-dev
...the rootfs has the Alpine apk package manager in it.
Tags: linux
LittlevGL evaluation part 3
Progress! Parts 1 and 2 are here:
http://bkhome.org/news/201808/first-go-at-evaluating-littlevgl.html
http://bkhome.org/news/201808/tentative-first-step-framebuffer-with-littlevgl.html
I didn't know how to get the mouse working without X, so posted a question to the developer's site:
https://github.com/littlevgl/lvgl/issues/374
Now have a window with buttons, and a mouse! Furthermore, it is
compiled statically with uClibc and the executable is 217KB -- bigger
than it needs to be as have included more modules than actually used.
I used my fork of Landley's uClibc-based Aboriginal chrootable filesystem:
http://distro.ibiblio.org/easyos/project/aboriginal/
...follow the instructions, and you will end up with a filesystem folder that you can chroot into.
LittlevGL is the pc-simulator tarball, as explained in the earlier
posts. But first, the exciting part... I excited from X and executed
'demo":
The "mouse pointer" is that little power-button symbol, don't yet
know how to create a proper image. I can move the pointer over a button,
click, and get output on the screen. Yay!
My changes to 'lv_conf.h':
#define LV_COLOR_DEPTH 24 /* BKColor depth: 1/8/16/24*/
Changes to 'lv_drv_conf.h':
#define USE_FBDEV 1
...
#define USE_EVDEV 1
Here is my 'Makefile':
#Here is my 'main.c':
# Makefile
#
CC = gcc
#CFLAGS = -Wall -Wshadow -Wundef -Wmaybe-uninitialized
CFLAGS = -Wall -Wshadow -Wundef
CFLAGS += -O3 -g3 -I./
#LDFLAGS += -lSDL2 -lm
BIN = demo
VPATH =
LDFLAGS = -static
LVGL_DIR = ${shell pwd}
MAINSRC = main.c
#LIBRARIES
include ./lvgl/lv_core/lv_core.mk
include ./lvgl/lv_hal/lv_hal.mk
include ./lvgl/lv_objx/lv_objx.mk
include ./lvgl/lv_misc/lv_fonts/lv_fonts.mk
include ./lvgl/lv_misc/lv_misc.mk
include ./lvgl/lv_themes/lv_themes.mk
include ./lvgl/lv_draw/lv_draw.mk
#DRIVERS
include ./lv_drivers/display/display.mk
include ./lv_drivers/indev/indev.mk
OBJEXT ?= .o
AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))
MAINOBJ = $(MAINSRC:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS) $(MAINSRC)
OBJS = $(AOBJS) $(COBJS)
## MAINOBJ -> OBJFILES
all: clean default
%.o: %.c
@$(CC) $(CFLAGS) -c $< -o $@
@echo "CC $<"
default: $(AOBJS) $(COBJS) $(MAINOBJ)
$(CC) -o $(BIN) $(MAINOBJ) $(AOBJS) $(COBJS) $(LDFLAGS)
clean:
rm -f $(BIN) $(AOBJS) $(COBJS) $(MAINOBJ)
#include "lvgl/lvgl.h"What we have now is a great jumping-off point for creating useful apps.
#include "lv_drivers/display/fbdev.h"
#include "lv_drivers/indev/evdev.h"
#include <unistd.h>
#include <stdio.h>
//Add a display for the LittlevGL using the frame buffer driver
void register_display(void)
{
lv_disp_drv_t disp_drv;
lv_disp_drv_init(&disp_drv);
disp_drv.disp_flush = fbdev_flush; //It flushes the internal graphical buffer to the frame buffer
lv_disp_drv_register(&disp_drv);
}
static lv_res_t btn_click_action(lv_obj_t * btn)
{
uint8_t id = lv_obj_get_free_num(btn);
printf("Button %d is released\n", id);
/* The button is released.
* Make something here */
return LV_RES_OK; /*Return OK if the button is not deleted*/
}
int main(void)
{
/*LittlevGL init*/
lv_init();
/*Linux frame buffer device init*/
fbdev_init();
// get a display
register_display();
// enable event input
evdev_init();
// get an input device like mouse
lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv);
indev_drv.type = LV_INDEV_TYPE_POINTER;
indev_drv.read = evdev_read;
// lv_indev_drv_register(&indev_drv);
lv_indev_t * mouse_indev = lv_indev_drv_register(&indev_drv);
lv_obj_t * cursor_obj = lv_img_create(lv_scr_act(), NULL); /*Create an image for the cursor */
lv_img_set_src(cursor_obj, SYMBOL_POWER); /*For simlicity add a built in symbol not an image*/
lv_indev_set_cursor(mouse_indev, cursor_obj); /* connect the object to the driver*/
/*Create a title label*/
lv_obj_t * label = lv_label_create(lv_scr_act(), NULL);
lv_label_set_text(label, "Default buttons");
lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, 5);
/*Create a normal button*/
lv_obj_t * btn1 = lv_btn_create(lv_scr_act(), NULL);
lv_cont_set_fit(btn1, true, true); /*Enable resizing horizontally and vertically*/
lv_obj_align(btn1, label, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
lv_obj_set_free_num(btn1, 1); /*Set a unique number for the button*/
lv_btn_set_action(btn1, LV_BTN_ACTION_CLICK, btn_click_action);
/*Add a label to the button*/
label = lv_label_create(btn1, NULL);
lv_label_set_text(label, "Normal");
/*Copy the button and set toggled state. (The release action is copied too)*/
lv_obj_t * btn2 = lv_btn_create(lv_scr_act(), btn1);
lv_obj_align(btn2, btn1, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
lv_btn_set_state(btn2, LV_BTN_STATE_TGL_REL); /*Set toggled state*/
lv_obj_set_free_num(btn2, 2); /*Set a unique number for the button*/
/*Add a label to the toggled button*/
label = lv_label_create(btn2, NULL);
lv_label_set_text(label, "Toggled");
/*Copy the button and set inactive state.*/
lv_obj_t * btn3 = lv_btn_create(lv_scr_act(), btn1);
lv_obj_align(btn3, btn2, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
lv_btn_set_state(btn3, LV_BTN_STATE_INA); /*Set inactive state*/
lv_obj_set_free_num(btn3, 3); /*Set a unique number for the button*/
/*Add a label to the inactive button*/
label = lv_label_create(btn3, NULL);
lv_label_set_text(label, "Inactive");
/*Handle LitlevGL tasks (tickless mode)*/
while(1)
{
lv_tick_inc(5);
lv_task_handler();
usleep(5000);
}
return 0;
}