Using Partition Manager created partitions for FatFS

I have an issue with using partitions created by PM in external flash. I can create a partition in my prj.conf file and use that and everything works. But I need to put some data into the external NOR memory. PM creates the partitions correctly as far as I can see. But I have not found a way to make the FatFS driver correctly find those partitions. Basically I have the exact same issue as in this ticket:  How to reference PM generated partitions from device tree? 

I need to create a disk like this for FatFS driver to find.

/ {
	msc_disk0 {
		compatible = "zephyr,flash-disk";
		partition = <&external_flash>;
		disk-name = "NAND";
		cache-size = <4096>;
	};
};

If I have the partition in internal memory I can at least make this compile (the partition is tiny so it won't work for my application)

&flash0 {
	partitions {
		compatible = "fixed-partitions";
		#address-cells = <1>;
		#size-cells = <1>;

		boot_partition: partition@0 {
			label = "mcuboot";
			reg = <0x0 0xc000>;
		};
		slot0_partition: partition@c000 {
			label = "image-0";
			reg = <0xc000 0x72000>;
		};
		slot1_partition: partition@7e000 {
			label = "image-1";
			reg = <0x7e000 0x72000>;
		};
		scratch_partition: partition@f0000 {
			label = "image-scratch";
			reg = <0xf0000 0xa000>;
		};
		storage_partition: partition@fa000 {
			label = "storage";
			reg = <0xfa000 0x5f00>;
		};
		external_flash: partition@fff00 {
			label = "external_flash";
			reg = <0xfff00 0x100>;
		};
	};
};

The external memory itself is fine and I can read/write it with flash_area_read() and flash_area_write() functions. 

Is there a way to reference the PM created partitions from within the devicetree file of my main application?

Parents
  • Hi

    There haven't been any updates in the internal ticket I'm afraid. I pinged the devs for an update now, but I can't guarantee anything, and I do not have an estimate of when this can be fixed. If you need/want to escalate this, you will need to go via the Nordic regional sales manager of your area. Let me know if you don't have their contact information and I'll help you get in touch.

    I've asked the developers on your thoughts to ship with a broken MSD/MSC part. We can't guarantee that this will be a patchable issue on shipped products, so if this is a necessary feature we can't recommend that you ship it with a broken USB MSD/C...

    Very sorry about the inconvenience and frustration this issue has caused.

    Best regards,

    Simon

  • Hi Simon,

    Thank you for checking with the devs.

    What I'm currently doing is patching each new version of the SDK by just hardcoding the "area_id" value in /zephyr/drivers/disk/flashdisk.c to 6 (6 being specific to my partition manager created partition for the flashdisk). 

    The macro that defines all the flashdisks uses DT_FIXED_PARTITION_ID(PARTITION_PHANDLE(n)) and that seems to only work for partitions defined in the devicetree. I tried my best to figure out how to change this macro to read the Partition Manager output but due to time constraints I can't put more time into this. Since we only really need one flashdisk this hardcoded partition id works for us for now. We are not likely to change our memory layout either so it should be safe for now.

    What your devs would need to do is replace the macro with one that can actually read Partition Manager outputs when that is used instead of the dts file.

    Best regards,

    Tiit

Reply
  • Hi Simon,

    Thank you for checking with the devs.

    What I'm currently doing is patching each new version of the SDK by just hardcoding the "area_id" value in /zephyr/drivers/disk/flashdisk.c to 6 (6 being specific to my partition manager created partition for the flashdisk). 

    The macro that defines all the flashdisks uses DT_FIXED_PARTITION_ID(PARTITION_PHANDLE(n)) and that seems to only work for partitions defined in the devicetree. I tried my best to figure out how to change this macro to read the Partition Manager output but due to time constraints I can't put more time into this. Since we only really need one flashdisk this hardcoded partition id works for us for now. We are not likely to change our memory layout either so it should be safe for now.

    What your devs would need to do is replace the macro with one that can actually read Partition Manager outputs when that is used instead of the dts file.

    Best regards,

    Tiit

Children
No Data
Related