diff options
author | Ming Wei | 2015-09-16 15:21:21 -0500 |
---|---|---|
committer | Ming Wei | 2015-09-16 15:21:21 -0500 |
commit | 4947ab584625ffebeb67d112694341f04e2dd274 (patch) | |
tree | f0eb7b8168cce86715878c13bac94452442a2ed0 /writer | |
parent | 8eae8951378ae971ba3df050646e35dc9342db9d (diff) | |
download | mcsdk-tools-4947ab584625ffebeb67d112694341f04e2dd274.tar.gz mcsdk-tools-4947ab584625ffebeb67d112694341f04e2dd274.tar.xz mcsdk-tools-4947ab584625ffebeb67d112694341f04e2dd274.zip |
mcsdk_3.2.0:
update to PDK release 1.0
Diffstat (limited to 'writer')
-rwxr-xr-x | writer/nand/src/nandwriter.c | 2 | ||||
-rw-r--r-- | writer/qspi_flash/src/qspiflashwriter.c | 22 |
2 files changed, 19 insertions, 5 deletions
diff --git a/writer/nand/src/nandwriter.c b/writer/nand/src/nandwriter.c index d520410..458796b 100755 --- a/writer/nand/src/nandwriter.c +++ b/writer/nand/src/nandwriter.c | |||
@@ -626,8 +626,6 @@ void main () | |||
626 | return; | 626 | return; |
627 | } | 627 | } |
628 | nandWriterInfo.deviceTotalBytes = p_device->block_count * p_device->page_count * p_device->page_size; | 628 | nandWriterInfo.deviceTotalBytes = p_device->block_count * p_device->page_count * p_device->page_size; |
629 | if (nandWriterInfo.deviceTotalBytes > 0x40000000) | ||
630 | nandWriterInfo.deviceTotalBytes = 0x40000000; /* Max write size 1 GB */ | ||
631 | nandWriterInfo.blockSizeBytes = p_device->page_count * p_device->page_size; | 629 | nandWriterInfo.blockSizeBytes = p_device->page_count * p_device->page_size; |
632 | 630 | ||
633 | if ((nandWriterInfo.startAddr % nandWriterInfo.blockSizeBytes) != 0) | 631 | if ((nandWriterInfo.startAddr % nandWriterInfo.blockSizeBytes) != 0) |
diff --git a/writer/qspi_flash/src/qspiflashwriter.c b/writer/qspi_flash/src/qspiflashwriter.c index a0ec20d..1f3f2ba 100644 --- a/writer/qspi_flash/src/qspiflashwriter.c +++ b/writer/qspi_flash/src/qspiflashwriter.c | |||
@@ -60,6 +60,7 @@ uint32_t swap_byte = 0; | |||
60 | 60 | ||
61 | /* Memory address to store the write data */ | 61 | /* Memory address to store the write data */ |
62 | #define WRITE_DATA_ADDRESS 0x80000000 | 62 | #define WRITE_DATA_ADDRESS 0x80000000 |
63 | #define QSPI_FLASH_SIZE (64 * 1024 * 1024) | ||
63 | 64 | ||
64 | /****************************************************************************** | 65 | /****************************************************************************** |
65 | * Structure: QSPI_FLASH_WRITER_INFO_T | 66 | * Structure: QSPI_FLASH_WRITER_INFO_T |
@@ -71,6 +72,7 @@ uint32_t swap_byte = 0; | |||
71 | typedef struct QSPI_FLASH_WRITER_INFO_tag | 72 | typedef struct QSPI_FLASH_WRITER_INFO_tag |
72 | { | 73 | { |
73 | char file_name[MAX_LINE_LENGTH]; /* CCS format data file name */ | 74 | char file_name[MAX_LINE_LENGTH]; /* CCS format data file name */ |
75 | uint32_t filesize; /* Number of bytes to be written into the device */ | ||
74 | uint32_t blockSizeBytes; /* The size of each sector */ | 76 | uint32_t blockSizeBytes; /* The size of each sector */ |
75 | uint32_t deviceTotalBytes; /* Total number of bytes available in the device */ | 77 | uint32_t deviceTotalBytes; /* Total number of bytes available in the device */ |
76 | uint32_t startAddr; /* Start address to write */ | 78 | uint32_t startAddr; /* Start address to write */ |
@@ -175,15 +177,26 @@ write_qspi_flash | |||
175 | 177 | ||
176 | start_block = qspiFlashWriterInfo.startAddr / qspiFlashWriterInfo.blockSizeBytes; | 178 | start_block = qspiFlashWriterInfo.startAddr / qspiFlashWriterInfo.blockSizeBytes; |
177 | 179 | ||
180 | for (block = start_block, wPos = 0; wPos < qspiFlashWriterInfo.filesize; block++, wPos += qspiFlashWriterInfo.blockSizeBytes) | ||
181 | { | ||
182 | printf ("Erasing sector %d \n", block); | ||
183 | if (platform_device_erase_block (p_device->handle, block)) | ||
184 | { | ||
185 | printf ("platform_device_erase_block sector # %d failed!\n", start_block); | ||
186 | print_platform_errno(); | ||
187 | if (swap_byte) free (scrach_block); | ||
188 | return (FALSE); | ||
189 | } | ||
190 | } | ||
178 | /* Program the QSPI flash */ | 191 | /* Program the QSPI flash */ |
179 | for (block = start_block, wPos = 0; wPos < qspiFlashWriterInfo.writeBytes; block++, wPos += qspiFlashWriterInfo.blockSizeBytes) | 192 | for (block = start_block, wPos = 0; wPos < qspiFlashWriterInfo.writeBytes; block++, wPos += qspiFlashWriterInfo.blockSizeBytes) |
180 | { | 193 | { |
181 | printf ("Flashing sector %d (%d bytes of %d)\n", block, wPos, qspiFlashWriterInfo.writeBytes); | 194 | printf ("Flashing sector %d (%d bytes of %d)\n", block, wPos, qspiFlashWriterInfo.writeBytes); |
182 | 195 | ||
183 | wLen = qspiFlashWriterInfo.blockSizeBytes; | 196 | wLen = qspiFlashWriterInfo.blockSizeBytes; |
184 | if ((qspiFlashWriterInfo.writeBytes - wPos) < qspiFlashWriterInfo.blockSizeBytes) | 197 | if ((qspiFlashWriterInfo.filesize - wPos) < qspiFlashWriterInfo.blockSizeBytes) |
185 | { | 198 | { |
186 | wLen = (qspiFlashWriterInfo.writeBytes - wPos); | 199 | wLen = (qspiFlashWriterInfo.filesize - wPos); |
187 | } | 200 | } |
188 | 201 | ||
189 | if (swap_byte) | 202 | if (swap_byte) |
@@ -390,7 +403,7 @@ find_file_length | |||
390 | data_len = ftell(fp); | 403 | data_len = ftell(fp); |
391 | fseek(fp, 0, SEEK_SET); | 404 | fseek(fp, 0, SEEK_SET); |
392 | } | 405 | } |
393 | 406 | printf ("The contents of file %s of length %d will be written to QSPI flash of size 0x%x.\n", qspiFlashWriterInfo.file_name, data_len, QSPI_FLASH_SIZE); | |
394 | if (data_len > (qspiFlashWriterInfo.deviceTotalBytes - qspiFlashWriterInfo.startAddr)) | 407 | if (data_len > (qspiFlashWriterInfo.deviceTotalBytes - qspiFlashWriterInfo.startAddr)) |
395 | { | 408 | { |
396 | printf ("The data file is too big to fit into the device.\n"); | 409 | printf ("The data file is too big to fit into the device.\n"); |
@@ -400,6 +413,9 @@ find_file_length | |||
400 | qspiFlashWriterInfo.writeBytes = data_len; | 413 | qspiFlashWriterInfo.writeBytes = data_len; |
401 | if (write_addr != WRITE_DATA_ADDRESS) | 414 | if (write_addr != WRITE_DATA_ADDRESS) |
402 | write_addr = WRITE_DATA_ADDRESS; | 415 | write_addr = WRITE_DATA_ADDRESS; |
416 | memset((void *)write_addr, 0xFF, qspiFlashWriterInfo.blockSizeBytes); | ||
417 | qspiFlashWriterInfo.filesize= fread((void *)write_addr, 1, data_len, fp); | ||
418 | printf ("The contents of file %s read is of length %d.\n", qspiFlashWriterInfo.file_name, qspiFlashWriterInfo.filesize); | ||
403 | qspiFlashWriterInfo.writeData = (uint8_t *)write_addr; | 419 | qspiFlashWriterInfo.writeData = (uint8_t *)write_addr; |
404 | qspiFlashWriterInfo.readData = (uint8_t *)(write_addr + qspiFlashWriterInfo.deviceTotalBytes); | 420 | qspiFlashWriterInfo.readData = (uint8_t *)(write_addr + qspiFlashWriterInfo.deviceTotalBytes); |
405 | 421 | ||