How to upgrade mini2440/micro2440 kernel image after the systems boots to Linux:
killall processes
mount -o remount,ro /
cd /dev/shm
flash_erase /dev/mtd1 0 16
nandwrite -a -p /dev/mtd1 /zImage_new
Bootloader
There are two "official" bootloaders, supervivi-128M and viv. supervivi is a little bit less than 256K (0x40000), while vivi is only 3-4K. We have supervivi in NOR flash, and viv in NAND flash.
0x0,00000 - 0x0,40000 bootloader
0x0,48000 - 0x0,60000 bootloader parameters (linux_cmd_line starts at 0x48000 and ends with the first 0x0)
0x0,60000 - 0x2,60000 2M of kernel space
0x2,60000 - 0x80,00000 close to 126M application image
Tools to read/write/erase flash after system is booted (all in mtd-utils project):
- flash_erase
- nandwrite
- nanddump
- mtd_debug
echo -n -e "VIVICMDLnoinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0\0000" > /tmp/cmdline
/cmdc/flash_erase /dev/mtd0 0x40000 1
/cmdc/nandwrite -p /dev/mtd0 -s 0x48000 /tmp/cmdline
You can probably use the same nandwrite to update the bootloader itself. I haven't tried that yet.
August 31, 2010
Export MySQL database to CSV file
SELECT * INTO OUTFILE '/tmp/result.text'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM test_table;
And the results are sent to /tmp/result.text in CSV format.
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM test_table;
And the results are sent to /tmp/result.text in CSV format.
August 27, 2010
Thunderbird turn off signature in reply emails
August 23, 2010
defishing an image
Open source software: Hugin/Nona
http://www.pentaxforums.com/forums/pentax-slr-lens-discussion/33634-how-do-you-de-fish.html
http://wiki.panotools.org/Hugin
http://www.flickr.com/groups/67669253@N00/discuss/72157594344672391/
http://sourceforge.net/projects/hugin/files/hugin/
http://www.pbase.com/troyz/defishing_examples
http://www.pentaxforums.com/forums/pentax-slr-lens-discussion/33634-how-do-you-de-fish.html
http://wiki.panotools.org/Hugin
http://www.flickr.com/groups/67669253@N00/discuss/72157594344672391/
http://sourceforge.net/projects/hugin/files/hugin/
http://www.pbase.com/troyz/defishing_examples
August 17, 2010
Remove blank/empty lines from a file
There are many ways to do it:
- grep '.' file > newfile
- awk '/./' file > newfile
August 14, 2010
Vim embedded command in the file edited
This is called "modeline" in vim. you can file help on that.
http://vim.wikia.com/wiki/Modeline_magic
First, make sure modeline is enabled. Then
http://vim.wikia.com/wiki/Modeline_magic
First, make sure modeline is enabled. Then
The following examples show some alternatives that could be in a C file:
// vim: noai:ts=4:sw=4
-or-
/* vim: noai:ts=4:sw=4
*/
-or-
/* vim: set noai ts=4 sw=4: */
-or-
/* vim: set fdm=expr fde=getline(v\:lnum)=~'{'?'>1'\:'1': */
With "set", the modeline ends at the first colon not following a backslash. Without "set", no text can follow the options, so for example, the following is invalid:
Error E518: Unknown option: */
/* vim: noai:ts=4:sw=4 */
August 10, 2010
Disable ssh server reverse dns lookup
Add/Edit the following lines to your /etc/ssh/sshd_config and restart ssh service
UseDNS no
GSSAPIAuthentication no
GatewayPorts yes
UseDNS no
GSSAPIAuthentication no
To enable remote port forwarding for all the computers on your subnet, add this:
August 5, 2010
Open source Windows TCP Serial port server
Download the Serproxy zip source code , and compile it using the following Makefile using mingw-32.
#
# File:Windows serproxy makefile
#
# (C)1999 Stefano Busti
#
VERSION = `cat VERSION`
SRCS = \
main.c sio.c sock.c thread.c vlist.c cfglib.c config.c string.c \
pipe.c error.c
OBJS = \
main.o sio.o sock.o thread.o vlist.o cfglib.o config.o string.o \
pipe.c error.c
CC = gcc
ifdef DEBUG
CFLAGS = -Wall -g -D__UNIX__ -DDEBUG
else
CFLAGS = -Wall -O2 -fomit-frame-pointer -D__WIN32__ -DWINTHREADS -DSOCK_WIN -DSIO_WIN32
endif
ifdef USE_EF
#LIBS= -lpthread -lefence
else
#LIBS= -lpthread
endif
LIBS=-lws2_32
# Build the program
serproxy: $(SRCS) $(OBJS)
$(CC) $(CFLAGS) -o serproxy $(OBJS) $(LDFLAGS) $(LIBS)
install: serproxy
cp -f serproxy /usr/local/bin
clean:
rm -f *.o *~
realclean:
rm -f *.o *~ serproxy *.gz *.zip
dep:
makedepend -Y -- $(CFLAGS) -- $(SRCS) 2&>/dev/null
# DO NOT DELETE
main.o: sio.h sock.h pipe.h thread.h vlist.h cfglib.h config.h error.h
sio.o: sio.h
sock.o: sock.h
thread.o: thread.h
vlist.o: vlist.h
cfglib.o: cfglib.h
config.o: config.h cfglib.h string.h
string.o: string.h
pipe.o: pipe.h sio.h sock.h thread.h
error.o: error.h
Cross Compile PHP 5.3.3 to ARM
Updated on 2012/05/08 for Compiling PHP 5.4.2 enabling FPM (fastcgi)
1. ./configure --host=arm-linux --without-pear --disable-simplexml --disable-mbregex --enable-sockets --enable-pdo --with-pdo-sqlite --with-sqlite3 --disable-all
2. vi Makefile, search for "-lcrypt", add "-ldl" to the same line.
3. make -j 12
4. php-cgi is in sapi/cgi.
5. use arm-linux-strip php-cgi to strip out the symbols
Done.
-- To compile PHP 5.4.2 with FPM enabled--
1. First edit the "configure" file to remove checking of ptrace and proc mem file (both should be set to yes, broken_ptrace set to no). If you don't need FPM, no change to configure script is necessary.
My new version of this section looks like this:
have_broken_ptrace=no
have_ptrace=yes
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ptrace works" >&5
$as_echo_n "checking whether ptrace works... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
if test "$have_ptrace" = "yes"; then
$as_echo "#define HAVE_PTRACE 1" >>confdefs.h
fi
...
Done.
1. ./configure --host=arm-linux --without-pear --disable-simplexml --disable-mbregex --enable-sockets --enable-pdo --with-pdo-sqlite --with-sqlite3 --disable-all
2. vi Makefile, search for "-lcrypt", add "-ldl" to the same line.
3. make -j 12
4. php-cgi is in sapi/cgi.
5. use arm-linux-strip php-cgi to strip out the symbols
Done.
-- To compile PHP 5.4.2 with FPM enabled--
1. First edit the "configure" file to remove checking of ptrace and proc mem file (both should be set to yes, broken_ptrace set to no). If you don't need FPM, no change to configure script is necessary.
My new version of this section looks like this:
have_broken_ptrace=no
have_ptrace=yes
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ptrace works" >&5
$as_echo_n "checking whether ptrace works... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
if test "$have_ptrace" = "yes"; then
$as_echo "#define HAVE_PTRACE 1" >>confdefs.h
fi
...
proc_mem_file="mem"
if test -n "$proc_mem_file" ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for proc mem file" >&5
$as_echo_n "checking for proc mem file... " >&6; }
if test "$cross_compiling" = no; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $proc_mem_file" >&5
$as_echo "$proc_mem_file" >&6; }
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
2. CC=arm-none-linux-gnueabi-gcc ./configure --host=arm-linux --without-pear --disable-simplexml --disable-mbregex --enable-sockets --enable-pdo --with-pdo-sqlite --with-sqlite3 --enable-fpm --disable-all
3. make -j 12
4. php-fpm is at sapi/cgi
5. use arm-linux-strip php-fpm to strip out the symbols
Done.
August 1, 2010
Subscribe to:
Posts (Atom)