From c826bbdda82bec648faf5c58fb15453cc8225cd5 Mon Sep 17 00:00:00 2001
From: JianjunJiang <8192542@qq.com>
Date: Wed, 15 Dec 2021 17:54:31 +0800
Subject: [PATCH] [xfel]change some tips for splwrite command
---
README.md | 38 +++++++++++++++++++-------------------
main.c | 44 ++++++++++++++++++++++----------------------
spinand.c | 22 +++++++++++-----------
spinand.h | 2 +-
4 files changed, 53 insertions(+), 53 deletions(-)
diff --git a/README.md b/README.md
index ac23c38..9f3a801 100644
--- a/README.md
+++ b/README.md
@@ -57,25 +57,25 @@ For 64-bits windows, you can using `x86_64-w64-mingw32-` instead of `i686-w64-mi
```shell
xfel(v1.2.2) - https://github.com/xboot/xfel
usage:
- xfel version - Show chip version
- xfel hexdump
- Dumps memory region in hex
- xfel dump - Binary memory dump to stdout
- xfel exec - Call function address
- xfel read32 - Read 32-bits value from device memory
- xfel write32 - Write 32-bits value to device memory
- xfel read - Read memory to file
- xfel write - Write file to memory
- xfel reset - Reset device using watchdog
- xfel sid - Show sid information
- xfel jtag - Enable jtag debug
- xfel ddr [type] - Initial ddr controller with optional type
- xfel spinor - Detect spi nor flash
- xfel spinor read - Read spi nor flash to file
- xfel spinor write - Write file to spi nor flash
- xfel spinand - Detect spi nand flash
- xfel spinand read - Read spi nand flash to file
- xfel spinand write - Write file to spi nand flash
- xfel spinand splwrite - Write file to spi nand flash with spl mode
+ xfel version - Show chip version
+ xfel hexdump - Dumps memory region in hex
+ xfel dump - Binary memory dump to stdout
+ xfel exec - Call function address
+ xfel read32 - Read 32-bits value from device memory
+ xfel write32 - Write 32-bits value to device memory
+ xfel read - Read memory to file
+ xfel write - Write file to memory
+ xfel reset - Reset device using watchdog
+ xfel sid - Show sid information
+ xfel jtag - Enable jtag debug
+ xfel ddr [type] - Initial ddr controller with optional type
+ xfel spinor - Detect spi nor flash
+ xfel spinor read - Read spi nor flash to file
+ xfel spinor write - Write file to spi nor flash
+ xfel spinand - Detect spi nand flash
+ xfel spinand read - Read spi nand flash to file
+ xfel spinand write - Write file to spi nand flash
+ xfel spinand splwrite - Write file to spi nand flash with split support
```
## Links
diff --git a/main.c b/main.c
index 0d7b0d2..e74f7e7 100644
--- a/main.c
+++ b/main.c
@@ -83,25 +83,25 @@ static void usage(void)
{
printf("xfel(v1.2.2) - https://github.com/xboot/xfel\r\n");
printf("usage:\r\n");
- printf(" xfel version - Show chip version\r\n");
- printf(" xfel hexdump - Dumps memory region in hex\r\n");
- printf(" xfel dump - Binary memory dump to stdout\r\n");
- printf(" xfel exec - Call function address\r\n");
- printf(" xfel read32 - Read 32-bits value from device memory\r\n");
- printf(" xfel write32 - Write 32-bits value to device memory\r\n");
- printf(" xfel read - Read memory to file\r\n");
- printf(" xfel write - Write file to memory\r\n");
- printf(" xfel reset - Reset device using watchdog\r\n");
- printf(" xfel sid - Show sid information\r\n");
- printf(" xfel jtag - Enable jtag debug\r\n");
- printf(" xfel ddr [type] - Initial ddr controller with optional type\r\n");
- printf(" xfel spinor - Detect spi nor flash\r\n");
- printf(" xfel spinor read - Read spi nor flash to file\r\n");
- printf(" xfel spinor write - Write file to spi nor flash\r\n");
- printf(" xfel spinand - Detect spi nand flash\r\n");
- printf(" xfel spinand read - Read spi nand flash to file\r\n");
- printf(" xfel spinand write - Write file to spi nand flash\r\n");
- printf(" xfel spinand splwrite - Write file to spi nand flash with spl mode\r\n");
+ printf(" xfel version - Show chip version\r\n");
+ printf(" xfel hexdump - Dumps memory region in hex\r\n");
+ printf(" xfel dump - Binary memory dump to stdout\r\n");
+ printf(" xfel exec - Call function address\r\n");
+ printf(" xfel read32 - Read 32-bits value from device memory\r\n");
+ printf(" xfel write32 - Write 32-bits value to device memory\r\n");
+ printf(" xfel read - Read memory to file\r\n");
+ printf(" xfel write - Write file to memory\r\n");
+ printf(" xfel reset - Reset device using watchdog\r\n");
+ printf(" xfel sid - Show sid information\r\n");
+ printf(" xfel jtag - Enable jtag debug\r\n");
+ printf(" xfel ddr [type] - Initial ddr controller with optional type\r\n");
+ printf(" xfel spinor - Detect spi nor flash\r\n");
+ printf(" xfel spinor read - Read spi nor flash to file\r\n");
+ printf(" xfel spinor write - Write file to spi nor flash\r\n");
+ printf(" xfel spinand - Detect spi nand flash\r\n");
+ printf(" xfel spinand read - Read spi nand flash to file\r\n");
+ printf(" xfel spinand write - Write file to spi nand flash\r\n");
+ printf(" xfel spinand splwrite - Write file to spi nand flash with split support\r\n");
}
int main(int argc, char * argv[])
@@ -388,14 +388,14 @@ int main(int argc, char * argv[])
{
argc -= 1;
argv += 1;
- uint32_t pagesz = strtoul(argv[0], NULL, 0);
+ uint32_t splitsz = strtoul(argv[0], NULL, 0);
uint64_t addr = strtoull(argv[1], NULL, 0);
uint64_t len;
void * buf = file_load(argv[2], &len);
if(buf)
{
- if(!spinand_splwrite(&ctx, pagesz, addr, buf, len))
- printf("Can't write spi nand flash with spl mode\r\n");
+ if(!spinand_splwrite(&ctx, splitsz, addr, buf, len))
+ printf("Can't write spi nand flash with split support\r\n");
free(buf);
}
}
diff --git a/spinand.c b/spinand.c
index 4eaa346..3aae724 100644
--- a/spinand.c
+++ b/spinand.c
@@ -490,7 +490,7 @@ int spinand_write(struct xfel_ctx_t * ctx, uint64_t addr, void * buf, uint64_t l
return 0;
}
-int spinand_splwrite(struct xfel_ctx_t * ctx, uint32_t pagesz, uint64_t addr, void * buf, uint64_t len)
+int spinand_splwrite(struct xfel_ctx_t * ctx, uint32_t splitsz, uint64_t addr, void * buf, uint64_t len)
{
struct spinand_pdata_t pdat;
struct progress_t p;
@@ -504,9 +504,9 @@ int spinand_splwrite(struct xfel_ctx_t * ctx, uint32_t pagesz, uint64_t addr, vo
{
esize = pdat.info.page_size * pdat.info.pages_per_block;
emask = esize - 1;
- if((pagesz <= 0) || (pagesz > pdat.info.page_size))
- pagesz = pdat.info.page_size;
- if(pagesz & 0x3ff)
+ if((splitsz <= 0) || (splitsz > pdat.info.page_size))
+ splitsz = pdat.info.page_size;
+ if(splitsz & 0x3ff)
{
printf("The valid page size is not 1k alignable and thus not supported\r\n");
return 0;
@@ -523,7 +523,7 @@ int spinand_splwrite(struct xfel_ctx_t * ctx, uint32_t pagesz, uint64_t addr, vo
printf("The spl size is too large, please check!\r\n");
return 0;
}
- uint32_t tsplsz = (splsz * pdat.info.page_size / pagesz + esize) & ~emask;
+ uint32_t tsplsz = (splsz * pdat.info.page_size / splitsz + esize) & ~emask;
if(addr >= tsplsz)
{
int copies = 0;
@@ -540,10 +540,10 @@ int spinand_splwrite(struct xfel_ctx_t * ctx, uint32_t pagesz, uint64_t addr, vo
uint8_t * pb = buf;
uint8_t * pnb = nbuf;
memset(pnb, 0xff, nlen);
- for(int i = 0; i < splsz; i += pagesz)
+ for(int i = 0; i < splsz; i += splitsz)
{
- memcpy(pnb, pb, pagesz);
- pb += pagesz;
+ memcpy(pnb, pb, splitsz);
+ pb += splitsz;
pnb += pdat.info.page_size;
}
for(int i = 1; i < copies; i++)
@@ -564,10 +564,10 @@ int spinand_splwrite(struct xfel_ctx_t * ctx, uint32_t pagesz, uint64_t addr, vo
uint8_t * pb = buf;
uint8_t * pnb = nbuf;
memset(pnb, 0xff, nlen);
- for(int i = 0; i < splsz; i += pagesz)
+ for(int i = 0; i < splsz; i += splitsz)
{
- memcpy(pnb, pb, pagesz);
- pb += pagesz;
+ memcpy(pnb, pb, splitsz);
+ pb += splitsz;
pnb += pdat.info.page_size;
}
}
diff --git a/spinand.h b/spinand.h
index 2670c4d..95f3d3d 100644
--- a/spinand.h
+++ b/spinand.h
@@ -10,7 +10,7 @@ extern "C" {
int spinand_detect(struct xfel_ctx_t * ctx, char * name, uint64_t * capacity);
int spinand_read(struct xfel_ctx_t * ctx, uint64_t addr, void * buf, uint64_t len);
int spinand_write(struct xfel_ctx_t * ctx, uint64_t addr, void * buf, uint64_t len);
-int spinand_splwrite(struct xfel_ctx_t * ctx, uint32_t pagesz, uint64_t addr, void * buf, uint64_t len);
+int spinand_splwrite(struct xfel_ctx_t * ctx, uint32_t splitsz, uint64_t addr, void * buf, uint64_t len);
#ifdef __cplusplus
}