[Bootloader]
- ML402: do baudrate init in board_init() - use faster memcpy - print CPU info - provide extra diagnostic during SREC load git-svn-id: http://moon:8086/svn/mips@176 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
@@ -52,5 +52,7 @@ uint32_t getBootOffset(uint32_t sel)
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
volatile uint32_t *pBaud = (uint32_t)SYS_UART_BAUD;
|
||||
|
||||
*pBaud = UART_CALC_BAUD(460800);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <board.h>
|
||||
#include <string.h>
|
||||
#include "libsys.h"
|
||||
#include "srec.h"
|
||||
#include "../cfiflash.h"
|
||||
@@ -52,9 +53,11 @@ void Exec_at(void *pEntry)
|
||||
|
||||
__asm
|
||||
(
|
||||
// Enable User Mode and Interrupts on RFE
|
||||
// Exception Vector = 0xBFC00080
|
||||
"li $26, 0x1000000C\n"
|
||||
// On RFE:
|
||||
// (KUp = 1): Enable User Mode
|
||||
// (IEp = 0): Disable Interrupts
|
||||
// (BEV = 1): Exception Vector = 0xBFC00080
|
||||
"li $26, 0x10000008\n"
|
||||
"mtc0 $26, $12\n"
|
||||
);
|
||||
|
||||
@@ -108,7 +111,6 @@ void Exec_RE_at(void *pEntry)
|
||||
}
|
||||
|
||||
#define MAX_IMG_SIZE (1024*1024) // bytes
|
||||
#define FLASH_USE_BLOCK 1
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -133,7 +135,9 @@ int main(int argc, char *argv[])
|
||||
*pGPIO_DATA = GPIO_0_DFLT_DATA;
|
||||
block_sel = 0x7F & (uint32_t)((*pGPIO_DATA >> GPIO_0_ALIGN_DIP) & GPIO_0_MASK_DIP);
|
||||
|
||||
sputs("\nMIPS bootloader\n");
|
||||
sputs("\nMIPS bootloader 2.0\n");
|
||||
PrintCPUinfo();
|
||||
|
||||
// ----------------------------------------------------------
|
||||
if (IS_ERROR(flash_find(&flash, SYS_FLASH_IO)))
|
||||
{
|
||||
@@ -193,12 +197,19 @@ int main(int argc, char *argv[])
|
||||
switch (srec_state)
|
||||
{
|
||||
case srec_data:
|
||||
if ((srec.addr + srec.size) > haddr)
|
||||
haddr = srec.addr + srec.size;
|
||||
result = -1;
|
||||
if ((srec.addr + srec.size) > MAX_IMG_SIZE)
|
||||
{
|
||||
sputs("O");
|
||||
break;
|
||||
}
|
||||
|
||||
pMem = (uint8_t*)srec.addr;
|
||||
for (i=0; i < srec.size; i++)
|
||||
*pMem++ = srec.data[i];
|
||||
memcpy((uint32_t*)srec.addr, srec.data, srec.size);
|
||||
if ((srec.addr + srec.size) > haddr)
|
||||
{
|
||||
haddr = srec.addr + srec.size;
|
||||
}
|
||||
result = 0;
|
||||
|
||||
break;
|
||||
|
||||
@@ -252,6 +263,7 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
|
||||
default:
|
||||
sputs("E");
|
||||
result = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
+1
-4
@@ -19,14 +19,11 @@ const uart_if_t uart_if[2] =
|
||||
// ------------------------------------
|
||||
// Low-level I/O
|
||||
// ------------------------------------
|
||||
#define CALC_BAUD(b) \
|
||||
(((10*CPU_FREQ_HZ)/((16*b) + 5))/10 - 1)
|
||||
|
||||
void UART_setbaud(void const *pInst, uint32_t baudrate)
|
||||
{
|
||||
uart_if_t *pReg = (uart_if_t*)pInst;
|
||||
|
||||
*pReg->pBAUD = CALC_BAUD(baudrate);
|
||||
*pReg->pBAUD = UART_CALC_BAUD(baudrate);
|
||||
}
|
||||
|
||||
int UART_readchar(void const *pInst)
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
#ifndef UART_H
|
||||
#define UART_H
|
||||
|
||||
#define UART_CALC_BAUD(b) \
|
||||
(((10*CPU_FREQ_HZ)/((16*b) + 5))/10 - 1)
|
||||
|
||||
typedef struct _suart_if_t
|
||||
{
|
||||
volatile uint32_t *pCTRL;
|
||||
|
||||
Reference in New Issue
Block a user