文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>How to add support for flash devices

How to add support for flash devices

时间:2007-02-09  来源:marsky

How to add support for flash devices

--------------------------------------------------------------------------------

Description
This document describes how to add support for new flash devices.
Prerequisites
Before you read this document you need the following:

An elinux tree
CRIS compiler tools
A hardware with the flash you want to support
Refer to How to Install the Developer Board Software for instructions how to install the developer board software and the GCC CRIS compiler.

Theory
No special software is required to read a flash but a driver is required to erase and write flashes. Writing is typically performed by issuing writes to special addresses that puts the flash in "writing" mode and then write the data. There are basically two types of flash devices: AMD (and compatibles) and Intel. Both types can be connected to ETRAX by changing some resistors on the PCB. The flash programmer in elinux currently only support AMD flashes.

Most AMD flashes have so called boot blocks. The boot blocks are smaller than the other blocks in the flash and are stored in the top or in the bottom of the flash. Both variants are supported by elinux.

ETRAX supports 2 flashes where each flash can be 16 or 32 bit wide (a 32 bit flash is typically achieved by connecting two 16 bit flashes in parallell). Elinux only supports 16 bit flashes.

Process
This is an example on how to add support for AM29LV320DT (32 MBit) with top boot blocks. If you want to add support for non AMD compatible flashes more work is needed.

Boot loader
The boot loader is used when loading the code with e.g. boot_elinux

Look up the device id for the flash in the datasheet for the flash (for AM29LV320DT it is 0x22F6)
Open tools/e100boot/cbl/flash.c in your elinux tree
Add AM29LV320DT = 0x22F6 in the enum containing AMD device IDs. If you are adding a flash from a manufacturer currently not listed you need to add a new enum similar to the others.
Add AM29LV320DT in the switch in the flash_probe function (values for the struct members can be found in data sheet, refer to source code below). If you are adding a flash from a manufacturer currently not listed you need to add the manufacturer code in the list above the switch. Note that some flashes from different manufactures uses the same ID.
Kernel flash driver
The kernel flash driver is used when writing to the flash file system and when upgrading the firmware with e.g. FTP.

Open elinux/drivers/block/flash.c in your elinux tree
Perform steps 3-4 in boot loader section above
Building
Now you are ready to build an image with support for your flash. But first you may want to edit your prodspec to take advantage of the new flash:

1. Run "make" in tools/e100boot/cbl
2. Run "make install" as root
3. Run "make clean; make dep ; make ; make zImage" in elinux directory
4. Open the file products/tech/devboard/prodspec

At the bottom of prodspec there is a line similar to:

exec HWID=400 buildsrc packages/productimages/2MB

Change this into:

exec HWID=400 buildsrc packages/productimages/4MB

This image gives you 2MB for jffs and 2MB for kernel and rescue. If you want some other configuration you can create your own directory under packages/productimages.

Note: You can't have flash partitions that cross flash boundaries (e.g. if you have two 2 MB flashes a 1 MB partition can't start at offset 1.5 MB in the first flash).

5. mkprod -c -r
6. Put your Etrax hardware in network boot mode
7. boot_elinux -f
8. Your new code is loaded!

Source Code
The enum listing the AMD flashes support looks like this after adding AML29LV320DT:

enum { ManufacturerAMD = 0x01,
AM29F800BB = 0x2258,
AM29F800BT = 0x22D6,
AM29LV800BB = 0x225B,
AM29LV800BT = 0x22DA,
AM29LV160BT = 0x22C4,
AM29LV320DT = 0x22F6
};
The following code shows how to fill in the struct members for AM29LV320DT:

case AM29LV320DT:
safe_printk("Flash: 32Mb TB.\n");
flash->flashSize = 0x00400000;
flash->bootsector = (unsigned char *)flash->flashStart +
flash->flashSize - flash->flashSector;
flash->bootsectorsize[0] = 0x2000;
flash->bootsectorsize[1] = 0x2000;
flash->bootsectorsize[2] = 0x2000;
flash->bootsectorsize[3] = 0x2000;
flash->bootsectorsize[4] = 0x2000;
flash->bootsectorsize[5] = 0x2000;
flash->bootsectorsize[6] = 0x2000;
flash->bootsectorsize[7] = 0x2000;
break;
Notes
Adding support for other flashes than AMD requires more work.

Most large AMD flashes (and compatibles) have support for CFI which is a standard for reporting information about the flash (i.e. you can retrieve all the figures about flash size and sector sizes). CFI support will soon be included in the elinux kernel.

相关阅读 更多 +
排行榜 更多 +
manwa2免费漫画官方版下载

manwa2免费漫画官方版下载

趣味娱乐 下载
AccuBattery汉化免费版下载

AccuBattery汉化免费版下载

生活实用 下载
甜瓜游乐场2官方正版下载

甜瓜游乐场2官方正版下载

模拟经营 下载