[U-Boot-Users] Write buffer programming for AMD flash chips

Thomas Schäfer thomas.schaefer at kontron.com
Thu Apr 28 14:58:16 CEST 2005


Hi Alex,

I had a look at your patch and I believe that it does almost the same than mine. From a point of readability and extendability I would prefer it, whereas my patch would save some memory.

A missing part in your patch is checking whether data to be written are aligned with the flash chips write buffer. This is done with the following hunk for the write_buff function:

 	buffered_size = (info->portwidth / info->chipwidth);
 	buffered_size *= info->buffer_size;
 	while (cnt >= info->portwidth) {
-		i = buffered_size > cnt ? cnt : buffered_size;
+		/* write buffer until next buffered_size aligned boundary */
+		i = buffered_size - (wp % buffered_size);
+		if (i>cnt)
+			i = cnt;
 		if ((rc = flash_write_cfibuffer (info, wp, src, i)) != ERR_OK)
 			return rc;
 		i -= (i % info->portwidth);

In our case, the lack of this code lead to errors when writing the environment to flash. The reason is that environment writing is done in 3 steps and this results in not buffer-aligned write cycles. The code above calculates the correct buffer size (i) depending on the first address (wp) to be written

Best regards,

Thomas Schäfer

E-mail: thomas.schaefer at kontron.com 




More information about the U-Boot mailing list