Author: acassis

Testing QDBM: Quick Database Manager

The QDBM is a small database manager that could be used for embedded systems (just pay attention on its license: LGPL, so only dynamic linkage if you are using it for commercial applications).

Fortunately the documentation of the project is very good:

The most basic example is demonstrated on project documentation:

#include <depot.h>
#include <stdlib.h>
#include <stdio.h>

#define NAME     "mikio"
#define NUMBER   "000-1234-5678"
#define DBNAME   "book"

int main(int argc, char **argv){
  DEPOT *depot;
  char *val;

  /* open the database */
  if(!(depot = dpopen(DBNAME, DP_OWRITER | DP_OCREAT, -1))){
    fprintf(stderr, "dpopen: %s\n", dperrmsg(dpecode));
    return 1;

  /* store the record */
  if(!dpput(depot, NAME, -1, NUMBER, -1, DP_DOVER)){
    fprintf(stderr, "dpput: %s\n", dperrmsg(dpecode));

  /* retrieve the record */
  if(!(val = dpget(depot, NAME, -1, 0, -1, NULL))){
    fprintf(stderr, "dpget: %s\n", dperrmsg(dpecode));
  } else {
    printf("Name: %s\n", NAME);
    printf("Number: %s\n", val);

  /* close the database */
    fprintf(stderr, "dpclose: %s\n", dperrmsg(dpecode));
    return 1;

  return 0;

To compile this example you need to install the libqdbm:

$ sudo apt install libqdbm-dev

Save the above code as phone.c and compile this way:

$ gcc -std=c99 -o phone phone.c $(pkg-config --cflags --libs qdbm)

You can also install the package qdbm-util:

$ sudo apt install qdbm-util

Now you can create the database using this command:

$ dpmgr create mydata.qdbm

To insert data:

$ dpmgr put mydata.qdbm “Joe” “Student”

$ dpmgr put mydata.qdbm “Mary” “Doctor”

$ dpmgr put mydata.qdbm “Julia” “Actress”

RTL-SDR as FM radio on Linux

Although you don’t need GNUradio, it is a good idea to install it and the rtl_sdr wil be installed as well:

$ sudo apt install gnuradio
$ sudo apt install gr-osmosdr

You will need the audio “play” command, it is on sox package:

$ sudo apt install sox

And finally (105.1MHz is Antena1 in Belo Horizonte)

$ rtl_fm -M wbfm -f 105.1M | play -r 32k -t raw -e s -b 16 -c 1 -V1 -

Using JLink with NXP MK64FX512VLL12

This is the command:

$ sudo JLinkExe -if swd
SEGGER J-Link Commander V6.46h (Compiled Jun 28 2019 17:19:57)
DLL version V6.46h, compiled Jun 28 2019 17:19:50
Connecting to J-Link via USB…O.K.
Firmware: J-Link ARM V8 compiled Nov 28 2014 13:44:46
Hardware version: V8.00
License(s): FlashBP, GDB
Type "connect" to establish a target connection, '?' for help
Please specify device / core. : ATSAML21G18
Type '?' for selection dialog
Specify target interface speed [kHz]. : 4000 kHz
Device "MK64FX512XXX12" selected.
Connecting to target via SWD
Protection bytes in flash at addr. 0x400 - 0x40F indicate that readout protection is set.
For debugger connection the device needs to be unsecured.
Note: Unsecuring will trigger a mass erase of the internal flash.
Device will be unsecured now.
Found SW-DP with ID 0x2BA01477
Scanning AP map to find all available APs
AP[2]: Stopped AP scan as end of AP map has been reached
AP[0]: AHB-AP (IDR: 0x24770011)
AP[1]: JTAG-AP (IDR: 0x001C0000)
Iterating through AP map to find AHB-AP to use
AP[0]: Core found
AP[0]: AHB-AP ROM base: 0xE00FF000
CPUID register: 0x410FC241. Implementer code: 0x41 (ARM)
Found Cortex-M4 r0p1, Little endian.
FPUnit: 6 code (BP) slots and 2 literal slots
CoreSight components:
ROMTbl[0] @ E00FF000
ROMTbl[0][0]: E000E000, CID: B105E00D, PID: 000BB00C SCS-M7
ROMTbl[0][1]: E0001000, CID: B105E00D, PID: 003BB002 DWT
ROMTbl[0][2]: E0002000, CID: B105E00D, PID: 002BB003 FPB
ROMTbl[0][3]: E0000000, CID: B105E00D, PID: 003BB001 ITM
ROMTbl[0][4]: E0040000, CID: B105900D, PID: 000BB9A1 TPIU
ROMTbl[0][5]: E0041000, CID: B105900D, PID: 000BB925 ETM
ROMTbl[0][6]: E0042000, CID: B105900D, PID: 003BB907 ETB
ROMTbl[0][7]: E0043000, CID: B105900D, PID: 001BB908 CSTF
Cortex-M4 identified.

Using SSH with github after cloning it as HTTPS

I did a mistake and cloned github as https:

$ git clone

Then after trying to submit a commit is was failing to accept my password:

$ git push origin master
Username for '': acassis
Password for '':
remote: Invalid username or password.

To error was happening because the https is not the right repository to authenticate with your SSH Keys.

After spending some minutes trying to figure out what happend I found the solution:

$ git remote set-url origin

This command will change the repository URL to use the SSH address.

Nice Bash terminals shortcuts

Today Adam Feuer submitted a NuttX patch to changes NSH command line editing so ctrl-K deletes from char pos to EOL like GNU readline

Besides Ctrl+K you can use many others interesting shortcuts in the Bash:

  • Ctrl + A => move the cursor to the beginning of the command line;
  • Ctrl + L => Clear screen and move the command line to top of the screen;
  • Ctrl + W => Erase the word at left side of the cursor;
  • Ctrl + E => Move the cursor to the end of command line;
  • Ctrl + R => Reserve-i-search: search for a previously typed command line;
  • Ctrl + T => Exchange the left character with the character at right (current position case you are not using the vertical line cursor, see below)
  • Ctrl + U => Erase all characters at the left of the cursor until the beginning of the command file;
  • Ctrl + P => Same as arrow up, show previous command line;
  • Ctrl + F => Same as arrow right, move a position to the right;
  • Ctrl + H => Same as Backspace;
  • Ctrl + K => Erase all characters from current position until the end of the line;
  • Ctrl + Z => Case you are running a command it will make it a zombie and you return to command file. Useful when you don’t know how to close a program and Ctrl + C doesn’t work;
  • Ctrl + B => Same as arrow left, move a position to the left;
  • Ctrl + N => Same as arrow down, show next command line (case you moved to previous command line)
  • Ctrl + C => Case you are running a command, it will send a signal to kill the command;
  • Alt + . => Copy the last word from previous command files

This command will replace the square bar cursor with a vertical line cursor:

$ echo -e -n "\x1b[\x36 q"

If you want to return to previous cursor just type: reset and press enter.