GNUDD Logo at91sam9263ek-nor 1.00

Next: , Previous: (dir), Up: (dir)


This document explains how to boot an AT91SAM9263 Evaluation kit from NOR flash memory. You need to mount a NOR chip on the board, though, as Atmed doesn't ship one.

I used a 8MB bottom-boot-block device, as suggested on the EK schematics. Some code must be adapted if you run a different chip.

Next: , Previous: Top, Up: Top

1 The problem

The AT91SAM9263 CPU should be able to boot from NAND or SD, but as documented in the errata it can't boot from either device. So we have the obsolete DataFlash or the NOR flash, and my client chose to mount a NOR device in its production devices.

Given a bottom-boot-block device (8 sectors are 8kB wide, the rest is 64kB) I chose to allocate it in this way (NCS0 starts at 0x1000.0000):

     0x1000.0000-0x1000.2000  at91boot
     0x1000.2000-0x1000.4000  environment
     0x1000.4000-0x1001.0000  available for app. configuration
     0x1001.0000-0x1005.0000  u-boot

I modified at91boot instead of placing the copying code in u-boot itself like is done on most CPU cores for three reasons:

So I had to change both at91boot and u-boot. The patches are available in and within at91sam9263ek-nor=1.00.tar.gz.

I used ELDK-4.1 to compile everything, and I assume in this document that CROSS_COMPILE is properly set in you environment.

Next: , Previous: The problem, Up: Top

2 at91boot

At boot time, the CPU runs very slowly, so we must switch the master clock at a higher frequency before we load u-boot. This switch can't be performed from NOR flash, as the access timings to the chip are different with the two clocks.

What I used in this project is at91bootstrap-2.3 as available on To the original source you need to apply my patches:

     tar xjf at91bootstrap-2.3.tar.bz2
     cd at91bootstrap-2.3
     zcat ../NORPATCH1 | patch -p1
     make at91sam9263ek_defconfig MEMORY=norflash

You'll get a file called at91sam9263ek-norflashboot-2.3.bin in the results/ subdir. This must be written to the first sector of the flash. The last chapter explains how to write it if you have a bootable DataFlash card.

A precompiled binary can be downloaded from

Previous: at91boot, Up: at91boot

2.1 Description of the at91boot patch

I made all my changes trying not to break the other configurations, but I didn't re-check them. The patch changes the following files:

For consistency, I use norflash instead of flash as device name; also a spurious tarball target is removed.
The code now copies itself to SRAM, from _stext to _edata.
The source now calls load_norflash(), if CFG_NORGLASH
I activated the I-chache, to make the copy loop faster.
Ne filese, copied from ../dataflash and modified.
Added norflash.c
New file, it programs NCS0 timings and copies u-boot to SDRAM.
Ne file, with the prototype.

Next: , Previous: at91boot, Up: Top

3 U-Boot

For this project I used u-boot-1.1.5 modified by Atmel. I tried their 1.2.0 version as well, but it didn't see the NAND flash, so I sticked to the older one.

To build from source, you need to run the following commands (there is a reject in the Atmel patch, but you can ignore it).

     tar xjf u-boot-1.1.5.tar.bz2
     cd u-boot-1.1.5
     bzcat ../$ATPATCH | patch -p1
     zcat ../NORPATCH2 | patch -p1
     make at91sam9263ek_config

The result is u-boot.bin, that you should place at offset 0x10000 (64kB) in the NOR flash. If you boot from DataFlash in order to program the NOR flash, you need to ran a NOR-aware U-boot binary, but you can't overwrite the one that is currently running.

Therefore, you'll need a binary compiled to run at a different address. I chose 0x23e0.0000 instead of the default 0x23f0.0000.

To accomplish the task, after you compiled u-boot.bin, do the following:

     FILES="board/at91sam9263ek/ include/configs/at91sam9263ek.h"
     perl -p -i -e 's/0x23f0/0x23e0/' $FILES
     make && mv u-boot.bin u-boot-23e0.bin
     perl -p -i -e 's/0x23f0/0x23e0/' $FILES

Both binaries are also available as precopiled files in

Previous: U-Boot, Up: U-Boot

3.1 Description of the patch to u-boot

The patch file u-boot-1.1.5-atmel-1.4-norboot2.patch.gz acts on the following files:

Use of local flash.c is removed, as I use drivers/cfi_flash.c instead.
It calls hw_flash_init to set up NCS0 timings, and it doesn't reset the PHY (it's unnedded, and I have an error in the debugger it is reset).
The strings are fixes to RAM, NOR and NAND sizes are printed as probed (not hardwired), and author attribution is fixed.
The net device is initialized each time, as per sane u-boot policy. More over, an infinite while loop is broken, so ctrl-C works.
Timer management has been rewritten, it didn't work. (This is not perfect, I had no time, but at least it works good enough).
Fixed a bug when CFG_HZ is less than 1000.
I use NOR
Turn a debug print into a normal prints, so the run address is always shown
Changed to use my logo, and extract it from a text file, so it can be added by a textual patch.
My log, as bmp, compressed and uuencodes.

Previous: U-Boot, Up: Top

4 Setting up for NOR boot

In order to program the NOR flash, you can either use a JTAG debugger or boot from DataFlash, for example with the binary-only u-boot that Atmel is releasing in blatant copyright violation.

I assume here you have the three binary files in a TFTP server.

First of all, you need to set up the boot loader for network access. For example like this:

     setenv serverip
     setenv ipaddr
     setenv ethaddr 0:1:2:3:4:5

I'll assume in all of the following commands that the three variables are properly set (both when issuing commands to the blatantly-violating-copyright-binary-only-u-boot and when issuing them to the nor-aware 1.1.5 we rebult).

Initially, you boot from DataFlash and run u-boot at address 0x23f0.0000. You therefore need to run the new one at a different address:

     tftpboot 23e00000 uboot-23e0.bin
     go 23e00000

At this point, you havea a NOR-aware boot loader running and you can write to NOR flash:

     tftpboot 23800000 at91sam9263ek-norflashboot-2.3.bin
     protect off   10000000 10001fff
     erase         10000000 10001fff
     cp.b 23800000 10000000 00002000
     tftpboot 23800000 u-boot.bin
     protect off   10010000 1004ffff
     erase         10010000 1004ffff
     cp.b 23800000 10010000    40000

At this point, you can reboot with the BMS jumper in place, and enjoy a completely-freed system booting from NOR. You can also saveenv if you wish, keeping in mind the address choices outlined at the beginning of this document.

Accessing the NOR chip from GNU/Linux is easy, as you just need to configure the physmap driver with the proper addresses for NCS0 memory.