ssh proxy

A cool feature of ssh config is to use a proxy to ssh to another host.

In this example I have connected a pi to a another pi:

 

.ssh/config

Host proxypi 192.168.1.1
    HostName 192.168.1.1
    User pi
    UserKnownHostsFile /dev/null
    StrictHostKeyChecking no
    IdentityFile ~/.ssh/id_rsa.pi

Host pi2 169.254.1.1
    HostName 169.254.1.1
    User pi
    UserKnownHostsFile /dev/null
    StrictHostKeyChecking no
    IdentityFile ~/.ssh/id_rsa.pi2
    ProxyCommand ssh -F ~/.ssh/config proxypi nc %h %p
Posted in ssh | Tagged | Comments Off on ssh proxy

Generate a ext4 filesystem image in Yocto

An easy way to generate a ext4 filesystem image is to add the following to conf/local.conf

IMAGE_FSTYPES_append=" ext4"
Posted in Linux commandline, Yocto | Tagged , | Comments Off on Generate a ext4 filesystem image in Yocto

Using bmap-tool with wic generated images

The FSL community repository now uses the wic tool to create images in the form of

core-image-x11-$(MACHINE).wic.gz

To flash this file to a SD-card do the following:

  1. Install bmap-tools
$ apt-get install bmap-tools

..

2. Copy to sdcard

$ sudo bmaptool copy --nobmap core-image-x11-XXX.wic.gz /dev/mmcblk0p1

bmaptool: info: no bmap given, copy entire image to '/dev/mmcblk0p1'

bmaptool: info: synchronizing '/dev/mmcblk0p1'
bmaptool: info: copying time: 42.9s, copying speed 10.1 MiB/sec
Posted in Yocto | Comments Off on Using bmap-tool with wic generated images

Find all files containing phone numbers

To find all files in a folder containing phone numbers do

Example files containing the phone numbers: +468 444 322, +472 422 5666, +4422 44 44 211

$ grep -r "^[+].[0-9]./s.*.[0-9]$"
Posted in Linux commandline | Leave a comment

Get size of all code files in a directory

I got a question on how to get all files in a directory listing containing code.

This is what I used:

find . \( -name '*.bb*' -o -name '*.h*' -o -name '*.c*' -o -name '*akefile' -o -name '*.sh' -o -name '*.py*' \) -exec du -ch {} +
Posted in Linux commandline | Tagged , , , | Leave a comment

Getting UUID of a partition for use in /etc/fstab

To get UUID of a partition use the command

blkid /dev/sdXX

Example

me@ubuntudevmach:~/$ blkid /dev/sdb1

/dev/sdb1: UUID="405d2966-6826-4942-baa4-244f24aa31c3" TYPE="ext4" PTUUID="775559d3" PTTYPE="dos"

This is useful when editing /etc/fstab to direct a partition to a folder

Example of directing a partition to be used as the /home folder

UUID=405d2966-6826-4942-baa4-244f24aa31c3 /home ext4 errors=remount-ro 0 1
Posted in Linux commandline | Tagged , , | Leave a comment

Copying more files to an existing rootfs image

  1. Check rootfs image
    e2fsck -f myimage.ext2
  2. Resize it
    resize2fs myimage.ext2 400M
  3. mount it
    mkdir myimage
    mount myimage.ext2 myimage
  4. copy new content
    cp newcontent myimage
Posted in Linux commandline | Tagged , , | Leave a comment

Using your Linux host as a opkg package server

It is very useful to have your computer working as a opkg package server in the sence that you can install packages built and test instantly instead of rebuilding the entire image.

To enable this I did the following:

Install nginx

apt-get install nginx

Create a new nginx server config

sudo vi /etc/nginx/site-enabled/opkg-server
server {
  listen 80 default_server;

  root /home/myuser/repos/myyocto/mybuild/tmp/eglibc/deploy/ipk;

  autoindex on;
}

Remove the nginx default enabled site

sudo rm /etc/nginx/sites-enabled/default

Enable the new opkg site

sudo ln -s /etc/nginx/sites-enabled/opkg-server/etc/nginx/sites-available/opkg-server

Restart the server

sudo /etc/init.d/nginx restart

You should now be able to surf into your localhost using a web-browser

Next step is to enable this on your device

ssh target
vi /etc/opkg/opkg.conf
src/gz all http://192.168.1.4/all
src/gz armv5te http://192.168.1.4/armv5te
src/gz armv7a-vfp-neon http://192.168.1.4/armv7a-vfp-neon
src/gz cortexa8-vfp-neon http://192.168.1.4/cortexa8-vfp-neon
src/gz cortexa8-vfp-neon-mx5 http://192.168.1.4/cortexa8-vfp-neon-mx5
src/gz x86_64-nativesdk http://192.168.1.4/x86_64-nativesdk

Where 192.168.1.4 is the IP-address of your host machine

Next update the package list

opkg update
Downloading http://169.254.1.4/all/Packages.gz.
Inflating http://169.254.1.4/all/Packages.gz.
Updated list of available packages in /var/lib/opkg/all.
Downloading http://169.254.1.4/armv5te/Packages.gz.
Inflating http://169.254.1.4/armv5te/Packages.gz.
Updated list of available packages in /var/lib/opkg/armv5te.
Downloading http://169.254.1.4/armv7a-vfp-neon/Packages.gz.
Inflating http://169.254.1.4/armv7a-vfp-neon/Packages.gz.
Updated list of available packages in /var/lib/opkg/armv7a-vfp-neon.
Downloading http://169.254.1.4/cortexa8-vfp-neon/Packages.gz.
Inflating http://169.254.1.4/cortexa8-vfp-neon/Packages.gz.
Updated list of available packages in /var/lib/opkg/cortexa8-vfp-neon.
Downloading http://169.254.1.4/cortexa8-vfp-neon-mx5/Packages.gz.
Inflating http://169.254.1.4/cortexa8-vfp-neon-mx5/Packages.gz.
Updated list of available packages in /var/lib/opkg/cortexa8-vfp-neon-mx5.
Downloading http://169.254.1.4/x86_64-nativesdk/Packages.gz.
Inflating http://169.254.1.4/x86_64-nativesdk/Packages.gz.
Updated list of available packages in /var/lib/opkg/x86_64-nativesdk.

And then your’e ready to update any package from your computer

opkg install mypackage
Posted in Yocto | Tagged , , | Leave a comment

Adding ssh password to raspberry pi

  1. Create ssh-key
    ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
  2. Add id_rsa.pub content to the raspberry pi .ssh/authorized_keys

    echo ~/.ssh/id_rsa.pub | ssh pi@192.168.1.5 "cat >> .ssh/authorized_keys
  3. Add new login part in your .ssh/config file
    vi .ssh/config
    Host pi
     Hostname 192.168.1.5
     User pi
     IdentityFile ~/.ssh/id_rsa

     

Posted in Yocto | Tagged , , | Leave a comment

Gerrit workflow using git-repo

This is the workflow I use when working with gerrit and git-repo

  1. Create a git-repo branch
    cd ~/myrepo
    repo start mybranch myproject
  2. Make changes and commit
    vim myclass.cpp
    git add myclass.cpp
    git commit -s
  3. Push to gerrit to master branch using your branch name as topic
    repo upload -D master -t
Posted in Yocto | Tagged , , | Leave a comment