I'm working on a project where we need to store into FLASH about 1350 bytes of compressed data at about 2HZ (twice a second). This is my first Nordic/Zephyr project, so I wanted your advice on which API would be more appropriate to use, the NVS interface (i.e. nvs_read/nvs_write). Or would the more lower-level FLASH API (flash_read and flash_write) be better? Note, we will have to be able to read as well as write the data. Second question, is writing an entire 4096 byte sector all at once the move efficient approach to writing to FLASH?
Finally, I want to be sure I understand the FLASH devicetree configuration. I've pasted the appropriate section below. It seems that all of the samples I've seen utilize only the "storage" partition. Since it starts at FA0000, does that mean is have about 66MB of storage capacity (i.e. 0x4000000 - 0xFA800 = 0x3F06000 = 66,084,864)? That doesn't seem right, so please correct my thinking. What is the meaning 0x6000 next to the offset FA0000?
So in short, if you could recommend the best FLASH API and correct my interpretation of the FLASH devicetree config, I'd appreciate it. BTW, in case it matters, I'm using SES and SDK v1.7.1.
Thanks in advance.
Kevin
------------------------------------------------------------------
peripheral@40000000 {
#address-cells = < 0x1 >;
#size-cells = < 0x1 >;
ranges = < 0x0 0x40000000 0x10000000 >;
flash_controller: flash-controller@39000 {
compatible = "nordic,nrf91-flash-controller";
reg = < 0x39000 0x1000 >;
#address-cells = < 0x1 >;
#size-cells = < 0x1 >;
label = "NRF_FLASH_DRV_NAME";
flash0: flash@0 {
compatible = "soc-nv-flash";
label = "NRF_FLASH";
erase-block-size = < 0x1000 >;
write-block-size = < 0x4 >;
reg = < 0x0 0x100000 >;
partitions {
compatible = "fixed-partitions";
#address-cells = < 0x1 >;
#size-cells = < 0x1 >;
boot_partition: partition@0 {
label = "mcuboot";
reg = < 0x0 0x10000 >;
};
slot0_partition: partition@10000 {
label = "image-0";
reg = < 0x10000 0x40000 >;
};
slot0_ns_partition: partition@50000 {
label = "image-0-nonsecure";
reg = < 0x50000 0x30000 >;
};
slot1_partition: partition@80000 {
label = "image-1";
reg = < 0x80000 0x40000 >;
};
slot1_ns_partition: partition@c0000 {
label = "image-1-nonsecure";
reg = < 0xc0000 0x30000 >;
};
scratch_partition: partition@f0000 {
label = "image-scratch";
reg = < 0xf0000 0xa000 >;
};
storage_partition: partition@fa000 {
label = "storage";
reg = < 0xfa000 0x6000 >;
};
};
};
};