LOGIN   :::   RECOVER PASS   :::   GET ACCOUNT    
Browse
  • Projects
  • Code (CVS)
  • Forums
  • News
  • Articles
  • Polls
  •  
    OpenCores
  • FAQ
  • CVS HowTo
  • Mission
  • Media
  • Tools
  • Advertise
  • Mirrors
  • Logos
  • Contact us
  • Job Opportunity
  •  
    Tools
  • Search
      
  • Download Cores (CVSGet)
  •  
    More
  • Wishbone
  • Perlilog
  • EDA tools
  • OpenTech CD
  •  
    Navigation: All forums > Cvs-checkins > Message List > Message Post

    Message

    Reply | Reply all
    Date Prev | Date Next | Thread Prev | Thread Next Date Index | Thread Index

    From: cvs at opencores.org<cvs@o...>
    Date: Mon Jan 28 03:38:03 CET 2008
    Subject: [cvs-checkins] MODIFIED: mlite ...
    Top
    Date: 00/08/01 28:03:38

    Modified: mlite/tools bootldr.c
    Log:
    Support boot from flash


    Revision Changes Path
    1.4 mlite/tools/bootldr.c

    http://www.opencores.org/cvsweb.shtml/mlite/tools/bootldr.c.diff?r1=1.3&r2=1.4

    (In the diff below, changes in quantity of whitespace are not shown.)

    Index: bootldr.c
    ===================================================================
    RCS file: /cvsroot/rhoads/mlite/tools/bootldr.c,v
    retrieving revision 1.3
    retrieving revision 1.4
    diff -u -b -r1.3 -r1.4
    --- bootldr.c 15 Dec 2007 16:21:16 -0000 1.3
    +++ bootldr.c 28 Jan 2008 02:38:03 -0000 1.4
    @@ -1,4 +1,14 @@
    -/* bootldr.c */
    +/*--------------------------------------------------------------------
    + * TITLE: Plasma Bootloader
    + * AUTHOR: Steve Rhoads (rhoadss@y...)
    + * DATE CREATED: 12/17/05
    + * FILENAME: bootldr.c
    + * PROJECT: Plasma CPU core
    + * COPYRIGHT: Software placed into the public domain by the author.
    + * Software 'as is' without warranty. Author liable for nothing.
    + * DESCRIPTION:
    + * Plasma bootloader.
    + *--------------------------------------------------------------------*/
    #include "plasma.h"

    #define MemoryRead(A) (*(volatile unsigned long*)(A))
    @@ -11,6 +21,45 @@
    extern int DdrInit(void);

    typedef void (*FuncPtr)(void);
    +typedef unsigned long uint32;
    +typedef unsigned short uint16;
    +
    +
    +void FlashRead(uint16 *dst, uint32 byteOffset, int bytes)
    +{
    + volatile uint32 *ptr=(uint32*)(FLASH_BASE + (byteOffset << 1));
    + *ptr = 0xff; //read mode
    + while(bytes > 0)
    + {
    + *dst++ = (uint16)*ptr++;
    + bytes -= 2;
    + }
    +}
    +
    +
    +void FlashWrite(uint16 *src, uint32 byteOffset, int bytes)
    +{
    + volatile uint32 *ptr=(uint32*)(FLASH_BASE + (byteOffset << 1));
    + while(bytes > 0)
    + {
    + *ptr = 0x40; //write mode
    + *ptr++ = *src++; //write data
    + while((*ptr & 0x80) == 0) //check status
    + ;
    + bytes -= 2;
    + }
    +}
    +
    +
    +void FlashErase(uint32 byteOffset)
    +{
    + volatile uint32 *ptr=(uint32*)(FLASH_BASE + (byteOffset << 1));
    + *ptr = 0x20; //erase block
    + *ptr = 0xd0; //confirm
    + while((*ptr & 0x80) == 0) //check status
    + ;
    +}
    +

    char *xtoa(unsigned long num)
    {
    @@ -26,6 +75,7 @@
    return buf;
    }

    +
    unsigned long getnum(void)
    {
    int i;
    @@ -62,6 +112,7 @@
    return value;
    }

    +
    int main(void)
    {
    int i, j, ch;
    @@ -76,6 +127,14 @@
    puts(" ");
    puts(__TIME__); puts(":\n"); + MemoryWrite(FLASH_BASE, 0xff); //read mode + if((MemoryRead(GPIOA_IN) & 1) && (MemoryRead(FLASH_BASE) & 0xffff) == 0x3c1c) + { + puts("Boot from flash\n"); + FlashRead((uint16*)RAM_EXTERNAL_BASE, 0, 1024*128); + funcPtr = (FuncPtr)RAM_EXTERNAL_BASE; + funcPtr(); + } for(;;) { puts("\nWaiting for binary image linked at 0x10000000\n"); @@ -89,6 +148,7 @@ puts("7. Raw memory write\n"); puts("8. Checksum\n"); puts("9. Dump\n"); + puts("F. Copy 128KB from DDR to flash\n"); puts("> "); ch = getch(); address = 0; @@ -132,8 +192,6 @@ case '6': puts("\nCount in hex> "); count = getnum(); - //puts(xtoa(count)); - //puts("\n"); for(i = 0; i < count; ++i) { ch = *(unsigned char*)(address + i); @@ -143,8 +201,6 @@ case '7': puts("\nCount in hex> "); count = getnum(); - //puts(xtoa(count)); - //putchar('\n'); for(i = 0; i < count; ++i) { ch = getch(); @@ -176,6 +232,10 @@ } puts("\r\n"); break; + case 'F': + FlashErase(0); + FlashWrite((uint16*)RAM_EXTERNAL_BASE, 0, 1024*128); + break; case 0x3c: //raw test.bin file ptr1 = (unsigned char*)0x10000000; for(i = 0; i < 1024*1024; ++i)

     
    Copyright (c) 1999 OPENCORES.ORG. All rights reserved.