Skip to content

Commit a383385

Browse files
committed
Sync from master v4.0.2 .
1 parent 840eec5 commit a383385

File tree

13 files changed

+122
-1235
lines changed

13 files changed

+122
-1235
lines changed

components/dfs/src/dfs_file.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,7 @@ int dfs_file_stat(const char *path, struct stat *buf)
369369

370370
if ((fs = dfs_filesystem_lookup(fullpath)) == NULL)
371371
{
372-
LOG_E(
373-
"can't find mounted filesystem on this path:%s", fullpath);
372+
LOG_E("can't find mounted filesystem on this path:%s", fullpath);
374373
rt_free(fullpath);
375374

376375
return -ENOENT;
@@ -399,8 +398,7 @@ int dfs_file_stat(const char *path, struct stat *buf)
399398
if (fs->ops->stat == NULL)
400399
{
401400
rt_free(fullpath);
402-
LOG_E(
403-
"the filesystem didn't implement this function");
401+
LOG_E("the filesystem didn't implement this function");
404402

405403
return -ENOSYS;
406404
}
@@ -565,7 +563,7 @@ void ls(const char *pathname)
565563
}
566564
else
567565
{
568-
rt_kprintf("%-25lu\n", stat.st_size);
566+
rt_kprintf("%-25lu\n", (unsigned long)stat.st_size);
569567
}
570568
}
571569
else

components/drivers/spi/spi_flash_sfud.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,11 @@ static sfud_err spi_write_read(const sfud_spi *spi, const uint8_t *write_buf, si
156156
if(rtt_dev->rt_spi_device->bus->mode & RT_SPI_BUS_MODE_QSPI) {
157157
qspi_dev = (struct rt_qspi_device *) (rtt_dev->rt_spi_device);
158158
if (write_size && read_size) {
159-
if (rt_qspi_send_then_recv(qspi_dev, write_buf, write_size, read_buf, read_size) == 0) {
159+
if (rt_qspi_send_then_recv(qspi_dev, write_buf, write_size, read_buf, read_size) <= 0) {
160160
result = SFUD_ERR_TIMEOUT;
161161
}
162162
} else if (write_size) {
163-
if (rt_qspi_send(qspi_dev, write_buf, write_size) == 0) {
163+
if (rt_qspi_send(qspi_dev, write_buf, write_size) <= 0) {
164164
result = SFUD_ERR_TIMEOUT;
165165
}
166166
}
@@ -173,11 +173,11 @@ static sfud_err spi_write_read(const sfud_spi *spi, const uint8_t *write_buf, si
173173
result = SFUD_ERR_TIMEOUT;
174174
}
175175
} else if (write_size) {
176-
if (rt_spi_send(rtt_dev->rt_spi_device, write_buf, write_size) == 0) {
176+
if (rt_spi_send(rtt_dev->rt_spi_device, write_buf, write_size) <= 0) {
177177
result = SFUD_ERR_TIMEOUT;
178178
}
179179
} else {
180-
if (rt_spi_recv(rtt_dev->rt_spi_device, read_buf, read_size) == 0) {
180+
if (rt_spi_recv(rtt_dev->rt_spi_device, read_buf, read_size) <= 0) {
181181
result = SFUD_ERR_TIMEOUT;
182182
}
183183
}
@@ -322,7 +322,7 @@ sfud_err sfud_spi_port_init(sfud_flash *flash) {
322322
}
323323

324324
#ifdef RT_USING_DEVICE_OPS
325-
const static struct rt_device_ops flash_device_ops =
325+
const static struct rt_device_ops flash_device_ops =
326326
{
327327
RT_NULL,
328328
RT_NULL,
@@ -734,6 +734,7 @@ static void sf(uint8_t argc, char **argv) {
734734
for (i = 0; i < size; i += write_size) {
735735
result = sfud_write(sfud_dev, addr + i, write_size, write_data);
736736
if (result != SFUD_SUCCESS) {
737+
rt_kprintf("Writing %s failed, already wr for %lu bytes, write %d each time\n", sfud_dev->name, i, write_size);
737738
break;
738739
}
739740
}
@@ -761,6 +762,7 @@ static void sf(uint8_t argc, char **argv) {
761762
}
762763

763764
if (result != SFUD_SUCCESS) {
765+
rt_kprintf("Read %s failed, already rd for %lu bytes, read %d each time\n", sfud_dev->name, i, read_size);
764766
break;
765767
}
766768
}

components/drivers/src/pipe.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
static int pipe_fops_open(struct dfs_fd *fd)
2121
{
22+
int rc = 0;
2223
rt_device_t device;
2324
rt_pipe_t *pipe;
2425

@@ -31,6 +32,11 @@ static int pipe_fops_open(struct dfs_fd *fd)
3132
if (device->ref_count == 0)
3233
{
3334
pipe->fifo = rt_ringbuffer_create(pipe->bufsz);
35+
if (pipe->fifo == RT_NULL)
36+
{
37+
rc = -RT_ENOMEM;
38+
goto __exit;
39+
}
3440
}
3541

3642
switch (fd->flags & O_ACCMODE)
@@ -48,9 +54,10 @@ static int pipe_fops_open(struct dfs_fd *fd)
4854
}
4955
device->ref_count ++;
5056

57+
__exit:
5158
rt_mutex_release(&(pipe->lock));
5259

53-
return 0;
60+
return rc;
5461
}
5562

5663
static int pipe_fops_close(struct dfs_fd *fd)
@@ -90,7 +97,8 @@ static int pipe_fops_close(struct dfs_fd *fd)
9097

9198
if (device->ref_count == 1)
9299
{
93-
rt_ringbuffer_destroy(pipe->fifo);
100+
if (pipe->fifo != RT_NULL)
101+
rt_ringbuffer_destroy(pipe->fifo);
94102
pipe->fifo = RT_NULL;
95103
}
96104
device->ref_count --;

components/drivers/src/ringblk_buf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ void rt_rbb_destroy(rt_rbb_t rbb)
9595
{
9696
RT_ASSERT(rbb);
9797

98-
rt_free(rbb);
9998
rt_free(rbb->buf);
10099
rt_free(rbb->blk_set);
100+
rt_free(rbb);
101101

102102
}
103103
RTM_EXPORT(rt_rbb_destroy);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright (c) 2006-2018, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2017-09-12 Bernard The first version
9+
*/
10+
11+
#ifndef SIGNAL_H__
12+
#define SIGNAL_H__
13+
14+
#include <libc/libc_signal.h>
15+
16+
#define SIG_DFL ((_sig_func_ptr)0) /* Default action */
17+
#define SIG_IGN ((_sig_func_ptr)1) /* Ignore action */
18+
#define SIG_ERR ((_sig_func_ptr)-1) /* Error return */
19+
20+
#endif

components/utilities/Kconfig

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@ menu "Utilities"
22

33
config RT_USING_RYM
44
bool "Enable Ymodem"
5-
depends on RT_USING_DFS = y
65
default n
76

87
if RT_USING_RYM
9-
config YMODEM_DISABLE_CRC_TABLE
10-
bool "Disable CRC Table"
8+
config YMODEM_USING_CRC_TABLE
9+
bool "Enable CRC Table in Ymodem"
10+
default n
11+
12+
config YMODEM_USING_FILE_TRANSFER
13+
bool "Enable file transfer feature"
14+
select RT_USING_DFS
1115
default n
1216
endif
1317

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
from building import *
22

33
cwd = GetCurrentDir()
4-
src = Glob('*.c')
4+
src = Split('''
5+
ymodem.c
6+
''')
7+
58
CPPPATH = [cwd]
9+
10+
if GetDepend('RT_USING_DFS') and GetDepend('YMODEM_USING_FILE_TRANSFER'):
11+
src += ['ry_sy.c']
12+
613
group = DefineGroup('Utilities', src, depend = ['RT_USING_RYM'], CPPPATH = CPPPATH)
714

815
Return('group')

components/utilities/ymodem/ry_sy.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
#include <rtthread.h>
1212
#include <ymodem.h>
1313
#include <dfs_posix.h>
14+
15+
#include <stdio.h>
1416
#include <stdlib.h>
15-
#include <board.h>
1617
#include <string.h>
1718

1819
struct custom_ctx

components/utilities/ymodem/ymodem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <rthw.h>
1414
#include "ymodem.h"
1515

16-
#ifndef YMODEM_DISABLE_CRC_TABLE
16+
#ifdef YMODEM_USING_CRC_TABLE
1717
static const rt_uint16_t ccitt_table[256] =
1818
{
1919
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,

include/libc/libc_signal.h

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,14 @@ typedef struct siginfo siginfo_t;
6363
#define SI_MESGQ 0x05 /* Signal generated by arrival of a
6464
message on an empty message queue. */
6565

66-
#ifdef RT_USING_NEWLIB
67-
#include <sys/signal.h>
66+
#if !defined(RT_USING_NEWLIB)
67+
typedef void (*_sig_func_ptr)(int);
68+
typedef unsigned long sigset_t;
6869
#endif
6970

70-
#if defined(__CC_ARM) || defined(__CLANG_ARM)
7171
#include <signal.h>
72-
typedef unsigned long sigset_t;
72+
73+
#if defined(__CC_ARM) || defined(__CLANG_ARM)
7374

7475
#define SIGHUP 1
7576
/* #define SIGINT 2 */
@@ -105,8 +106,6 @@ typedef unsigned long sigset_t;
105106
#define SIG_BLOCK 1 /* set of signals to block */
106107
#define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
107108

108-
typedef void (*_sig_func_ptr)(int);
109-
110109
struct sigaction
111110
{
112111
_sig_func_ptr sa_handler;
@@ -124,8 +123,6 @@ int sigprocmask (int how, const sigset_t *set, sigset_t *oset);
124123
int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
125124

126125
#elif defined(__IAR_SYSTEMS_ICC__)
127-
#include <signal.h>
128-
typedef unsigned long sigset_t;
129126

130127
#define SIGHUP 1
131128
#define SIGINT 2
@@ -161,8 +158,6 @@ typedef unsigned long sigset_t;
161158
#define SIG_BLOCK 1 /* set of signals to block */
162159
#define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
163160

164-
typedef void (*_sig_func_ptr)(int);
165-
166161
struct sigaction
167162
{
168163
_sig_func_ptr sa_handler;

0 commit comments

Comments
 (0)