Posts

Assembler Basics: Registers

When learning Assembler and Machine Language, processor registers are super important. Whenever you want to calculate something in Assembler, you first have to load the values into a register before you can perform the arithmetic calculation. Let's start with a hello world program in C: hello.c: #include <stdio.h> int main() { printf("hello world"); }  Compile and link it with: gcc hello.c Have a look at the <main> function with the command: objdump -d -Mintel a.out Note that objdump -Mintel puts the source operand right and the target operand left while objdump -MIntel does it the other way round. Here is the <main> function:  1149: f3 0f 1e fa endbr64 114d: 55 push rbp 114e: 48 89 e5 mov rbp,rsp 1161: 48 8d 05 9c 0e 00 00 lea rax,[rip+0xe9c] # 2004 <_IO_stdin_used+0x4> 1168: 48 89 c7 mov rdi,rax 116b: b8 00 00 00 00 mov eax,0x0 1170: ...

programming Linux Kernel modules

Image
Linux kernel modules run in a priviledged space. But what does this mean? Let's find out. First let's program a "hello world" Linux kernel module: create a folder kernel mkdir kernel create a file hello.c: #include <linux/module.h> #include <linux/kernel.h> #include <linux/init.h> MODULE_DESCRIPTION("Insert description"); MODULE_AUTHOR("Insert author"); MODULE_LICENSE("GPL"); static int __init hello_init(void) { printk(KERN_INFO "Hello world\n"); return 0; } module_init(hello_init); create a file Makefile: obj-m += hello.o all: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules clean: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean run make: make insert the module: sudo insmod hello.ko verify the syslog: sudo dmesg and I see in it the following line that confirms me it works: [49694.489768] Hello world See also https://tldp.org/LDP/lkmpg/2.6/html/hello2.html https://stackoverflow...

NET::ERR_CERT_AUTHORITY_INVALID and you are webmaster?

 I am webmaster for https://linuxintro.org . However, when I visited this page in Chrome I always got the message NET::ERR_CERT_AUTHORITY_INVALID Today I resolved it after some years. I went to  https://letsencrypt.org/getting-started/ followed the instructions and got it working in 11 minutes. And it did not cost anything :) I am super happy this site exists and makes it so easy for me. I immediately donated to them because they are just so useful :)

Host key verification failed

Image
Today I got the error "host key verification failed" when trying to connect from my Linux desktop to my Google Cloud VM "linuxintro.org": # ssh thorsten@linuxintro.org The authenticity of host 'linuxintro.org (34.122.183.250)' can't be established. ED25519 key fingerprint is SHA256:7F9VxKJOEhY/ulnvywkGuQRZUB6S5xd2hG2oWbCSd2E. This key is not known by any other names Are you sure you want to continue connecting (yes/no/[fingerprint])?  Host key verification failed. The reason was that I had never logged in before, so the system did not know the key of my target VM. Solution was to call: # ssh -o "StrictHostKeyChecking no" thorsten@linuxintro.org A question that remains open with me is why I did not have to do it earlier. Earlier, the host keys were automatically added to the known_hosts file. Now I get the next error: # ssh thorsten@linuxintro.org thorsten@linuxintro.org: Permission denied (publickey). To resolve this error, I need a private/pub...

A camera for less than 10 EUR

Image
Today I got my ESP32-CAM to work. My goal is to have cheap camera surveillance all over the house, even in cellar to read my gas counter :) The camera costs less than 10 EUR, I got it from  https://de.aliexpress.com/item/32983165020.html?spm=a2g0o.order_list.order_list_main.5.26655c5fja4s5J&gatewayAdapt=glo2deu Here is the beautiful thing: I connected it to the 5V and GND GPIO PINS of my Raspberry Pi: connecting pin 1 and 3 of the RasPi to 1 and 2 on the ESP Then I looked on my desktop's internet settings and found a new open WLAN: (note: with other models I have also seen the name ESP_1065BD) I connected to the camera's WLAN. It showed a question mark as there was no connection to the internet (just to the webcam): Then, on my desktop, I looked what IP address I had in the camera's WLAN: thorsten@tweedleburg:~$ ifconfig enp2s0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500         ether 8c:ec:4b:26:a9:31  txqueuelen 1000  (Ethernet) ...

monitoring my gas counter with a webcam

Image
During my certification I have learned about DocumentAI and I am eager to put it into practical use. So, here is my project: I will install a webcam to watch my gas counter and take a picture every day. Will use DocumentAI to find out its read and store it in a table. Here is the prototype: Webcam monitoring my gas counter OK, first we have the physical setup. I use an old Ubuntu laptop (will be a Raspberry Pi soon) with a very new and good webcam:  On Ubuntu, I issue the command to grab the picture from the webcam: $ fswebcam -r 4000x3000 -d /dev/video0 test2.jpg --- Opening /dev/video0... Trying source module v4l2... /dev/video0 opened. No input was specified, using the first. Adjusting resolution from 4000x3000 to 2304x1296. --- Capturing frame... Captured frame in 0.00 seconds. --- Processing captured image... Writing JPEG image to 'test2.jpg'. When I upload it to DocumentAI, it does recognize the counter's number, in this case 9153.486 m³ Now, this deserves to be autom...

Windows is too slow - let's try Linux

Image
Today I decided to try Linux again as my desktop operating system. Here is an assessment how it worked out - especially for people who have other things to do in their lives than operating systems. Windows Windows was slow and had a lot of hiccups where it would suddenly stall for some seconds. Reboot button did not exist any longer, instead a message that power options are not available. It suggested updating to Windows 11, but said my beloved VMware Player would then cease to work. So, time for a change... to Linux. Considerations What I don't want is constant switching between operating systems. Live has better things to experience. Also, what I don't want is a USB installation that forgets the WLAN password and all my settings on reboot. Functionality The functionality I need is: Video Editing - I do it via wevideo.com, this is available where Chrome is, so, as well on Linux and Windows FreeCiv - my favorite game is available both on Windows and Linux (and the reason I do n...

Set up a webcam with Linux

Image
Hi friends,  I migrated my article to  https://medium.com/@thorsten_28158/set-up-a-webcam-under-linux-1aba3ec7bb51 A capture from a webcam in the program Cheese

AppEngine hello world

Image
During my certification I learned that you can save a lot of time by using AppEngine. Instead of setting up a web server, installing nginx and python, and wondering why they don't work together, you use AppEngine and can start programming right away. Today I wanted to check this out and deployed a "hello world" app on AppEngine. I will show you how I did it - with everything you can possible do wrong and how to correct it. Later I will show you how to put this application behind a load balancer. Go to Google Cloud Console, open Cloud Shell, check out the hello world code: git clone https://github.com/GoogleCloudPlatform/python-docs-samples Cloning the "hello world" AppEngine app from github Now deploy the application: cd python-docs-samples/appengine/ gcloud app deploy OK, now I got the first error message: So I went to Google Cloud Console -> IAM and looked for the AppEngine default Service Account. Once I had it, I gave it the requested permissions: I again...

Permission denied (publickey).

Image
Whenever I tried to ssh from one of my Google Cloud VMs to another, I got an error message. SSH asks me if I want to continue connecting, and when I say "yes", I get: Permission denied (publickey). If I just type enter (fingerprint), I get Host key verification failed. Solution for both issues: # ssh -o "StrictHostKeyChecking no" thorsten@linuxintro.org A question that remains open with me is why I did not have to do it earlier. Earlier, the host keys were automatically added to the known_hosts file. Now I get the next error: # ssh thorsten@linuxintro.org thorsten@linuxintro.org: Permission denied (publickey). To resolve this error, I need a private/public ssh key pair on my laptop. If you don't have a public key, create it using the command ssh-keygen Type ENTER for every question from ssh-keygen. Then you will find your public key file in your home directory under .ssh/id_rsa.pub. Find out how it looks, here is mine: # cat .ssh/id_rsa.pub  ssh-rsa AAAAB3NzaC1y...

When bookmarks are not enough...

Image
When bookmarks are not enough...  I just want to type tr whatever into Chrome's search bar and get a translation of whatever : The quickest way to get a translation,  in this case of "bookmark". Read below how to set it up. I knew this was possible and searched for it using the terms quicksearch , shortcuts and extended bookmarks . But the real feature name is site search . Let's see how we set it up: in Chrome's settings menu, select search engine -> manage search engines and site search: scroll to "site search", click "add": enter a keyword and URL to be composed from the string you give after the keyword: You see that you configure a keyword here (in this example tr) and tell the browser to move to an URL on this keyword. This URL can contain the string you enter after they keyword. You just write %s and the URL will contain the string at this place. OK, cool thing, especially because it is so versatile. I recall in the KDE project we ha...

How do databases work?

Image
When you study databases, you wonder why some people always seem to get it right, while the majority just doesn't seem to get it right. I will tell you in the next 10 minutes how to get it right - or you get your money back. So, the secret is storytelling. When I think of a database, I think of my friend John who works in front of a big file cabinet like this here: John's job is to keep his boss happy. His boss comes in every now and then and wants to have some information from the file cabinet, like "how many blue cars have we sold in 2021". Sometimes, the boss also tells John some information that he is supposed to write into the files. This takes a lot of time because every folder has an index that needs to be updated (one index is for "car salesmen", the other for "car types" and many more). Plus, there are " aggregates " (how many cars are still in stock) that need to be updated whenever a car sale goes into the folders. And much mor...