...your main source of everything AVR32 Linux

Navigation

Adding support for a new board

This guide attempts to explain all the modifications needed in order to run u-boot and Linux on a custom or otherwise unsupported board. Only two components need to be modified: The u-boot bootloader and the Linux kernel. Once running, the Linux kernel is responsible for abstracting away all differences between boards, so existing applications will run unmodified. If your board will be part of a new product, you probably want to customize the applications as well in order to optimize memory- and flash-usage, but this is outside the scope of this guide.

This guide also assumes that all the drivers you need have already been written and are present in your copy of the u-boot source code.

Customizing u-boot

Since u-boot already supports more than 200 boards and more than 300 different configurations, adding support for a new board to u-boot is relatively painless. You basically need to add three things:
  • A subdirectory under boards or boards/vendor containing board-specific code
  • A header file for each configuration (usually just one) under include/configs
  • A target for each configuration in the top-level Makefile

Implementing board-specific code

The avr32 initialization code expects the following two functions to be defined by the board-specific code. Normally, these should be in a single .c file with the same name as your board:
board_init_memories
Initialize any on-board memory. If you have SDRAM on your board, this is where you should initialize it. The low-level code for doing this is common for all AVR32 AP CPUs, but since the timing- and addressing parameters depend on which particular SDRAM chip is present on the board, you need to provide that information here. See below for details.
board_init_info
Initialize board-specific members, e.g. MII addresses of any ethernet PHYs, in the bd_info structure, defined in include/asm-avr32/u-boot.h. A pointer to this structure is available as =gd->bd assuming you've declared the global data pointer, gd, by putting DECLARE_GLOBAL_DATA_PTR; somewhere near the beginning of the file

If you need any board-specific drivers, they should be put in this directory. If there's a possibility that more than one board can use the same driver, however, it should probably be put under drivers/.

SDRAM parameters

The CPU-specific function sdram_init() takes a pointer to struct sdram_info. It's the responsibility of the board-specific code to fill in this struct with the correct information based on the particular type of SDRAM present on the board.

To get these numbers right, you need to dig up the data sheet for your SDRAM chip. The members in the sdram_info should match up nicely with the numbers in the data sheet, but note that while all the sdram_info timings are specified as a number of bus cycles, the data sheet usually specify some of them in nanoseconds.

phys_addr
The physical address where the SDRAM is mapped. On the AT32AP7000, this is always 0x10000000.
row_bits, col_bits, bank_bits
Specify how to divide the physical address into row address, column address and bank, respectively. The total size of the SDRAM address should be (1 << (row_bits + col_bits + bank_bits + 2)) for 32-bit data bus width, or half that number for 16-bit data bus width.
cas, twr, trc, trp, trcd, tras, txsr
Timing parameters. These have to be calculated based on the values in the data sheet for the SDRAM chip.

Makefile

The Makefile is pretty much the same for all boards:
#
# (C) Copyright 2001-2006
# Wolfgang Denk, DENX Software Engineering, [email protected].
#
# Copyright (C)  
#
# See file CREDITS for list of people who contributed to this
# project. 
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# 
# 

include $(TOPDIR)/config.mk

LIB   := $(obj)lib$(BOARD).a

COBJS   := $(BOARD).o
SOBJS   :=

SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
OBJS   := $(addprefix $(obj),$(SOBJS) $(COBJS))

$(LIB): $(obj).depend $(OBJS)
   $(AR) $(ARFLAGS) $@ $(OBJS)

#########################################################################

# defines $(obj).depend target
include $(SRCTREE)/rules.mk

sinclude $(obj).depend

#########################################################################

If you need any additional C or assembly source files, they should be appended to the COBJS and SOBJS variables, respectively, replacing their suffix with ".o".

r2 - 26 Nov 2006 - 20:14 - HaavardSkinnemoen
Copyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Linux® is the registered trademark of Linus Torvalds in the U.S. and other countries.
Atmel®, AVR® and others are registered trademarks or trademarks of Atmel Corporation or its subsidiaries.
All other trademarks are the property of their respective owners.
Powered by Wed, 08 Feb 2006 build 8740
Syndicate this site