diff --git a/bsp/beaglebone/drivers/serial.c b/bsp/beaglebone/drivers/serial.c index d07621080b44fac0379e67ef1faf5da8ba84a5b1..5430358798cead1786904dc34dde7501b6eceb0b 100644 --- a/bsp/beaglebone/drivers/serial.c +++ b/bsp/beaglebone/drivers/serial.c @@ -426,7 +426,7 @@ int rt_hw_serial_init(void) config.stop_bits = STOP_BITS_1; config.invert = NRZ_NORMAL; serial3.ops = &am33xx_uart_ops; - serial3.int_rx = &uart_3_int_rx; + serial3.int_rx = &uart3_int_rx; serial3.config = config; /* enable RX interrupt */ UART_IER_REG(uart3.base) = 0x01; @@ -470,7 +470,7 @@ int rt_hw_serial_init(void) config.parity = PARITY_NONE; config.stop_bits = STOP_BITS_1; config.invert = NRZ_NORMAL; - + serial5.ops = &am33xx_uart_ops; serial5.int_rx = &uart5_int_rx; serial5.config = config; diff --git a/bsp/stm32f40x/drivers/usart.c b/bsp/stm32f40x/drivers/usart.c index ab03c92b126e8c71f817f92b708f5cba9ba5047e..cd221ab0a2120bd386cf77452a6c5cf66147ddb3 100644 --- a/bsp/stm32f40x/drivers/usart.c +++ b/bsp/stm32f40x/drivers/usart.c @@ -165,8 +165,8 @@ static void GPIO_Configuration(void) GPIO_Init(UART3_GPIO, &GPIO_InitStructure); /* Connect alternate function */ - GPIO_PinAFConfig(UART2_GPIO, UART3_TX_PIN_SOURCE, GPIO_AF_USART3); - GPIO_PinAFConfig(UART2_GPIO, UART3_RX_PIN_SOURCE, GPIO_AF_USART3); + GPIO_PinAFConfig(UART3_GPIO, UART3_TX_PIN_SOURCE, GPIO_AF_USART3); + GPIO_PinAFConfig(UART3_GPIO, UART3_RX_PIN_SOURCE, GPIO_AF_USART3); #endif } diff --git a/components/dfs/src/dfs_file.c b/components/dfs/src/dfs_file.c index 32198371d7dd1e0fcaf925ac3d2df70d2c0ca61e..d1a47aa9fa4dd5e6c7de76fd9108f9dd72493235 100644 --- a/components/dfs/src/dfs_file.c +++ b/components/dfs/src/dfs_file.c @@ -629,7 +629,15 @@ static void copyfile(const char *src, const char *dst) read_bytes = dfs_file_read(&src_fd, block_ptr, BUF_SZ); if (read_bytes > 0) { - dfs_file_write(&fd, block_ptr, read_bytes); + int length; + + length = dfs_file_write(&fd, block_ptr, read_bytes); + if (length != read_bytes) + { + /* write failed. */ + rt_kprintf("Write file data failed, errno=%d\n", length); + break; + } } } while (read_bytes > 0); diff --git a/components/libc/newlib/syscalls.c b/components/libc/newlib/syscalls.c index 5b829f47532f30378250ff665b8baf80c81e590a..388d240c9449c136b7611c4fe075fef1ec3c8147 100644 --- a/components/libc/newlib/syscalls.c +++ b/components/libc/newlib/syscalls.c @@ -3,6 +3,14 @@ #include #include +#ifdef RT_USING_DFS +#include +#endif + +#ifdef RT_USING_PTHREADS +#include +#endif + /* Reentrant versions of system calls. */ int diff --git a/components/pthreads/pthread_cond.c b/components/pthreads/pthread_cond.c index e5342dd775078792e15aadef9919d3ecc9694a5e..25628fc2b3da510dffd2f4b2935691b5f95e286a 100644 --- a/components/pthreads/pthread_cond.c +++ b/components/pthreads/pthread_cond.c @@ -98,7 +98,11 @@ int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr) rt_snprintf(cond_name, sizeof(cond_name), "cond%02d", cond_num++); - cond->attr = *attr; + if (attr == RT_NULL) /* use default value */ + cond->attr = PTHREAD_PROCESS_PRIVATE; + else + cond->attr = *attr; + result = rt_sem_init(&cond->sem, cond_name, 0, RT_IPC_FLAG_FIFO); if (result != RT_EOK) return EINVAL; diff --git a/libcpu/arm/cortex-m0/context_gcc.S b/libcpu/arm/cortex-m0/context_gcc.S index 997c34517927062bcc1e88c79948636027657d68..3186a5ae9f446365862dd96f4237794ce0b10cf0 100644 --- a/libcpu/arm/cortex-m0/context_gcc.S +++ b/libcpu/arm/cortex-m0/context_gcc.S @@ -79,8 +79,8 @@ _reswitch: STR R1, [R0] BX LR -/* R0 --> swith from thread stack - * R1 --> swith to thread stack +/* R0 --> switch from thread stack + * R1 --> switch to thread stack * psr, pc, LR, R12, R3, R2, R1, R0 are pushed into [from] stack */ .global PendSV_Handler @@ -103,7 +103,7 @@ PendSV_Handler: LDR R0, =rt_interrupt_from_thread LDR R1, [R0] CMP R1, #0x00 - BEQ swtich_to_thread /* skip register save at the first time */ + BEQ switch_to_thread /* skip register save at the first time */ MRS R1, PSP /* get from thread stack pointer */ @@ -118,7 +118,7 @@ PendSV_Handler: MOV R6, R10 MOV R7, R11 STMIA R1!, {R4 - R7} /* push thread {R8 - R11} high register to thread stack */ -swtich_to_thread: +switch_to_thread: LDR R1, =rt_interrupt_to_thread LDR R1, [R1] LDR R1, [R1] /* load thread stack pointer */ diff --git a/libcpu/arm/cortex-m0/context_iar.S b/libcpu/arm/cortex-m0/context_iar.S index f1318e552d7e6800f3e2192f477e90729961ea61..67ea808d8c71b8ba5d4ccac970275e6cc6a6746f 100644 --- a/libcpu/arm/cortex-m0/context_iar.S +++ b/libcpu/arm/cortex-m0/context_iar.S @@ -81,8 +81,8 @@ _reswitch STR r1, [r0] BX LR -; r0 --> swith from thread stack -; r1 --> swith to thread stack +; r0 --> switch from thread stack +; r1 --> switch to thread stack ; psr, pc, lr, r12, r3, r2, r1, r0 are pushed into [from] stack EXPORT PendSV_Handler PendSV_Handler: @@ -104,7 +104,7 @@ PendSV_Handler: LDR r0, =rt_interrupt_from_thread LDR r1, [r0] CMP r1, #0x00 - BEQ swtich_to_thread ; skip register save at the first time + BEQ switch_to_thread ; skip register save at the first time MRS r1, psp ; get from thread stack pointer @@ -120,7 +120,7 @@ PendSV_Handler: MOV r7, r11 STMIA r1!, {r4 - r7} ; push thread {r8 - r11} high register to thread stack -swtich_to_thread +switch_to_thread LDR r1, =rt_interrupt_to_thread LDR r1, [r1] LDR r1, [r1] ; load thread stack pointer diff --git a/libcpu/arm/cortex-m0/context_rvds.S b/libcpu/arm/cortex-m0/context_rvds.S index 9c2f42ac83102eaac2d2d50c2640a86b0163f0eb..89ac0292825726d0735d9c441fa970656165c8ec 100644 --- a/libcpu/arm/cortex-m0/context_rvds.S +++ b/libcpu/arm/cortex-m0/context_rvds.S @@ -85,8 +85,8 @@ _reswitch BX LR ENDP -; r0 --> swith from thread stack -; r1 --> swith to thread stack +; r0 --> switch from thread stack +; r1 --> switch to thread stack ; psr, pc, lr, r12, r3, r2, r1, r0 are pushed into [from] stack PendSV_Handler PROC EXPORT PendSV_Handler @@ -108,7 +108,7 @@ PendSV_Handler PROC LDR r0, =rt_interrupt_from_thread LDR r1, [r0] CMP r1, #0x00 - BEQ swtich_to_thread ; skip register save at the first time + BEQ switch_to_thread ; skip register save at the first time MRS r1, psp ; get from thread stack pointer @@ -124,7 +124,7 @@ PendSV_Handler PROC MOV r7, r11 STMIA r1!, {r4 - r7} ; push thread {r8 - r11} high register to thread stack -swtich_to_thread +switch_to_thread LDR r1, =rt_interrupt_to_thread LDR r1, [r1] LDR r1, [r1] ; load thread stack pointer diff --git a/libcpu/arm/cortex-m3/context_gcc.S b/libcpu/arm/cortex-m3/context_gcc.S index 7ff810d5347b4513f251a3606b137178ebc560a8..ca961bbd87f40795676fa6904edf3173585ffbc5 100644 --- a/libcpu/arm/cortex-m3/context_gcc.S +++ b/libcpu/arm/cortex-m3/context_gcc.S @@ -80,8 +80,8 @@ _reswitch: STR R1, [R0] BX LR -/* R0 --> swith from thread stack - * R1 --> swith to thread stack +/* R0 --> switch from thread stack + * R1 --> switch to thread stack * psr, pc, LR, R12, R3, R2, R1, R0 are pushed into [from] stack */ .global PendSV_Handler @@ -102,14 +102,14 @@ PendSV_Handler: LDR R0, =rt_interrupt_from_thread LDR R1, [R0] - CBZ R1, swtich_to_thread /* skip register save at the first time */ + CBZ R1, switch_to_thread /* skip register save at the first time */ MRS R1, PSP /* get from thread stack pointer */ STMFD R1!, {R4 - R11} /* push R4 - R11 register */ LDR R0, [R0] STR R1, [R0] /* update from thread stack pointer */ -swtich_to_thread: +switch_to_thread: LDR R1, =rt_interrupt_to_thread LDR R1, [R1] LDR R1, [R1] /* load thread stack pointer */ diff --git a/libcpu/arm/cortex-m3/context_iar.S b/libcpu/arm/cortex-m3/context_iar.S index 7dc595f6c18240b23dae11461650cab7fe69abb2..ad9fa0dd0f82008bb22bff047f3ade4919bbb732 100644 --- a/libcpu/arm/cortex-m3/context_iar.S +++ b/libcpu/arm/cortex-m3/context_iar.S @@ -81,8 +81,8 @@ _reswitch STR r1, [r0] BX LR -; r0 --> swith from thread stack -; r1 --> swith to thread stack +; r0 --> switch from thread stack +; r1 --> switch to thread stack ; psr, pc, lr, r12, r3, r2, r1, r0 are pushed into [from] stack EXPORT PendSV_Handler PendSV_Handler: @@ -102,14 +102,14 @@ PendSV_Handler: LDR r0, =rt_interrupt_from_thread LDR r1, [r0] - CBZ r1, swtich_to_thread ; skip register save at the first time + CBZ r1, switch_to_thread ; skip register save at the first time MRS r1, psp ; get from thread stack pointer STMFD r1!, {r4 - r11} ; push r4 - r11 register LDR r0, [r0] STR r1, [r0] ; update from thread stack pointer -swtich_to_thread +switch_to_thread LDR r1, =rt_interrupt_to_thread LDR r1, [r1] LDR r1, [r1] ; load thread stack pointer diff --git a/libcpu/arm/cortex-m3/context_rvds.S b/libcpu/arm/cortex-m3/context_rvds.S index 7f431cc042373377c072b47db770a6c97144c419..c86b70e1f91354f231f5a5ad9be9a7977df98a90 100644 --- a/libcpu/arm/cortex-m3/context_rvds.S +++ b/libcpu/arm/cortex-m3/context_rvds.S @@ -84,8 +84,8 @@ _reswitch BX LR ENDP -; r0 --> swith from thread stack -; r1 --> swith to thread stack +; r0 --> switch from thread stack +; r1 --> switch to thread stack ; psr, pc, lr, r12, r3, r2, r1, r0 are pushed into [from] stack PendSV_Handler PROC EXPORT PendSV_Handler @@ -105,14 +105,14 @@ PendSV_Handler PROC LDR r0, =rt_interrupt_from_thread LDR r1, [r0] - CBZ r1, swtich_to_thread ; skip register save at the first time + CBZ r1, switch_to_thread ; skip register save at the first time MRS r1, psp ; get from thread stack pointer STMFD r1!, {r4 - r11} ; push r4 - r11 register LDR r0, [r0] STR r1, [r0] ; update from thread stack pointer -swtich_to_thread +switch_to_thread LDR r1, =rt_interrupt_to_thread LDR r1, [r1] LDR r1, [r1] ; load thread stack pointer diff --git a/libcpu/arm/cortex-m4/context_gcc.S b/libcpu/arm/cortex-m4/context_gcc.S index 6a910355a814483062772563e6eaa36392577cfd..908a44f8472557da629729f1abec3dc9d86b07ea 100644 --- a/libcpu/arm/cortex-m4/context_gcc.S +++ b/libcpu/arm/cortex-m4/context_gcc.S @@ -82,8 +82,8 @@ _reswitch: STR r1, [r0] BX LR -/* r0 --> swith from thread stack - * r1 --> swith to thread stack +/* r0 --> switch from thread stack + * r1 --> switch to thread stack * psr, pc, lr, r12, r3, r2, r1, r0 are pushed into [from] stack */ .global PendSV_Handler @@ -104,7 +104,7 @@ PendSV_Handler: LDR r0, =rt_interrupt_from_thread LDR r1, [r0] - CBZ r1, swtich_to_thread /* skip register save at the first time */ + CBZ r1, switch_to_thread /* skip register save at the first time */ MRS r1, psp /* get from thread stack pointer */ @@ -127,7 +127,7 @@ PendSV_Handler: LDR r0, [r0] STR r1, [r0] /* update from thread stack pointer */ -swtich_to_thread: +switch_to_thread: LDR r1, =rt_interrupt_to_thread LDR r1, [r1] LDR r1, [r1] /* load thread stack pointer */ diff --git a/libcpu/arm/cortex-m4/context_iar.S b/libcpu/arm/cortex-m4/context_iar.S index e882f36f6499b89d52ae30b35ddd56d8e2faffc8..8761a9705299d564dd51ae3909ab4a2ab79b2842 100644 --- a/libcpu/arm/cortex-m4/context_iar.S +++ b/libcpu/arm/cortex-m4/context_iar.S @@ -82,8 +82,8 @@ _reswitch STR r1, [r0] BX LR -; r0 --> swith from thread stack -; r1 --> swith to thread stack +; r0 --> switch from thread stack +; r1 --> switch to thread stack ; psr, pc, lr, r12, r3, r2, r1, r0 are pushed into [from] stack EXPORT PendSV_Handler PendSV_Handler: @@ -103,7 +103,7 @@ PendSV_Handler: LDR r0, =rt_interrupt_from_thread LDR r1, [r0] - CBZ r1, swtich_to_thread ; skip register save at the first time + CBZ r1, switch_to_thread ; skip register save at the first time MRS r1, psp ; get from thread stack pointer @@ -130,7 +130,7 @@ push_flag LDR r0, [r0] STR r1, [r0] ; update from thread stack pointer -swtich_to_thread +switch_to_thread LDR r1, =rt_interrupt_to_thread LDR r1, [r1] LDR r1, [r1] ; load thread stack pointer diff --git a/libcpu/arm/cortex-m4/context_rvds.S b/libcpu/arm/cortex-m4/context_rvds.S index 189ae33db18b3c2815597feb3f7758a0a4c6594e..af7461fd498774a476afd943edff53df6a13a0ea 100644 --- a/libcpu/arm/cortex-m4/context_rvds.S +++ b/libcpu/arm/cortex-m4/context_rvds.S @@ -85,8 +85,8 @@ _reswitch BX LR ENDP -; r0 --> swith from thread stack -; r1 --> swith to thread stack +; r0 --> switch from thread stack +; r1 --> switch to thread stack ; psr, pc, lr, r12, r3, r2, r1, r0 are pushed into [from] stack PendSV_Handler PROC EXPORT PendSV_Handler @@ -106,7 +106,7 @@ PendSV_Handler PROC LDR r0, =rt_interrupt_from_thread LDR r1, [r0] - CBZ r1, swtich_to_thread ; skip register save at the first time + CBZ r1, switch_to_thread ; skip register save at the first time MRS r1, psp ; get from thread stack pointer @@ -129,7 +129,7 @@ PendSV_Handler PROC LDR r0, [r0] STR r1, [r0] ; update from thread stack pointer -swtich_to_thread +switch_to_thread LDR r1, =rt_interrupt_to_thread LDR r1, [r1] LDR r1, [r1] ; load thread stack pointer diff --git a/src/idle.c b/src/idle.c index 7bca6c28cb7d734d5c70742718d7bf0bfbe30d38..5f7fe45d4be42aed850eaca919a481fe83178205 100644 --- a/src/idle.c +++ b/src/idle.c @@ -180,7 +180,7 @@ static void rt_thread_idle_entry(void *parameter) } /** - * @ingroup SymstemInit + * @ingroup SystemInit * * This function will initialize idle thread, then start it. * diff --git a/tools/building.py b/tools/building.py index 54193fcf2f84b6c09b68d9b2dcdbe89f7ba23ef7..bb0fcdcb654280c70bf0d50b23c95ed9042bd28c 100644 --- a/tools/building.py +++ b/tools/building.py @@ -12,24 +12,44 @@ Env = None class Win32Spawn: def spawn(self, sh, escape, cmd, args, env): + # deal with the cmd build-in commands which cannot be used in + # subprocess.Popen + if cmd == 'del': + for f in args[1:]: + try: + os.remove(f) + except Exception as e: + print 'Error removing file: %s' % e + return -1 + return 0 + import subprocess newargs = string.join(args[1:], ' ') cmdline = cmd + " " + newargs startupinfo = subprocess.STARTUPINFO() + startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW + + # Make sure the env is constructed by strings + _e = {k: str(v) for k, v in env.items()} - proc = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, startupinfo=startupinfo, shell = False) - data, err = proc.communicate() - rv = proc.wait() - if data: - print data - if err: - print err + # Windows(tm) CreateProcess does not use the env passed to it to find + # the executables. So we have to modify our own PATH to make Popen + # work. + old_path = os.environ['PATH'] + os.environ['PATH'] = _e['PATH'] + + try: + proc = subprocess.Popen(cmdline, env=_e, + startupinfo=startupinfo, shell=False) + except Exception as e: + print 'Error in calling:\n%s' % cmdline + print 'Exception: %s: %s' % (e, os.strerror(e.errno)) + return e.errno + finally: + os.environ['PATH'] = old_path - if rv: - return rv - return 0 + return proc.wait() def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = []): import SCons.cpp @@ -59,11 +79,11 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [ env['LIBDIRPREFIX'] = '--userlibpath ' # patch for win32 spawn - if env['PLATFORM'] == 'win32' and rtconfig.PLATFORM == 'gcc': + if env['PLATFORM'] == 'win32': win32_spawn = Win32Spawn() win32_spawn.env = env env['SPAWN'] = win32_spawn.spawn - + if env['PLATFORM'] == 'win32': os.environ['PATH'] = rtconfig.EXEC_PATH + ";" + os.environ['PATH'] else: