My Tech notes: April 2009
Subscribe

Unix Documentation

Free Online Unix Training Materials

Lists many links to free Unix training materials.

Pointers and Arrays Materials

Pointers and Arrays materials Explained for C beginners

C FAQ and General Questions C Interview Questions

Powered By

Free XML Skins for Blogger

Powered by Blogger

Thursday, April 23, 2009

The Linux Foundation Free Training Program at linuxfoundation

The Linux Foundation Training Program is:

* For the Community, by the Community. The Linux Foundation is
building the program with its Technical Advisory Board to ensure the
content, instructors and classes are the top quality available.
* Technically the most advanced. Since the Linux Foundation works
directly with community developers, it can cover features and advances
in Linux before commercial companies.
* Connected. The Linux Foundation has unfettered access to the
leading developers and companies in the Linux ecosystem and will use
these connections to best position attendees for success. For example,
attendees can attend the exclusive, invite-only Collaboration Summit
where they can forge connections beneficial to their career.
* Real World. The Linux Foundation training courses all have hands
on components and a highly rigorous curriculum of programming or
administration exercises. Graduates will be well equipped to master
Linux programming and system administration tasks

The Linux Foundation Training Program will span the enterprise server
and mobile and embedded markets, with courses being offered on the
following subjects:

* The latest filesystems
* Device driver development
* Kernel internals
* Advanced systems administration
* Kernel debugging
* Application development
* Power Management & Optimization

These courses will be provided in three core offerings:

* Training offered at the Linux Foundation Collaboration Summit
and LinuxCon allowing developers to attend advanced training as a part
of their conference experience.
* Courses held in cities throughout the U.S. and around the world
* Custom courses for corporations who need training to help
advance their developer core
For more information, please contact training (at) linuxfoundation dot org.
source http://events.linuxfoundation.org/training

Monday, April 20, 2009

Configure udhcpc for Setting IP netmask and Gateway

How to Configure udhcpc for Setting IP netmask and Gateway?
Tell udhcpc client to run on eht1 interface with -i option.
Also use -s option to tell udhcpc client to use script from specified path.
/sbin/udhcpc -i eth1 -p /var/run/dhcpClient-wifi.pid -s /usr/share/udhcpc-wifi/default.script &

default.script directs the udhcpc to executes one by one scripts from specified folder ie /usr/share/udhcpc-wifi/
else default folder location for udhcpc script is /usr/share/udhcpc/

For directing IP address to temp file obtained using udhcpc client or for DHCP, do little
modification in sample.bound file.
Here is Sample udhcpc renew script, which will update the ip address, netmask and gatway obtained
by boradcasting. The new values will be updataed in /var/dhcpfile.

#!/bin/sh
# Sample udhcpc renew script

RESOLV_CONF="/etc/resolv.conf"

[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
[ -n "$subnet" ] && NETMASK="netmask $subnet

echo $ip > /var/dhcpfile
echo $subnet >> /var/dhcpfile

/sbin/ifconfig $interface $ip $BROADCAST $NETMASK

if [ -n "$router" ]
then
echo "deleting routers"
while /sbin/route del default gw 0.0.0.0 dev $interface
do :
done

for i in $router
do
/sbin/route add default gw $i dev $interface
echo $i > /var/dhcp_gw_wifi
done
fi

Same file can be extended to work on multiple interfaces link eth0 eth1 using $interface

example

if [ "$interface" == "eth0" ];
then
echo $ip > /var/dhcpfile
echo $subnet >> /var/dhcpfile
else
echo $ip > /var/dhcpfile1
echo $subnet >> /var/dhcpfile1
fi

Wednesday, April 8, 2009

Use Of Bootloader In SoC Design Life Cycle

Use of bootloader, in SoC design.
SoC in simple terms is collection of required blocks, like USB, MAC, PCI, surrounded to the CPU (generally RISC CPU, ARM).
As a part of SoC development each hardware block is validated for its functionality.
Validation is done register level. Example if we want to test functionality provided by MAC block in our SoC, then these functionality are validated by writing test cases in bootloader (u-boot-1.1.6).
Bootloader will create an environment for the test cases. The test cases are added as commands for each block with different subtests for each block to touch the corner conditions.
To start with U-boot provides generic block test cases, like I2C and many more are getting added day by day.
Format of bootloader commands

int do_hello (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
printf("Hello World\n");
}


U_BOOT_CMD(
hello, 5, 0, do_hello,
" hello - Prints hello world\n",
" hello - Prints hello world\n"
" \n" \
);

this will register "hello" as command in bootloader commands list.
Using this structure To validate simple GPIO functionality we write GPIO related test cases, so as to test GPIO features like GPIO interrupt.

MAC Block Validation test cases could be
  1. Link Up/Down test
  2. a. Validates PHY interface.
  3. b. Validates link negotiated by PHY
  4. Link Interrupt test
  5. a. Validatess the Link interrupt
  6. Digital loop-back test in full duplex mode
  7. a. Validates data path in MAC controller in varous link speeds
  8. 10/100/1000Mbps
  9. b. Validates normal frames (60-1514)
  10. Analog Loop-back in full duplex mode
  11. a. Validates PHY interface
  12. b. Validates Data path in MAC as well as PHY
  13. External loop-back test
  14. a. Validates PHY interface
  15. b. Validates Data path in MAC as well as PHY
  16. Digital Loop-back test in half duplex mode
  17. a. Validates data path in MAC controller
  18. DMA interrupt test
  19. a. Validates th MAC interrupts
  20. Incremental test
  21. a. Validates Data pathin MAC controller for varrying packet length
  22. External Incremental test
  23. a. Validates Data path in MAC controller and PHY for varrying packet length
  24. Promiscuous and MIB
  25. a. Validates Promiscous and Normal mode
  26. b. Validates the statistic count registers
  27. Pause Frame test
  28. a. Validates Pause frame Transmit and recieve
  29. b. Validates the statistic count registers
  30. Multicast frame test
  31. a. Validates the Hash table entry for Multicast filter
  32. b. Validates drop and pass of a Multicast Frame
  33. c. Validates the statistic count registers

Friday, April 3, 2009

UDP Traffic Generator Client Side C code

Learning Networking basics using C programs, to start with here is simple UDP client side code,
Why to start with UDP because its simple, no need of connection handshake like TCP.
This code sends continues UDP traffic over network, depending on the payload (ie send_buf) and delay between each transfer, rate at which data is pumped over network is calculated. Example: this client program is sending constant length 0f 1400 (in sendto function), so if you keep delay as 1s then data transfer rate will be 1400 per sec, decrease the delay to pump traffic at high rate.
You need UDP server side code for running this client.
udp client

#include
#include
#include
#include
#include
#include
#include
#include /* memset() */
#include /* select() */

#define REMOTE_SERVER_PORT 1500
#define MAX_MSG 1600


int main() {

int sd, rc, i;
struct sockaddr_in cliAddr, remoteServAddr;
struct hostent *h;
char *send_buf;
unsigned int count=0;
int reply;

send_buf= (char *) malloc(1600);
*((unsigned int *)send_buf) = count;

strcpy((send_buf+4),"hello how r u !!!!");
remoteServAddr.sin_family = AF_INET;
remoteServAddr.sin_addr.s_addr= inet_addr("1.168.3.100"); //using fixed IP for simplicity
remoteServAddr.sin_port = htons(REMOTE_SERVER_PORT);

/* socket creation */
sd = socket(AF_INET,SOCK_DGRAM,0);
if(sd<0)>
printf("cannot open socket \n");
exit(-1);
}

/* send data */
while(1){

*((unsigned int *)send_buf) = ++count;

rc = sendto(sd, send_buf, 1400, 0,(struct sockaddr *) &remoteServAddr,
sizeof(remoteServAddr));
usleep(10000);

if(rc<0)>
printf("cannot send data %d \n");
close(sd);
exit(-1);
}
}
}

Thursday, April 2, 2009

UDP Traffic Generator Server Side C code

Learning Networking basics using C programs, to start with here is simple UDP server side code,
Why to start with UDP because its simple, no need of connection handshake like TCP.

udp server

#include <sys/types.h>;
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <stdio.h>
#include <unistd.h>/* close() */
#include <string.h> /* memset() */

#define LOCAL_SERVER_PORT 1500
#define MAX_MSG 1500

int main() {

int sd, rc, n, cliLen;
struct sockaddr_in cliAddr, servAddr;
char msg[MAX_MSG];
int count;
int prev_count=0;
/* socket creation */
sd=socket(AF_INET, SOCK_DGRAM, 0); //create unix socket
if(sd<0)>
printf("cannot open socket \n");
exit(-1);
}

/* bind local server port */
servAddr.sin_family = AF_INET;
servAddr.sin_addr.s_addr = inet_addr("1.168.3.100"); //using fixed IP for simplicity
servAddr.sin_port = htons(LOCAL_SERVER_PORT);
rc = bind (sd, (struct sockaddr *) &servAddr,sizeof(servAddr));
if(rc<0)>
printf("cannot bind port number %d \n", LOCAL_SERVER_PORT);
exit(-1);
}

printf("waiting for data on port UDP %u\n",
LOCAL_SERVER_PORT);

/* server infinite loop */
while(1) {

/* receive message */
cliLen = sizeof(cliAddr);
n = recvfrom(sd, msg, MAX_MSG, 0,
(struct sockaddr *) &cliAddr, &cliLen);

if(n<0)>
printf("cannot receive data \n");
continue;
}

/* print received message */
printf("from %s:UDP%u: count:%d message: %s\n",

}/* end of server infinite loop */

return 0;
}