[1] OReilly - Practical C++ Programming.chm By Steve Oualline Publisher : O'Reilly
Pub Date : December 2002 ISBN : 0-596-00419-2 Pages : 574 21.1 Derived Classes
DIFFERENCE OF KEYWORD 'PUBLIC','PRIVATE','PROTECTED'
----------------------------------------------------
So the three protection keywords are:
private
Access is limited to the class only.
protected
The class and any derived class that use the class as a base class can access the member.
public
Anyone can access the member.
Wednesday, December 29, 2010
Thursday, December 16, 2010
Monday, December 13, 2010
thread relevant function in Linux
CREATE THREADS
---------------------
int pthread_create(pthread_t *restrict thread,
const pthread_attr_t *restrict attr,
void *(*start_routine)(void*), void *restrict arg);
WAIT FOR THE FINISH OF THREAD
-------------------------------------
int pthread_join(pthread_t thread, void **value_ptr);
PROTECTION OF SHARED RESOURCE AMONG MULTIPLE THREADS
------------------------------------------------------
int pthread_mutex_lock(pthread_mutex_t *mutex);
int pthread_mutex_trylock(pthread_mutex_t *mutex);
int pthread_mutex_unlock(pthread_mutex_t *mutex);
If the mutex is already locked, the calling thread shall block
until the mutex becomes available.
THREAD SYNCH BY BLOCKING ON A CONDITION VARIABLE
--------------------------------------------------
int pthread_cond_timedwait(pthread_cond_t *restrict cond,
pthread_mutex_t *restrict mutex,
const struct timespec *restrict abstime);
int pthread_cond_wait(pthread_cond_t *restrict cond,
pthread_mutex_t *restrict mutex);
Condition Variables: pthreads support condition variables, which
allow one thread to wait (sleep) for an event generated by any other thread.
This allows us to avoid the busy waiting problem.
THREAD SYNCH BY UNBLOCKING THREAD BLOCKED ON A CONDITION VARIABLE
------------------------------------------------------------------
int pthread_cond_broadcast(pthread_cond_t *cond); unblock all
int pthread_cond_signal(pthread_cond_t *cond); unblock at least one thread
The thread(s) that are unblocked shall contend for the mutex according to the
scheduling policy (if applicable), and as if each had called pthread_mutex_lock().
THREAD ATTRIBUTES SETTING
-----------------------------
int pthread_attr_destroy(pthread_attr_t *attr);
int pthread_attr_init(pthread_attr_t *attr);
SET THREAD SCHEDULING POLICY
---------------------------------
int pthread_attr_getschedparam(const pthread_attr_t *restrict attr,
struct sched_param *restrict param);
int pthread_attr_setschedparam(pthread_attr_t *restrict attr,
const struct sched_param *restrict param);
int pthread_attr_getscope(const pthread_attr_t *restrict attr,
int *restrict contentionscope);
int pthread_attr_setscope(pthread_attr_t *attr, int contentionscope);
contentionscope -- PTHREAD_SCOPE_SYSTEM,PTHREAD_SCOPE_PROCESS
int pthread_attr_getschedpolicy(const pthread_attr_t *restrict attr,
int *restrict policy);
int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy);
policy -- SCHED_FIFO, SCHED_RR, SCHED_SPORADIC,and SCHED_OTHER
TERMINATE THREAD
----------------------
void pthread_exit(void *value_ptr);
If main() returns or any thread calls, exit()all threads are terminated
OTHER PASTRIES PTHREAD FUNCTIONS
-----------------------------------
int pthread_key_create(pthread_key_t *key, void (*destructor)(void*));
int pthread_once(pthread_once_t *once_control,
void (*init_routine)(void));
pthread_once_t once_control = PTHREAD_ONCE_INIT;
void *pthread_getspecific(pthread_key_t key);
int pthread_setspecific(pthread_key_t key, const void *value);
Be aware of a list of the Posix thread-safe functions
---------------------
int pthread_create(pthread_t *restrict thread,
const pthread_attr_t *restrict attr,
void *(*start_routine)(void*), void *restrict arg);
WAIT FOR THE FINISH OF THREAD
-------------------------------------
int pthread_join(pthread_t thread, void **value_ptr);
PROTECTION OF SHARED RESOURCE AMONG MULTIPLE THREADS
------------------------------------------------------
int pthread_mutex_lock(pthread_mutex_t *mutex);
int pthread_mutex_trylock(pthread_mutex_t *mutex);
int pthread_mutex_unlock(pthread_mutex_t *mutex);
If the mutex is already locked, the calling thread shall block
until the mutex becomes available.
THREAD SYNCH BY BLOCKING ON A CONDITION VARIABLE
--------------------------------------------------
int pthread_cond_timedwait(pthread_cond_t *restrict cond,
pthread_mutex_t *restrict mutex,
const struct timespec *restrict abstime);
int pthread_cond_wait(pthread_cond_t *restrict cond,
pthread_mutex_t *restrict mutex);
Condition Variables: pthreads support condition variables, which
allow one thread to wait (sleep) for an event generated by any other thread.
This allows us to avoid the busy waiting problem.
THREAD SYNCH BY UNBLOCKING THREAD BLOCKED ON A CONDITION VARIABLE
------------------------------------------------------------------
int pthread_cond_broadcast(pthread_cond_t *cond); unblock all
int pthread_cond_signal(pthread_cond_t *cond); unblock at least one thread
The thread(s) that are unblocked shall contend for the mutex according to the
scheduling policy (if applicable), and as if each had called pthread_mutex_lock().
THREAD ATTRIBUTES SETTING
-----------------------------
int pthread_attr_destroy(pthread_attr_t *attr);
int pthread_attr_init(pthread_attr_t *attr);
SET THREAD SCHEDULING POLICY
---------------------------------
int pthread_attr_getschedparam(const pthread_attr_t *restrict attr,
struct sched_param *restrict param);
int pthread_attr_setschedparam(pthread_attr_t *restrict attr,
const struct sched_param *restrict param);
int pthread_attr_getscope(const pthread_attr_t *restrict attr,
int *restrict contentionscope);
int pthread_attr_setscope(pthread_attr_t *attr, int contentionscope);
contentionscope -- PTHREAD_SCOPE_SYSTEM,PTHREAD_SCOPE_PROCESS
int pthread_attr_getschedpolicy(const pthread_attr_t *restrict attr,
int *restrict policy);
int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy);
policy -- SCHED_FIFO, SCHED_RR, SCHED_SPORADIC,and SCHED_OTHER
TERMINATE THREAD
----------------------
void pthread_exit(void *value_ptr);
If main() returns or any thread calls, exit()all threads are terminated
OTHER PASTRIES PTHREAD FUNCTIONS
-----------------------------------
int pthread_key_create(pthread_key_t *key, void (*destructor)(void*));
int pthread_once(pthread_once_t *once_control,
void (*init_routine)(void));
pthread_once_t once_control = PTHREAD_ONCE_INIT;
void *pthread_getspecific(pthread_key_t key);
int pthread_setspecific(pthread_key_t key, const void *value);
Be aware of a list of the Posix thread-safe functions
FW: 可重入函数
[1] http://blog.chinaunix.net/u2/68846/showart_689446.html
把一个不可重入函数变成可重入的唯一方法是用可重入规则来重写他。
其实很简单,只要遵守了几条很容易理解的规则,那么写出来的函数就是可重入的。
第一,不要使用全局变量。因为别的代码很可能覆盖这些变量值。
第二,在和硬件发生交互的时候,切记执行类似disinterrupt()之类的操作,就是关闭硬件中断。完成交互记得打开中断,在有些系列上,这叫做“进入/退出核心”或者用OS_ENTER_KERNAL/OS_EXIT_KERNAL来描述。
第三,不能调用任何不可重入的函数。
第四,谨慎使用堆栈。最好先在使用前先OS_ENTER_KERNAL。
还有一些规则,都是很好理解的,总之,时刻记住一句话:保证中断是安全的!
把一个不可重入函数变成可重入的唯一方法是用可重入规则来重写他。
其实很简单,只要遵守了几条很容易理解的规则,那么写出来的函数就是可重入的。
第一,不要使用全局变量。因为别的代码很可能覆盖这些变量值。
第二,在和硬件发生交互的时候,切记执行类似disinterrupt()之类的操作,就是关闭硬件中断。完成交互记得打开中断,在有些系列上,这叫做“进入/退出核心”或者用OS_ENTER_KERNAL/OS_EXIT_KERNAL来描述。
第三,不能调用任何不可重入的函数。
第四,谨慎使用堆栈。最好先在使用前先OS_ENTER_KERNAL。
还有一些规则,都是很好理解的,总之,时刻记住一句话:保证中断是安全的!
Sunday, December 12, 2010
makefile of ThreadTest Program
[q.yang@localhost Sample_011_pThread_test]$ cat makefile
DESTDIR = ./debug
PROGRAM = $(DESTDIR)/ThreadTest
SRCDIR = ./
C = g++
OBJS := $(addprefix $(DESTDIR)/,task1.o)
DEBUG = -g
CFLAGS = -Wall $(DEBUG)
$(PROGRAM): $(OBJS)
$(C) -o $(PROGRAM) $(OBJS)
$(DESTDIR)/%.o:$(SRCDIR)/%.cpp
$(C) -c $(CFLAGS) $< -o $@ $(INCL)
clean :
rm -f $(OBJS)
rm -f $(PROGRAM)
DESTDIR = ./debug
PROGRAM = $(DESTDIR)/ThreadTest
SRCDIR = ./
C = g++
OBJS := $(addprefix $(DESTDIR)/,task1.o)
DEBUG = -g
CFLAGS = -Wall $(DEBUG)
$(PROGRAM): $(OBJS)
$(C) -o $(PROGRAM) $(OBJS)
-lpthread
$(DESTDIR)/%.o:$(SRCDIR)/%.cpp
$(C) -c $(CFLAGS) $< -o $@ $(INCL)
clean :
rm -f $(OBJS)
rm -f $(PROGRAM)
Thursday, December 9, 2010
Thread Vs Process
[1] http://www.cs.rpi.edu/~hollingd/netprog2001/notes/threads/threads.pdf
[2] http://blog.csdn.net/lanmoshui963/archive/2008/03/13/2176376.aspx
[3] sample thread code. http://paste.ubuntu.org.cn/809
[4] http://blog.chinaunix.net/u2/68846/showart_1077115.html
[5] http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html MultiThread Debugging
[6] http://www.linuxselfhelp.com/HOWTO/C++Programming-HOWTO-18.html
[7] http://www.codeproject.com/KB/threads/threadobject.aspx Sample Codes CThread
[8] http://www.ibm.com/developerworks/cn/linux/thread/posix_threadapi/part2/ ThreadProgGuide
[9] http://blog.chinaunix.net/u/22935/showart_310711.html CN BLOG of thread prog
多线程可以把程序中处理用户输入输出的部分与其它部分分开。
线程的缺点 线程也有不足之处。编写多线程程序需要更全面更深入的思考。在一个多线程程序里,因时间分配上的细微偏差或者因共享了不该共享的变量而造成不良影响的可能性是很大的。调试一个多线程程序也比调试一个单线程程序困难得多。
进程的所有信息对该进程的所有线程都是共享的,包括可执行的程序文本,程序的全局内存和堆内存、栈以及文件描述符。[9]
The static function will then typecast the void * and use it to call a non static member function. [6]
从逻辑角度来看,多线程的意义在于一个应用程序中,有多个执行部分可以同时执行。但操作系统并没有将多个线程看做多个独立的应用,来实现进程的调度和管理以及资源分配。这就是进程和线程的重要区别。
线程是进程的一个实体,是CPU调度和分派的基本单位,它是比进程更小的能独立运行的基本单位.线程自己基本上不拥有系统资源,只拥有一点在运行中必不可少的资源(如程序计数器,一组寄存器和栈),但是它可与同属一个进程的其他的线程共享进程所拥有的全部资源。
一个线程可以创建和撤销另一个线程,同一个进程中的多个线程之间可以并发执行。
线程有自己的堆栈和局部变量,但线程之间没有单独的地址空间,一个线程死掉就等于整个进程死掉,所以多进程的程序要比多线程的程序健壮,但在进程切换时,耗费资源较大,效率要差一些。但对于一些要求同时进行并且又要共享某些变量的并发操作,只能用线程,不能用进程。
对开发人员来说,线程之间的数据共享比进程之间的容易得多。在 unix 上,进程间数据共享是通过管道、SOCKET、共享内存、信号灯等机制实现的,在 windows 上也有一套类似的机制。而线程间数据共享只需要共享全局变量即可。多进程无疑比多线程程序更健壮一些,但是代价也是比较大的,特别在进程数或者线程数较多的情况下。
进程在执行过程中有内存单元的初始入口点,并且进程存活过程中始终拥有独立的内存地址空间;
●进程的生存期状态包括创建、就绪、运行、阻塞和死亡等类型;
●从应用程序进程在执行过程中向CPU发出的运行指令形式不同,可以将进程的状态分为用户态和核心态。处于用户态下的进程执行的是应用程序指令、处于核心态下的应用程序进程执行的是操作系统指令。
在Unix操作系统启动过程中,系统自动创建swapper、init等系统进程,用于管理内存资源以及对用户进程进行调度等。在Unix环境下无论是由操作系统创建的进程还要由应用程序执行创建的进程,均拥有唯一的进程标识(PID)。[4]
Creation of a new process using fork is expensive (time & memory).
A thread (sometimes called a lightweight process) does not require lots of memory or startup time.
Each process can include many threads.
All threads of a process share:
– memory (program code and global data)
– open file/socket descriptors
– signal handlers and signal dispositions
– working environment (current directory, user ID,
etc.)
Each thread has it’s own:
– Thread ID (integer)
– Stack, Registers, Program Counter
– errno (if not - errno would be useless!)
Threads within the same process can
communicate using shared memory.
Must be done carefully!
We will focus on Posix Threads - most widely
supported threads programming API.
You need to link with “-lpthread”
On many systems this also forces the
compiler to link in re-entrant libraries
(instead of plain vanilla C libraries).
pthread_create(
pthread_t *tid,
const pthread_attr_t *attr,
void *(*func)(void *),
void *arg);
func is the function to be called.
When func() returns the thread is terminated.
• The return value is 0 for OK.
positive error number on error.
• Does not set errno !!!
• Thread ID is returned in tid
Thread Arguments (cont.)
----------------------------------
Complex parameters can be passed by creating
a structure and passing the address of the
structure.
The structure can't be a local variable (of the
function calling pthread_create)!!
- threads have different stacks!
Joinable Thread
------------------------------
Joinable: on thread termination the thread ID
and exit status are saved by the OS.
One thread can "join" another by calling
pthread_join- which waits (blocks)
until a specified thread exits.
int pthread_join( pthread_t tid,
void **status);
Shared Global Variables
---------------------------------
int counter=0;
void *pancake(void *arg) {
counter++;
printf("Thread %u is number %d\n",
pthread_self(),counter);
}
main() {
int i; pthread_t tid;
for (i=0;i<10;i++)
pthread_create(&tid,NULL,pancake,NULL);
}
Locking and Unlocking
----------------------------
• To lock use:
pthread_mutex_lock(pthread_mutex_t &);
• To unlock use:
pthread_mutex_unlock(pthread_mutex_t &);
• Both functions are blocking!
Condition Variables (cont.)
------------------------------
A condition variable is always used with mutex.
pthread_cond_wait(pthread_cond_t *cptr,
pthread_mutex_t *mptr);
pthread_cond_signal(pthread_cond_t
*cptr);
don’t let the word signal confuse you -
this has nothing to do with Unix signals
摘自资料(linux 与Windows不同)
线程间无需特别的手段进行通信,因为线程间可以共享数据结构,也就是一个全局变量可以被两个线程同时使用。不过要注意的是线程间需要做好同步,一般用 mutex。可以参考一些比较新的UNIX/Linux编程的书,都会提到Posix线程编程,比如《UNIX环境高级编程(第二版)》、《UNIX系统编程》等等。 linux的消息属于IPC,也就是进程间通信,线程用不上。
linux用pthread_kill对线程发信号。 另:windows下不是用post..(你是说PostMessage吗?)进行线程通信的吧?
windows用PostThreadMessage进行线程间通信,但实际上极少用这种方法。还是利用同步多一些 LINUX下的同步和Windows原理都是一样的。不过Linux下的singal中断也很好用。
用好信号量,共享资源就可以了。
使用多线程的理由之一是和进程相比,它是一种非常"节俭"的多任务操作方式。我们知道,在Linux系统下,启动一个新的进程必须分配给它独立的地址空间,建立众多的数据表来维护它的代码段、堆栈段和数据段,这是一种"昂贵"的多任务工作方式。而运行于一个进程中的多个线程,它们彼此之间使用相同的地址空间,共享大部分数据,启动一个线程所花费的空间远远小于启动一个进程所花费的空间,而且,线程间彼此切换所需的时间也远远小于进程间切换所需要的时间。
使用多线程的理由之二是线程间方便的通信机制。对不同进程来说,它们具有独立的数据空间,要进行数据的传递只能通过通信的方式进行,这种方式不仅费时,而且很不方便。线程则不然,由于同一进程下的线程之间共享数据空间,所以一个线程的数据可以直接为其它线程所用,这不仅快捷,而且方便。当然,数据的共享也带来其他一些问题,有的变量不能同时被两个线程所修改,有的子程序中声明为static的数据更有可能给多线程程序带来灾难性的打击,这些正是编写多线程程序时最需要注意的地方。
1、简单的多线程程序
首先在主函数中,我们使用到了两个函数,pthread_create和pthread_join,并声明了一个pthread_t型的变量。
pthread_t在头文件pthread.h中已经声明,是线程的标示符
函数pthread_create用来创建一个线程,函数原型:
extern int pthread_create __P ((pthread_t *__thread, __const pthread_attr_t *__attr,void *(*__start_routine) (void *), void *__arg));
第一个参数为指向线程标识符的指针,第二个参数用来设置线程属性,第三个参数是线程运行函数的起始地址,最后一个参数是运行函数的参数。若我们的函数thread不需要参数,所以最后一个参数设为空指针。第二个参数我们也设为空指针,这样将生成默认属性的线程。对线程属性的设定和修改我们将在下一节阐述。当创建线程成功时,函数返回0,若不为0则说明创建线程失败,常见的错误返回代码为EAGAIN和EINVAL。前者表示系统限制创建新的线程,例如线程数目过多了;后者表示第二个参数代表的线程属性值非法。创建线程成功后,新创建的线程则运行参数三和参数四确定的函数,原来的线程则继续运行下一行代码。
函数pthread_join用来等待一个线程的结束。函数原型为:
extern int pthread_join __P ((pthread_t __th, void **__thread_return));
第一个参数为被等待的线程标识符,第二个参数为一个用户定义的指针,它可以用来存储被等待线程的返回值。这个函数是一个线程阻塞的函数,调用它的函数将一直等待到被等待的线程结束为止,当函数返回时,被等待线程的资源被收回。一个线程的结束有两种途径,一种是象我们上面的例子一样,函数结束了,调用它的线程也就结束了;另一种方式是通过函数pthread_exit来实现。它的函数原型为:
extern void pthread_exit __P ((void *__retval)) __attribute__ ((__noreturn__));
唯一的参数是函数的返回代码,只要pthread_join中的第二个参数thread_return不是NULL,这个值将被传递给 thread_return。最后要说明的是,一个线程不能被多个线程等待,否则第一个接收到信号的线程成功返回,其余调用pthread_join的线程则返回错误代码ESRCH。
2、修改线程的属性
设置线程绑定状态的函数为pthread_attr_setscope,它有两个参数,第一个是指向属性结构的指针,第二个是绑定类型,它有两个取值:PTHREAD_SCOPE_SYSTEM(绑定的)和PTHREAD_SCOPE_PROCESS(非绑定的)。下面的代码即创建了一个绑定的线程。
#include
pthread_attr_t attr;
pthread_t tid;
/*初始化属性值,均设为默认值*/
pthread_attr_init(&attr);
pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
pthread_create(&tid, &attr, (void *) my_function, NULL);
3、线程的数据处理
和进程相比,线程的最大优点之一是数据的共享性,各个进程共享父进程处沿袭的数据段,可以方便的获得、修改数据。但这也给多线程编程带来了许多问题。我们必须当心有多个不同的进程访问相同的变量。许多函数是不可重入的,即同时不能运行一个函数的多个拷贝(除非使用不同的数据段)。在函数中声明的静态变量常常带来问题,函数的返回值也会有问题。因为如果返回的是函数内部静态声明的空间的地址,则在一个线程调用该函数得到地址后使用该地址指向的数据时,别的线程可能调用此函数并修改了这一段数据。在进程中共享的变量必须用关键字volatile来定义,这是为了防止编译器在优化时(如gcc中使用 -OX参数)改变它们的使用方式。为了保护变量,我们必须使用信号量、互斥等方法来保证我们对变量的正确使用。
4、互斥锁
互斥锁用来保证一段时间内只有一个线程在执行一段代码。必要性显而易见:假设各个线程向同一个文件顺序写入数据,最后得到的结果一定是灾难性的
[2] http://blog.csdn.net/lanmoshui963/archive/2008/03/13/2176376.aspx
[3] sample thread code. http://paste.ubuntu.org.cn/809
[4] http://blog.chinaunix.net/u2/68846/showart_1077115.html
[5] http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html MultiThread Debugging
[6] http://www.linuxselfhelp.com/HOWTO/C++Programming-HOWTO-18.html
[7] http://www.codeproject.com/KB/threads/threadobject.aspx Sample Codes CThread
[8] http://www.ibm.com/developerworks/cn/linux/thread/posix_threadapi/part2/ ThreadProgGuide
[9] http://blog.chinaunix.net/u/22935/showart_310711.html CN BLOG of thread prog
多线程可以把程序中处理用户输入输出的部分与其它部分分开。
线程的缺点 线程也有不足之处。编写多线程程序需要更全面更深入的思考。在一个多线程程序里,因时间分配上的细微偏差或者因共享了不该共享的变量而造成不良影响的可能性是很大的。调试一个多线程程序也比调试一个单线程程序困难得多。
进程的所有信息对该进程的所有线程都是共享的,包括可执行的程序文本,程序的全局内存和堆内存、栈以及文件描述符。[9]
The static function will then typecast the void * and use it to call a non static member function. [6]
从逻辑角度来看,多线程的意义在于一个应用程序中,有多个执行部分可以同时执行。但操作系统并没有将多个线程看做多个独立的应用,来实现进程的调度和管理以及资源分配。这就是进程和线程的重要区别。
线程是进程的一个实体,是CPU调度和分派的基本单位,它是比进程更小的能独立运行的基本单位.线程自己基本上不拥有系统资源,只拥有一点在运行中必不可少的资源(如程序计数器,一组寄存器和栈),但是它可与同属一个进程的其他的线程共享进程所拥有的全部资源。
一个线程可以创建和撤销另一个线程,同一个进程中的多个线程之间可以并发执行。
线程有自己的堆栈和局部变量,但线程之间没有单独的地址空间,一个线程死掉就等于整个进程死掉,所以多进程的程序要比多线程的程序健壮,但在进程切换时,耗费资源较大,效率要差一些。但对于一些要求同时进行并且又要共享某些变量的并发操作,只能用线程,不能用进程。
对开发人员来说,线程之间的数据共享比进程之间的容易得多。在 unix 上,进程间数据共享是通过管道、SOCKET、共享内存、信号灯等机制实现的,在 windows 上也有一套类似的机制。而线程间数据共享只需要共享全局变量即可。多进程无疑比多线程程序更健壮一些,但是代价也是比较大的,特别在进程数或者线程数较多的情况下。
进程在执行过程中有内存单元的初始入口点,并且进程存活过程中始终拥有独立的内存地址空间;
●进程的生存期状态包括创建、就绪、运行、阻塞和死亡等类型;
●从应用程序进程在执行过程中向CPU发出的运行指令形式不同,可以将进程的状态分为用户态和核心态。处于用户态下的进程执行的是应用程序指令、处于核心态下的应用程序进程执行的是操作系统指令。
在Unix操作系统启动过程中,系统自动创建swapper、init等系统进程,用于管理内存资源以及对用户进程进行调度等。在Unix环境下无论是由操作系统创建的进程还要由应用程序执行创建的进程,均拥有唯一的进程标识(PID)。[4]
Creation of a new process using fork is expensive (time & memory).
A thread (sometimes called a lightweight process) does not require lots of memory or startup time.
Each process can include many threads.
All threads of a process share:
– memory (program code and global data)
– open file/socket descriptors
– signal handlers and signal dispositions
– working environment (current directory, user ID,
etc.)
Each thread has it’s own:
– Thread ID (integer)
– Stack, Registers, Program Counter
– errno (if not - errno would be useless!)
Threads within the same process can
communicate using shared memory.
Must be done carefully!
We will focus on Posix Threads - most widely
supported threads programming API.
You need to link with “-lpthread”
On many systems this also forces the
compiler to link in re-entrant libraries
(instead of plain vanilla C libraries).
pthread_create(
pthread_t *tid,
const pthread_attr_t *attr,
void *(*func)(void *),
void *arg);
func is the function to be called.
When func() returns the thread is terminated.
• The return value is 0 for OK.
positive error number on error.
• Does not set errno !!!
• Thread ID is returned in tid
Thread Arguments (cont.)
----------------------------------
Complex parameters can be passed by creating
a structure and passing the address of the
structure.
The structure can't be a local variable (of the
function calling pthread_create)!!
- threads have different stacks!
Joinable Thread
------------------------------
Joinable: on thread termination the thread ID
and exit status are saved by the OS.
One thread can "join" another by calling
pthread_join- which waits (blocks)
until a specified thread exits.
int pthread_join( pthread_t tid,
void **status);
Shared Global Variables
---------------------------------
int counter=0;
void *pancake(void *arg) {
counter++;
printf("Thread %u is number %d\n",
pthread_self(),counter);
}
main() {
int i; pthread_t tid;
for (i=0;i<10;i++)
pthread_create(&tid,NULL,pancake,NULL);
}
Locking and Unlocking
----------------------------
• To lock use:
pthread_mutex_lock(pthread_mutex_t &);
• To unlock use:
pthread_mutex_unlock(pthread_mutex_t &);
• Both functions are blocking!
Condition Variables (cont.)
------------------------------
A condition variable is always used with mutex.
pthread_cond_wait(pthread_cond_t *cptr,
pthread_mutex_t *mptr);
pthread_cond_signal(pthread_cond_t
*cptr);
don’t let the word signal confuse you -
this has nothing to do with Unix signals
摘自资料(linux 与Windows不同)
线程间无需特别的手段进行通信,因为线程间可以共享数据结构,也就是一个全局变量可以被两个线程同时使用。不过要注意的是线程间需要做好同步,一般用 mutex。可以参考一些比较新的UNIX/Linux编程的书,都会提到Posix线程编程,比如《UNIX环境高级编程(第二版)》、《UNIX系统编程》等等。 linux的消息属于IPC,也就是进程间通信,线程用不上。
linux用pthread_kill对线程发信号。 另:windows下不是用post..(你是说PostMessage吗?)进行线程通信的吧?
windows用PostThreadMessage进行线程间通信,但实际上极少用这种方法。还是利用同步多一些 LINUX下的同步和Windows原理都是一样的。不过Linux下的singal中断也很好用。
用好信号量,共享资源就可以了。
使用多线程的理由之一是和进程相比,它是一种非常"节俭"的多任务操作方式。我们知道,在Linux系统下,启动一个新的进程必须分配给它独立的地址空间,建立众多的数据表来维护它的代码段、堆栈段和数据段,这是一种"昂贵"的多任务工作方式。而运行于一个进程中的多个线程,它们彼此之间使用相同的地址空间,共享大部分数据,启动一个线程所花费的空间远远小于启动一个进程所花费的空间,而且,线程间彼此切换所需的时间也远远小于进程间切换所需要的时间。
使用多线程的理由之二是线程间方便的通信机制。对不同进程来说,它们具有独立的数据空间,要进行数据的传递只能通过通信的方式进行,这种方式不仅费时,而且很不方便。线程则不然,由于同一进程下的线程之间共享数据空间,所以一个线程的数据可以直接为其它线程所用,这不仅快捷,而且方便。当然,数据的共享也带来其他一些问题,有的变量不能同时被两个线程所修改,有的子程序中声明为static的数据更有可能给多线程程序带来灾难性的打击,这些正是编写多线程程序时最需要注意的地方。
1、简单的多线程程序
首先在主函数中,我们使用到了两个函数,pthread_create和pthread_join,并声明了一个pthread_t型的变量。
pthread_t在头文件pthread.h中已经声明,是线程的标示符
函数pthread_create用来创建一个线程,函数原型:
extern int pthread_create __P ((pthread_t *__thread, __const pthread_attr_t *__attr,void *(*__start_routine) (void *), void *__arg));
第一个参数为指向线程标识符的指针,第二个参数用来设置线程属性,第三个参数是线程运行函数的起始地址,最后一个参数是运行函数的参数。若我们的函数thread不需要参数,所以最后一个参数设为空指针。第二个参数我们也设为空指针,这样将生成默认属性的线程。对线程属性的设定和修改我们将在下一节阐述。当创建线程成功时,函数返回0,若不为0则说明创建线程失败,常见的错误返回代码为EAGAIN和EINVAL。前者表示系统限制创建新的线程,例如线程数目过多了;后者表示第二个参数代表的线程属性值非法。创建线程成功后,新创建的线程则运行参数三和参数四确定的函数,原来的线程则继续运行下一行代码。
函数pthread_join用来等待一个线程的结束。函数原型为:
extern int pthread_join __P ((pthread_t __th, void **__thread_return));
第一个参数为被等待的线程标识符,第二个参数为一个用户定义的指针,它可以用来存储被等待线程的返回值。这个函数是一个线程阻塞的函数,调用它的函数将一直等待到被等待的线程结束为止,当函数返回时,被等待线程的资源被收回。一个线程的结束有两种途径,一种是象我们上面的例子一样,函数结束了,调用它的线程也就结束了;另一种方式是通过函数pthread_exit来实现。它的函数原型为:
extern void pthread_exit __P ((void *__retval)) __attribute__ ((__noreturn__));
唯一的参数是函数的返回代码,只要pthread_join中的第二个参数thread_return不是NULL,这个值将被传递给 thread_return。最后要说明的是,一个线程不能被多个线程等待,否则第一个接收到信号的线程成功返回,其余调用pthread_join的线程则返回错误代码ESRCH。
2、修改线程的属性
设置线程绑定状态的函数为pthread_attr_setscope,它有两个参数,第一个是指向属性结构的指针,第二个是绑定类型,它有两个取值:PTHREAD_SCOPE_SYSTEM(绑定的)和PTHREAD_SCOPE_PROCESS(非绑定的)。下面的代码即创建了一个绑定的线程。
#include
pthread_attr_t attr;
pthread_t tid;
/*初始化属性值,均设为默认值*/
pthread_attr_init(&attr);
pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
pthread_create(&tid, &attr, (void *) my_function, NULL);
3、线程的数据处理
和进程相比,线程的最大优点之一是数据的共享性,各个进程共享父进程处沿袭的数据段,可以方便的获得、修改数据。但这也给多线程编程带来了许多问题。我们必须当心有多个不同的进程访问相同的变量。许多函数是不可重入的,即同时不能运行一个函数的多个拷贝(除非使用不同的数据段)。在函数中声明的静态变量常常带来问题,函数的返回值也会有问题。因为如果返回的是函数内部静态声明的空间的地址,则在一个线程调用该函数得到地址后使用该地址指向的数据时,别的线程可能调用此函数并修改了这一段数据。在进程中共享的变量必须用关键字volatile来定义,这是为了防止编译器在优化时(如gcc中使用 -OX参数)改变它们的使用方式。为了保护变量,我们必须使用信号量、互斥等方法来保证我们对变量的正确使用。
4、互斥锁
互斥锁用来保证一段时间内只有一个线程在执行一段代码。必要性显而易见:假设各个线程向同一个文件顺序写入数据,最后得到的结果一定是灾难性的
Wednesday, December 8, 2010
Check GDB version in Fefora
[q.yang@localhost ProjProgrammingTest]$ gdb
GNU gdb Fedora (6.8-24.fc9)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu".
(gdb) help
List of classes of commands:
aliases -- Aliases of other commands
breakpoints -- Making program stop at certain points
data -- Examining data
files -- Specifying and examining files
internals -- Maintenance commands
obscure -- Obscure features
running -- Running the program
stack -- Examining the stack
status -- Status inquiries
support -- Support facilities
tracepoints -- Tracing of program execution without stopping the program
user-defined -- User-defined commands
Type "help" followed by a class name for a list of commands in that class.
Type "help all" for the list of all commands.
Type "help" followed by command name for full documentation.
Type "apropos word" to search for commands related to "word".
Command name abbreviations are allowed if unambiguous.
GNU gdb Fedora (6.8-24.fc9)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu".
(gdb) help
List of classes of commands:
aliases -- Aliases of other commands
breakpoints -- Making program stop at certain points
data -- Examining data
files -- Specifying and examining files
internals -- Maintenance commands
obscure -- Obscure features
running -- Running the program
stack -- Examining the stack
status -- Status inquiries
support -- Support facilities
tracepoints -- Tracing of program execution without stopping the program
user-defined -- User-defined commands
Type "help" followed by a class name for a list of commands in that class.
Type "help all" for the list of all commands.
Type "help" followed by command name for full documentation.
Type "apropos word" to search for commands related to "word".
Command name abbreviations are allowed if unambiguous.
Tuesday, November 23, 2010
SSH file transfer
[1] http://www.go2linux.org/scp-linux-command-line-copy-files-over-ssh
[2] http://en.kioskea.net/faq/794-file-transfer-via-ssh
[3] http://www.terminally-incoherent.com/blog/2006/09/23/command-line-scp-for-windows/
[1]
---------------------
Usage
scp [[user@]from-host:]source-file [[user@]to-host:][destination-file]
scp -r miguel@10.1.2.2:/home/miguel/ miguel@10.1.2.3:/home/miguel/
[q.yang@localhost user]$ scp q.yang@10.10.20.70:/home/q.yang/lpc3250/ltib-GsnComms3240/rootfs/home/user/TcpIpCommsTarget root@10.10.20.89:/home/user/
The authenticity of host '10.10.20.70 (10.10.20.70)' can't be established.
RSA key fingerprint is 1b:19:f1:da:bd:28:f7:ac:15:fc:d8:28:62:58:47:8b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.10.20.70' (RSA) to the list of known hosts.
q.yang@10.10.20.70's password:
Permission denied, please try again.
q.yang@10.10.20.70's password:
The authenticity of host '10.10.20.89 (10.10.20.89)' can't be established.
RSA key fingerprint is 9a:5b:48:d3:8c:aa:4f:19:6b:fe:5d:9c:bd:64:72:16.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.10.20.89' (RSA) to the list of known hosts.
root@10.10.20.89's password:
TcpIpCommsTarget 100% 11KB 11.0KB/s 00:00
Connection to 10.10.20.70 closed.
[3] PSCP SCP client under windows
------------------------------------
You can download pscp.exe from Putty download page. Works under windows command line.
See screen shot:
Microsoft Windows XP [Version 5.1.2600]
D:\MyDocXp\Downloads>pscp U:\Quentin\Zone__Release\Release-CommsModule\Current\A
pp\GsnCommsTask_20110214 root@172.16.18.2:/home/user/
root@172.16.18.2's password:
GsnCommsTask_20110214 | 318 kB | 318.8 kB/s | ETA: 00:00:00 | 100%
D:\MyDocXp\Downloads>
See screen shot:
[2]
-----------------------------------
ssh server "cat remote_file" > local_file
ssh server "gzip -c remote_file" > local_file.gz
ssh server "gzip -c remote_file " |gunzip > local_file
* Linux/Unix
o Most Unix/Linux versions are supplied as standard with an ssh client, and most with an ssh server.
* Under Windows
* Free ssh client:
o Putty
* Free graphical scp/sftp client :
o WinSCP
o FileZilla
* Free SSH server:
* For Windows 2000/XP:
o ssh Windows (can be operate as a service)
* For Windows 95/98/ME/2000/XP:
o Use Cygwin
[2] http://en.kioskea.net/faq/794-file-transfer-via-ssh
[3] http://www.terminally-incoherent.com/blog/2006/09/23/command-line-scp-for-windows/
[1]
---------------------
Usage
scp [[user@]from-host:]source-file [[user@]to-host:][destination-file]
scp -r miguel@10.1.2.2:/home/miguel/ miguel@10.1.2.3:/home/miguel/
[q.yang@localhost user]$ scp q.yang@10.10.20.70:/home/q.yang/lpc3250/ltib-GsnComms3240/rootfs/home/user/TcpIpCommsTarget root@10.10.20.89:/home/user/
The authenticity of host '10.10.20.70 (10.10.20.70)' can't be established.
RSA key fingerprint is 1b:19:f1:da:bd:28:f7:ac:15:fc:d8:28:62:58:47:8b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.10.20.70' (RSA) to the list of known hosts.
q.yang@10.10.20.70's password:
Permission denied, please try again.
q.yang@10.10.20.70's password:
The authenticity of host '10.10.20.89 (10.10.20.89)' can't be established.
RSA key fingerprint is 9a:5b:48:d3:8c:aa:4f:19:6b:fe:5d:9c:bd:64:72:16.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.10.20.89' (RSA) to the list of known hosts.
root@10.10.20.89's password:
TcpIpCommsTarget 100% 11KB 11.0KB/s 00:00
Connection to 10.10.20.70 closed.
[3] PSCP SCP client under windows
------------------------------------
You can download pscp.exe from Putty download page. Works under windows command line.
See screen shot:
Microsoft Windows XP [Version 5.1.2600]
D:\MyDocXp\Downloads>pscp U:\Quentin\Zone__Release\Release-CommsModule\Current\A
pp\GsnCommsTask_20110214 root@172.16.18.2:/home/user/
root@172.16.18.2's password:
GsnCommsTask_20110214 | 318 kB | 318.8 kB/s | ETA: 00:00:00 | 100%
D:\MyDocXp\Downloads>
See screen shot:
[2]
-----------------------------------
ssh server "cat remote_file" > local_file
ssh server "gzip -c remote_file" > local_file.gz
ssh server "gzip -c remote_file " |gunzip > local_file
* Linux/Unix
o Most Unix/Linux versions are supplied as standard with an ssh client, and most with an ssh server.
* Under Windows
* Free ssh client:
o Putty
* Free graphical scp/sftp client :
o WinSCP
o FileZilla
* Free SSH server:
* For Windows 2000/XP:
o ssh Windows (can be operate as a service)
* For Windows 95/98/ME/2000/XP:
o Use Cygwin
Wednesday, November 17, 2010
LTIB -- Usage Summary
[1] http://www.ltib.org/documentation-LtibFaq
[2] http://blog.csdn.net/wangzhong1979/archive/2010/02/08/5295777.aspx
[3] http://lists.gnu.org/archive/html/ltib/2010-11/msg00139.html
[4] http://lists.gnu.org/archive/html/ltib/2010-10/msg00008.html --- cross compiler
[5] http://www.linuxselfhelp.com/HOWTO/MIPS-HOWTO-9.html ---- cross compiler
[6] http://www.codesourcery.com/sgpp/lite/arm/portal/target_arch?@action=faq&target_arch=arm --- one provider where can download arm-nonlinux-guneabi
[7] http://www.codesourcery.com/sgpp/lite/arm ---GNU Tool Chain from CodeSourcery
[8] http://lists.gnu.org/archive/html/ltib/2010-10/msg00008.html --- Ltib not installing the cross compiler.
[9] https://wiki.linaro.org/Resources/FAQ ---- Org for Linux On ARM solution
[10]http://web.archiveorange.com/archive/v/zE6LZwICaTeR5uWNSWaW ----- Stuart Reply /proc make nods.
[11]mkfs.jffs2 man
USE DIFFERENT CROSS COMPILING TOOL CHAIN UNDER LTIB
---------------------------------------------
[4] [5]
[6] Why doesn't Sourcery G++ Lite Edition contain libraries for big-endian GNU/Linux? Or for systems with VFP or NEON?
Why does CodeSourcery provide GLIBC? Can I use the version that comes with my GNU/Linux distribution?
Why is the configuration name for GNU/Linux arm-none-linux-gnueabi instead of just arm-none-linux-eabi? Is there a GNU variant of the EABI?
Answer
The Free Software Foundation prefers that configuration names for GNU/Linux contain both the string linux and the string gnu. The configuration arm-none-linux-gnu refers to the legacy ARM ABI for GNU/Linux. Some tools depend on the fact that configuration names have at most three hyphens, so gnu and eabi were combined into a single word.
The ABI used on GNU/Linux is not a special GNU variant of the EABI; it is just the EABI.
-O2 -fsigned-char -mfloat-abi=softfp -mfpu=vfp
/home/quentin/CodeSourcery/arm-2010q1
arm-none-linux-gnueabi-
BUILD FROM SCRATCH
------------------------------------------------
Note:
This will remove rootfs and all configrations.
Build all packages and kernel from scratch.
[root@localhost ltib-qs]#./ltib -m distclean
[root@localhost ltib-qs]#./ltib --config
ADD CUSTOMER BSP INTO LTIB MENU
--------------------------------
Steps to Add your new board into LTIB menu (CM-HS1)
01-MAR-2012
1. Add new machine ID for the new board:
Register a machine ID for the new board via http://www.arm.linux.org.uk/developer/machines/ website and then update mach-types.h under /linux_kernel_dir/arch/arm/tools/ to the latest version;
2. Add new board information into the LTIB menus:
a. Make a folder for the new Board Support Package (BSP) under '/ltib/config/platform/'. The folder name should be the same as that defined in main.lkc, i.e., '/ltib/config/platform/gsncomm'. Please refer to 2.c below.
b. Copy all files from an existing Board Support Package (BSP) folder to the new BSP folder. We use the one we did the evaluation, i.e., from 'phy3250';
c. Make necessary changes to main.lkc under new BSP folder '/ltib/config/platform/$NEW_BOARD/'. All contents in main.lkc that are related to CPU and board need to be modified.
d. Create a Linux kernel pre-configuration file, e.g., 'linux-2.6.34-gsncomm.config'. This file can be manually generated by running the LTIB, which has Linux Kernel configuration GUI. 'linux-2.6.34-gsncomm.config' is generated based on 'linux-2.6.34-phy3250.config' with some modifications to mach GridSense Lpc 3240 board. 'linux-2.6.34-gsncomm.config' has to be stored under path '/ltib/config/platform/$NEW_BOARD/'
e. Overwrite the Linux board configuration file 'defconfig' and 'defconfig.dev' under ''/ltib/config/platform/$NEW_BOARD/' with your own board configuration file, in which different Linux kernel pre-configuration file, and installed Linux packages can be defined. New Linux board configuration file can also be generated with the help of LTIB, which has a Linux board configuration GUI. Basically, board configuration file will decide what application will be installed in Linux Root File System (RFS).
3. Add new BSP into to Linux Kernel (here we use lpc32xx based board as example):
a. Add new board choice to Kconfig under '/linux_kernel_src_dir/arch/arm/mach_lpc32xx/'. Add sub menu items if required;
b. Add board level initialisation BSP source code under the folder. It is recommended the main source code file name follow the board name. i.e., BSP source code 'gsncomm.c' under '/linux_kernel_src_dir/arch/arm/mach_lpc32xx/'.
c. Add board level initialisation code file(s) to the Makefile within the folder.
d. Copy Linux kernel pre-configuration file 'linux-2.6.34-gsncomm.config' to folder '/linux_kernel_src_dir/arch/arm/configs/' and rename it to 'gsncomm_defconfig'.
4. Use LTIB menu-based GUI to do further configuration and then build the kernel. Fix any error raised during porting.
CHOOSE CUSTOMER BSP
-------------------------
UPDATE ALL PACKAGES AND PATCHES FROM CVS
---------------------------------------------
Just run"cvs update" in your ltib directory. It'll fetch the updates and in the ltib config you can see the 2.6.34 kernel support.
MISSING NODES UNDER /DEV/
--------------------------------------
Has to change default phytect 'busybox.config', and add support for 'mdev'.
then /rootfs/sbin/mdev will appear and symbol link to busybox.
Make /DEV/ nodes from device_table.txt
If the target architecture is different from the original one, a different cross compiler will be needed. It will be downloaded and installed in the correct location if it isn't already present.
How to add device nodes
Device nodes with static major/minor numbers can be added to the file ltib/bin/device_table.txt. The format is described in the file itself.
Since there is no dependency checking for device_table.txt, after adding a new entry, force rebuild devices to make sure the new /dev nodes are in the file system:
$ ./ltib -p dev -f
MISSING /PROC/DEVICES
-------------------------------
After changing the property of all files under 'etc/rc.d/init.d/', adding 'x' right, problem is solved.
quentin@ubuntu:~/lpc3250/ltib-qs/rootfs$ sudo chmod a+x etc/rc.d/init.d/*
quentin@ubuntu:~/lpc3250/ltib-qs/rootfs$ ll etc/rc.d/init.d/
total 88
drwxr-xr-x 2 root root 4096 2011-06-10 16:56 ./
drwxr-sr-x 3 root root 4096 2011-06-11 08:14 ../
-rw-r--r-- 1 root root 357 2011-06-10 16:56 boa
-rw-r--r-- 1 root root 176 2011-06-10 16:56 depmod
-rw-r--r-- 1 root root 219 2011-06-10 16:56 devfsd
-rw-r--r-- 1 root root 904 2011-06-10 16:56 dhcp
-rw-r--r-- 1 root root 413 2011-06-10 16:56 dhcpd
-rw-r--r-- 1 root root 651 2011-06-10 16:56 dropbear
-rw-r--r-- 1 root root 1299 2011-06-10 16:56 filesystems
-rw-r--r-- 1 root root 183 2011-06-10 16:56 hostname
-rw-r--r-- 1 root root 342 2011-06-10 16:56 inetd
-rw-r--r-- 1 root root 741 2011-06-10 16:56 mdev
-rw-r--r-- 1 root root 165 2011-06-10 16:56 modules
-rw-r--r-- 1 root root 160 2011-06-10 16:56 mount-proc-sys
-rw-r--r-- 1 root root 5229 2011-06-10 16:56 network
-rw-r--r-- 1 root root 346 2011-06-10 16:56 portmap
-rw-r--r-- 1 root root 722 2011-06-10 16:56 settime
-rw-r--r-- 1 root root 279 2011-06-10 16:56 smb
-rw-r--r-- 1 root root 735 2011-06-10 16:56 sshd
-rw-r--r-- 1 root root 502 2011-06-10 16:56 syslog
-rw-r--r-- 1 root root 797 2011-06-10 16:56 udev
[l.lu@localhost ltib]$ ll rootfs/etc/rc.d/init.d/
total 84
-rwxr-xr-x 1 root root 357 2011-06-01 19:02 boa
-rwxr-xr-x 1 root root 176 2011-06-01 19:02 depmod
-rwxr-xr-x 1 root root 219 2011-06-01 19:02 devfsd
-rwxr-xr-x 1 root root 904 2011-06-01 19:02 dhcp
-rwxr-xr-x 1 root root 413 2011-06-01 19:02 dhcpd
-rwxr-xr-x 1 root root 651 2011-06-01 19:02 dropbear
-rwxr-xr-x 1 root root 1299 2011-06-01 19:02 filesystems
-rwxr-xr-x 1 root root 183 2011-06-01 19:02 hostname
-rwxr-xr-x 1 root root 1170 2011-06-01 19:12 hotplug
-rwxr-xr-x 1 root root 342 2011-06-01 19:02 inetd
-rwxr-xr-x 1 root root 741 2011-06-01 19:02 mdev
-rwxr-xr-x 1 root root 165 2011-06-01 19:02 modules
-rwxr-xr-x 1 root root 160 2011-06-01 19:02 mount-proc-sys
-rwxr-xr-x 1 root root 5229 2011-06-01 19:02 network
-rwxr-xr-x 1 root root 346 2011-06-01 19:02 portmap
-rwxr-xr-x 1 root root 722 2011-06-01 19:02 settime
-rwxr-xr-x 1 root root 279 2011-06-01 19:02 smb
-rwxr-xr-x 1 root root 735 2011-06-01 19:02 sshd
-rwxr-xr-x 1 root root 502 2011-06-01 19:02 syslog
-rwxr-xr-x 1 root root 797 2011-06-01 19:02 udev
HOW TO UNINSTALL LTIB
-----------------------------
[2] 在ubuntu系统上,假如ltib已经安装了,我们只需编译、重新配置ltib,
以非root用户登陆,进入ltib所在文件夹,依次输入以下两条命令:
./ltib clean
./ltib -c
即可先后配置linux应用软件包、linux内核。
编译成功后,~/ltib/rootfs/boot目录下,有新编译的内核文件uImage、设备树mpc8315erdb_default.dtb,分别拷贝到/tftpboot目录下。
MULTIPLE LTIB INSTALLATION
-----------------------------------
[1]Can I have more than one root file system on my host at the same time
Yes, the system will support multiple root file systems, for the same or for different target architectures.
If you are using an iso image, install your ltib archive into an different directory by entering a new directory name for the installation when prompted by the install script..
If you are using CVS, check-out CVS into a different directory by using the -d option to cvs co. For example:
ADD FILES TO THE TARGET ROOT FILE SYSTEM
------------------------------------------
[1] Can I add files to the target root file system without creating a package
Yes, to do this, you need to create a merge directory. There are 2 options:
1 Top level merge directory, that applies to all targets 2 Platform specific merge directory
The platform specific merge directory contents override the top level merge directory, which overrides the corresponding file(s) in your rootfs
Example:
You have a CVS version of LTIB, and you have build the tqm823l default configuration, now:
1 You want to add the a platform specific file /home/fred/myfile1 2 You want all platforms you may build to use your own /etc/hosts file
Here's what you would do:
$ cd
$ mkdir -p config/platform/tqm823l/merge/home/fred
$ cp/myfile1 config/platform/tqm823l/merge/home/fred
$ mkdir -p merge/etc
$ cp/hosts merge/etc
$ ./ltib
CHECK LTIB LOCAL CVS REVISION
------------------------------------
[l.lu@localhost ltib]$ cd CVS/
[l.lu@localhost CVS]$ ll
total 16
-rw-rw-rw- 1 l.lu developer 215 2011-05-30 15:28 Entries
-rw-rw-rw- 1 l.lu developer 86 2011-05-30 15:28 Entries.Log
-rw-rw-rw- 1 l.lu developer 5 2011-05-30 15:28 Repository
-rw-rw-rw- 1 l.lu developer 57 2011-05-30 15:28 Root
-rw-rw-rw- 1 l.lu developer 0 2011-05-30 15:28 Template
[l.lu@localhost CVS]$ cat Entries
/.gitignore/1.1.1.2/Wed Mar 18 17:53:24 2009//
/.ltibrc/1.16/Tue Aug 17 18:18:00 2010//
/COPYING/1.1.1.2/Tue Nov 6 15:44:42 2007//
/README/1.1.1.3/Tue Nov 6 15:44:41 2007//
/ltib/1.75/Sat Apr 2 10:56:01 2011//
[l.lu@localhost CVS]$ cat Root
:pserver:anonymous@cvs.savannah.nongnu.org:/sources/ltib
[l.lu@localhost CVS]$ cat Repository
ltib
[l.lu@localhost CVS]$ cat Entries.Log
A D/bin////
A D/config////
A D/dist////
A D/doc////
A D/internal////
R D/internal////
BUILD RFS ROOT FILE SYSTEM
--------------------------------------
------++++check files/folders size under rootfs
[root@localhost ltib]# du -h rootfs/ | grep M
38M rootfs/boot
7.1M rootfs/usr/lib
1.4M rootfs/usr/include/openssl
3.3M rootfs/usr/include
1.1M rootfs/usr/sbin
7.0M rootfs/usr/bin
236K rootfs/usr/share/locale/uk/LC_MESSAGES
32K rootfs/usr/share/locale/ko/LC_MESSAGES
212K rootfs/usr/share/locale/da/LC_MESSAGES
----++++ trimmed unwanted files/folders in rootfs
----++++ force dev table if don't have enough in /rootfs/dev/
[l.lu@localhost ltib]$ ./ltib -p dev -f
Processing platform: Phytec 3250 board with the NXP LPC32XX SoC
=================================================================
using config/platform/phy3250/.config
Processing: dev
=================
Build path taken because: force set, build key set,
rpmbuild --dbpath /home/l.lu/lpc3250/ltib/rootfs//var/lib/rpm --target arm --define '_unpackaged_files_terminate_build 0' --define '_target_cpu arm' --define '__strip strip' --define '_topdir /home/l.lu/lpc3250/ltib/rpm' --define '_prefix /usr' --define '_tmppath /home/l.lu/lpc3250/ltib/tmp' --define '_rpmdir /home/l.lu/lpc3250/ltib/rpm/RPMS' --define '_mandir /usr/share/man' --define '_sysconfdir /etc' --define '_localstatedir /var' -bb --clean --rmsource /home/l.lu/lpc3250/ltib/dist/lfs-5.1/dev/dev.spec
Building target platforms: arm
Building for target arm
Executing(%prep): /bin/sh -e /home/l.lu/lpc3250/ltib/tmp/rpm-tmp.29641
+ umask 022
+ cd /home/l.lu/lpc3250/ltib/rpm/BUILD
+ cd /home/l.lu/lpc3250/ltib/rpm/BUILD
+ rm -rf dev-1.1
+ /bin/gzip -dc /home/l.lu/lpc3250/ltib/rpm/SOURCES/dev-1.1.tar.gz
+ tar -xvvf -
drwxr-xr-x seh/users 0 2005-03-23 22:48 dev-1.1/
-rw-r--r-- seh/users 5643 2005-03-23 06:49 dev-1.1/device_table.txt
-rwxr-xr-x seh/users 2187 2005-03-23 22:43 dev-1.1/mkrpmdev
-rw-r--r-- seh/users 766 2005-03-23 22:48 dev-1.1/dev.spec
-rw-r--r-- seh/users 34 2005-03-23 22:46 dev-1.1/Makefile
-rw-r--r-- seh/users 262 2005-03-23 22:47 dev-1.1/README
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd dev-1.1
+ exit 0
Executing(%build): /bin/sh -e /home/l.lu/lpc3250/ltib/tmp/rpm-tmp.29641
+ umask 022
+ cd /home/l.lu/lpc3250/ltib/rpm/BUILD
+ cd dev-1.1
+ exit 0
Executing(%install): /bin/sh -e /home/l.lu/lpc3250/ltib/tmp/rpm-tmp.29641
+ umask 022
+ cd /home/l.lu/lpc3250/ltib/rpm/BUILD
+ cd dev-1.1
+ rm -rf /home/l.lu/lpc3250/ltib/tmp/dev
+ '[' -f /home/l.lu/lpc3250/ltib/bin/device_table.txt ']'
+ DEV_TABLE=/home/l.lu/lpc3250/ltib/bin/device_table.txt
+ mkdir -p /home/l.lu/lpc3250/ltib/tmp/dev//opt/freescale/rootfs/arm//dev
+ ln -s /var/tmp/log /home/l.lu/lpc3250/ltib/tmp/dev//opt/freescale/rootfs/arm//dev/log
+ ln -s /proc/mounts /home/l.lu/lpc3250/ltib/tmp/dev//opt/freescale/rootfs/arm//dev/mtab
+ PREFIX=/opt/freescale/rootfs/arm/
+ perl mkrpmdev /home/l.lu/lpc3250/ltib/bin/device_table.txt
+ exit 0
Processing files: dev-1.1-1
Finding Provides: (using /opt/ltib/usr/lib/rpm/find-provides)...
Finding Requires: (using /opt/ltib/usr/lib/rpm/find-requires)...
PreReq: rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(CompressedFileNames) <= 3.0.4-1
Requires(rpmlib): rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(CompressedFileNames) <= 3.0.4-1
Wrote: /home/l.lu/lpc3250/ltib/rpm/RPMS/arm/dev-1.1-1.arm.rpm
Executing(%clean): /bin/sh -e /home/l.lu/lpc3250/ltib/tmp/rpm-tmp.98556
+ umask 022
+ cd /home/l.lu/lpc3250/ltib/rpm/BUILD
+ cd dev-1.1
+ rm -rf /home/l.lu/lpc3250/ltib/tmp/dev
+ rm -f /tmp/manifest
+ exit 0
Executing(--clean): /bin/sh -e /home/l.lu/lpc3250/ltib/tmp/rpm-tmp.98556
+ umask 022
+ cd /home/l.lu/lpc3250/ltib/rpm/BUILD
+ rm -rf dev-1.1
+ exit 0
Build time for dev: 2 seconds
sudo /opt/ltib/usr/bin/rpm --root /home/l.lu/lpc3250/ltib/rootfs --dbpath /var/lib/rpm -e --allmatches --nodeps --noscripts --define '_tmppath /tmp/ltib' dev 2>/dev/null
sudo /opt/ltib/usr/bin/rpm --root /home/l.lu/lpc3250/ltib/rootfs --dbpath /var/lib/rpm --prefix / --ignorearch -ivh --force --excludedocs --noscripts --define '_tmppath /tmp/ltib' /home/l.lu/lpc3250/ltib/rpm/RPMS/arm/dev-1.1-1.arm.rpm
error: failed to stat /home/l.lu/.gvfs: Permission denied
Preparing... ########################################### [100%]
1:dev ########################################### [100%]
Processing deployment operations
==================================
making filesystem image file
staging directory is /home/l.lu/lpc3250/ltib/rootfs.tmp
removing the boot directory and files
removing man files and directories
removing info files
removing /usr/src directory
removing /usr/include directory
removing /usr/share/locale directory
removing static libraries
removing target rpm database
stripping binaries and libraries
WARN: /home/l.lu/lpc3250/ltib/rootfs.tmp/sbin/sln statically linked
WARN: /home/l.lu/lpc3250/ltib/rootfs.tmp/sbin/ldconfig statically linked
WARN: /home/l.lu/lpc3250/ltib/rootfs.tmp/bin/busybox statically linked
Filesystem stats, including padding:
Total size = 38408k
Total number of files = 1055
running post build user command: . ../GsnComm_FlashRelease_copyUimgRfsToTftp.sh
cp: cannot stat `/home/l.lu/lpc3250/ltib/rootfs/boot/uImage': No such file or directory
Started: Thu Jun 2 10:40:31 2011
Ended: Thu Jun 2 10:40:57 2011
Elapsed: 26 seconds
Build Succeeded
--------++++Manually generate RFS
mkfs.jffs2 [ -p,--pad[=SIZE] ] [ -r,-d,--root directory ] [ -s,--pagesize=SIZE ] [ -e,--eraseblock=SIZE ] [ -c,--cleanmarker=SIZE ] [ -n,--no-cleanmarkers ] [ -o,--output image.jffs2 ] [ -l,--little-endian ] [ -b,--big-endian ] [ -D,--devtable=FILE ] [ -f,--faketime ] [ -q,--squash ] [ -U,--squash-uids ] [ -P,--squash-perms ] [ --with-xattr ] [ --with-selinux ] [ --with-posix-acl ] [ -m,--compression-mode=MODE ] [ -x,--disable-compressor=NAME ] [ -X,--enable-compressor=NAME ] [ -y,--compressor-priority=PRIORITY:NAME ] [ -L,--list-compressors ] [ -t,--test-compression ] [ -h,--help ] [ -v,--verbose ] [ -V,--version ] [ -i,--incremental image.jffs2 ]
Note: /rootfs/ has to be owned by root, so make sure
#chown -R root:root ./rootfs/ before manually generating RFS.
/opt/ltib/usr/bin/mkfs.jffs2 -n -r rootfs_working -m size -e 16 -o /tftpboot/rootfs.jffs2
[l.lu@localhost ltib]$ /opt/ltib/usr/bin/mkfs.jffs2 -n -r ./rootfs -m size -e 16 -o ./manual_rfs.jffs2
[l.lu@localhost ltib]$ /opt/ltib/usr/bin/mkfs.jffs2 -n -r ./manual_trimmed_rootfs_after-p-dev-f_bkup/rootfs/ -m size -e 16 -o ./manual_rfs.jffs2
use LTIB to build RFS auotmatically
-----------------------------------------------
[3]
$./ltib -m clean
$./ltib -m distclean
Removed whole rootfs folder after '-m distclean'
quentin@ubuntu:~/lpc3250/ltib-qs$ ./ltib -m distclean
You are about remove all the work you have been doing, are you really
sure you want to completely remove files from:
/home/quentin/lpc3250/ltib-qs/rootfs
To continue type in 'yes': yes
Removing target root filesystem
[sudo] password for quentin:
Processing: mkdistclean
=========================
Build path taken because: force set, build key set, no prebuilt rpm,
rpmbuild --dbpath ///home/quentin/lpc3250/ltib-qs/cleanupdb --target i686 --define '_unpackaged_files_terminate_build 0' --define '_target_cpu i686' --define '__strip strip' --define '_topdir /home/quentin/lpc3250/ltib-qs/rpm' --define '_prefix /usr' --define '_tmppath /home/quentin/lpc3250/ltib-qs/tmp' --define '_rpmdir /home/quentin/lpc3250/ltib-qs/rpm/RPMS' --define '_mandir /usr/share/man' --define '_sysconfdir /etc' --define '_localstatedir /var' -bb --clean --rmsource /home/quentin/lpc3250/ltib-qs/dist/lfs-5.1/mkdistclean/mkdistclean.spec
Building target platforms: i686
Building for target i686
Executing(%prep): /bin/sh -e /home/quentin/lpc3250/ltib-qs/tmp/rpm-tmp.46763
+ umask 022
+ cd /home/quentin/lpc3250/ltib-qs/rpm/BUILD
+ exit 0
Executing(%build): /bin/sh -e /home/quentin/lpc3250/ltib-qs/tmp/rpm-tmp.46763
+ umask 022
+ cd /home/quentin/lpc3250/ltib-qs/rpm/BUILD
+ exit 0
Executing(%install): /bin/sh -e /home/quentin/lpc3250/ltib-qs/tmp/rpm-tmp.46763
+ umask 022
+ cd /home/quentin/lpc3250/ltib-qs/rpm/BUILD
+ : /home/quentin/lpc3250/ltib-qs/rootfs
+ '[' '!' -d /home/quentin/lpc3250/ltib-qs/rootfs ']'
+ '[' /home/quentin/lpc3250/ltib-qs/rootfs = / ']'
+ '[' 1000 = 0 ']'
+ '[' '!' -O /home/quentin/lpc3250/ltib-qs/rootfs ']'
+ rm -rf /home/quentin/lpc3250/ltib-qs/tmp/mkdistclean
+ mkdir -p /home/quentin/lpc3250/ltib-qs/tmp/mkdistclean//opt/freescale/rootfs/i686
+ cd /home/quentin/lpc3250/ltib-qs/rootfs
+ set +e
+ find -type d -exec mkdir -p '/home/quentin/lpc3250/ltib-qs/tmp/mkdistclean//opt/freescale/rootfs/i686/{}' ';'
+ find . '!' -type d -exec touch '/home/quentin/lpc3250/ltib-qs/tmp/mkdistclean//opt/freescale/rootfs/i686/{}' ';'
+ exit 0
+ mkdir -p /home/quentin/lpc3250/ltib-qs/tmp/mkdistclean//opt/freescale/rootfs/i686/root/.ssh
+ touch /home/quentin/lpc3250/ltib-qs/tmp/mkdistclean//opt/freescale/rootfs/i686/root/.ssh/known_hosts
+ touch /home/quentin/lpc3250/ltib-qs/tmp/mkdistclean//opt/freescale/rootfs/i686/.ash_history
Processing files: mkdistclean-1.0-1
Finding Provides: (using /opt/ltib/usr/lib/rpm/find-provides)...
Finding Requires: (using /opt/ltib/usr/lib/rpm/find-requires)...
PreReq: rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(CompressedFileNames) <= 3.0.4-1
Requires(rpmlib): rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(CompressedFileNames) <= 3.0.4-1
Wrote: /home/quentin/lpc3250/ltib-qs/rpm/RPMS/i686/mkdistclean-1.0-1.i686.rpm
Executing(%clean): /bin/sh -e /home/quentin/lpc3250/ltib-qs/tmp/rpm-tmp.23031
+ umask 022
+ cd /home/quentin/lpc3250/ltib-qs/rpm/BUILD
+ rm -rf /home/quentin/lpc3250/ltib-qs/tmp/mkdistclean
+ exit 0
Executing(--clean): /bin/sh -e /home/quentin/lpc3250/ltib-qs/tmp/rpm-tmp.23031
+ umask 022
+ cd /home/quentin/lpc3250/ltib-qs/rpm/BUILD
+ exit 0
Build time for mkdistclean: 15 seconds
sudo /opt/ltib/usr/bin/rpm --root / --dbpath /home/quentin/lpc3250/ltib-qs/cleanupdb -e --allmatches --nodeps --noscripts --define '_tmppath /home/quentin/lpc3250/ltib-qs/tmp' mkdistclean 2>/dev/null
sudo /opt/ltib/usr/bin/rpm --root / --dbpath /home/quentin/lpc3250/ltib-qs/cleanupdb --prefix /home/quentin/lpc3250/ltib-qs/rootfs --ignorearch -ivh --force --excludedocs --noscripts --define '_tmppath /home/quentin/lpc3250/ltib-qs/tmp' /home/quentin/lpc3250/ltib-qs/rpm/RPMS/i686/mkdistclean-1.0-1.i686.rpm
error: failed to stat /home/quentin/.gvfs: Permission denied
Preparing... ########################################### [100%]
1:mkdistclean ########################################### [100%]
sudo /opt/ltib/usr/bin/rpm --root / --dbpath /home/quentin/lpc3250/ltib-qs/cleanupdb -e --allmatches --noscripts --define '_tmppath /home/quentin/lpc3250/ltib-qs/tmp' mkdistclean
error: failed to stat /home/quentin/.gvfs: Permission denied
quentin@ubuntu:~/lpc3250/ltib-qs$ ll rootfs_image
lrwxrwxrwx 1 quentin developer 14 2011-05-31 11:05 rootfs_image -> ./rootfs.jffs2
quentin@ubuntu:~/lpc3250/ltib-qs$ ll
total 288
drwxrwxrwx 8 quentin quentin 4096 2011-06-01 08:52 ./
drwxr-xr-x 4 quentin quentin 4096 2011-05-26 12:37 ../
-rwxr--r-- 1 quentin quentin 886 2011-05-25 11:55 2869_ltib.patch*
drwxrwxrwx 3 quentin quentin 4096 2011-06-01 08:52 bin/
drwxrwxrwx 7 quentin quentin 4096 2011-06-01 08:52 config/
-rw-rw-rw- 1 quentin quentin 17989 2007-11-07 02:44 COPYING
drwxrwxrwx 2 quentin quentin 4096 2011-05-24 14:50 CVS/
drwxrwxrwx 4 quentin quentin 4096 2011-05-24 14:50 dist/
drwxrwxrwx 3 quentin quentin 4096 2011-05-24 14:50 doc/
-rw-rw-rw- 1 quentin quentin 436 2009-03-19 04:53 .gitignore
-rwxrwxrwx 1 quentin quentin 110719 2011-05-25 11:57 ltib*
-rwxrwxrwx 1 quentin quentin 110337 2011-04-02 21:56 ltib.orig*
-rw-rw-rw- 1 quentin quentin 2579 2010-08-18 04:18 .ltibrc
-rw-rw-rw- 1 quentin quentin 952 2007-11-07 02:44 README
lrwxrwxrwx 1 quentin developer 14 2011-05-31 11:05 rootfs_image -> ./rootfs.jffs2
drwxrwsr-x 3 quentin quentin 4096 2011-06-01 08:52 rpm/
quentin@ubuntu:~/lpc3250/ltib-qs$
NOTES FROM LtibConvertPcsBsp
-----------------------------------------
-----+++ Deploying the BSP
The primary deployment mechanism in ltib is expected to be NFS. By
default ltib will build a root filesystem suitable for exporting as
a root filesystem in ~/ltib/rootfs . It is the user's responsibility
to export this directory and setup the bootloader parameters to
use this. Note that the built kernel can be located in ~/ltib/rootfs/boot
---++ Saving your work
Once you have booted your board and are happy to check in your work,
you need to do the following:
* copy the updated .config to defconfig
cp config/platform/mpc5200/.config config/platform/mpc5200/defconfig
* checking ltib changes to CVS
* copy new source files to the GPP
[2] http://blog.csdn.net/wangzhong1979/archive/2010/02/08/5295777.aspx
[3] http://lists.gnu.org/archive/html/ltib/2010-11/msg00139.html
[4] http://lists.gnu.org/archive/html/ltib/2010-10/msg00008.html --- cross compiler
[5] http://www.linuxselfhelp.com/HOWTO/MIPS-HOWTO-9.html ---- cross compiler
[6] http://www.codesourcery.com/sgpp/lite/arm/portal/target_arch?@action=faq&target_arch=arm --- one provider where can download arm-nonlinux-guneabi
[7] http://www.codesourcery.com/sgpp/lite/arm ---GNU Tool Chain from CodeSourcery
[8] http://lists.gnu.org/archive/html/ltib/2010-10/msg00008.html --- Ltib not installing the cross compiler.
[9] https://wiki.linaro.org/Resources/FAQ ---- Org for Linux On ARM solution
[10]http://web.archiveorange.com/archive/v/zE6LZwICaTeR5uWNSWaW ----- Stuart Reply /proc make nods.
[11]mkfs.jffs2 man
USE DIFFERENT CROSS COMPILING TOOL CHAIN UNDER LTIB
---------------------------------------------
[4] [5]
[6] Why doesn't Sourcery G++ Lite Edition contain libraries for big-endian GNU/Linux? Or for systems with VFP or NEON?
Why does CodeSourcery provide GLIBC? Can I use the version that comes with my GNU/Linux distribution?
Why is the configuration name for GNU/Linux arm-none-linux-gnueabi instead of just arm-none-linux-eabi? Is there a GNU variant of the EABI?
Answer
The Free Software Foundation prefers that configuration names for GNU/Linux contain both the string linux and the string gnu. The configuration arm-none-linux-gnu refers to the legacy ARM ABI for GNU/Linux. Some tools depend on the fact that configuration names have at most three hyphens, so gnu and eabi were combined into a single word.
The ABI used on GNU/Linux is not a special GNU variant of the EABI; it is just the EABI.
-O2 -fsigned-char -mfloat-abi=softfp -mfpu=vfp
/home/quentin/CodeSourcery/arm-2010q1
arm-none-linux-gnueabi-
BUILD FROM SCRATCH
------------------------------------------------
Note:
This will remove rootfs and all configrations.
Build all packages and kernel from scratch.
[root@localhost ltib-qs]#./ltib -m distclean
[root@localhost ltib-qs]#./ltib --config
ADD CUSTOMER BSP INTO LTIB MENU
--------------------------------
Steps to Add your new board into LTIB menu (CM-HS1)
01-MAR-2012
1. Add new machine ID for the new board:
Register a machine ID for the new board via http://www.arm.linux.org.uk/developer/machines/ website and then update mach-types.h under /linux_kernel_dir/arch/arm/tools/ to the latest version;
2. Add new board information into the LTIB menus:
a. Make a folder for the new Board Support Package (BSP) under '/ltib/config/platform/'. The folder name should be the same as that defined in main.lkc, i.e., '/ltib/config/platform/gsncomm'. Please refer to 2.c below.
b. Copy all files from an existing Board Support Package (BSP) folder to the new BSP folder. We use the one we did the evaluation, i.e., from 'phy3250';
c. Make necessary changes to main.lkc under new BSP folder '/ltib/config/platform/$NEW_BOARD/'. All contents in main.lkc that are related to CPU and board need to be modified.
d. Create a Linux kernel pre-configuration file, e.g., 'linux-2.6.34-gsncomm.config'. This file can be manually generated by running the LTIB, which has Linux Kernel configuration GUI. 'linux-2.6.34-gsncomm.config' is generated based on 'linux-2.6.34-phy3250.config' with some modifications to mach GridSense Lpc 3240 board. 'linux-2.6.34-gsncomm.config' has to be stored under path '/ltib/config/platform/$NEW_BOARD/'
e. Overwrite the Linux board configuration file 'defconfig' and 'defconfig.dev' under ''/ltib/config/platform/$NEW_BOARD/' with your own board configuration file, in which different Linux kernel pre-configuration file, and installed Linux packages can be defined. New Linux board configuration file can also be generated with the help of LTIB, which has a Linux board configuration GUI. Basically, board configuration file will decide what application will be installed in Linux Root File System (RFS).
3. Add new BSP into to Linux Kernel (here we use lpc32xx based board as example):
a. Add new board choice to Kconfig under '/linux_kernel_src_dir/arch/arm/mach_lpc32xx/'. Add sub menu items if required;
b. Add board level initialisation BSP source code under the folder. It is recommended the main source code file name follow the board name. i.e., BSP source code 'gsncomm.c' under '/linux_kernel_src_dir/arch/arm/mach_lpc32xx/'.
c. Add board level initialisation code file(s) to the Makefile within the folder.
d. Copy Linux kernel pre-configuration file 'linux-2.6.34-gsncomm.config' to folder '/linux_kernel_src_dir/arch/arm/configs/' and rename it to 'gsncomm_defconfig'.
4. Use LTIB menu-based GUI to do further configuration and then build the kernel. Fix any error raised during porting.
CHOOSE CUSTOMER BSP
-------------------------
UPDATE ALL PACKAGES AND PATCHES FROM CVS
---------------------------------------------
Just run"cvs update" in your ltib directory. It'll fetch the updates and in the ltib config you can see the 2.6.34 kernel support.
MISSING NODES UNDER /DEV/
--------------------------------------
Has to change default phytect 'busybox.config', and add support for 'mdev'.
then /rootfs/sbin/mdev will appear and symbol link to busybox.
Make /DEV/ nodes from device_table.txt
If the target architecture is different from the original one, a different cross compiler will be needed. It will be downloaded and installed in the correct location if it isn't already present.
How to add device nodes
Device nodes with static major/minor numbers can be added to the file ltib/bin/device_table.txt. The format is described in the file itself.
Since there is no dependency checking for device_table.txt, after adding a new entry, force rebuild devices to make sure the new /dev nodes are in the file system:
$ ./ltib -p dev -f
MISSING /PROC/DEVICES
-------------------------------
After changing the property of all files under 'etc/rc.d/init.d/', adding 'x' right, problem is solved.
quentin@ubuntu:~/lpc3250/ltib-qs/rootfs$ sudo chmod a+x etc/rc.d/init.d/*
quentin@ubuntu:~/lpc3250/ltib-qs/rootfs$ ll etc/rc.d/init.d/
total 88
drwxr-xr-x 2 root root 4096 2011-06-10 16:56 ./
drwxr-sr-x 3 root root 4096 2011-06-11 08:14 ../
-rw-r--r-- 1 root root 357 2011-06-10 16:56 boa
-rw-r--r-- 1 root root 176 2011-06-10 16:56 depmod
-rw-r--r-- 1 root root 219 2011-06-10 16:56 devfsd
-rw-r--r-- 1 root root 904 2011-06-10 16:56 dhcp
-rw-r--r-- 1 root root 413 2011-06-10 16:56 dhcpd
-rw-r--r-- 1 root root 651 2011-06-10 16:56 dropbear
-rw-r--r-- 1 root root 1299 2011-06-10 16:56 filesystems
-rw-r--r-- 1 root root 183 2011-06-10 16:56 hostname
-rw-r--r-- 1 root root 342 2011-06-10 16:56 inetd
-rw-r--r-- 1 root root 741 2011-06-10 16:56 mdev
-rw-r--r-- 1 root root 165 2011-06-10 16:56 modules
-rw-r--r-- 1 root root 160 2011-06-10 16:56 mount-proc-sys
-rw-r--r-- 1 root root 5229 2011-06-10 16:56 network
-rw-r--r-- 1 root root 346 2011-06-10 16:56 portmap
-rw-r--r-- 1 root root 722 2011-06-10 16:56 settime
-rw-r--r-- 1 root root 279 2011-06-10 16:56 smb
-rw-r--r-- 1 root root 735 2011-06-10 16:56 sshd
-rw-r--r-- 1 root root 502 2011-06-10 16:56 syslog
-rw-r--r-- 1 root root 797 2011-06-10 16:56 udev
[l.lu@localhost ltib]$ ll rootfs/etc/rc.d/init.d/
total 84
-rwxr-xr-x 1 root root 357 2011-06-01 19:02 boa
-rwxr-xr-x 1 root root 176 2011-06-01 19:02 depmod
-rwxr-xr-x 1 root root 219 2011-06-01 19:02 devfsd
-rwxr-xr-x 1 root root 904 2011-06-01 19:02 dhcp
-rwxr-xr-x 1 root root 413 2011-06-01 19:02 dhcpd
-rwxr-xr-x 1 root root 651 2011-06-01 19:02 dropbear
-rwxr-xr-x 1 root root 1299 2011-06-01 19:02 filesystems
-rwxr-xr-x 1 root root 183 2011-06-01 19:02 hostname
-rwxr-xr-x 1 root root 1170 2011-06-01 19:12 hotplug
-rwxr-xr-x 1 root root 342 2011-06-01 19:02 inetd
-rwxr-xr-x 1 root root 741 2011-06-01 19:02 mdev
-rwxr-xr-x 1 root root 165 2011-06-01 19:02 modules
-rwxr-xr-x 1 root root 160 2011-06-01 19:02 mount-proc-sys
-rwxr-xr-x 1 root root 5229 2011-06-01 19:02 network
-rwxr-xr-x 1 root root 346 2011-06-01 19:02 portmap
-rwxr-xr-x 1 root root 722 2011-06-01 19:02 settime
-rwxr-xr-x 1 root root 279 2011-06-01 19:02 smb
-rwxr-xr-x 1 root root 735 2011-06-01 19:02 sshd
-rwxr-xr-x 1 root root 502 2011-06-01 19:02 syslog
-rwxr-xr-x 1 root root 797 2011-06-01 19:02 udev
HOW TO UNINSTALL LTIB
-----------------------------
[2] 在ubuntu系统上,假如ltib已经安装了,我们只需编译、重新配置ltib,
以非root用户登陆,进入ltib所在文件夹,依次输入以下两条命令:
./ltib clean
./ltib -c
即可先后配置linux应用软件包、linux内核。
编译成功后,~/ltib/rootfs/boot目录下,有新编译的内核文件uImage、设备树mpc8315erdb_default.dtb,分别拷贝到/tftpboot目录下。
MULTIPLE LTIB INSTALLATION
-----------------------------------
[1]Can I have more than one root file system on my host at the same time
Yes, the system will support multiple root file systems, for the same or for different target architectures.
If you are using an iso image, install your ltib archive into an different directory by entering a new directory name for the installation when prompted by the install script..
If you are using CVS, check-out CVS into a different directory by using the -d option to cvs co. For example:
ADD FILES TO THE TARGET ROOT FILE SYSTEM
------------------------------------------
[1] Can I add files to the target root file system without creating a package
Yes, to do this, you need to create a merge directory. There are 2 options:
1 Top level merge directory, that applies to all targets 2 Platform specific merge directory
The platform specific merge directory contents override the top level merge directory, which overrides the corresponding file(s) in your rootfs
Example:
You have a CVS version of LTIB, and you have build the tqm823l default configuration, now:
1 You want to add the a platform specific file /home/fred/myfile1 2 You want all platforms you may build to use your own /etc/hosts file
Here's what you would do:
$ cd
$ mkdir -p config/platform/tqm823l/merge/home/fred
$ cp
$ mkdir -p merge/etc
$ cp
$ ./ltib
CHECK LTIB LOCAL CVS REVISION
------------------------------------
[l.lu@localhost ltib]$ cd CVS/
[l.lu@localhost CVS]$ ll
total 16
-rw-rw-rw- 1 l.lu developer 215 2011-05-30 15:28 Entries
-rw-rw-rw- 1 l.lu developer 86 2011-05-30 15:28 Entries.Log
-rw-rw-rw- 1 l.lu developer 5 2011-05-30 15:28 Repository
-rw-rw-rw- 1 l.lu developer 57 2011-05-30 15:28 Root
-rw-rw-rw- 1 l.lu developer 0 2011-05-30 15:28 Template
[l.lu@localhost CVS]$ cat Entries
/.gitignore/1.1.1.2/Wed Mar 18 17:53:24 2009//
/.ltibrc/1.16/Tue Aug 17 18:18:00 2010//
/COPYING/1.1.1.2/Tue Nov 6 15:44:42 2007//
/README/1.1.1.3/Tue Nov 6 15:44:41 2007//
/ltib/1.75/Sat Apr 2 10:56:01 2011//
[l.lu@localhost CVS]$ cat Root
:pserver:anonymous@cvs.savannah.nongnu.org:/sources/ltib
[l.lu@localhost CVS]$ cat Repository
ltib
[l.lu@localhost CVS]$ cat Entries.Log
A D/bin////
A D/config////
A D/dist////
A D/doc////
A D/internal////
R D/internal////
BUILD RFS ROOT FILE SYSTEM
--------------------------------------
------++++check files/folders size under rootfs
[root@localhost ltib]# du -h rootfs/ | grep M
38M rootfs/boot
7.1M rootfs/usr/lib
1.4M rootfs/usr/include/openssl
3.3M rootfs/usr/include
1.1M rootfs/usr/sbin
7.0M rootfs/usr/bin
236K rootfs/usr/share/locale/uk/LC_MESSAGES
32K rootfs/usr/share/locale/ko/LC_MESSAGES
212K rootfs/usr/share/locale/da/LC_MESSAGES
----++++ trimmed unwanted files/folders in rootfs
----++++ force dev table if don't have enough in /rootfs/dev/
[l.lu@localhost ltib]$ ./ltib -p dev -f
Processing platform: Phytec 3250 board with the NXP LPC32XX SoC
=================================================================
using config/platform/phy3250/.config
Processing: dev
=================
Build path taken because: force set, build key set,
rpmbuild --dbpath /home/l.lu/lpc3250/ltib/rootfs//var/lib/rpm --target arm --define '_unpackaged_files_terminate_build 0' --define '_target_cpu arm' --define '__strip strip' --define '_topdir /home/l.lu/lpc3250/ltib/rpm' --define '_prefix /usr' --define '_tmppath /home/l.lu/lpc3250/ltib/tmp' --define '_rpmdir /home/l.lu/lpc3250/ltib/rpm/RPMS' --define '_mandir /usr/share/man' --define '_sysconfdir /etc' --define '_localstatedir /var' -bb --clean --rmsource /home/l.lu/lpc3250/ltib/dist/lfs-5.1/dev/dev.spec
Building target platforms: arm
Building for target arm
Executing(%prep): /bin/sh -e /home/l.lu/lpc3250/ltib/tmp/rpm-tmp.29641
+ umask 022
+ cd /home/l.lu/lpc3250/ltib/rpm/BUILD
+ cd /home/l.lu/lpc3250/ltib/rpm/BUILD
+ rm -rf dev-1.1
+ /bin/gzip -dc /home/l.lu/lpc3250/ltib/rpm/SOURCES/dev-1.1.tar.gz
+ tar -xvvf -
drwxr-xr-x seh/users 0 2005-03-23 22:48 dev-1.1/
-rw-r--r-- seh/users 5643 2005-03-23 06:49 dev-1.1/device_table.txt
-rwxr-xr-x seh/users 2187 2005-03-23 22:43 dev-1.1/mkrpmdev
-rw-r--r-- seh/users 766 2005-03-23 22:48 dev-1.1/dev.spec
-rw-r--r-- seh/users 34 2005-03-23 22:46 dev-1.1/Makefile
-rw-r--r-- seh/users 262 2005-03-23 22:47 dev-1.1/README
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd dev-1.1
+ exit 0
Executing(%build): /bin/sh -e /home/l.lu/lpc3250/ltib/tmp/rpm-tmp.29641
+ umask 022
+ cd /home/l.lu/lpc3250/ltib/rpm/BUILD
+ cd dev-1.1
+ exit 0
Executing(%install): /bin/sh -e /home/l.lu/lpc3250/ltib/tmp/rpm-tmp.29641
+ umask 022
+ cd /home/l.lu/lpc3250/ltib/rpm/BUILD
+ cd dev-1.1
+ rm -rf /home/l.lu/lpc3250/ltib/tmp/dev
+ '[' -f /home/l.lu/lpc3250/ltib/bin/device_table.txt ']'
+ DEV_TABLE=/home/l.lu/lpc3250/ltib/bin/device_table.txt
+ mkdir -p /home/l.lu/lpc3250/ltib/tmp/dev//opt/freescale/rootfs/arm//dev
+ ln -s /var/tmp/log /home/l.lu/lpc3250/ltib/tmp/dev//opt/freescale/rootfs/arm//dev/log
+ ln -s /proc/mounts /home/l.lu/lpc3250/ltib/tmp/dev//opt/freescale/rootfs/arm//dev/mtab
+ PREFIX=/opt/freescale/rootfs/arm/
+ perl mkrpmdev /home/l.lu/lpc3250/ltib/bin/device_table.txt
+ exit 0
Processing files: dev-1.1-1
Finding Provides: (using /opt/ltib/usr/lib/rpm/find-provides)...
Finding Requires: (using /opt/ltib/usr/lib/rpm/find-requires)...
PreReq: rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(CompressedFileNames) <= 3.0.4-1
Requires(rpmlib): rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(CompressedFileNames) <= 3.0.4-1
Wrote: /home/l.lu/lpc3250/ltib/rpm/RPMS/arm/dev-1.1-1.arm.rpm
Executing(%clean): /bin/sh -e /home/l.lu/lpc3250/ltib/tmp/rpm-tmp.98556
+ umask 022
+ cd /home/l.lu/lpc3250/ltib/rpm/BUILD
+ cd dev-1.1
+ rm -rf /home/l.lu/lpc3250/ltib/tmp/dev
+ rm -f /tmp/manifest
+ exit 0
Executing(--clean): /bin/sh -e /home/l.lu/lpc3250/ltib/tmp/rpm-tmp.98556
+ umask 022
+ cd /home/l.lu/lpc3250/ltib/rpm/BUILD
+ rm -rf dev-1.1
+ exit 0
Build time for dev: 2 seconds
sudo /opt/ltib/usr/bin/rpm --root /home/l.lu/lpc3250/ltib/rootfs --dbpath /var/lib/rpm -e --allmatches --nodeps --noscripts --define '_tmppath /tmp/ltib' dev 2>/dev/null
sudo /opt/ltib/usr/bin/rpm --root /home/l.lu/lpc3250/ltib/rootfs --dbpath /var/lib/rpm --prefix / --ignorearch -ivh --force --excludedocs --noscripts --define '_tmppath /tmp/ltib' /home/l.lu/lpc3250/ltib/rpm/RPMS/arm/dev-1.1-1.arm.rpm
error: failed to stat /home/l.lu/.gvfs: Permission denied
Preparing... ########################################### [100%]
1:dev ########################################### [100%]
Processing deployment operations
==================================
making filesystem image file
staging directory is /home/l.lu/lpc3250/ltib/rootfs.tmp
removing the boot directory and files
removing man files and directories
removing info files
removing /usr/src directory
removing /usr/include directory
removing /usr/share/locale directory
removing static libraries
removing target rpm database
stripping binaries and libraries
WARN: /home/l.lu/lpc3250/ltib/rootfs.tmp/sbin/sln statically linked
WARN: /home/l.lu/lpc3250/ltib/rootfs.tmp/sbin/ldconfig statically linked
WARN: /home/l.lu/lpc3250/ltib/rootfs.tmp/bin/busybox statically linked
Filesystem stats, including padding:
Total size = 38408k
Total number of files = 1055
running post build user command: . ../GsnComm_FlashRelease_copyUimgRfsToTftp.sh
cp: cannot stat `/home/l.lu/lpc3250/ltib/rootfs/boot/uImage': No such file or directory
Started: Thu Jun 2 10:40:31 2011
Ended: Thu Jun 2 10:40:57 2011
Elapsed: 26 seconds
Build Succeeded
--------++++Manually generate RFS
mkfs.jffs2 [ -p,--pad[=SIZE] ] [ -r,-d,--root directory ] [ -s,--pagesize=SIZE ] [ -e,--eraseblock=SIZE ] [ -c,--cleanmarker=SIZE ] [ -n,--no-cleanmarkers ] [ -o,--output image.jffs2 ] [ -l,--little-endian ] [ -b,--big-endian ] [ -D,--devtable=FILE ] [ -f,--faketime ] [ -q,--squash ] [ -U,--squash-uids ] [ -P,--squash-perms ] [ --with-xattr ] [ --with-selinux ] [ --with-posix-acl ] [ -m,--compression-mode=MODE ] [ -x,--disable-compressor=NAME ] [ -X,--enable-compressor=NAME ] [ -y,--compressor-priority=PRIORITY:NAME ] [ -L,--list-compressors ] [ -t,--test-compression ] [ -h,--help ] [ -v,--verbose ] [ -V,--version ] [ -i,--incremental image.jffs2 ]
Note: /rootfs/ has to be owned by root, so make sure
#chown -R root:root ./rootfs/ before manually generating RFS.
/opt/ltib/usr/bin/mkfs.jffs2 -n -r rootfs_working -m size -e 16 -o /tftpboot/rootfs.jffs2
[l.lu@localhost ltib]$ /opt/ltib/usr/bin/mkfs.jffs2 -n -r ./rootfs -m size -e 16 -o ./manual_rfs.jffs2
[l.lu@localhost ltib]$ /opt/ltib/usr/bin/mkfs.jffs2 -n -r ./manual_trimmed_rootfs_after-p-dev-f_bkup/rootfs/ -m size -e 16 -o ./manual_rfs.jffs2
use LTIB to build RFS auotmatically
-----------------------------------------------
[3]
$./ltib -m clean
$./ltib -m distclean
Removed whole rootfs folder after '-m distclean'
quentin@ubuntu:~/lpc3250/ltib-qs$ ./ltib -m distclean
You are about remove all the work you have been doing, are you really
sure you want to completely remove files from:
/home/quentin/lpc3250/ltib-qs/rootfs
To continue type in 'yes': yes
Removing target root filesystem
[sudo] password for quentin:
Processing: mkdistclean
=========================
Build path taken because: force set, build key set, no prebuilt rpm,
rpmbuild --dbpath ///home/quentin/lpc3250/ltib-qs/cleanupdb --target i686 --define '_unpackaged_files_terminate_build 0' --define '_target_cpu i686' --define '__strip strip' --define '_topdir /home/quentin/lpc3250/ltib-qs/rpm' --define '_prefix /usr' --define '_tmppath /home/quentin/lpc3250/ltib-qs/tmp' --define '_rpmdir /home/quentin/lpc3250/ltib-qs/rpm/RPMS' --define '_mandir /usr/share/man' --define '_sysconfdir /etc' --define '_localstatedir /var' -bb --clean --rmsource /home/quentin/lpc3250/ltib-qs/dist/lfs-5.1/mkdistclean/mkdistclean.spec
Building target platforms: i686
Building for target i686
Executing(%prep): /bin/sh -e /home/quentin/lpc3250/ltib-qs/tmp/rpm-tmp.46763
+ umask 022
+ cd /home/quentin/lpc3250/ltib-qs/rpm/BUILD
+ exit 0
Executing(%build): /bin/sh -e /home/quentin/lpc3250/ltib-qs/tmp/rpm-tmp.46763
+ umask 022
+ cd /home/quentin/lpc3250/ltib-qs/rpm/BUILD
+ exit 0
Executing(%install): /bin/sh -e /home/quentin/lpc3250/ltib-qs/tmp/rpm-tmp.46763
+ umask 022
+ cd /home/quentin/lpc3250/ltib-qs/rpm/BUILD
+ : /home/quentin/lpc3250/ltib-qs/rootfs
+ '[' '!' -d /home/quentin/lpc3250/ltib-qs/rootfs ']'
+ '[' /home/quentin/lpc3250/ltib-qs/rootfs = / ']'
+ '[' 1000 = 0 ']'
+ '[' '!' -O /home/quentin/lpc3250/ltib-qs/rootfs ']'
+ rm -rf /home/quentin/lpc3250/ltib-qs/tmp/mkdistclean
+ mkdir -p /home/quentin/lpc3250/ltib-qs/tmp/mkdistclean//opt/freescale/rootfs/i686
+ cd /home/quentin/lpc3250/ltib-qs/rootfs
+ set +e
+ find -type d -exec mkdir -p '/home/quentin/lpc3250/ltib-qs/tmp/mkdistclean//opt/freescale/rootfs/i686/{}' ';'
+ find . '!' -type d -exec touch '/home/quentin/lpc3250/ltib-qs/tmp/mkdistclean//opt/freescale/rootfs/i686/{}' ';'
+ exit 0
+ mkdir -p /home/quentin/lpc3250/ltib-qs/tmp/mkdistclean//opt/freescale/rootfs/i686/root/.ssh
+ touch /home/quentin/lpc3250/ltib-qs/tmp/mkdistclean//opt/freescale/rootfs/i686/root/.ssh/known_hosts
+ touch /home/quentin/lpc3250/ltib-qs/tmp/mkdistclean//opt/freescale/rootfs/i686/.ash_history
Processing files: mkdistclean-1.0-1
Finding Provides: (using /opt/ltib/usr/lib/rpm/find-provides)...
Finding Requires: (using /opt/ltib/usr/lib/rpm/find-requires)...
PreReq: rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(CompressedFileNames) <= 3.0.4-1
Requires(rpmlib): rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(CompressedFileNames) <= 3.0.4-1
Wrote: /home/quentin/lpc3250/ltib-qs/rpm/RPMS/i686/mkdistclean-1.0-1.i686.rpm
Executing(%clean): /bin/sh -e /home/quentin/lpc3250/ltib-qs/tmp/rpm-tmp.23031
+ umask 022
+ cd /home/quentin/lpc3250/ltib-qs/rpm/BUILD
+ rm -rf /home/quentin/lpc3250/ltib-qs/tmp/mkdistclean
+ exit 0
Executing(--clean): /bin/sh -e /home/quentin/lpc3250/ltib-qs/tmp/rpm-tmp.23031
+ umask 022
+ cd /home/quentin/lpc3250/ltib-qs/rpm/BUILD
+ exit 0
Build time for mkdistclean: 15 seconds
sudo /opt/ltib/usr/bin/rpm --root / --dbpath /home/quentin/lpc3250/ltib-qs/cleanupdb -e --allmatches --nodeps --noscripts --define '_tmppath /home/quentin/lpc3250/ltib-qs/tmp' mkdistclean 2>/dev/null
sudo /opt/ltib/usr/bin/rpm --root / --dbpath /home/quentin/lpc3250/ltib-qs/cleanupdb --prefix /home/quentin/lpc3250/ltib-qs/rootfs --ignorearch -ivh --force --excludedocs --noscripts --define '_tmppath /home/quentin/lpc3250/ltib-qs/tmp' /home/quentin/lpc3250/ltib-qs/rpm/RPMS/i686/mkdistclean-1.0-1.i686.rpm
error: failed to stat /home/quentin/.gvfs: Permission denied
Preparing... ########################################### [100%]
1:mkdistclean ########################################### [100%]
sudo /opt/ltib/usr/bin/rpm --root / --dbpath /home/quentin/lpc3250/ltib-qs/cleanupdb -e --allmatches --noscripts --define '_tmppath /home/quentin/lpc3250/ltib-qs/tmp' mkdistclean
error: failed to stat /home/quentin/.gvfs: Permission denied
quentin@ubuntu:~/lpc3250/ltib-qs$ ll rootfs_image
lrwxrwxrwx 1 quentin developer 14 2011-05-31 11:05 rootfs_image -> ./rootfs.jffs2
quentin@ubuntu:~/lpc3250/ltib-qs$ ll
total 288
drwxrwxrwx 8 quentin quentin 4096 2011-06-01 08:52 ./
drwxr-xr-x 4 quentin quentin 4096 2011-05-26 12:37 ../
-rwxr--r-- 1 quentin quentin 886 2011-05-25 11:55 2869_ltib.patch*
drwxrwxrwx 3 quentin quentin 4096 2011-06-01 08:52 bin/
drwxrwxrwx 7 quentin quentin 4096 2011-06-01 08:52 config/
-rw-rw-rw- 1 quentin quentin 17989 2007-11-07 02:44 COPYING
drwxrwxrwx 2 quentin quentin 4096 2011-05-24 14:50 CVS/
drwxrwxrwx 4 quentin quentin 4096 2011-05-24 14:50 dist/
drwxrwxrwx 3 quentin quentin 4096 2011-05-24 14:50 doc/
-rw-rw-rw- 1 quentin quentin 436 2009-03-19 04:53 .gitignore
-rwxrwxrwx 1 quentin quentin 110719 2011-05-25 11:57 ltib*
-rwxrwxrwx 1 quentin quentin 110337 2011-04-02 21:56 ltib.orig*
-rw-rw-rw- 1 quentin quentin 2579 2010-08-18 04:18 .ltibrc
-rw-rw-rw- 1 quentin quentin 952 2007-11-07 02:44 README
lrwxrwxrwx 1 quentin developer 14 2011-05-31 11:05 rootfs_image -> ./rootfs.jffs2
drwxrwsr-x 3 quentin quentin 4096 2011-06-01 08:52 rpm/
quentin@ubuntu:~/lpc3250/ltib-qs$
NOTES FROM LtibConvertPcsBsp
-----------------------------------------
-----+++ Deploying the BSP
The primary deployment mechanism in ltib is expected to be NFS. By
default ltib will build a root filesystem suitable for exporting as
a root filesystem in ~/ltib/rootfs . It is the user's responsibility
to export this directory and setup the bootloader parameters to
use this. Note that the built kernel can be located in ~/ltib/rootfs/boot
---++ Saving your work
Once you have booted your board and are happy to check in your work,
you need to do the following:
* copy the updated .config to defconfig
* checking ltib changes to CVS
* copy new source files to the GPP
Machine ID Management.
[1] http://www.arm.linux.org.uk/developer/machines/list.php?id=3185
/linux-2.6.34/arch/arm/tools/mach-types will list all supported ARM machine ID.
/linux-2.6.34/arch/arm/tools/mach-types will list all supported ARM machine ID.
Necessary Package List
[1] ipcrm http://en.wikipedia.org/wiki/Ipcrm
[*] util_linux include support of 'ipcrm'
[*] util_linux include support of 'ipcrm'
Tuesday, November 16, 2010
Bash_Prog while loop and Delay
[1] http://www.faqs.org/docs/bashman/bashref_68.html
#!/bin/bash
var0=0
LIMIT=10
while [ ! -a /dev/ttyUSB3 ]
#while [ -a /dev/tty6 ]
do
echo "checking /dev/ttyUSB3 " # -n suppresses newline.
sleep 3
done
#exit 1
#!/bin/bash
var0=0
LIMIT=10
while [ ! -a /dev/ttyUSB3 ]
#while [ -a /dev/tty6 ]
do
echo "checking /dev/ttyUSB3 " # -n suppresses newline.
sleep 3
done
#exit 1
Monday, November 15, 2010
GPIO Access from user space.
[1] http://www.avrfreaks.net/wiki/index.php/Documentation:Linux/GPIO#Getting_access_to_a_GPIO
CREATE 'gpo06' FOR USER SPACE GPIO ACCESS
------------------------------------------------
[root@GsnCommsModule user]# echo "85" > /sys/class/gpio/export
[root@GsnCommsModule user]# ls /sys/class/gpio/
export gpiochip32 gpiochip51 gpiochip8 unexport
gpiochip0 gpiochip45 gpiochip79 gpo06
[root@GsnCommsModule user]#
CREATE 'gpo06' FOR USER SPACE GPIO ACCESS
------------------------------------------------
[root@GsnCommsModule user]# echo "85" > /sys/class/gpio/export
[root@GsnCommsModule user]# ls /sys/class/gpio/
export gpiochip32 gpiochip51 gpiochip8 unexport
gpiochip0 gpiochip45 gpiochip79 gpo06
[root@GsnCommsModule user]#
Thursday, November 11, 2010
TFTP and NFS server set up
[1] http://rpm.pbone.net/index.php3/stat/4/idpl/13694850/dir/fedora_9/com/tftp-server-0.48-6.fc9.i386.rpm.html
[2] https://help.ubuntu.com/community/SettingUpNFSHowTo ---- NFS setting under UBUNTU
[3] https://help.ubuntu.com/8.04/serverguide/C/network-file-system.html --- NFS Setting
[4] Fail to put file to TFTP server answer
Ip address range should be listed in format below:
###########################
#TFTP Server Set UP.
###########################
CHECK WHETHER TFTP PACKAGE IS INSTALLED
-------------------------------------------
[q.yang@localhost ~]$ rpm -q tftp-server
tftp-server-0.48-6.fc9.i386
INSTALL TFTP FROM RPM
------------------------------
Download it from [1]
Download Tftp dependancy xinetd-2.3.14-20.fc9.i386 from [1]
[root@localhost q.yang]# rpm -ivh Download/xinetd-2.3.14-20.fc9.i386.rpm
warning: Download/xinetd-2.3.14-20.fc9.i386.rpm: Header V3 DSA signature: NOKEY, key ID 6df2196f
Preparing... ########################################### [100%]
1:xinetd ########################################### [100%]
[root@localhost q.yang]# rpm -ivh Download/tftp-server-0.48-6.fc9.i386.rpm
warning: Download/tftp-server-0.48-6.fc9.i386.rpm: Header V3 DSA signature: NOKEY, key ID 6df2196f
Preparing... ########################################### [100%]
1:tftp-server ########################################### [100%]
[root@localhost q.yang]# rpm -q tftp-server
tftp-server-0.48-6.fc9.i386
[root@localhost q.yang]# chkconfig tftp on
[root@localhost ~]# vi /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A INPUT -m state --state NEW -m udp -p udp --dport 69 -j ACCEPT
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
[root@localhost ~]# service iptables restart
Alternatively using GUI to manage firmwall:
[root@localhost ~]# chkconfig tftp on
[root@localhost ltib-qs]# service xinetd restart
#show whether tftp is running.
[root@localhost ltib-qs]# netstat -a | grep udp
[root@localhost ~]# chown q.yang /var/lib/tftpboot
[root@localhost ~]# chgrp users /var/lib/tftpboot
alternatively:
[root@localhost q.yang]# chown q.yang:developer /var/lib/tftpboot/
[root@localhost q.yang]# chmod g+w /var/lib/tftpboot/
drwxrwxr-x 2 q.yang developer 4096 2008-05-22 07:55 tftpboot
VARIFY TFTP SERVER IS WORKING FROM WINDOWS
--------------------------------------------
Using Tftp command under windows console
PERMISSION ERROR WHEN WRITE FILE INTO TFTP SERVER
--------------------------------------
#chmod 777 /var/lib/tftpboot
RESTART TFTP SERVER
---------------------
[root@localhost ltib-qs]# service xinetd restart
FAIL TO PUT FILE TO TFTP SERVER [4]
----------------------------------
check the /etc/xinetd.d/tftp file..
change:
server_args = -s /tftpboot
to:
server_args = -c -s /tftpboot
“-c” allows the creation of new file
##################################
# NFS Server set up under UBUNTU
###################################
[3] [2]
quentin@ubuntu:~/CodeSourcery/arm-2010q1$ sudo apt-get install nfs-kernel-server
............
............
quentin@ubuntu:~/CodeSourcery/arm-2010q1$ sudo vi /etc/exports
quentin@ubuntu:~/CodeSourcery/arm-2010q1$ sudo /etc/init.d/nfs-kernel-server start
* Exporting directories for NFS kernel daemon... [ OK ]
* Starting NFS kernel daemon [ OK ]
$ sudo service nfs-kernel-server start
* Exporting directories for NFS kernel daemon... [ OK ]
* Starting NFS kernel daemon [ OK ]
#########################
# NFS Server set up
#######################
INSTALL NFS-UTILS RPCBIND RPM PACKAGE IF NOT INSTALLED
--------------------------------------------------------
#rpm -q nfs-utils To check whether nfs-utils installed.
INSTALL NFS-UTILS AND RPCBIND VIA YUM
-------------------------------------
Note:Not latest rpm is detected by yum due to yum package is old.
[root@localhost q.yang]# yum install nfs-utils rpcbind
Loaded plugins: refresh-packagekit
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package rpcbind.i386 0:0.1.4-14.fc9 set to be updated
---> Package nfs-utils.i386 1:1.1.2-2.fc9 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
nfs-utils i386 1:1.1.2-2.fc9 fedora 291 k
rpcbind i386 0.1.4-14.fc9 fedora 48 k
Transaction Summary
=============================================================================
Install 2 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 339 k
Is this ok [y/N]: y
.....................
.....................
CREATE NFS SHARE
-----------------------
-- Option 1: --
You can edit /etc/exports file as follows:
[root@localhost ~]# vi /etc/exports
[q.yang@localhost ~]$ cat /etc/exports
/home/q.yang/Desktop 10.10.20.70(rw,insecure,sync,no_root_squash)
/home/q.yang/lpc3250/ltib-qs/rootfs 10.10.20.88(rw,no_root_squash,no_subtree_check,sync)
/home/q.yang/lpc3250/rootfs4Luke 10.10.20.90(rw,no_root_squash,no_subtree_check,sync)
-- Option 2: --
Using NFS GUI (need install yp-tools.i386 0:2.9-3 ypbind.i386 3:1.20.4-6.fc9 two packages)
START NFS, RPCBIND SERVICE
------------------------------
[root@localhost eclipse]# service rpcbind start
Starting rpcbind: [ OK ]
[root@localhost eclipse]# service nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]
CHECK WHETHER NFS IS RUNNING
-----------------------------------
You should see portmapper and nfs running as below. If not try
#service nfs restart
[root@localhost ~]# rpcinfo -p
program vers proto port service
100000 4 tcp 111 portmapper
100000 3 tcp 111 portmapper
100000 2 tcp 111 portmapper
100000 4 udp 111 portmapper
100000 3 udp 111 portmapper
100000 2 udp 111 portmapper
100000 4 0 111 portmapper
100000 3 0 111 portmapper
100000 2 0 111 portmapper
100011 1 udp 1016 rquotad
100011 2 udp 1016 rquotad
100011 1 tcp 1019 rquotad
100011 2 tcp 1019 rquotad
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
100003 4 udp 2049 nfs
100021 1 udp 56276 nlockmgr
100021 3 udp 56276 nlockmgr
100021 4 udp 56276 nlockmgr
100003 2 tcp 2049 nfs
100003 3 tcp 2049 nfs
100003 4 tcp 2049 nfs
100021 1 tcp 39972 nlockmgr
100021 3 tcp 39972 nlockmgr
100021 4 tcp 39972 nlockmgr
100005 1 udp 54842 mountd
100005 1 tcp 59798 mountd
100005 2 udp 54842 mountd
100005 2 tcp 59798 mountd
100005 3 udp 54842 mountd
100005 3 tcp 59798 mountd
CHECK WHETHER NFS IS RUNNING FROM ANOTHER LINUX PC
--------------------------------------------------
On Linux PC B(10.10.20.70):
[root@localhost q.yang]# mount -t nfs 10.10.20.35:/home/q.yang/Desktop /mnt/nfstest/
[root@localhost q.yang]# ll /mnt/nfstest/
total 12
-rw-r--r-- 1 q.yang 500 5559 2010-06-03 17:23 gnome-terminal.desktop
On Linux PC A (10.10.20.35)
[q.yang@localhost ~]$ cat /etc/exports
/home/q.yang/Desktop 10.10.20.70(rw,insecure,sync,no_root_squash)
NFS TROUBLE SHOOTING
-------------------------------------
Fail to connect NFS due to firewall
-----------------------------------
1. Upgrade system-config-firewall/system-config-firewall-tui rpm package so that
correct /etc/sysconfig/iptables, /etc/sysconfig/iptables-config can be generated.
2. Disable firewall.
UPGRADE FIREWALL RPM PACKAGE MANUALLY
----------------------------------------
The files modified and generated as a result of system-config-firewall (system-config-firewall-1.2.16-3.fc9.noarch.rpm)
[root@localhost eclipse]# ll /etc/sysconfig/ |grep ip
-rw------- 1 root root 1753 2011-02-25 14:32 ip6tables-config
-rw------- 1 root root 1740 2011-02-25 14:32 iptables-config
-rw------- 1 root root 1776 2011-02-24 15:25 ip6tables-config.old
-rw------- 1 root root 1876 2011-02-24 15:10 ip6tables.old
-rw------- 1 root root 1763 2011-02-24 15:25 iptables-config.old
-rw------- 1 root root 1871 2011-02-24 15:10 iptables.old
YUM COULDN'T FIND LATEST FIREWALL RPM PACKAGE
[root@localhost eclipse]# yum install system-config-firewall
Loaded plugins: refresh-packagekit
updates | 2.6 kB 00:00
fedora | 2.4 kB 00:00
Setting up Install Process
Parsing package install arguments
Package system-config-firewall-1.2.7-1.fc9.noarch already installed and latest version
Nothing to do
[root@localhost eclipse]# rpm -U /home/q.yang/Download/system-config-firewall-1.2.16-3.fc9.noarch.rpm
warning: /home/q.yang/Download/system-config-firewall-1.2.16-3.fc9.noarch.rpm: Header V3 DSA signature: NOKEY, key ID df9b0ae9
error: Failed dependencies:
system-config-firewall-tui = 1.2.16-3.fc9 is needed by system-config-firewall-1.2.16-3.fc9.noarch
[root@localhost eclipse]# rpm -U /home/q.yang/Download/system-config-firewall-tui-1.2.16-3.fc9.noarch.rpm
warning: /home/q.yang/Download/system-config-firewall-tui-1.2.16-3.fc9.noarch.rpm: Header V3 DSA signature: NOKEY, key ID df9b0ae9
error: Failed dependencies:
system-config-firewall-tui = 1.2.7-1.fc9 is needed by (installed) system-config-firewall-1.2.7-1.fc9.noarch
[root@localhost eclipse]# rpm -q system-config-firewall-tui
system-config-firewall-tui-1.2.7-1.fc9.noarch
REMOVE EXISTING FIREWALL RPM PACKAGE
[root@localhost eclipse]# rpm -e system-config-firewall-tui
error: Failed dependencies:
system-config-firewall-tui = 1.2.7-1.fc9 is needed by (installed) system-config-firewall-1.2.7-1.fc9.noarch
[root@localhost eclipse]# rpm -e system-config-firewall
[root@localhost eclipse]# rpm -e system-config-firewall-tui
MANUALLY INSTALL FIREWALL RPM PACKAGE
[root@localhost eclipse]# rpm -ivh /home/q.yang/Download/system-config-firewall-1.2.16-3.fc9.noarch.rpm
warning: /home/q.yang/Download/system-config-firewall-1.2.16-3.fc9.noarch.rpm: Header V3 DSA signature: NOKEY, key ID df9b0ae9
error: Failed dependencies:
system-config-firewall-tui = 1.2.16-3.fc9 is needed by system-config-firewall-1.2.16-3.fc9.noarch
[root@localhost eclipse]# rpm -ivh /home/q.yang/Download/system-config-firewall-tui-1.2.16-3.fc9.noarch.rpm
warning: /home/q.yang/Download/system-config-firewall-tui-1.2.16-3.fc9.noarch.rpm: Header V3 DSA signature: NOKEY, key ID df9b0ae9
Preparing... ########################################### [100%]
1:system-config-firewall-########################################### [100%]
[root@localhost eclipse]# rpm -ivh /home/q.yang/Download/system-config-firewall-1.2.16-3.fc9.noarch.rpm
warning: /home/q.yang/Download/system-config-firewall-1.2.16-3.fc9.noarch.rpm: Header V3 DSA signature: NOKEY, key ID df9b0ae9
Preparing... ########################################### [100%]
1:system-config-firewall ########################################### [100%]
CHECK FIREWALL FROM COMMAND LINE
-------------------------------------
[root@localhost eclipse]# iptables -L |more
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT icmp -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:nfs
ACCEPT udp -- anywhere anywhere state NEW udp dpt:nfs
ACCEPT udp -- anywhere anywhere state NEW udp dpt:netbios-ns
ACCEPT udp -- anywhere anywhere state NEW udp dpt:netbios-dgm
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:netbios-ssn
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:microsoft-ds
...................
..................
IF NFS FAILURE IS DUE TO OLD NFS-UTILS RPCBIND RPM PACKAGE
----------------------------------------------------------
REMOVE AND INSTALL NEW PACKAGE VIA YUM
-----------------------------------------
[root@localhost eclipse]# yum erase rpcbind
Loaded plugins: refresh-packagekit
Setting up Remove Process
updates | 2.6 kB 00:00
fedora | 2.4 kB 00:00
Resolving Dependencies
--> Running transaction check
---> Package rpcbind.i386 0:0.1.7-1.fc9 set to be erased
--> Processing Dependency: rpcbind for package: nfs-utils
--> Processing Dependency: rpcbind for package: ypbind
--> Running transaction check
---> Package nfs-utils.i386 1:1.1.2-2.fc9 set to be erased
---> Package ypbind.i386 3:1.20.4-6.fc9 set to be erased
--> Processing Dependency: ypbind for package: yp-tools
--> Running transaction check
---> Package yp-tools.i386 0:2.9-3 set to be erased
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Removing:
rpcbind i386 0.1.7-1.fc9 installed 90 k
Removing for dependencies:
nfs-utils i386 1:1.1.2-2.fc9 installed 555 k
yp-tools i386 2.9-3 installed 151 k
ypbind i386 3:1.20.4-6.fc9 installed 64 k
Transaction Summary
=============================================================================
Install 0 Package(s)
Update 0 Package(s)
Remove 4 Package(s)
Is this ok [y/N]:
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Shutting down NFS mountd: [ OK ]
Shutting down NFS daemon: [ OK ]
Shutting down NFS quotas: [ OK ]
Shutting down NFS services: [ OK ]
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]
Stopping RPC idmapd: [ OK ]
Starting RPC idmapd: [ OK ]
Erasing : nfs-utils ######################### [1/4]
warning: /var/lib/nfs/state saved as /var/lib/nfs/state.rpmsave
warning: /var/lib/nfs/etab saved as /var/lib/nfs/etab.rpmsave
Erasing : rpcbind ######################### [2/4]
Erasing : yp-tools ######################### [3/4]
Erasing : ypbind ######################### [4/4]
Removed: rpcbind.i386 0:0.1.7-1.fc9
Dependency Removed: nfs-utils.i386 1:1.1.2-2.fc9 yp-tools.i386 0:2.9-3 ypbind.i386 3:1.20.4-6.fc9
Complete!
[root@localhost eclipse]# rpm -q rpcbind
package rpcbind is not installed
[root@localhost eclipse]# yum install nfs-utils rpcbind
Loaded plugins: refresh-packagekit
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package rpcbind.i386 0:0.1.4-14.fc9 set to be updated
---> Package nfs-utils.i386 1:1.1.2-2.fc9 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
nfs-utils i386 1:1.1.2-2.fc9 fedora 291 k
rpcbind i386 0.1.4-14.fc9 fedora 48 k
Transaction Summary
=============================================================================
Install 2 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 339 k
Is this ok [y/N]: y
[2] https://help.ubuntu.com/community/SettingUpNFSHowTo ---- NFS setting under UBUNTU
[3] https://help.ubuntu.com/8.04/serverguide/C/network-file-system.html --- NFS Setting
[4] Fail to put file to TFTP server answer
Ip address range should be listed in format below:
192.168.1.0/28 192.168.1.0 - 192.168.1.15 192.168.1.16/28 192.168.1.16 - 192.168.1.31 192.168.1.32/27 192.168.1.32 - 192.168.1.63 192.168.1.64/26 192.168.1.64 - 192.168.1.127 192.168.1.128/25 192.168.1.128 - 192.168.1.255
###########################
#TFTP Server Set UP.
###########################
CHECK WHETHER TFTP PACKAGE IS INSTALLED
-------------------------------------------
[q.yang@localhost ~]$ rpm -q tftp-server
tftp-server-0.48-6.fc9.i386
INSTALL TFTP FROM RPM
------------------------------
Download it from [1]
Download Tftp dependancy xinetd-2.3.14-20.fc9.i386 from [1]
[root@localhost q.yang]# rpm -ivh Download/xinetd-2.3.14-20.fc9.i386.rpm
warning: Download/xinetd-2.3.14-20.fc9.i386.rpm: Header V3 DSA signature: NOKEY, key ID 6df2196f
Preparing... ########################################### [100%]
1:xinetd ########################################### [100%]
[root@localhost q.yang]# rpm -ivh Download/tftp-server-0.48-6.fc9.i386.rpm
warning: Download/tftp-server-0.48-6.fc9.i386.rpm: Header V3 DSA signature: NOKEY, key ID 6df2196f
Preparing... ########################################### [100%]
1:tftp-server ########################################### [100%]
[root@localhost q.yang]# rpm -q tftp-server
tftp-server-0.48-6.fc9.i386
[root@localhost q.yang]# chkconfig tftp on
[root@localhost ~]# vi /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A INPUT -m state --state NEW -m udp -p udp --dport 69 -j ACCEPT
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
[root@localhost ~]# service iptables restart
Alternatively using GUI to manage firmwall:
[root@localhost ~]# chkconfig tftp on
[root@localhost ltib-qs]# service xinetd restart
#show whether tftp is running.
[root@localhost ltib-qs]# netstat -a | grep udp
[root@localhost ~]# chown q.yang /var/lib/tftpboot
[root@localhost ~]# chgrp users /var/lib/tftpboot
alternatively:
[root@localhost q.yang]# chown q.yang:developer /var/lib/tftpboot/
[root@localhost q.yang]# chmod g+w /var/lib/tftpboot/
drwxrwxr-x 2 q.yang developer 4096 2008-05-22 07:55 tftpboot
VARIFY TFTP SERVER IS WORKING FROM WINDOWS
--------------------------------------------
Using Tftp command under windows console
PERMISSION ERROR WHEN WRITE FILE INTO TFTP SERVER
--------------------------------------
#chmod 777 /var/lib/tftpboot
RESTART TFTP SERVER
---------------------
[root@localhost ltib-qs]# service xinetd restart
FAIL TO PUT FILE TO TFTP SERVER [4]
----------------------------------
check the /etc/xinetd.d/tftp file..
change:
server_args = -s /tftpboot
to:
server_args = -c -s /tftpboot
“-c” allows the creation of new file
##################################
# NFS Server set up under UBUNTU
###################################
[3] [2]
quentin@ubuntu:~/CodeSourcery/arm-2010q1$ sudo apt-get install nfs-kernel-server
............
............
quentin@ubuntu:~/CodeSourcery/arm-2010q1$ sudo vi /etc/exports
quentin@ubuntu:~/CodeSourcery/arm-2010q1$ sudo /etc/init.d/nfs-kernel-server start
* Exporting directories for NFS kernel daemon... [ OK ]
* Starting NFS kernel daemon [ OK ]
$ sudo service nfs-kernel-server start
* Exporting directories for NFS kernel daemon... [ OK ]
* Starting NFS kernel daemon [ OK ]
#########################
# NFS Server set up
#######################
INSTALL NFS-UTILS RPCBIND RPM PACKAGE IF NOT INSTALLED
--------------------------------------------------------
#rpm -q nfs-utils To check whether nfs-utils installed.
INSTALL NFS-UTILS AND RPCBIND VIA YUM
-------------------------------------
Note:Not latest rpm is detected by yum due to yum package is old.
[root@localhost q.yang]# yum install nfs-utils rpcbind
Loaded plugins: refresh-packagekit
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package rpcbind.i386 0:0.1.4-14.fc9 set to be updated
---> Package nfs-utils.i386 1:1.1.2-2.fc9 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
nfs-utils i386 1:1.1.2-2.fc9 fedora 291 k
rpcbind i386 0.1.4-14.fc9 fedora 48 k
Transaction Summary
=============================================================================
Install 2 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 339 k
Is this ok [y/N]: y
.....................
.....................
CREATE NFS SHARE
-----------------------
-- Option 1: --
You can edit /etc/exports file as follows:
[root@localhost ~]# vi /etc/exports
[q.yang@localhost ~]$ cat /etc/exports
/home/q.yang/Desktop 10.10.20.70(rw,insecure,sync,no_root_squash)
/home/q.yang/lpc3250/ltib-qs/rootfs 10.10.20.88(rw,no_root_squash,no_subtree_check,sync)
/home/q.yang/lpc3250/rootfs4Luke 10.10.20.90(rw,no_root_squash,no_subtree_check,sync)
-- Option 2: --
Using NFS GUI (need install yp-tools.i386 0:2.9-3 ypbind.i386 3:1.20.4-6.fc9 two packages)
START NFS, RPCBIND SERVICE
------------------------------
[root@localhost eclipse]# service rpcbind start
Starting rpcbind: [ OK ]
[root@localhost eclipse]# service nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]
CHECK WHETHER NFS IS RUNNING
-----------------------------------
You should see portmapper and nfs running as below. If not try
#service nfs restart
[root@localhost ~]# rpcinfo -p
program vers proto port service
100000 4 tcp 111 portmapper
100000 3 tcp 111 portmapper
100000 2 tcp 111 portmapper
100000 4 udp 111 portmapper
100000 3 udp 111 portmapper
100000 2 udp 111 portmapper
100000 4 0 111 portmapper
100000 3 0 111 portmapper
100000 2 0 111 portmapper
100011 1 udp 1016 rquotad
100011 2 udp 1016 rquotad
100011 1 tcp 1019 rquotad
100011 2 tcp 1019 rquotad
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
100003 4 udp 2049 nfs
100021 1 udp 56276 nlockmgr
100021 3 udp 56276 nlockmgr
100021 4 udp 56276 nlockmgr
100003 2 tcp 2049 nfs
100003 3 tcp 2049 nfs
100003 4 tcp 2049 nfs
100021 1 tcp 39972 nlockmgr
100021 3 tcp 39972 nlockmgr
100021 4 tcp 39972 nlockmgr
100005 1 udp 54842 mountd
100005 1 tcp 59798 mountd
100005 2 udp 54842 mountd
100005 2 tcp 59798 mountd
100005 3 udp 54842 mountd
100005 3 tcp 59798 mountd
CHECK WHETHER NFS IS RUNNING FROM ANOTHER LINUX PC
--------------------------------------------------
On Linux PC B(10.10.20.70):
[root@localhost q.yang]# mount -t nfs 10.10.20.35:/home/q.yang/Desktop /mnt/nfstest/
[root@localhost q.yang]# ll /mnt/nfstest/
total 12
-rw-r--r-- 1 q.yang 500 5559 2010-06-03 17:23 gnome-terminal.desktop
On Linux PC A (10.10.20.35)
[q.yang@localhost ~]$ cat /etc/exports
/home/q.yang/Desktop 10.10.20.70(rw,insecure,sync,no_root_squash)
NFS TROUBLE SHOOTING
-------------------------------------
Fail to connect NFS due to firewall
-----------------------------------
1. Upgrade system-config-firewall/system-config-firewall-tui rpm package so that
correct /etc/sysconfig/iptables, /etc/sysconfig/iptables-config can be generated.
2. Disable firewall.
UPGRADE FIREWALL RPM PACKAGE MANUALLY
----------------------------------------
The files modified and generated as a result of system-config-firewall (system-config-firewall-1.2.16-3.fc9.noarch.rpm)
[root@localhost eclipse]# ll /etc/sysconfig/ |grep ip
-rw------- 1 root root 1753 2011-02-25 14:32 ip6tables-config
-rw------- 1 root root 1740 2011-02-25 14:32 iptables-config
-rw------- 1 root root 1776 2011-02-24 15:25 ip6tables-config.old
-rw------- 1 root root 1876 2011-02-24 15:10 ip6tables.old
-rw------- 1 root root 1763 2011-02-24 15:25 iptables-config.old
-rw------- 1 root root 1871 2011-02-24 15:10 iptables.old
YUM COULDN'T FIND LATEST FIREWALL RPM PACKAGE
[root@localhost eclipse]# yum install system-config-firewall
Loaded plugins: refresh-packagekit
updates | 2.6 kB 00:00
fedora | 2.4 kB 00:00
Setting up Install Process
Parsing package install arguments
Package system-config-firewall-1.2.7-1.fc9.noarch already installed and latest version
Nothing to do
[root@localhost eclipse]# rpm -U /home/q.yang/Download/system-config-firewall-1.2.16-3.fc9.noarch.rpm
warning: /home/q.yang/Download/system-config-firewall-1.2.16-3.fc9.noarch.rpm: Header V3 DSA signature: NOKEY, key ID df9b0ae9
error: Failed dependencies:
system-config-firewall-tui = 1.2.16-3.fc9 is needed by system-config-firewall-1.2.16-3.fc9.noarch
[root@localhost eclipse]# rpm -U /home/q.yang/Download/system-config-firewall-tui-1.2.16-3.fc9.noarch.rpm
warning: /home/q.yang/Download/system-config-firewall-tui-1.2.16-3.fc9.noarch.rpm: Header V3 DSA signature: NOKEY, key ID df9b0ae9
error: Failed dependencies:
system-config-firewall-tui = 1.2.7-1.fc9 is needed by (installed) system-config-firewall-1.2.7-1.fc9.noarch
[root@localhost eclipse]# rpm -q system-config-firewall-tui
system-config-firewall-tui-1.2.7-1.fc9.noarch
REMOVE EXISTING FIREWALL RPM PACKAGE
[root@localhost eclipse]# rpm -e system-config-firewall-tui
error: Failed dependencies:
system-config-firewall-tui = 1.2.7-1.fc9 is needed by (installed) system-config-firewall-1.2.7-1.fc9.noarch
[root@localhost eclipse]# rpm -e system-config-firewall
[root@localhost eclipse]# rpm -e system-config-firewall-tui
MANUALLY INSTALL FIREWALL RPM PACKAGE
[root@localhost eclipse]# rpm -ivh /home/q.yang/Download/system-config-firewall-1.2.16-3.fc9.noarch.rpm
warning: /home/q.yang/Download/system-config-firewall-1.2.16-3.fc9.noarch.rpm: Header V3 DSA signature: NOKEY, key ID df9b0ae9
error: Failed dependencies:
system-config-firewall-tui = 1.2.16-3.fc9 is needed by system-config-firewall-1.2.16-3.fc9.noarch
[root@localhost eclipse]# rpm -ivh /home/q.yang/Download/system-config-firewall-tui-1.2.16-3.fc9.noarch.rpm
warning: /home/q.yang/Download/system-config-firewall-tui-1.2.16-3.fc9.noarch.rpm: Header V3 DSA signature: NOKEY, key ID df9b0ae9
Preparing... ########################################### [100%]
1:system-config-firewall-########################################### [100%]
[root@localhost eclipse]# rpm -ivh /home/q.yang/Download/system-config-firewall-1.2.16-3.fc9.noarch.rpm
warning: /home/q.yang/Download/system-config-firewall-1.2.16-3.fc9.noarch.rpm: Header V3 DSA signature: NOKEY, key ID df9b0ae9
Preparing... ########################################### [100%]
1:system-config-firewall ########################################### [100%]
CHECK FIREWALL FROM COMMAND LINE
-------------------------------------
[root@localhost eclipse]# iptables -L |more
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT icmp -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:nfs
ACCEPT udp -- anywhere anywhere state NEW udp dpt:nfs
ACCEPT udp -- anywhere anywhere state NEW udp dpt:netbios-ns
ACCEPT udp -- anywhere anywhere state NEW udp dpt:netbios-dgm
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:netbios-ssn
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:microsoft-ds
...................
..................
IF NFS FAILURE IS DUE TO OLD NFS-UTILS RPCBIND RPM PACKAGE
----------------------------------------------------------
REMOVE AND INSTALL NEW PACKAGE VIA YUM
-----------------------------------------
[root@localhost eclipse]# yum erase rpcbind
Loaded plugins: refresh-packagekit
Setting up Remove Process
updates | 2.6 kB 00:00
fedora | 2.4 kB 00:00
Resolving Dependencies
--> Running transaction check
---> Package rpcbind.i386 0:0.1.7-1.fc9 set to be erased
--> Processing Dependency: rpcbind for package: nfs-utils
--> Processing Dependency: rpcbind for package: ypbind
--> Running transaction check
---> Package nfs-utils.i386 1:1.1.2-2.fc9 set to be erased
---> Package ypbind.i386 3:1.20.4-6.fc9 set to be erased
--> Processing Dependency: ypbind for package: yp-tools
--> Running transaction check
---> Package yp-tools.i386 0:2.9-3 set to be erased
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Removing:
rpcbind i386 0.1.7-1.fc9 installed 90 k
Removing for dependencies:
nfs-utils i386 1:1.1.2-2.fc9 installed 555 k
yp-tools i386 2.9-3 installed 151 k
ypbind i386 3:1.20.4-6.fc9 installed 64 k
Transaction Summary
=============================================================================
Install 0 Package(s)
Update 0 Package(s)
Remove 4 Package(s)
Is this ok [y/N]:
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Shutting down NFS mountd: [ OK ]
Shutting down NFS daemon: [ OK ]
Shutting down NFS quotas: [ OK ]
Shutting down NFS services: [ OK ]
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]
Stopping RPC idmapd: [ OK ]
Starting RPC idmapd: [ OK ]
Erasing : nfs-utils ######################### [1/4]
warning: /var/lib/nfs/state saved as /var/lib/nfs/state.rpmsave
warning: /var/lib/nfs/etab saved as /var/lib/nfs/etab.rpmsave
Erasing : rpcbind ######################### [2/4]
Erasing : yp-tools ######################### [3/4]
Erasing : ypbind ######################### [4/4]
Removed: rpcbind.i386 0:0.1.7-1.fc9
Dependency Removed: nfs-utils.i386 1:1.1.2-2.fc9 yp-tools.i386 0:2.9-3 ypbind.i386 3:1.20.4-6.fc9
Complete!
[root@localhost eclipse]# rpm -q rpcbind
package rpcbind is not installed
[root@localhost eclipse]# yum install nfs-utils rpcbind
Loaded plugins: refresh-packagekit
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package rpcbind.i386 0:0.1.4-14.fc9 set to be updated
---> Package nfs-utils.i386 1:1.1.2-2.fc9 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
nfs-utils i386 1:1.1.2-2.fc9 fedora 291 k
rpcbind i386 0.1.4-14.fc9 fedora 48 k
Transaction Summary
=============================================================================
Install 2 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 339 k
Is this ok [y/N]: y
Uboot Env -- Original and Newly build
ORIGINAL U-Boot 1.3.3 (Apr 10 2009 - 09:21:30)
----------------------------------------------------
uboot> printenv
bootdelay=3
baudrate=115200
bootfile=uImage
bootargs=console=ttyS0,115200n81 root=/dev/mtdblock3 rw rootfstype=jffs2 init=/sbin/init
flash_kernel=nand erase 0x190000 0x270000; nand write.jffs2 0x80100000 0x190000 0x1a0000
flash_rootfs=nand erase 0x590000 0x3a70000; nand write.jffs2 0x80100000 0x590000 0xbc4000
boot_nand=nboot.jffs2 0x80100000 0x0 0x190000; bootm
bootcmd=nboot.jffs2 0x80100000 0x0 0x190000; bootm
stdin=serial
stdout=serial
stderr=serial
filesize=19F4D4
fileaddr=80100000
gatewayip=192.168.1.1
netmask=255.255.255.0
ipaddr=10.10.20.88
serverip=10.10.20.70
Environment size: 575/16380 bytes<0A>
----------------------------------------------------
uboot> printenv
bootdelay=3
baudrate=115200
bootfile=uImage
bootargs=console=ttyS0,115200n81 root=/dev/mtdblock3 rw rootfstype=jffs2 init=/sbin/init
flash_kernel=nand erase 0x190000 0x270000; nand write.jffs2 0x80100000 0x190000 0x1a0000
flash_rootfs=nand erase 0x590000 0x3a70000; nand write.jffs2 0x80100000 0x590000 0xbc4000
boot_nand=nboot.jffs2 0x80100000 0x0 0x190000; bootm
bootcmd=nboot.jffs2 0x80100000 0x0 0x190000; bootm
stdin=serial
stdout=serial
stderr=serial
filesize=19F4D4
fileaddr=80100000
gatewayip=192.168.1.1
netmask=255.255.255.0
ipaddr=10.10.20.88
serverip=10.10.20.70
Environment size: 575/16380 bytes<0A>
Program Linux FileSystem to Flash with UBoot
tftpboot 0x80100000 rootfs.jffs2
HW MAC address: 00:01:90:00:C0:81
ENET:auto-negotiation complete
ENET:FULL DUPLEX
ENET:100MBase
TFTP from server 10.10.20.70; our IP address is 10.10.20.88
Filename 'rootfs.jffs2'.
Load address: 0x80100000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
######################################################
done
Bytes transferred = 5554176 (54c000 hex)
uboot> nand erase 0x590000 0x3a70000
NAND erase: device 0 offset 0x590000, size 0x3a70000
Erasing at 0x590000 -- 0% complete.<0D>
Erasing at 0x624000 -- 1% complete.<0D>
Erasing at 0x6b8000 -- 2% complete.<0D>
Erasing at 0x750000 -- 3% complete.<0D>
Erasing at 0x7e4000 -- 4% complete.<0D>
Erasing at 0x878000 -- 5% complete.<0D>
....................................
Erasing at 0x2648000 -- 56% complete.
Erasing at 0x26dc000 -- 57% complete.
Skipping bad block at 0x026f4000
Erasing at 0x2774000 -- 58% complete.
Erasing at 0x2808000 -- 59% complete.
......................................
Erasing at 0x3f68000 -- 99% complete.<0D>
Erasing at 0x3ffc000 -- 100% complete.
OK
uboot> nand write.jffs2 0x80100000 0x590000 0x54C000
NAND write: device 0 offset 0x590000, size 0x54c000
5554176 bytes written: OK
uboot> setenv bootargs 'console=ttyS0,115200n81 root=/dev/mtdblock3 rw rootfstype
=jffs2 ip=10.10.20.88 init=/sbin/init'
uboot> saveenv
Saving Environment to NAND...
Erasing Nand...
Erasing at 0x1f4000 -- 25% complete.<0D>
Erasing at 0x1f8000 -- 50% complete.<0D>
Erasing at 0x1fc000 -- 75% complete.<0D>
Erasing at 0x200000 -- 100% complete.
Writing to Nand... done
uboot>
HW MAC address: 00:01:90:00:C0:81
ENET:auto-negotiation complete
ENET:FULL DUPLEX
ENET:100MBase
TFTP from server 10.10.20.70; our IP address is 10.10.20.88
Filename 'rootfs.jffs2'.
Load address: 0x80100000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
######################################################
done
Bytes transferred = 5554176 (54c000 hex)
uboot> nand erase 0x590000 0x3a70000
NAND erase: device 0 offset 0x590000, size 0x3a70000
Erasing at 0x590000 -- 0% complete.<0D>
Erasing at 0x624000 -- 1% complete.<0D>
Erasing at 0x6b8000 -- 2% complete.<0D>
Erasing at 0x750000 -- 3% complete.<0D>
Erasing at 0x7e4000 -- 4% complete.<0D>
Erasing at 0x878000 -- 5% complete.<0D>
....................................
Erasing at 0x2648000 -- 56% complete.
Erasing at 0x26dc000 -- 57% complete.
Skipping bad block at 0x026f4000
Erasing at 0x2774000 -- 58% complete.
Erasing at 0x2808000 -- 59% complete.
......................................
Erasing at 0x3f68000 -- 99% complete.<0D>
Erasing at 0x3ffc000 -- 100% complete.
OK
uboot> nand write.jffs2 0x80100000 0x590000 0x54C000
NAND write: device 0 offset 0x590000, size 0x54c000
5554176 bytes written: OK
uboot> setenv bootargs 'console=ttyS0,115200n81 root=/dev/mtdblock3 rw rootfstype
=jffs2 ip=10.10.20.88 init=/sbin/init'
uboot> saveenv
Saving Environment to NAND...
Erasing Nand...
Erasing at 0x1f4000 -- 25% complete.<0D>
Erasing at 0x1f8000 -- 50% complete.<0D>
Erasing at 0x1fc000 -- 75% complete.<0D>
Erasing at 0x200000 -- 100% complete.
Writing to Nand... done
uboot>
Program Linux Kernel to Flash with UBoot
uboot> tftpboot 0x80100000 uImage
HW MAC address: 00:01:90:00:C0:81
ENET:auto-negotiation complete
ENET:FULL DUPLEX
ENET:100MBase
TFTP from server 10.10.20.70; our IP address is 10.10.20.88
Filename 'uImage'.
Load address: 0x80100000
Loading: *<08>#################################################################
##########################################################
done
Bytes transferred = 1801676 (1b7dcc hex)
uboot>nand erase 0x190000 0x270000
NAND erase: device 0 offset 0x190000, size 0x270000
Erasing at 0x190000 -- 0% complete.<0D>
Erasing at 0x194000 -- 1% complete.<0D>
Erasing at 0x19c000 -- 2% complete.<0D>
Erasing at 0x1a0000 -- 3% complete.<0D>
Erasing at 0x1a8000 -- 4% complete.<0D>
Erasing at 0x1ac000 -- 5% complete.<0D>
.......................................
Erasing at 0x3f0000 -- 98% complete.<0D>
Erasing at 0x3f8000 -- 99% complete.<0D>
Erasing at 0x3fc000 -- 100% complete.<0A>
OK
uboot>nand write.jffs2 0x80100000 0x190000 0x1B8000
NAND write: device 0 offset 0x190000, size 0x1b8000
1802240 bytes written: OK
uboot>setenv bootcmd 'nboot.jffs2 0x80100000 0x0 0x190000; bootm'
uboot> saveenv
Saving Environment to NAND...
Erasing Nand...
Erasing at 0x1f4000 -- 25% complete.<0D>
Erasing at 0x1f8000 -- 50% complete.<0D>
Erasing at 0x1fc000 -- 75% complete.<0D>
Erasing at 0x200000 -- 100% complete.
Writing to Nand... done
uboot>
HW MAC address: 00:01:90:00:C0:81
ENET:auto-negotiation complete
ENET:FULL DUPLEX
ENET:100MBase
TFTP from server 10.10.20.70; our IP address is 10.10.20.88
Filename 'uImage'.
Load address: 0x80100000
Loading: *<08>#################################################################
##########################################################
done
Bytes transferred = 1801676 (1b7dcc hex)
uboot>nand erase 0x190000 0x270000
NAND erase: device 0 offset 0x190000, size 0x270000
Erasing at 0x190000 -- 0% complete.<0D>
Erasing at 0x194000 -- 1% complete.<0D>
Erasing at 0x19c000 -- 2% complete.<0D>
Erasing at 0x1a0000 -- 3% complete.<0D>
Erasing at 0x1a8000 -- 4% complete.<0D>
Erasing at 0x1ac000 -- 5% complete.<0D>
.......................................
Erasing at 0x3f0000 -- 98% complete.<0D>
Erasing at 0x3f8000 -- 99% complete.<0D>
Erasing at 0x3fc000 -- 100% complete.<0A>
OK
uboot>nand write.jffs2 0x80100000 0x190000 0x1B8000
NAND write: device 0 offset 0x190000, size 0x1b8000
1802240 bytes written: OK
uboot>setenv bootcmd 'nboot.jffs2 0x80100000 0x0 0x190000; bootm'
uboot> saveenv
Saving Environment to NAND...
Erasing Nand...
Erasing at 0x1f4000 -- 25% complete.<0D>
Erasing at 0x1f8000 -- 50% complete.<0D>
Erasing at 0x1fc000 -- 75% complete.<0D>
Erasing at 0x200000 -- 100% complete.
Writing to Nand... done
uboot>
Tuesday, November 9, 2010
Multiple network in Linux
[1] http://www.shallowsky.com/linux/networkSchemes.html
[2] http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch03_:_Linux_Networking
Howto Set Up Multiple Network Schemes on a Linux Laptop
[2] http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch03_:_Linux_Networking
Howto Set Up Multiple Network Schemes on a Linux Laptop
PPP in Linux
[1] http://www.faqs.org/docs/Linux-HOWTO/PPP-HOWTO.html#AEN582
[2] http://rsc.anu.edu.au/General/linux_ppp/ANU-PPP-HOWTO-3.html
[3] http://www.spinics.net/lists/linux-ppp/msg00799.html pppd options
Packages that are needed when compiling Linux Kernel
-------------------------------------
With support for ppp_async, pppoe.
Maintaining a permanent connection to the net with pppd.
You can see why ppp failed from this log:
[root@GsnCommsModule user]# cat /var/log/messages
You can shut down the pppd connection by:
killall -HUP pppd
AUTO PPP
---------------------------
/svn/CableTracker/CommsModuleLinuxKernel/trunk/rootfs/etc/rc.d/rc.local
can automatically run all the shells that root user want to run after restart.
PPP account and connection retry
---------------------------------
/svn/CableTracker/CommsModuleLinuxKernel/trunk/rootfs/etc/ppp/peers/gsm
$cat gsm
lcp-echo-failure 0
/dev/ttyUSB3
115200
debug
defaultroute
usepeerdns
#ipcp-no-address
#ipcp-no-addresses
ipcp-max-failure 4
ipcp-accept-local
ipcp-accept-remote
# AUTHENTICATION
# If noauth works, use that, otherwise you have to pass
# the user name and password. This is an example of a
# standard Cingular user/pw combo
noauth
#ppp account infomation
user GridSense0002@maxwan.com.au
password GTre387a
crtscts
#persist will cause connection retry after ppp off-line
persist
maxfail 100
lock
connect '/sbin/chat -v -t6 -f /etc/ppp/peers/gsm_chat'
PULL DOWN ETH CONNECTION
----------------------------
[root@GsnCommsModule user]# ifconfig eth0 down
[2] http://rsc.anu.edu.au/General/linux_ppp/ANU-PPP-HOWTO-3.html
[3] http://www.spinics.net/lists/linux-ppp/msg00799.html pppd options
Packages that are needed when compiling Linux Kernel
-------------------------------------
With support for ppp_async, pppoe.
Maintaining a permanent connection to the net with pppd.
You can see why ppp failed from this log:
[root@GsnCommsModule user]# cat /var/log/messages
You can shut down the pppd connection by:
killall -HUP pppd
AUTO PPP
---------------------------
/svn/CableTracker/CommsModuleLinuxKernel/trunk/rootfs/etc/rc.d/rc.local
can automatically run all the shells that root user want to run after restart.
PPP account and connection retry
---------------------------------
/svn/CableTracker/CommsModuleLinuxKernel/trunk/rootfs/etc/ppp/peers/gsm
$cat gsm
lcp-echo-failure 0
/dev/ttyUSB3
115200
debug
defaultroute
usepeerdns
#ipcp-no-address
#ipcp-no-addresses
ipcp-max-failure 4
ipcp-accept-local
ipcp-accept-remote
# AUTHENTICATION
# If noauth works, use that, otherwise you have to pass
# the user name and password. This is an example of a
# standard Cingular user/pw combo
noauth
#ppp account infomation
user GridSense0002@maxwan.com.au
password GTre387a
crtscts
#persist will cause connection retry after ppp off-line
persist
maxfail 100
lock
connect '/sbin/chat -v -t6 -f /etc/ppp/peers/gsm_chat'
PULL DOWN ETH CONNECTION
----------------------------
[root@GsnCommsModule user]# ifconfig eth0 down
Monday, November 8, 2010
Decimal point in java script
[1] http://www.mredkj.com/javascript/nfbasic2.html
// Example: toFixed(2) when the number has no decimal places
// It will add trailing zeros
var num = 10;
var result = num.toFixed(2); // result will equal 10.00
// Example: toFixed(3) when the number has decimal places
// It will round to the thousandths place
num = 930.9805;
result = num.toFixed(3); // result will equal 930.981
PADDING '0'
-----------------------------------
function PadDigits(n, totalDigits)
{
n = n.toString();
var pd = '';
if (totalDigits > n.length)
{
for (i=0; i < (totalDigits-n.length); i++)
{
pd += '0';
}
}
return pd + n.toString();
}
// Example: toFixed(2) when the number has no decimal places
// It will add trailing zeros
var num = 10;
var result = num.toFixed(2); // result will equal 10.00
// Example: toFixed(3) when the number has decimal places
// It will round to the thousandths place
num = 930.9805;
result = num.toFixed(3); // result will equal 930.981
PADDING '0'
-----------------------------------
function PadDigits(n, totalDigits)
{
n = n.toString();
var pd = '';
if (totalDigits > n.length)
{
for (i=0; i < (totalDigits-n.length); i++)
{
pd += '0';
}
}
return pd + n.toString();
}
Wednesday, October 27, 2010
Notes from Embedded Linux Virtual Conference
1. Embedded Linux and Commercial RTOS are friends in the growing multi-core solution.
------------------------------------------------------------------------------------
Consider a hypervisor so you can have both RTOS and Linux for user interface
Venders like Wind River and Green Hills have lightweight hypervisors that allow for mixing Linux and RTOS on different cores.
Also, during our panel discussion, most of the vendor talked about running an RTOS alongside Linux on a two-core chip.
2. Chat of footprint
-------------------------------------------------
ThreadX can be as small as 2KB
if you're targeting 16Kb RAM, then Linux is out of the question. Think uCOS/III, ThreadX, uVelocity, etc. if you really need an O/S.
Jim Turley (10/22/2010 3:45:35 AM):Minimum memory size for Linux is about 4 MB, according to our panelists.
in a prev company I was stuck with an in-house RTOS very limited ability. Installed a demo RTOS that had a remote debug system. That alone justified the purchase order. (this was 8/16-bit days)
Mike Anderson (10/22/2010 3:46:26 AM):I've gotten Linux down to 295K, but it was a very focused application. 2K is so small that even the tiny RTOS kernels may be too big.
John Carbone (10/22/2010 3:50:42 AM):@zahir - for 25 tasks (we call them "threads" but it's the same thing), each one uses about 164 bytes, so 4KB of RAM just for the Thread Control Blocks.
3. Chat of ucLinux
---------------------------------
Bruce Christensen (10/22/2010 3:53:24 AM):@Dave M -- uClinux doesn't have an MMU so it doesn't support multi-threaded designs which eliminates some of the open source software out there. In some aspects it is easier though when working with an embedded system because addresses referred to in the code are 'real' addresses, not virtual
Lloyd Sargent (10/22/2010 3:54:15 AM):@Dave M Also you can't really use fork - there is a work-around but it can mean a lot of code rework
4. Chat of eCOS
---------------------------
Yanming Wu (10/22/2010 3:58:28 AM):eCos is also open source, like linux, any comments on eCos?
Mike Anderson (10/22/2010 4:02:25 AM):eCOS is a nice little platform, you see it most often these days ad the RedBoot boot loader.
erol ozkarsli (10/22/2010 4:04:44 AM):@mike is eCOS open source?
zahir parkar (10/22/2010 4:04:53 AM):@john Thanks
Mike Anderson (10/22/2010 4:05:01 AM):@erol: yes, covered by GPL
erol ozkarsli (10/22/2010 4:22:23 AM):@Yanming eCOS is not support luminary devices instead eCOScentric does
5. Firmware Upgrade with Embedded Linux
-----------------------------------------------------
WanQiang(Quentin) YANG (10/22/2010 4:20:38 AM): Hi, what's the common way or is there common way to do firmware upgrade with embedded Linux? For our previous products without RTOS, firmware itself is able to reprogram the whole flash(ROM) with new firmware delievered via 3G modem.
Mike Anderson (10/22/2010 4:22:31 AM):@Wan: You could certainly do it that way. Boot firmware like UBoot could support that. But, I normally have a piece of firmware that I never allow the users to update so they can't brick the box. Then the O/S & filesystem are updated in flash via the boot firmware like you've done in the past
WanQiang(Quentin) YANG (10/22/2010 4:25:45 AM):Yeah, in our previous product, one piece of code, we call it bootloader, can never be upgraded, which stay same in a certain part of FLASH.
Raghavendra Reddy Desai (10/22/2010 4:28:20 AM):@ EROL :for cortex-M3 try using openICE EDS
WanQiang(Quentin) YANG (10/22/2010 4:28:40 AM):So, you reckon, I can do the same thing, get one level of boot loader before UBoot to manage the Embedded Linux upgrade for both Kernel and File System. Thanks. That'll be part of job outside of Linux Porting.
Mike Anderson (10/22/2010 4:29:25 AM):@Wan: Yes, that's what we've done many times in the past and that seems to work reliably. Good luck.
6. Chat of Real-time about Embedded Linux
----------------------------------------------------
Mike Anderson (10/22/2010 6:05:42 AM):Yes, that would be unfair. I've seen very good determinism from the RT-patched kernel.
Doug Gibbs (10/22/2010 6:07:21 AM):@Brett, the patch removes/replaces instances of the big lock. Mainline kernel is also removing them.
Mike Anderson (10/22/2010 6:07:28 AM):Absolutely. Real-time means being fast enough. Deterministic behavior is great, but the world is rarely deterministic. And, if you want real determinism, you have to be willing to disable your processor caches and SMP.
Nuno Felicio (10/22/2010 6:07:28 AM):an RT-patched kernel runs linux as a low priority task of an hard RTOS
Jose Luis Briz (10/22/2010 6:08:01 AM):@Sutton you have fully preemption. Without the RT patch, processes running kernel mode can't be preempted if holding a spin lock
Jason Wessel (10/22/2010 6:08:10 AM):Doug / Brett: It is more than that, an RT patched kernel converts nearly all the spin locks in the kernel into priority based mutexes.
Jason Wessel (10/22/2010 6:09:03 AM):Jose Luis Briz, in most cases that is true, some drivers do not play so nice and they are made RT safe with non-premptible locks.
Mike Anderson (10/22/2010 6:09:08 AM):@Nuno: actually, that is only one type of RT-Linux -- the sub- or co-kernel flavor RTAI and Xenomai are examples of that. But the RT-patched kernel (PREEMPT_RT) has determinism built into the kernel as a native feature.
Jose Luis Briz (10/22/2010 6:09:15 AM):@Sutton All interrupt serv.routines and softirqs are tasks, so they imply a context switch. And all spin locks are mutexes (the process blocks)
Nuno Felicio (10/22/2010 6:10:37 AM):@Mike yes but the RT- patched kernel only gives determinist arround 100 us or something like that, so its only soft real time
Don McFarland (10/22/2010 6:10:52 AM):having only used embedded Linux kernels that use MMUs (Coldfire processors), I was wondering if ucLinux does better in tight timing situations ?
Mike Anderson (10/22/2010 6:10:59 AM):That depends on your system requirements.
7. Chat of boot time about Embedded Linux
---------------------------------------------------
Don McFarland (10/22/2010 6:16:31 AM):one serious problem with embedded Linux w/MMU is the rediculous boot times - 1 1/2 minutes on one of our boards and 30 seconds on another of our boards - with CPU clock in excess of 100MHz on both boards
Dean Misenhimer (10/22/2010 6:17:41 AM):@don we just did a webinar on fast boot techniques...it's not here in the show but you can find it on our website. Lots of good info in it
Dean Misenhimer (10/22/2010 6:13:24 AM):There is a white paper on real-time in our booth that may be helpful...It's a few years old, but still has some good info in it. Look in the general info section of our collateral.
Ron Wilson (10/22/2010 6:13:56 AM):@Dean: which booth is that?
Mike Anderson (10/22/2010 6:14:00 AM):http://www.versalogic.com/downloads/whitepapers/Real-time_Linux_Benchmark.pdf
Dean Misenhimer (10/22/2010 6:14:12 AM):@ron Sorry...MontaVista
Dean Misenhimer (10/22/2010 6:18:48 AM):we also did a one second boot for a customer...cold power on to data display in 1.5 seconds, so it can be done...takes a lot of tuning
John Faith (10/22/2010 6:19:00 AM):Don: you might try running bootchart. See http://elinux.org/Bootchart
Jose Luis Briz (10/22/2010 6:20:28 AM):@Brian PREEMPT_RT is only in the patc
Nuno Felicio (10/22/2010 6:22:50 AM):@Brian, with an mpu Linux can provide process isolation/protection
Don McFarland (10/22/2010 6:23:50 AM):Nuno - are you running the kernel out of the flash - with a one second boot I had to ask... because decompressing and loading the kernel before any code actually start running except for the boot loader, can take that long
Nuno Felicio (10/22/2010 6:23:55 AM):for example AT91SAM9G20 have mpu
Nuno Felicio (10/22/2010 6:24:04 AM):and runs the complete Linux
Nuno Felicio (10/22/2010 6:24:31 AM):@Don the kernel its not compressed
Nuno Felicio (10/22/2010 6:24:43 AM):@Don its faster
Don McFarland (10/22/2010 6:26:09 AM):@Nuno - understood - Ive never seen a Linux be able to load and initialize all of the device drivers in that time frame, even on a 3 GHz Intel CPU
Nuno Felicio (10/22/2010 6:27:51 AM):@Don in a PC its very hard to achieve very fast boot times, the PC is a horrible designed machine :), in a small board its more or less easy
Tim Michals (10/22/2010 6:25:46 AM):From many RTOS Linux providers give the response, "You have to test your application to validate the timing will be met" That is a hard sell to management to spend money any comments?
Lloyd Sargent (10/22/2010 6:28:49 AM):@Tim In my 25 years (save for one company) it was ALWAYS a hard sell to get management to spend money to validate testing
Lloyd Sargent (10/22/2010 6:29:26 AM):@Tim Sorry, TIMING not TESTING
------------------------------------------------------------------------------------
Consider a hypervisor so you can have both RTOS and Linux for user interface
Venders like Wind River and Green Hills have lightweight hypervisors that allow for mixing Linux and RTOS on different cores.
Also, during our panel discussion, most of the vendor talked about running an RTOS alongside Linux on a two-core chip.
2. Chat of footprint
-------------------------------------------------
ThreadX can be as small as 2KB
if you're targeting 16Kb RAM, then Linux is out of the question. Think uCOS/III, ThreadX, uVelocity, etc. if you really need an O/S.
Jim Turley (10/22/2010 3:45:35 AM):Minimum memory size for Linux is about 4 MB, according to our panelists.
in a prev company I was stuck with an in-house RTOS very limited ability. Installed a demo RTOS that had a remote debug system. That alone justified the purchase order. (this was 8/16-bit days)
Mike Anderson (10/22/2010 3:46:26 AM):I've gotten Linux down to 295K, but it was a very focused application. 2K is so small that even the tiny RTOS kernels may be too big.
John Carbone (10/22/2010 3:50:42 AM):@zahir - for 25 tasks (we call them "threads" but it's the same thing), each one uses about 164 bytes, so 4KB of RAM just for the Thread Control Blocks.
3. Chat of ucLinux
---------------------------------
Bruce Christensen (10/22/2010 3:53:24 AM):@Dave M -- uClinux doesn't have an MMU so it doesn't support multi-threaded designs which eliminates some of the open source software out there. In some aspects it is easier though when working with an embedded system because addresses referred to in the code are 'real' addresses, not virtual
Lloyd Sargent (10/22/2010 3:54:15 AM):@Dave M Also you can't really use fork - there is a work-around but it can mean a lot of code rework
4. Chat of eCOS
---------------------------
Yanming Wu (10/22/2010 3:58:28 AM):eCos is also open source, like linux, any comments on eCos?
Mike Anderson (10/22/2010 4:02:25 AM):eCOS is a nice little platform, you see it most often these days ad the RedBoot boot loader.
erol ozkarsli (10/22/2010 4:04:44 AM):@mike is eCOS open source?
zahir parkar (10/22/2010 4:04:53 AM):@john Thanks
Mike Anderson (10/22/2010 4:05:01 AM):@erol: yes, covered by GPL
erol ozkarsli (10/22/2010 4:22:23 AM):@Yanming eCOS is not support luminary devices instead eCOScentric does
5. Firmware Upgrade with Embedded Linux
-----------------------------------------------------
WanQiang(Quentin) YANG (10/22/2010 4:20:38 AM): Hi, what's the common way or is there common way to do firmware upgrade with embedded Linux? For our previous products without RTOS, firmware itself is able to reprogram the whole flash(ROM) with new firmware delievered via 3G modem.
Mike Anderson (10/22/2010 4:22:31 AM):@Wan: You could certainly do it that way. Boot firmware like UBoot could support that. But, I normally have a piece of firmware that I never allow the users to update so they can't brick the box. Then the O/S & filesystem are updated in flash via the boot firmware like you've done in the past
WanQiang(Quentin) YANG (10/22/2010 4:25:45 AM):Yeah, in our previous product, one piece of code, we call it bootloader, can never be upgraded, which stay same in a certain part of FLASH.
Raghavendra Reddy Desai (10/22/2010 4:28:20 AM):@ EROL :for cortex-M3 try using openICE EDS
WanQiang(Quentin) YANG (10/22/2010 4:28:40 AM):So, you reckon, I can do the same thing, get one level of boot loader before UBoot to manage the Embedded Linux upgrade for both Kernel and File System. Thanks. That'll be part of job outside of Linux Porting.
Mike Anderson (10/22/2010 4:29:25 AM):@Wan: Yes, that's what we've done many times in the past and that seems to work reliably. Good luck.
6. Chat of Real-time about Embedded Linux
----------------------------------------------------
Mike Anderson (10/22/2010 6:05:42 AM):Yes, that would be unfair. I've seen very good determinism from the RT-patched kernel.
Doug Gibbs (10/22/2010 6:07:21 AM):@Brett, the patch removes/replaces instances of the big lock. Mainline kernel is also removing them.
Mike Anderson (10/22/2010 6:07:28 AM):Absolutely. Real-time means being fast enough. Deterministic behavior is great, but the world is rarely deterministic. And, if you want real determinism, you have to be willing to disable your processor caches and SMP.
Nuno Felicio (10/22/2010 6:07:28 AM):an RT-patched kernel runs linux as a low priority task of an hard RTOS
Jose Luis Briz (10/22/2010 6:08:01 AM):@Sutton you have fully preemption. Without the RT patch, processes running kernel mode can't be preempted if holding a spin lock
Jason Wessel (10/22/2010 6:08:10 AM):Doug / Brett: It is more than that, an RT patched kernel converts nearly all the spin locks in the kernel into priority based mutexes.
Jason Wessel (10/22/2010 6:09:03 AM):Jose Luis Briz, in most cases that is true, some drivers do not play so nice and they are made RT safe with non-premptible locks.
Mike Anderson (10/22/2010 6:09:08 AM):@Nuno: actually, that is only one type of RT-Linux -- the sub- or co-kernel flavor RTAI and Xenomai are examples of that. But the RT-patched kernel (PREEMPT_RT) has determinism built into the kernel as a native feature.
Jose Luis Briz (10/22/2010 6:09:15 AM):@Sutton All interrupt serv.routines and softirqs are tasks, so they imply a context switch. And all spin locks are mutexes (the process blocks)
Nuno Felicio (10/22/2010 6:10:37 AM):@Mike yes but the RT- patched kernel only gives determinist arround 100 us or something like that, so its only soft real time
Don McFarland (10/22/2010 6:10:52 AM):having only used embedded Linux kernels that use MMUs (Coldfire processors), I was wondering if ucLinux does better in tight timing situations ?
Mike Anderson (10/22/2010 6:10:59 AM):That depends on your system requirements.
7. Chat of boot time about Embedded Linux
---------------------------------------------------
Don McFarland (10/22/2010 6:16:31 AM):one serious problem with embedded Linux w/MMU is the rediculous boot times - 1 1/2 minutes on one of our boards and 30 seconds on another of our boards - with CPU clock in excess of 100MHz on both boards
Dean Misenhimer (10/22/2010 6:17:41 AM):@don we just did a webinar on fast boot techniques...it's not here in the show but you can find it on our website. Lots of good info in it
Dean Misenhimer (10/22/2010 6:13:24 AM):There is a white paper on real-time in our booth that may be helpful...It's a few years old, but still has some good info in it. Look in the general info section of our collateral.
Ron Wilson (10/22/2010 6:13:56 AM):@Dean: which booth is that?
Mike Anderson (10/22/2010 6:14:00 AM):http://www.versalogic.com/downloads/whitepapers/Real-time_Linux_Benchmark.pdf
Dean Misenhimer (10/22/2010 6:14:12 AM):@ron Sorry...MontaVista
Dean Misenhimer (10/22/2010 6:18:48 AM):we also did a one second boot for a customer...cold power on to data display in 1.5 seconds, so it can be done...takes a lot of tuning
John Faith (10/22/2010 6:19:00 AM):Don: you might try running bootchart. See http://elinux.org/Bootchart
Jose Luis Briz (10/22/2010 6:20:28 AM):@Brian PREEMPT_RT is only in the patc
Nuno Felicio (10/22/2010 6:22:50 AM):@Brian, with an mpu Linux can provide process isolation/protection
Don McFarland (10/22/2010 6:23:50 AM):Nuno - are you running the kernel out of the flash - with a one second boot I had to ask... because decompressing and loading the kernel before any code actually start running except for the boot loader, can take that long
Nuno Felicio (10/22/2010 6:23:55 AM):for example AT91SAM9G20 have mpu
Nuno Felicio (10/22/2010 6:24:04 AM):and runs the complete Linux
Nuno Felicio (10/22/2010 6:24:31 AM):@Don the kernel its not compressed
Nuno Felicio (10/22/2010 6:24:43 AM):@Don its faster
Don McFarland (10/22/2010 6:26:09 AM):@Nuno - understood - Ive never seen a Linux be able to load and initialize all of the device drivers in that time frame, even on a 3 GHz Intel CPU
Nuno Felicio (10/22/2010 6:27:51 AM):@Don in a PC its very hard to achieve very fast boot times, the PC is a horrible designed machine :), in a small board its more or less easy
Tim Michals (10/22/2010 6:25:46 AM):From many RTOS Linux providers give the response, "You have to test your application to validate the timing will be met" That is a hard sell to management to spend money any comments?
Lloyd Sargent (10/22/2010 6:28:49 AM):@Tim In my 25 years (save for one company) it was ALWAYS a hard sell to get management to spend money to validate testing
Lloyd Sargent (10/22/2010 6:29:26 AM):@Tim Sorry, TIMING not TESTING
Saturday, October 23, 2010
Video Knowledge
[1] http://hometheater.about.com/cs/television/a/aavideoresa_2.htm
Digital TV Resolution Standards
----------------------------------
The three vertical scan line systems used in digital TV are 480p (480 lines vertically scanned in a progressive fashion), 720p (720 lines vertically scanned in a progressive fashion), and 1080i (1,080 lines scanned in an interlaced fashion).
NTSC
--------
NTSC is based on a 525-line, 60 fields/30 frames-per-second, at 60Hz system for transmission and display of video images.
PAL
-------------
PAL is the dominant format in the World for analog television broadcasting and video display and is based on a 625 line, 50 field/25 frames a second, 50HZ system.
Video format with horizontal resolution estimates:
Resolution (vertical, horizontal)
------------------------------------
The number of scan lines, or vertical resolution, of NTSC/PAL/SECAM are constant in that all analog video recording and display equipment conforms to the above standards.
However, in addition to vertical scan lines, the amount of dots displayed within each line on the screen contributes to a factor known as horizontal resolution which can vary
-VHS/VHS-C 220 - 240 lines
-S-VHS/S-VHSC 400 lines
-DVD-R/-RW/+R/+RW 250 - 400+ lines (Depends on recording mode and compression used)
-miniDV 400 - 520 lines
-Analog TV Broadcast 330 lines
-Analog Cable TV 330 lines
-Standard Digital Cable
330 - 500 lines (Depends on original source of the signal and compression used in downloading to the cable box)
-Commercial DVD Up to 540 lines
-BETA 250 lines
-8mm 250 - 280 lines
-SuperBETA 270 - 280 lines
-Laserdisc 400 - 425 lines
-Hi8 380 - 440 lines
-Digital 8 400 - 500 lines
-microMV 500 lines
-ED BETA 500 lines
Digital TV Resolution Standards
----------------------------------
The three vertical scan line systems used in digital TV are 480p (480 lines vertically scanned in a progressive fashion), 720p (720 lines vertically scanned in a progressive fashion), and 1080i (1,080 lines scanned in an interlaced fashion).
NTSC
--------
NTSC is based on a 525-line, 60 fields/30 frames-per-second, at 60Hz system for transmission and display of video images.
PAL
-------------
PAL is the dominant format in the World for analog television broadcasting and video display and is based on a 625 line, 50 field/25 frames a second, 50HZ system.
Video format with horizontal resolution estimates:
Resolution (vertical, horizontal)
------------------------------------
The number of scan lines, or vertical resolution, of NTSC/PAL/SECAM are constant in that all analog video recording and display equipment conforms to the above standards.
However, in addition to vertical scan lines, the amount of dots displayed within each line on the screen contributes to a factor known as horizontal resolution which can vary
-VHS/VHS-C 220 - 240 lines
-S-VHS/S-VHSC 400 lines
-DVD-R/-RW/+R/+RW 250 - 400+ lines (Depends on recording mode and compression used)
-miniDV 400 - 520 lines
-Analog TV Broadcast 330 lines
-Analog Cable TV 330 lines
-Standard Digital Cable
330 - 500 lines (Depends on original source of the signal and compression used in downloading to the cable box)
-Commercial DVD Up to 540 lines
-BETA 250 lines
-8mm 250 - 280 lines
-SuperBETA 270 - 280 lines
-Laserdisc 400 - 425 lines
-Hi8 380 - 440 lines
-Digital 8 400 - 500 lines
-microMV 500 lines
-ED BETA 500 lines
Thursday, October 14, 2010
GNU Make Notes
[1] http://www.gnu.org/software/make/manual/make.html#Running
9 How to Run make
A makefile that says how to recompile a program can be used in more than one way. The simplest use is to recompile every file that is out of date. Usually, makefiles are written so that if you run make with no arguments, it does just that.
But you might want to update only some of the files; you might want to use a different compiler or different compiler options; you might want just to find out which files are out of date without changing them.
By giving arguments when you run make, you can do any of these things and many others.
9 How to Run make
A makefile that says how to recompile a program can be used in more than one way. The simplest use is to recompile every file that is out of date. Usually, makefiles are written so that if you run make with no arguments, it does just that.
But you might want to update only some of the files; you might want to use a different compiler or different compiler options; you might want just to find out which files are out of date without changing them.
By giving arguments when you run make, you can do any of these things and many others.
Save GNU make result into a text file - divert output
$make 2>&1 | tee build-log.txt
Sunday, October 10, 2010
Eclipse Usage and shortcut
[1]Eclipse.Org
CTRL+L go to line number
ISSUE: eclipse overlaps the location of another project [1]
---------------------------------------------------------
---My solution-----
If it's under, then must tick 'using default workspace', and just give the directory name 'LIQGateWay_Dnp3_Porint' as the project name, then it won't report "...eclipse overlaps the location of another project..." as it happened when you untick using default workspace, but still choose folder under .
---Other suggestions----
ONE: Check file '/home/q.yang/EclipseCDT/qywkspace/LIQGateWay_Dnp3_Porting/.metadata'
TWO: Check file '/.metadata/plugins/org.eclipse.core.resources/.projects'
THREE:
Workaround the problem:
1. Go to "%ECLIPSE_HOME%\configuration\.settings" and delete the workspace listed at the key RECENT_WORKSPACES
2. Restart Eclipse, go to File>Switch Workspace>Other... and select your workspace dir again
3. Now I could create new projects as always
CTRL+L go to line number
ISSUE: eclipse overlaps the location of another project [1]
---------------------------------------------------------
---My solution-----
If it's under
---Other suggestions----
ONE: Check file '/home/q.yang/EclipseCDT/qywkspace/LIQGateWay_Dnp3_Porting/.metadata'
TWO: Check file '
THREE:
Workaround the problem:
1. Go to "%ECLIPSE_HOME%\configuration\.settings" and delete the workspace listed at the key RECENT_WORKSPACES
2. Restart Eclipse, go to File>Switch Workspace>Other... and select your workspace dir again
3. Now I could create new projects as always
Friday, October 1, 2010
Access Window's shared drive from Linux.
[1]http://www.cyberciti.biz/faq/linux-mount-cifs-windows-share/
[root@QuentinFedoraHome q.yang]# mount -t cifs //10.1.1.9/Photo_Son$/ ./mnt_photo_son/ -o username=GeorgeYANG,password=xxxx,domain=workgroup
[q.yang@QuentinFedoraHome ~]$ cat mountAcerDataSada.sh
mount -t cifs //10.1.1.10/Tool$/ ./mnt_Acer_DataSada/ -o username=GeorgeYANG,password=xxxx,domain=workgroup,uid=q.yang
[root@QuentinFedoraHome q.yang]# mount -t cifs //10.1.1.9/Photo_Son$/ ./mnt_photo_son/ -o username=GeorgeYANG,password=xxxx,domain=workgroup
[q.yang@QuentinFedoraHome ~]$ cat mountAcerDataSada.sh
mount -t cifs //10.1.1.10/Tool$/ ./mnt_Acer_DataSada/ -o username=GeorgeYANG,password=xxxx,domain=workgroup,uid=q.yang
Tuesday, September 28, 2010
C++ Programming Notes
[1] http://bytes.com/topic/c/answers/624119-how-do-you-declare-use-static-constant-array-inside-class
[2] http://www.cplusplus.com/forum/beginner/2052/
HOW DO WE DECLARE AND INITIALIZE CONSTANT CHAR ARRAY? [1]
-----------------------------------------------------------
class Test
{
public:
static const int arr[]= {1,2,3}; // LINE 11
}
You can declare it here, but you can't initialize it here.
Initialize it in a separate definition.
Otherwise, you will get compiling error
"a brace-enclosed initializer is not allowed here before '{' token"
Header file:
class Test
{
public:
static const int arr[];
};
Implementation file in *.cpp:
const int Test::arr[3] = {1,2,3};
iostream linker error is solved by using g++ instead of gcc in makefile.
-----------------------------------------------------------------
Mistake to avoid when using 'inline'
-------------------------------------------------------------
1.Don't put inline in front of class constructor/destructor
2.Don't put inline in front of functions within 'namespace'.
linker error when using static variables in class [2]
--------------------------------------------------------
[2] http://www.cplusplus.com/forum/beginner/2052/
HOW DO WE DECLARE AND INITIALIZE CONSTANT CHAR ARRAY? [1]
-----------------------------------------------------------
class Test
{
public:
static const int arr[]= {1,2,3}; // LINE 11
}
You can declare it here, but you can't initialize it here.
Initialize it in a separate definition.
Otherwise, you will get compiling error
"a brace-enclosed initializer is not allowed here before '{' token"
Header file:
class Test
{
public:
static const int arr[];
};
Implementation file in *.cpp:
const int Test::arr[3] = {1,2,3};
iostream linker error is solved by using g++ instead of gcc in makefile.
-----------------------------------------------------------------
Mistake to avoid when using 'inline'
-------------------------------------------------------------
1.Don't put inline in front of class constructor/destructor
2.Don't put inline in front of functions within 'namespace'.
linker error when using static variables in class [2]
--------------------------------------------------------
Wednesday, September 15, 2010
Vi / Vim Notes
[1] vim.org tagbar plugin
[2] vimawesome.com vim plugin\
[3] linux.com vim-101-a-beginners-guide-to-vim
[4] derickbailey/2010/04/23/using-vim-as-your-c-code-editor-from-visual-studio/
[5] cscope.sourceforge.net/cscope_vim_tutorial.html
qyang@lubuntu-laptop:~$ tree ~/.vim
/home/qyang/.vim
├── autoload
│ ├── acp.vim
│ └── tagbar.vim
├── doc
│ ├── acp.jax
│ ├── acp.txt
│ ├── tagbar.txt
│ ├── tags
│ └── tags-ja
├── plugin
│ ├── cscope_maps.vim
│ └── tagbar.vim
├── plugins
│ ├── acp.vim
│ ├── cctree.vim
│ ├── ming.vim
│ └── qt.vim
├── README.md
└── syntax
├── python.vim
└── tagbar.vim
ming.vim
set showcmd
set ruler
set nocompatible
set ignorecase smartcase incsearch hlsearch
set nowrap
set smartindent
set backspace=indent,eol,start
function Setcohda(...)
set tabstop=2 shiftwidth=2
set expandtab
endfunction
function Setlinux(...)
set tabstop=8 shiftwidth=8
set noexpandtab
endfunction
command Cohda call Setcohda()
command Linux call Setlinux()
autocmd FileType cpp Cohda
autocmd FileType make set noexpandtab tabstop=8
autocmd FileType python set tabstop=4 shiftwidth=4 noexpandtab
noremap :!make
inoremap :!make
qt.vim
------------------------------------
Generate cscope.out on root directory of source code project, then start vim from that root directory. All symbols index in cscope.out can be used by vim now.
Try below to jump straight to the file including 'main' symbol
Insert following code into makefile to generate cscope.out via make.
DISPLAY TAB
---------------------
Not quite work correctly to show all tabs
:SeeTab vim.wikia.com
OPEN MULTIPLE FILES FROM CMD LINE
-------------------------
TURN ON LINE NUMBER
------------------------
:set number
REPLACE A STRING
-------------------
:1,$s/word1/word2/gc IN A WHOLE FILE
:n1,n2s/word1/word2/gc IN BETWEEN LINE 'n1' and 'n2', special character use '\' prefix. (e.g.,:1,$s/word\[/word1\[/gc, replace 'word[' with 'word1[' )
COMMAND MODE
---------------------
'g0' -- go zero, go to head of line;
'g$' -- go to end of line;
'G' -- go to end of this file;
'H' -- go to top of screen;
'M' -- go to middle of screen;
'L' -- go to bottom of screen;
'nG' -- go to line number 'n'
'/word' -- search a string 'word' forward;
'?word' -- search a string 'word' backward;
'nyy' -- yank/copy n lines after cursor;
'p' -- paste yanked contens one line below cursor;
'dd' -- delete current line;
'nd' -- delete n lines after cursor;
DELETE/COPY(YANK) A BLOCK OF TEXT
----------------------------
The ‘mark command can be very useful when deleting a long series of lines.To
delete a long series of lines, follow these steps:
1. Move the cursor to the beginning of the text you want to delete.
2. Mark it using the command ma. (This marks it with mark a.)
3. Go to the end of the text to be removed. Delete to mark a using the command
d’a.
Note:There is nothing special about using the a mark. Any mark from a to z
may be used.
BACK TO PREVIOUSLY VISITED LOCATION previous view
-----------------------------
Ctrl + O
Ctrl + I (tab)
Jumping_to_previously_visited_locations
JUMP TO SYMBOL DEFINITION when ctags/cscope enabled
------------------------------
Ctrl + ]
Ctrl + T
A 05 Vi Exercise
===============================
[1] http://stackoverflow.com/questions/1737163/traversing-text-in-insert-mode
Insert mode and navigation mode switch
----------------------------------------
ESC or Ctrl+[
Navigation Fast
--------------------
15 + h go backward 15 characters
5 + j go forward 5 lines
Ctrl+o + 2 + b navigate two words back without leaving insert mode
Ctrl+o will give you chance to run one vi command at navigation
mode, then return to insert mode automatically.
'+. back to previous editing place after navigation
Type 20 '-' delete backword 9 '-'
----------------------------------------
20 + i + - + ESC
9 + X
'20' set number of execute times
'i' into insert mode
'-' letter or words you want to repeat
'ESC' back to navigation mode will display all insert letters.
'9' set number of exectue times
'X' delete backward, 'x' delete forward
Paste from clip board
-----------------------------------
"+p
" use register
+ clipboard register index
p paste shortcut key
Corret Typo
----------------------
accifently
FfrdA will correct the word from accifently to accidently
'F' find backward 'f' find forward
'f' find letter 'f'
'r' replace current cursor
'd' type correct letter 'd'
'A' back to original edit place
Rewrite word
--------------------
you accidentlly typed
you intentially typed
you intertially typed
ESC + 2 + b + c + w intentially + ESC + A
Write words in multiple lines
--------------------
[2] http://vim.wikia.com/wiki/Inserting_text_in_multiple_lines
hello
hello
hello
hel:added:loappend
hel:added:loappend
hel:added:loappend
hllo hello append
hllo hello append
hllo hello append
Ctrl+v + navigate coursor to 'l' + j + j + j + I + :added: + ESC
Ctrl+v + navigate coursor to 'o' + l + A + Ctrl+R + "
Ctrl+v + select block you want to delete + d
'Ctrl+v' visual block mode.
'I' insert before current cursor in visual block mode.
'A' append after current cursor in visual block mode.
'Ctrl + R + "' past yank register in insert mode
'Ctrl + R + +' past clipboard insert mode.
[2] vimawesome.com vim plugin\
[3] linux.com vim-101-a-beginners-guide-to-vim
[4] derickbailey/2010/04/23/using-vim-as-your-c-code-editor-from-visual-studio/
[5] cscope.sourceforge.net/cscope_vim_tutorial.html
qyang@lubuntu-laptop:~$ tree ~/.vim
/home/qyang/.vim
├── autoload
│ ├── acp.vim
│ └── tagbar.vim
├── doc
│ ├── acp.jax
│ ├── acp.txt
│ ├── tagbar.txt
│ ├── tags
│ └── tags-ja
├── plugin
│ ├── cscope_maps.vim
│ └── tagbar.vim
├── plugins
│ ├── acp.vim
│ ├── cctree.vim
│ ├── ming.vim
│ └── qt.vim
├── README.md
└── syntax
├── python.vim
└── tagbar.vim
ming.vim
qt.vim
------------------------------------
: colorscheme morning : syntax on : autocmd FileType * set formatoptions=tcql nocindent comments& : autocmd InsertEnter * colorscheme blue : autocmd InsertLeave * colorscheme morning : set autowrite : ab #d #define : ab #i #include : ab #b /******************************************************** : ab #e ^H^H********************************************************/ : ab #l /*------------------------------------------------------*/ : set sw=4 : set notextmode : set notextauto : set hlsearch : set incsearch : set textwidth=150 : au BufWinEnter * let w:m1=matchadd('Search','\%<151v .="">77v', -1) : au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>150v.\+', -1) : autocmd FileType c,cpp set formatoptions=croql cindent comments=sr: /*,mb: *.ex: */,: // : set nowrap : match ErrorMsg '\%>80v.\+' : set expandtab : set shiftwidth=2 : set softtabstop=2 : map: s/^/\/\// 151v>: map : s/^\/\/// : set smartcase : set ic
: nmap :TagbarToggle func! DeleteTrailingWS() exe "normal mz" %s/\s\+$//ge exe "normal `z" endfunc autocmd BufWrite *.py : call DeleteTrailingWS()
Generate cscope.out on root directory of source code project, then start vim from that root directory. All symbols index in cscope.out can be used by vim now.
Try below to jump straight to the file including 'main' symbol
$vi -t main
Insert following code into makefile to generate cscope.out via make.
$make cscope -f MakefileName
# Make software # # Generate csope files cscope: cscope.out cscope.out: cscope.files @cscope -R -b -i $< cscope.files: @find am335x -name "*.[ch]" -not -path "*/bootloader/*" > $@ && \ find libs -name "*.[ch]" -not -path "*/kissfft/*" >> $@ && \ find am335x -name "*.cpp" -o -name "*.h" -not -path "*/bootloader/*" >> find rtos -name "*.c" -o -name "*.h" -o -name "*.cpp" >> $@ clean: @rm cscope.*
DISPLAY TAB
---------------------
Not quite work correctly to show all tabs
:SeeTab vim.wikia.com
OPEN MULTIPLE FILES FROM CMD LINE
-------------------------
qyang@lubuntu-laptop:~/Git_Local_Sandbox/PcapPlot$ vi -g -p *.sh *.py 12 files to edit
TURN ON LINE NUMBER
------------------------
:set number
REPLACE A STRING
-------------------
:1,$s/word1/word2/gc IN A WHOLE FILE
:n1,n2s/word1/word2/gc IN BETWEEN LINE 'n1' and 'n2', special character use '\' prefix. (e.g.,:1,$s/word\[/word1\[/gc, replace 'word[' with 'word1[' )
COMMAND MODE
---------------------
'g0' -- go zero, go to head of line;
'g$' -- go to end of line;
'G' -- go to end of this file;
'H' -- go to top of screen;
'M' -- go to middle of screen;
'L' -- go to bottom of screen;
'nG' -- go to line number 'n'
'/word' -- search a string 'word' forward;
'?word' -- search a string 'word' backward;
'nyy' -- yank/copy n lines after cursor;
'p' -- paste yanked contens one line below cursor;
'dd' -- delete current line;
'nd' -- delete n lines after cursor;
DELETE/COPY(YANK) A BLOCK OF TEXT
----------------------------
The ‘mark command can be very useful when deleting a long series of lines.To
delete a long series of lines, follow these steps:
1. Move the cursor to the beginning of the text you want to delete.
2. Mark it using the command ma. (This marks it with mark a.)
3. Go to the end of the text to be removed. Delete to mark a using the command
d’a.
Note:There is nothing special about using the a mark. Any mark from a to z
may be used.
BACK TO PREVIOUSLY VISITED LOCATION previous view
-----------------------------
Ctrl + O
Ctrl + I (tab)
Jumping_to_previously_visited_locations
JUMP TO SYMBOL DEFINITION when ctags/cscope enabled
------------------------------
Ctrl + ]
Ctrl + T
A 05 Vi Exercise
===============================
[1] http://stackoverflow.com/questions/1737163/traversing-text-in-insert-mode
Insert mode and navigation mode switch
----------------------------------------
ESC or Ctrl+[
Navigation Fast
--------------------
15 + h go backward 15 characters
5 + j go forward 5 lines
Ctrl+o + 2 + b navigate two words back without leaving insert mode
Ctrl+o will give you chance to run one vi command at navigation
mode, then return to insert mode automatically.
'+. back to previous editing place after navigation
Type 20 '-' delete backword 9 '-'
----------------------------------------
20 + i + - + ESC
9 + X
'20' set number of execute times
'i' into insert mode
'-' letter or words you want to repeat
'ESC' back to navigation mode will display all insert letters.
'9' set number of exectue times
'X' delete backward, 'x' delete forward
Paste from clip board
-----------------------------------
"+p
" use register
+ clipboard register index
p paste shortcut key
Corret Typo
----------------------
accifently
FfrdA will correct the word from accifently to accidently
'F' find backward 'f' find forward
'f' find letter 'f'
'r' replace current cursor
'd' type correct letter 'd'
'A' back to original edit place
Rewrite word
--------------------
you accidentlly typed
you intentially typed
you intertially typed
ESC + 2 + b + c + w intentially + ESC + A
Write words in multiple lines
--------------------
[2] http://vim.wikia.com/wiki/Inserting_text_in_multiple_lines
hello
hello
hello
hel:added:loappend
hel:added:loappend
hel:added:loappend
hllo hello append
hllo hello append
hllo hello append
Ctrl+v + navigate coursor to 'l' + j + j + j + I + :added: + ESC
Ctrl+v + navigate coursor to 'o' + l + A + Ctrl+R + "
Ctrl+v + select block you want to delete + d
'Ctrl+v' visual block mode.
'I' insert before current cursor in visual block mode.
'A' append after current cursor in visual block mode.
'Ctrl + R + "' past yank register in insert mode
'Ctrl + R + +' past clipboard insert mode.
Subscribe to:
Posts (Atom)