OpenCores
URL https://opencores.org/ocsvn/amber/amber/trunk

Subversion Repositories amber

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /amber
    from Rev 64 to Rev 65
    Reverse comparison

Rev 64 → Rev 65

trunk/sw/boot-loader Property changes : Deleted: svn:ignore ## -1,5 +0,0 ## -*.map -*.mem -*.dis -*.elf -*_memparams*.v Index: trunk/sw/boot-loader-serial/fpga-version.h =================================================================== --- trunk/sw/boot-loader-serial/fpga-version.h (nonexistent) +++ trunk/sw/boot-loader-serial/fpga-version.h (revision 65) @@ -0,0 +1 @@ +#define AMBER_FPGA_VERSION "20130428143120" Index: trunk/sw/boot-loader-serial/start.S =================================================================== --- trunk/sw/boot-loader-serial/start.S (nonexistent) +++ trunk/sw/boot-loader-serial/start.S (revision 65) @@ -0,0 +1,225 @@ +/*---------------------------------------------------------------- +// // +// start.S // +// // +// This file is part of the Amber project // +// http://www.opencores.org/project,amber // +// // +// Description // +// Assembly routines for boot-loader. // +// As boot-loader is a stand-alone application, it needs a // +// simple start function written in assembly to call the // +// C code main() function. // +// // +// Author(s): // +// - Conor Santifort, csantifort.amber@gmail.com // +// // +////////////////////////////////////////////////////////////////// +// // +// Copyright (C) 2010 Authors and OPENCORES.ORG // +// // +// This source file may be used and distributed without // +// restriction provided that this copyright statement is not // +// removed from the file and that any derivative work contains // +// the original copyright notice and the associated disclaimer. // +// // +// This source file is free software; you can redistribute it // +// and/or modify it under the terms of the GNU Lesser General // +// Public License as published by the Free Software Foundation; // +// either version 2.1 of the License, or (at your option) any // +// later version. // +// // +// This source 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 Lesser General Public License for more // +// details. // +// // +// You should have received a copy of the GNU Lesser General // +// Public License along with this source; if not, download it // +// from http://www.opencores.org/lgpl.shtml // +// // +----------------------------------------------------------------*/ + +#include "amber_registers.h" + + +/* Defined in vmlinux/include/asm-arm/setup.h */ +#define ATAG_CORE 0x54410001 +#define ATAG_MEM 0x54410002 +#define ATAG_INITRD 0x54410005 +#define ATAG_RAMDISK 0x54410004 +#define ATAG_NONE 0x00000000 + +#define ATAG_CORE_SIZE ((2*4 + 3*4) >> 2) +#define ATAG_MEM_SIZE ((2*4 + 2*4) >> 2) +#define ATAG_INITRD_SIZE ((2*4 + 2*4) >> 2) +#define ATAG_RAMDISK_SIZE ((2*4 + 3*4) >> 2) + + +/* from vmlinux/arch/arm/kernel/compat.c */ +#define FLAG_READONLY 1 + +/* from the list in wmlinux/arch/arm/tools/mach-types */ +#define MACH_TYPE_A5K 11 + + + + .section .text + .globl start +start: + /* 0x00 Reset Interrupt vector address */ + b startup + + /* 0x04 Undefined Instruction Interrupt vector address */ + b _testfail + + /* 0x08 SWI Interrupt vector address */ + b _testfail + + /* 0x0c Prefetch abort Interrupt vector address */ + b _testfail + + /* 0x10 Data abort Interrupt vector address */ + b _testfail + b _testfail + + /* 0x18 IRQ vector address */ + b _testfail + + /* 0x1c FIRQ vector address */ + b _testfail + +startup: + /* Unset interrupt mask bits, stay in svc mode */ + mov r0, #0x00000003 + teqp pc, r0 + + @ Enable the cache + mov r0, #0xffffffff + mcr 15, 0, r0, cr3, cr0, 0 @ cacheable area + mov r0, #1 + mcr 15, 0, r0, cr2, cr0, 0 @ cache enable + + @ init SP + ldr sp, AdrStack + + @ Set 32MB memory mode + ldr r0, AdrMemCtrl + mov r1, #1 + str r1, [r0] + + .extern main + bl main + + @ jump to program at r0 + .globl _jump_to_program +_jump_to_program: + + + @ ---------------------------------------------- + @ Copy ATAG structure to AdrBootParams + @ ---------------------------------------------- + ldr r1, AdrBootParams + ldr r2, AdrATAGBase + ldr r3, AdeEndATAG + +1: cmp r2, r3 + beq 2f + ldr r4, [r2], #4 + str r4, [r1], #4 + b 1b + + @ Set memc page tables +2: ldr r2, AdrPageTabes + mov r3, #0 + mov r4, #40 +3: str r3,[r2],#4 + subs r4, r4, #1 + bne 3b + + @ ---------------------------------------------- + @ jump to start of program in svc mode with interrupts disabled + @ ---------------------------------------------- + mov r4, r0 + orr r4, #0x0c000003 + mov r0, #0 + mov pc, r4 + + + @ ---------------------------------------------- + @ Print CPU Core status + @ ---------------------------------------------- + .globl _core_status +_core_status: + stmdb sp!,{lr} + stmdb sp!,{r0-r12} + mov r4, #0 + mov r5, sp + mov r6, lr + +1: ldr r0, =Status_Message + mov r1, r4 + ldr r2, [r5], #4 + bl printf + + cmp r4, #13 + addne r4, r4, #1 + bne 1b + + @ Stack Pointer + ldr r0, =SPStatus_Message + mov r1, sp + bl printf + + @ Program Counter - Use Link Register value because + @ want the PC value of whatever called this function + ldr r0, =PCStatus_Message + sub r1, r6, #4 + bl printf + + ldmia sp!,{r0-r12} + ldmia sp!,{pc}^ + + +/* stack at top of ddr3 memory space */ +AdrStack: .word 0x02000000 +AdrMemCtrl: .word ADR_AMBER_TEST_MEM_CTRL + +/* core status messages */ +Status_Message: .ascii "r%2d %08x\n\00" +SPStatus_Message: .ascii "sp %08x\n\00" +PCStatus_Message: .ascii "pc %08x\n\00" + + .align 2 +AdrATAGBase: .word ATAGBase +AdeEndATAG: .word EndATAG + +ATAGBase: .word ATAG_CORE_SIZE + .word ATAG_CORE + .word FLAG_READONLY @ flags + .word 4096 @ page size + .word 0x0 @ rootdev + + .word ATAG_MEM_SIZE + .word ATAG_MEM + .word 32*1024*1024 @ size - 32MB + .word 0x0 @ start + + .word ATAG_RAMDISK_SIZE + .word ATAG_RAMDISK + .word 1 @ flags: bit 0 = load, bit 1 = prompt + .word 0x000000d0 @ size in 1k blocks + .word 0x00800000 @ physical address of start of ramdisk + + .word ATAG_INITRD_SIZE + .word ATAG_INITRD + .word 0x02800000 @ virtual address of start of initrd image + .word 0x00032000 @ size = 200k + + .word ATAG_NONE + .word 0x0 +EndATAG: .word 0x0 + +AdrBootParams: .word 0x7c000 +AdrPageTabes: .word 0x3f01000 Index: trunk/sw/boot-loader-serial/boot-loader.c =================================================================== --- trunk/sw/boot-loader-serial/boot-loader.c (nonexistent) +++ trunk/sw/boot-loader-serial/boot-loader.c (revision 65) @@ -0,0 +1,430 @@ +/*---------------------------------------------------------------- +// // +// boot-loader.c // +// // +// This file is part of the Amber project // +// http://www.opencores.org/project,amber // +// // +// Description // +// The main functions for the boot loader application. This // +// application is embedded in the FPGA's SRAM and is used // +// to load larger applications into the DDR3 memory on // +// the development board. // +// // +// Author(s): // +// - Conor Santifort, csantifort.amber@gmail.com // +// // +////////////////////////////////////////////////////////////////// +// // +// Copyright (C) 2010 Authors and OPENCORES.ORG // +// // +// This source file may be used and distributed without // +// restriction provided that this copyright statement is not // +// removed from the file and that any derivative work contains // +// the original copyright notice and the associated disclaimer. // +// // +// This source file is free software; you can redistribute it // +// and/or modify it under the terms of the GNU Lesser General // +// Public License as published by the Free Software Foundation; // +// either version 2.1 of the License, or (at your option) any // +// later version. // +// // +// This source 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 Lesser General Public License for more // +// details. // +// // +// You should have received a copy of the GNU Lesser General // +// Public License along with this source; if not, download it // +// from http://www.opencores.org/lgpl.shtml // +// // +----------------------------------------------------------------*/ + +#include "amber_registers.h" +#include "stdio.h" +#include "boot-loader.h" +#include "fpga-version.h" + + +int main ( void ) { + int c, esc = 0; + char buf [20]; /* current line */ + char lbuf [20]; /* last line */ + int i = 0; + int li = 0; + int j; + + /* Enable the UART FIFO */ + *(unsigned int *) ADR_AMBER_UART0_LCRH = 0x10; + + printf("%cAmber Boot Loader v%s\n", 0xc, AMBER_FPGA_VERSION ); /* 0xc == new page */ + + + /* When ADR_AMBER_TEST_SIM_CTRL is non-zero, its a Verilog simulation. + The ADR_AMBER_TEST_SIM_CTRL register is always 0 in the real fpga + The register is in vlog/system/test_module.v + */ + if ( *(unsigned int *) ADR_AMBER_TEST_SIM_CTRL ) { + load_run(*(unsigned int *) ADR_AMBER_TEST_SIM_CTRL, 0); + } + + + /* Print the instructions */ + print_help(); + printf("Ready\n> "); + + /* Loop forever on user input */ + while (1) { + if ((c = _inbyte (DLY_1S)) >= 0) { + + /* Escape Sequence ? */ + if (c == 0x1b) esc = 1; + else if (esc == 1 && c == 0x5b) esc = 2; + else if (esc == 2) { + esc = 0; + if (c == 'A') { + /* Erase current line using backspaces */ + for (j=0;j 0) { i--; } + else { buf[i++] = c; } + } + + /* End of line ? */ + if (c == '\r' || i >= 19) { + if (i>1) { + /* Copy current line buffer to last line buffer */ + for (j=0;j<20;j++) lbuf[j] = buf[j]; + li = i-1; + } + buf[i] = 0; i = 0; + + /* Process line */ + printf("\n"); + parse( buf ); + printf("> "); + } + } + } +} + + +/* Parse a command line passed from main and execute the command */ +void parse ( char * buf ) +{ + unsigned int found, address, data, i, length, bytes, rdata; + int file_size; + char byte; + unsigned int lcount; + char bad_command_msg[] = "Invalid command"; + + /* Ignore returns with no trext on the line */ + if (!buf[1]) return; + + /* Check if its a single character instruction */ + if (buf[1] == '\r') { + switch (buf[0]) { + + case 'h': /* Help */ + print_help(); + break; + + case 'l': /* Load */ + load_run(1,0); + break; + + case 's': /* Status */ + _core_status(); + /* Flush out the uart with spaces */ + print_spaces(16); + printf ("\n"); + break; + + default: + printf ("%s\n", bad_command_msg); + break; + } + return; + } + + + /* Check for invalid instruction format for multi-word instructions */ + else if (buf[1] != 0x20) { + printf ("%s\n", bad_command_msg); + return; + } + + + switch (buf[0]) { + + case 'd': /* Dump block of memory */ + /* Dump memory contents */ + if (get_address_data ( buf, &address, &bytes )) { + for (i=address;i */ + if (get_hex ( buf, 2, &address, &length )) { + load_run(0, address); + } + break; + + + case 'p': /* Print String */ + /* Recover the address from the string - the address is written in hex */ + if (get_hex ( buf, 2, &address, &length )) { + length = 0; + lcount = 0; + byte = * (char *)address++; + while ( byte < 128 && length < 0x1000 ) { + + if ( byte != 0 ) _outbyte( byte ); + if ( byte == '\r' ) printf("\n"); lcount = 0; + if ( lcount == 79 ) printf("\n"); lcount = 0; + + byte = * (char *)address++; + lcount++; + length++; + } + } + break; + + case 'r': /* Read address */ + /* Recover the address from the string - the address is written in hex */ + if (get_hex ( buf, 2, &address, &length )) { + printm (address); + } + break; + + case 'b': /* Load binary file into address */ + /* Recover the address from the string - the address is written in hex */ + if (get_hex ( buf, 2, &address, &length )) { + load_run (5, address); + } + break; + + case 'w': /* Write address */ + /* Get the address */ + if (get_address_data ( buf, &address, &data )) { + /* Write to memory */ + * (unsigned int*) address = data; + /* read back */ + printm (address); + } + break; + + default: + printf ("%s\n", bad_command_msg); + break; + } +} + + +/* Load a binary file into memory via the UART + If its an elf file, copy it into the correct memory areas + and execute it. +*/ +void load_run( int type, unsigned int address ) +{ + int file_size; + char * message = "Send file w/ 1K Xmodem protocol from terminal emulator now..."; + + switch (type) { + + case 1: /* Load a binary file to FILE_LOAD_BASE */ + /* Load a file using the xmodem protocol */ + printf ("%s\n", message); + + /* Destination, Destination Size */ + file_size = xmodemReceive((char *) FILE_LOAD_BASE, FILE_MAX_SIZE); + if (file_size < 0 || file_size > FILE_MAX_SIZE) { + printf ("Xmodem error file size 0x%x \n", file_size); + return; + } + + printf("\nelf split\n"); + elfsplitter(FILE_LOAD_BASE, file_size); + break; + + + case 2: /* testing the boot loader itself in simulation */ + print_help(); + _core_status(); + print_spaces(16); + _testpass(); + break; + + + case 3: /* vmlinux in simulation */ + printf("j 0x%08x\n", LINUX_JUMP_ADR); + /* Flush the uart tx buffer with spaces */ + print_spaces(16); + printf("\n"); + /* pc jump */ + _jump_to_program(LINUX_JUMP_ADR); + _testpass(); + break; + + + case 4: /* programs starting at 0x8000 in simulation */ + printf("j 0x%08x\n", APP_JUMP_ADR); + /* Flush the uart tx buffer with spaces */ + print_spaces(16); + printf("\n"); + /* pc jump */ + _jump_to_program(APP_JUMP_ADR); + _testpass(); + break; + + + case 5: /* Load a binary file into memory, to 'address' */ + /* Load a file using the xmodem protocol */ + printf ("%s\n", message); + /* Destination, Destination Size */ + file_size = xmodemReceive((char *) address, FILE_MAX_SIZE); + if (file_size < 0 || file_size > FILE_MAX_SIZE) { + printf ("Xmodem error file size 0x%x \n", file_size); + return; + } + break; + + + default: /* Run the program */ + printf("j 0x%08x\n", address); + /* Flush the uart tx buffer with spaces */ + print_spaces(16); + printf("\n"); + /* pc jump */ + _jump_to_program(address); + _testpass(); + break; + } +} + + +/* Print a memory location */ +void printm ( unsigned int address ) +{ + printf ("mem 0x%08x = 0x%08x\n", address, * (unsigned int *)address); +} + + +void print_help ( void ) + +{ + printf("Commands\n"); + printf("l"); + print_spaces(29); + printf(": Load elf file\n"); + + printf("b
"); + print_spaces(19); + printf(": Load binary file to
\n"); + + printf("d : Dump mem\n"); + + printf("h"); + print_spaces(29); + printf(": Print help message\n"); + + printf("j
"); + print_spaces(19); + printf(": Execute loaded elf, jumping to
\n"); + + printf("p
"); + print_spaces(19); + printf(": Print ascii mem until first 0\n"); + + printf("r
"); + print_spaces(19); + printf(": Read mem\n"); + + printf("s"); + print_spaces(29); + printf(": Core status\n"); + + printf("w
"); + print_spaces(11); + printf(": Write mem\n"); +} + + +/* Print a number of spaces */ +void print_spaces ( int num ) +{ + while(num--) printf(" "); +} + + +/* Return a number recovered from a string of hex digits */ +int get_hex ( char * buf, int start_position, + unsigned int *address, + unsigned int *length) +{ + + int cpos = 0, done = 0; + + cpos = start_position; done = 0; *address = 0; + + while (done == 0) { + if ( buf[cpos] >= '0' && buf[cpos] <= '9' ) { + *address = *address<<4; + *address = *address + buf[cpos] - '0'; + } + else if ( buf[cpos] >= 'A' && buf[cpos] <= 'F' ) { + *address = *address<<4; + *address = *address + buf[cpos] - 'A' + 10; + } + else if ( buf[cpos] >= 'a' && buf[cpos] <= 'f' ) { + *address = *address<<4; + *address = *address + buf[cpos] - 'a' + 10; + } + else { + done = 1; + *length = cpos - start_position; + } + if ( cpos >= 8+start_position ) { + done = 1; + *length = 8; + } + cpos++; + } + + /* Return the length of the hexadecimal string */ + if (cpos > start_position+1) return 1; else return 0; +} + + +/* Parse a string for an address and data in hex */ +int get_address_data ( char * buf, unsigned int *address, unsigned int *data ) +{ + int found, length; + + found = get_hex ( buf, 2, address, &length ); + if (found) { + /* Get the data */ + found = get_hex ( buf, 3+length, data, &length ); + } + + return found; +} + Index: trunk/sw/boot-loader-serial/boot-loader.h =================================================================== --- trunk/sw/boot-loader-serial/boot-loader.h (nonexistent) +++ trunk/sw/boot-loader-serial/boot-loader.h (revision 65) @@ -0,0 +1,58 @@ +/*---------------------------------------------------------------- +// // +// boot-loader.h // +// // +// This file is part of the Amber project // +// http://www.opencores.org/project,amber // +// // +// Description // +// Defines for the boot-loader application. // +// // +// Author(s): // +// - Conor Santifort, csantifort.amber@gmail.com // +// // +////////////////////////////////////////////////////////////////// +// // +// Copyright (C) 2010 Authors and OPENCORES.ORG // +// // +// This source file may be used and distributed without // +// restriction provided that this copyright statement is not // +// removed from the file and that any derivative work contains // +// the original copyright notice and the associated disclaimer. // +// // +// This source file is free software; you can redistribute it // +// and/or modify it under the terms of the GNU Lesser General // +// Public License as published by the Free Software Foundation; // +// either version 2.1 of the License, or (at your option) any // +// later version. // +// // +// This source 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 Lesser General Public License for more // +// details. // +// // +// You should have received a copy of the GNU Lesser General // +// Public License along with this source; if not, download it // +// from http://www.opencores.org/lgpl.shtml // +// // +----------------------------------------------------------------*/ + +/* These uart input delay values are correct for a 33MHz system clock */ +#define DLY_1S 1000 +#define DLY_300MS 300 + +#define LINUX_JUMP_ADR 0x00080000 /* Boot loader jumps to this address to run vmlinux */ +#define APP_JUMP_ADR 0x00008000 /* Boot loader jumps to this address to run test programs */ +#define FILE_LOAD_BASE 0x01000000 +#define DEBUG_BUF 0x01800000 +#define FILE_MAX_SIZE 0x00800000 /* 8MB max Xmodem transfer file size */ + +/* Function prototypes */ +void parse ( char * buf ); +void printm ( unsigned int address ); +int get_hex ( char * buf, int start_position, unsigned int *address, unsigned int *length ); +int get_address_data ( char * buf, unsigned int *address, unsigned int *data ); +void load_run( int type, unsigned int address ); +void print_spaces ( int num ); +void print_help ( void ); Index: trunk/sw/boot-loader-serial/elfsplitter.c =================================================================== --- trunk/sw/boot-loader-serial/elfsplitter.c (nonexistent) +++ trunk/sw/boot-loader-serial/elfsplitter.c (revision 65) @@ -0,0 +1,304 @@ +/*---------------------------------------------------------------- +// // +// elfsplitter.c // +// // +// This file is part of the Amber project // +// http://www.opencores.org/project,amber // +// // +// Description // +// Used by the boot loader to split an elf file and copy it // +// to the correct memory locations ready for execution. // +// // +// Author(s): // +// - Conor Santifort, csantifort.amber@gmail.com // +// // +////////////////////////////////////////////////////////////////// +// // +// Copyright (C) 2010 Authors and OPENCORES.ORG // +// // +// This source file may be used and distributed without // +// restriction provided that this copyright statement is not // +// removed from the file and that any derivative work contains // +// the original copyright notice and the associated disclaimer. // +// // +// This source file is free software; you can redistribute it // +// and/or modify it under the terms of the GNU Lesser General // +// Public License as published by the Free Software Foundation; // +// either version 2.1 of the License, or (at your option) any // +// later version. // +// // +// This source 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 Lesser General Public License for more // +// details. // +// // +// You should have received a copy of the GNU Lesser General // +// Public License along with this source; if not, download it // +// from http://www.opencores.org/lgpl.shtml // +// // +----------------------------------------------------------------*/ + +/* +ELF File Structure +A single segment usually consist of several sections. E.g., a loadable +read-only segment could contain sections for executable code, read-only +data, and symbols for the dynamic linker. Relocatable files have section +header tables. Executable files have program header tables. Shared object +files have both. Sections are intended for further processing by a linker, +while the segments are intended to be mapped into memory. +*/ + +/* #define DEBUG */ + +#define EI_NIDENT 16 + +#define SHT_NULL 0 /* sh_type */ +#define SHT_PROGBITS 1 +#define SHT_SYMTAB 2 +#define SHT_STRTAB 3 +#define SHT_RELA 4 +#define SHT_HASH 5 +#define SHT_DYNAMIC 6 +#define SHT_NOTE 7 +#define SHT_NOBITS 8 +#define SHT_REL 9 +#define SHT_SHLIB 10 +#define SHT_DYNSYM 11 +#define SHT_UNKNOWN12 12 +#define SHT_UNKNOWN13 13 +#define SHT_INIT_ARRAY 14 +#define SHT_FINI_ARRAY 15 +#define SHT_PREINIT_ARRAY 16 +#define SHT_GROUP 17 +#define SHT_SYMTAB_SHNDX 18 +#define SHT_NUM 19 + + +/* Main ELF Header Table */ +typedef struct { + unsigned char e_ident[EI_NIDENT]; /* bytes 0 to 15 */ + unsigned short e_e_type; /* bytes 15 to 16 */ + unsigned short e_machine; /* bytes 17 to 18 */ + unsigned int e_version; /* bytes 19 to 22 */ + unsigned int e_entry; /* bytes 23 to 26 */ + unsigned int e_phoff; /* bytes 27 to 30 */ + unsigned int e_shoff; /* bytes 31 to 34 */ + unsigned int e_flags; /* bytes 35 to 38 */ + unsigned short e_ehsize; /* bytes 39 to 40 */ + unsigned short e_phentsize; /* bytes 41 to 42 */ + unsigned short e_phnum; /* bytes 43 to 44 (2B to 2C) */ + unsigned short e_shentsize; /* bytes 45 to 46 */ + unsigned short e_shnum; /* bytes 47 to 48 */ + unsigned short e_shstrndx; /* bytes 49 to 50 */ +} ElfHeader; + + +/* Program Headers */ +typedef struct { + unsigned int p_type; /* entry type */ + unsigned int p_offset; /* file offset */ + unsigned int p_vaddr; /* virtual address */ + unsigned int p_paddr; /* physical address */ + unsigned int p_filesz; /* file size */ + unsigned int p_memsz; /* memory size */ + unsigned int p_flags; /* entry flags */ + unsigned int p_align; /* memory/file alignment */ +} Elf32_Phdr; + + +/* Section Headers */ +typedef struct { + unsigned int sh_name; /* section name - index into string table */ + unsigned int sh_type; /* SHT_... */ + unsigned int sh_flags; /* SHF_... */ + unsigned int sh_addr; /* virtual address */ + unsigned int sh_offset; /* file offset */ + unsigned int sh_size; /* section size */ + unsigned int sh_link; /* misc info */ + unsigned int sh_info; /* misc info */ + unsigned int sh_addralign; /* memory alignment */ + unsigned int sh_entsize; /* entry size if table */ +} Elf32_Shdr; + + +/* +PROGBITS: This holds program contents including code, data, and debugger information. +NOBITS: Like PROGBITS. However, it occupies no space. +SYMTAB and DYNSYM: These hold symbol table. +STRTAB: This is a string table, like the one used in a.out. +REL and RELA: These hold relocation information. +DYNAMIC and HASH: This holds information related to dynamic linking. +*/ + +#define SHT_NULL 0 /* sh_type */ +#define SHT_PROGBITS 1 +#define SHT_SYMTAB 2 +#define SHT_STRTAB 3 +#define SHT_RELA 4 +#define SHT_HASH 5 +#define SHT_DYNAMIC 6 +#define SHT_NOTE 7 +#define SHT_NOBITS 8 +#define SHT_REL 9 +#define SHT_SHLIB 10 +#define SHT_DYNSYM 11 +#define SHT_UNKNOWN12 12 +#define SHT_UNKNOWN13 13 +#define SHT_INIT_ARRAY 14 +#define SHT_FINI_ARRAY 15 +#define SHT_PREINIT_ARRAY 16 +#define SHT_GROUP 17 +#define SHT_SYMTAB_SHNDX 18 +#define SHT_NUM 19 + + + +char SHT_NAME[80]; + +#ifdef _PRINT_IT +char* pSHT ( int sh_type ) +{ + switch (sh_type) { + case SHT_NULL : strcpy(SHT_NAME, "SHT_NULL"); break; + case SHT_PROGBITS : strcpy(SHT_NAME, "SHT_PROGBITS"); break; + case SHT_SYMTAB : strcpy(SHT_NAME, "SHT_SYMTAB"); break; + case SHT_STRTAB : strcpy(SHT_NAME, "SHT_STRTAB"); break; + case SHT_RELA : strcpy(SHT_NAME, "SHT_RELA"); break; + case SHT_HASH : strcpy(SHT_NAME, "SHT_HASH"); break; + case SHT_DYNAMIC : strcpy(SHT_NAME, "SHT_DYNAMIC"); break; + case SHT_NOTE : strcpy(SHT_NAME, "SHT_NOTE"); break; + case SHT_NOBITS : strcpy(SHT_NAME, "SHT_NOBITS"); break; + case SHT_REL : strcpy(SHT_NAME, "SHT_REL"); break; + case SHT_SHLIB : strcpy(SHT_NAME, "SHT_SHLIB"); break; + case SHT_DYNSYM : strcpy(SHT_NAME, "SHT_DYNSYM"); break; + case SHT_UNKNOWN12 : strcpy(SHT_NAME, "SHT_UNKNOWN12"); break; + case SHT_UNKNOWN13 : strcpy(SHT_NAME, "SHT_UNKNOWN13"); break; + case SHT_INIT_ARRAY : strcpy(SHT_NAME, "SHT_INIT_ARRAY"); break; + case SHT_FINI_ARRAY : strcpy(SHT_NAME, "SHT_FINI_ARRAY"); break; + case SHT_PREINIT_ARRAY: strcpy(SHT_NAME, "SHT_PREINIT_ARRAY"); break; + case SHT_GROUP : strcpy(SHT_NAME, "SHT_GROUP"); break; + case SHT_SYMTAB_SHNDX : strcpy(SHT_NAME, "SHT_SYMTAB_SHNDX"); break; + case SHT_NUM : strcpy(SHT_NAME, "SHT_NUM"); break; + default: strcpy(SHT_NAME, "???"); break; + } + return &SHT_NAME[0]; +} +#endif + + + +int elfsplitter (unsigned int base, unsigned int size) +{ + unsigned char *buf; + unsigned int length,d,i,gp_ptr=0; + unsigned int bss_start=0,bss_end=0; + unsigned int StringSectionOffset; + unsigned int StringSectionOffsetFound = 0; + + char tmp[6] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }; + unsigned int j, k; + int m; + ElfHeader *elfHeader; + Elf32_Phdr *elfProgram; + Elf32_Shdr *elfSection; + + buf=(unsigned char*)base; + +#ifdef DEBUG + printf("Debug: size = %d\n",size); +#endif + + elfHeader=(ElfHeader*)buf; + +#ifdef DEBUG +// printf("Call strncpy\n"); +// strncpy(tmp, (char*)elfHeader->e_ident+1, 3); +// printf("Debug: elfHeader->e_ident= %s\n",tmp); + printf("Debug: elfHeader->e_machine= 0x%x\n",elfHeader->e_machine); +#endif + + + if(strncmp((char*)elfHeader->e_ident+1,"ELF",3)) { + + printf("ERROR: Not an ELF file.\n"); + return(1); + } + + if(elfHeader->e_machine != 40) { + printf("ERROR: ELF file not targetting correct processor type\n"); + return(1); + } + +#ifdef DEBUG + printf("Debug: elfHeader->e_phnum=0x%x\n",elfHeader->e_phnum); +#endif + + for(i=0;ie_phnum;++i) { + elfProgram = (Elf32_Phdr*)(buf+elfHeader->e_phoff+elfHeader->e_phentsize*i); + length=elfProgram->p_vaddr+elfProgram->p_memsz; +#ifdef DEBUG + printf("Debug: Program Length=0x%x\n",length); +#endif + } + + + /* Find the location in the file of the string section + containing the section names + */ + for(i=0;ie_shnum;++i) { + elfSection=(Elf32_Shdr*)(buf+elfHeader->e_shoff+elfHeader->e_shentsize*i); + if (elfSection->sh_type == SHT_STRTAB && !StringSectionOffsetFound) { + StringSectionOffset = elfSection->sh_offset; + StringSectionOffsetFound = 1; + } + } + + for(i=0;ie_shnum;++i) { + elfSection=(Elf32_Shdr*)(buf+elfHeader->e_shoff+elfHeader->e_shentsize*i); + +#ifdef _PRINT_IT + if (elfSection->sh_type != SHT_NULL) { + printf("Section name %s\n", (char*)(buf+StringSectionOffset+elfSection->sh_name)); + printf("Type %s, Size 0x%x, Start address 0x%08x, File offset 0x%x\n", + pSHT(elfSection->sh_type), + elfSection->sh_size, + elfSection->sh_addr, + elfSection->sh_offset); + } +#endif + + /* section with non-zero bits, can be either text or data */ + if (elfSection->sh_type == SHT_PROGBITS && elfSection->sh_size != 0) { + for (j=0; jsh_size; j=j+4) { + k = j + elfSection->sh_offset; + *(unsigned int*)(elfSection->sh_addr + j) = + (buf[k+3] << 24) | (buf[k+2] << 16) | (buf[k+1] << 8) | (buf[k+0]); +#ifdef _PRINT_IT + if (j%0x1000 == 0) { + printf("@%08x %02x%02x%02x%02x\n", + (elfSection->sh_addr + j), /* use word addresses */ + buf[k+3], buf[k+2], buf[k+1], buf[k+0]); + } +#endif + } + } + + if (elfSection->sh_type == SHT_NOBITS && elfSection->sh_size != 0) { +#ifdef _PRINT_IT + printf("// .bss Dump Zeros\n"); +#endif + for (j=elfSection->sh_offset; jsh_offset+elfSection->sh_size; j=j+4) { + *(unsigned int*) (j + elfSection->sh_addr - elfSection->sh_offset) = 0; +#ifdef _PRINT_IT + printf("@%08x 00000000\n", + (j + elfSection->sh_addr - elfSection->sh_offset)); /* use word addresses */ +#endif + } + } + + + } + + return 0; +} Index: trunk/sw/boot-loader-serial/crc16.c =================================================================== --- trunk/sw/boot-loader-serial/crc16.c (nonexistent) +++ trunk/sw/boot-loader-serial/crc16.c (revision 65) @@ -0,0 +1,75 @@ +/* + * Copyright 2001-2010 Georges Menie (www.menie.org) + * 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 following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the University of California, Berkeley nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS 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. + */ + +#include "crc16.h" + +/* CRC16 implementation acording to CCITT standards */ + +static const unsigned short crc16tab[256]= { + 0x0000,0x1021,0x2042,0x3063,0x4084,0x50a5,0x60c6,0x70e7, + 0x8108,0x9129,0xa14a,0xb16b,0xc18c,0xd1ad,0xe1ce,0xf1ef, + 0x1231,0x0210,0x3273,0x2252,0x52b5,0x4294,0x72f7,0x62d6, + 0x9339,0x8318,0xb37b,0xa35a,0xd3bd,0xc39c,0xf3ff,0xe3de, + 0x2462,0x3443,0x0420,0x1401,0x64e6,0x74c7,0x44a4,0x5485, + 0xa56a,0xb54b,0x8528,0x9509,0xe5ee,0xf5cf,0xc5ac,0xd58d, + 0x3653,0x2672,0x1611,0x0630,0x76d7,0x66f6,0x5695,0x46b4, + 0xb75b,0xa77a,0x9719,0x8738,0xf7df,0xe7fe,0xd79d,0xc7bc, + 0x48c4,0x58e5,0x6886,0x78a7,0x0840,0x1861,0x2802,0x3823, + 0xc9cc,0xd9ed,0xe98e,0xf9af,0x8948,0x9969,0xa90a,0xb92b, + 0x5af5,0x4ad4,0x7ab7,0x6a96,0x1a71,0x0a50,0x3a33,0x2a12, + 0xdbfd,0xcbdc,0xfbbf,0xeb9e,0x9b79,0x8b58,0xbb3b,0xab1a, + 0x6ca6,0x7c87,0x4ce4,0x5cc5,0x2c22,0x3c03,0x0c60,0x1c41, + 0xedae,0xfd8f,0xcdec,0xddcd,0xad2a,0xbd0b,0x8d68,0x9d49, + 0x7e97,0x6eb6,0x5ed5,0x4ef4,0x3e13,0x2e32,0x1e51,0x0e70, + 0xff9f,0xefbe,0xdfdd,0xcffc,0xbf1b,0xaf3a,0x9f59,0x8f78, + 0x9188,0x81a9,0xb1ca,0xa1eb,0xd10c,0xc12d,0xf14e,0xe16f, + 0x1080,0x00a1,0x30c2,0x20e3,0x5004,0x4025,0x7046,0x6067, + 0x83b9,0x9398,0xa3fb,0xb3da,0xc33d,0xd31c,0xe37f,0xf35e, + 0x02b1,0x1290,0x22f3,0x32d2,0x4235,0x5214,0x6277,0x7256, + 0xb5ea,0xa5cb,0x95a8,0x8589,0xf56e,0xe54f,0xd52c,0xc50d, + 0x34e2,0x24c3,0x14a0,0x0481,0x7466,0x6447,0x5424,0x4405, + 0xa7db,0xb7fa,0x8799,0x97b8,0xe75f,0xf77e,0xc71d,0xd73c, + 0x26d3,0x36f2,0x0691,0x16b0,0x6657,0x7676,0x4615,0x5634, + 0xd94c,0xc96d,0xf90e,0xe92f,0x99c8,0x89e9,0xb98a,0xa9ab, + 0x5844,0x4865,0x7806,0x6827,0x18c0,0x08e1,0x3882,0x28a3, + 0xcb7d,0xdb5c,0xeb3f,0xfb1e,0x8bf9,0x9bd8,0xabbb,0xbb9a, + 0x4a75,0x5a54,0x6a37,0x7a16,0x0af1,0x1ad0,0x2ab3,0x3a92, + 0xfd2e,0xed0f,0xdd6c,0xcd4d,0xbdaa,0xad8b,0x9de8,0x8dc9, + 0x7c26,0x6c07,0x5c64,0x4c45,0x3ca2,0x2c83,0x1ce0,0x0cc1, + 0xef1f,0xff3e,0xcf5d,0xdf7c,0xaf9b,0xbfba,0x8fd9,0x9ff8, + 0x6e17,0x7e36,0x4e55,0x5e74,0x2e93,0x3eb2,0x0ed1,0x1ef0 +}; + +unsigned short crc16_ccitt(const void *buf, int len) +{ + register int counter; + register unsigned short crc = 0; + for( counter = 0; counter < len; counter++) + crc = (crc<<8) ^ crc16tab[((crc>>8) ^ *(char *)buf++)&0x00FF]; + return crc; +} + Index: trunk/sw/boot-loader-serial/crc16.h =================================================================== --- trunk/sw/boot-loader-serial/crc16.h (nonexistent) +++ trunk/sw/boot-loader-serial/crc16.h (revision 65) @@ -0,0 +1,33 @@ +/* + * Copyright 2001-2010 Georges Menie (www.menie.org) + * 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 following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the University of California, Berkeley nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS 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. + */ + +#ifndef _CRC16_H_ +#define _CRC16_H_ + +unsigned short crc16_ccitt(const void *buf, int len); + +#endif /* _CRC16_H_ */ Index: trunk/sw/boot-loader-serial/sections.lds =================================================================== --- trunk/sw/boot-loader-serial/sections.lds (nonexistent) +++ trunk/sw/boot-loader-serial/sections.lds (revision 65) @@ -0,0 +1,80 @@ +/*---------------------------------------------------------------- +// // +// sections.lds // +// // +// This file is part of the Amber project // +// http://www.opencores.org/project,amber // +// // +// Description // +// Sections linker file for the boot-loader application. // +// Note that the address map starts at 0x0 because this is // +// a stand-alone application . // +// // +// Author(s): // +// - Conor Santifort, csantifort.amber@gmail.com // +// // +////////////////////////////////////////////////////////////////// +// // +// Copyright (C) 2010 Authors and OPENCORES.ORG // +// // +// This source file may be used and distributed without // +// restriction provided that this copyright statement is not // +// removed from the file and that any derivative work contains // +// the original copyright notice and the associated disclaimer. // +// // +// This source file is free software; you can redistribute it // +// and/or modify it under the terms of the GNU Lesser General // +// Public License as published by the Free Software Foundation; // +// either version 2.1 of the License, or (at your option) any // +// later version. // +// // +// This source 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 Lesser General Public License for more // +// details. // +// // +// You should have received a copy of the GNU Lesser General // +// Public License along with this source; if not, download it // +// from http://www.opencores.org/lgpl.shtml // +// // +----------------------------------------------------------------*/ + +ENTRY(main) + + +SECTIONS { + + . = 0x00000000; + + .start : + { + start*(.text) + } + + .text : + { + *(.text) + } + + .rodata : + { + *(.rodata) + } + + .data : + { + *(.data) + } + + .bss : + { + *(.bss) + } + + .stack : + { + __stack = . ; + } + +} Index: trunk/sw/boot-loader-serial/xmodem.c =================================================================== --- trunk/sw/boot-loader-serial/xmodem.c (nonexistent) +++ trunk/sw/boot-loader-serial/xmodem.c (revision 65) @@ -0,0 +1,219 @@ +/* + * Copyright 2001-2010 Georges Menie (www.menie.org) + * 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 following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the University of California, Berkeley nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS 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. + */ + +/* this code needs standard functions memcpy() and memset() + and input/output functions _inbyte() and _outbyte(). + + the prototypes of the input/output functions are: + int _inbyte(unsigned short timeout); // msec timeout + void _outbyte(int c); + + */ + +#include "crc16.h" +#include "boot-loader.h" + +/* +#define DEBUG_XMODEM +*/ + +#define SOH 0x01 +#define STX 0x02 +#define EOT 0x04 +#define ACK 0x06 +#define NAK 0x15 +#define CAN 0x18 +#define CTRLZ 0x1A + + +#define MAXRETRANS 25 + +#ifdef DEBUG_XMODEM +char* dbuf; +#endif + + +static int check(int crc, const unsigned char *buf, int sz) +{ + if (crc) { + unsigned short crc = crc16_ccitt(buf, sz); + unsigned short tcrc = (buf[sz]<<8)+buf[sz+1]; + if (crc == tcrc) { + #ifdef DEBUG_XMODEM + dbuf += sprintf(dbuf, "cok1\n"); + #endif + return 1; + } + } + else { + int i; + unsigned char cks = 0; + for (i = 0; i < sz; ++i) { + cks += buf[i]; + } + if (cks == buf[sz]) { + #ifdef DEBUG_XMODEM + dbuf += sprintf(dbuf, "cok2\n"); + #endif + return 1; + } + } + + #ifdef DEBUG_XMODEM + dbuf += sprintf(dbuf, "cer\n"); + #endif + return 0; +} + + +static void flushinput(void) +{ + while (_inbyte(DLY_300MS) >= 0) ; +} + + +int xmodemReceive(unsigned char *dest, int destsz) +{ + unsigned char xbuff[1030]; /* 1024 for XModem 1k + 3 head chars + 2 crc + nul */ + unsigned char *p; + int bufsz, crc = 0; + unsigned char trychar = 'C'; + unsigned char packetno = 1; + int i, c, len = 0; + int retry, retrans = MAXRETRANS; + unsigned int wait; + + #ifdef DEBUG_XMODEM + dbuf = (char *) DEBUG_BUF; + dbuf += sprintf(dbuf, "XR\n"); + #endif + + for(;;) { + for( retry = 0; retry < 80; ++retry) { + if (trychar) _outbyte(trychar); + if ((c = _inbyte(DLY_1S)) >= 0) { + switch (c) { + case SOH: + bufsz = 128; + #ifdef DEBUG_XMODEM + dbuf += sprintf(dbuf, "128\n"); + #endif + goto start_recv; + case STX: + bufsz = 1024; + #ifdef DEBUG_XMODEM + dbuf += sprintf(dbuf, "1k\n"); + #endif + goto start_recv; + case EOT: + _outbyte(ACK); + flushinput(); + #ifdef DEBUG_XMODEM + dbuf += sprintf(dbuf, "EOT\n"); + #endif + return len; /* normal end */ + case CAN: + #ifdef DEBUG_XMODEM + dbuf += sprintf(dbuf, "CAN\n"); + #endif + if ((c = _inbyte(DLY_1S)) == CAN) { + flushinput(); + _outbyte(ACK); + return -1; /* canceled by remote */ + } + break; + default: + break; + } + } + } + if (trychar == 'C') { trychar = NAK; continue; } + flushinput(); + _outbyte(CAN); + _outbyte(CAN); + _outbyte(CAN); + return -2; /* sync error */ + + start_recv: + #ifdef DEBUG_XMODEM + dbuf += sprintf(dbuf, "sr\n"); + #endif + if (trychar == 'C') crc = 1; + trychar = 0; + p = xbuff; + *p++ = c; + for (i = 0; i < (bufsz+(crc?1:0)+3); ++i) { + if ((c = _inbyte(DLY_1S)) < 0) goto reject; + *p++ = c; + } + + + if (xbuff[1] == (unsigned char)(~xbuff[2]) && + (xbuff[1] == packetno || xbuff[1] == (unsigned char)packetno-1) && + check(crc, &xbuff[3], bufsz)) { + if (xbuff[1] == packetno) { + register int count = destsz - len; + if (count > bufsz) count = bufsz; + if (count > 0) { + memcpy (&dest[len], &xbuff[3], count); + len += count; + } + ++packetno; + retrans = MAXRETRANS+1; + } + if (--retrans <= 0) { + flushinput(); + _outbyte(CAN); + _outbyte(CAN); + _outbyte(CAN); + #ifdef DEBUG_XMODEM + dbuf += sprintf(dbuf, "mx e\n"); + #endif + return -3; /* too many retry error */ + } + _outbyte(ACK); + continue; + + + } + else { + #ifdef DEBUG_XMODEM + dbuf += sprintf(dbuf, "bad\n"); + #endif + } + + reject: + #ifdef DEBUG_XMODEM + dbuf += sprintf(dbuf, "rj %d\n", c); + #endif + + flushinput(); + _outbyte(NAK); + } +} + + Index: trunk/sw/boot-loader-serial/README.txt =================================================================== --- trunk/sw/boot-loader-serial/README.txt (nonexistent) +++ trunk/sw/boot-loader-serial/README.txt (revision 65) @@ -0,0 +1,2 @@ +The boot loader must fit in the boot memory, which is 8KBytes. +Keep an eye on the .mem file to make sure it doesn't get larger than that. Index: trunk/sw/boot-loader-serial/Makefile =================================================================== --- trunk/sw/boot-loader-serial/Makefile (nonexistent) +++ trunk/sw/boot-loader-serial/Makefile (revision 65) @@ -0,0 +1,57 @@ +# ---------------------------------------------------------------- +# // +# Makefile for the boot-loader application. // +# // +# This file is part of the Amber project // +# http://www.opencores.org/project,amber // +# // +# Description // +# Simple makefile that defines the sources and target. // +# Uses the common.mk common makefile script. // +# // +# Author(s): // +# - Conor Santifort, csantifort.amber@gmail.com // +# // +#/ /////////////////////////////////////////////////////////////// +# // +# Copyright (C) 2010 Authors and OPENCORES.ORG // +# // +# This source file may be used and distributed without // +# restriction provided that this copyright statement is not // +# removed from the file and that any derivative work contains // +# the original copyright notice and the associated disclaimer. // +# // +# This source file is free software; you can redistribute it // +# and/or modify it under the terms of the GNU Lesser General // +# Public License as published by the Free Software Foundation; // +# either version 2.1 of the License, or (at your option) any // +# later version. // +# // +# This source 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 Lesser General Public License for more // +# details. // +# // +# You should have received a copy of the GNU Lesser General // +# Public License along with this source; if not, download it // +# from http://www.opencores.org/lgpl.shtml // +# // +# ---------------------------------------------------------------- +# Assembly source files + +SRC = boot-loader.c start.S crc16.c xmodem.c elfsplitter.c +DEP = boot-loader.h fpga-version.h +TGT = boot-loader.elf +LDS = sections.lds + +USE_MINI_LIBC = 1 + +# Needs to fit into the boot memory on the FPGA - 8kBytes +# so size is important +MIN_SIZE = 1 + +all : debug + ../tools/check_mem_size.sh $(MEM) "@000020" + +include ../include/common.mk Index: trunk/sw/boot-loader-serial =================================================================== --- trunk/sw/boot-loader-serial (nonexistent) +++ trunk/sw/boot-loader-serial (revision 65)
trunk/sw/boot-loader-serial Property changes : Added: svn:ignore ## -0,0 +1,5 ## +*.map +*.mem +*.dis +*.elf +*_memparams*.v

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.