Filesystem in RTEMS
xuelin.tian at qkmtech.com
xuelin.tian at qkmtech.com
Mon Oct 23 10:07:23 UTC 2017
Sorry, I delete some parts of my code.
The sectors of S25FL256S flash chip has a combination of 4KB and 64KB. Only the 64KB sectors will be used, for simplicity, and the beginning address of them is 0x00020000.
The "beginning" variable I use here is equal to offset plus 0x00020000 (S25FL256S_BOTTOM_GAP_ADDRESS).
The page size of flash is 256B, BTW.
/*******************************************************************************************/
static int flash_write(
rtems_jffs2_flash_control *super,
uint32_t offset,
unsigned char *buffer,
size_t length) {
flash_control *self = get_flash_control(super);
XQspiPs *flash_handle = self->flash_instance;
uint32_t beginning = offset + S25FL256S_BOTTOM_GAP_ADDRESS;
uint32_t num = length / S25FL256S_PAGE_SIZE;
uint32_t remaining = length % S25FL256S_PAGE_SIZE;
uint32_t written;
for (written = 0; written < num; written++) {
FlashWrite(flash_handle, beginning + written*S25FL256S_PAGE_SIZE, \
S25FL256S_PAGE_SIZE, WRITE_CMD, \
buffer + written*S25FL256S_PAGE_SIZE);
}
if (remaining) {
FlashWrite(flash_handle, beginning + num*S25FL256S_PAGE_SIZE, \
remaining, WRITE_CMD, buffer + num*S25FL256S_PAGE_SIZE);
}
return S25FL256S_SUCCESS;
}
/*************************************************************************************************/
Best wishes,
xuelin.tian at qkmtech.com
From: Sebastian Huber
Date: 2017-10-23 17:44
To: xuelin.tian at qkmtech.com; Chris Johns
CC: users at rtems.org
Subject: Re: Filesystem in RTEMS
On 23/10/17 11:40, Sebastian Huber wrote:
>
>
> On 23/10/17 11:33, xuelin.tian at qkmtech.com wrote:
>> static int flash_write(
>> rtems_jffs2_flash_control *super,
>> uint32_t offset,
>> unsigned char *buffer,
>> size_t length) {
>>
>> flash_control *self = get_flash_control(super);
>> XQspiPs *flash_handle = self->flash_instance;
>> uint32_t num = length / S25FL256S_PAGE_SIZE;
>> uint32_t remaining = length % S25FL256S_PAGE_SIZE;
>> uint32_t written;
>>
>> for (written = 0; written < num; written++) {
>> FlashWrite(flash_handle, beginning + written*S25FL256S_PAGE_SIZE, \
>>
>> S25FL256S_PAGE_SIZE, WRITE_CMD, \
>> buffer + written*S25FL256S_PAGE_SIZE);
>> }
>> if (remaining) {
>> FlashWrite(flash_handle, beginning + num*S25FL256S_PAGE_SIZE, \
>> remaining, WRITE_CMD, buffer + num*S25FL256S_PAGE_SIZE);
>> }
>> return S25FL256S_SUCCESS;
>> }
>>
>> where, my FlashRead and FlashWrite functions will invoke the
>> functions defined in Xilinx BSP to transfer data from/into flash.
>>
>> I do not know where the problem is...
>
> You assume length % S25FL256S_PAGE_SIZE == 0.
Sorry, I should have read the code more carefully.
What is "beginning"? Why don't you use "offset" in this function?
--
Sebastian Huber, embedded brains GmbH
Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : sebastian.huber at embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20171023/7a909af7/attachment-0002.html>
More information about the users
mailing list