The difference analysis of flash writing speed under Uboot and Linux

Source: Internet
Author: User

Handavei @ Jilin Normal University

2015.1.27.

Reprint please indicate the source

*********************************************


Uboot and Linux Flash write speed is not the same, the main reason is that the delay between the use of the minimum latency time is different. Linux is relatively large. The reasons are as follows:

There are two important time parameters in the Flash Chip Handbook:






The first is the general block write timeout, which is recorded as Time-ty, and the second is the maximum block write time-out period, recorded as Time-max.

Suppose there are two CFI nor flash chips, A's time-ty is ten, B's time-ty is 8; A, B's Time-max are all 2.

As you can see below, under Uboot, the flash write speed difference between A and B is very small. But under Linux, the Flash write time of A and B is very different. Assume that the clocks are stable.


Algorithms in Uboot:


1, the time-out period Info->buffer_write_tout:

Info->buffer_write_tout = (((1 << time-ty) * (1 << Time-max)) + 999)/1000;


A flash:time-ty = ten, Time-max = 2, calculated 5 ms

Flash:time-ty of B = 8, Time-max = 2, calculated 2 ms


2, then use Info->buffer_write_tout:


while (1) {

...

if (ready)//This flag indicates that the write instruction has been completed,

Break

if (Get_timer () > Info->buffer_write_tout) {

return err_timout;

}

Udelay (1); Use a delay of 1 us each time until the ready exit loop appears. Generally, the execution time of the write instruction does not wait for the buffer_write_tout to succeed so long, so it is very fast to jump out of the loop

}

The latency used by Uboot when writing Flash is at the US level. So users almost don't feel Flash "typical timeout for maximum size buffer Program" The effects of different time parameters.


Delay time under Linux:


1, first come to Chip->buffer_write_time

Chips[i].buffer_write_time = 1<<time-ty;


A:buffer_write_time = 1024x768 US

B:buffer_write_time = $ US


2, Linux uses buffer_write_time as a variable for the minimum delay function:


static inline void Cfi_udelay (int us) {

if (US >=) {//a buffer_write_time is 1024, using msleep delay, the time unit is MS

Msleep ((us+999)/1000);

} else {

Udelay (US); Buffer_write_time of B is 256, using Udelay delay, time unit is US

Cond_resched ();

}

}


can be seen due to a and B Flash "typical timeout for maximum size buffer Program"  Parameters are not the same. results in a large difference in the latency function used at the bottom.

This is the reason why there is a big difference in the write time of Flash under Linux.


Note:


a Flash chip instance information :


Vendor ID is 2 (AMD series)

Manufacturer ID is 0x89

Device ID is 0x7e

Device Id2 is 0x2201

CFI version is 0x3133

Chip Size: 33554687 B, 32MB

Number of Sectors the a

Sector size/One time can cache erase size: 131072 B, 128KB

Cache write Wait time: 1024x768 US

Cache write Max time: 4096 us



The above can refer to the source code of UBOOT/LINUX/OPENWRT:


Uboot


DRIVERS/MTD/CFI_FLASH.C (CFI specification flash driver)

COMMON/CMD_FLASH.C (Implementation of Uboot's upgrade command)


Linux:


DRIVERS/MTD/CHIPS/CFI_PROBE.C (CFI Specification Universal Drive Entry)

DRIVERS/MTD/CHIPS/CFI_CMDSET_0002.C (AMD spec flash driver)

ARCH/MIPS/CAVIUM-OCTEON/FLASH_SETUP.C (Octeon platform Flash driver)

DRIVERS/MTD/CMDLINEPART.C (Parse partition)

DRIVERS/MTD/MTDPART.C (System MTD Operation call Center)



OpenWrt

PACKAGE/MTD/SRC/MTD.C (source code for MTD tools)


The difference analysis of flash writing speed under Uboot and Linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.