Vikrant More <vikrant8051@...>
toggle quoted message
Show quoted text
On Tue, Jan 30, 2018 at 8:07 PM, Puzdrowski, Andrzej <Andrzej.Puzdrowski@...> wrote:
> I request Zephyr OS maintainer to create & add following attached main.c under $zephyr_base/samples/boards/nrf52/nffs/src
& prj.conf under $zephyr_base/samples/boards/nrf52/nffs/ on Github.
Great, so I’m waiting for a PR with this.
Andrzej
From: zephyr-devel-bounces@lists.zephyrproject.org [mailto:zephyr-devel-bounces@lists.zephyrproject.org]
On Behalf Of Vikrant More
Sent: Monday, January 29, 2018 7:49 AM
To: Michael Hope <michaelh@...>; zephyr-users@lists.zephyrproject.org; zephyr-devel@lists.zephyrproject.org
Subject: Re: [Zephyr-devel] FW: support for NFFS file system
Now I can access flash of nRF52840 using NFFS file system APIs.
I request Zephyr OS maintainer to create & add following attached main.c under $zephyr_base/samples/boards/nrf52/nffs/src
& prj.conf under $zephyr_base/samples/boards/nrf52/nffs/ on Github.
Thank You !!
On Fri, Jan 26, 2018 at 1:43 AM, Michael Hope <michaelh@...> wrote:
You can look up the error numbers to see what they mean in:
-19 is ENODEV which suggests you have a flash driver configuration problem.
I put together a little sample at
https://github.com/nzmichaelh/zephyr_mini_samples I tested it on an Arduino Zero, not a NRF5 board, so you will need to update prj.conf but I hope it helps.
-- Michael
fs_open( ) returns -19 instead of 0.
On Thu, Jan 25, 2018 at 12:10 AM, Michael Hope <michaelh@...> wrote:
Hi Vikrant. I'm pretty sure you're reading past the end of the file - you'll need to close and reopen it before you can read back what you just wrote. Try something like:
I also recommend checking the return value when you're experimenting. In this case, you'll find that fs_read() is returning zero, i.e. it read zero bytes which is a good clue as to why there's no data in the buffer.
-- Michael
I make following changes .....
fs_file_t my_zfp;
unsigned char ptr[32];
for(cntr=0;cntr<=31;cntr++)
{
ptr[cntr]='@';
}
fs_open(&my_zfp,"mesh.prv");
fs_write(&my_zfp,"0123456789ABCDEF",16);
fs_read(&my_zfp,ptr,32);
fs_close(&my_zfp);
for(cntr=0;cntr<=31;cntr++)
{
printk("%c",ptr[cntr]);
}
But it prints --> @@@@@@@@@@@@@@@@
instead of --> 0123456789ABCDEF
On Wed, Jan 24, 2018 at 5:41 PM, Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@nordicsemi.no> wrote:
Its:
fs_file_t my_zfp; // no * please;
and
fs_open(&my_zfp,"mesh.prv"); // & please
J
That said, I am not expert on FS!
-Vinayak
I copied & pasted $zephyr/ext/fs/nffs directory into $zephyr_base/include
----------------------------------------------------------------------------------------------------------------------
& edit $zephyr_base/include/fs/nffs_fs.h as follow
/*
* Copyright (c) 2017 Codecoup
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _NFFS_FS_H_
#define _NFFS_FS_H_
#include <sys/types.h>
#include <nffs/include/nffs/nffs.h>
#ifdef __cplusplus
extern "C" {
#endif
FS_FILE_DEFINE(struct nffs_file *fp);
FS_DIR_DEFINE(struct nffs_dir *dp);
#define MAX_FILE_NAME 256
#ifdef __cplusplus
}
#endif
#endif /* _NFFS_FS_H_ */
-------------------------------------------------------------------------------------------------------------------------
& add following config into my prj.conf
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y
CONFIG_SOC_FLASH_NRF5=y
CONFIG_SOC_FLASH_NRF5_DEV_NAME="NRF52_FLASH"
CONFIG_SOC_FLASH_NRF5_RADIO_SYNC=y
CONFIG_ZTEST_STACKSIZE=2048
CONFIG_MAIN_STACK_SIZE=1024
CONFIG_HEAP_MEM_POOL_SIZE=1024
CONFIG_FILE_SYSTEM=y
CONFIG_FILE_SYSTEM_NFFS=y
CONFIG_FS_NFFS_NUM_FILES=4
CONFIG_FS_NFFS_NUM_DIRS=4
CONFIG_FS_NFFS_NUM_INODES=1024
CONFIG_FS_NFFS_NUM_BLOCKS=1024
CONFIG_FS_NFFS_NUM_CACHE_INODES=1
CONFIG_FS_NFFS_NUM_CACHE_BLOCKS=1
CONFIG_FILE_SYSTEM_NFFS=y
CONFIG_NFFS_FILESYSTEM_MAX_AREAS=12
------------------------------------------------------------------------------------------------------------------------
& add following lines in main.c
void main( )
{
fs_file_t *my_zfp;
unsigned char ptr[32];
fs_open(my_zfp,"mesh.prv");
fs_write(my_zfp,"Hello World !! ",16);
fs_read(my_zfp,ptr,32);
fs_close(my_zfp);
printk("%s",ptr);
}
After all this every thing gets compiled with warning :
warning: ‘my_zfp’ may be used uninitialized in this function [-Wmaybe-uninitialized]
fs_open(my_zfp,"mesh.prv");
Could you please help me, how to initialized my_zfp here ?
On Tue, Jan 23, 2018 at 1:15 AM, Michael Hope <michaelh@...> wrote:
void main( )
{
fs_file_t *my_zfp;
unsigned char ptr[32];
fs_open(my_zfp,"mesh.prv");
fs_write(my_zfp,"Hello World !! ",16);
fs_read(my_zfp,ptr,32);
fs_close(my_zfp);
printk("%s",ptr);
}
I've edited main.c in my project as mentioned above.
And add CONFIG_FILE_SYSTEM_NFFS=y in prj.conf
1st time I got following error,
In file included from /home/vikrant/projects/zephyr/zephyr/samples/bluetooth/mesh/src/main.c:3:0:
/home/vikrant/projects/zephyr/zephyr/include/fs.h:66:12: error: ‘MAX_FILE_NAME’ undeclared here (not in a function)
char name[MAX_FILE_NAME + 1];
^~~~~~~~~~~~~
CMakeFiles/app.dir/build.make:302: recipe for target 'CMakeFiles/app.dir/src/main.c.obj' failed
make[2]: *** [CMakeFiles/app.dir/src/main.c.obj] Error 1
CMakeFiles/Makefile2:259: recipe for target 'CMakeFiles/app.dir/all' failed
make[1]: *** [CMakeFiles/app.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
To overcome it I added ,
#define MAX_FILE_NAME 10 in zephyr/include/fs.h
After this I got following error,
../libapp.a(main.c.obj): In function `main':
/home/vikrant/projects/zephyr/zephyr/samples/bluetooth/mesh/src/main.c:226: undefined reference to `fs_open'
/home/vikrant/projects/zephyr/zephyr/samples/bluetooth/mesh/src/main.c:227: undefined reference to `fs_write'
/home/vikrant/projects/zephyr/zephyr/samples/bluetooth/mesh/src/main.c:228: undefined reference to `fs_read'
/home/vikrant/projects/zephyr/zephyr/samples/bluetooth/mesh/src/main.c:229: undefined reference to `fs_close'
collect2: error: ld returned 1 exit status
zephyr/CMakeFiles/zephyr_prebuilt.dir/build.make:104: recipe for target 'zephyr/zephyr_prebuilt.elf' failed
make[2]: *** [zephyr/zephyr_prebuilt.elf] Error 1
CMakeFiles/Makefile2:569: recipe for target 'zephyr/CMakeFiles/zephyr_prebuilt.dir/all' failed
make[1]: *** [zephyr/CMakeFiles/zephyr_prebuilt.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
Following line are already present in zephyr/boards/arm/nrf52840_pca10056/nrf52840_pca10056.dts
#if defined(CONFIG_FILE_SYSTEM_NFFS)
nffs_partition: partition@fc000 {
label = "nffs";
reg = <0x000fc000 0x00004000>;
};
#endif
Could you please tell me what I'm missing ?
On Fri, Jan 19, 2018 at 12:15 AM, Michael Hope <michaelh@...> wrote:
2. Turn on CONFIG_FILE_SYSTEM_NFFS in the config
3. Use the APIs in include/fs.h such as fs_open() etc
If you turn on CONFIG_FILE_SYSTEM_SHELL then you'll also get a simple interactive shell where you can list directories etc.
--
Michael
On Wed, Jan 24, 2018 at 5:41 PM, Chettimada, Vinayak Kariappa <vinayak.kariappa.chettimada@nordicsemi.no> wrote:
Its:
fs_file_t my_zfp; // no * please;
and
fs_open(&my_zfp,"mesh.prv"); // & please
J
That said, I am not expert on FS!
-Vinayak
I copied & pasted $zephyr/ext/fs/nffs directory into $zephyr_base/include
----------------------------------------------------------------------------------------------------------------------
& edit $zephyr_base/include/fs/nffs_fs.h as follow
/*
* Copyright (c) 2017 Codecoup
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _NFFS_FS_H_
#define _NFFS_FS_H_
#include <sys/types.h>
#include <nffs/include/nffs/nffs.h>
#ifdef __cplusplus
extern "C" {
#endif
FS_FILE_DEFINE(struct nffs_file *fp);
FS_DIR_DEFINE(struct nffs_dir *dp);
#define MAX_FILE_NAME 256
#ifdef __cplusplus
}
#endif
#endif /* _NFFS_FS_H_ */
-------------------------------------------------------------------------------------------------------------------------
& add following config into my prj.conf
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y
CONFIG_SOC_FLASH_NRF5=y
CONFIG_SOC_FLASH_NRF5_DEV_NAME="NRF52_FLASH"
CONFIG_SOC_FLASH_NRF5_RADIO_SYNC=y
CONFIG_ZTEST_STACKSIZE=2048
CONFIG_MAIN_STACK_SIZE=1024
CONFIG_HEAP_MEM_POOL_SIZE=1024
CONFIG_FILE_SYSTEM=y
CONFIG_FILE_SYSTEM_NFFS=y
CONFIG_FS_NFFS_NUM_FILES=4
CONFIG_FS_NFFS_NUM_DIRS=4
CONFIG_FS_NFFS_NUM_INODES=1024
CONFIG_FS_NFFS_NUM_BLOCKS=1024
CONFIG_FS_NFFS_NUM_CACHE_INODES=1
CONFIG_FS_NFFS_NUM_CACHE_BLOCKS=1
CONFIG_FILE_SYSTEM_NFFS=y
CONFIG_NFFS_FILESYSTEM_MAX_AREAS=12
------------------------------------------------------------------------------------------------------------------------
& add following lines in main.c
void main( )
{
fs_file_t *my_zfp;
unsigned char ptr[32];
fs_open(my_zfp,"mesh.prv");
fs_write(my_zfp,"Hello World !! ",16);
fs_read(my_zfp,ptr,32);
fs_close(my_zfp);
printk("%s",ptr);
}
After all this every thing gets compiled with warning :
warning: ‘my_zfp’ may be used uninitialized in this function [-Wmaybe-uninitialized]
fs_open(my_zfp,"mesh.prv");
Could you please help me, how to initialized my_zfp here ?
On Tue, Jan 23, 2018 at 1:15 AM, Michael Hope <michaelh@...> wrote:
void main( )
{
fs_file_t *my_zfp;
unsigned char ptr[32];
fs_open(my_zfp,"mesh.prv");
fs_write(my_zfp,"Hello World !! ",16);
fs_read(my_zfp,ptr,32);
fs_close(my_zfp);
printk("%s",ptr);
}
I've edited main.c in my project as mentioned above.
And add CONFIG_FILE_SYSTEM_NFFS=y in prj.conf
1st time I got following error,
In file included from /home/vikrant/projects/zephyr/zephyr/samples/bluetooth/mesh/src/main.c:3:0:
/home/vikrant/projects/zephyr/zephyr/include/fs.h:66:12: error: ‘MAX_FILE_NAME’ undeclared here (not in a function)
char name[MAX_FILE_NAME + 1];
^~~~~~~~~~~~~
CMakeFiles/app.dir/build.make:302: recipe for target 'CMakeFiles/app.dir/src/main.c.obj' failed
make[2]: *** [CMakeFiles/app.dir/src/main.c.obj] Error 1
CMakeFiles/Makefile2:259: recipe for target 'CMakeFiles/app.dir/all' failed
make[1]: *** [CMakeFiles/app.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
To overcome it I added ,
#define MAX_FILE_NAME 10 in zephyr/include/fs.h
After this I got following error,
../libapp.a(main.c.obj): In function `main':
/home/vikrant/projects/zephyr/zephyr/samples/bluetooth/mesh/src/main.c:226: undefined reference to `fs_open'
/home/vikrant/projects/zephyr/zephyr/samples/bluetooth/mesh/src/main.c:227: undefined reference to `fs_write'
/home/vikrant/projects/zephyr/zephyr/samples/bluetooth/mesh/src/main.c:228: undefined reference to `fs_read'
/home/vikrant/projects/zephyr/zephyr/samples/bluetooth/mesh/src/main.c:229: undefined reference to `fs_close'
collect2: error: ld returned 1 exit status
zephyr/CMakeFiles/zephyr_prebuilt.dir/build.make:104: recipe for target 'zephyr/zephyr_prebuilt.elf' failed
make[2]: *** [zephyr/zephyr_prebuilt.elf] Error 1
CMakeFiles/Makefile2:569: recipe for target 'zephyr/CMakeFiles/zephyr_prebuilt.dir/all' failed
make[1]: *** [zephyr/CMakeFiles/zephyr_prebuilt.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
Following line are already present in zephyr/boards/arm/nrf52840_pca10056/nrf52840_pca10056.dts
#if defined(CONFIG_FILE_SYSTEM_NFFS)
nffs_partition: partition@fc000 {
label = "nffs";
reg = <0x000fc000 0x00004000>;
};
#endif
Could you please tell me what I'm missing ?
On Fri, Jan 19, 2018 at 12:15 AM, Michael Hope <michaelh@...> wrote:
2. Turn on CONFIG_FILE_SYSTEM_NFFS in the config
3. Use the APIs in include/fs.h such as fs_open() etc
If you turn on CONFIG_FILE_SYSTEM_SHELL then you'll also get a simple interactive shell where you can list directories etc.
--
Michael
|