From: 吴身国 <ipv06@163.com>
To: "ecos-discuss" <ecos-discuss@sources.redhat.com>
Subject: [ECOS] flash build problem
Date: Thu, 04 Aug 2005 00:25:00 -0000 [thread overview]
Message-ID: <20050804002500.O_QmkYohmPpbML173HwMhq1F0ngmbD0C_yTFqGp-ykI@z> (raw)
[-- Attachment #1: Type: text/plain, Size: 437 bytes --]
Dear Adrew:
I am porting eCos to a new platform EasyARM2200.
This board is made up of:
CPU: phyllips LPC2210 *1
FLASH: sst 1M*16bit 39VF160 *1
SRAM: issi 256K*16bit *1
and other current parts.
I ported my platform from mcb2100 and aim711 in eCos repository. The aim711 is made of the template of flash part. But the problem occurs when I ld flash. I created or modified some file that is attached.
Could you help me?
Shenguo Wu
[-- Attachment #2: zlg2200_flash.c --]
[-- Type: application/octet-stream, Size: 2783 bytes --]
//==========================================================================
//
// zlg2200_flash.c
//
// Flash programming for Atmel device on ZLG EasyARM2200 board
//
//==========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos 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 or (at your option) any later version.
//
// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//==========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s):
// Contributors: jskov, nickg, tkoeller
// Date: 2005-07-29
// Purpose:
// Description:
//
//####DESCRIPTIONEND####
//
//==========================================================================
// The EasyARM2200 is equipped with one single SST 39VF160 flash chip.
#define CYGPKG_DEVS_FLASH_SST_39VF160
#define CYGNUM_FLASH_INTERLEAVE 1
#define CYGNUM_FLASH_SERIES 1
#define CYGNUM_FLASH_BASE 0x80000000
#ifdef CYGINT_DEVS_FLASH_SST_39VFXXX_REQUIRED
#include "cyg/io/flash_sst_39vfxxx.inl"
#endif
// ------------------------------------------------------------------------
// EOF zlg2200_flash.c
[-- Attachment #3: builderr.txt --]
[-- Type: application/octet-stream, Size: 1399 bytes --]
/opt/cvs/ecos/packages/redboot/current/src/load.c:738: undefined reference to `flash_code_overlaps'
/opt/cvs/ecos/packages/redboot/current/src/load.c:580: undefined reference to `flash_code_overlaps'
/opt/cvs/ecos/packages/redboot/current/src/load.c:532: undefined reference to `flash_code_overlaps'
/root/lx/zlg/zlg_install/lib/libtarget.a(io_flash_flash.o): In function `flash_errmsg':
/opt/cvs/ecos/packages/io/flash/current/src/flash.c:256: undefined reference to `flash_hwr_init'
/root/lx/zlg/zlg_install/lib/libtarget.a(io_flash_flash.o): In function `flash_program':
make[1]: Leaving directory `/root/lx/zlg/zlg_build/redboot/current'
/opt/cvs/ecos/packages/io/flash/current/src/flash.c:291: undefined reference to `flash_hwr_map_error'
make: Leaving directory `/root/lx/zlg/zlg_build'
/opt/cvs/ecos/packages/io/flash/current/src/flash.c:293: undefined reference to `flash_erase_block'
/root/lx/zlg/zlg_install/lib/libtarget.a(io_flash_flash.o): In function `flash_errmsg':
/opt/cvs/ecos/packages/io/flash/current/src/flash.c:557: undefined reference to `flash_hwr_map_error'
/root/lx/zlg/zlg_install/lib/libtarget.a(io_flash_flash.o): In function `flash_program':
/opt/cvs/ecos/packages/io/flash/current/src/flash.c:293: undefined reference to `flash_program_buf'
collect2: ld returned 1 exit status
make[1]: *** [/root/lx/zlg/zlg_install/bin/redboot.elf] Error 1
make: *** [build] Error 2
[-- Attachment #4: flash_sst_39vfxxx.inl --]
[-- Type: application/octet-stream, Size: 12611 bytes --]
#ifndef CYGONCE_DEVS_FLASH_SST_39VFXXX_INL
#define CYGONCE_DEVS_FLASH_SST_39VFXXX_INL
//==========================================================================
//
// flash_sst_39vfxxx.inl
//
// SST 39VFxxx series flash driver
//
//==========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos 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 or (at your option) any later version.
//
// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//==========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): gthomas
// Contributors: gthomas, jskov, rcassebohm
// Date: 2001-02-21
// Purpose:
// Description:
//
// Notes: FLASH_P2V is not properly used.
// Needs locking.
//####DESCRIPTIONEND####
//
//==========================================================================
#include <pkgconf/hal.h>
#include <cyg/hal/hal_arch.h>
#include <cyg/hal/hal_cache.h>
#include CYGHWR_MEMORY_LAYOUT_H
#define _FLASH_PRIVATE_
#include <cyg/io/flash.h>
//----------------------------------------------------------------------------
// Common device details.
#define FLASH_Read_ID FLASHWORD( 0x90 )
#define FLASH_Read_ID_Exit FLASHWORD( 0xF0 )
#define FLASH_Reset FLASHWORD( 0xFF )
#define FLASH_Program FLASHWORD( 0xA0 )
#define FLASH_Block_Erase FLASHWORD( 0x30 )
#define FLASH_Data FLASHWORD( 0x80 ) // Data complement
#define FLASH_Busy FLASHWORD( 0x40 ) // "Toggle" bit
#define FLASH_Err FLASHWORD( 0x20 )
#define FLASH_Sector_Erase_Timer FLASHWORD( 0x08 )
#define FLASH_Setup_Addr1 (0x5555)
#define FLASH_Setup_Addr2 (0x2AAA)
#define FLASH_Setup_Code1 FLASHWORD( 0xAA )
#define FLASH_Setup_Code2 FLASHWORD( 0x55 )
#define FLASH_Setup_Erase FLASHWORD( 0x80 )
// Platform code must define the below
// #define CYGNUM_FLASH_INTERLEAVE : Number of interleaved devices (in parallel)
// #define CYGNUM_FLASH_SERIES : Number of devices in series
// #define CYGNUM_FLASH_BASE : Address of first device
// And select one of the below device variants
#ifdef CYGPKG_DEVS_FLASH_SST_39VF080
# define FLASH_BLOCK_SIZE (0x1000*CYGNUM_FLASH_INTERLEAVE)
# define FLASH_NUM_REGIONS (256)
# define CYGNUM_FLASH_BASE_MASK (0xFFF00000u) // 1024kB devices
# define CYGNUM_FLASH_WIDTH (8)
# define CYGNUM_FLASH_BLANK (1)
# define CYGNUM_FLASH_ID_MANUFACTURER FLASHWORD(0xBF)
# define CYGNUM_FLASH_ID_DEVICE FLASHWORD(0xD8)
#endif
#ifdef CYGPKG_DEVS_FLASH_SST_39VF016
# define FLASH_BLOCK_SIZE (0x1000*CYGNUM_FLASH_INTERLEAVE)
# define FLASH_NUM_REGIONS (512)
# define CYGNUM_FLASH_BASE_MASK (0xFFE00000u) // 2048kB devices
# define CYGNUM_FLASH_WIDTH (8)
# define CYGNUM_FLASH_BLANK (1)
# define CYGNUM_FLASH_ID_MANUFACTURER FLASHWORD(0xBF)
# define CYGNUM_FLASH_ID_DEVICE FLASHWORD(0xD9)
#endif
#ifdef CYGPKG_DEVS_FLASH_SST_39VF160
#define FLASH_BLOCK_SIZE (0x1000*CYGNUM_FLASH_INTERLEAVE)
#define FLASH_NUM_REGIONS (0x100000/FLASH_BLOCK_SIZE)
#define CYGNUM_FLASH_BASE_MASK (0xFFF000000u) //1024KB devices
#define CYGNUM_FLASH_WIDTH (16)
#define CYGNUM_FLASH_BLANK (1)
#define CYGNUM_FLASH_ID_MANUFACTURER FLASHWORD(0x00BF)
#define CYGNUM_FLASH_ID_DEVICE FLASHWORD(0x2782)
#endif
#ifdef CYGPKG_DEVS_FLASH_SST_39VF400
# define FLASH_BLOCK_SIZE (0x1000*CYGNUM_FLASH_INTERLEAVE)
# define FLASH_NUM_REGIONS (0x80000/FLASH_BLOCK_SIZE)
# define CYGNUM_FLASH_BASE_MASK (0xFFF80000u) // 512kB devices
# define CYGNUM_FLASH_WIDTH (16)
# define CYGNUM_FLASH_BLANK (1)
# define CYGNUM_FLASH_ID_MANUFACTURER FLASHWORD(0x00BF)
# define CYGNUM_FLASH_ID_DEVICE FLASHWORD(0x2780)
#endif
#define FLASH_DEVICE_SIZE (FLASH_BLOCK_SIZE*FLASH_NUM_REGIONS)
#define CYGNUM_FLASH_DEVICES (CYGNUM_FLASH_INTERLEAVE*CYGNUM_FLASH_SERIES)
//----------------------------------------------------------------------------
// Now that device properties are defined, include magic for defining
// accessor type and constants.
#include <cyg/io/flash_dev.h>
//----------------------------------------------------------------------------
// Functions that put the flash device into non-read mode must reside
// in RAM.
void flash_query(void* data) __attribute__ ((section (".2ram.flash_query")));
int flash_erase_block(void* block, unsigned int size)
__attribute__ ((section (".2ram.flash_erase_block")));
int flash_program_buf(void* addr, void* data, int len)
__attribute__ ((section (".2ram.flash_program_buf")));
//----------------------------------------------------------------------------
// Initialize driver details
int
flash_hwr_init(void)
{
flash_data_t id[2];
flash_dev_query(id);
// Check that flash_id data is matching the one the driver was
// configured for.
if (id[0] != CYGNUM_FLASH_ID_MANUFACTURER
|| id[1] != CYGNUM_FLASH_ID_DEVICE)
return FLASH_ERR_DRV_WRONG_PART;
// Hard wired for now
flash_info.block_size = FLASH_BLOCK_SIZE;
flash_info.blocks = FLASH_NUM_REGIONS;
flash_info.start = (void *)CYGNUM_FLASH_BASE;
flash_info.end = (void *)(CYGNUM_FLASH_BASE+ (FLASH_NUM_REGIONS * FLASH_BLOCK_SIZE * CYGNUM_FLASH_SERIES));
return FLASH_ERR_OK;
}
//----------------------------------------------------------------------------
// Map a hardware status to a package error
int
flash_hwr_map_error(int e)
{
return e;
}
//----------------------------------------------------------------------------
// See if a range of FLASH addresses overlaps currently running code
bool
flash_code_overlaps(void *start, void *end)
{
extern unsigned char _stext[], _etext[];
return ((((unsigned long)&_stext >= (unsigned long)start) &&
((unsigned long)&_stext < (unsigned long)end)) ||
(((unsigned long)&_etext >= (unsigned long)start) &&
((unsigned long)&_etext < (unsigned long)end)));
}
//----------------------------------------------------------------------------
// Flash Query
//
// Only reads the manufacturer and part number codes for the first
// device(s) in series. It is assumed that any devices in series
// will be of the same type.
void
flash_query(void* data)
{
volatile flash_data_t *ROM;
flash_data_t* id = (flash_data_t*) data;
int i;
ROM = (volatile flash_data_t*) CYGNUM_FLASH_BASE;
ROM[FLASH_Setup_Addr1] = FLASH_Setup_Code1;
ROM[FLASH_Setup_Addr2] = FLASH_Setup_Code2;
ROM[FLASH_Setup_Addr1] = FLASH_Read_ID;
// FIXME: 10ms delay
for (i = 10000; i > 0; i--);
// Manufacturers' code
id[0] = ROM[0];
// Part number
id[1] = ROM[1];
ROM[FLASH_Setup_Addr1] = FLASH_Setup_Code1;
ROM[FLASH_Setup_Addr2] = FLASH_Setup_Code2;
ROM[FLASH_Setup_Addr1] = FLASH_Read_ID_Exit;
// FIXME: 10ms delay
for (i = 10000; i > 0; i--);
}
//----------------------------------------------------------------------------
// Erase Block
int
flash_erase_block(void* block, unsigned int len)
{
volatile flash_data_t* ROM;
volatile flash_data_t* addr_ptr = (volatile flash_data_t*) block;
int res = FLASH_ERR_OK;
while ((FLASH_ERR_OK == res) && (len > 0)) {
int timeout;
flash_data_t state, prev_state;
// Base address of device(s) being programmed.
ROM = (volatile flash_data_t*)((unsigned long)block & ~(FLASH_DEVICE_SIZE-1));
// Program data [byte] - 6 step sequence
ROM[FLASH_Setup_Addr1] = FLASH_Setup_Code1;
ROM[FLASH_Setup_Addr2] = FLASH_Setup_Code2;
ROM[FLASH_Setup_Addr1] = FLASH_Setup_Erase;
ROM[FLASH_Setup_Addr1] = FLASH_Setup_Code1;
ROM[FLASH_Setup_Addr2] = FLASH_Setup_Code2;
*addr_ptr = FLASH_Block_Erase;
// Wait for completion (bit 6 stops toggling)
timeout = 5000000;
prev_state = *addr_ptr & FLASH_Busy;
while (true) {
state = *addr_ptr & FLASH_Busy;
if (prev_state == state) {
break;
}
if (--timeout == 0) {
res = FLASH_ERR_DRV_TIMEOUT;
break;
}
prev_state = state;
}
// Verify loaded data bytes
while (len > 0) {
if (*addr_ptr != FLASH_BlankValue) {
// Only update return value if erase operation was OK
if (FLASH_ERR_OK == res) res = FLASH_ERR_DRV_VERIFY;
break;
}
addr_ptr++;
len -= sizeof(*addr_ptr);
}
}
return FLASH_ERR_OK;
}
//----------------------------------------------------------------------------
// Program Buffer
int
flash_program_buf(void* addr, void* data, int len)
{
volatile flash_data_t* ROM;
volatile flash_data_t* addr_ptr = (volatile flash_data_t*) addr;
volatile flash_data_t* data_ptr = (volatile flash_data_t*) data;
int res = FLASH_ERR_OK;
#if 0
CYG_ASSERT((unsigned long)data_ptr & (sizeof(flash_data_t)-1) == 0,
"Data not properly aligned");
CYG_ASSERT((unsigned long)addr_ptr & (CYGNUM_FLASH_INTERLEAVE*sizeof(flash_data_t)-1) == 0,
"Addr not properly aligned (to first interleaved device)");
#endif
while ((FLASH_ERR_OK == res) && (len > 0)) {
int timeout;
flash_data_t state, prev_state;
// Base address of device(s) being programmed.
ROM = (volatile flash_data_t*)((unsigned long)addr & ~(FLASH_DEVICE_SIZE-1));
// Program data [byte] - 4 step sequence
ROM[FLASH_Setup_Addr1] = FLASH_Setup_Code1;
ROM[FLASH_Setup_Addr2] = FLASH_Setup_Code2;
ROM[FLASH_Setup_Addr1] = FLASH_Program;
*addr_ptr = *data_ptr;
// Wait for completion (bit 6 stops toggling)
timeout = 5000000;
prev_state = *addr_ptr & FLASH_Busy;
while (true) {
state = *addr_ptr & FLASH_Busy;
if (prev_state == state) {
break;
}
if (--timeout == 0) {
res = FLASH_ERR_DRV_TIMEOUT;
break;
}
prev_state = state;
}
// Verify loaded data bytes
if (*addr_ptr != *data_ptr) {
// Only update return value if program operation was OK
if (FLASH_ERR_OK == res) res = FLASH_ERR_DRV_VERIFY;
break;
}
addr_ptr++;
data_ptr++;
len -= sizeof(*data_ptr);
}
// Ideally, we'd want to return not only the failure code, but also
// the address/device that reported the error.
return res;
}
#endif // CYGONCE_DEVS_FLASH_SST_39VFXXX_INL
[-- Attachment #5: flash_zlg2200.cdl --]
[-- Type: application/octet-stream, Size: 2884 bytes --]
# ====================================================================
#
# flash_zlg2200.cdl
#
# FLASH memory - Hardware support on ZLG EasyARM2200 board
#
# ====================================================================
#####ECOSGPLCOPYRIGHTBEGIN####
## -------------------------------------------
## This file is part of eCos, the Embedded Configurable Operating System.
## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
##
## eCos 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 or (at your option) any later version.
##
## eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
##
## As a special exception, if other files instantiate templates or use macros
## or inline functions from this file, or you compile this file and link it
## with other works to produce a work based on this file, this file does not
## by itself cause the resulting work to be covered by the GNU General Public
## License. However the source code for this file must still be made available
## in accordance with section (3) of the GNU General Public License.
##
## This exception does not invalidate any other reasons why a work based on
## this file might be covered by the GNU General Public License.
##
## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
## at http://sources.redhat.com/ecos/ecos-license/
## -------------------------------------------
#####ECOSGPLCOPYRIGHTEND####
# ====================================================================
######DESCRIPTIONBEGIN####
#
# Author(s): gthomas, hmt, jskov, rcassebohm
# Original data: gthomas
# Contributors: gthomas, rcassebohm
# Date: 2001-02-20
#
#####DESCRIPTIONEND####
#
# ====================================================================
cdl_package CYGPKG_DEVS_FLASH_ZLG2200 {
display "ZLG EasyARM2200 FLASH memory support"
description "FLASH memory device support for ZLG EasyARM2200 board"
parent CYGPKG_IO_FLASH
active_if CYGPKG_IO_FLASH
requires CYGPKG_HAL_ARM_LPC2XXX
compile zlg2200_flash.c
# Arguably this should do in the generic package
# but then there is a logic loop so you can never enable it.
cdl_interface CYGINT_DEVS_FLASH_SST_39VFXXX_REQUIRED {
display "Generic SST 39VFxxx driver required"
}
implements CYGINT_DEVS_FLASH_SST_39VFXXX_REQUIRED
}
[-- Attachment #6: Type: text/plain, Size: 148 bytes --]
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
next reply other threads:[~2005-08-04 0:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-04 0:25 吴身国 [this message]
[not found] <E1E0TY8-0001IH-00@londo.lunn.ch>
2005-08-04 7:20 ` Andrew Lunn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050804002500.O_QmkYohmPpbML173HwMhq1F0ngmbD0C_yTFqGp-ykI@z \
--to=ipv06@163.com \
--cc=ecos-discuss@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).