在spi的flash中创建了文件系统,然后通过Ymodem协议向里面传输文件,但是点击Ymodem发送后,会报错error creating file: -12。如下图
请问这是什么原因呢。
这个需要你单步调试一下运行一下看看了,根据打印的日志信息,是这个函数打印出来的,所以你应该在 open 这里打断点单步调试一下看看是运行到哪一步返回了错误代码。
// 文件 components/utilities/ymodem/ry_sy.c
static enum rym_code _rym_recv_begin(
struct rym_ctx *ctx,
rt_uint8_t *buf,
rt_size_t len)
{
struct custom_ctx *cctx = (struct custom_ctx *)ctx;
cctx->fpath[0] = '/';
rt_strncpy(&(cctx->fpath[1]), (const char *)buf, len - 1);
cctx->fd = open(cctx->fpath, O_CREAT | O_WRONLY | O_TRUNC, 0);
if (cctx->fd < 0)
{
rt_err_t err = rt_get_errno();
rt_kprintf("error creating file: %d\n", err);
return RYM_CODE_CAN;
}
cctx->flen = atoi(1 + (const char *)buf + rt_strnlen((const char *)buf, len - 1));
if (cctx->flen == 0)
cctx->flen = -1;
return RYM_CODE_ACK;
}
而根据错误代码 -12,查阅可以得到具体含义是 ENOMEM
,错误代码含义如下:
// error.h
#define EPERM 1 /* Not owner */
#define ENOENT 2 /* No such file or directory */
#define ESRCH 3 /* No such process */
#define EINTR 4 /* Interrupted system call */
#define EIO 5 /* I/O error */
#define ENXIO 6 /* No such device or address */
#define E2BIG 7 /* Arg list too long */
#define ENOEXEC 8 /* Exec format error */
#define EBADF 9 /* Bad file number */
#define ECHILD 10 /* No children */
#define EAGAIN 11 /* No more processes */
#define ENOMEM 12 /* Not enough space */
#define EACCES 13 /* Permission denied */
#define EFAULT 14 /* Bad address */
Not enough space 这个指的是哪个的空间不足啊?是堆栈不足吗?
你可以看看你的线程栈大小和片外flash的大小。这个需要你具体调试一下,看看是哪个函数返回的错误代码,然后才能进一步分析出问题的原因。
好的,再麻烦问您一下,Ymodem的线程栈在哪里设置调整啊
@ldk060
你用 ps 指令看一下你现在都运行了什么线程,把线程的相关信息贴出来