Month: April 2016

How to protect GRUB to avoid init=/bin/bash

Normally the GRUB bootloader of our computer enable any people to edit it and change the kernel command line to add “init=/bin/bash” and get irrestricted access to all files in your system.

Fortunately GRUB lets you to add a password to it as explained here:

All you need to do is edit your /boot/grub/grub.conf and add:

set superusers="root"
password_pbkdf2 root grub.pbkdf2.sha512.10000.biglongstring

Also you need to create a password’s hash using this command:

$ grub-mkpasswd-pbkdf2

Then replace the above “grub.pbkdf2.sha512.10000.biglongstring” with this generated hash.

But this solution is not good enough because it will prevent the GRUB menu editing but also will annoy you asking a password everytime you try to boot your system.

You can fix it adding “- – unrestricted” to menuentry in the grub.conf:

menuentry 'Debian GNU/Linux' ... --unrestricted {

That is all!

Getting started with RFM69

The RF transceivers RFM69 are really nice for low power applications. There are many projects using it currently.

It supports FSK, GFSK, MSK, GMSK and OOK modulations. Also it has AES and CRC-16 engines internally.

I decide to list some projects here as future reference.

First project is called RadioHead (no! it is not the music band). The main advantage of RadioHead is because it supports many types of transceivers (nRF24, CC1100, MRF89, etc) :

The second project is from LowPowerLab, it is devoted exclusively to RFM69 family:

Other project devoted to RFM69 is plainRFM69, this project has some optimization to enter on low power mode as soon os possible and doesn’t have all features from previous project:

There is an interesting thread from iwanders (Ivor Wanders is the author of plainRFM69) :

Another interesting project: Using a RFM69 to control a KaKu switch with OOK modulation:

I receive some RFM69HW modules (bought from Alibaba) and my plan is to use it with NuttX, this transceiver has many features, then creating a Network Driver is not so easy. The datasheet is here:

Running NuttX on Teensy 3.1

The PJRC Teensy 3.1 board is a very nice and powerful board. It has a small form-factor powered by NXP/Freescale MK20DX256 ARM Cortex-M4 microcontroller at 72MHz.

Normally it is used to run Arduino compatible sketches. Since I’m not a great Arduino fan the logic thing to do is run something else on it.

Fortunately NuttX has support to this board.

These are the steps I did to get it running:

1) Download the teensy loader for your platform:

$ gunzip teensy.64bit.gz 
$ mv teensy.64bit teensy_loader
$ chmod a+x teensy_loader
$ sudo cp teensy_loader /usr/local/bin/

3) Get the udev rules and copy it to right place:

$ wget
Resolving (
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1622 (1.6K) [text/plain]
Saving to: ‘49-teensy.rules’

49-teensy.rules                100%[=================================================>]   1.58K  --.-KB/s    in 0s      

2016-04-16 15:23:31 (47.7 MB/s) - ‘49-teensy.rules’ saved [1622/1622]

$ sudo cp 49-teensy.rules /etc/udev/rules.d/

3) Clone NuttX mainline bitbucket apps and nuttx repositories.

$ mkdir nuttx_teensy
$ cd nuttx_teensy
$ git clone
$ git clone

4) Compile NuttX to Teensy 3.1:

$ cd nuttx
$ cd tools/
$ ./ teensy-3.x/nsh
$ cd ..
$ make menuconfig
  Build Setup  --->
    Build Host Platform (Linux)  --->

$ make
LD: nuttx
make[1]: Leaving directory '/comum/workspace/NuttX/nuttx/nuttx/arch/arm/src'
CP: nuttx.hex
CP: nuttx.bin

5) Plug Teensy 3.1 on USB cable and press the board’s button.

6) Now run the teensy loader:

$ teensy_loader
File ->
  Open HEX File
    Select nuttx.hex

Click on Program icon Button it will program nuttx.hex in the board

7) Connect a USB/Serial 3.3V to Teensy 3.1 board, this way:

USB Serial | Teensy Board pin
   GND     |       GND
   TXD     |        0
   RXD     |        1

8) Run minicom or other serial console program
Configure it to use your USB/Serial port as 115200 8n1

Now in the teensy load program click on Reset icon Button, the NuttX shell will appear:

NuttShell (NSH)
nsh> ?
help usage:  help [-v] []

  [           cmp         free        mkfifo      set         unset       
  ?           dirname     help        mh          sh          usleep      
  basename    dd          hexdump     mv          sleep       xd          
  break       echo        kill        mw          test        
  cat         exec        ls          pwd         time        
  cd          exit        mb          rm          true        
  cp          false       mkdir       rmdir       uname       

Builtin Apps:

Moving all files and directories to a new subdirectory with a single command

This is a nice trick I learned today thank to this post.

If you are inside a directory with many files and subdirectories and you want to move everything to a new subdirectory you don’t need to move one-by-one, you can use this trick:

$ cd ~/Download
$ ls
fileA fileB fileC
dirAA dirBB dirCC
$ mkdir Download
$ shopt -s extglob
$ mv !(Download) Download

This command will move all files and directories to a new subdirectory, except the hidden files and directories (files/dir started with .something).