AM35x-NOR-Flash-Support-ApplicationNote

'''  Content is no longer maintained and is being kept for reference only! '''



Important

Please note that Currently NOR boot mode is not supported in PSP releases.

Overview
'''  Content is no longer maintained and is being kept for reference only! '''

This wiki page provides information on using NOR Flash (PC28F640P30B85) support available on Logic PD's AM3517 Application board. This document talks about how to add support for NOR Flash (PC28F640P30B85) in X-loader (Primary Boot-loader), U-Boot (secondary boot-loader), Linux Kernel and will demonstrate NOR Flash boot mode.

NOTE: Since NOR is XIP we do not need to have two stage booting process, ROM code can directly jump to U-boot start address in NOR Flash. But to keep consistency with other boot mode options (NAND, MMC, etc...) we are following up two stage process here.

Background Information

 * Since NOR Flash is XIP not special configuration other than GPMC initialization required in X-Loader. But natively X-Loader is designed (or rather required) considering NAND and MMC boot mode.
 * U-Boot does support and have common interfaces for CFI Complaint flash devices. Also the NOR Flash (PC28F640P30B85) available on AM3517 Application board is CFI Complaint.
 * User can choose the boot medium (either NOR or NAND Flash) using user configurable switch S11. Below are the supported options through S11,



Note: Please note that NOR Flash is located on Application board and requires hardware modification to get NOR boot mode working. Please refer to section "EVM configuration" for more details.


 * EVM Configuration

In NAND Boot mode :- Set S7 switch position to

1    2     3     4     5               -|-|-|-|-                off   off   off   off   off

nCS0 => NAND Flash device (Boot device)

nCS2 => NOR Flash device

In NOR Flash boot mode :- Set S7 switch position to

1    2     3     4     5               -|-|-|-|-                 on   off   off   off   off

nCS0 => NOR Flash device (Boot device)

nCS2 => NAND Flash device

EVM Board modification (NOR Boot mode) -


 * From the baseboard remove R235 resistor (located underneath S7).
 * And configure switch S7 in NOR Flash boot mode (as described above)

NOTE: Please note that, once you remove R235 resistor from the baseboard, you will not be able to boot from NAND without Application board. The GPMC_nCS0 is now routed through Application board.

NOR Flash Layout
As mentioned above, there are 2 possible options here,


 * Over nCS0, where it will work as a boot medium.
 * Over nCS2, as a data flash

The NOR part on the EVM has been configured in the following manner. Please note that the base address is dependent on the boot device, so below layout shows the offset and not actual base address.

 Note If NOR Flash is detected on CS0, the address would be 0x00000000 and if NOR Flash is detected on CS2, the address would be 0x08000000.

++-&gt;0x00000000-&gt; X-loader start |           |  |            |--&gt;0x0001FFFF-&gt; X-loader end |           |--&gt;0x00020000-&gt; U-Boot start |           |  |            |  |            |--&gt;0x000BFFFF-&gt; U-Boot end |           |--&gt;0x000C0000-&gt; ENV start |           |  |            |--&gt;0x000FFFFF-&gt; ENV end |           |--&gt;0x00100000-&gt; Linux Kernel start |           |  |            |  |            |  |            |--&gt;0x004FFFFF-&gt; Linux Kernel end |           |--&gt;0x00500000-&gt; Filesystem start |           |  |            |  |            |  |            |  |            |  |            |  |            |  |            |  ++--&gt;0x007FFFFF-&gt; Filesystem end

Adding support in X-Loader
Patch:

Adding support in U-Boot
Patch:

Adding support in Linux Kernel
Nor Flash hook up -

Patch:

NOTE: Please note that above patch disabled the NAND initialization in board init sequence.

Defconfig changes required to enable NOR Flash -

Patch:

Adding support in X-Loader, U-Boot & Kernel(on top of PSP04.02.00.06 release)
Please note that support for NOR Flash is disabled in U-boot configuration, whereas in X-loader & Linux it is enabled by default.

Adding support in U-Boot
Since NOR Flash is mounted on Application board and natively u-boot doesn't support run-time detection and configuration of Flash devices, the NOR Flash support is disabled in U-boot. Please enable.

Patch:

Support in U-Boot and Kernel (in AMSDK 05.03.02 and later)
In this version the changes for support are already integrated in U-Boot and the Kernel. There is no X-Loader for any bootmode and U-Boot is run directly from NOR without need of a previous stage.

Building U-Boot
Please refer back to the AMSDK u-boot User's Guide for general build information. In this case you need to build for am3517_evm_norflash and boot the resulting MLO and u-boot.img from a non-NOR media and also build for am3517_evm_norflash_boot and write the resulting u-boot.bin to NOR.

Building the Linux Kernel
Start building the kernel with the am3517_evm_nor_defconfig config file as a reference.

Usage
This section talks about default partitions defined and how user can flash the images to respective partition in NOR flash -

Default Partition configiration
To keep aligned with other flash devices supported with OMAP family of devices like, NAND or OneNAND we have defined similar partition table for NOR Flash. Please note that, first 4 blocks are of 32K and rest all blocks are 128K.

Prior to AMSDK 05.03.02.00
X-Loader     :-     0x00000000 - 0x00020000 (4 blocks = 128K) U-Boot       :-     0x00020000 - 0x000C0000 (5 blocks = 864K) U-Boot Env   :-     0x000C0000 - 0x00100000 (2 blocks = 1M) Kernel       :-     0x00100000 - 0x00500000 (32 blocks = 4MB) Data/FS      :-     0x00500000 - 0x07FFFFFF (Rest all)

AMSDK 05.03.02.00 and later
U-Boot       :-     0x00000000 - 0x00080000 (512K) U-Boot Env   :-     0x00080000 - 0x000A0000 (128K) Kernel       :-     0x000A0000 - 0x003A0000 (3MB) Data/FS      :-     0x003A0000 - 0x07FFFFFF (Rest all)

Flashing Instruction
This section describes how to flash x-load.bin and u-boot.bin to NOR flash, please note that flashing is achieved from another uboot image, booted up from MMC/NAND Flash.

X-Loader
AM3517_EVM # AM3517_EVM # protect off 0x08000000 +0x20000 Un-Protect Flash Bank # 1 .... done AM3517_EVM # erase 0x08000000 +0x20000 Erase Flash Bank # 1 .... done AM3517_EVM # mw.b 0x80000000 0xff 0x20000 AM3517_EVM # loadb 80000000 AM3517_EVM # cp.b 0x80000000 0x08000000 0x20000 Copy to Flash... done AM3517_EVM #
 * 1) Ready for binary (kermit) download to 0x80000000 at 115200 bps...
 * 2) Total Size      = 0x000042b0 = 17072 Bytes
 * 3) Start Addr      = 0x80000000

U-Boot
AM3517_EVM # AM3517_EVM # protect off 0x08020000 +0xA0000 Un-Protect Flash Bank # 1 ...... done AM3517_EVM # erase 0x08020000 +0xA0000 Erase Flash Bank # 1 ...... done AM3517_EVM # mw.b 0x80000000 0xFF 0xA0000 AM3517_EVM # loadb 0x80000000 AM3517_EVM # cp.b 0x80000000 0x08020000 0xA0000 Copy to Flash... done
 * 1) Ready for binary (kermit) download to 0x80000000 at 115200 bps...
 * 2) Total Size      = 0x00039128 = 233768 Bytes
 * 3) Start Addr      = 0x80000000

U-Boot
AM3517_EVM # AM3517_EVM # protect off 0x08000000 +0xA0000 Un-Protect Flash Bank # 1 .... done AM3517_EVM # erase 0x08000000 +0xA0000 Erase Flash Bank # 1 .... done AM3517_EVM # mw.b 0x80000000 0xff 0xA0000 AM3517_EVM # loadb 80000000 AM3517_EVM # cp.b 0x80000000 0x08000000 0xA0000 Copy to Flash... done
 * 1) Ready for binary (kermit) download to 0x80000000 at 115200 bps...
 * 2) Total Size      = 0x00039128 = 233768 Bytes
 * 3) Start Addr      = 0x80000000

NOTE: Please note that early revision of Application board doesn't work with NOR flash boot mode due to HW issue. The NOR boot mode has been validated against >=Rev4 revision of Application board.

NOTE: Please untar the file to access the patch, tar file has been attached since Wiki page doesn't allow to attach .patch extension files.

NOTE: Please note that the above patches have not went under regression test, so likely to have some issues. We are working on this and will update this page once we are done with your testing. By default, NOR Flash goes to nCS2 chip select and will be able to use Data Flash.