Re: Running ZTest for custom drivers on Boards.
Hi,
Running sanitycheck on a specific device is currently not supported, but it is a highly requested features and is planned. You could always go into the test you
are interested in and just flash the binary to the device you are testing for now.
Anas
toggle quoted messageShow quoted text
From: zephyr-users-bounces@... [mailto:zephyr-users-bounces@...]
On Behalf Of dhananjay gj
Sent: Tuesday, February 6, 2018 9:13 AM
To: zephyr-users@...
Subject: [Zephyr-users] Running ZTest for custom drivers on Boards.
I created a custom driver for one of our device on a board and wanted to write testcases for it. I can build the testcases by following other test driver folders like gpio or i2c , but these are not
running the test_main() which is supposed to run the test suite that i wrote. And I also followed the zephyr documentation about using the sanitycheck script, but i think this just builds the project if i understood it. I would like to know how to run unit
tests on the board for my devices instead of qemu on the PC.
This may be rookie question but i could find any documentation how about can we do this on boards if its possible. Any leads on this will be helpful.
Many thanks for the support.
Regards,
Dhananjay G J
|
|
Running ZTest for custom drivers on Boards.
Hello All,
I created a custom driver for one of our device on a board and wanted to write testcases for it. I can build the testcases by following other test driver folders like gpio or i2c , but these are not running the test_main() which is supposed to run the test suite that i wrote. And I also followed the zephyr documentation about using the sanitycheck script, but i think this just builds the project if i understood it. I would like to know how to run unit tests on the board for my devices instead of qemu on the PC. This may be rookie question but i could find any documentation how about can we do this on boards if its possible. Any leads on this will be helpful. Many thanks for the support. Regards, Dhananjay G J
|
|
(#BluetoothMesh) just binding APP-key allow SRV to process the message
Vikrant More <vikrant8051@...>
Using #meshctl I gave following commands to BOARD_1
appkey-add 1
bind 0 1 1000 bind 0 1 1001 bind 0 1 1002 bind 0 1 1003 sub-add 0100 c000 1000 sub-add 0100 c001 1000 pub-set 0100 c000 1 0 5 1001 sub-add 0100 c000 1002 pub-set 0100 c000 1 0 5 1003 ------------------------------ ------------------------------ ------------------------------ -------- Using #meshctl I gave following commands to BOARD_2
appkey-add 1
bind 0 1 1000 bind 0 1 1001 bind 0 1 1002 bind 0 1 1003 sub-add 0101 c000 1000 //in last email I by mistake wrote 0100 instead of 0101, but main Question is as it is. pub-set 0101 c001 1 0 5 1001 ------------------------------ ------------------------------ ------------------------------ ------------ I've hard coded 4 Models, viz,
GEN_ONOFF_SRV
GEN_ONOFF_CLI
GEN_LEVEL_SRV
GEN_LEVEL_CLI
on both boards.
I found something wrong in case of BOARD_2,
where I only bound APP_Key to all available models but didn't
assign any sub or pub addresses to GEN_LEVEL_SRV or GEN_LEVEL_CLI
even after that BOARD_2 is processing data publish by GEN_LEVEL_CLIENT of BOARD_1.
Have anybody noticed it ?
|
|
(#BluetoothMesh) just binding APP-key allow SRV to process the message
Vikrant More <vikrant8051@...>
Using #meshctl I gave following commands to BOARD_1
appkey-add 1
bind 0 1 1000 bind 0 1 1001 bind 0 1 1002 bind 0 1 1003 sub-add 0100 c000 1000 sub-add 0100 c001 1000 pub-set 0100 c000 1 0 5 1001 sub-add 0100 c000 1002 pub-set 0100 c000 1 0 5 1003 -------------------------------------------------------------------------------------------------- Using #meshctl I gave following commands to BOARD_2
appkey-add 1
bind 0 1 1000 bind 0 1 1001 bind 0 1 1002 bind 0 1 1003 sub-add 0100 c000 1000 pub-set 0100 c001 1 0 5 1001 ------------------------------------------------------------------------------------------------------ I've hard coded 4 Models, viz,
GEN_ONOFF_SRV
GEN_ONOFF_CLI
GEN_LEVEL_SRV
GEN_LEVEL_CLI
on both boards.
I found something wrong in case of BOARD_2,
where I only bound APP_Key to all available models but didn't
assign any sub or pub addresses to GEN_LEVEL_SRV or GEN_LEVEL_CLI
even after that BOARD_2 is processing data publish by GEN_LEVEL_CLIENT of BOARD_1.
Have anybody noticed it ?
|
|
Sorry meant to be prov_db.json. autocorrect failed me.
Sent from my Samsung Galaxy smartphone.
toggle quoted messageShow quoted text
-------- Original message --------
From: Hongjian Fan <fan@...>
Date: 06/02/2018 14:46 (GMT+08:00)
To: zephyr-users@...
Subject: [Zephyr-users] RPI 3 bluez recipe
Hi
Trying meshctl from latest bluez git checkout with latest raspbian on RPI 3, Failed to parse provide.json. Wondered how you successfully run on it. Can please share detailed instructions?
Thanks!
|
|
Hi
Trying meshctl from latest bluez git checkout with latest raspbian on RPI 3, Failed to parse provide.json. Wondered how you successfully run on it. Can please share detailed instructions?
Thanks!
|
|
1-32khz sensor-sampling loop
hi all,
i'd like to sample a sensor (actually several sensors) in precise intervals at speeds up to 32khz.
it seems timer and sleep functions only have millisecond resolution and I cannot busy wait.
anyone have suggestions on the best way to go about this?
best, nathan
|
|
Re: [Zephyr-devel] FW: support for NFFS file system
Vikrant More <vikrant8051@...>
Hello World !!
What to do so that every fs_write( ) will save data on next new line ? Similarly what to do so that every fs_read() will read data from next new line ? Thank You !!
toggle quoted messageShow quoted text
On Wed, Jan 31, 2018 at 3:17 PM, Cufi, Carles <Carles.Cufi@...> wrote:
Hi Vikrant,
Yes, we would like the sample to be merged, but you need to send a Pull Request using GitHub.
Please read through the Contribution Guidelines:
http://docs.zephyrproject.org/contribute/contribute_guidelines.html.
Feel free to ask questions about those here or on IRC (#zephyrproject on freenode.net)
Regards,
Carles
On Tue, Jan 30, 2018 at 8:07 PM, Puzdrowski, Andrzej <Andrzej.Puzdrowski@nordicsemi.no>
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
|
|
Re: [Zephyr-devel] FW: support for NFFS file system
Hi Vikrant,
Yes, we would like the sample to be merged, but you need to send a Pull Request using GitHub.
Please read through the Contribution Guidelines:
http://docs.zephyrproject.org/contribute/contribute_guidelines.html.
Feel free to ask questions about those here or on IRC (#zephyrproject on freenode.net)
Regards,
Carles
From:
<zephyr-devel-bounces@...> on behalf of Vikrant More <vikrant8051@...>
Date: Wednesday, 31 January 2018 at 06:04
To: "Puzdrowski, Andrzej" <Andrzej.Puzdrowski@...>
Cc: "zephyr-users@..." <zephyr-users@...>, "zephyr-devel@..." <zephyr-devel@...>
Subject: Re: [Zephyr-devel] FW: support for NFFS file system
toggle quoted messageShow 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@...
[mailto:zephyr-devel-bounces@...]
On Behalf Of Vikrant More
Sent: Monday, January 29, 2018 7:49 AM
To: Michael Hope <michaelh@...>;
zephyr-users@...;
zephyr-devel@...
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@...>
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@...>
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
|
|
Re: [Zephyr-devel] FW: support for NFFS file system
Vikrant More <vikrant8051@...>
toggle quoted messageShow 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
|
|
Re: [Zephyr-devel] FW: support for NFFS file system
Puzdrowski, Andrzej <Andrzej.Puzdrowski@...>
> 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
toggle quoted messageShow quoted text
From: zephyr-devel-bounces@... [mailto:zephyr-devel-bounces@...]
On Behalf Of Vikrant More
Sent: Monday, January 29, 2018 7:49 AM
To: Michael Hope <michaelh@...>; zephyr-users@...; zephyr-devel@...
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@...> 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@...> 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
|
|
Re: Saving #BluetoothMesh Provisioning & Configuration related data on flash of nRF52 using NFFS
#bluetoothmesh
Vikrant More <vikrant8051@...>
As per this document ....
nrf5_SDK_for_Mesh_v1.0.1_src/doc/introduction/mesh_hw_resources.md
(I've attached this file for reference......very informative)
The mesh stack uses flash to store the following states:
- Encryption keys
- Mesh addresses
- Access model composition
- Access model configuration
- Network message sequence number
- Network IV index state
- DFU metadata (it is not part of #BluetoothMesh Specs)
Link to download latest Nordic Mesh SDK v1.0.1 --> https://www.nordicsemi.com/eng/nordic/download_resource/62377/26/71116706/126781
Is other than this, anything else we have to save on flash ?
Thank You !!
toggle quoted messageShow quoted text
On Tue, Jan 30, 2018 at 5:22 PM, Vikrant More <vikrant8051@...> wrote: So I edit above mentioned structure definition as (in both locations)
struct prov_data { u8_t pdu[25]; u8_t dev_key[16]; u8_t flags; u16_t net_idx; u16_t addr; u32_t iv_index;
} __attribute__((packed));
|
|
Re: Saving #BluetoothMesh Provisioning & Configuration related data on flash of nRF52 using NFFS
#bluetoothmesh
Vikrant More <vikrant8051@...>
So I edit above mentioned structure definition as (in both locations) struct prov_data { u8_t pdu[25]; u8_t dev_key[16]; u8_t flags; u16_t net_idx; u16_t addr; u32_t iv_index; } __attribute__((packed));
toggle quoted messageShow quoted text
On Tue, Jan 30, 2018 at 3:49 PM, Vikrant More <vikrant8051@...> wrote: Hello World !!
By including NFFS support into #BluetoothMesh project, now I can access flash of nRF52.
{
I've edited prov_data( ) function which is available at $zephyr_base/subssy/bluetooth/host/mesh/prov.c as follow, static void prov_data(const u8_t *data) { struct net_buf_simple *msg = PROV_BUF(1); u8_t session_key[16]; u8_t nonce[13]; u8_t dev_key[16]; u8_t pdu[25]; u8_t flags; u32_t iv_index; u16_t addr; u16_t net_idx; int err; BT_DBG(""); err = bt_mesh_session_key(link. dhkey, link.prov_salt, session_key); if (err) { BT_ERR("Unable to generate session key"); close_link(PROV_ERR_UNEXP_ERR, CLOSE_REASON_FAILED); return; } BT_DBG("SessionKey: %s", bt_hex(session_key, 16)); err = bt_mesh_prov_nonce(link.dhkey, link.prov_salt, nonce); if (err) { BT_ERR("Unable to generate session nonce"); close_link(PROV_ERR_UNEXP_ERR, CLOSE_REASON_FAILED); return; } BT_DBG("Nonce: %s", bt_hex(nonce, 13)); err = bt_mesh_prov_decrypt(session_ key, nonce, data, pdu); if (err) { BT_ERR("Unable to decrypt provisioning data"); close_link(PROV_ERR_DECRYPT, CLOSE_REASON_FAILED); return; } err = bt_mesh_dev_key(link.dhkey, link.prov_salt, dev_key); if (err) { BT_ERR("Unable to generate device key"); close_link(PROV_ERR_UNEXP_ERR, CLOSE_REASON_FAILED); return; } BT_DBG("DevKey: %s", bt_hex(dev_key, 16)); net_idx = sys_get_be16(&pdu[16]); flags = pdu[18]; iv_index = sys_get_be32(&pdu[19]); addr = sys_get_be16(&pdu[23]); BT_DBG("net_idx %u iv_index 0x%08x, addr 0x%04x", net_idx, iv_index, addr); prov_buf_init(msg, PROV_COMPLETE); prov_send(msg); /* Ignore any further PDUs on this link */ link.expect = 0; bt_mesh_provision(pdu, net_idx, flags, iv_index, 0, addr, dev_key); //------------------------------------------------------------------------------------------------------------------------------------------
struct prov_data { u8_t pdu[25]; u8_t dev_key[16]; u8_t flags; u16_t net_idx; u16_t addr; u32_t iv_index; };
union { unsigned char array[50]; struct prov_data a; }foo; int i;
for(i=0;i<=24;i++) { foo.a.pdu[i]=pdu[i]; }
for(i=0;i<=15;i++) { foo.a.dev_key[i]=dev_key[i]; }
foo.a.flags = flags; foo.a.net_idx = net_idx; foo.a.addr = addr; foo.a.iv_index = iv_index; fs_file_t fp;
err = fs_open(&fp,"/prov.txt"); if (err != 0) { printk("\n\rerror %d while opening prov_cfg.txt for write\n\r", err); }
err = fs_write(&fp, foo.array, 50); if (err != 50) { printk("\n\rerror %d while writing PDU\n\r", err); }
err = fs_close(&fp); if (err != 0) { printk("\n\rerror %d while closing prov_cfg.txt after write\n\r", err); }
//------------------------------------------------------------------------------------------------------------------------------------------} Similarly, edit bt_ready( ) from $zephyr_base/samples/ bluetooth/mesh/src/main.c as follow static void bt_ready(int err) { . . . . printk("Mesh initialized\n\r"); struct fs_dirent entry;
struct prov_data { u8_t pdu[25]; u8_t dev_key[16]; u8_t flags; u16_t net_idx; u16_t addr; u32_t iv_index; };
union { unsigned char array[50]; struct prov_data a; }test;
if(fs_stat("/prov.txt",&entry)==0) { printk("\n\rprov.txt is available\n\r");
fs_file_t fp;
err = fs_open(&fp,"/prov.txt"); if (err != 0) { printk("error %d while opening for read\n\r", err); }
err = fs_read(&fp, test.array, 50); if (err < 0) { printk("error %d while reading\n\r", err); }
err = fs_close(&fp); if (err != 0) { printk("error %d while closing after read\n\r", err); }
err = bt_mesh_provision(test.a.pdu, test.a.net_idx, test.a.flags, test.a.iv_index, 0, test.a.addr, test.a.dev_key); if(err) { printk("Provisioning failed (err %d)\n", err); return; }
printk("Provisioning completed\n\r"); }
} So after reset if prov.txt is available then DEVICE will automatically provision itself.
And as per my testing it is working perfectly.
But is it right approach since I've dare to touch stack ? 🤔
Now I wanna save data related to configuration which happens just after provisioning.
Where I will find that function ?
I'm aware about bt_mesh_cfg_app_key_add( ) this function but for that we've to enable CONFIG_BT_MESH_CFG_CLI=y
Is it necessary ? ...because even we disable it, provisioner APP trigger some function which does every thing like bt_mesh_cfg_app_key_add( ) does.
So please tell me where I will find that function, so that I can save ALL data related configuration into cfg.txt ?
As per my understanding once we complete, Provisioning & Configuration process, then there is no need to touch prov.txt & cfg.txt
in future for writing ? Am I right ?
Besides prov.txt & cfg.txt , how many files we have to create ?
If there will be standard for creating files for #BluetoothMesh then that will helpful for all.
Thank You !!
|
|
Saving #BluetoothMesh Provisioning & Configuration related data on flash of nRF52 using NFFS
#bluetoothmesh
Vikrant More <vikrant8051@...>
Hello World !!
By including NFFS support into #BluetoothMesh project, now I can access flash of nRF52.
{
I've edited prov_data( ) function which is available at $zephyr_base/subssy/bluetooth/host/mesh/prov.c as follow, static void prov_data(const u8_t *data) { struct net_buf_simple *msg = PROV_BUF(1); u8_t session_key[16]; u8_t nonce[13]; u8_t dev_key[16]; u8_t pdu[25]; u8_t flags; u32_t iv_index; u16_t addr; u16_t net_idx; int err; BT_DBG(""); err = bt_mesh_session_key(link.dhkey, link.prov_salt, session_key); if (err) { BT_ERR("Unable to generate session key"); close_link(PROV_ERR_UNEXP_ERR, CLOSE_REASON_FAILED); return; } BT_DBG("SessionKey: %s", bt_hex(session_key, 16)); err = bt_mesh_prov_nonce(link.dhkey, link.prov_salt, nonce); if (err) { BT_ERR("Unable to generate session nonce"); close_link(PROV_ERR_UNEXP_ERR, CLOSE_REASON_FAILED); return; } BT_DBG("Nonce: %s", bt_hex(nonce, 13)); err = bt_mesh_prov_decrypt(session_key, nonce, data, pdu); if (err) { BT_ERR("Unable to decrypt provisioning data"); close_link(PROV_ERR_DECRYPT, CLOSE_REASON_FAILED); return; } err = bt_mesh_dev_key(link.dhkey, link.prov_salt, dev_key); if (err) { BT_ERR("Unable to generate device key"); close_link(PROV_ERR_UNEXP_ERR, CLOSE_REASON_FAILED); return; } BT_DBG("DevKey: %s", bt_hex(dev_key, 16)); net_idx = sys_get_be16(&pdu[16]); flags = pdu[18]; iv_index = sys_get_be32(&pdu[19]); addr = sys_get_be16(&pdu[23]); BT_DBG("net_idx %u iv_index 0x%08x, addr 0x%04x", net_idx, iv_index, addr); prov_buf_init(msg, PROV_COMPLETE); prov_send(msg); /* Ignore any further PDUs on this link */ link.expect = 0; bt_mesh_provision(pdu, net_idx, flags, iv_index, 0, addr, dev_key); //------------------------------------------------------------------------------------------------------------------------------------------
struct prov_data { u8_t pdu[25]; u8_t dev_key[16]; u8_t flags; u16_t net_idx; u16_t addr; u32_t iv_index; };
union { unsigned char array[50]; struct prov_data a; }foo; int i;
for(i=0;i<=24;i++) { foo.a.pdu[i]=pdu[i]; }
for(i=0;i<=15;i++) { foo.a.dev_key[i]=dev_key[i]; }
foo.a.flags = flags; foo.a.net_idx = net_idx; foo.a.addr = addr; foo.a.iv_index = iv_index; fs_file_t fp;
err = fs_open(&fp,"/prov.txt"); if (err != 0) { printk("\n\rerror %d while opening prov_cfg.txt for write\n\r", err); }
err = fs_write(&fp, foo.array, 50); if (err != 50) { printk("\n\rerror %d while writing PDU\n\r", err); }
err = fs_close(&fp); if (err != 0) { printk("\n\rerror %d while closing prov_cfg.txt after write\n\r", err); }
//------------------------------------------------------------------------------------------------------------------------------------------} Similarly, edit bt_ready( ) from $zephyr_base/samples/bluetooth/mesh/src/main.c as follow static void bt_ready(int err) { . . . . printk("Mesh initialized\n\r"); struct fs_dirent entry;
struct prov_data { u8_t pdu[25]; u8_t dev_key[16]; u8_t flags; u16_t net_idx; u16_t addr; u32_t iv_index; };
union { unsigned char array[50]; struct prov_data a; }test;
if(fs_stat("/prov.txt",&entry)==0) { printk("\n\rprov.txt is available\n\r");
fs_file_t fp;
err = fs_open(&fp,"/prov.txt"); if (err != 0) { printk("error %d while opening for read\n\r", err); }
err = fs_read(&fp, test.array, 50); if (err < 0) { printk("error %d while reading\n\r", err); }
err = fs_close(&fp); if (err != 0) { printk("error %d while closing after read\n\r", err); }
err = bt_mesh_provision(test.a.pdu, test.a.net_idx, test.a.flags, test.a.iv_index, 0, test.a.addr, test.a.dev_key); if(err) { printk("Provisioning failed (err %d)\n", err); return; }
printk("Provisioning completed\n\r"); }
} So after reset if prov.txt is available then DEVICE will automatically provision itself.
And as per my testing it is working perfectly.
But is it right approach since I've dare to touch stack ? 🤔
Now I wanna save data related to configuration which happens just after provisioning.
Where I will find that function ?
I'm aware about bt_mesh_cfg_app_key_add( ) this function but for that we've to enable CONFIG_BT_MESH_CFG_CLI=y
Is it necessary ? ...because even we disable it, provisioner APP trigger some function which does every thing like bt_mesh_cfg_app_key_add( ) does.
So please tell me where I will find that function, so that I can save ALL data related configuration into cfg.txt ?
As per my understanding once we complete, Provisioning & Configuration process, then there is no need to touch prov.txt & cfg.txt
in future for writing ? Am I right ?
Besides prov.txt & cfg.txt , how many files we have to create ?
If there will be standard for creating files for #BluetoothMesh then that will helpful for all.
Thank You !!
|
|
Re: [Zephyr-devel] FW: support for NFFS file system
Vikrant More <vikrant8051@...>
I forgot to inform that, we have to add ext/fs/nffs/include into list of include directories.
For that edit $zephyr_base/CMakeLists.txt as follow .... so it will looks like..
zephyr_include_directories( kernel/include arch/${ARCH}/include arch/${ARCH}/soc/${SOC_PATH} arch/${ARCH}/soc/${SOC_PATH}/include arch/${ARCH}/soc/${SOC_FAMILY}/include ${BOARD_DIR} include include/drivers ${PROJECT_BINARY_DIR}/include/generated ${USERINCLUDE} ${STDINCLUDE} ext/fs/nffs/include )
I have also corrected my main.c. Plz consider it.
toggle quoted messageShow quoted text
On Mon, Jan 29, 2018 at 12:19 PM, Vikrant More <vikrant8051@...> wrote: Thanks Michael !!
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 !!
|
|
Re: [Zephyr-devel] FW: support for NFFS file system
Vikrant More <vikrant8051@...>
Thanks Michael !!
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 !!
toggle quoted messageShow quoted text
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.
|
|
Re: [Zephyr-devel] FW: support for NFFS file system
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
toggle quoted messageShow quoted text
fs_open( ) returns -19 instead of 0.
|
|
hiding GATT peripheral services till Passkey pairing
Vikrant More <vikrant8051@...>
Hello World !! I modified $zephyr_base/sample/bluetooth/peripheral/src/main.c as mentioned above.
Using nRF Blinky Android App, I can toggle LED1 on nRF52840-PDK board & can read & receive notification about Button1 status.
But anyone with that App can access my peripheral device.
If I enabled BT_GATT_PERM_READ_AUTHEN & BT_GATT_PERM_WRITE_AUTHEN for characteristic using BT_GATT_DESCRIPTOR then only paired device could access it.
For password based pairing, we have to access peripheral's UART terminal since it throws random passkey on it.
How to make it static one?
If I reboot the board, why MAC address get updated ?
If I reboot the board, I have to pair it again with Smartphone. Why it so ?
How to avoid this ?
What changes I have to make, so that once paired peripheral will not allow other device to access it unless & until I pressed some button on it ?
How to enable GATT connection, only after password protected pairing process has completed with Smartphone ?
When I do experiments with nRF connect App I can connect to other BLE devices surrounding to me but I can't see services running on them. How to achive that ?
Thank You !!
|
|
Re: [Zephyr-devel] FW: support for NFFS file system
Vikrant More <vikrant8051@...>
fs_open( ) returns -19 instead of 0.
toggle quoted messageShow quoted text
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:
fs_open(...) fs_write(...) fs_close(...)
fs_open(...) fs_read(...)
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
Hi Vinayak, it works !!
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]); }
|
|
Re: [Zephyr-devel] FW: support for NFFS file system
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:
fs_open(...) fs_write(...) fs_close(...)
fs_open(...) fs_read(...)
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
toggle quoted messageShow quoted text
Hi Vinayak, it works !!
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]); }
|
|