diff --git a/Targets/LS2K/dev/spi_w.c b/Targets/LS2K/dev/spi_w.c index 58ae0a50..e7ee938a 100644 --- a/Targets/LS2K/dev/spi_w.c +++ b/Targets/LS2K/dev/spi_w.c @@ -459,7 +459,7 @@ int spi_erase_area(unsigned int saddr,unsigned int eaddr,unsigned sectorsize) * 0x52 erase 32kbyte of memory array * 0xd8 erase 64kbyte of memory array */ - SET_SPI(TXFIFO,0x20); + SET_SPI(TXFIFO,(sectorsize==0x1000?0x20:((sectorsize==0x8000)?0x52:0xd8))); while((GET_SPI(SPSR))&RFEMPTY); GET_SPI(RXFIFO); SET_SPI(TXFIFO,addr >> 16); @@ -544,7 +544,7 @@ int spi_read_area(int flashaddr,char *buffer,int size) struct fl_device myflash = { .fl_name="spiflash", .fl_size=0x100000, - .fl_secsize=0x10000, + .fl_secsize=FLASH_SECTOR_SIZE, }; struct fl_device *fl_devident(void *base, struct fl_map **m) @@ -572,7 +572,7 @@ int fl_erase_device(void *fl_base, int size, int verbose) int off; map = fl_find_map(fl_base); off = (int)(fl_base - map->fl_map_base) + map->fl_map_offset; - spi_erase_area(off,off+size,0x1000); + spi_erase_area(off,off+size, myflash.fl_secsize); spi_initr(); return 0; } diff --git a/Targets/LS2K/include/bonito.h b/Targets/LS2K/include/bonito.h index 046273dc..a1f288db 100644 --- a/Targets/LS2K/include/bonito.h +++ b/Targets/LS2K/include/bonito.h @@ -69,6 +69,10 @@ struct pci_config_data { /*********************************************************************/ /*nvram define */ /*********************************************************************/ +#ifndef FLASH_SECTOR_SIZE +#define FLASH_SECTOR_SIZE 0x1000 +#endif + #ifdef NVRAM_IN_FLASH # define NVRAM_SIZE 492 /*modified by tangyt*/ # define NVRAM_SECSIZE 500 @@ -77,7 +81,7 @@ struct pci_config_data { #ifdef BOOT_FROM_NAND # define NVRAM_OFFS 0x000ffc00/*number 4 block*/ #else -# define NVRAM_OFFS 0x000ff000 +# define NVRAM_OFFS (0x100000 - FLASH_SECTOR_SIZE) #endif # define ETHER_OFFS 494 /* Ethernet address base */ #else /* Use clock ram, 256 bytes only */ diff --git a/Targets/LS2K/include/load_dtb.h b/Targets/LS2K/include/load_dtb.h index df3b9f81..b8e050e9 100644 --- a/Targets/LS2K/include/load_dtb.h +++ b/Targets/LS2K/include/load_dtb.h @@ -25,7 +25,7 @@ normal: |-----bfc00000---| dtb: |-----bfc00000---| #include #define DTB_SIZE 0x4000 /* 16K dtb size*/ -#define DTB_OFFS (NVRAM_OFFS - DTB_SIZE) +#define DTB_OFFS ((NVRAM_OFFS - DTB_SIZE) & ~(FLASH_SECTOR_SIZE - 1)) #define MAX_LEVEL 32 /* how deeply nested we will go */ #define SCRATCHPAD 1024 /* bytes of scratchpad memory */