You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "jingfei195887 (via GitHub)" <gi...@apache.org> on 2026/01/13 13:28:54 UTC

[PR] driver/cfi-flash: Add a config option for the page size of CFI flash. [nuttx]

jingfei195887 opened a new pull request, #17866:
URL: https://github.com/apache/nuttx/pull/17866

   ## Summary
   We have added a defconfig configuration to set the page size of the flash. According to the CFI protocol, the flash supports a single write operation with a data volume ranging from byte size up to the maximum number of bytes. However, the MTD device structure requires defining a page size, which serves as the minimum write unit of the flash. Hence, this configuration is introduced. Any page size within the range of 1 to the maximum number of bytes is considered valid.
   
   ## Impact
   Only impacts CFI-Flash writes
   
   ## Testing
   We have completed the validation based on the QEMU environment.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] driver/cfi-flash: Add a config option for the page size of CFI flash. [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on PR #17866:
URL: https://github.com/apache/nuttx/pull/17866#issuecomment-3757705712

   @jingfei195887 please squash your change into one patch to fix the ci warning:
   ```
   ../nuttx/tools/checkpatch.sh -c -u -m -g 4514a11237e9d012db39f377a2a92d5ced1e1066..HEAD
   ❌ Commit subject missing colon (e.g. 'subsystem: msg')
   ❌ Missing Signed-off-by
   ❌ Commit subject missing colon (e.g. 'subsystem: msg')
   ❌ Missing Signed-off-by
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] driver/cfi-flash: Add a config option for the page size of CFI flash. [nuttx]

Posted by "jingfei195887 (via GitHub)" <gi...@apache.org>.
jingfei195887 commented on code in PR #17866:
URL: https://github.com/apache/nuttx/pull/17866#discussion_r2686642555


##########
drivers/mtd/Kconfig:
##########
@@ -1503,4 +1503,18 @@ config MTD_CFI
 	---help---
 		Support CFI(common flash interface) NOR FLASH.
 
+config MTD_CFI_PAGE_SIZE
+	int "page size of MTD CFI NOR FLASH (bytes)"

Review Comment:
   yes this is better, thanks~



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] driver/cfi-flash: Add a config option for the page size of CFI flash. [nuttx]

Posted by "jingfei195887 (via GitHub)" <gi...@apache.org>.
jingfei195887 commented on code in PR #17866:
URL: https://github.com/apache/nuttx/pull/17866#discussion_r2697546336


##########
drivers/mtd/Kconfig:
##########
@@ -1503,4 +1503,11 @@ config MTD_CFI
 	---help---
 		Support CFI(common flash interface) NOR FLASH.
 
+config MTD_CFI_PAGE_SIZE
+	int "Page Size of MTD CFI NOR FLASH (bytes)"
+	default 16
+	depends on MTD_CFI
+	---help---
+		Configure write page size of CFI Flash.

Review Comment:
   no, the page size is fixed by flash device. it's a fixed value



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] driver/cfi-flash: Add a config option for the page size of CFI flash. [nuttx]

Posted by "jingfei195887 (via GitHub)" <gi...@apache.org>.
jingfei195887 commented on code in PR #17866:
URL: https://github.com/apache/nuttx/pull/17866#discussion_r2686628377


##########
drivers/mtd/Kconfig:
##########
@@ -1503,4 +1503,18 @@ config MTD_CFI
 	---help---
 		Support CFI(common flash interface) NOR FLASH.
 
+config MTD_CFI_PAGE_SIZE
+	int "page size of MTD CFI NOR FLASH (bytes)"
+	default 16
+	depends on MTD_CFI
+	---help---
+		Configure write page size of CFI Flash.
+		According to the CFI protocol, the flash supports write
+		operation size from one byte up to a maximum number of bytes
+		defined in flash hardware acccording the CFI document JEP137B.

Review Comment:
   removed



##########
drivers/mtd/Kconfig:
##########
@@ -1503,4 +1503,18 @@ config MTD_CFI
 	---help---
 		Support CFI(common flash interface) NOR FLASH.
 
+config MTD_CFI_PAGE_SIZE
+	int "page size of MTD CFI NOR FLASH (bytes)"
+	default 16

Review Comment:
   no range is needed here



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] driver/cfi-flash: Add a config option for the page size of CFI flash. [nuttx]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #17866:
URL: https://github.com/apache/nuttx/pull/17866#discussion_r2686456561


##########
drivers/mtd/Kconfig:
##########
@@ -1503,4 +1503,18 @@ config MTD_CFI
 	---help---
 		Support CFI(common flash interface) NOR FLASH.
 
+config MTD_CFI_PAGE_SIZE
+	int "page size of MTD CFI NOR FLASH (bytes)"
+	default 16

Review Comment:
   The configuration option lacks input validation. Consider adding a range constraint to ensure the page size is at least 1 byte and doesn't exceed a reasonable maximum. For example: `range 1 65536` to prevent invalid configurations that could cause runtime errors.
   ```suggestion
   	default 16
   	range 1 65536
   ```



##########
drivers/mtd/Kconfig:
##########
@@ -1503,4 +1503,18 @@ config MTD_CFI
 	---help---
 		Support CFI(common flash interface) NOR FLASH.
 
+config MTD_CFI_PAGE_SIZE
+	int "page size of MTD CFI NOR FLASH (bytes)"
+	default 16
+	depends on MTD_CFI
+	---help---
+		Configure write page size of CFI Flash.
+		According to the CFI protocol, the flash supports write
+		operation size from one byte up to a maximum number of bytes
+		defined in flash hardware acccording the CFI document JEP137B.

Review Comment:
   Typo in the word 'acccording' - it has three 'c's instead of two. It should be 'according'.
   ```suggestion
   		defined in flash hardware according the CFI document JEP137B.
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] driver/cfi-flash: Add a config option for the page size of CFI flash. [nuttx]

Posted by "jingfei195887 (via GitHub)" <gi...@apache.org>.
jingfei195887 commented on PR #17866:
URL: https://github.com/apache/nuttx/pull/17866#issuecomment-3758844556

   > @jingfei195887 please look the suggestions from Copilot, I think these suggestion could be incorporated in the PR
   
   Some copilot's comment is accepted, thanks for reminding.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] driver/cfi-flash: Add a config option for the page size of CFI flash. [nuttx]

Posted by "jingfei195887 (via GitHub)" <gi...@apache.org>.
jingfei195887 commented on PR #17866:
URL: https://github.com/apache/nuttx/pull/17866#issuecomment-3758845856

   > @jingfei195887 please squash your change into one patch to fix the ci warning:
   > 
   > ```
   > ../nuttx/tools/checkpatch.sh -c -u -m -g 4514a11237e9d012db39f377a2a92d5ced1e1066..HEAD
   > ❌ Commit subject missing colon (e.g. 'subsystem: msg')
   > ❌ Missing Signed-off-by
   > ❌ Commit subject missing colon (e.g. 'subsystem: msg')
   > ❌ Missing Signed-off-by
   > ```
   
   this is done


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] driver/cfi-flash: Add a config option for the page size of CFI flash. [nuttx]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #17866:
URL: https://github.com/apache/nuttx/pull/17866#discussion_r2686735377


##########
drivers/mtd/Kconfig:
##########
@@ -1503,4 +1503,11 @@ config MTD_CFI
 	---help---
 		Support CFI(common flash interface) NOR FLASH.
 
+config MTD_CFI_PAGE_SIZE
+	int "Page Size of MTD CFI NOR FLASH (bytes)"
+	default 16
+	depends on MTD_CFI
+	---help---
+		Configure write page size of CFI Flash.

Review Comment:
   The page size should ideally be a multiple of the bank width to ensure optimal write operations. The code at line 1100 uses ALIGN_DOWN(nbytes, cfi->bankwidth), which suggests that writes must be aligned to bankwidth. Consider documenting in the Kconfig help text that the page size should be a multiple of the bank width, or add validation to ensure this constraint is met.
   ```suggestion
   		Configure write page size of CFI Flash.
   		The configured page size should be a multiple of the device
   		bank width to match the alignment requirements of the CFI
   		driver and avoid having writes rounded down to the nearest
   		bank-width boundary.
   ```



##########
drivers/mtd/Kconfig:
##########
@@ -1503,4 +1503,11 @@ config MTD_CFI
 	---help---
 		Support CFI(common flash interface) NOR FLASH.
 
+config MTD_CFI_PAGE_SIZE
+	int "Page Size of MTD CFI NOR FLASH (bytes)"
+	default 16

Review Comment:
   The configuration option lacks validation to ensure CONFIG_MTD_CFI_PAGE_SIZE is positive. A page size of zero would cause division by zero errors in cfi_mtd_bread (line 113, 116) and cfi_mtd_bwrite (line 132, 135) in mtd_cfi.c, as well as a modulo by zero error in cfi_write (line 1096) in cfi.c. Consider adding a "range 1 65536" constraint to prevent invalid values.
   ```suggestion
   	default 16
   	range 1 65536
   ```



##########
drivers/mtd/Kconfig:
##########
@@ -1503,4 +1503,11 @@ config MTD_CFI
 	---help---
 		Support CFI(common flash interface) NOR FLASH.
 
+config MTD_CFI_PAGE_SIZE
+	int "Page Size of MTD CFI NOR FLASH (bytes)"
+	default 16
+	depends on MTD_CFI
+	---help---
+		Configure write page size of CFI Flash.
+

Review Comment:
   The help text for this configuration option should be more detailed. It should explain: (1) the valid range of values (must be at least 1 and should not exceed the hardware-supported maximum write buffer size), (2) the relationship to the CFI flash's max_write_bytes_num parameter, and (3) the performance implications of choosing different page sizes. Users need this context to make informed configuration decisions.
   ```suggestion
   		Configure the write page size (in bytes) used by the CFI NOR Flash
   		driver.
   
   		The value must be at least 1 and should not exceed the maximum
   		write buffer size supported by the CFI device. In the driver,
   		this capability is typically exposed as the device's
   		"max_write_bytes_num" parameter; this configuration value should
   		be chosen such that it is less than or equal to
   		max_write_bytes_num for the target flash.
   
   		Larger page sizes (up to the hardware limit) usually improve
   		write throughput by allowing more data to be written per program
   		operation, reducing command overhead. Smaller page sizes may be
   		more conservative and can reduce the latency of individual
   		writes, but they increase the number of write operations needed
   		for the same amount of data and can therefore reduce overall
   		performance.
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] driver/cfi-flash: Add a config option for the page size of CFI flash. [nuttx]

Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on PR #17866:
URL: https://github.com/apache/nuttx/pull/17866#issuecomment-3754438914

   @xiaoxiang781216 what you think about these Copilot suggestion? At first glance it appears like an improvement.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] driver/cfi-flash: Add a config option for the page size of CFI flash. [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #17866:
URL: https://github.com/apache/nuttx/pull/17866


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] driver/cfi-flash: Add a config option for the page size of CFI flash. [nuttx]

Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on code in PR #17866:
URL: https://github.com/apache/nuttx/pull/17866#discussion_r2686620577


##########
drivers/mtd/Kconfig:
##########
@@ -1503,4 +1503,18 @@ config MTD_CFI
 	---help---
 		Support CFI(common flash interface) NOR FLASH.
 
+config MTD_CFI_PAGE_SIZE
+	int "page size of MTD CFI NOR FLASH (bytes)"

Review Comment:
   ```suggestion
   	int "Page Size of MTD CFI NOR FLASH (bytes)"



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] driver/cfi-flash: Add a config option for the page size of CFI flash. [nuttx]

Posted by "jingfei195887 (via GitHub)" <gi...@apache.org>.
jingfei195887 commented on PR #17866:
URL: https://github.com/apache/nuttx/pull/17866#issuecomment-3754449623

   > @xiaoxiang781216 what you think about these Copilot suggestion? At first glance it appears like an improvement.
   @acassis Sorry for the late reply. I also saw Copilot's suggestions on my end—they should be helpful. I'll make the revisions now, and thanks for reminding
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org