Commit 4b97f3cb authored by ntfreak's avatar ntfreak
Browse files

- added mingw elf patches from Vincent Palatin

- added str9x programming using flash controller tap (str9xpec), including option bytes and device lock/unlock
- inttypes.h now used for long long printf style declarations

git-svn-id: svn://svn.berlios.de/openocd/trunk@174 b42882b7-edfa-0310-969c-e2dbd0fdcd60
parent 3d026ce9
......@@ -5,6 +5,7 @@ AC_SEARCH_LIBS([ioperm], [ioperm])
AC_CANONICAL_HOST
AC_CHECK_HEADERS(sys/param.h)
AC_CHECK_HEADERS(elf.h)
AC_C_BIGENDIAN
......
INCLUDES = -I$(top_srcdir)/src/helper -I$(top_srcdir)/src/jtag -I$(top_srcdir)/src/target $(all_includes)
METASOURCES = AUTO
noinst_LIBRARIES = libflash.a
libflash_a_SOURCES = flash.c lpc2000.c cfi.c non_cfi.c at91sam7.c str7x.c str9x.c nand.c lpc3180_nand_controller.c stellaris.c
noinst_HEADERS = flash.h lpc2000.h cfi.h non_cfi.h at91sam7.h str7x.h str9x.h nand.h lpc3180_nand_controller.h stellaris.h
libflash_a_SOURCES = flash.c lpc2000.c cfi.c non_cfi.c at91sam7.c str7x.c str9x.c nand.c lpc3180_nand_controller.c stellaris.c str9xpec.c
noinst_HEADERS = flash.h lpc2000.h cfi.h non_cfi.h at91sam7.h str7x.h str9x.h nand.h lpc3180_nand_controller.h stellaris.h str9xpec.h
......@@ -23,7 +23,6 @@
#include "flash.h"
#include "command.h"
#include "log.h"
#include "target.h"
#include "time_support.h"
......@@ -36,6 +35,7 @@
#include <fileio.h>
#include <image.h>
#include "log.h"
/* command handlers */
int handle_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
......@@ -56,6 +56,7 @@ extern flash_driver_t at91sam7_flash;
extern flash_driver_t str7x_flash;
extern flash_driver_t str9x_flash;
extern flash_driver_t stellaris_flash;
extern flash_driver_t str9xpec_flash;
flash_driver_t *flash_drivers[] =
{
......@@ -65,6 +66,7 @@ flash_driver_t *flash_drivers[] =
&str7x_flash,
&str9x_flash,
&stellaris_flash,
&str9xpec_flash,
NULL,
};
......@@ -373,9 +375,10 @@ int handle_flash_erase_command(struct command_context_s *cmd_ctx, char *cmd, cha
int last = strtoul(args[2], NULL, 0);
int retval;
flash_bank_t *p = get_flash_bank_by_num(strtoul(args[0], NULL, 0));
struct timeval start, end, duration;
gettimeofday(&start, NULL);
duration_t duration;
char *duration_text;
duration_start_measure(&duration);
if (!p)
{
......@@ -411,10 +414,10 @@ int handle_flash_erase_command(struct command_context_s *cmd_ctx, char *cmd, cha
}
else
{
gettimeofday(&end, NULL);
timeval_subtract(&duration, &end, &start);
command_print(cmd_ctx, "erased sectors %i through %i on flash bank %i in %is %ius", first, last, strtoul(args[0], 0, 0), duration.tv_sec, duration.tv_usec);
duration_stop_measure(&duration, &duration_text);
command_print(cmd_ctx, "erased sectors %i through %i on flash bank %i in %s", first, last, strtoul(args[0], 0, 0), duration_text);
free(duration_text);
}
}
else
......
......@@ -31,6 +31,7 @@
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <errno.h>
......@@ -1387,7 +1388,7 @@ int handle_nand_dump_command(struct command_context_s *cmd_ctx, char *cmd, char
fileio_close(&fileio);
duration_stop_measure(&duration, &duration_text);
command_print(cmd_ctx, "dumped %lli byte in %s", fileio.size, duration_text);
command_print(cmd_ctx, "dumped %"PRIi64" byte in %s", fileio.size, duration_text);
free(duration_text);
}
else
......
This diff is collapsed.
/***************************************************************************
* Copyright (C) 2005 by Dominic Rath *
* Dominic.Rath@gmx.de *
* *
* 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 Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef STR9XPEC_H
#define STR9XPEC_H
#include "flash.h"
#include "target.h"
#include "jtag.h"
typedef struct str9xpec_flash_controller_s
{
struct target_s *target;
u32 *sector_bits;
int chain_pos;
int isc_enable;
jtag_device_t* devarm;
u8 options[8];
} str9xpec_flash_controller_t;
enum str9xpec_status_codes
{
STR9XPEC_INVALID_COMMAND = 1,
STR9XPEC_ISC_SUCCESS = 2,
STR9XPEC_ISC_DISABLED = 3,
STR9XPEC_ISC_INTFAIL = 32,
};
/* ISC commands */
#define ISC_IDCODE 0xFE
#define ISC_MFG_READ 0x4C
#define ISC_CONFIGURATION 0x07
#define ISC_ENABLE 0x0C
#define ISC_DISABLE 0x0F
#define ISC_NOOP 0x10
#define ISC_ADDRESS_SHIFT 0x11
#define ISC_CLR_STATUS 0x13
#define ISC_PROGRAM 0x20
#define ISC_PROGRAM_SECURITY 0x22
#define ISC_PROGRAM_UC 0x23
#define ISC_ERASE 0x30
#define ISC_READ 0x50
#define ISC_BLANK_CHECK 0x60
/* ISC_DEFAULT bit definitions */
#define ISC_STATUS_SECURITY 0x40
#define ISC_STATUS_INT_ERROR 0x30
#define ISC_STATUS_MODE 0x08
#define ISC_STATUS_BUSY 0x04
#define ISC_STATUS_ERROR 0x03
typedef struct mem_layout_str9pec {
u32 sector_start;
u32 sector_size;
u32 sector_bit;
} str9xpec_mem_layout_t;
/* Option bytes definitions */
#define STR9XPEC_OPT_CSMAPBIT 48
#define STR9XPEC_OPT_LVDTHRESBIT 49
#define STR9XPEC_OPT_LVDSELBIT 50
#define STR9XPEC_OPT_LVDWARNBIT 51
#define STR9XPEC_OPT_OTPBIT 63
#endif /* STR9XPEC_H */
......@@ -24,6 +24,8 @@
#include "config.h"
#endif
#include "types.h"
/* include necessary headers for socket functionality */
#ifdef _WIN32
#include <winsock2.h>
......@@ -152,4 +154,51 @@ static __inline void socket_nonblock(int fd)
#endif
}
#ifndef HAVE_ELF_H
typedef struct
{
unsigned char e_ident[16]; /* Magic number and other info */
u16 e_type; /* Object file type */
u16 e_machine; /* Architecture */
u32 e_version; /* Object file version */
u32 e_entry; /* Entry point virtual address */
u32 e_phoff; /* Program header table file offset */
u32 e_shoff; /* Section header table file offset */
u32 e_flags; /* Processor-specific flags */
u16 e_ehsize; /* ELF header size in bytes */
u16 e_phentsize; /* Program header table entry size */
u16 e_phnum; /* Program header table entry count */
u16 e_shentsize; /* Section header table entry size */
u16 e_shnum; /* Section header table entry count */
u16 e_shstrndx; /* Section header string table index */
} Elf32_Ehdr;
#define ELFMAG "\177ELF"
#define SELFMAG 4
#define EI_CLASS 4 /* File class byte index */
#define ELFCLASS32 1 /* 32-bit objects */
#define ELFCLASS64 2 /* 64-bit objects */
#define EI_DATA 5 /* Data encoding byte index */
#define ELFDATA2LSB 1 /* 2's complement, little endian */
#define ELFDATA2MSB 2 /* 2's complement, big endian */
typedef struct
{
u32 p_type; /* Segment type */
u32 p_offset; /* Segment file offset */
u32 p_vaddr; /* Segment virtual address */
u32 p_paddr; /* Segment physical address */
u32 p_filesz; /* Segment size in file */
u32 p_memsz; /* Segment size in memory */
u32 p_flags; /* Segment flags */
u32 p_align; /* Segment alignment */
} Elf32_Phdr;
#define PT_LOAD 1 /* Loadable program segment */
#endif /* HAVE_ELF_H */
#endif /* REPLACEMENTS_H */
......@@ -21,6 +21,7 @@
#include "config.h"
#endif
#include "replacements.h"
#include "time_support.h"
#include "log.h"
......
......@@ -21,6 +21,8 @@
#include "config.h"
#endif
#include "replacements.h"
#include "pld.h"
#include "jtag.h"
......
......@@ -301,7 +301,7 @@ int server_loop(command_context_t *command_context)
FD_ZERO(&read_fds);
else
{
ERROR("error during select: %d", strerror(errno));
ERROR("error during select: %s", strerror(errno));
exit(-1);
}
#else
......
......@@ -241,8 +241,8 @@ void arm720t_post_debug_entry(target_t *target)
arm720t->armv4_5_mmu.armv4_5_cache.i_cache_enabled = 0;
/* save i/d fault status and address register */
arm720t_read_cp15(target, 0xee150f10, &arm720t->fsr);
arm720t_read_cp15(target, 0xee160f10, &arm720t->far);
arm720t_read_cp15(target, 0xee150f10, &arm720t->fsr_reg);
arm720t_read_cp15(target, 0xee160f10, &arm720t->far_reg);
jtag_execute_queue();
}
......@@ -254,8 +254,8 @@ void arm720t_pre_restore_context(target_t *target)
arm720t_common_t *arm720t = arm7tdmi->arch_info;
/* restore i/d fault status and address register */
arm720t_write_cp15(target, 0xee050f10, arm720t->fsr);
arm720t_write_cp15(target, 0xee060f10, arm720t->far);
arm720t_write_cp15(target, 0xee050f10, arm720t->fsr_reg);
arm720t_write_cp15(target, 0xee060f10, arm720t->far_reg);
}
int arm720t_get_arch_pointers(target_t *target, armv4_5_common_t **armv4_5_p, arm7_9_common_t **arm7_9_p, arm7tdmi_common_t **arm7tdmi_p, arm720t_common_t **arm720t_p)
......
......@@ -36,8 +36,8 @@ typedef struct arm720t_common_s
armv4_5_mmu_common_t armv4_5_mmu;
arm7tdmi_common_t arm7tdmi_common;
u32 cp15_control_reg;
u32 fsr;
u32 far;
u32 fsr_reg;
u32 far_reg;
} arm720t_common_t;
#endif /* ARM720T_H */
......@@ -23,7 +23,9 @@
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_ELF_H
#include <elf.h>
#endif
#include "image.h"
......@@ -320,8 +322,8 @@ int image_elf_read_headers(image_t *image)
elf->endianness = elf->header->e_ident[EI_DATA];
if ((elf->endianness==ELFDATANONE)
||(elf->endianness>=ELFDATANUM))
if ((elf->endianness!=ELFDATA2LSB)
&&(elf->endianness!=ELFDATA2MSB))
{
ERROR("invalid ELF file, unknown endianess setting");
return ERROR_IMAGE_FORMAT_ERROR;
......
......@@ -20,7 +20,14 @@
#ifndef IMAGE_H
#define IMAGE_H
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_ELF_H
#include <elf.h>
#endif
#include "replacements.h"
#include "fileio.h"
#include "target.h"
......
......@@ -31,6 +31,7 @@
#include <string.h>
#include <stdlib.h>
#include <inttypes.h>
#include <sys/types.h>
#include <sys/stat.h>
......@@ -1776,7 +1777,7 @@ int handle_dump_image_command(struct command_context_s *cmd_ctx, char *cmd, char
fileio_close(&fileio);
duration_stop_measure(&duration, &duration_text);
command_print(cmd_ctx, "dumped %lli byte in %s", fileio.size, duration_text);
command_print(cmd_ctx, "dumped %"PRIi64" byte in %s", fileio.size, duration_text);
free(duration_text);
return ERROR_OK;
......
......@@ -17,7 +17,11 @@
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "replacements.h"
#include "xscale.h"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment