ÀÌ ¸Å´º¾óÀº JKÀüÀÚ(JK Electronics) ¿¡ ÀÇÇؼ ¹ø¿ª, ¼öÁ¤, ÀÛ¼º µÇ¾ú°í ¼ÒÀ¯±Ç ¶ÇÇÑ JKÀüÀÚ(JK Electronics)ÀÇ °ÍÀÔ´Ï´Ù. ¼ÒÀ¯±ÇÀÚÀÇ Çã°¡¸¦ ¹ÞÁö ¾Ê°í ¹«´ÜÀ¸·Î ¼öÁ¤, »èÁ¦Çϰųª ¹èÆ÷ ÇÒ ¼ö ¾ø½À´Ï´Ù. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
S3C6410 Start Kit Linux ÄÜ¼Ö ¾îÇø®ÄÉÀÌ¼Ç Developer Guide |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
* Update history - 2011.1.13 : Ãʱâ Release |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
S3C6410 Startkit ÀÇ ¸ðµç ¿¹Á¦¿Í ÄÄÆÄÀÏ °úÁ¤Àº VMWare¿¡ ¼³Ä¡µÈ Fedora9 ¸Ó½Å¿¡¼ ½ÇÇà ÇÏ¿´½À´Ï´Ù. ´Ù¸¥
¸®´ª½º ȯ°æ¿¡¼´Â Å×½ºÆ® µÇÁö ¾Ê¾Ò½À´Ï´Ù. Æóµµ¶ó ¸®´ª½ºÀÇ Àüü ¼³Ä¡ °úÁ¤Àº ¿©±â Installation
Fedora9 À» ÂüÁ¶ÇϽñ⠹ٶø´Ï´Ù.
|
#include
<stdio.h> int main(void) { printf("hello, FriendlyARM!\n"); } |
Step1 : Compile Hello, World
# cd
/opt/FriendlyARM/mini6410/linux/examples/hello
# make
ÄÄÆÄÀÏÀÌ ¿Ï·áµÈ ¹ÙÀ̳ʸ® ÆÄÀÏÀÇ Á¤º¸¸¦ º¼ ¼ö ÀÖ½À´Ï´Ù.
Step2 : Download Hello, World example to development board
°³¹ßº¸µå¿¡ ÄÄÆÄÀÏµÈ ¿¹Á¦¸¦ ´Ù¿î·Îµå ÇÏ´Â ¹æ¹ý¿¡´Â 4°¡Áö Á¤µµÀÇ ¹æ¹ýÀÌ ÀÖ½À´Ï´Ù.
(1) FTP¸¦ ÀÌ¿ëÇÑ ´Ù¿î·ÎµåÇÏ´Â ¹æ¹ý
(2) USB ¸Þ¸ð¸® or SD ¸Þ¸ð¸® Ä«µå¸¦ ÀÌ¿ëÇؼ Ÿ°Ù º¸µå¿¡ ¸¶¿îÆ® ÈÄ º¹»çÇÏ´Â ¹æ¹ý
(3) ½Ã¸®¾ó Æ÷Æ®¸¦ ÀÌ¿ëÇؼ ´Ù¿î·Îµå ÇÏ´Â ¹æ¹ý
(4) NFS¸¦ ÀÌ¿ëÇؼ ¹Ù·Î ½ÇÇà ÇÏ´Â ¹æ¹ý
(1) FTP¸¦ ÀÌ¿ëÇÑ ´Ù¿î·ÎµåÇÏ´Â ¹æ¹ý (recommended)
¾Æ·¡¿Í °°ÀÌ °³¹ß¿ë Linux PC¿¡¼ Ÿ°Ù º¸µå¿¡ FTP·Î Á¢¼ÓÈÄ ´Ù¿î·Îµå ÇÕ´Ï´Ù.
´Ù¿î·Îµå°¡ ¿Ï·áµÇ¸é Ÿ°Ù º¸µå¿¡¼ ´Ù¿î·ÎµåÇÑ ÆÄÀÏ¿¡ ½ÇÇà ±ÇÇÑÀ» ºÎ¿© ÇÕ´Ï´Ù.
(2) USB ¸Þ¸ð¸® or SD ¸Þ¸ð¸® Ä«µå¸¦ ÀÌ¿ëÇؼ Ÿ°Ù º¸µå¿¡ ¸¶¿îÆ® ÈÄ º¹»çÇÏ´Â ¹æ¹ý
PC¿¡¼ ¾Æ·¡ ¸í·ÉÀ» ÀÌ¿ëÇؼ USB ¸Þ¸ð¸®¸¦ ¸¶¿îÆ® ÇÑ´ÙÀ½ ¿¹Á¦ ÆÄÀÏÀ» USB¸Þ¸ð¸®¿¡ º¹»çÇÕ´Ï´Ù.
# mount /dev/sda1 /mnt
# cp hello /mnt
# umount /mnt
USB ¸Þ¸ð¸®¸¦ Ÿ°Ù °³¹ßº¸µå¿¡ ¿¬°á Çϸé ÀÚµ¿À¸¸® /udisk·Î ¸¶¿îÆ®°¡ µÇ°í ¾Æ·¡°ú °°Àº ¸í·ÉÀ¸·Î ½ÇÇà ÇØ º¼ ¼ö ÀÖ½À´Ï´Ù.
# cd /udisk
# ./hello
(3) ½Ã¸®¾ó Æ÷Æ®¸¦ ÀÌ¿ëÇؼ ´Ù¿î·Îµå ÇÏ´Â ¹æ¹ý
½Ã¸®¾óÀ» ÅëÇÑ ÆÄÀÏ ´Ù¿î·Îµå ÇÏ´Â ¹æ¹ýÀº ¸®´ª½º »ç¿ëÀÚ °¡À̵å "1.2.4 ½Ã¸®¾ó Æ÷Æ®¸¦ ÀÌ¿ëÇÑ PCÆÄÀÏ Àü¼Û" À» ÂüÁ¶ÇϽñâ
¹Ù¶ø´Ï´Ù.
´Ù¿î·ÎµåÇÑ ÆÄÀÏ¿¡ ½ÇÇà ±ÇÇÑÀ» ºÎ¿© ÇÕ´Ï´Ù.
# chmod +x hello
(4) NFS¸¦ ÀÌ¿ëÇؼ ¹Ù·Î ½ÇÇà ÇÏ´Â ¹æ¹ý
"192.168.1.111" ´Â NFS¼¹ö PCÀÇ IP ÁÖ¼Ò ÀÔ´Ï´Ù.
# mount -t nfs -o nolock
192.168.1.111:/opt/FriendlyARM/mini6410/linux/rootfs_qtopia_qt4 /mnt
NFS¸¶¿îÆ®°¡ ¼º°øÀûÀ¸·Î ¿¬°áÀÌ µÇ¸é /mnt µð·ºÅ丮¿¡ NFS¼¹öÀÇ
"opt/FriendlyARM/mini6410/linux/rootfs_qtopia_qt4" µð·ºÅ丮°¡ ¸¶¿îÆ® µÇ¾î Á¢±Ù ÇÒ ¼ö
ÀÖ½À´Ï´Ù.
# cd /mnt
# ./hello
µå¶óÀ̹ö ¼Ò½º ÆÄÀÏ À̸§ | mini6410_leds.c |
Device Type | misc |
Device Name | /dev/leds |
¼Ò½º µð·ºÅ丮 | /opt/FriendlyARM/mini6410/linux/examples/leds |
¿¹Á¦ À̸§ | led.c |
¿¹Á¦ ½ÇÇà ÆÄÀÏ À̸§ | led |
LED driver has been compiled into the default kernel, so can not be loaded using insmod. | |
#include
<stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/ioctl.h> int main(int argc, char **argv) { int on; int led_no; int fd; /* check led control of two parameters, if no parameter input is out. */ if (argc != 3 || sscanf(argv[1], "%d", &led_no) != 1 || sscanf(argv[2],"%d", &on) != 1 || on < 0 || on > 1 || led_no < 0 || led_no > 3) { fprintf(stderr, "Usage: leds led_no 0|1\n"); exit(1); } /* open /dev/ leds device file */ fd = open("/dev/leds0", 0); if (fd < 0) { fd = open("/dev/leds", 0); } if (fd < 0) { perror("open device leds"); exit(1); } /* the ioctl system call and input the parameter control led */ ioctl(fd, on, led_no); /* close the device handle */ close(fd); return 0; } |
ÄÄÆÄÀÏÇÏ°í Ÿ°Ùº¸µå¿¡ ´Ù¿î·Îµå Çؼ ½ÇÇàÇÏ´Â ¹æ¹ýÀº Hello, World ¿¹Á¦¿Í µ¿ÀÏ ÇÕ´Ï´Ù.
µå¶óÀ̹ö ¼Ò½º µð·ºÅ丮 | /opt/FriendlyARM/mini6410/linux/linux-2.6.36/drivers/char |
µå¶óÀ̹ö ¼Ò½º ÆÄÀÏ À̸§ | Mini6410_buttons.c |
Device Type | misc |
Device Name | /dev/buttons |
¼Ò½º µð·ºÅ丮 | /opt/FriendlyARM/mini6410/linux/examples/buttons |
¿¹Á¦ À̸§ | buttons_test.c |
¿¹Á¦ ½ÇÇà ÆÄÀÏ À̸§ | buttons |
Button driver has been compiled into the default kernel, so can not be loaded using insmod. | |
#include
<stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/select.h> #include <sys/time.h> #include <errno.h> int main(void) { int buttons_fd; char buttons[6] = {'0', '0', '0', '0', '0', '0'}; buttons_fd = open("/dev/buttons", 0); if (buttons_fd < 0) { perror("open device buttons"); exit(1); } for (;;) { char current_buttons[6]; int count_of_changed_key; int i; if (read(buttons_fd, current_buttons, sizeof current_buttons) != sizeof current_buttons) { perror("read buttons:"); exit(1); } for (i = 0, count_of_changed_key = 0; i < sizeof buttons / sizeof buttons[0]; i++) { if (buttons[i] != current_buttons[i]) { buttons[i] = current_buttons[i]; printf("%skey %d is %s", count_of_changed_key? ", ": "", i+1, buttons[i] == '0' ? "up" : "down"); count_of_changed_key++; } } if (count_of_changed_key) { printf("\n"); } } close(buttons_fd); return 0; } |
µå¶óÀ̹ö ¼Ò½º µð·ºÅ丮 | /opt/FriendlyARM/mini6410/linux/linux-2.6.36/drivers/char |
µå¶óÀ̹ö ¼Ò½º ÆÄÀÏ À̸§ | Mini6410_pwm.c |
Device Type | misc |
Device Name | /dev/pwm |
¼Ò½º µð·ºÅ丮 | /opt/FriendlyARM/mini6410/linux/examples/pwm |
¿¹Á¦ À̸§ | pwm_test.c |
¿¹Á¦ ½ÇÇà ÆÄÀÏ À̸§ | Pwm_test |
PWM driver has been compiled into the default kernel, so can not be loaded using insmod. | |
#include
<stdio.h> #include <termios.h> #include <unistd.h> #include <stdlib.h> #define PWM_IOCTL_SET_FREQ 1 #define PWM_IOCTL_STOP 2 #define ESC_KEY 0x1b static int getch(void) { struct termios oldt,newt; int ch; if (!isatty(STDIN_FILENO)) { fprintf(stderr, "this problem should be run at a terminal\n"); exit(1); } // save terminal setting if(tcgetattr(STDIN_FILENO, &oldt) < 0) { perror("save the terminal setting"); exit(1); } // set terminal as need newt = oldt; newt.c_lflag &= ~( ICANON | ECHO ); if(tcsetattr(STDIN_FILENO,TCSANOW, &newt) < 0) { perror("set terminal"); exit(1); } ch = getchar(); // restore termial setting if(tcsetattr(STDIN_FILENO,TCSANOW,&oldt) < 0) { perror("restore the termial setting"); exit(1); } return ch; } static int fd = -1; static void close_buzzer(void); static void open_buzzer(void) { fd = open("/dev/pwm", 0); if (fd < 0) { perror("open pwm_buzzer device"); exit(1); } // any function exit call will stop the buzzer atexit(close_buzzer); } static void close_buzzer(void) { if (fd >= 0) { ioctl(fd, PWM_IOCTL_STOP); close(fd); fd = -1; } } static void set_buzzer_freq(int freq) { // this IOCTL command is the key to set frequency int ret = ioctl(fd, PWM_IOCTL_SET_FREQ, freq); if(ret < 0) { perror("set the frequency of the buzzer"); exit(1); } } static void stop_buzzer(void) { int ret = ioctl(fd, PWM_IOCTL_STOP); if(ret < 0) { perror("stop the buzzer"); exit(1); } } int main(int argc, char **argv) { int freq = 1000 ; open_buzzer(); printf( "\nBUZZER TEST ( PWM Control )\n" ); printf( "Press +/- to increase/reduce the frequency of the BUZZER\n" ) ; printf( "Press 'ESC' key to Exit this program\n\n" ); while( 1 ) { int key; set_buzzer_freq(freq); printf( "\tFreq = %d\n", freq ); key = getch(); switch(key) { case '+': if( freq < 20000 ) freq += 10; break; case '-': if( freq > 11 ) freq -= 10 ; break; case ESC_KEY: case EOF: stop_buzzer(); exit(0); default: break; } } } |
µå¶óÀ̹ö ¼Ò½º µð·ºÅ丮 | /opt/FriendlyARM/mini6410/linux/linux-2.6.36/drivers/i2c/busses |
µå¶óÀ̹ö ¼Ò½º ÆÄÀÏ À̸§ | I2c-s3c2410.c |
Device Type | Char device |
Device Name | /dev/i2c/0 |
¼Ò½º µð·ºÅ丮 | /opt/FriendlyARM/mini6410/linux/examples/i2c |
¿¹Á¦ À̸§ | eeprog.c 24cXX.c |
¿¹Á¦ ½ÇÇà ÆÄÀÏ À̸§ | i2c |
PWM driver has been compiled into the default kernel, so can not be loaded using insmod. | |
#include
<stdio.h> #include <fcntl.h> #include <getopt.h> #include <unistd.h> #include <stdlib.h> #include <errno.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include "24cXX.h" #define usage_if(a) do { do_usage_if( a , __LINE__); } while(0); void do_usage_if(int b, int line) { const static char *eeprog_usage = "I2C-24C08(256 bytes) Read/Write Program, ONLY FOR TEST!\n" "FriendlyARM Computer Tech. 2009\n"; if(!b) return; fprintf(stderr, "%s\n[line %d]\n", eeprog_usage, line); exit(1); } #define die_if(a, msg) do { do_die_if( a , msg, __LINE__); } while(0); void do_die_if(int b, char* msg, int line) { if(!b) return; fprintf(stderr, "Error at line %d: %s\n", line, msg); fprintf(stderr, " sysmsg: %s\n", strerror(errno)); exit(1); } static int read_from_eeprom(struct eeprom *e, int addr, int size) { int ch, i; for(i = 0; i < size; ++i, ++addr) { die_if((ch = eeprom_read_byte(e, addr)) < 0, "read error"); if( (i % 16) == 0 ) printf("\n %.4x| ", addr); else if( (i % 8) == 0 ) printf(" "); printf("%.2x ", ch); fflush(stdout); } fprintf(stderr, "\n\n"); return 0; } static int write_to_eeprom(struct eeprom *e, int addr) { int i; for(i=0, addr=0; i<256; i++, addr++) { if( (i % 16) == 0 ) printf("\n %.4x| ", addr); else if( (i % 8) == 0 ) printf(" "); printf("%.2x ", i); fflush(stdout); die_if(eeprom_write_byte(e, addr, i), "write error"); } fprintf(stderr, "\n\n"); return 0; } int main(int argc, char** argv) { struct eeprom e; int op; op = 0; usage_if(argc != 2 || argv[1][0] != '-' || argv[1][2] != '\0'); op = argv[1][1]; fprintf(stderr, "Open /dev/i2c/0 with 8bit mode\n"); die_if(eeprom_open("/dev/i2c/0", 0x50, EEPROM_TYPE_8BIT_ADDR, &e) < 0, "unable to open eeprom device file " "(check that the file exists and that it's readable)"); switch(op) { case 'r': fprintf(stderr, " Reading 256 bytes from 0x0\n"); read_from_eeprom(&e, 0, 256); break; case 'w': fprintf(stderr, " Writing 0x00-0xff into 24C08 \n"); write_to_eeprom(&e, 0); break; default: usage_if(1); exit(1); } eeprom_close(&e); return 0; } |
µå¶óÀ̹ö ¼Ò½º µð·ºÅ丮 | /opt/FriendlyARM/mini6410/linux/linux-2.6.36/drivers/serial/ |
µå¶óÀ̹ö ¼Ò½º ÆÄÀÏ À̸§ | S3c6400.c |
Device Name | /dev/ttySAC0,1,2,4 |
¼Ò½º µð·ºÅ丮 | /opt/FriendlyARM/mini6410/linux/examples/comtest |
¿¹Á¦ À̸§ | comtest.c |
¿¹Á¦ ½ÇÇà ÆÄÀÏ À̸§ | armcomtest |
Test program compiled x86 version and arm version available, and its source code is exactly the same | |
# include
<stdio.h> # include <stdlib.h> # include <termio.h> # include <unistd.h> # include <fcntl.h> # include <getopt.h> # include <time.h> # include <errno.h> # include <string.h> static void Error(const char *Msg) { fprintf (stderr, "%s\n", Msg); fprintf (stderr, "strerror() is %s\n", strerror(errno)); exit(1); } static void Warning(const char *Msg) { fprintf (stderr, "Warning: %s\n", Msg); } static int SerialSpeed(const char *SpeedString) { int SpeedNumber = atoi(SpeedString); # define TestSpeed(Speed) if (SpeedNumber == Speed) return B##Speed TestSpeed(1200); TestSpeed(2400); TestSpeed(4800); TestSpeed(9600); TestSpeed(19200); TestSpeed(38400); TestSpeed(57600); TestSpeed(115200); TestSpeed(230400); Error("Bad speed"); return -1; } static void PrintUsage(void) { fprintf(stderr, "comtest - interactive program of comm port\n"); fprintf(stderr, "press [ESC] 3 times to quit\n\n"); fprintf(stderr, "Usage: comtest [-d device] [-t tty] [-s speed] [-7] [-c] [-x] [-o] [-h]\n"); fprintf(stderr, " -7 7 bit\n"); fprintf(stderr, " -x hex mode\n"); fprintf(stderr, " -o output to stdout too\n"); fprintf(stderr, " -c stdout output use color\n"); fprintf(stderr, " -h print this help\n"); exit(-1); } static inline void WaitFdWriteable(int Fd) { fd_set WriteSetFD; FD_ZERO(&WriteSetFD); FD_SET(Fd, &WriteSetFD); if (select(Fd + 1, NULL, &WriteSetFD, NULL, NULL) < 0) { Error(strerror(errno)); } } int main(int argc, char **argv) { int CommFd, TtyFd; struct termios TtyAttr; struct termios BackupTtyAttr; int DeviceSpeed = B115200; int TtySpeed = B115200; int ByteBits = CS8; const char *DeviceName = "/dev/ttyS0"; const char *TtyName = "/dev/tty"; int OutputHex = 0; int OutputToStdout = 0; int UseColor = 0; opterr = 0; for (;;) { int c = getopt(argc, argv, "d:s:t:7xoch"); if (c == -1) break; switch(c) { case 'd': DeviceName = optarg; break; case 't': TtyName = optarg; break; case 's': if (optarg[0] == 'd') { DeviceSpeed = SerialSpeed(optarg + 1); } else if (optarg[0] == 't') { TtySpeed = SerialSpeed(optarg + 1); } else TtySpeed = DeviceSpeed = SerialSpeed(optarg); break; case 'o': OutputToStdout = 1; break; case '7': ByteBits = CS7; break; case 'x': OutputHex = 1; break; case 'c': UseColor = 1; break; case '?': case 'h': default: PrintUsage(); } } if (optind != argc) PrintUsage(); CommFd = open(DeviceName, O_RDWR, 0); if (CommFd < 0) Error("Unable to open device"); if (fcntl(CommFd, F_SETFL, O_NONBLOCK) < 0) Error("Unable set to NONBLOCK mode"); memset(&TtyAttr, 0, sizeof(struct termios)); TtyAttr.c_iflag = IGNPAR; TtyAttr.c_cflag = DeviceSpeed | HUPCL | ByteBits | CREAD | CLOCAL; TtyAttr.c_cc[VMIN] = 1; if (tcsetattr(CommFd, TCSANOW, &TtyAttr) < 0) Warning("Unable to set comm port"); TtyFd = open(TtyName, O_RDWR | O_NDELAY, 0); if (TtyFd < 0) Error("Unable to open tty"); TtyAttr.c_cflag = TtySpeed | HUPCL | ByteBits | CREAD | CLOCAL; if (tcgetattr(TtyFd, &BackupTtyAttr) < 0) Error("Unable to get tty"); if (tcsetattr(TtyFd, TCSANOW, &TtyAttr) < 0) Error("Unable to set tty"); for (;;) { unsigned char Char = 0; fd_set ReadSetFD; void OutputStdChar(FILE *File) { char Buffer[10]; int Len = sprintf(Buffer, OutputHex ? "%.2X " : "%c", Char); fwrite(Buffer, 1, Len, File); } FD_ZERO(&ReadSetFD); FD_SET(CommFd, &ReadSetFD); FD_SET( TtyFd, &ReadSetFD); # define max(x,y) ( ((x) >= (y)) ? (x) : (y) ) if (select(max(CommFd, TtyFd) + 1, &ReadSetFD, NULL, NULL, NULL) < 0) { Error(strerror(errno)); } # undef max if (FD_ISSET(CommFd, &ReadSetFD)) { while (read(CommFd, &Char, 1) == 1) { WaitFdWriteable(TtyFd); if (write(TtyFd, &Char, 1) < 0) { Error(strerror(errno)); } if (OutputToStdout) { if (UseColor) fwrite("\x1b[01;34m", 1, 8, stdout); OutputStdChar(stdout); if (UseColor) fwrite("\x1b[00m", 1, 8, stdout); fflush(stdout); } } } if (FD_ISSET(TtyFd, &ReadSetFD)) { while (read(TtyFd, &Char, 1) == 1) { static int EscKeyCount = 0; WaitFdWriteable(CommFd); if (write(CommFd, &Char, 1) < 0) { Error(strerror(errno)); } if (OutputToStdout) { if (UseColor) fwrite("\x1b[01;31m", 1, 8, stderr); OutputStdChar(stderr); if (UseColor) fwrite("\x1b[00m", 1, 8, stderr); fflush(stderr); } if (Char == '\x1b') { EscKeyCount ++; if (EscKeyCount >= 3) goto ExitLabel; } else EscKeyCount = 0; } } } ExitLabel: if (tcsetattr(TtyFd, TCSANOW, &BackupTtyAttr) < 0) Error("Unable to set tty"); return 0; } |
µå¶óÀ̹ö ¼Ò½º µð·ºÅ丮 | /opt/FriendlyARM/mini6410/linux/linux-2.6.36/drivers/net/ |
µå¶óÀ̹ö ¼Ò½º ÆÄÀÏ À̸§ | dm9000.c |
Device Name | eth0 |
¼Ò½º µð·ºÅ丮 | /opt/FriendlyARM/mini6410/linux/examples/udptak |
¿¹Á¦ À̸§ | udptalk.c |
¿¹Á¦ ½ÇÇà ÆÄÀÏ À̸§ | udptalk |
Test program compiled x86 version and arm version available, and its source code is exactly the same | |
¿¹Á¦ÀÇ Àüü ÄÚµå´Â ¼Ò½ºÆÄÀÏÀ» ÂüÁ¶Çϼ¼¿ä. |