linux kernel – error

linux kernel – error # couldn’t mount as ext3 due to feature incompatibilities

– Use menuconfig to enable options in FileSystem to match filesystem of your storage device where rootfs is placed

linux kernel – error

Llinux kernel error # couldn’t mount as ext3 due to feature incompatibilities

– Use menuconfig to enable options in FileSystem to match filesystem of your storage device where rootfs is placed

enum as bitfield

By default enum can't be as bitfield
typedef enum _type_ {
CAT = 0,
DOG,
UNKNOWN
} TYPE;
typedef struct _animal {
TYPE type : 2;
};
GCC ((Sourcery CodeBench 2015.17-10) 5.2.0) will show error "width of 'type' exceeds its type"
Use -fno-short-enums to get rid of this. Details: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0774b/chr1411640303038.html

view raw
enum as bitfield
hosted with ❤ by GitHub

python debug

To print line number in python script for debugging purposes, use following line of codes to print file name, and line number to see what is going on inside the python script:

from inspect import currentframe, getframeinfo
frameinfo = getframeinfo(currentframe())
print "[Debug]", frameinfo.filename, frameinfo.lineno

Thread Module in c++11

C++11 supports Thread library (http://en.cppreference.com/w/cpp/thread). If you are using it in your application you have to pass -pthread to g++ linker to inform it which sort of backend should be used for linking Thread library. If -pthread is not passed your application will end up with following execution error:

terminate called after throwing an instance of 'std::system_error'
 what(): Enable multithreading to use std::thread: Operation not permitted
Aborted (core dumped)

 

Linux Device Tree Compiler (DTC)

It has been a common practice to keep a device tree of a platform scattered across multiple DTS files. Seeing all of these DTS files as a single device tree is a nightmare.

Currently everyone is using DTC compiler to convert DTS file(s) into DTB file and then use it again to convert DTB into DTS file. The problem with this approach is that DTC compiler will convert alias/device name (string) into integer (phandle). This transformation makes final DTS file less readable.

To solve this problem, I have added a new option is added in forked DTC compiler. This new option (-m or –merge) allows to generate DTS very similar to DTB but keeps device
names/aliases in their original format.

There is an another option (-g or –ignore-dead) which will be useful alongwith –merge option. This option allows DTC compiler to ignore dead aliases otherwise it will generate an error on finding dead alias.

Here is the comparison of the DTB converted into DTS using mainline and forked DTC.

dtc1

dtc2

 

 

Handy commands to convert DTB into DTS using mainline and forked DTC.

# To convert dts file into dtb
<kernel-source>/scripts/dtc/dtc -I dts -O dtb <dts_file> -o <dtb_file>
# To convert dtb to dts
<kernel-source>/scripts/dtc/dtc -I dtb -O dts <dtb_file> -o <dts_file>
# Both of above commands are using dtc built with linux kernel source.
# However you can also use dtc binary comes with ubuntu packages. For this you
# need to install following package:
sudo apt-get install -y device-tree-compiler
# Ubuntu device-tree-compiler package comes with another utility known as fdtdump.
# fdtdump can also be used to convert dtb file into dts.
fdtdump <dtb_file> > <dts_dump>

view raw
dts <> dtb
hosted with ❤ by GitHub

# !/bin/bash
#
# This script uses forked dtc to generate flat device tree.
#
# Change these path as per your machine
COMPILER='arm-linux-gnueabihf-gcc'
KERNEL_FOLDER='/your/linux/source/code'
DTS_FILE_NAME='dra7-evm.dts'
FORKED_DTC='/forked/dtc/executable'
# Setup useful env
DTS_FOLDER=$KERNEL_FOLDER/arch/arm/boot/dts
DTS_INCLUDE=$DTS_FOLDER/include
KERNEL_INCLUDE=$KERNEL_FOLDER/include
DTS_FILE=$KERNEL_FOLDER/arch/arm/boot/dts/$DTS_FILE_NAME
echo "Generate flat dts file…(an intermediate file)"
$COMPILER -E -nostdinc -undef -D__DTS__ -x assembler-with-cpp -I$DTS_FOLDER -I$DTS_INCLUDE -o $DTS_FILE_NAME.flat $DTS_FILE
echo "Generate merge dts file…($DTS_FILE_NAME.merge)"
$FORKED_DTC/dtc -i$DTS_FOLDER -i$DTS_INCLUDE -I dts -O dts -m -g $DTS_FILE_NAME.flat -o $DTS_FILE_NAME.merge

view raw
dts <> dtb (forked)
hosted with ❤ by GitHub