コード例 #1
0
ファイル: main.c プロジェクト: qiaozhou/usbdm-flash-routines
//! Main C entry point
//! 
//! Assumes ramBuffer is set up beforehand
//!
void entry(void) {
   FlashData_t *flashData;  // Handle on programming data
   
   // Disable COP
   *(gFlashProgramHeader.soptAddress+0x0A) = 0x00;
   
   // Handle on programming data
   flashData = gFlashProgramHeader.flashData;

   // Indicate not complete
   flashData->flags &= ~IS_COMPLETE;
   
   // No errors so far
   flashData->errorCode = FLASH_ERR_OK;
   
   if (flashData->controller == NULL) {
      setErrorCode(FLASH_ERR_ILLEGAL_PARAMS);
   }
   // Clear invalid/unused address bits
   // A23 is used for Flash block number
   flashData->address &= 0x008FFFFFUL;
   
   initFlash(flashData);
   eraseFlashBlock(flashData);
   programPartition(flashData) ;
   eraseRange(flashData);
   blankCheckRange(flashData);
   programRange(flashData);
   verifyRange(flashData);
   
   // Indicate completed
   setErrorCode(FLASH_ERR_OK);
}
コード例 #2
0
/**
 * Main C entry point
 *
 * Assumes ramBuffer is set up beforehand
 */
void entry(void) {
   // Set the interrupt vector table position
   SCB_VTOR = (uint32_t)__vector_table;
   
   // Handle on programming data
   FlashData_t *flashData = gFlashProgramHeader.flashData;

   initFlash(flashData);
   eraseFlashBlock(flashData);
   programPartition(flashData) ;
   eraseRange(flashData);
   blankCheckRange(flashData);
   programRange(flashData);
   verifyRange(flashData);
   
#ifndef DEBUG
   // Indicate completed & stop
   setErrorCode(FLASH_ERR_OK);
#endif
}
コード例 #3
0
ファイル: cachetest.c プロジェクト: ZiCog/pi-propeller-load
int main(void)
{
    extern char TESTDRIVER[];
    
    //LED_OFF();
    //DIRA |= LED_MASK;

    cache_line_mask = cacheStart(TESTDRIVER, &cache_mbox, cache, CACHE_CONFIG1, CACHE_CONFIG2, CACHE_CONFIG3, CACHE_CONFIG4);
    
    printf("mbox  %08x\n", (uint32_t)&cache_mbox);
    printf("cache %08x\n", (uint32_t)cache);
    printf("buf   %08x\n", (uint32_t)buf);
    
#ifdef FLASH_TEST

{
    int start, i, j;
    
    printf("Flash test\n");
    
    srand(CNT);
    start = rand();
    printf("Starting with %08x\n", start);
    for (i = 0, j = start; i < BUF_SIZE; ++i)
        buf[i] = j++;
    eraseFlashBlock(0);
    writeFlashBlock(0, buf, sizeof(buf));
    memset(buf, 0, sizeof(buf));
    readBlock(ROM_BASE, buf, sizeof(buf));
    for (i = 0, j = start; i < BUF_SIZE; ++i) {
        if (buf[i] != j++)
            printf("%08x: expected %08x, found %08x\n", i, j - 1, buf[i]);
    }

    printf("done\n");
}

#endif

#ifdef BIG_FLASH_TEST

{
    uint32_t addr, startValue, value;
    int i, j;
    
    printf("Big flash test\n");

    addr = ROM_BASE;
    srand(CNT);
    startValue = value = addr + rand();
    printf("Start value %08x\n", startValue);
    printf("Filling flash\n");
    for (j = 0; j < BUF_COUNT; ++j) {
        uint32_t startAddr = addr;
        for (i = 0; i < BUF_SIZE; ++i, addr += sizeof(uint32_t))
            buf[i] = value++;
        if ((startAddr & BLOCK_MASK_4K) == 0) {
            //printf("Erasing %08x\n", ROM_BASE + startAddr);
            eraseFlashBlock(startAddr - ROM_BASE);
        }
        //printf("Writing %08x\n", ROM_BASE + startAddr);
        writeFlashBlock(startAddr - ROM_BASE, buf, sizeof(buf));
    }
    
    printf("Checking flash\n");
    addr = ROM_BASE;
    value = startValue;
    for (j = 0; j < BUF_COUNT; ++j) {
        //printf("Reading %08x\n", addr);
        readBlock(addr, buf, sizeof(buf));
        for (i = 0; i < BUF_SIZE; ++i, addr += sizeof(uint32_t))
            if (buf[i] != value++)
                printf("%08x: expected %08x, found %08x\n", addr, value - 1, buf[i]);
    }

    addr = ROM_BASE;
    value = startValue;
    printf("Filling flash inverted\n");
    for (j = 0; j < BUF_COUNT; ++j) {
        uint32_t startAddr = addr;
        for (i = 0; i < BUF_SIZE; ++i, addr += sizeof(uint32_t))
            buf[i] = ~value++;
        if ((startAddr & BLOCK_MASK_4K) == 0) {
            //printf("Erasing %08x\n", ROM_BASE + startAddr);
            eraseFlashBlock(startAddr - ROM_BASE);
        }
        //printf("Writing %08x\n", ROM_BASE + startAddr);
        writeFlashBlock(startAddr - ROM_BASE, buf, sizeof(buf));
    }
    
    addr = ROM_BASE;
    value = startValue;
    printf("Checking flash inverted\n");
    for (j = 0; j < BUF_COUNT; ++j) {
        //printf("Reading %08x\n", addr);
        readBlock(addr, buf, sizeof(buf));
        for (i = 0; i < BUF_SIZE; ++i, addr += sizeof(uint32_t))
            if (buf[i] != ~value++)
                printf("%08x: expected %08x, found %08x\n", addr, ~(value - 1), buf[i]);
    }

    printf("done\n");
}

#endif

#ifdef RAM_TEST

{
    int i;

    printf("RAM test\n");
    
    for (i = 0; i < BUF_SIZE; ++i)
        buf[i] = 0xbeef0000 + i;
    writeBlock(RAM_BASE, buf, sizeof(buf));
    
    memset(buf, 0, sizeof(buf));
    
    readBlock(RAM_BASE, buf, sizeof(buf));
    for (i = 0; i < BUF_SIZE; ++i)
        printf("buf[%d] = %08x\n", i, buf[i]);

    printf("done\n");
}

#endif
        
#ifdef BIG_RAM_TEST

{
    uint32_t addr, startValue, value;
    int i, j;
    
    printf("Big RAM test\n");

    addr = RAM_BASE;
    srand(CNT);
    startValue = value = addr + rand();
    printf("Start value %08x\n", startValue);
    printf("Filling RAM\n");
    for (j = 0; j < BUF_COUNT; ++j) {
        uint32_t startAddr = addr;
        for (i = 0; i < BUF_SIZE; ++i, addr += sizeof(uint32_t))
            buf[i] = value++;
        //printf("Writing %08x\n", startAddr);
        writeBlock(startAddr, buf, sizeof(buf));
    }
    
    printf("Checking RAM\n");
    addr = RAM_BASE;
    value = startValue;
    for (j = 0; j < BUF_COUNT; ++j) {
        //printf("Reading %08x\n", addr);
        readBlock(addr, buf, sizeof(buf));
        for (i = 0; i < BUF_SIZE; ++i, addr += sizeof(uint32_t))
            if (buf[i] != value++)
                printf("%08x: expected %08x, found %08x\n", addr, value - 1, buf[i]);
    }

    printf("Filling RAM inverted\n");
    addr = RAM_BASE;
    value = startValue;
    for (j = 0; j < BUF_COUNT; ++j) {
        uint32_t startAddr = addr;
        for (i = 0; i < BUF_SIZE; ++i, addr += sizeof(uint32_t))
            buf[i] = ~value++;
        //printf("Writing %08x\n", startAddr);
        writeBlock(startAddr, buf, sizeof(buf));
    }
    
    printf("Checking RAM inverted\n");
    addr = RAM_BASE;
    value = startValue;
    for (j = 0; j < BUF_COUNT; ++j) {
        //printf("Reading %08x\n", addr);
        readBlock(addr, buf, sizeof(buf));
        for (i = 0; i < BUF_SIZE; ++i, addr += sizeof(uint32_t))
            if (buf[i] != ~value++)
                printf("%08x: expected %08x, found %08x\n", addr, ~(value - 1), buf[i]);
    }

    printf("done\n");
}

#endif

#ifdef CACHE_TEST

{
    int i;
    
    printf("cache test\n");
    
    for (i = 0; i < 32*1024; i += sizeof(uint32_t))
        writeLong(RAM_BASE + i, i);
        
    for (i = 0; i < 32*1024; i += sizeof(uint32_t)) {
        uint32_t data = readLong(RAM_BASE + i);
        if (data != i)
            printf("%08x: expected %08x, found %08x\n", RAM_BASE + i, i, data);
    }

    printf("done\n");
}
    
#endif

    return 0;
}