2009-07-14 11:59:39     Atmel SPI FLASH: Power-of-Two Conversion Tool

Document created by Aaronwu Employee on Sep 24, 2013
Version 1Show Document
  • View in full screen mode

2009-07-14 11:59:39     Atmel SPI FLASH: Power-of-Two Conversion Tool

JF Duval (CANADA)

Message: 77243   

 

Hello everybody,

 

I wrote a small function to change a Dataflash (like an AT45DB321D) in 512 bytes pages (rather than 528 bytes). Here is how to do it:

 

1- In spi_flash.c (.../u-boot-1.1.6-2008R1.5/board/YourBoard/spi_flash.c), you need to add one line in eeprom_info(void). Just before SPI_DEINIT(); add atmel_po2(flash.sector_size); //Atmel Dataflash vs Power-of-Two

 

2- In spi_flash.c, add this function (after eeprom_info(void)):

 

//ATMEL Spi Flash Power-of-Two Tool (JFDuval, IntRoLab, 2009)

int atmel_po2(int size)

{

    char InData;

 

    if(size == 528)  

    {

        //It's in Dataflash, we can change it

        printf("Your FLASH uses 528 bytes pages.  It can be converted to 512 bytes\n"                 "pages.  Important: conversion is PERMANENT (no come back). Want to\n"                 "change it to 512? [y/n]");

 

        InData = getc();

        if((InData == 'y')||(InData == 'Y'))

        {

            printf("\nRunning conversion tool...\n");

 

            //Open SPI

            SPI_ON();

  

            //Send the 4 configuration bytes

            printf("Byte: 0x3D\n");

            spi_write_read_byte(0x3D);

            printf("Byte: 0x2A\n");

            spi_write_read_byte(0x2A);

            printf("Byte: 0x80\n");

            spi_write_read_byte(0x80);

            printf("Byte: 0xA6\n");

            spi_write_read_byte(0xA6);

 

            printf("Wait a moment than cycle power.\n");

 

            //Close SPI

            SPI_OFF();

 

        }

        else

            printf("\nNo modifications will be done.\n");

 

    }

    else if(size == 512)

    {

        printf("This FLASH is in Power-of-Two mode.\n");

    }

 

}

 

3- To use it, just call eeprom info while running U-Boot and follow the instructions.

 

I hope it will be useful!

 

 

 

P.S.: I attached my spi_flash.c file.

 

JFDuval

 

 

 

 

spi_flash.c

QuoteReplyEditDelete

 

 

2009-08-17 16:35:55     Re: Atmel SPI FLASH: Power-of-Two Conversion Tool

Mike Frysinger (UNITED STATES)

Message: 78964   

 

ive been working a slightly different angle upstream.  i took your code and turned it into a standalone u-boot app:

http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/64233/focus=64530

 

afaik, upstream will be accepting this, but it's just that the current merge window is closed so it'll probably get merged in the next cycle

Attachments

Outcomes