[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [microblaze-uclinux]U-boot hang in function flash_detect_cfi(...), need your help.



Hi John:
    Thanks a lot.

2009/11/12 John Williams <john.williams@xxxxxxxxxxxxx>:
> Hi Childhood,
>
> On Thu, Nov 12, 2009 at 6:26 PM, Childhood Hwang
> <childhood.hwang@xxxxxxxxx> wrote:
>> Hello all:
>>
>> The function  flash_readarray_mode(...) of fs-boot set  an value
>> 0xFFFFFFFF, What is it for ?
>
> It's a kind of reset for CFI flash, to ensure it's in so-called "read
> array mode" - that is in normal, reading, randomly accessible mode.
>
> It's used to make sure that the flash is in a known state before
> trying to read or execute code from it.
>
>> /*!
>>  * This routine send a command to the CUI
>>  * to put the FLASH into Read Array mode.
>>  *
>>  * @param  addr - Memory address of FLASH device
>>  *
>>  * @return  none
>>  */
>> static void flash_readarray_mode(unsigned long flash_addr)
>> {
>>
>>        /*
>>         * We assume it is all CFI FLASH
>>         * Write 32-bit to take care off all flash
>>         * configurations.
>>         */
>>        *((volatile unsigned long *)(flash_addr)) = 0xFFFFFFFF;
>> }
>>
>> I am trying to initialize a flash during u-boot phase, but u-boot hang
>> in function flash_detect_cfi(...).
>> This flash works well when I use it as the flash memory to boot u-boot
>> and the kernel.
>
> So if I understand the problem is in u-boot somewhere?

For testing, I modify uboot's function flash_init (void) in cfi_flash.c :

/* I copy it from the function flash_get_size (ulong base, int
banknum) , and modify a little bit*/
ulong flash_get_size_1 (ulong base, int banknum)
{
     /* This two lines is my modification and the left code is the
same with flash_get_size(...), Childhood.hwang*/
    flash_info_t tmp_flash_info;                     // add
	flash_info_t *info = &tmp_flash_info  /*&flash_info[banknum]*/;  // modified


	int i, j;
	flash_sect_t sect_cnt;
	unsigned long sector;
	unsigned long tmp;
	int size_ratio;
	uchar num_erase_regions;
	int erase_region_size;
	int erase_region_count;
#ifdef CFG_FLASH_PROTECTION
	int ext_addr;
	info->legacy_unlock = 0;
#endif

	info->start[0] = base;
	if (flash_detect_cfi (info)) {         // uboot hang here
             ..........................................
        }
             ..........................................
}

In function flash_detect_cfi (info), the two "for loops" run to
"FLASH_CFI_64BIT     0x08" and "FLASH_CFI_BY64     0x08",
then hang in "if" statement:
                         if (flash_isequal (info, 0, FLASH_OFFSET_CFI_RESP, 'Q')
			    && flash_isequal (info, 0, FLASH_OFFSET_CFI_RESP + 1, 'R')
			    && flash_isequal (info, 0, FLASH_OFFSET_CFI_RESP + 2, 'Y'))

unsigned long flash_init (void)
{
	unsigned long size = 0;
	int i;

        ....................................................

        flash_get_size_1(0x87000000, 0);   // for testing , add by
Childhood.hwang
	return (size);
}

>
>> Should anyone help me about initialization of an flash ?
>
> Normally 'just works' - is there anything non-standard about your
> flash connection and interface etc?

This flash is TE28F256J3C125. The only special thing of these flash is
that one EMC control two banks of the flash.
EMC configs:

BEGIN xps_mch_emc
 PARAMETER INSTANCE = SRAM_FLASH
 PARAMETER HW_VER = 2.00.a
 PARAMETER C_NUM_CHANNELS = 0
 PARAMETER C_MCH_PLB_CLK_PERIOD_PS = 8000
 PARAMETER C_MAX_MEM_WIDTH = 16
 PARAMETER C_MEM0_WIDTH = 16
 PARAMETER C_INCLUDE_DATAWIDTH_MATCHING_0 = 1
 PARAMETER C_TCEDV_PS_MEM_0 = 110000
 PARAMETER C_TWC_PS_MEM_0 = 11000
 PARAMETER C_TAVDV_PS_MEM_0 = 110000
 PARAMETER C_TWP_PS_MEM_0 = 70000
 PARAMETER C_THZCE_PS_MEM_0 = 35000
 PARAMETER C_TLZWE_PS_MEM_0 = 35000
 PARAMETER C_NUM_BANKS_MEM = 2
 PARAMETER C_MEM1_WIDTH = 8
 PARAMETER C_INCLUDE_DATAWIDTH_MATCHING_1 = 1
 PARAMETER C_TCEDV_PS_MEM_1 = 110000
 PARAMETER C_TAVDV_PS_MEM_1 = 110000
 PARAMETER C_THZCE_PS_MEM_1 = 35000
 PARAMETER C_TWC_PS_MEM_1 = 11000
 PARAMETER C_TWP_PS_MEM_1 = 70000
 PARAMETER C_TLZWE_PS_MEM_1 = 35000
 PARAMETER C_MEM0_BASEADDR = 0x88000000
 PARAMETER C_MEM0_HIGHADDR = 0x8fffffff
 PARAMETER C_MEM1_BASEADDR = 0x87000000
 PARAMETER C_MEM1_HIGHADDR = 0x87ffffff
 BUS_INTERFACE SPLB = mb_plb
 PORT Mem_A = fpga_0_SRAM_FLASH_Mem_A_split
 PORT Mem_WEN = fpga_0_SRAM_FLASH_Mem_WEN_dmux
 PORT Mem_OEN = fpga_0_SRAM_FLASH_Mem_OEN
 PORT Mem_CEN = fpga_0_SRAM_FLASH_Mem_CEN
 PORT RdClk = sys_clk_s
 PORT Mem_DQ_O = fpga_0_SRAM_FLASH_Mem_DQ_O_dmux
 PORT Mem_RPN = fpga_0_BASE_FLASH_Mem_RPN_dmux
 PORT Mem_DQ_T = fpga_0_SRAM_FLASH_Mem_DQ_T_dmux
 PORT Mem_DQ_I = fpga_0_SRAM_FLASH_Mem_DQ_I_dmux
END

The one I am trying to initialize is in 8Bits data bus width and 16M
Bytes (in fact this flash is 32M Bytes, hardware
has some mistake, but it doesn't matter), but the other is in 16Bits
data bus width and 32M Bytes.
I config these two flash as the flash memory individually, each of
them works well. But when I use the "16Bits" flash
as the flash memory and try to call "flash_get_size()" in function
flash_init(....), flash_detect_cfi (....) hangs there.

In u-boot, I can display the  content of the "8Bits data bus width"
flash using  command  "md 0x87000000", so I think
the hardware connection is correct.

I will try more testing tomorrow, I feel lost right now.

>
> John
> --
> John Williams, PhD, B.Eng, B.IT
> PetaLogix - Linux Solutions for a Reconfigurable World
> w: www.petalogix.com  p: +61-7-30090663  f: +61-7-30090663
>
> ___________________________
> microblaze-uclinux mailing list
> microblaze-uclinux@xxxxxxxxxxxxxx
> Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
> Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/
>
>

Rgs.
Childhood.

___________________________
microblaze-uclinux mailing list
microblaze-uclinux@xxxxxxxxxxxxxx
Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/