diff -crN buildroot-2013.08.1-ckb-20150123-1/board/ckb/common/samples/uart_test/Makefile buildroot-2013.08.1-ckb-20150123-1-new/board/ckb/common/samples/uart_test/Makefile
*** buildroot-2013.08.1-ckb-20150123-1/board/ckb/common/samples/uart_test/Makefile	1970-01-01 09:00:00.000000000 +0900
--- buildroot-2013.08.1-ckb-20150123-1-new/board/ckb/common/samples/uart_test/Makefile	2015-10-14 09:30:35.472170727 +0900
***************
*** 0 ****
--- 1,22 ----
+ # Makefile
+ 
+ BUILDROOT_DIR:=../../../../../
+ CROSS_COMPILE:=$(BUILDROOT_DIR)/output/host/usr/bin/arm-linux-
+ #APP_DEBUG:=-ggdb
+ 
+ CC = $(CROSS_COMPILE)gcc $(APP_DEBUG) -I$(KERNEL_HEADERS)
+ LIB= -ldl -lpthread
+ APP_RECV=uart_recv
+ APP_SEND=uart_send
+ 
+ all:
+ 	$(CC) $(LIB) recv.c -o $(APP_RECV)
+ 	$(CC) $(LIB) send.c -o $(APP_SEND)
+ 
+ clean:
+ 	rm -f *.o $(APP_RECV) $(APP_SEND)
+ 
+ install:
+ 	cp -f $(APP_RECV) $(BUILDROOT_DIR)/output/target/usr/bin/
+ 	cp -f $(APP_SEND) $(BUILDROOT_DIR)/output/target/usr/bin/
+ 
diff -crN buildroot-2013.08.1-ckb-20150123-1/board/ckb/common/samples/uart_test/recv.c buildroot-2013.08.1-ckb-20150123-1-new/board/ckb/common/samples/uart_test/recv.c
*** buildroot-2013.08.1-ckb-20150123-1/board/ckb/common/samples/uart_test/recv.c	1970-01-01 09:00:00.000000000 +0900
--- buildroot-2013.08.1-ckb-20150123-1-new/board/ckb/common/samples/uart_test/recv.c	2015-10-14 09:30:35.472170727 +0900
***************
*** 0 ****
--- 1,130 ----
+ #include <linux/serial.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <unistd.h>
+ #include <fcntl.h>
+ #include <termios.h>
+ #include <string.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <sys/ioctl.h>
+ 
+ #define TTY_DEVICE "/dev/ttyO4"
+ /*
+ /*
+  * Test program for serial control
+  */
+ void help(char *app_name)
+ {
+ 	printf("%s -d [device path]\n", app_name);
+ 	printf("\t-d - tty device path ("TTY_DEVICE")\n");
+ }
+ char input_device[16];
+ 
+ 
+ /******************************************************************************
+ Description.: 
+ Input Value.: 
+ Return Value: 
+ ******************************************************************************/
+ void daemon_mode(void) {
+   int fr=0;
+ 
+   fr = fork();
+   if( fr < 0 ) {
+     fprintf(stderr, "fork() failed\n");
+     exit(1);
+   }
+   if ( fr > 0 ) {
+     exit(0);
+   }
+ 
+   if( setsid() < 0 ) {
+     fprintf(stderr, "setsid() failed\n");
+     exit(1);
+   }
+ 
+   fr = fork();
+   if( fr < 0 ) {
+     fprintf(stderr, "fork() failed\n");
+     exit(1);
+   }
+   if ( fr > 0 ) {
+     fprintf(stderr, "forked to background (%d)\n", fr);
+     exit(0);
+   }
+ 
+   umask(0);
+ 
+   chdir("/");
+   close(0);
+   close(1);
+   close(2);
+ 
+   open("/dev/null", O_RDWR);
+   dup(0);
+   dup(0);
+ }
+ 
+ int main(int argc, char* argv[])
+ {
+ 	char buffer;
+ 	int i, rv, opt;
+ 	struct termios my_termios, new_termios, stdio;
+ 	char shortoptions[] = "d:h";
+ 	int d, index;
+ 	input_device[0] = 0;
+ 
+ 	for (;;) {
+ 		d = getopt_long(argc, argv, shortoptions, (void *)NULL, &index);
+ 		if (-1 == d)
+ 		{
+ 			break;
+ 		}
+ 		switch (d) {
+ 		case 'd':
+ 			strcpy(input_device, optarg);
+ 			break;
+ 		default:
+ 			help(argv[0]);
+ 			exit(1);
+ 		}
+ 	}
+ 	if(input_device[0] == 0)
+ 	{
+ 		strcpy(input_device, TTY_DEVICE);
+ 	}
+ 
+ 	int fd2 = open(input_device, O_RDWR | O_NOCTTY | O_NDELAY);
+ 
+ 	tcgetattr(fd2, &my_termios);
+ 	my_termios.c_iflag &= ~(IGNBRK | BRKINT | ICRNL | INLCR | PARMRK | INPCK | ISTRIP | IXON);
+ 	my_termios.c_oflag &= ~(OCRNL | ONLCR | ONLRET | ONOCR | OFILL | OLCUC | OPOST);
+ 	my_termios.c_lflag &= ~(ECHO | ECHOE | ECHOKE | ECHONL | ICANON | IEXTEN | ISIG | ECHOK | ECHOCTL | ECHOPRT);
+ 	my_termios.c_cflag &= ~(CSIZE | PARENB);
+ 	my_termios.c_cflag &= ~CRTSCTS;
+ 	my_termios.c_cflag |= CS8 | CLOCAL | CREAD;
+ 	my_termios.c_cflag &= ~CBAUD;
+ 	my_termios.c_cflag |= B19200;
+ 	my_termios.c_cc[VMIN] = 1;
+ 	my_termios.c_cc[VTIME] = 5;
+ 	rv = tcsetattr(fd2, TCSANOW, &my_termios);
+ 	tcgetattr(fd2, &new_termios);
+ 
+ 	fcntl(STDIN_FILENO, F_SETFL, O_NONBLOCK);
+ 
+ 	printf("Reading (hit q and Enter to quit)...\n");
+ 	while(1)
+ 	{
+ 		if(read(fd2, &buffer, 1) > 0)
+ 		{
+ 			write(STDOUT_FILENO, &buffer, 1);
+ 		}
+ 		if(read(STDIN_FILENO, &buffer, 1) > 0) {
+ 			if (buffer == 'q') {
+ 				break;
+ 			}
+ 		}
+ 	}
+ 	close(fd2);
+ }
diff -crN buildroot-2013.08.1-ckb-20150123-1/board/ckb/common/samples/uart_test/send.c buildroot-2013.08.1-ckb-20150123-1-new/board/ckb/common/samples/uart_test/send.c
*** buildroot-2013.08.1-ckb-20150123-1/board/ckb/common/samples/uart_test/send.c	1970-01-01 09:00:00.000000000 +0900
--- buildroot-2013.08.1-ckb-20150123-1-new/board/ckb/common/samples/uart_test/send.c	2015-10-14 09:30:35.476170720 +0900
***************
*** 0 ****
--- 1,151 ----
+ #include <linux/serial.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <unistd.h>
+ #include <fcntl.h>
+ #include <termios.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ 
+ #define TTY_DEVICE 		"/dev/ttyO4"
+ #define NUM_PACKETS		30
+ #define SEND_LEN 		20
+ /*
+  * Test program for serial control
+  */
+ void help(char *app_name)
+ {
+ 	printf("%s -d [device path] -i [num of packets] -n -b\n", app_name);
+ 	printf("\t-d - tty device path ("TTY_DEVICE")\n");
+ 	printf("\t-i - Number of packets to transmit (%d)\n", NUM_PACKETS);
+ 	printf("\t-n - Include new-line after every transmit\n");
+ 	printf("\t-b - Execute in background\n");
+ }
+ char input_device[16];
+ 
+ 
+ /******************************************************************************
+ Description.: 
+ Input Value.: 
+ Return Value: 
+ ******************************************************************************/
+ void daemon_mode(void) {
+   int fr=0;
+ 
+   fr = fork();
+   if( fr < 0 ) {
+     fprintf(stderr, "fork() failed\n");
+     exit(1);
+   }
+   if ( fr > 0 ) {
+     exit(0);
+   }
+ 
+   if( setsid() < 0 ) {
+     fprintf(stderr, "setsid() failed\n");
+     exit(1);
+   }
+ 
+   fr = fork();
+   if( fr < 0 ) {
+     fprintf(stderr, "fork() failed\n");
+     exit(1);
+   }
+   if ( fr > 0 ) {
+     fprintf(stderr, "forked to background (%d)\n", fr);
+     exit(0);
+   }
+ 
+   umask(0);
+ 
+   chdir("/");
+   close(0);
+   close(1);
+   close(2);
+ 
+   open("/dev/null", O_RDWR);
+   dup(0);
+   dup(0);
+ }
+ 
+ int main(int argc, char* argv[])
+ {
+ 	char buffer[SEND_LEN+1];
+ 	int i, rv, opt;
+ 	struct termios my_termios, new_termios;
+ 	char shortoptions[] = "d:i:nbh";
+ 	int d, index;
+ 	input_device[0] = 0;
+ 	int daemon = 0;
+ 	int nl = 0;
+ 	int send_len = SEND_LEN;
+ 	int num_packets = NUM_PACKETS; 
+ 	buffer[SEND_LEN] = '\n';
+ 	for (;;) {
+ 		d = getopt_long(argc, argv, shortoptions, (void *)NULL, &index);
+ 		if (-1 == d)
+ 		{
+ 			break;
+ 		}
+ 		switch (d) {
+ 		case 'd':
+ 			strcpy(input_device, optarg);
+ 			break;
+ 		case 'i':
+ 			num_packets = atoi(optarg);
+ 			break;
+ 		case 'n':
+ 			send_len++;
+ 			break;
+ 		case 'b':
+ 			daemon = 1;
+ 			break;
+ 		default:
+ 			help(argv[0]);
+ 			exit(1);
+ 		}
+ 	}
+ 	if(num_packets == 0)
+ 	{
+ 		printf("No packets sent\n");
+ 		return;
+ 	}
+ 		
+ 	if(input_device[0] == 0)
+ 	{
+ 		strcpy(input_device, TTY_DEVICE);
+ 	}
+ 	if(daemon)
+ 		daemon_mode();
+ 		
+ 	int fd0 = open(input_device, O_RDWR | O_NDELAY | O_NOCTTY);
+ 
+ 	tcgetattr(fd0, &my_termios);
+ 	my_termios.c_iflag &= ~(IGNBRK | BRKINT | ICRNL | INLCR | PARMRK | INPCK | ISTRIP | IXON);
+ 	my_termios.c_oflag &= ~(OCRNL | ONLCR | ONLRET | ONOCR | OFILL | OLCUC | OPOST);
+ 	my_termios.c_lflag &= ~(ECHO | ECHONL | ICANON | IEXTEN | ISIG | ECHOK | ECHOCTL | ECHOPRT);
+ 	my_termios.c_cflag &= ~(CSIZE | PARENB);
+ 	my_termios.c_cflag &= ~CRTSCTS;
+ 	my_termios.c_cflag |= CS8 | CLOCAL;
+ 	my_termios.c_cflag &= ~CBAUD;
+ 	my_termios.c_cflag |= B19200;
+ 	my_termios.c_cc[VMIN] = 1;
+ 	my_termios.c_cc[VTIME] = 0;
+ 	rv = tcsetattr(fd0, TCSANOW, &my_termios);
+ 	tcgetattr(fd0, &new_termios);
+ 
+ 	for (i = 0; i < SEND_LEN; i++) {
+ 		buffer[i] = 'A'+i;
+ 	}
+ 	printf("Sending %d packets...\n", num_packets);
+ 	i = 0;
+ 	while(1)
+ 	{
+ 		printf("Writing [%d]\n", i);
+ 		write(fd0, buffer, send_len);
+ 		if(++i == num_packets)
+ 			break;
+ 		sleep(1);
+ 	}
+ 	close(fd0);
+ }
diff -crN buildroot-2013.08.1-ckb-20150123-1/board/ckb/Config.in buildroot-2013.08.1-ckb-20150123-1-new/board/ckb/Config.in
*** buildroot-2013.08.1-ckb-20150123-1/board/ckb/Config.in	2015-10-14 09:41:16.688165002 +0900
--- buildroot-2013.08.1-ckb-20150123-1-new/board/ckb/Config.in	2015-10-14 09:43:24.288692500 +0900
***************
*** 168,173 ****
--- 168,180 ----
  	help
  		This will build the SPI device sample application \"spidev_test\".
  
+ config BR2_CKB_UART_TEST_APP
+ 	bool "UART sample"
+ 	default y
+ 	help
+ 		This will build UART samples applications \"uart_recv\" and \"uart_send\".
+ 
+ 
  if BR2_BOARD_CKB_1808
  config BR2_CKB_EXT_CN5_MEM_SAMPLE
  	bool "External connector memory sample"
diff -crN buildroot-2013.08.1-ckb-20150123-1/board/ckb/Makefile.in buildroot-2013.08.1-ckb-20150123-1-new/board/ckb/Makefile.in
*** buildroot-2013.08.1-ckb-20150123-1/board/ckb/Makefile.in	2015-10-14 09:41:16.688165002 +0900
--- buildroot-2013.08.1-ckb-20150123-1-new/board/ckb/Makefile.in	2015-10-14 09:43:41.174702000 +0900
***************
*** 334,339 ****
--- 334,354 ----
  			|| ! [ -e "$(TARGET_DIR)/$(FIRMWARE_DIR)/cmj100/wl1271-nvs.bin" ] ; then \
  */	
  
+ uart_test:
+ 	@$(call MESSAGE, "**************************************************************")
+ 		@$(call MESSAGE, "Building uart_test sample applications")
+ 	@$(call MESSAGE, "**************************************************************")
+ 	@make CROSS_COMPILE="$(TARGET_CROSS)" \
+ 		CFLAGS="$(TARGET_CFLAGS)" \
+ 		LDFLAGS="$(TARGET_LDFLAGS)" \
+ 		OUTPUT_DIR="$(O)" \
+ 		-C $(BOARD_COMMON_DIR)/samples/uart_test
+ 	@cp $(BOARD_COMMON_DIR)/samples/uart_test/uart_recv $(TARGET_DIR)/bin/
+ 	@cp $(BOARD_COMMON_DIR)/samples/uart_test/uart_send $(TARGET_DIR)/bin/
+ 
+ uart_test-clean:
+ 	make clean -C $(BOARD_COMMON_DIR)/samples/uart_test
+ 
  cmj100_module: cmj100_module-clean
  # change to the directory and compile the module
  	@$(call MESSAGE, "**************************************************************")
***************
*** 421,426 ****
--- 436,444 ----
  ifeq ($(BR2_CKB_LISTUP_APP),y)
  TARGETS += listup
  endif
+ ifeq ($(BR2_CKB_UART_TEST_APP),y)
+ TARGETS += uart_test
+ endif
  ifeq ($(BR2_CKB_CGI_SAMPLE),y)
  TARGETS += cgi_build
  endif
diff -crN buildroot-2013.08.1-ckb-20150123-1/configs/ckb-1808_defconfig buildroot-2013.08.1-ckb-20150123-1-new/configs/ckb-1808_defconfig
*** buildroot-2013.08.1-ckb-20150123-1/configs/ckb-1808_defconfig	2015-10-14 09:41:16.692164990 +0900
--- buildroot-2013.08.1-ckb-20150123-1-new/configs/ckb-1808_defconfig	2015-10-14 09:44:13.995956200 +0900
***************
*** 89,94 ****
--- 89,95 ----
  BR2_CKB_CALENDER_SAMPLE=y
  BR2_CKB_GPIO_SAMPLE=y
  BR2_SPIDEV_SAMPLE=y
+ BR2_CKB_UART_TEST_APP=y
  BR2_CKB_EXT_CN5_MEM_SAMPLE=y
  
  #
diff -crN buildroot-2013.08.1-ckb-20150123-1/configs/ckb-3352_defconfig buildroot-2013.08.1-ckb-20150123-1-new/configs/ckb-3352_defconfig
*** buildroot-2013.08.1-ckb-20150123-1/configs/ckb-3352_defconfig	2015-10-14 09:41:16.692164990 +0900
--- buildroot-2013.08.1-ckb-20150123-1-new/configs/ckb-3352_defconfig	2015-10-14 09:44:28.509679100 +0900
***************
*** 94,99 ****
--- 94,100 ----
  BR2_CKB_CALENDER_SAMPLE=y
  BR2_CKB_GPIO_SAMPLE=y
  BR2_SPIDEV_SAMPLE=y
+ BR2_CKB_UART_TEST_APP=y
  BR2_CKB_EXT_CN1_MEM_SAMPLE=y
  BR2_CKB_WDT_SAMPLE=y
  
diff -crN buildroot-2013.08.1-ckb-20150123-1/configs/ckb-rz_defconfig buildroot-2013.08.1-ckb-20150123-1-new/configs/ckb-rz_defconfig
*** buildroot-2013.08.1-ckb-20150123-1/configs/ckb-rz_defconfig	2015-10-14 09:41:16.696164972 +0900
--- buildroot-2013.08.1-ckb-20150123-1-new/configs/ckb-rz_defconfig	2015-10-14 09:44:43.326906800 +0900
***************
*** 94,99 ****
--- 94,100 ----
  BR2_CKB_CALENDER_SAMPLE=y
  BR2_CKB_GPIO_SAMPLE=y
  BR2_SPIDEV_SAMPLE=y
+ BR2_CKB_UART_TEST_APP=y
  BR2_CKB_EX1_CN_CS2_MEM_SAMPLE=y
  # BR2_CKB_EX1_CN_CS2_MEM_16_SAMPLE is not set
  
