diff options
| author | armink <[email protected]> | 2019-12-20 14:46:01 +0800 |
|---|---|---|
| committer | armink <[email protected]> | 2019-12-20 16:03:33 +0800 |
| commit | a383385a3c0a676cee4471fd3cb4f372a36e1023 (patch) | |
| tree | 594994078d07de40ba37c47d5d5c536a51bfe0fc /components | |
| parent | 840eec5594e9a85d054a3242c814146ab12ad3ee (diff) | |
Sync from master v4.0.2 .
Diffstat (limited to 'components')
| -rw-r--r-- | components/dfs/src/dfs_file.c | 8 | ||||
| -rw-r--r-- | components/drivers/spi/spi_flash_sfud.c | 12 | ||||
| -rw-r--r-- | components/drivers/src/pipe.c | 12 | ||||
| -rw-r--r-- | components/drivers/src/ringblk_buf.c | 2 | ||||
| -rw-r--r-- | components/libc/compilers/minilibc/signal.h | 20 | ||||
| -rw-r--r-- | components/utilities/Kconfig | 10 | ||||
| -rw-r--r-- | components/utilities/ymodem/SConscript | 9 | ||||
| -rw-r--r-- | components/utilities/ymodem/ry_sy.c | 3 | ||||
| -rw-r--r-- | components/utilities/ymodem/ymodem.c | 2 |
9 files changed, 59 insertions, 19 deletions
diff --git a/components/dfs/src/dfs_file.c b/components/dfs/src/dfs_file.c index 1063a278ab..91d39597f0 100644 --- a/components/dfs/src/dfs_file.c +++ b/components/dfs/src/dfs_file.c @@ -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 diff --git a/components/drivers/spi/spi_flash_sfud.c b/components/drivers/spi/spi_flash_sfud.c index ce67ce9a72..eff604fe02 100644 --- a/components/drivers/spi/spi_flash_sfud.c +++ b/components/drivers/spi/spi_flash_sfud.c @@ -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; } } diff --git a/components/drivers/src/pipe.c b/components/drivers/src/pipe.c index b682c351ad..ae87b6f5f2 100644 --- a/components/drivers/src/pipe.c +++ b/components/drivers/src/pipe.c @@ -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 --; diff --git a/components/drivers/src/ringblk_buf.c b/components/drivers/src/ringblk_buf.c index 86e812cd4c..7d83149c5e 100644 --- a/components/drivers/src/ringblk_buf.c +++ b/components/drivers/src/ringblk_buf.c @@ -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); diff --git a/components/libc/compilers/minilibc/signal.h b/components/libc/compilers/minilibc/signal.h new file mode 100644 index 0000000000..f52f1e1009 --- /dev/null +++ b/components/libc/compilers/minilibc/signal.h @@ -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 diff --git a/components/utilities/Kconfig b/components/utilities/Kconfig index 7fa6b47601..8b733ecf5c 100644 --- a/components/utilities/Kconfig +++ b/components/utilities/Kconfig @@ -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 diff --git a/components/utilities/ymodem/SConscript b/components/utilities/ymodem/SConscript index 3fc3b17249..5be32247d6 100644 --- a/components/utilities/ymodem/SConscript +++ b/components/utilities/ymodem/SConscript @@ -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') diff --git a/components/utilities/ymodem/ry_sy.c b/components/utilities/ymodem/ry_sy.c index fa57b8553a..4f4476e402 100644 --- a/components/utilities/ymodem/ry_sy.c +++ b/components/utilities/ymodem/ry_sy.c @@ -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 diff --git a/components/utilities/ymodem/ymodem.c b/components/utilities/ymodem/ymodem.c index 0214845303..07055db615 100644 --- a/components/utilities/ymodem/ymodem.c +++ b/components/utilities/ymodem/ymodem.c @@ -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, |
