提交 a383385a 编写于 作者: armink_ztl's avatar armink_ztl

Sync from master v4.0.2 .

上级 840eec55
...@@ -369,8 +369,7 @@ int dfs_file_stat(const char *path, struct stat *buf) ...@@ -369,8 +369,7 @@ int dfs_file_stat(const char *path, struct stat *buf)
if ((fs = dfs_filesystem_lookup(fullpath)) == NULL) if ((fs = dfs_filesystem_lookup(fullpath)) == NULL)
{ {
LOG_E( LOG_E("can't find mounted filesystem on this path:%s", fullpath);
"can't find mounted filesystem on this path:%s", fullpath);
rt_free(fullpath); rt_free(fullpath);
return -ENOENT; return -ENOENT;
...@@ -399,8 +398,7 @@ int dfs_file_stat(const char *path, struct stat *buf) ...@@ -399,8 +398,7 @@ int dfs_file_stat(const char *path, struct stat *buf)
if (fs->ops->stat == NULL) if (fs->ops->stat == NULL)
{ {
rt_free(fullpath); rt_free(fullpath);
LOG_E( LOG_E("the filesystem didn't implement this function");
"the filesystem didn't implement this function");
return -ENOSYS; return -ENOSYS;
} }
...@@ -565,7 +563,7 @@ void ls(const char *pathname) ...@@ -565,7 +563,7 @@ void ls(const char *pathname)
} }
else else
{ {
rt_kprintf("%-25lu\n", stat.st_size); rt_kprintf("%-25lu\n", (unsigned long)stat.st_size);
} }
} }
else else
......
...@@ -156,11 +156,11 @@ static sfud_err spi_write_read(const sfud_spi *spi, const uint8_t *write_buf, si ...@@ -156,11 +156,11 @@ static sfud_err spi_write_read(const sfud_spi *spi, const uint8_t *write_buf, si
if(rtt_dev->rt_spi_device->bus->mode & RT_SPI_BUS_MODE_QSPI) { if(rtt_dev->rt_spi_device->bus->mode & RT_SPI_BUS_MODE_QSPI) {
qspi_dev = (struct rt_qspi_device *) (rtt_dev->rt_spi_device); qspi_dev = (struct rt_qspi_device *) (rtt_dev->rt_spi_device);
if (write_size && read_size) { if (write_size && read_size) {
if (rt_qspi_send_then_recv(qspi_dev, write_buf, write_size, read_buf, read_size) == 0) { if (rt_qspi_send_then_recv(qspi_dev, write_buf, write_size, read_buf, read_size) <= 0) {
result = SFUD_ERR_TIMEOUT; result = SFUD_ERR_TIMEOUT;
} }
} else if (write_size) { } else if (write_size) {
if (rt_qspi_send(qspi_dev, write_buf, write_size) == 0) { if (rt_qspi_send(qspi_dev, write_buf, write_size) <= 0) {
result = SFUD_ERR_TIMEOUT; result = SFUD_ERR_TIMEOUT;
} }
} }
...@@ -173,11 +173,11 @@ static sfud_err spi_write_read(const sfud_spi *spi, const uint8_t *write_buf, si ...@@ -173,11 +173,11 @@ static sfud_err spi_write_read(const sfud_spi *spi, const uint8_t *write_buf, si
result = SFUD_ERR_TIMEOUT; result = SFUD_ERR_TIMEOUT;
} }
} else if (write_size) { } else if (write_size) {
if (rt_spi_send(rtt_dev->rt_spi_device, write_buf, write_size) == 0) { if (rt_spi_send(rtt_dev->rt_spi_device, write_buf, write_size) <= 0) {
result = SFUD_ERR_TIMEOUT; result = SFUD_ERR_TIMEOUT;
} }
} else { } else {
if (rt_spi_recv(rtt_dev->rt_spi_device, read_buf, read_size) == 0) { if (rt_spi_recv(rtt_dev->rt_spi_device, read_buf, read_size) <= 0) {
result = SFUD_ERR_TIMEOUT; result = SFUD_ERR_TIMEOUT;
} }
} }
...@@ -322,7 +322,7 @@ sfud_err sfud_spi_port_init(sfud_flash *flash) { ...@@ -322,7 +322,7 @@ sfud_err sfud_spi_port_init(sfud_flash *flash) {
} }
#ifdef RT_USING_DEVICE_OPS #ifdef RT_USING_DEVICE_OPS
const static struct rt_device_ops flash_device_ops = const static struct rt_device_ops flash_device_ops =
{ {
RT_NULL, RT_NULL,
RT_NULL, RT_NULL,
...@@ -734,6 +734,7 @@ static void sf(uint8_t argc, char **argv) { ...@@ -734,6 +734,7 @@ static void sf(uint8_t argc, char **argv) {
for (i = 0; i < size; i += write_size) { for (i = 0; i < size; i += write_size) {
result = sfud_write(sfud_dev, addr + i, write_size, write_data); result = sfud_write(sfud_dev, addr + i, write_size, write_data);
if (result != SFUD_SUCCESS) { if (result != SFUD_SUCCESS) {
rt_kprintf("Writing %s failed, already wr for %lu bytes, write %d each time\n", sfud_dev->name, i, write_size);
break; break;
} }
} }
...@@ -761,6 +762,7 @@ static void sf(uint8_t argc, char **argv) { ...@@ -761,6 +762,7 @@ static void sf(uint8_t argc, char **argv) {
} }
if (result != SFUD_SUCCESS) { if (result != SFUD_SUCCESS) {
rt_kprintf("Read %s failed, already rd for %lu bytes, read %d each time\n", sfud_dev->name, i, read_size);
break; break;
} }
} }
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
static int pipe_fops_open(struct dfs_fd *fd) static int pipe_fops_open(struct dfs_fd *fd)
{ {
int rc = 0;
rt_device_t device; rt_device_t device;
rt_pipe_t *pipe; rt_pipe_t *pipe;
...@@ -31,6 +32,11 @@ static int pipe_fops_open(struct dfs_fd *fd) ...@@ -31,6 +32,11 @@ static int pipe_fops_open(struct dfs_fd *fd)
if (device->ref_count == 0) if (device->ref_count == 0)
{ {
pipe->fifo = rt_ringbuffer_create(pipe->bufsz); pipe->fifo = rt_ringbuffer_create(pipe->bufsz);
if (pipe->fifo == RT_NULL)
{
rc = -RT_ENOMEM;
goto __exit;
}
} }
switch (fd->flags & O_ACCMODE) switch (fd->flags & O_ACCMODE)
...@@ -48,9 +54,10 @@ static int pipe_fops_open(struct dfs_fd *fd) ...@@ -48,9 +54,10 @@ static int pipe_fops_open(struct dfs_fd *fd)
} }
device->ref_count ++; device->ref_count ++;
__exit:
rt_mutex_release(&(pipe->lock)); rt_mutex_release(&(pipe->lock));
return 0; return rc;
} }
static int pipe_fops_close(struct dfs_fd *fd) static int pipe_fops_close(struct dfs_fd *fd)
...@@ -90,7 +97,8 @@ static int pipe_fops_close(struct dfs_fd *fd) ...@@ -90,7 +97,8 @@ static int pipe_fops_close(struct dfs_fd *fd)
if (device->ref_count == 1) if (device->ref_count == 1)
{ {
rt_ringbuffer_destroy(pipe->fifo); if (pipe->fifo != RT_NULL)
rt_ringbuffer_destroy(pipe->fifo);
pipe->fifo = RT_NULL; pipe->fifo = RT_NULL;
} }
device->ref_count --; device->ref_count --;
......
...@@ -95,9 +95,9 @@ void rt_rbb_destroy(rt_rbb_t rbb) ...@@ -95,9 +95,9 @@ void rt_rbb_destroy(rt_rbb_t rbb)
{ {
RT_ASSERT(rbb); RT_ASSERT(rbb);
rt_free(rbb);
rt_free(rbb->buf); rt_free(rbb->buf);
rt_free(rbb->blk_set); rt_free(rbb->blk_set);
rt_free(rbb);
} }
RTM_EXPORT(rt_rbb_destroy); RTM_EXPORT(rt_rbb_destroy);
......
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2017-09-12 Bernard The first version
*/
#ifndef SIGNAL_H__
#define SIGNAL_H__
#include <libc/libc_signal.h>
#define SIG_DFL ((_sig_func_ptr)0) /* Default action */
#define SIG_IGN ((_sig_func_ptr)1) /* Ignore action */
#define SIG_ERR ((_sig_func_ptr)-1) /* Error return */
#endif
...@@ -2,12 +2,16 @@ menu "Utilities" ...@@ -2,12 +2,16 @@ menu "Utilities"
config RT_USING_RYM config RT_USING_RYM
bool "Enable Ymodem" bool "Enable Ymodem"
depends on RT_USING_DFS = y
default n default n
if RT_USING_RYM if RT_USING_RYM
config YMODEM_DISABLE_CRC_TABLE config YMODEM_USING_CRC_TABLE
bool "Disable CRC Table" bool "Enable CRC Table in Ymodem"
default n
config YMODEM_USING_FILE_TRANSFER
bool "Enable file transfer feature"
select RT_USING_DFS
default n default n
endif endif
......
from building import * from building import *
cwd = GetCurrentDir() cwd = GetCurrentDir()
src = Glob('*.c') src = Split('''
ymodem.c
''')
CPPPATH = [cwd] CPPPATH = [cwd]
if GetDepend('RT_USING_DFS') and GetDepend('YMODEM_USING_FILE_TRANSFER'):
src += ['ry_sy.c']
group = DefineGroup('Utilities', src, depend = ['RT_USING_RYM'], CPPPATH = CPPPATH) group = DefineGroup('Utilities', src, depend = ['RT_USING_RYM'], CPPPATH = CPPPATH)
Return('group') Return('group')
...@@ -11,8 +11,9 @@ ...@@ -11,8 +11,9 @@
#include <rtthread.h> #include <rtthread.h>
#include <ymodem.h> #include <ymodem.h>
#include <dfs_posix.h> #include <dfs_posix.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <board.h>
#include <string.h> #include <string.h>
struct custom_ctx struct custom_ctx
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include <rthw.h> #include <rthw.h>
#include "ymodem.h" #include "ymodem.h"
#ifndef YMODEM_DISABLE_CRC_TABLE #ifdef YMODEM_USING_CRC_TABLE
static const rt_uint16_t ccitt_table[256] = static const rt_uint16_t ccitt_table[256] =
{ {
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
......
...@@ -63,13 +63,14 @@ typedef struct siginfo siginfo_t; ...@@ -63,13 +63,14 @@ typedef struct siginfo siginfo_t;
#define SI_MESGQ 0x05 /* Signal generated by arrival of a #define SI_MESGQ 0x05 /* Signal generated by arrival of a
message on an empty message queue. */ message on an empty message queue. */
#ifdef RT_USING_NEWLIB #if !defined(RT_USING_NEWLIB)
#include <sys/signal.h> typedef void (*_sig_func_ptr)(int);
typedef unsigned long sigset_t;
#endif #endif
#if defined(__CC_ARM) || defined(__CLANG_ARM)
#include <signal.h> #include <signal.h>
typedef unsigned long sigset_t;
#if defined(__CC_ARM) || defined(__CLANG_ARM)
#define SIGHUP 1 #define SIGHUP 1
/* #define SIGINT 2 */ /* #define SIGINT 2 */
...@@ -105,8 +106,6 @@ typedef unsigned long sigset_t; ...@@ -105,8 +106,6 @@ typedef unsigned long sigset_t;
#define SIG_BLOCK 1 /* set of signals to block */ #define SIG_BLOCK 1 /* set of signals to block */
#define SIG_UNBLOCK 2 /* set of signals to, well, unblock */ #define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
typedef void (*_sig_func_ptr)(int);
struct sigaction struct sigaction
{ {
_sig_func_ptr sa_handler; _sig_func_ptr sa_handler;
...@@ -124,8 +123,6 @@ int sigprocmask (int how, const sigset_t *set, sigset_t *oset); ...@@ -124,8 +123,6 @@ int sigprocmask (int how, const sigset_t *set, sigset_t *oset);
int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact); int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
#elif defined(__IAR_SYSTEMS_ICC__) #elif defined(__IAR_SYSTEMS_ICC__)
#include <signal.h>
typedef unsigned long sigset_t;
#define SIGHUP 1 #define SIGHUP 1
#define SIGINT 2 #define SIGINT 2
...@@ -161,8 +158,6 @@ typedef unsigned long sigset_t; ...@@ -161,8 +158,6 @@ typedef unsigned long sigset_t;
#define SIG_BLOCK 1 /* set of signals to block */ #define SIG_BLOCK 1 /* set of signals to block */
#define SIG_UNBLOCK 2 /* set of signals to, well, unblock */ #define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
typedef void (*_sig_func_ptr)(int);
struct sigaction struct sigaction
{ {
_sig_func_ptr sa_handler; _sig_func_ptr sa_handler;
......
...@@ -137,6 +137,7 @@ rt_err_t rt_thread_delete(rt_thread_t thread); ...@@ -137,6 +137,7 @@ rt_err_t rt_thread_delete(rt_thread_t thread);
rt_err_t rt_thread_yield(void); rt_err_t rt_thread_yield(void);
rt_err_t rt_thread_delay(rt_tick_t tick); rt_err_t rt_thread_delay(rt_tick_t tick);
rt_err_t rt_thread_delay_until(rt_tick_t *tick, rt_tick_t inc_tick);
rt_err_t rt_thread_mdelay(rt_int32_t ms); rt_err_t rt_thread_mdelay(rt_int32_t ms);
rt_err_t rt_thread_control(rt_thread_t thread, int cmd, void *arg); rt_err_t rt_thread_control(rt_thread_t thread, int cmd, void *arg);
rt_err_t rt_thread_suspend(rt_thread_t thread); rt_err_t rt_thread_suspend(rt_thread_t thread);
......
...@@ -534,6 +534,63 @@ rt_err_t rt_thread_delay(rt_tick_t tick) ...@@ -534,6 +534,63 @@ rt_err_t rt_thread_delay(rt_tick_t tick)
} }
RTM_EXPORT(rt_thread_delay); RTM_EXPORT(rt_thread_delay);
/**
* This function will let current thread delay until (*tick + inc_tick).
*
* @param tick the tick of last wakeup.
* @param inc_tick the increment tick
*
* @return RT_EOK
*/
rt_err_t rt_thread_delay_until(rt_tick_t *tick, rt_tick_t inc_tick)
{
register rt_base_t level;
struct rt_thread *thread;
RT_ASSERT(tick != RT_NULL);
/* set to current thread */
thread = rt_thread_self();
RT_ASSERT(thread != RT_NULL);
RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread);
/* disable interrupt */
level = rt_hw_interrupt_disable();
if (rt_tick_get() - *tick < inc_tick)
{
*tick = rt_tick_get() - *tick + inc_tick;
/* suspend thread */
rt_thread_suspend(thread);
/* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer), RT_TIMER_CTRL_SET_TIME, tick);
rt_timer_start(&(thread->thread_timer));
/* enable interrupt */
rt_hw_interrupt_enable(level);
rt_schedule();
/* clear error number of this thread to RT_EOK */
if (thread->error == -RT_ETIMEOUT)
{
thread->error = RT_EOK;
}
}
else
{
rt_hw_interrupt_enable(level);
}
/* get the wakeup tick */
*tick = rt_tick_get();
return RT_EOK;
}
RTM_EXPORT(rt_thread_delay_until);
/** /**
* This function will let current thread delay for some milliseconds. * This function will let current thread delay for some milliseconds.
* *
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册