Showing posts with label arm-linux. Show all posts
Showing posts with label arm-linux. Show all posts

Friday, November 21, 2008

flash jffs2

Use flash on a arm-linux board always requires jffs2.

Here is the command that do flash erase and copy rootfs to mtdblock4.


# flash_eraseall -j /dev/mtd4
# dd if=rootfs.jffs2 of=/dev/mtd4 bs=4096
# mount -t jffs2 /dev/mtdblock4 /mnt/jffs2

Wednesday, October 8, 2008

clone jffs2


mount -t jffs2 /dev/mtdblock4 /mnt/nand
mount /dev/mmcblk0p2 /mnt/mmc2


I use mmc card as the media to save the rootfs at nand flash. It is not as easy as type: "tar czvf /mnt/mmc2/target.tar.gz /mnt/nand/". It won't work within busybox from the ARM target, could be the problem of tar.

How ever here is the magic:

tar cf - -C /mnt/nand . | tar xvf - -C /mnt/mmc2/target


Then pull the SD card and connect to the Linux PC, copy the file system with simply "cp -r /tftpboot /mnt/mmc2/target".

Friday, October 3, 2008

compile mplayer with ALSA for ARM

1. download mplayer source code. I am using (MPlay-1.0rc2.tar.bz2)
2. extract it.
3. write a script mybuild.sh for configuring

export CROSS_CC=/opt/CodeSourcery/arm-2007q3-51
export PATH=$CROSS_CC/bin:$PATH
export TGT="your target file system"
./configure --enable-cross-compile -cc=arm-none-linux-gnueabi-gcc \
--host-cc=gcc --target=arm-linux --prefix=$TGT \
--disable-network --disable-x11 --disable-gui \
--with-extralibdir=$TGT/lib \
--with-extraincdir=$TGT/include


Here $TGT contains alsa include files and library "libasound.so.2".

4. type "make"

Wednesday, August 29, 2007

arm-linux : struct alignment

The following code examine arm structure....

#include < stdio.h >

#define PACKED __attribute__((packed))

typedef struct struct_Foo
{
char c;
int r;
long f;
} PACKED FOO;

typedef struct struct_Foo2
{
char c;
int r;
long f;
} FOO2;

int main(int argc, char* argv[])
{
printf ("Test arm...\n");
printf (" char : %2d\n", sizeof(char));
printf (" int : %2d\n", sizeof(int));
printf (" long : %2d\n", sizeof(long));
printf (" foo : %2d\n", sizeof(FOO));
printf (" foo2 : %2d\n", sizeof(FOO2));
}


and my Makefile:

# where is my tool chains for arm
BLD_NAME=greenphone
BLD_TOOL_VER = gcc-4.1.1-glibc-2.3.6
BLD_TARGET=arm-linux
BLD_PREFIX= /opt/toolchains/greenphone/$(BLD_TOOL_VER)
CROSS_COMPILE=$(BLD_PREFIX)/$(BLD_TARGET)/bin/$(BLD_TARGET)-

# tools... I am using

LD = $(CROSS_COMPILE)ld
CC = $(CROSS_COMPILE)gcc
CPP = $(CC) -E

CFLAGS = -x c

all:
$(CC) $(CFLAGS) -o test test.c


result?

int : 4
long : 4
foo : 9
foo2 : 12

Thursday, August 16, 2007

gdb on arm-linux

It is a little different to debug an application on arm-linux.

First, start gdbserver from the device, 3230 is any port number that is not used by the network.

gdbserver localhost:3230 ./helloworld


Second, start arm-linux-debug from the host,

arm-linux-gdb ./helloworld
target remote 10.10.10.20:3230
b main
c

Here b identify set break point, and c identify continue, they are gdb commands.

Right now, I am debugging without emacs, still hope to configure emacs to support embedded debugging.