1
0
Эх сурвалжийг харах

fixed object name copy bug; update AT91SAM7S64 branch.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1787 bbd45198-f89e-11dd-88c7-29a3b14d5316
bernard.xiong 13 жил өмнө
parent
commit
e7eaf16bf4

+ 22 - 22
bsp/sam7s/project.Opt

@@ -14,17 +14,17 @@ Target (RT-Thread/AT91SAM7S), 0x0004 // Tools: 'ARM-ADS'
 GRPOPT 1,(Startup),1,0,0
 GRPOPT 2,(Kernel),0,0,0
 GRPOPT 3,(AT91SAM7S),1,0,0
-GRPOPT 4,(finsh),1,0,0
+GRPOPT 4,(finsh),0,0,0
 
-OPTFFF 1,1,1,352321536,0,0,0,0,<.\application.c><application.c> 
-OPTFFF 1,2,1,402653184,0,0,0,0,<.\board.c><board.c> 
+OPTFFF 1,1,1,0,0,0,0,0,<.\application.c><application.c> 
+OPTFFF 1,2,1,0,0,0,0,0,<.\board.c><board.c> 
 OPTFFF 1,3,1,0,0,0,0,0,<.\startup.c><startup.c> 
-OPTFFF 1,4,5,0,0,0,0,0,<.\rtconfig.h><rtconfig.h> 
+OPTFFF 1,4,5,436207616,0,0,0,0,<.\rtconfig.h><rtconfig.h> 
 OPTFFF 2,5,1,0,0,0,0,0,<..\..\src\clock.c><clock.c> 
-OPTFFF 2,6,1,0,0,0,0,0,<..\..\src\idle.c><idle.c> 
-OPTFFF 2,7,1,0,0,0,0,0,<..\..\src\ipc.c><ipc.c> 
+OPTFFF 2,6,1,167772160,0,0,0,0,<..\..\src\idle.c><idle.c> 
+OPTFFF 2,7,1,436207616,0,0,0,0,<..\..\src\ipc.c><ipc.c> 
 OPTFFF 2,8,1,0,0,0,0,0,<..\..\src\irq.c><irq.c> 
-OPTFFF 2,9,1,0,0,0,0,0,<..\..\src\kservice.c><kservice.c> 
+OPTFFF 2,9,1,385875968,0,0,0,0,<..\..\src\kservice.c><kservice.c> 
 OPTFFF 2,10,1,0,0,0,0,0,<..\..\src\mem.c><mem.c> 
 OPTFFF 2,11,1,0,0,0,0,0,<..\..\src\mempool.c><mempool.c> 
 OPTFFF 2,12,1,0,0,0,0,0,<..\..\src\object.c><object.c> 
@@ -35,24 +35,24 @@ OPTFFF 2,16,1,0,0,0,0,0,<..\..\src\thread.c><thread.c>
 OPTFFF 2,17,1,0,0,0,0,0,<..\..\src\device.c><device.c> 
 OPTFFF 3,18,1,0,0,0,0,0,<..\..\libcpu\arm\AT91SAM7S\cpu.c><cpu.c> 
 OPTFFF 3,19,1,0,0,0,0,0,<..\..\libcpu\arm\AT91SAM7S\interrupt.c><interrupt.c> 
-OPTFFF 3,20,1,100663296,0,0,0,0,<..\..\libcpu\arm\AT91SAM7S\serial.c><serial.c> 
+OPTFFF 3,20,1,436207616,0,0,0,0,<..\..\libcpu\arm\AT91SAM7S\serial.c><serial.c> 
 OPTFFF 3,21,1,0,0,0,0,0,<..\..\libcpu\arm\AT91SAM7S\stack.c><stack.c> 
 OPTFFF 3,22,1,0,0,0,0,0,<..\..\libcpu\arm\AT91SAM7S\trap.c><trap.c> 
-OPTFFF 3,23,2,385875968,0,0,0,0,<..\..\libcpu\arm\AT91SAM7S\context_rvds.S><context_rvds.S> 
+OPTFFF 3,23,2,0,0,0,0,0,<..\..\libcpu\arm\AT91SAM7S\context_rvds.S><context_rvds.S> 
 OPTFFF 3,24,2,0,0,0,0,0,<..\..\libcpu\arm\AT91SAM7S\start_rvds.S><start_rvds.S> 
-OPTFFF 4,25,1,0,0,0,0,0,<..\..\finsh\cmd.c><cmd.c> 
-OPTFFF 4,26,1,0,0,0,0,0,<..\..\finsh\finsh_compiler.c><finsh_compiler.c> 
-OPTFFF 4,27,1,0,0,0,0,0,<..\..\finsh\finsh_error.c><finsh_error.c> 
-OPTFFF 4,28,1,0,0,0,0,0,<..\..\finsh\finsh_heap.c><finsh_heap.c> 
-OPTFFF 4,29,1,0,0,0,0,0,<..\..\finsh\finsh_init.c><finsh_init.c> 
-OPTFFF 4,30,1,0,0,0,0,0,<..\..\finsh\finsh_node.c><finsh_node.c> 
-OPTFFF 4,31,1,0,0,0,0,0,<..\..\finsh\finsh_ops.c><finsh_ops.c> 
-OPTFFF 4,32,1,0,0,0,0,0,<..\..\finsh\finsh_parser.c><finsh_parser.c> 
-OPTFFF 4,33,1,0,0,0,0,0,<..\..\finsh\finsh_token.c><finsh_token.c> 
-OPTFFF 4,34,1,0,0,0,0,0,<..\..\finsh\finsh_var.c><finsh_var.c> 
-OPTFFF 4,35,1,0,0,0,0,0,<..\..\finsh\finsh_vm.c><finsh_vm.c> 
-OPTFFF 4,36,1,0,0,0,0,0,<..\..\finsh\shell.c><shell.c> 
-OPTFFF 4,37,1,0,0,0,0,0,<..\..\finsh\symbol.c><symbol.c> 
+OPTFFF 4,25,1,0,0,0,0,0,<..\..\components\finsh\cmd.c><cmd.c> 
+OPTFFF 4,26,1,0,0,0,0,0,<..\..\components\finsh\finsh_compiler.c><finsh_compiler.c> 
+OPTFFF 4,27,1,0,0,0,0,0,<..\..\components\finsh\finsh_error.c><finsh_error.c> 
+OPTFFF 4,28,1,0,0,0,0,0,<..\..\components\finsh\finsh_heap.c><finsh_heap.c> 
+OPTFFF 4,29,1,0,0,0,0,0,<..\..\components\finsh\finsh_init.c><finsh_init.c> 
+OPTFFF 4,30,1,0,0,0,0,0,<..\..\components\finsh\finsh_node.c><finsh_node.c> 
+OPTFFF 4,31,1,0,0,0,0,0,<..\..\components\finsh\finsh_ops.c><finsh_ops.c> 
+OPTFFF 4,32,1,0,0,0,0,0,<..\..\components\finsh\finsh_parser.c><finsh_parser.c> 
+OPTFFF 4,33,1,0,0,0,0,0,<..\..\components\finsh\finsh_token.c><finsh_token.c> 
+OPTFFF 4,34,1,0,0,0,0,0,<..\..\components\finsh\finsh_var.c><finsh_var.c> 
+OPTFFF 4,35,1,0,0,0,0,0,<..\..\components\finsh\finsh_vm.c><finsh_vm.c> 
+OPTFFF 4,36,1,0,0,0,0,0,<..\..\components\finsh\shell.c><shell.c> 
+OPTFFF 4,37,1,0,0,0,0,0,<..\..\components\finsh\symbol.c><symbol.c> 
 
 
 TARGOPT 1, (RT-Thread/AT91SAM7S)

+ 4 - 102
bsp/sam7s/rtconfig.h

@@ -3,7 +3,7 @@
 #define __RTTHREAD_CFG_H__
 
 /* RT_NAME_MAX*/
-#define RT_NAME_MAX	4
+#define RT_NAME_MAX	8
 
 /* RT_ALIGN_SIZE*/
 #define RT_ALIGN_SIZE	4
@@ -16,6 +16,7 @@
 
 /* SECTION: RT_DEBUG */
 /* Thread Debug*/
+#define RT_DEBUG
 /* #define RT_THREAD_DEBUG */
 
 /* Using Hook*/
@@ -31,9 +32,6 @@
 /* Using Event*/
 #define RT_USING_EVENT
 
-/* Using Faset Event*/
-/* #define RT_USING_FASTEVENT */
-
 /* Using MailBox*/
 #define RT_USING_MAILBOX
 
@@ -56,22 +54,18 @@
 /* SECTION: Device System */
 /* Using Device System*/
 #define RT_USING_DEVICE
+#define RT_USING_CONSOLE
 
 /* buffer size for UART reception*/
 #define RT_UART_RX_BUFFER_SIZE	64
-
 /* buffer size for UART transmission*/
 #define RT_UART_TX_BUFFER_SIZE	64
 
 /* Using UART1*/
 #define RT_USING_UART1
-
-/* Using UART1*/
+/* Using UART2*/
 /* #define RT_USING_UART2 */
 
-/* Using UART1*/
-/* #define RT_USING_UART3 */
-
 /* SECTION: Console options */
 /* the buffer size of console*/
 #define RT_CONSOLEBUF_SIZE	128
@@ -87,96 +81,4 @@
 /* a runtime libc library*/
 /* #define RT_USING_NEWLIB */
 
-/* SECTION: C++ support */
-/* Using C++ support*/
-/* #define RT_USING_CPLUSPLUS */
-
-/* SECTION: RTGUI support */
-/* using RTGUI support*/
-/* #define RT_USING_RTGUI */
-
-/* SECTION: Device filesystem support */
-/* using DFS support*/
-/* #define RT_USING_DFS */
-
-/* SECTION: EFSL filesystem support */
-/* using  EFSL filesystem  support*/
-/* #define RT_USING_EFSL */
-
-/* SECTION: lwip, a lighwight TCP/IP protocol stack */
-/* Using lighweight TCP/IP protocol stack*/
-/* #define RT_USING_LWIP */
-
-/* Using webserver goahead support*/
-/* #define RT_USING_WEBSERVER */
-
-/* Using ftpserver support*/
-/* #define RT_USING_FTPSERVER */
-
-/* Trace LwIP protocol*/
-/* #define RT_LWIP_DEBUG */
-
-/* Enable ICMP protocol*/
-#define RT_LWIP_ICMP
-
-/* Enable IGMP protocol*/
-#define RT_LWIP_IGMP
-
-/* Enable UDP protocol*/
-#define RT_LWIP_UDP
-
-/* Enable TCP protocol*/
-#define RT_LWIP_TCP
-
-/* the number of simulatenously active TCP connections*/
-#define RT_LWIP_TCP_PCB_NUM	5
-
-/* TCP sender buffer space*/
-#define RT_LWIP_TCP_SND_BUF	10240
-
-/* Enable SNMP protocol*/
-/* #define RT_LWIP_SNMP */
-
-/* Using DHCP*/
-/* #define RT_LWIP_DHCP */
-
-/* ip address of target*/
-#define RT_LWIP_IPADDR0	192
-#define RT_LWIP_IPADDR1	168
-#define RT_LWIP_IPADDR2	0
-#define RT_LWIP_IPADDR3	30
-
-/* gateway address of target*/
-#define RT_LWIP_GWADDR0	192
-#define RT_LWIP_GWADDR1	168
-#define RT_LWIP_GWADDR2	0
-#define RT_LWIP_GWADDR3	1
-
-/* mask address of target*/
-#define RT_LWIP_MSKADDR0	255
-#define RT_LWIP_MSKADDR1	255
-#define RT_LWIP_MSKADDR2	255
-#define RT_LWIP_MSKADDR3	0
-
-/* the number of blocks for pbuf*/
-#define RT_LWIP_PBUF_NUM	16
-
-/* thread priority of tcpip thread*/
-#define RT_LWIP_TCPTHREAD_PRIORITY	128
-
-/* mail box size of tcpip thread to wait for*/
-#define RT_LWIP_TCPTHREAD_MBOX_SIZE	8
-
-/* thread stack size of tcpip thread*/
-#define RT_LWIP_TCPTHREAD_STACKSIZE	4096
-
-/* thread priority of ethnetif thread*/
-#define RT_LWIP_ETHTHREAD_PRIORITY	144
-
-/* mail box size of ethnetif thread to wait for*/
-#define RT_LWIP_ETHTHREAD_MBOX_SIZE	32
-
-/* thread stack size of ethnetif thread*/
-#define RT_LWIP_ETHTHREAD_STACKSIZE	1024
-
 #endif

+ 2 - 2
libcpu/arm/AT91SAM7S/serial.c

@@ -136,8 +136,8 @@ static rt_err_t rt_serial_init (rt_device_t dev)
 
 	RT_ASSERT(serial != RT_NULL);
 	/* must be US0 or US1 */
-	RT_ASSERT((serial->peripheral_id != AT91C_ID_US0) &&
-		(serial->peripheral_id != AT91C_ID_US1));
+	RT_ASSERT(((serial->peripheral_id == AT91C_ID_US0) ||
+		(serial->peripheral_id == AT91C_ID_US1)));
 
 	/* Enable Clock for USART */
 	AT91C_PMC_PCER = 1 << serial->peripheral_id;

+ 18 - 7
src/kservice.c

@@ -355,20 +355,31 @@ rt_uint32_t rt_strcasecmp(const char *a, const char *b)
 /**
  * This function will copy string no more than n bytes.
  *
- * @param dest the string to copy
+ * @param dst the string to copy
  * @param src the string to be copied
  * @param n the maximum copied length
  *
  * @return the result
  */
-char *rt_strncpy(char *dest, const char *src, rt_ubase_t n)
+char *rt_strncpy(char *dst, const char *src, rt_ubase_t n)
 {
-	char *tmp = (char *)dest, *s = (char *)src;
-
-	while (n--)
-		*tmp++ = *s++;
+	if (n != 0)
+	{
+		char *d = dst;
+		const char *s = src;
 
-	return dest;
+		do
+		{
+			if ((*d++ = *s++) == 0)
+			{
+				/* NUL pad the remaining n-1 bytes */
+				while (--n != 0)
+						*d++ = 0;
+				break;
+			}
+		} while (--n != 0);
+	}
+	return (dst);
 }
 
 /**

+ 2 - 8
src/object.c

@@ -204,10 +204,7 @@ void rt_object_init(struct rt_object *object, enum rt_object_class_type type, co
 	object->type = type | RT_Object_Class_Static;
 
 	/* copy name */
-	for (temp = 0; temp < RT_NAME_MAX; temp ++)
-	{
-		object->name[temp] = name[temp];
-	}
+	rt_strncpy(object->name, name, RT_NAME_MAX);
 
 	RT_OBJECT_HOOK_CALL(rt_object_attach_hook, (object));
 
@@ -296,10 +293,7 @@ rt_object_t rt_object_allocate(enum rt_object_class_type type, const char *name)
 #endif
 
 	/* copy name */
-	for (temp = 0; temp < RT_NAME_MAX; temp ++)
-	{
-		object->name[temp] = name[temp];
-	}
+	rt_strncpy(object->name, name, RT_NAME_MAX);
 
 	RT_OBJECT_HOOK_CALL(rt_object_attach_hook, (object));