How to create a new partition in the internal flash memory to read and write data using zephyr?

hi guys,

I am using the nRF54L15 for software development. I have a requirement to define a space in the chip's internal flash for data storage. I referred to the soc-flash-nrf example program in the NCS V3.1.1 version. As shown in the figure below, I created a user_partition space by following the example and then attempted to perform read and write operations. However, the chip directly crashes at this line of code. I don't know why. Is my definition of user_partition incomplete?

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

		boot_partition: partition@0 {
			label = "mcuboot";
			reg = <0x0 DT_SIZE_K(64)>;
		};

		slot0_partition: partition@10000 {
			label = "image-0";
			reg = <0x10000 DT_SIZE_K(524)>;
		};

		slot1_partition: partition@93000 {
			label = "image-1";
			reg = <0x93000 DT_SIZE_K(524)>;
		};

		storage_partition: partition@116000 {
			label = "storage";
			reg = <0x116000 DT_SIZE_K(36)>;
		};

		user_partition: partition@11f000 {
			label = "user-storage";
			reg = <0x11f000 DT_SIZE_K(280)>;
		};
	};
};

int main(void)
{
	//uint32_t offset;
	const struct device *flash_dev = TEST_PARTITION_DEVICE;
	struct flash_parameters flash_params;

	uint8_t test_data[TEST_DATA_SIZE_IN_BYTES];

	memcpy(&flash_params, flash_get_parameters(flash_dev), sizeof(flash_params));//this code went crashes 
	// prepare_test_data(test_data);

	printf("\nNordic nRF5 Internal Storage Sample\n");
	printf("=====================================\n");

	// if (!device_is_ready(flash_dev)) {
	// 	printf("Internal storage device not ready\n");
	// 	return 0;
	// }

Parents Reply Children
Related