From: Erik M. <er...@us...> - 2001-07-18 23:49:45
|
Update of /cvsroot/blob/blob/src In directory usw-pr-cvs1:/tmp/cvs-serv26212/src Modified Files: Tag: blob_1_0_9_hack flash.c main.c start.S Log Message: - clean first MB of memory from start.S (this should help to get a .bss segment) - download, flash, and reload now know about the "blob" target so you can upgrade blob without a JTAG dongle - new command "reboot" to be able to reboot blob after a new version was flashed Index: flash.c =================================================================== RCS file: /cvsroot/blob/blob/src/flash.c,v retrieving revision 1.1.1.1.2.1 retrieving revision 1.1.1.1.2.2 diff -u -r1.1.1.1.2.1 -r1.1.1.1.2.2 --- flash.c 2001/07/08 22:34:14 1.1.1.1.2.1 +++ flash.c 2001/07/18 23:49:41 1.1.1.1.2.2 @@ -132,12 +132,21 @@ char *thisBlock; int numBlocks, i; - if(which == blKernel) { + switch(which) { + case blBlob: + thisBlock = (char *)BLOB_START; + numBlocks = NUM_BLOB_BLOCKS; + break; + + case blKernel: thisBlock = (char *)KERNEL_START; numBlocks = NUM_KERNEL_BLOCKS; - } else { + break; + + case blRamdisk: thisBlock = (char *)INITRD_START; numBlocks = NUM_INITRD_BLOCKS; + break; } for(i = 0; i < numBlocks; i++, thisBlock += MAIN_BLOCK_SIZE) { @@ -170,14 +179,22 @@ if(length & 0x03) length += 0x04; length &= ~((u32) 0x03); - - if(type == blKernel) { + + switch(type) { + case blBlob: + flashBase = (u32 *)BLOB_START; + maxLength = BLOB_LEN; + break; + + case blKernel: flashBase = (u32 *)KERNEL_START; maxLength = KERNEL_LEN; - } - else { + break; + + case blRamdisk: flashBase = (u32 *)INITRD_START; maxLength = INITRD_LEN; + break; } if(length > maxLength) Index: main.c =================================================================== RCS file: /cvsroot/blob/blob/src/main.c,v retrieving revision 1.1.1.1.2.6 retrieving revision 1.1.1.1.2.7 diff -u -r1.1.1.1.2.6 -r1.1.1.1.2.7 --- main.c 2001/07/16 21:40:41 1.1.1.1.2.6 +++ main.c 2001/07/18 23:49:41 1.1.1.1.2.7 @@ -46,6 +46,9 @@ #include "util.h" #include "uucodec.h" +/* Tell SA-1100.h to shut up; we're including it anyway. Nyah nyah ;-) */ +#define __ASM_ARCH_HARDWARE_H +#include <asm/arch-sa1100/SA-1100.h> @@ -64,6 +67,9 @@ int ramdiskSize; blockSource ramdiskType; + int blobSize; + blockSource blobType; + u32 blockSize; eBauds downloadSpeed; @@ -81,6 +87,13 @@ void ResetTerminal(void); void Reload(char *commandline, blobStatus *status); void PrintSerialSpeed(eBauds speed); +void Reboot(void); + +/* Hmm, the compiler complains that the 'noreturn' function + * returns. Looks like a compiler bug, should test with gcc-3.0 to see + * if it got fixed -- Erik + */ +/* void Reboot(void) __attribute__ ((noreturn)) ; */ @@ -125,6 +138,7 @@ /* Load kernel and ramdisk from flash to RAM */ + Reload("blob", &status); Reload("kernel", &status); Reload("ramdisk", &status); @@ -178,6 +192,8 @@ Flash(commandline + 6, &status); } else if(MyStrNCmp(commandline, "help", 4) == 0) { PrintHelp(); + } else if(MyStrNCmp(commandline, "reboot", 6) == 0) { + Reboot(); } else if(MyStrNCmp(commandline, "reload ", 7) == 0) { Reload(commandline + 7, &status); } else if(MyStrNCmp(commandline, "reset", 5) == 0) { @@ -258,7 +274,13 @@ int bufLen; int *numRead = 0; - if(MyStrNCmp(commandline, "kernel", 6) == 0) { + if(MyStrNCmp(commandline, "blob", 4) == 0) { + /* download blob */ + startAddress = BLOB_RAM_BASE; + bufLen = status->blockSize - BLOB_BLOCK_OFFSET; + numRead = &status->blobSize; + status->blobType = fromDownload; + } else if(MyStrNCmp(commandline, "kernel", 6) == 0) { /* download kernel */ startAddress = KERNEL_RAM_BASE; bufLen = status->blockSize - KERNEL_BLOCK_OFFSET; @@ -319,8 +341,19 @@ u32 startAddress = 0; tBlockType block; int numBytes = 0;; + + if(MyStrNCmp(commandline, "blob", 4) == 0) { + startAddress = BLOB_RAM_BASE; + block = blBlob; + numBytes = status->blobSize; - if(MyStrNCmp(commandline, "kernel", 6) == 0) { + if(status->blobType == fromFlash) { + SerialOutputString("*** No blob downloaded\r"); + return; + } + + SerialOutputString("Saving blob to flash "); + } else if(MyStrNCmp(commandline, "kernel", 6) == 0) { startAddress = KERNEL_RAM_BASE; block = blKernel; numBytes = status->kernelSize; @@ -362,17 +395,18 @@ { SerialOutputString("Help for " PACKAGE " " VERSION ", the LART bootloader\r"); SerialOutputString("The following commands are supported:\r"); - SerialOutputString("* boot [kernel options] Boot Linux with optional kernel options\r"); + SerialOutputString("* boot [kernel options] Boot Linux with optional kernel options\r"); SerialOutputString("* clock PPCR MDCNFG MDCAS0 MDCAS1 MDCAS2\r"); - SerialOutputString(" Set the SA1100 core clock and DRAM timings\r"); - SerialOutputString(" (WARNING: dangerous command!)\r"); - SerialOutputString("* download {kernel|ramdisk} Download kernel or ramdisk image to RAM\r"); - SerialOutputString("* flash {kernel|ramdisk} Copy kernel or ramdisk from RAM to flash\r"); - SerialOutputString("* help Get this help\r"); - SerialOutputString("* reload {kernel|ramdisk} Reload kernel or ramdisk from flash to RAM\r"); - SerialOutputString("* reset Reset terminal\r"); - SerialOutputString("* speed Set download speed\r"); - SerialOutputString("* status Display current status\r"); + SerialOutputString(" Set the SA1100 core clock and DRAM timings\r"); + SerialOutputString(" (WARNING: dangerous command!)\r"); + SerialOutputString("* download {blob|kernel|ramdisk} Download kernel or ramdisk image to RAM\r"); + SerialOutputString("* flash {blob|kernel|ramdisk} Copy kernel or ramdisk from RAM to flash\r"); + SerialOutputString("* help Get this help\r"); + SerialOutputString("* reboot Reboot system\r"); + SerialOutputString("* reload {blob|kernel|ramdisk} Reload kernel or ramdisk from flash to RAM\r"); + SerialOutputString("* reset Reset terminal\r"); + SerialOutputString("* speed Set download speed\r"); + SerialOutputString("* status Display current status\r"); } @@ -438,6 +472,15 @@ PrintSerialSpeed(status->downloadSpeed); SerialOutputString(" baud\r"); + SerialOutputString("Blob : "); + if(status->blobType == fromFlash) { + SerialOutputString("from flash\r"); + } else { + SerialOutputString("downloaded, "); + SerialOutputDec(status->blobSize); + SerialOutputString(" bytes\r"); + } + SerialOutputString("Kernel : "); if(status->kernelType == fromFlash) { SerialOutputString("from flash\r"); @@ -481,7 +524,14 @@ u32 *dst = 0; int numWords; - if(MyStrNCmp(commandline, "kernel", 6) == 0) { + if(MyStrNCmp(commandline, "blob", 4) == 0) { + src = (u32 *)BLOB_RAM_BASE; + dst = (u32 *)BLOB_START; + numWords = BLOB_LEN / 4; + status->blobSize = 0; + status->blobType = fromFlash; + SerialOutputString("Loading blob from flash "); + } else if(MyStrNCmp(commandline, "kernel", 6) == 0) { src = (u32 *)KERNEL_RAM_BASE; dst = (u32 *)KERNEL_START; numWords = KERNEL_LEN / 4; @@ -542,3 +592,11 @@ } } + + + +void Reboot(void) +{ + SerialOutputString("Rebooting...\r\r"); + RSRR = 1; +} Index: start.S =================================================================== RCS file: /cvsroot/blob/blob/src/start.S,v retrieving revision 1.1.1.1.2.9 retrieving revision 1.1.1.1.2.10 diff -u -r1.1.1.1.2.9 -r1.1.1.1.2.10 --- start.S 2001/07/17 14:18:38 1.1.1.1.2.9 +++ start.S 2001/07/18 23:49:41 1.1.1.1.2.10 @@ -95,16 +95,19 @@ mov r1, #0x00 str r1, [r0, #ICMR] + /* switch CPU to correct speed */ ldr r0, PWR_BASE LDR r1, cpuspeed str r1, [r0, #PPCR] + /* setup memory */ bl memsetup /* init LED */ bl ledinit + /* check if this is a wake-up from sleep */ ldr r0, RST_BASE @@ -122,12 +125,14 @@ ldr r1, [r0, #PSPR] mov pc, r1 + normal_boot: /* enable I-cache */ mrc p15, 0, r1, c1, c0, 0 @ read control reg orr r1, r1, #0x1000 @ set Icache mcr p15, 0, r1, c1, c0, 0 @ write it back + /* check the first 1MB in increments of 4k */ mov r7, #0x1000 mov r6, r7, lsl #8 /* 4k << 2^8 = 1MB */ @@ -142,8 +147,27 @@ add r5, r5, r7 subs r6, r6, r7 bne mem_test_loop + - /* the first megabyte is OK, so let's copy ourself to it */ + /* the first megabyte is OK, so let's clear it */ + mov r0, #((1024 * 1024) / (8 * 4)) /* 1MB in steps of 32 bytes */ + ldr r1, MEM_START + mov r2, #0 + mov r3, #0 + mov r4, #0 + mov r5, #0 + mov r6, #0 + mov r7, #0 + mov r8, #0 + mov r9, #0 + +clear_loop: + stmia r1!, {r2-r9} + subs r0, r0, #(8 * 4) + bne clear_loop + + + /* relocate the second stage loader */ mov r0, #0x400 /* skip first 1024 bytes */ ldr r1, MEM_START mov r2, #(128 * 1024) /* blob is 128kB */ @@ -154,10 +178,12 @@ cmp r0, r2 ble copy_loop + /* set up the stack pointer */ ldr r0, MEM_START add r1, r0, #(1024 * 1024) sub sp, r1, #0x04 + /* blob is copied to ram, so jump to it */ mov pc, r0 |