Friday, December 2, 2016

QEMU : Installing Debian on Qemu emulated MIPS - Linux(x86) host

Hello People,

So, Here I needed to test some drivers functionality with 16K page size specifically. After walking through my options I settled with Linux on Qemu emulated MIPS. QEMU is a generic and open source machine emulator.



Here are the steps to install Debian on emulated MIPS machine using Qemu:


Preparation:
Here I am using Ubuntu 14.04 x86 system as my host machine.

1 . Installing Qemu on host system - install qemu package,

apt-get install qemu

2. Need to download a debian-installer kernel (vmlinux-3.16.0-4-4kc-malta) and initrd (initrd.gz) to boot from.

Setting up the MIPS system:

1. First need to create a virtual disk to install Debian on,

qemu-img create -f qcow2 debian_mips.qcow2 10G

This will create virtual disk of 10G size.

2. Next, install Debian to this virtual disk
qemu-system-mips -hda debian_mips.qcow2 -kernel vmlinux-3.16.0-4-4kc-malta -initrd initrd.gz -append "console=ttyS0" -nographic

Then follow shown on terminal as of normal Debian installation to the end.
This will take quite a while (so better get that fresh cup of coffee) as it will download all packages needed for installation.

boot:
After installations, next step is to boot into the system we just installed.

qemu-system-mips -hda debian_mips.qcow2 -kernel vmlinux-3.16.0-4-4kc-malta -append "root=/dev/sda1 console=ttyS0" -nographic

VoilĂ , you will be booted into MIPS system with Debian Linux!!
Rest is just usual Debian/Linux.


Accessing Host: 
Next thing that any developer will need is access to the Host system for exchanging all sort of stuff....driver, applicatin, source code etc.

You can SSH into the Host as bellow or just do SCP.
ssh host_user@10.0.2.2

Referances:
Networking: http://wiki.qemu.org/Documentation/Networking
Qemu: http://wiki.qemu.org/Main_Page

Cheers!!

Friday, September 23, 2016

Android CTS 7.0_r1 : Running modules list through automated script

Hello Guys,
How are you doing? hope all is well. Its been while, lets get started!

So whats new? Yeah Android 7 is new! Android 7 has been out now for a while and everybody (device vendors) wants it up and running as soon as possible. So here I am trying to get Android 7 up for some super secrete project, just kidding, yes I (and my team) had just completed bring up of the device with Android N (i.e. Android 7, called Nougat) yeeeh! but that's just the half battle, still need to run Android Compatibility Test Suite (CTS) to win the rest.



So, here is the issue, The device I have has some serious battery problem, it cant charge through USB if its connected to computer, it needs to be connect to charger to do so. So every time I kick CTS plan device goes down before it completes. The solution is instead of running whole plan run module by module and get result but its heck lot of manual work and I have to keep eye on it. Also in CTS 7 google has changed structure a bit lot.

So here I am going to give you scripts which helps you run CTS modules one-by-one and also saves results location in log file. So if device goes down while running some module you can continue from where you left. You just need to follow some steps as bellow:


1. Download CTS 7  

You can download CTS package from : CTS download   and extract it.

 

2. Get list of modules

After extracting CTS package go to android-cts/tools directory and execute following command to get available modules list,
Then copy list of modules to a file e.g. modules.lst or you can get it here 

3. Script to run modules one-by-one from the list

Now what you need is a script that runs modules from above list one-by-one, here it is, 

Running the CTS modules using script,

If device dies while running some module using the script, you can press 'ctrl+c' to stop script in between and remove modules from 'modules.lst' file which ran to completion successfully, then run the script again as before to continue from where you left.

4. Collecting logs of CTS

Result of each module ran using above script can be found in android-cts/results/ directory in separate sub-directories with sub-directory name as time-stamp when respective module has started. Above script collects all modules time-stamp in log file, modules.lst.log, which you can use latter to correlate time-stamps recorded to find each modules result/log directory. See snap-shot bellow,

That's it guys, have a nice day!!
Cheers!!!

Tuesday, July 26, 2016

Ubuntu 14.04 : How to install 4.4.8 Kernel

Hello,

Here are some simple steps to install Kernel 4.4.8 on your Ubuntu machine.
Open terminal and execute following commands in given order.

32bit Ubutnu:

Lets download the packages needed for installation.

Now, install downloaded packages: it will take a while, just sit back and relax

64bit Ubuntu:

Same way as earlier, lets download required packages first,
Installing downloaded packages: same as that of 32bit

We are done! Just reboot system and you should see newer Kernel installed on your system.
Cheers!!

Thursday, March 31, 2016

issue "/usr/include/linux/errno.h:1:23: fatal error: asm/errno.h: No such file or directory" while cross-compiling

Aloha,

So, making this post as it did cost me more than couple of hours to figure-out what the hell is happening.

I was building some (secrete) driver for android yesterday and I needed to install cross-compile tool-chain  for same, but while installing tool-chain on Ubuntu some of the packages already installed got removed by package installer.

Next, I set up the environment for building driver and kicked the build. Suddenly I started getting following error from compiler:


I did not noticed that some package has been forcefully removed while installing tool-chain. After some Googl'ing I found the package that needs to be installed.

Just install following package and issue will disappear :)

$sudo apt-get install linux-libc-dev:i386

cheers!!

Tuesday, July 21, 2015

Tmuxing with Tmuxinator

Ooolo,

So, Here is what’s happened, I was doing some testing with driver for #top_secrete project. So each time to test my driver, I have to go through following steps,

- ssh to target platform (tab0), run vim to edit code
- ssh to target platform (tab1), cd to source dir
- source environment
- build/install
- ssh to target (tab2), cd to log dir and start ldmesg script to continuously monitor dmesg logs
- ssh to target (tab3), cd to test dir and start test (server)
- ssh to target (tab3), cd to test dir and start test (client).


aahh, lots of steps and if driver crashes during testing (and that's what happens most of the times), I have to repeat this whole process again. Above described (steps) stuff is mostly unproductive. So how to avoid it??

So here comes tmux,

Tmux (terminal multiplexer) allows you to switch between multiple programs in single terminal. Its similar to screen.

Getting started resources for tmux :
-Part1
-Part2

So if I login in to target system over SSH in one terminal and start tmux, I can create multiple tabs inside single terminal using tmux to run multiple programs. This solves partial problem i.e. multiple SSH logins, but sill I have to do lots of stuff manually after creating multiple tabs using tmux. I needed further automation in the process...

After doing some googling I came across tool called tmuxinator.
It does exactly what's needed. Tmuxinator is awesome tool that allows you to configure tmux session i.e. how many TTYs (tabs) to start with, executing some commands on start, splitting window, base/root directory for each tabs can be configured separately, cool right!

Getting started resources for tmuxinator:
-Basics

So tmuxinator automates most of the steps above, it launches tmux, creates multiple tabs, source env, changes dir to specific directory and additionally we can maintain multiple project settings/profiles much easily and what it needs is simple configuration file.

Cheers!
(will update more soon!)

Tuesday, May 19, 2015

How to increase vmalloc size [vmalloc: allocation failure]

Hello,

So this is what happened, I was working on the graphics driver and testing some GLBenchmark applications to see if everything is smooth and healthy. But one of the test was always failing for unknown reason (at that time). I have put more than couple of hours to debug that. I was ignoring some errors in dmesg (kernel log) that I was getting,

May 18 14:53:38 pc-vbox kernel: [412318.373157] vmap allocation for size 37752832 failed: use vmalloc=<size> to increase size.
May 18 14:53:38 pc-vbox kernel: [412318.373161] vmalloc: allocation failure: 37748736 bytes
May 18 14:53:38 pc-vbox kernel: [412318.373163] GLBenchmark27_X: page allocation failure: order:0, mode:0xd2



Latter I found that application was quite a heavy and vmalloc is failing due to insufficient space. On x86_32 systems default vmalloc size is 128MB and can be override by vmalloc kernel boot option. vmalloc() allocates block of memory with continuous virtual addresses or pages  (no guarantee that pages are actually contiguous in physical RAM) . You can find current vmalloc size of your system as bellow,

$cat /proc/meminfo | grep -i vmalloc

VmallocTotal: 122880 kB
VmallocUsed: 28216 kB
VmallocChunk: 94156 kB


How to increase vmalloc space?
We have to modify the kernel boot options in grub in order to do that.
open /etc/default/grub and make following change,
This will increase total vmalloc space to 512MB, next you need to update the grub as follows,

$sudo update-grub

After this corresponding  change will be reflected in /boot/grub/grub.cfg file as bellow,


Then just reboot the system and that solved my problem. Its not the thumb rule to set vmalloc to 512M but just set to what solves your problem!

After reboot you can see vmalloc size increased,

$cat /proc/meminfo | grep -i vmalloc
VmallocTotal:     524288 kB
VmallocUsed:       64768 kB
VmallocChunk:     366544 kB


cheers



Wednesday, September 17, 2014

Capture and monitor dmesg continuously

Greetings folks!

If you are working on device drivers for Linux/Android we do rely on dmesg for almost all of the times. But you know the dmesg buffer is limited, its circular buffer. So what ever overflows the buffer is lost for good (?). We feel need to increase the buffer size but its not trivial task and also most of the times enough is just not enough!

Here are some simple scripts for Linux to log dmesg continuously and dump into file and at the same time you can monitor changes in dmesg!

Give exe permissions to script and run as bellow,
$sudo ./ldmesg.sh

Now, dmesg is getting continuously logged in dmesg.log file in current directory. Next script needs to be run in another terminal tab/window which will monitor changes in dmesg (actually dmesg.log).

Give exe permissions to script and run as bellow,
$./mdmesg.sh


Image bellow shows dmesg being monitored.

For Android developers, here is ldmesg modified to use it over adb,
 
-- Cheers!!