ATMEL官方的AT91BootStrap不支持NorFlash,
如果需要支持NorFlash就要自己动手了
在 Bootstrap-v1.15/board/at91sam9260ek 目录添加 norflash文件夹,
在该目录下面添加 at91sam9260ek.h 文件, 文件内容:
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support - ROUSSET -
* ----------------------------------------------------------------------------
* Copyright (c) 2006, Atmel Corporation* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer below in the documentation and/or
* other materials provided with the distribution.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
* File Name : at91sam9260ek.h
* Object :
* Creation : NLe Sep 28th 2006
*-----------------------------------------------------------------------------
*/
#ifndef _AT91SAM9260EK_H
#define _AT91SAM9260EK_H/* ******************************************************************* */
/* PMC Settings */
/* */
/* The main oscillator is enabled as soon as possible in the c_startup */
/* and MCK is switched on the main oscillator. */
/* PLL initialization is done later in the hw_init() function */
/* ******************************************************************* */
#define MASTER_CLOCK (198656000/2)
#define PLL_LOCK_TIMEOUT 1000000#define PLLA_SETTINGS 0x2060BF09
#define PLLB_SETTINGS 0x10483F0E/* Switch MCK on PLLA output PCK = PLLA = 2 * MCK */
#define MCKR_SETTINGS (AT91C_PMC_CSS_PLLA_CLK | AT91C_PMC_PRES_CLK | AT91C_PMC_MDIV_2)
#define MCKR_CSS_SETTINGS (AT91C_PMC_CSS_PLLA_CLK | MCKR_SETTINGS)/* ******************************************************************* */
/* BootStrap Settings */
/* */
/* ******************************************************************* */
#define IMG_ADDRESS 0x10004000 /* Image Address in NorFlash */
#define IMG_SIZE 0x30000 /* Image Size in NorFlash */#define MACH_TYPE 0x44B /* AT91SAM9260-EK */
#define JUMP_ADDR 0x23F00000 /* Final Jump Address *//* ******************************************************************* */
/* Application Settings */
/* ******************************************************************* */
#define CFG_DEBUG#define CFG_SDRAM
#define CFG_HW_INIT#undef CFG_DATAFLASH
#undef CFG_NANDFLASH#ifndef CFG_NORFLASH
#define CFG_NORFLASH
#endif#endif /* _AT91SAM9260EK_H */
添加Makefile文件
# TODO: set this appropriately for your local toolchain
ifndef ERASE_FCT
ERASE_FCT=rm -f
endif
ifndef CROSS_COMPILE
CROSS_COMPILE=arm-elf-
endifTOOLCHAIN=gcc
BOOTSTRAP_PATH=../../..
# NorFlashBoot Configuration for AT91SAM9260EK
# Target name (case sensitive!!!)
TARGET=AT91SAM9260
# Board name (case sensitive!!!)
BOARD=at91sam9260ek
# Link Address and Top_of_Memory
LINK_ADDR=0x200000
TOP_OF_MEMORY=0x301000
# Name of current directory
PROJECT=norflashifndef BOOT_NAME
BOOT_NAME=$(PROJECT)_$(BOARD)
endifINCL=./$(BOOTSTRAP_PATH)/board/$(BOARD)/$(PROJECT)
ifeq ($(TOOLCHAIN), gcc)
AS=$(CROSS_COMPILE)gcc
CC=$(CROSS_COMPILE)gcc
LD=$(CROSS_COMPILE)gcc
NM= $(CROSS_COMPILE)nm
SIZE=$(CROSS_COMPILE)size
OBJCOPY=$(CROSS_COMPILE)objcopy
OBJDUMP=$(CROSS_COMPILE)objdump
CCFLAGS=-g -mcpu=arm926ej-s -Os -Wall -D$(TARGET) -I$(INCL)
ASFLAGS=-g -mcpu=arm926ej-s -c -Os -Wall -D$(TARGET) -I$(INCL) -DTOP_OF_MEM=$(TOP_OF_MEMORY)# Linker flags.
# -Wl,...: tell GCC to pass this to linker.
# -Map: create map file
# --cref: add cross reference to map file
LDFLAGS+=-nostartfiles -nostdlib -Wl,-Map=$(BOOT_NAME).map,--cref
LDFLAGS+=-T $(BOOTSTRAP_PATH)/elf32-littlearm.lds -Ttext $(LINK_ADDR)
OBJS=crt0_gnu.oendif
OBJS+=/
$(BOARD).o /
main.o /
gpio.o /
pmc.o /
debug.o /
sdramc.o /
norflash.o /
_udivsi3.o /
_umodsi3.o /
div0.o /
udiv.o /
string.orebuild: clean all
all: $(BOOT_NAME)
ifeq ($(TOOLCHAIN), gcc)
$(BOOT_NAME): $(OBJS)
$(LD) $(LDFLAGS) -n -o $(BOOT_NAME).elf $(OBJS)
$(OBJCOPY) --strip-debug --strip-unneeded $(BOOT_NAME).elf -O binary $(BOOT_NAME).bin
endif$(BOARD).o: $(BOOTSTRAP_PATH)/board/$(BOARD)/$(BOARD).c
$(CC) -c $(CCFLAGS) $(BOOTSTRAP_PATH)/board/$(BOARD)/$(BOARD).c -o $(BOARD).omain.o: $(BOOTSTRAP_PATH)/main.c
$(CC) -c $(CCFLAGS) $(BOOTSTRAP_PATH)/main.c -o main.ogpio.o: $(BOOTSTRAP_PATH)/driver/gpio.c
$(CC) -c $(CCFLAGS) $(BOOTSTRAP_PATH)/driver/gpio.c -o gpio.opmc.o: $(BOOTSTRAP_PATH)/driver/pmc.c
$(CC) -c $(CCFLAGS) $(BOOTSTRAP_PATH)/driver/pmc.c -o pmc.odebug.o: $(BOOTSTRAP_PATH)/driver/debug.c
$(CC) -c $(CCFLAGS) $(BOOTSTRAP_PATH)/driver/debug.c -o debug.osdramc.o: $(BOOTSTRAP_PATH)/driver/sdramc.c
$(CC) -c $(CCFLAGS) $(BOOTSTRAP_PATH)/driver/sdramc.c -o sdramc.onorflash.o: $(BOOTSTRAP_PATH)/driver/norflash.c
$(CC) -c $(CCFLAGS) $(BOOTSTRAP_PATH)/driver/norflash.c -o norflash.ocrt0_gnu.o: $(BOOTSTRAP_PATH)/crt0_gnu.S
$(AS) $(ASFLAGS) $(BOOTSTRAP_PATH)/crt0_gnu.S -o crt0_gnu.odiv0.o: $(BOOTSTRAP_PATH)/lib/div0.c
$(CC) -c $(CCFLAGS) $(BOOTSTRAP_PATH)/lib/div0.c -o div0.ostring.o: $(BOOTSTRAP_PATH)/lib/string.c
$(CC) -c $(CCFLAGS) $(BOOTSTRAP_PATH)/lib/string.c -o string.oudiv.o: $(BOOTSTRAP_PATH)/lib/udiv.c
$(CC) -c $(CCFLAGS) $(BOOTSTRAP_PATH)/lib/udiv.c -o udiv.o_udivsi3.o: $(BOOTSTRAP_PATH)/lib/_udivsi3.S
$(AS) $(ASFLAGS) $(BOOTSTRAP_PATH)/lib/_udivsi3.S -o _udivsi3.o_umodsi3.o: $(BOOTSTRAP_PATH)/lib/_umodsi3.S
$(AS) $(ASFLAGS) $(BOOTSTRAP_PATH)/lib/_umodsi3.S -o _umodsi3.oclean:
$(ERASE_FCT) *.o *.bin *.elf *.map
修改 Bootstrap-v1.15/board/at91sam9260ek/at91sam9260ek.c 文件, 添加:
#ifdef CFG_NORFLASH
#include "../../include/norflash.h"
#endif
#ifdef CFG_NORFLASH
void norflash_hw_init(void)
{
/* Configure CS0 */
writel(AT91C_FLASH_NWE_SETUP | /
AT91C_FLASH_NCS_WR_SETUP | /
AT91C_FLASH_NRD_SETUP | /
AT91C_FLASH_NCS_RD_SETUP, AT91C_BASE_SMC + SMC_SETUP0);
writel(AT91C_FLASH_NWE_PULSE | /
AT91C_FLASH_NCS_WR_PULSE | /
AT91C_FLASH_NRD_PULSE | /
AT91C_FLASH_NCS_RD_PULSE, AT91C_BASE_SMC + SMC_PULSE0);
writel(AT91C_FLASH_NWE_CYCLE | /
AT91C_FLASH_NRD_CYCLE, AT91C_BASE_SMC + SMC_CYCLE0);
writel(AT91C_SMC_READMODE | /
AT91C_SMC_WRITEMODE | /
AT91C_SMC_NWAITM_NWAIT_DISABLE | /
AT91C_SMC_BAT_BYTE_WRITE | /
AT91C_SMC_DBW_WIDTH_SIXTEEN_BITS | /
(AT91C_SMC_TDF & (1 << 16)), AT91C_BASE_SMC + SMC_CTRL0);
}
#endif
在 Bootstrap-v1.15/board/at91sam9260ek/norflash 目录执行 make命令会生成
我们需要的 norflash_at91sam9260ek.bin 文件