EmbLogic's Blog

tool chain compilation command

Toolchains have a loose name convention like arch[-vendor][-os]-abi.

  • arch is for architecture: arm, mips, x86, i686
  • vendor is tool chain supplier: apple,
  • os is for operating system: linux, none (bare metal)
  • abi is for application binary interface convention: eabi, gnueabi, gnueabihf
Posted in Uncategorized | Leave a comment

merge sort

/*Merge sort is a divide and conquer sorting technique in which we divide big problems into small i.e. in this we divide a big array into small arrays and after sorting these arrays we merge it and after merging it we get a sorted array.
At the time of doing this sorting technique i find some of the problems like garbage values and also segmentation faults so i tried to do this technique with a small array than after sometime i get my result*/
#include
void mergesort(int *,int ,int );
void merge(int *,int,int,int);
#define max 50
int main()
{
int merge[max],n,i,p=0;
printf(“enter no. of elements that you want to sort\n”);
scanf(“%d”,&n);
printf(“enter the elemrnts of array\n”);
for(i=0;i<n;i++)
scanf("%d",&merge[i]);
mergesort(merge, p, n-1);
printf("\n");
for(i=0;i<n;i++)
{
printf("a[%d]=%d\n",i,merge[i]);
}
return 0;
}
void mergesort(int* a,int p,int r)
{
int q;
if(p<r)
{
q=(p+r)/2;
mergesort(a,p,q);
mergesort(a,q+1,r);
merge(a,p,q,r);
}
}
void merge(int* a,int p,int q,int r)
{
int i=p,l=p,m=q+1,temp[max],k;
while(l<=q&&ma[m])
{
temp[i]=a[m];
m++;
}
else
{
temp[i]=a[l];
l++;
}
i++;
}
if(l>q)
{
for(i=i;iq temp[%d]=%d,a[%d]=%d\n”,i,temp[i],m,a[m]);
}
}
else
{
for(i=i;ir temp[%d]=%d,a[%d]=%d\n”,i,temp[i],l,a[l]);
}
}
for(i=p;i<=r;i++)
{
a[i]=temp[i];
printf("temp[%d]=%d,a[%d]=%d\n",i,temp[i],i,a[i]);
}
}

Posted in Uncategorized | Leave a comment

Compile kernel& module compile . Then Put Debian & kernel module in 2nd partition

make ARCH=arm  CROSS_COMPILE=arm-linux-gnueabihf- uImage

make ARCH=arm  CROSS_COMPILE=arm-linux-gnueabihf- Image
make ARCH=arm  CROSS_COMPILE=arm-linux-gnueabihf- zImage

make ARCH=arm  CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=out modules

OBJCOPY arch/arm/boot/Image

Kernel: arch/arm/boot/Image is ready

AS arch/arm/boot/compressed/head.o

GZIP arch/arm/boot/compressed/piggy.gzip

AS arch/arm/boot/compressed/piggy.gzip.o

CC arch/arm/boot/compressed/misc.o

CC arch/arm/boot/compressed/decompress.o

CC arch/arm/boot/compressed/string.o

SHIPPED arch/arm/boot/compressed/lib1funcs.S

AS arch/arm/boot/compressed/lib1funcs.o

SHIPPED arch/arm/boot/compressed/ashldi3.S

AS arch/arm/boot/compressed/ashldi3.o

LD arch/arm/boot/compressed/vmlinux

OBJCOPY arch/arm/boot/zImage

Kernel: arch/arm/boot/zImage is ready

UIMAGE arch/arm/boot/uImage

“mkimage” command not found – U-Boot images will not be built

make[1]: *** [arch/arm/boot/uImage] Error 1

make: *** [uImage] Error 2

gunzip -c /home/emb/diga/Control-project/Project/project-olinuxino/mele_debian_armhf_minimal.cpio.gz | cpio -i

Posted in ARM Embedded Processors | Leave a comment

sdcard image for ARM

CREATING THE PARTITION IN THE MICROSD CARD :

1. The process of partition the microsd card .

1.1 detecting as block device / dev/mmcblk0p1

1.2 fdisk /dev/mmcblk0p1

n

p

1

2048 ( second stage bootlader write have to from 8 block 8 kbyte)

34815

n

p

2

34816

enter

enter

w

when we write “w” to comit the partition table . It is giving following errors .

//********************************************************************

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 22: Invalid argument.

The kernel still uses the old table. The new table will be used at

the next reboot or after you run partprobe(8) or kpartx(8)

Syncing disks.

//****************************************************************

then i type partprobe

then

sync

all the partit ion was successfully commit in the microSDcard

Device Boot Start End Blocks Id System

/dev/mmcblk0p1p1 2048 34815 16384 83 Linux

/dev/mmcblk0p1p2 34816 15515647 7740416 83 Linux

Posted in ARM Embedded Processors | Leave a comment

creating cross compiler

1. Download the Cross compiler compatible with 32-bit system

following are the files in the folder  ” arm-linux-gnueabihf bin lib libexec share”

2. follow the procedure as per documents –> then also the error is coming after running the following command

make ARCH=arm CROSS_COMPILE=arm-unknown-linux-gnueabi-distclean

error -1:

2.1 arm-unknown-linux-guneabi is not a command

so i got it right as in 32-bit cross compiler the file this command was acessing is

arm-linux-gnueabihf ,

error -2

still command not found

so i got it right after see the document again ,

the command is

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-  distclean

there is space b/w guneabihf- and distclean.

after all above issue resolved the command run successfully .

 

 

Posted in ARM Embedded Processors | Leave a comment

ls – list command

ls – list command
=================
- ls means list directory content
- Prototype :
ls [OPTION] … [FILE] …
- Exit status
It returns 0 ,on success
Returns 1 in case of minor problems (eg. cannot access subdirectory)
returns 2 in case of serious trouble (eg. Cannot access command line argument)
- For specific listing you can use *
eg.1) For listing all files starting with a use :
ls a*
2) for listing all .c files use :
ls *.c
3) for listing all .c files starting with a use :
ls a*.c
- Some common options are :
i) -a –all –> Do not ignore enteries starting with .
Use this to view swap or temporary files.
ii) -l –> long listing format
iii) -r –) Reverse order sort (by name) and list
iv) -s –size –> Print allocated size of each file in blocks
v) -S –> Sort by file size
vi) -t –> Sort by modification time, newest first
vii) -U –> Do not sort; list enteries in directory order
viii) -X –> Sort alphabetically by entry extension.
ix) -F –> to distinguish files from directories (Puts / in directory and * with executable files)
x) -R –> It shows files that are contained in directory. It continued to dirrectory in a directory and so on.

- In fedora for long lsting use command :

ll

 

Posted in Shell Scripts | Tagged , , , , , , , , , , , | Leave a comment

CD – Change Directory Command

CD – Change Directory Command
=============================
- cd means change working directory
- Prototype:
cd [-L | -P] [directory]
cd -
-If you do not give any directory to cd command, it will take you to home directory.
eg. cd –> It will go to home directory.
- For previous directory use :
cd ..
- Further for more than one previous directory use :
cd ../..
- Directory can be defined by 2 types :
i) Absolute filepath – Path starting from ‘/’.
eg. cd /usr/bin/
ii)Relative Filepath – Path relative to current directory
eg. cd /usr –> Absolute filepath
cd etc –> Relative Filepath

Posted in Shell Scripts | Tagged , , , , , , | Leave a comment

Common linux virtual directories

Common Linux Virtual Directories
=================================
Directory               Usage
/ Root                     of virtual directory. No files are placed here (normally)
/bin                         Binary directory.GNU user level utilities are stored
/boot                       Boot directory.Boot files are stored here
/dev                         device directory, where linux creates device nodes
/etc                          system configuration files directory
/home                      home directory, user directories are placed here
/lib                          System & application library files are stored here
/media                   Common place for mount point of removable media
/mnt                        mount directory, for removable devices
/opt                         used to store optional software packages
/root                       home directory of root user
/sbin                      GNU admin level utilities are store here
/tmp                       Temporary work files are created and destroyed
/usr                        User installed softwares directory
/var                         For frequently changing directory ,such as log files

Posted in Shell Scripts | Tagged , , , , , , , , | Leave a comment

Linux Filesystem

Linux Filesystem
================
- In windows, physical drive determines the pathname of the file.
- Windows assigns a letter to each disk drive.
- Each directory contains its own directory structure for accesing files stored in it.
- For eg. in windows filepath is as:
c:\Users\ankur\Documents\Lessons.doc

- Linux does not use drive letters in pathnames like windows.
- Linux stores files within a single directory structure, called a virtual directory.
- Virtual directory contains filepaths from all storage devices installed on PC, mergedinto a single directory.
- There is a single base directory, called the root.
- root drive contains core of virtual directory.
- On root drive, Linux has special directories called mount points.
-When we start a new shell prompt, your session starts in your home directory.

Posted in Shell Scripts | Tagged , , , , | Leave a comment

How to get help in Linux – Fedora

To get help in fedora
=====================
To learn about any new command, function or utility in Fedora we can get help from it.
It has 3 such commands :-

i) man pages – These are manual pages .
- It contains interface to online reference manuals
- Press q to exit.
- How to Use ( Command ) – man command_name
- for all man pages of BASH shell, use
man bash
- It generally contains following information about command(command_name) :-
* Name
* Synopsis (Prototype)
* Description (Options)
* Author (author of command)
* Reporting Bugs (Feedback emails/Website)
* Copyright (copyright details)
* See Also (for further reference of command)

ii) Info pages – Read info documents
- It contains BASH manuals.
- Press q to exit
- How to Use (command) – info command_name
- It contains information about :-
* Prototype
* Introduction
* Options
* Exit Status
iii) help command
- It gives basic help for using a command and its various options.
- It gives output on Standard Output.
- It do not require exit command.
- How to Use (command) – help command_name
- It contains following information about command (command_name) :-
* Function of command
* Options
* Exit status

eg.
man echo
info echo
help echo

- To check total no. of enteries in each of three
I) type either of three (with space at end)
II) Press tab button for 3-4 times.
We will get the total number of possible options defined or list of them also.
eg. (<tab> means Press tab button)
man <tab><tab><tab>

Posted in Shell Scripts | Tagged , , , , , , , , | Leave a comment

SWAP THE THREE VALUES WITHOUT USING FOURTH VARIABLE

#include<stdio.h>

int main()
{
int a=5;
int b=6;
int c=7;

a^=b,b^=a,a^=b;
b^=c,c^=b,b^=c;

printf(“a= %d\n”,a);
printf(“b= %d\n”,b);
printf(“c= %d\n”,c);

return 0;
}

Posted in Uncategorized | Leave a comment

SEVER SINGLE CLIENT FIFO AND PIPES WITH USE THE SHELL SCRIPT

RCS file: header.h,v
Working file: header.h
head: 1.1
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;     selected revisions: 1
description:
In file include a all header files realted this project.
—————————-
revision 1.1
date: 2016/02/04 11:32:41;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: request.h,v
Working file: request.h
head: 1.3
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 3;     selected revisions: 3
description:
In file delacare a structure name is struct opreations and decalre a in member variable .
—————————-
revision 1.3
date: 2016/02/04 20:20:28;  author: root;  state: Exp;  lines: +0 -1
In file decalre result varable.
—————————-
revision 1.2
date: 2016/02/04 20:19:24;  author: root;  state: Exp;  lines: +1 -0
*** empty log message ***
—————————-
revision 1.1
date: 2016/02/04 11:33:11;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: processing_client.c,v
Working file: processing_client.c
head: 1.8
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 8;     selected revisions: 8
description:
In file a getv the all structure data read the all structure using pipe and then found the result give the sever call to to the write.
—————————-
revision 1.8
date: 2016/02/07 11:01:05;  author: root;  state: Exp;  lines: +2 -0
In file removes the all sleeps.
—————————-
revision 1.7
date: 2016/02/04 19:16:31;  author: root;  state: Exp;  lines: +1 -1
In file display a operator.
—————————-
revision 1.6
date: 2016/02/04 19:14:40;  author: root;  state: Exp;  lines: +1 -1
In file some changing.
—————————-
revision 1.5
date: 2016/02/04 19:12:48;  author: root;  state: Exp;  lines: +4 -1
In file get a display structure in member variable.
—————————-
revision 1.4
date: 2016/02/04 19:07:15;  author: root;  state: Exp;  lines: +1 -0
In file calling sleep in 2 sec.
—————————-
revision 1.3
date: 2016/02/04 19:05:20;  author: root;  state: Exp;  lines: +1 -1
In file now write a result.
—————————-
revision 1.2
date: 2016/02/04 18:50:16;  author: root;  state: Exp;  lines: +1 -0
In file wfd,rfd and result are variables declare.
—————————-
revision 1.1
date: 2016/02/04 13:33:06;  author: root;  state: Exp;
Initial revision
=============================================================================
RCS file: request_client.c,v
Working file: request_client.c
head: 1.8
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 8;     selected revisions: 8
description:
In file declare a struct operations type a variable and all sturcture members in values all assign .
then call to the open and file open the all structure write a in fifo then call to the sleep in 5 sec.
—————————-
revision 1.8
date: 2016/02/07 11:01:44;  author: root;  state: Exp;  lines: +1 -1
In file check the this file write the data or not.
—————————-
revision 1.7
date: 2016/02/04 20:20:54;  author: root;  state: Exp;  lines: +1 -1
In file declare a result varibale and display the result .
—————————-
revision 1.6
date: 2016/02/04 20:19:26;  author: root;  state: Exp;  lines: +7 -9
*** empty log message ***
—————————-
revision 1.5
date: 2016/02/04 20:02:32;  author: root;  state: Exp;  lines: +20 -2
In file get a result of the server and display the result and add a if else condition in a file.
—————————-
revision 1.4
date: 2016/02/04 12:05:34;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.3
date: 2016/02/04 11:49:47;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.2
date: 2016/02/04 11:48:32;  author: root;  state: Exp;  lines: +14 -1
In file add a some checking condtions.
—————————-
revision 1.1
date: 2016/02/04 11:34:07;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: server.c,v
Working file: server.c
head: 1.11
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 11;    selected revisions: 11
description:
In file a first one declare a struct operations type a variable then calling to the system call is access and in condtions the fifo file in already avialable or not check the access then if not available the fifo file then call to mkfifo the n create fifo file and then call the open if open file is successfully then call to the read and read the structure in a fifo then all the structure is display in which some condions.
—————————-
revision 1.11
date: 2016/02/07 11:02:37;  author: root;  state: Exp;  lines: +1 -3
In file removes the all sleep.
/.
—————————-
revision 1.10
date: 2016/02/04 20:05:33;  author: root;  state: Exp;  lines: +15 -0
In file get a result to proceesing client and then in sleep 3 sec then give the result of the request client .
—————————-
revision 1.9
date: 2016/02/04 19:16:56;  author: root;  state: Exp;  lines: +1 -1
In file read a result .
—————————-
revision 1.8
date: 2016/02/04 18:55:15;  author: root;  state: Exp;  lines: +3 -3
In file check the working .
—————————-
revision 1.7
date: 2016/02/04 18:51:20;  author: root;  state: Exp;  lines: +2 -0
In file get result to processing client and display a result in file.
—————————-
revision 1.6
date: 2016/02/04 13:34:28;  author: root;  state: Exp;  lines: +25 -5
In file call a first call to the pipe and create a pipe then call to fork and then add a switch statements then execl call and and write a data give the all structure to processing client and then get a result of the processing client .
—————————-
revision 1.5
date: 2016/02/04 12:05:36;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.4
date: 2016/02/04 11:53:18;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.3
date: 2016/02/04 11:52:22;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.2
date: 2016/02/04 11:43:54;  author: root;  state: Exp;  lines: +2 -0
*** empty log message ***
—————————-
revision 1.1
date: 2016/02/04 11:36:18;  author: root;  state: Exp;
Initial revision
=============================================================================
SHELL SCRIPT

#! /bin/bash

delete()
{
rm -rf  server
rm -rf  request_client
}

edit()
{
read -p “do you want a edit further (y or n)” answer

if [ 'y' = $answer ]
then

for file in $(ls *.h,v)
do
co -l $file
done

for file in $(ls *.c,v)
do
co -l $file
done
delete
exit 0
fi
}

execute()
{
read -p “do you want a execute script(y or n)” answer

if [ 'y' = $answer ]
then
if (gcc -o server server.c)
then
echo “compailation successfully”
else
echo “compailation is failed”
edit
fi

if (gcc -o request_client request_client.c)
then
echo “compailation successfully”
else
echo “compailation is failed”
edit
fi
if (gcc -o processing_client processing_client.c)
then
echo “compailation successfully”
else
echo “compailation is failed”
edit
fi

else
edit
fi
./server & ./request_client
}

logfile()
{
chmod +x rlog.sh
./rlog.sh
edit
}

for file in $(ls *.h)
do
ci $file
done

for file in $(ls *.c)
do
ci $file
done

for file in $(ls *.h,v)
do
co $file
done

for file in $(ls *.c,v)
do
co $file
done
execute
read
logfile

 

 

 

Posted in Project 03: Client Server Communication using Linux and IPC | Leave a comment

How to change default prompt in BASH shell

To change default prompt :-
========================
- We can change default prompt by assigning the character to it.
- Each character have a specific meaning.

BASH Shell Prompt Characters :-
Character Description
\a Bell Character
\d Date in format “Day Month Date”
\e ASCII escape character
\h Local hostname
\H Fully qualified domain hostname
\j Number of jobs currently managed by the shell
\l Basename of the shell’s terminal device name
\n ASCII newline character
\r ASCII carriage return
\s Name of the shell
\t Current time in 24-hour HH:MM:SS format
\T Current time in 12-hour HH:MM:SS format
\@ Current time in 12-hour am/pm format
\u Username of current user
\v Version of BASH shell
\V Release level of bash shell
\w Current working directory
\W Basename of current working directory
\# Command number of this command
\$ A dollar sign if normal user, #(Pound) for root user
/nnn Character corresponding to value nnn
\\ Backslash
\[ Begins a control code sequence
/] Ends a control code sequence

eg.
[ankur@(none) ~]$ PS1 = “[\t][\u]$”
[15:20:30][ankur]$

Posted in Shell Scripts | Tagged , , , , , , , , | Leave a comment

Command line Prompt – PS1, PS2

Command line Prompt
===================
Environmental variables that controls Command line Prompt
PS1 : Controls the format of default command line prompt.
PS2 : Controls the format of second-tier command line prompt.
PS3 : Controls the format of tertiary command line prompt.

- Shell uses default PS1 prompt for initial data entry into shell.
- If we enter a command that requires additional information, shell displays second-tier prompt specified by PS2 .
- To display current settings for prompt use command :
echo $PS1
echo $PS2
- PS3 is used only in shell scripts.

Posted in Shell Scripts | Tagged , , , , , , , , | Leave a comment

Project03: Linux System Programming & Client Server Communication

RCS file: fork.c,v
Working file: fork.c
head: 1.1
branch:
locks: strict
reena: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
process duplication for project 03: Inter Process Communication
using fork()
—————————-
revision 1.1 locked by: reena;
date: 2016/02/07 12:58:41; author: reena; state: Exp;
Initial revision
=============================================================================

Posted in Project 03: Client Server Communication using Linux and IPC | Leave a comment