User`s manual
UC-8410/8416/8418 LX User’s Manual Programmer’s Guide
5-17
printf(“Usage: %s [pattern]\n”);
exit(0);
}
if ( argc == 2 ) {
pattern=argv[1][0];
printf(“pattern:%c\n”, pattern);
}
fd = open(“/dev/sram”, O_RDWR);
if( fd < 0 ) {
printf(“Open /dev/sram fail”);
exit(0);
}
// Write the sram with pattern
memset(sram_buf1, pattern, sizeof(sram_buf1));
// Read from sram and compare with pattern
len=read(fd, sram_buf2, sizeof(sram_buf2));
if( len < 0 ) {
printf(“Read from /dev/sram fail\n”);
exit(0);
}
if ( memcmp(sram_buf1, sram_buf2, SRAM_SIZE) != 0 ) {
printf(“Memory compared fail\n”);
exit(0);
}
printf(“The content is identical\n”);
close(fd);
}
Make File Example
The following Makefile file sample code is copied from the Hello example on the
UC-8410/8416/8418’s CD-ROM.
CC = xscale-linux-gcc
CPP = xscale-linux-gcc
SOURCES = hello.c
OBJS = $(SOURCES:.c=.o)
all: hello
hello: $(OBJS)
$(CC) -o $@ $^ $(LDFLAGS) $(LIBS)
clean:
rm -f $(OBJS) hello core *.gdb