Sync from master v4.0.2 .
This commit is contained in:
parent
840eec5594
commit
a383385a3c
|
@ -369,8 +369,7 @@ int dfs_file_stat(const char *path, struct stat *buf)
|
|||
|
||||
if ((fs = dfs_filesystem_lookup(fullpath)) == NULL)
|
||||
{
|
||||
LOG_E(
|
||||
"can't find mounted filesystem on this path:%s", fullpath);
|
||||
LOG_E("can't find mounted filesystem on this path:%s", fullpath);
|
||||
rt_free(fullpath);
|
||||
|
||||
return -ENOENT;
|
||||
|
@ -399,8 +398,7 @@ int dfs_file_stat(const char *path, struct stat *buf)
|
|||
if (fs->ops->stat == NULL)
|
||||
{
|
||||
rt_free(fullpath);
|
||||
LOG_E(
|
||||
"the filesystem didn't implement this function");
|
||||
LOG_E("the filesystem didn't implement this function");
|
||||
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
@ -565,7 +563,7 @@ void ls(const char *pathname)
|
|||
}
|
||||
else
|
||||
{
|
||||
rt_kprintf("%-25lu\n", stat.st_size);
|
||||
rt_kprintf("%-25lu\n", (unsigned long)stat.st_size);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -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) {
|
||||
qspi_dev = (struct rt_qspi_device *) (rtt_dev->rt_spi_device);
|
||||
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;
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
@ -173,11 +173,11 @@ static sfud_err spi_write_read(const sfud_spi *spi, const uint8_t *write_buf, si
|
|||
result = SFUD_ERR_TIMEOUT;
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
@ -322,7 +322,7 @@ sfud_err sfud_spi_port_init(sfud_flash *flash) {
|
|||
}
|
||||
|
||||
#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,
|
||||
|
@ -734,6 +734,7 @@ static void sf(uint8_t argc, char **argv) {
|
|||
for (i = 0; i < size; i += write_size) {
|
||||
result = sfud_write(sfud_dev, addr + i, write_size, write_data);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -761,6 +762,7 @@ static void sf(uint8_t argc, char **argv) {
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
static int pipe_fops_open(struct dfs_fd *fd)
|
||||
{
|
||||
int rc = 0;
|
||||
rt_device_t device;
|
||||
rt_pipe_t *pipe;
|
||||
|
||||
|
@ -31,6 +32,11 @@ static int pipe_fops_open(struct dfs_fd *fd)
|
|||
if (device->ref_count == 0)
|
||||
{
|
||||
pipe->fifo = rt_ringbuffer_create(pipe->bufsz);
|
||||
if (pipe->fifo == RT_NULL)
|
||||
{
|
||||
rc = -RT_ENOMEM;
|
||||
goto __exit;
|
||||
}
|
||||
}
|
||||
|
||||
switch (fd->flags & O_ACCMODE)
|
||||
|
@ -48,9 +54,10 @@ static int pipe_fops_open(struct dfs_fd *fd)
|
|||
}
|
||||
device->ref_count ++;
|
||||
|
||||
__exit:
|
||||
rt_mutex_release(&(pipe->lock));
|
||||
|
||||
return 0;
|
||||
return rc;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
rt_ringbuffer_destroy(pipe->fifo);
|
||||
if (pipe->fifo != RT_NULL)
|
||||
rt_ringbuffer_destroy(pipe->fifo);
|
||||
pipe->fifo = RT_NULL;
|
||||
}
|
||||
device->ref_count --;
|
||||
|
|
|
@ -95,9 +95,9 @@ void rt_rbb_destroy(rt_rbb_t rbb)
|
|||
{
|
||||
RT_ASSERT(rbb);
|
||||
|
||||
rt_free(rbb);
|
||||
rt_free(rbb->buf);
|
||||
rt_free(rbb->blk_set);
|
||||
rt_free(rbb);
|
||||
|
||||
}
|
||||
RTM_EXPORT(rt_rbb_destroy);
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* 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"
|
|||
|
||||
config RT_USING_RYM
|
||||
bool "Enable Ymodem"
|
||||
depends on RT_USING_DFS = y
|
||||
default n
|
||||
|
||||
if RT_USING_RYM
|
||||
config YMODEM_DISABLE_CRC_TABLE
|
||||
bool "Disable CRC Table"
|
||||
config YMODEM_USING_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
|
||||
endif
|
||||
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c')
|
||||
src = Split('''
|
||||
ymodem.c
|
||||
''')
|
||||
|
||||
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)
|
||||
|
||||
Return('group')
|
||||
|
|
|
@ -11,8 +11,9 @@
|
|||
#include <rtthread.h>
|
||||
#include <ymodem.h>
|
||||
#include <dfs_posix.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <board.h>
|
||||
#include <string.h>
|
||||
|
||||
struct custom_ctx
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <rthw.h>
|
||||
#include "ymodem.h"
|
||||
|
||||
#ifndef YMODEM_DISABLE_CRC_TABLE
|
||||
#ifdef YMODEM_USING_CRC_TABLE
|
||||
static const rt_uint16_t ccitt_table[256] =
|
||||
{
|
||||
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
|
||||
|
|
|
@ -63,13 +63,14 @@ typedef struct siginfo siginfo_t;
|
|||
#define SI_MESGQ 0x05 /* Signal generated by arrival of a
|
||||
message on an empty message queue. */
|
||||
|
||||
#ifdef RT_USING_NEWLIB
|
||||
#include <sys/signal.h>
|
||||
#if !defined(RT_USING_NEWLIB)
|
||||
typedef void (*_sig_func_ptr)(int);
|
||||
typedef unsigned long sigset_t;
|
||||
#endif
|
||||
|
||||
#if defined(__CC_ARM) || defined(__CLANG_ARM)
|
||||
#include <signal.h>
|
||||
typedef unsigned long sigset_t;
|
||||
|
||||
#if defined(__CC_ARM) || defined(__CLANG_ARM)
|
||||
|
||||
#define SIGHUP 1
|
||||
/* #define SIGINT 2 */
|
||||
|
@ -105,8 +106,6 @@ typedef unsigned long sigset_t;
|
|||
#define SIG_BLOCK 1 /* set of signals to block */
|
||||
#define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
|
||||
|
||||
typedef void (*_sig_func_ptr)(int);
|
||||
|
||||
struct sigaction
|
||||
{
|
||||
_sig_func_ptr sa_handler;
|
||||
|
@ -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);
|
||||
|
||||
#elif defined(__IAR_SYSTEMS_ICC__)
|
||||
#include <signal.h>
|
||||
typedef unsigned long sigset_t;
|
||||
|
||||
#define SIGHUP 1
|
||||
#define SIGINT 2
|
||||
|
@ -161,8 +158,6 @@ typedef unsigned long sigset_t;
|
|||
#define SIG_BLOCK 1 /* set of signals to block */
|
||||
#define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
|
||||
|
||||
typedef void (*_sig_func_ptr)(int);
|
||||
|
||||
struct sigaction
|
||||
{
|
||||
_sig_func_ptr sa_handler;
|
||||
|
|
|
@ -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_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_control(rt_thread_t thread, int cmd, void *arg);
|
||||
rt_err_t rt_thread_suspend(rt_thread_t thread);
|
||||
|
|
57
src/thread.c
57
src/thread.c
|
@ -534,6 +534,63 @@ rt_err_t rt_thread_delay(rt_tick_t tick)
|
|||
}
|
||||
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.
|
||||
*
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue