Moxa UC-8416-T-LX [68/90] Make file example

Moxa UC-8410-LX [68/90] Make file example
UC-8410/8416/8418/8430 Programmer's Guide
5-16
}
/**************************************************************
History :
Versoin Author Date Comment
1.0 Jared Wu. 09-11-2008 Read from the SRAM and compare with some pattern.
**************************************************************/
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <linux/kd.h>
#define SRAM_SIZE 0x00040000 // 256 Kbytes
static char sram_buf1[SRAM_SIZE], sram_buf2[SRAM_SIZE];
int main(int argc, char * argv[])
{
int fd, len;
unsigned long ms=0;
char pattern=‘9’;
if ( argc > 2 ) {
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/8430’s
CD-ROM.
CC = xscale-linux-gcc

Содержание

Скачать