mirror of
https://github.com/taubel/sdk-ameba-v4.0b-gcc.git
synced 2026-07-09 04:45:43 +00:00
initial commit
This commit is contained in:
commit
60a7afcc83
2528 changed files with 1001987 additions and 0 deletions
BIN
component/soc/realtek/8195a/misc/bsp/image/ram_1.p.bin
Normal file
BIN
component/soc/realtek/8195a/misc/bsp/image/ram_1.p.bin
Normal file
Binary file not shown.
BIN
component/soc/realtek/8195a/misc/bsp/image/ram_1.r.bin
Normal file
BIN
component/soc/realtek/8195a/misc/bsp/image/ram_1.r.bin
Normal file
Binary file not shown.
BIN
component/soc/realtek/8195a/misc/bsp/lib/common/GCC/lib_dct.a
Normal file
BIN
component/soc/realtek/8195a/misc/bsp/lib/common/GCC/lib_dct.a
Normal file
Binary file not shown.
BIN
component/soc/realtek/8195a/misc/bsp/lib/common/GCC/lib_http.a
Normal file
BIN
component/soc/realtek/8195a/misc/bsp/lib/common/GCC/lib_http.a
Normal file
Binary file not shown.
BIN
component/soc/realtek/8195a/misc/bsp/lib/common/GCC/lib_mdns.a
Normal file
BIN
component/soc/realtek/8195a/misc/bsp/lib/common/GCC/lib_mdns.a
Normal file
Binary file not shown.
Binary file not shown.
BIN
component/soc/realtek/8195a/misc/bsp/lib/common/GCC/lib_rtlstd.a
Normal file
BIN
component/soc/realtek/8195a/misc/bsp/lib/common/GCC/lib_rtlstd.a
Normal file
Binary file not shown.
Binary file not shown.
BIN
component/soc/realtek/8195a/misc/bsp/lib/common/GCC/lib_wlan.a
Normal file
BIN
component/soc/realtek/8195a/misc/bsp/lib/common/GCC/lib_wlan.a
Normal file
Binary file not shown.
Binary file not shown.
BIN
component/soc/realtek/8195a/misc/bsp/lib/common/GCC/lib_wps.a
Normal file
BIN
component/soc/realtek/8195a/misc/bsp/lib/common/GCC/lib_wps.a
Normal file
Binary file not shown.
BIN
component/soc/realtek/8195a/misc/bsp/lib/common/GCC/lib_xmodem.a
Normal file
BIN
component/soc/realtek/8195a/misc/bsp/lib/common/GCC/lib_xmodem.a
Normal file
Binary file not shown.
BIN
component/soc/realtek/8195a/misc/bsp/lib/common/IAR/lib_dct.a
Normal file
BIN
component/soc/realtek/8195a/misc/bsp/lib/common/IAR/lib_dct.a
Normal file
Binary file not shown.
BIN
component/soc/realtek/8195a/misc/bsp/lib/common/IAR/lib_http.a
Normal file
BIN
component/soc/realtek/8195a/misc/bsp/lib/common/IAR/lib_http.a
Normal file
Binary file not shown.
BIN
component/soc/realtek/8195a/misc/bsp/lib/common/IAR/lib_mdns.a
Normal file
BIN
component/soc/realtek/8195a/misc/bsp/lib/common/IAR/lib_mdns.a
Normal file
Binary file not shown.
Binary file not shown.
BIN
component/soc/realtek/8195a/misc/bsp/lib/common/IAR/lib_rtlstd.a
Normal file
BIN
component/soc/realtek/8195a/misc/bsp/lib/common/IAR/lib_rtlstd.a
Normal file
Binary file not shown.
Binary file not shown.
BIN
component/soc/realtek/8195a/misc/bsp/lib/common/IAR/lib_wlan.a
Normal file
BIN
component/soc/realtek/8195a/misc/bsp/lib/common/IAR/lib_wlan.a
Normal file
Binary file not shown.
Binary file not shown.
BIN
component/soc/realtek/8195a/misc/bsp/lib/common/IAR/lib_wps.a
Normal file
BIN
component/soc/realtek/8195a/misc/bsp/lib/common/IAR/lib_wps.a
Normal file
Binary file not shown.
BIN
component/soc/realtek/8195a/misc/bsp/lib/common/IAR/lib_xmodem.a
Normal file
BIN
component/soc/realtek/8195a/misc/bsp/lib/common/IAR/lib_xmodem.a
Normal file
Binary file not shown.
BIN
component/soc/realtek/8195a/misc/bsp/lib/va0/rom.a
Normal file
BIN
component/soc/realtek/8195a/misc/bsp/lib/va0/rom.a
Normal file
Binary file not shown.
247
component/soc/realtek/8195a/misc/driver/console_hs_uart.c
Normal file
247
component/soc/realtek/8195a/misc/driver/console_hs_uart.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright(c) 2007 - 2016 Realtek Corporation. All rights reserved.
|
||||
*
|
||||
*
|
||||
******************************************************************************/
|
||||
#include <platform_opts.h>
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include <platform/platform_stdlib.h>
|
||||
#include "semphr.h"
|
||||
#include "device.h"
|
||||
#include "serial_api.h"
|
||||
#include "at_cmd/log_service.h"
|
||||
#include "osdep_service.h"
|
||||
#include "serial_ex_api.h"
|
||||
#include "pinmap.h"
|
||||
|
||||
char hs_uart_ready = 0; // used to switch between loguart and high speed uart
|
||||
// 0: loguart
|
||||
// 1: highspeed uart
|
||||
|
||||
// select uart tx/rx pin with gpio interrupt function
|
||||
#define UART_TX PA_7
|
||||
#define UART_RX PA_6
|
||||
|
||||
#define KEY_NL 0xa // '\n'
|
||||
#define KEY_ENTER 0xd // '\r'
|
||||
#define KEY_BS 0x8
|
||||
#define KEY_ESC 0x1B
|
||||
#define KEY_LBRKT 0x5B
|
||||
#define STR_END_OF_MP_FORMAT "\r\n\r\r#"
|
||||
|
||||
|
||||
#define CMD_HISTORY_LEN 4 // max number of executed command saved
|
||||
extern char log_buf[LOG_SERVICE_BUFLEN];
|
||||
extern xSemaphoreHandle log_rx_interrupt_sema;
|
||||
char cmd_history[CMD_HISTORY_LEN][LOG_SERVICE_BUFLEN];
|
||||
static unsigned int cmd_history_count = 0;
|
||||
|
||||
serial_t loguart_sobj;
|
||||
//_sema at_printf_sema;
|
||||
_sema hs_uart_dma_tx_sema;
|
||||
|
||||
#define HS_UART_USE_DMA_TX 1
|
||||
|
||||
void hs_uart_put_char(u8 c){
|
||||
serial_putc(&loguart_sobj, c);
|
||||
}
|
||||
|
||||
void hs_uart_send_string(char *str)
|
||||
{
|
||||
unsigned int i=0;
|
||||
while (str[i] != '\0') {
|
||||
serial_putc(&loguart_sobj, str[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
#if UART_AT_USE_DMA_TX
|
||||
static void hs_uart_send_buf_done(uint32_t id)
|
||||
{
|
||||
//serial_t *sobj = (serial_t *)id;
|
||||
|
||||
rtw_up_sema_from_isr(&uart_at_dma_tx_sema);
|
||||
}
|
||||
#endif
|
||||
|
||||
void hs_uart_send_buf(u8 *buf, u32 len)
|
||||
{
|
||||
unsigned char *st_p=buf;
|
||||
if(!len || (!buf)){
|
||||
return;
|
||||
}
|
||||
#if UART_AT_USE_DMA_TX
|
||||
int ret;
|
||||
while(rtw_down_sema(&uart_at_dma_tx_sema) == _TRUE){
|
||||
ret = serial_send_stream_dma(&loguart_sobj, st_p, len);
|
||||
if(ret != HAL_OK){
|
||||
rtw_up_sema(&uart_at_dma_tx_sema);
|
||||
return;
|
||||
}else{
|
||||
return;
|
||||
}
|
||||
}
|
||||
#else
|
||||
while(len){
|
||||
serial_putc(&loguart_sobj, *st_p);
|
||||
st_p++;
|
||||
len--;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void hs_uart_irq(uint32_t id, SerialIrq event)
|
||||
{
|
||||
serial_t *sobj = (serial_t *)id;
|
||||
unsigned char rc=0;
|
||||
static unsigned char temp_buf[LOG_SERVICE_BUFLEN] = "\0";
|
||||
static unsigned char combo_key = 0;
|
||||
static unsigned short buf_count = 0;
|
||||
static unsigned char key_enter = 0;
|
||||
static char cmd_history_index = 0;
|
||||
if(event == RxIrq) {
|
||||
rc = serial_getc(sobj);
|
||||
|
||||
if(key_enter && rc == KEY_NL){
|
||||
//serial_putc(sobj, rc);
|
||||
return;
|
||||
}
|
||||
|
||||
if(rc == KEY_ESC){
|
||||
combo_key = 1;
|
||||
}else if(combo_key == 1){
|
||||
if(rc == KEY_LBRKT)
|
||||
combo_key = 2;
|
||||
else
|
||||
combo_key = 0;
|
||||
}else if(combo_key == 2){
|
||||
if(rc == 'A' || rc == 'B'){ // UP or Down
|
||||
if(rc == 'A'){
|
||||
cmd_history_index--;
|
||||
if(cmd_history_index < 0)
|
||||
cmd_history_index = (cmd_history_count>CMD_HISTORY_LEN)?CMD_HISTORY_LEN-1:(cmd_history_count-1)%CMD_HISTORY_LEN;
|
||||
}else{
|
||||
cmd_history_index++;
|
||||
if(cmd_history_index > (cmd_history_count>CMD_HISTORY_LEN?CMD_HISTORY_LEN-1:(cmd_history_count-1)%CMD_HISTORY_LEN))
|
||||
cmd_history_index = 0;
|
||||
}
|
||||
|
||||
if(cmd_history_count > 0){
|
||||
buf_count = strlen(temp_buf);
|
||||
rtw_memset(temp_buf,'\0',buf_count);
|
||||
while(--buf_count >= 0){
|
||||
serial_putc(sobj, KEY_BS);
|
||||
serial_putc(sobj, ' ');
|
||||
serial_putc(sobj, KEY_BS);
|
||||
}
|
||||
hs_uart_send_string(cmd_history[cmd_history_index%CMD_HISTORY_LEN]);
|
||||
strcpy(temp_buf, cmd_history[cmd_history_index%CMD_HISTORY_LEN]);
|
||||
buf_count = strlen(temp_buf);
|
||||
}
|
||||
}
|
||||
|
||||
// exit combo
|
||||
combo_key = 0;
|
||||
}
|
||||
else if(rc == KEY_ENTER){
|
||||
key_enter = 1;
|
||||
if(buf_count>0){
|
||||
serial_putc(sobj, KEY_NL);
|
||||
serial_putc(sobj, KEY_ENTER);
|
||||
rtw_memset(log_buf,'\0',LOG_SERVICE_BUFLEN);
|
||||
strncpy(log_buf,(char *)&temp_buf[0],buf_count);
|
||||
rtw_up_sema_from_isr(&log_rx_interrupt_sema);
|
||||
rtw_memset(temp_buf,'\0',buf_count);
|
||||
|
||||
/* save command */
|
||||
rtw_memset(cmd_history[((cmd_history_count)%CMD_HISTORY_LEN)], '\0', buf_count+1);
|
||||
strcpy(cmd_history[((cmd_history_count++)%CMD_HISTORY_LEN)], log_buf);
|
||||
cmd_history_index = cmd_history_count%CMD_HISTORY_LEN;
|
||||
//cmd_history_count++;
|
||||
buf_count=0;
|
||||
}else{
|
||||
hs_uart_send_string(STR_END_OF_MP_FORMAT);
|
||||
}
|
||||
}
|
||||
else if(rc == KEY_BS){
|
||||
if(buf_count>0){
|
||||
buf_count--;
|
||||
temp_buf[buf_count] = '\0';
|
||||
|
||||
serial_putc(sobj, rc);
|
||||
serial_putc(sobj, ' ');
|
||||
serial_putc(sobj, rc);
|
||||
}
|
||||
}
|
||||
else{
|
||||
/* cache input characters */
|
||||
if(buf_count < (LOG_SERVICE_BUFLEN - 1)){
|
||||
temp_buf[buf_count] = rc;
|
||||
buf_count++;
|
||||
serial_putc(sobj, rc);
|
||||
key_enter = 0;
|
||||
}
|
||||
else if(buf_count == (LOG_SERVICE_BUFLEN - 1)){
|
||||
temp_buf[buf_count] = '\0';
|
||||
|
||||
hs_uart_send_string("\r\nERROR:exceed size limit"STR_END_OF_ATCMD_RET);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void console_init_hs_uart(void)
|
||||
{
|
||||
serial_init(&loguart_sobj,UART_TX,UART_RX);
|
||||
serial_baud(&loguart_sobj,38400);
|
||||
serial_format(&loguart_sobj, 8, ParityNone, 1);
|
||||
|
||||
#if UART_AT_USE_DMA_TX
|
||||
rtw_init_sema(&hs_uart_dma_tx_sema, 1);
|
||||
serial_send_comp_handler(&loguart_sobj, (void*)hs_uart_send_buf_done, (uint32_t)&loguart_sobj);
|
||||
#endif
|
||||
|
||||
serial_irq_handler(&loguart_sobj, hs_uart_irq, (uint32_t)&loguart_sobj);
|
||||
serial_irq_set(&loguart_sobj, RxIrq, 1);
|
||||
|
||||
for(char i=0; i<CMD_HISTORY_LEN; i++)
|
||||
memset(cmd_history[i], '\0', LOG_SERVICE_BUFLEN);
|
||||
|
||||
/* indicate low level layer that hs uart is ready */
|
||||
hs_uart_ready = 1;
|
||||
}
|
||||
|
||||
int use_mode;
|
||||
|
||||
|
||||
VOID HalSerialPutcRtl8195a(
|
||||
IN u8 c
|
||||
)
|
||||
{
|
||||
extern char hs_uart_ready;
|
||||
extern void hs_uart_put_char(u8 c);
|
||||
if(hs_uart_ready)
|
||||
hs_uart_put_char(c);
|
||||
}
|
||||
|
||||
void console_init(void)
|
||||
{
|
||||
sys_log_uart_off();
|
||||
console_init_hs_uart();
|
||||
|
||||
#if !TASK_SCHEDULER_DISABLED
|
||||
RtlConsolInitRam((u32)RAM_STAGE,(u32)0,(VOID*)NULL);
|
||||
#else
|
||||
RtlConsolInitRam((u32)ROM_STAGE,(u32)0,(VOID*)NULL);
|
||||
#endif
|
||||
|
||||
#if BUFFERED_PRINTF
|
||||
rtl_printf_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
166
component/soc/realtek/8195a/misc/driver/console_i2c.c
Normal file
166
component/soc/realtek/8195a/misc/driver/console_i2c.c
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
#include <platform_opts.h>
|
||||
#include "serial_api.h"
|
||||
#include "serial_ex_api.h"
|
||||
#include "PinNames.h"
|
||||
#include "i2c_api.h"
|
||||
#include "pinmap.h"
|
||||
#include "ex_api.h"
|
||||
|
||||
#define MBED_I2C_MTR_SDA PB_3 //i2c3
|
||||
#define MBED_I2C_MTR_SCL PB_2
|
||||
|
||||
#define UART_BAUDRATE 115200
|
||||
|
||||
#define MBED_I2C_SLAVE_ADDR0 0x4D // 0x9A //
|
||||
#define MBED_I2C_BUS_CLK 500000 //hz *Remind that in baud rate 9600 or 19200, 100000hz is suitable*
|
||||
|
||||
static i2c_t i2cmaster;
|
||||
|
||||
#define I2C_DATA_LENGTH 2
|
||||
static char i2cdatardsrc[I2C_DATA_LENGTH];
|
||||
static char i2cdatarddst[I2C_DATA_LENGTH];
|
||||
|
||||
const u8 DLL = 921600/UART_BAUDRATE;
|
||||
|
||||
char ctrl_initial_1[2] = {0x03 << 3,0x80};
|
||||
char ctrl_initial_2[2] = {0x00 << 3,921600/UART_BAUDRATE};
|
||||
char ctrl_initial_3[2] = {0x01 << 3,0x00};
|
||||
char ctrl_initial_4[2] = {0x03 << 3,0xbf};
|
||||
char ctrl_initial_5[2] = {0x02 << 3,0x10};
|
||||
char ctrl_initial_6[2] = {0x03 << 3,0x03};
|
||||
char ctrl_initial_7[2] = {0x02 << 3,0x06};
|
||||
char ctrl_initial_8[2] = {0x02 << 3,0x01};
|
||||
//end i2c
|
||||
|
||||
|
||||
// Master// Tx
|
||||
#define CLEAR_MST_TXC_FLAG (masterTXC = 0)
|
||||
#define SET_MST_TXC_FLAG (masterTXC = 1)
|
||||
#define WAIT_MST_TXC while(masterTXC == 0){;}
|
||||
|
||||
volatile int masterTXC;
|
||||
static char i2c_ready = 0;
|
||||
|
||||
|
||||
static void i2c_master_rxc_callback(void *userdata)
|
||||
{
|
||||
|
||||
int i2clocalcnt;
|
||||
int result = 0;
|
||||
|
||||
// verify result
|
||||
result = 1;
|
||||
for (i2clocalcnt = 0; i2clocalcnt < I2C_DATA_LENGTH; i2clocalcnt++) {
|
||||
if (i2cdatarddst[i2clocalcnt] != i2cdatardsrc[i2clocalcnt]) {
|
||||
result = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void i2c_master_txc_callback(void *userdata)
|
||||
{
|
||||
SET_MST_TXC_FLAG;
|
||||
}
|
||||
|
||||
static void i2c_master_write(void)
|
||||
{
|
||||
|
||||
//DBG_8195A("Mst-W\n");
|
||||
CLEAR_MST_TXC_FLAG;
|
||||
|
||||
i2c_write(&i2cmaster, MBED_I2C_SLAVE_ADDR0, &ctrl_initial_1[0], 2, 1);
|
||||
i2c_write(&i2cmaster, MBED_I2C_SLAVE_ADDR0, &ctrl_initial_2[0], 2, 1);
|
||||
i2c_write(&i2cmaster, MBED_I2C_SLAVE_ADDR0, &ctrl_initial_3[0], 2, 1);
|
||||
i2c_write(&i2cmaster, MBED_I2C_SLAVE_ADDR0, &ctrl_initial_4[0], 2, 1);
|
||||
i2c_write(&i2cmaster, MBED_I2C_SLAVE_ADDR0, &ctrl_initial_5[0], 2, 1);
|
||||
i2c_write(&i2cmaster, MBED_I2C_SLAVE_ADDR0, &ctrl_initial_6[0], 2, 1);
|
||||
i2c_write(&i2cmaster, MBED_I2C_SLAVE_ADDR0, &ctrl_initial_7[0], 2, 1);
|
||||
i2c_write(&i2cmaster, MBED_I2C_SLAVE_ADDR0, &ctrl_initial_8[0], 2, 1);
|
||||
|
||||
WAIT_MST_TXC;
|
||||
|
||||
}
|
||||
|
||||
static void i2c_master_enable(void)
|
||||
{
|
||||
_memset(&i2cmaster, 0x00, sizeof(i2c_t));
|
||||
i2c_init(&i2cmaster, MBED_I2C_MTR_SDA ,MBED_I2C_MTR_SCL);
|
||||
i2c_frequency(&i2cmaster,MBED_I2C_BUS_CLK);
|
||||
i2c_set_user_callback(&i2cmaster, I2C_RX_COMPLETE, i2c_master_rxc_callback);
|
||||
i2c_set_user_callback(&i2cmaster, I2C_TX_COMPLETE, i2c_master_txc_callback);
|
||||
//i2c_set_user_callback(&i2cmaster, I2C_ERR_OCCURRED, i2c_master_err_callback);
|
||||
|
||||
}
|
||||
|
||||
void i2c_redirect_init(void)
|
||||
{
|
||||
|
||||
// prepare for transmission
|
||||
|
||||
_memset(&i2cdatardsrc[0], 0x00, I2C_DATA_LENGTH);
|
||||
_memset(&i2cdatarddst[0], 0x00, I2C_DATA_LENGTH);
|
||||
|
||||
i2c_ready = 1;
|
||||
|
||||
i2c_master_enable();
|
||||
i2c_master_write();
|
||||
|
||||
}
|
||||
|
||||
static u8 tx_data_i2c[2];
|
||||
static u8 rx_data_i2c[2];
|
||||
|
||||
void i2c_put_char(u8 c){
|
||||
|
||||
_memset(&tx_data_i2c[0],0x00,2);
|
||||
_memset(&rx_data_i2c[0],0x00,2);
|
||||
tx_data_i2c[0] = 0x00 << 3;
|
||||
tx_data_i2c[1] = c;
|
||||
i2c_write(&i2cmaster, 0x4D, &tx_data_i2c[0], 2, 1);
|
||||
i2c_read (&i2cmaster, 0x4D, &rx_data_i2c[0], 2, 1);
|
||||
}
|
||||
|
||||
int use_mode;
|
||||
|
||||
void console_init(void)
|
||||
{
|
||||
i2c_redirect_init();
|
||||
|
||||
if(HalCheckSDramExist()){
|
||||
//DiagPrintf("It's 8195_AM\n");
|
||||
redirect_rom_init();
|
||||
}
|
||||
|
||||
#if !TASK_SCHEDULER_DISABLED
|
||||
RtlConsolInitRam((u32)RAM_STAGE,(u32)0,(VOID*)NULL);
|
||||
#else
|
||||
RtlConsolInitRam((u32)ROM_STAGE,(u32)0,(VOID*)NULL);
|
||||
#endif
|
||||
|
||||
#if BUFFERED_PRINTF
|
||||
rtl_printf_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
VOID HalSerialPutcRtl8195a(IN u8 c){
|
||||
|
||||
u32 CounterIndex = 0;
|
||||
|
||||
extern char i2c_ready;
|
||||
if(i2c_ready)
|
||||
i2c_put_char(c);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
119
component/soc/realtek/8195a/misc/driver/low_level_io.c
Normal file
119
component/soc/realtek/8195a/misc/driver/low_level_io.c
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
#include <stdio.h>
|
||||
#include "hal_api.h"
|
||||
#include "rtl8195a.h"
|
||||
#include "platform_opts.h"
|
||||
|
||||
#if !defined (__ICCARM__)
|
||||
extern u8 RAM_IMG1_VALID_PATTEN[];
|
||||
void *tmp = RAM_IMG1_VALID_PATTEN;
|
||||
#endif
|
||||
|
||||
//for internal test
|
||||
#ifdef USE_MODE
|
||||
extern int use_mode;
|
||||
void mode_init(void){use_mode = 1;}
|
||||
#endif
|
||||
|
||||
#if defined ( __ICCARM__ )
|
||||
size_t __write(int Handle, const unsigned char * Buf, size_t Bufsize)
|
||||
{
|
||||
int nChars = 0;
|
||||
/* Check for stdout and stderr
|
||||
(only necessary if file descriptors are enabled.) */
|
||||
if (Handle != 1 && Handle != 2)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
for (/*Empty */; Bufsize > 0; --Bufsize)
|
||||
{
|
||||
DiagPutChar(*Buf++);
|
||||
++nChars;
|
||||
}
|
||||
return nChars;
|
||||
}
|
||||
|
||||
size_t __read(int Handle, unsigned char * Buf, size_t Bufsize)
|
||||
{
|
||||
int nChars = 0;
|
||||
/* Check for stdin
|
||||
(only necessary if FILE descriptors are enabled) */
|
||||
if (Handle != 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
for (/*Empty*/; Bufsize > 0; --Bufsize)
|
||||
{
|
||||
int c = DiagGetChar(_FALSE);
|
||||
if (c < 0)
|
||||
break;
|
||||
*(Buf++) = c;
|
||||
++nChars;
|
||||
}
|
||||
return nChars;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
int disablePrintf = FALSE;
|
||||
|
||||
|
||||
__weak VOID HalSerialPutcRtl8195a(IN u8 c){
|
||||
|
||||
u32 CounterIndex = 0;
|
||||
|
||||
if(disablePrintf == TRUE) return;
|
||||
|
||||
while(1) {
|
||||
CounterIndex++;
|
||||
if (CounterIndex >=6540)
|
||||
break;
|
||||
|
||||
if (HAL_UART_READ8(UART_LINE_STATUS_REG_OFF) & 0x60)
|
||||
break;
|
||||
}
|
||||
HAL_UART_WRITE8(UART_TRAN_HOLD_OFF, c);
|
||||
if (c == 0x0a) {
|
||||
HAL_UART_WRITE8(UART_TRAN_HOLD_OFF, 0x0d);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#include <diag.h>
|
||||
u32
|
||||
DiagPrintf(
|
||||
IN const char *fmt, ...
|
||||
)
|
||||
{
|
||||
if(disablePrintf == TRUE) return _TRUE;
|
||||
|
||||
(void)VSprintf(0, fmt, ((const int *)&fmt)+1);
|
||||
return _TRUE;
|
||||
}
|
||||
|
||||
extern u32 ConfigDebugErr;
|
||||
extern u32 ConfigDebugInfo;
|
||||
extern u32 ConfigDebugWarn;
|
||||
static u32 backupErr;
|
||||
static u32 backupInfo;
|
||||
static u32 backupWarn;
|
||||
void log_uart_enable_printf(void)
|
||||
{
|
||||
disablePrintf = FALSE;
|
||||
ConfigDebugErr = backupErr;
|
||||
ConfigDebugInfo = backupInfo;
|
||||
ConfigDebugWarn = backupWarn;
|
||||
}
|
||||
|
||||
void log_uart_disable_printf(void)
|
||||
{
|
||||
disablePrintf = TRUE;
|
||||
backupErr = ConfigDebugErr;
|
||||
backupInfo = ConfigDebugInfo;
|
||||
backupWarn = ConfigDebugWarn;
|
||||
ConfigDebugErr = 0;
|
||||
ConfigDebugInfo = 0;
|
||||
ConfigDebugWarn = 0;
|
||||
}
|
||||
487
component/soc/realtek/8195a/misc/driver/rtl_consol.c
Normal file
487
component/soc/realtek/8195a/misc/driver/rtl_consol.c
Normal file
|
|
@ -0,0 +1,487 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#include "rtl8195a.h"
|
||||
//#include <stdarg.h>
|
||||
#include "rtl_consol.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include <event_groups.h>
|
||||
#include "semphr.h"
|
||||
#if defined(configUSE_WAKELOCK_PMU) && (configUSE_WAKELOCK_PMU == 1)
|
||||
#include "freertos_pmu.h"
|
||||
#endif
|
||||
#include "tcm_heap.h"
|
||||
|
||||
// Those symbols will be defined in linker script for gcc compiler
|
||||
// If not doing this would cause extra memory cost
|
||||
#if defined (__GNUC__)
|
||||
|
||||
extern volatile UART_LOG_CTL UartLogCtl;
|
||||
extern volatile UART_LOG_CTL *pUartLogCtl;
|
||||
extern u8 *ArgvArray[MAX_ARGV];
|
||||
extern UART_LOG_BUF UartLogBuf;
|
||||
|
||||
#ifdef CONFIG_UART_LOG_HISTORY
|
||||
extern u8 UartLogHistoryBuf[UART_LOG_HISTORY_LEN][UART_LOG_CMD_BUFLEN];
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
MON_RAM_BSS_SECTION
|
||||
volatile UART_LOG_CTL UartLogCtl;
|
||||
MON_RAM_BSS_SECTION
|
||||
volatile UART_LOG_CTL *pUartLogCtl;
|
||||
MON_RAM_BSS_SECTION
|
||||
u8 *ArgvArray[MAX_ARGV];
|
||||
MON_RAM_BSS_SECTION
|
||||
UART_LOG_BUF UartLogBuf;
|
||||
|
||||
#ifdef CONFIG_UART_LOG_HISTORY
|
||||
MON_RAM_BSS_SECTION
|
||||
u8 UartLogHistoryBuf[UART_LOG_HISTORY_LEN][UART_LOG_CMD_BUFLEN];
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL
|
||||
static void (*up_sema_from_isr)(_sema *) = NULL;
|
||||
#endif
|
||||
|
||||
|
||||
_LONG_CALL_
|
||||
extern u8
|
||||
UartLogCmdChk(
|
||||
IN u8 RevData,
|
||||
IN UART_LOG_CTL *prvUartLogCtl,
|
||||
IN u8 EchoFlag
|
||||
);
|
||||
|
||||
_LONG_CALL_
|
||||
extern VOID
|
||||
ArrayInitialize(
|
||||
IN u8 *pArrayToInit,
|
||||
IN u8 ArrayLen,
|
||||
IN u8 InitValue
|
||||
);
|
||||
|
||||
_LONG_CALL_
|
||||
extern VOID
|
||||
UartLogHistoryCmd(
|
||||
IN u8 RevData,
|
||||
IN UART_LOG_CTL *prvUartLogCtl,
|
||||
IN u8 EchoFlag
|
||||
);
|
||||
|
||||
_LONG_CALL_
|
||||
extern VOID
|
||||
UartLogCmdExecute(
|
||||
IN PUART_LOG_CTL pUartLogCtlExe
|
||||
);
|
||||
|
||||
|
||||
|
||||
//=================================================
|
||||
|
||||
|
||||
/* Minimum and maximum values a `signed long int' can hold.
|
||||
(Same as `int'). */
|
||||
#ifndef __LONG_MAX__
|
||||
#if defined (__alpha__) || (defined (__sparc__) && defined(__arch64__)) || defined (__sparcv9) || defined (__s390x__)
|
||||
#define __LONG_MAX__ 9223372036854775807L
|
||||
#else
|
||||
#define __LONG_MAX__ 2147483647L
|
||||
#endif /* __alpha__ || sparc64 */
|
||||
#endif
|
||||
#undef LONG_MIN
|
||||
#define LONG_MIN (-LONG_MAX-1)
|
||||
#undef LONG_MAX
|
||||
#define LONG_MAX __LONG_MAX__
|
||||
|
||||
/* Maximum value an `unsigned long int' can hold. (Minimum is 0). */
|
||||
#undef ULONG_MAX
|
||||
#define ULONG_MAX (LONG_MAX * 2UL + 1)
|
||||
|
||||
#ifndef __LONG_LONG_MAX__
|
||||
#define __LONG_LONG_MAX__ 9223372036854775807LL
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
//======================================================
|
||||
//<Function>: UartLogIrqHandleRam
|
||||
//<Usage >: To deal with Uart-Log RX IRQ
|
||||
//<Argus >: VOID
|
||||
//<Return >: VOID
|
||||
//<Notes >: NA
|
||||
//======================================================
|
||||
//MON_RAM_TEXT_SECTION
|
||||
VOID
|
||||
UartLogIrqHandleRam
|
||||
(
|
||||
VOID * Data
|
||||
)
|
||||
{
|
||||
u8 UartReceiveData = 0;
|
||||
//For Test
|
||||
BOOL PullMode = _FALSE;
|
||||
|
||||
u32 IrqEn = DiagGetIsrEnReg();
|
||||
|
||||
DiagSetIsrEnReg(0);
|
||||
|
||||
UartReceiveData = DiagGetChar(PullMode);
|
||||
if (UartReceiveData == 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
//KB_ESC chk is for cmd history, it's a special case here.
|
||||
if (UartReceiveData == KB_ASCII_ESC) {
|
||||
//4 Esc detection is only valid in the first stage of boot sequence (few seconds)
|
||||
if (pUartLogCtl->ExecuteEsc != _TRUE)
|
||||
{
|
||||
pUartLogCtl->ExecuteEsc = _TRUE;
|
||||
(*pUartLogCtl).EscSTS = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
//4 the input commands are valid only when the task is ready to execute commands
|
||||
if ((pUartLogCtl->BootRdy == 1)
|
||||
#ifdef CONFIG_KERNEL
|
||||
||(pUartLogCtl->TaskRdy == 1)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
if ((*pUartLogCtl).EscSTS==0)
|
||||
{
|
||||
(*pUartLogCtl).EscSTS = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
(*pUartLogCtl).EscSTS = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((*pUartLogCtl).EscSTS==1){
|
||||
if (UartReceiveData != KB_ASCII_LBRKT){
|
||||
(*pUartLogCtl).EscSTS = 0;
|
||||
}
|
||||
else{
|
||||
(*pUartLogCtl).EscSTS = 2;
|
||||
}
|
||||
}
|
||||
|
||||
else{
|
||||
if ((*pUartLogCtl).EscSTS==2){
|
||||
(*pUartLogCtl).EscSTS = 0;
|
||||
#ifdef CONFIG_UART_LOG_HISTORY
|
||||
if ((UartReceiveData=='A')|| UartReceiveData=='B'){
|
||||
UartLogHistoryCmd(UartReceiveData,(UART_LOG_CTL *)pUartLogCtl,1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else{
|
||||
if (UartLogCmdChk(UartReceiveData,(UART_LOG_CTL *)pUartLogCtl,1)==2)
|
||||
{
|
||||
//4 check UartLog buffer to prevent from incorrect access
|
||||
if (pUartLogCtl->pTmpLogBuf != NULL)
|
||||
{
|
||||
pUartLogCtl->ExecuteCmd = _TRUE;
|
||||
#if defined(CONFIG_KERNEL) && !TASK_SCHEDULER_DISABLED
|
||||
if (pUartLogCtl->TaskRdy && up_sema_from_isr != NULL)
|
||||
//RtlUpSemaFromISR((_Sema *)&pUartLogCtl->Sema);
|
||||
up_sema_from_isr((_sema *)&pUartLogCtl->Sema);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
ArrayInitialize((u8 *)pUartLogCtl->pTmpLogBuf->UARTLogBuf, UART_LOG_CMD_BUFLEN, '\0');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exit:
|
||||
DiagSetIsrEnReg(IrqEn);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//MON_RAM_TEXT_SECTION
|
||||
VOID
|
||||
RtlConsolInitRam(
|
||||
IN u32 Boot,
|
||||
IN u32 TBLSz,
|
||||
IN VOID *pTBL
|
||||
)
|
||||
{
|
||||
UartLogBuf.BufCount = 0;
|
||||
ArrayInitialize(&UartLogBuf.UARTLogBuf[0],UART_LOG_CMD_BUFLEN,'\0');
|
||||
pUartLogCtl = &UartLogCtl;
|
||||
|
||||
pUartLogCtl->NewIdx = 0;
|
||||
pUartLogCtl->SeeIdx = 0;
|
||||
pUartLogCtl->RevdNo = 0;
|
||||
pUartLogCtl->EscSTS = 0;
|
||||
pUartLogCtl->BootRdy = 0;
|
||||
pUartLogCtl->pTmpLogBuf = &UartLogBuf;
|
||||
#ifdef CONFIG_UART_LOG_HISTORY
|
||||
pUartLogCtl->CRSTS = 0;
|
||||
pUartLogCtl->pHistoryBuf = &UartLogHistoryBuf[0];
|
||||
#endif
|
||||
pUartLogCtl->pfINPUT = (VOID*)&DiagPrintf;
|
||||
pUartLogCtl->pCmdTbl = (PCOMMAND_TABLE) pTBL;
|
||||
pUartLogCtl->CmdTblSz = TBLSz;
|
||||
#ifdef CONFIG_KERNEL
|
||||
pUartLogCtl->TaskRdy = 0;
|
||||
#endif
|
||||
//executing boot sequence
|
||||
if (Boot == ROM_STAGE)
|
||||
{
|
||||
pUartLogCtl->ExecuteCmd = _FALSE;
|
||||
pUartLogCtl->ExecuteEsc = _FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
pUartLogCtl->ExecuteCmd = _FALSE;
|
||||
pUartLogCtl->ExecuteEsc= _TRUE;//don't check Esc anymore
|
||||
#if defined(CONFIG_KERNEL)
|
||||
/* Create a Semaphone */
|
||||
//RtlInitSema((_Sema*)&(pUartLogCtl->Sema), 0);
|
||||
rtw_init_sema((_sema*)&(pUartLogCtl->Sema), 0);
|
||||
pUartLogCtl->TaskRdy = 0;
|
||||
#ifdef PLATFORM_FREERTOS
|
||||
#define LOGUART_STACK_SIZE 128 //USE_MIN_STACK_SIZE modify from 512 to 128
|
||||
#if CONFIG_USE_TCM_HEAP
|
||||
{
|
||||
int ret = 0;
|
||||
void *stack_addr = tcm_heap_malloc(LOGUART_STACK_SIZE*sizeof(int));
|
||||
//void *stack_addr = rtw_malloc(stack_size*sizeof(int));
|
||||
if(stack_addr == NULL){
|
||||
DiagPrintf("Out of TCM heap in \"LOGUART_TASK\" ");
|
||||
}
|
||||
ret = xTaskGenericCreate(
|
||||
RtlConsolTaskRam,
|
||||
(const char *)"LOGUART_TASK",
|
||||
LOGUART_STACK_SIZE,
|
||||
NULL,
|
||||
tskIDLE_PRIORITY + 5 + PRIORITIE_OFFSET,
|
||||
NULL,
|
||||
stack_addr,
|
||||
NULL);
|
||||
if (pdTRUE != ret)
|
||||
{
|
||||
DiagPrintf("Create Log UART Task Err!!\n");
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (pdTRUE != xTaskCreate( RtlConsolTaskRam, (const signed char * const)"LOGUART_TASK", LOGUART_STACK_SIZE, NULL, tskIDLE_PRIORITY + 5 + PRIORITIE_OFFSET, NULL))
|
||||
{
|
||||
DiagPrintf("Create Log UART Task Err!!\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
CONSOLE_8195A();
|
||||
}
|
||||
|
||||
extern u8** GetArgv(const u8 *string);
|
||||
#if SUPPORT_LOG_SERVICE
|
||||
extern char log_buf[LOG_SERVICE_BUFLEN];
|
||||
extern xSemaphoreHandle log_rx_interrupt_sema;
|
||||
#endif
|
||||
//======================================================
|
||||
void console_cmd_exec(PUART_LOG_CTL pUartLogCtlExe)
|
||||
{
|
||||
u8 CmdCnt = 0;
|
||||
u8 argc = 0;
|
||||
u8 **argv;
|
||||
//u32 CmdNum;
|
||||
PUART_LOG_BUF pUartLogBuf = pUartLogCtlExe->pTmpLogBuf;
|
||||
#if SUPPORT_LOG_SERVICE
|
||||
strncpy(log_buf, (const u8*)&(*pUartLogBuf).UARTLogBuf[0], LOG_SERVICE_BUFLEN-1);
|
||||
#endif
|
||||
argc = GetArgc((const u8*)&((*pUartLogBuf).UARTLogBuf[0]));
|
||||
argv = GetArgv((const u8*)&((*pUartLogBuf).UARTLogBuf[0]));
|
||||
|
||||
if(argc > 0){
|
||||
#if SUPPORT_LOG_SERVICE
|
||||
// if(log_handler(argv[0]) == NULL)
|
||||
// legency_interactive_handler(argc, argv);
|
||||
//RtlUpSema((_Sema *)&log_rx_interrupt_sema);
|
||||
rtw_up_sema((_sema *)&log_rx_interrupt_sema);
|
||||
#endif
|
||||
ArrayInitialize(argv[0], sizeof(argv[0]) ,0);
|
||||
}else{
|
||||
#if defined(configUSE_WAKELOCK_PMU) && (configUSE_WAKELOCK_PMU == 1)
|
||||
pmu_acquire_wakelock(BIT(PMU_LOGUART_DEVICE));
|
||||
#endif
|
||||
CONSOLE_8195A(); // for null command
|
||||
}
|
||||
|
||||
(*pUartLogBuf).BufCount = 0;
|
||||
ArrayInitialize(&(*pUartLogBuf).UARTLogBuf[0], UART_LOG_CMD_BUFLEN, '\0');
|
||||
}
|
||||
//======================================================
|
||||
// overload original RtlConsolTaskRam
|
||||
//MON_RAM_TEXT_SECTION
|
||||
VOID
|
||||
RtlConsolTaskRam(
|
||||
VOID *Data
|
||||
)
|
||||
{
|
||||
#if SUPPORT_LOG_SERVICE
|
||||
log_service_init();
|
||||
#endif
|
||||
//4 Set this for UartLog check cmd history
|
||||
#ifdef CONFIG_KERNEL
|
||||
pUartLogCtl->TaskRdy = 1;
|
||||
up_sema_from_isr = rtw_up_sema_from_isr;
|
||||
#endif
|
||||
#ifndef CONFIG_KERNEL
|
||||
pUartLogCtl->BootRdy = 1;
|
||||
#endif
|
||||
do{
|
||||
#if defined(CONFIG_KERNEL) && !TASK_SCHEDULER_DISABLED
|
||||
//RtlDownSema((_Sema *)&pUartLogCtl->Sema);
|
||||
rtw_down_sema((_sema *)&pUartLogCtl->Sema);
|
||||
#endif
|
||||
if (pUartLogCtl->ExecuteCmd) {
|
||||
// Add command handler here
|
||||
console_cmd_exec((PUART_LOG_CTL)pUartLogCtl);
|
||||
//UartLogCmdExecute((PUART_LOG_CTL)pUartLogCtl);
|
||||
pUartLogCtl->ExecuteCmd = _FALSE;
|
||||
}
|
||||
}while(1);
|
||||
}
|
||||
|
||||
//======================================================
|
||||
#if BUFFERED_PRINTF
|
||||
xTaskHandle print_task = NULL;
|
||||
EventGroupHandle_t print_event = NULL;
|
||||
char print_buffer[MAX_PRINTF_BUF_LEN];
|
||||
int flush_idx = 0;
|
||||
int used_length = 0;
|
||||
|
||||
int available_space(void)
|
||||
{
|
||||
return MAX_PRINTF_BUF_LEN-used_length;
|
||||
}
|
||||
|
||||
int buffered_printf(const char* fmt, ...)
|
||||
{
|
||||
if((print_task==NULL) || (print_event==NULL) )
|
||||
return 0;
|
||||
char tmp_buffer[UART_LOG_CMD_BUFLEN+1];
|
||||
static int print_idx = 0;
|
||||
int cnt;
|
||||
|
||||
if(xEventGroupGetBits(print_event)!=1)
|
||||
xEventGroupSetBits(print_event, 1);
|
||||
|
||||
memset(tmp_buffer,0,UART_LOG_CMD_BUFLEN+1);
|
||||
VSprintf(tmp_buffer, fmt, ((const int *)&fmt)+1);
|
||||
cnt = _strlen(tmp_buffer);
|
||||
if(cnt < available_space()){
|
||||
if(print_idx >= flush_idx){
|
||||
if(MAX_PRINTF_BUF_LEN-print_idx >= cnt){
|
||||
memcpy(&print_buffer[print_idx], tmp_buffer, cnt);
|
||||
}else{
|
||||
memcpy(&print_buffer[print_idx], tmp_buffer, MAX_PRINTF_BUF_LEN-print_idx);
|
||||
memcpy(&print_buffer[0], &tmp_buffer[MAX_PRINTF_BUF_LEN-print_idx], cnt-(MAX_PRINTF_BUF_LEN-print_idx));
|
||||
}
|
||||
}else{ // space is flush_idx - print_idx, and available space is enough
|
||||
memcpy(&print_buffer[print_idx], tmp_buffer, cnt);
|
||||
}
|
||||
// protection needed
|
||||
taskENTER_CRITICAL();
|
||||
used_length+=cnt;
|
||||
taskEXIT_CRITICAL();
|
||||
print_idx+=cnt;
|
||||
if(print_idx>=MAX_PRINTF_BUF_LEN)
|
||||
print_idx -= MAX_PRINTF_BUF_LEN;
|
||||
}else{
|
||||
// skip
|
||||
cnt = 0;
|
||||
}
|
||||
|
||||
return cnt;
|
||||
}
|
||||
|
||||
|
||||
void printing_task(void* arg)
|
||||
{
|
||||
while(1){
|
||||
//wait event
|
||||
if(xEventGroupWaitBits(print_event, 1, pdFALSE, pdFALSE, 100 ) == 1){
|
||||
while(used_length > 0){
|
||||
putchar(print_buffer[flush_idx]);
|
||||
flush_idx++;
|
||||
if(flush_idx >= MAX_PRINTF_BUF_LEN)
|
||||
flush_idx-=MAX_PRINTF_BUF_LEN;
|
||||
taskENTER_CRITICAL();
|
||||
used_length--;
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
// clear event
|
||||
xEventGroupClearBits( print_event, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void rtl_printf_init()
|
||||
{
|
||||
if(print_event==NULL){
|
||||
print_event = xEventGroupCreate();
|
||||
if(print_event == NULL)
|
||||
printf("\n\rprint event init fail!\n");
|
||||
}
|
||||
if(print_task == NULL){
|
||||
if(xTaskCreate(printing_task, (const char *)"print_task", 512, NULL, tskIDLE_PRIORITY + 1, &print_task) != pdPASS)
|
||||
printf("\n\rprint task init fail!\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//======================================================
|
||||
|
||||
|
||||
__weak void console_init(void)
|
||||
{
|
||||
|
||||
IRQ_HANDLE UartIrqHandle;
|
||||
|
||||
//4 Register Log Uart Callback function
|
||||
UartIrqHandle.Data = NULL;//(u32)&UartAdapter;
|
||||
UartIrqHandle.IrqNum = UART_LOG_IRQ;
|
||||
UartIrqHandle.IrqFun = (IRQ_FUN) UartLogIrqHandleRam;
|
||||
UartIrqHandle.Priority = 6;
|
||||
|
||||
|
||||
//4 Register Isr handle
|
||||
InterruptUnRegister(&UartIrqHandle);
|
||||
InterruptRegister(&UartIrqHandle);
|
||||
|
||||
|
||||
|
||||
#if !TASK_SCHEDULER_DISABLED
|
||||
RtlConsolInitRam((u32)RAM_STAGE,(u32)0,(VOID*)NULL);
|
||||
#else
|
||||
RtlConsolInitRam((u32)ROM_STAGE,(u32)0,(VOID*)NULL);
|
||||
#endif
|
||||
|
||||
#if BUFFERED_PRINTF
|
||||
rtl_printf_init();
|
||||
#endif
|
||||
}
|
||||
140
component/soc/realtek/8195a/misc/driver/rtl_consol.h
Normal file
140
component/soc/realtek/8195a/misc/driver/rtl_consol.h
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _RTK_CONSOL_H_
|
||||
#define _RTK_CONSOL_H_
|
||||
/*
|
||||
* Include user defined options first. Anything not defined in these files
|
||||
* will be set to standard values. Override anything you dont like!
|
||||
*/
|
||||
#if defined(CONFIG_PLATFORM_8195A) || defined(CONFIG_PLATFORM_8711B)
|
||||
#include "platform_opts.h"
|
||||
#endif
|
||||
|
||||
//#include "osdep_api.h"
|
||||
#include "osdep_service.h"
|
||||
#include "hal_diag.h"
|
||||
#include "platform_stdlib.h"
|
||||
|
||||
#define CONSOLE_PREFIX "#"
|
||||
|
||||
|
||||
//Log UART
|
||||
//UART_LOG_CMD_BUFLEN: only 126 bytes could be used for keeping input
|
||||
// cmd, the last byte is for string end ('\0').
|
||||
#define UART_LOG_CMD_BUFLEN 127
|
||||
#define MAX_ARGV 10
|
||||
|
||||
//print log buffer length, if buffer get full, the extra logs will be discarded.
|
||||
#if BUFFERED_PRINTF
|
||||
#define MAX_PRINTF_BUF_LEN 1024
|
||||
#endif
|
||||
|
||||
|
||||
typedef u32 (*ECHOFUNC)(IN u8*,...); //UART LOG echo-function type.
|
||||
|
||||
typedef struct _UART_LOG_BUF_ {
|
||||
u8 BufCount; //record the input cmd char number.
|
||||
u8 UARTLogBuf[UART_LOG_CMD_BUFLEN]; //record the input command.
|
||||
} UART_LOG_BUF, *PUART_LOG_BUF;
|
||||
|
||||
|
||||
|
||||
typedef struct _UART_LOG_CTL_ {
|
||||
u8 NewIdx;
|
||||
u8 SeeIdx;
|
||||
u8 RevdNo;
|
||||
u8 EscSTS;
|
||||
u8 ExecuteCmd;
|
||||
u8 ExecuteEsc;
|
||||
u8 BootRdy;
|
||||
u8 Resvd;
|
||||
PUART_LOG_BUF pTmpLogBuf;
|
||||
VOID *pfINPUT;
|
||||
PCOMMAND_TABLE pCmdTbl;
|
||||
u32 CmdTblSz;
|
||||
#ifdef CONFIG_UART_LOG_HISTORY
|
||||
u32 CRSTS;
|
||||
#endif
|
||||
#ifdef CONFIG_UART_LOG_HISTORY
|
||||
u8 (*pHistoryBuf)[UART_LOG_CMD_BUFLEN];
|
||||
#endif
|
||||
#ifdef CONFIG_KERNEL
|
||||
u32 TaskRdy;
|
||||
//_Sema Sema;
|
||||
_sema Sema;
|
||||
#else
|
||||
// Since ROM code will reference this typedef, so keep the typedef same size
|
||||
u32 TaskRdy;
|
||||
void *Sema;
|
||||
#endif
|
||||
} UART_LOG_CTL, *PUART_LOG_CTL;
|
||||
|
||||
|
||||
#define KB_ASCII_NUL 0x00
|
||||
#define KB_ASCII_BS 0x08
|
||||
#define KB_ASCII_TAB 0x09
|
||||
#define KB_ASCII_LF 0x0A
|
||||
#define KB_ASCII_CR 0x0D
|
||||
#define KB_ASCII_ESC 0x1B
|
||||
#define KB_ASCII_SP 0x20
|
||||
#define KB_ASCII_BS_7F 0x7F
|
||||
#define KB_ASCII_LBRKT 0x5B //[
|
||||
|
||||
#define KB_SPACENO_TAB 1
|
||||
|
||||
#ifdef CONFIG_UART_LOG_HISTORY
|
||||
#define UART_LOG_HISTORY_LEN 5
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DEBUG_LOG
|
||||
#define _ConsolePrint DiagPrintf
|
||||
#else
|
||||
#define _ConsolePrint
|
||||
#endif
|
||||
|
||||
#ifndef CONSOLE_PREFIX
|
||||
#define CONSOLE_PREFIX "<RTL8195A>"
|
||||
#endif
|
||||
|
||||
#define CONSOLE_8195A(...) do {\
|
||||
_ConsolePrint("\r"CONSOLE_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
|
||||
_LONG_CALL_ VOID
|
||||
RtlConsolInit(
|
||||
IN u32 Boot,
|
||||
IN u32 TBLSz,
|
||||
IN VOID *pTBL
|
||||
);
|
||||
|
||||
#if defined(CONFIG_KERNEL)
|
||||
_LONG_CALL_ VOID
|
||||
RtlConsolTaskRam(
|
||||
VOID *Data
|
||||
);
|
||||
#endif
|
||||
|
||||
_LONG_CALL_ VOID
|
||||
RtlConsolTaskRom(
|
||||
VOID *Data
|
||||
);
|
||||
|
||||
|
||||
_LONG_CALL_ u32
|
||||
Strtoul(
|
||||
IN const u8 *nptr,
|
||||
IN u8 **endptr,
|
||||
IN u32 base
|
||||
);
|
||||
|
||||
void console_init(void);
|
||||
|
||||
#endif //_RTK_CONSOL_H_
|
||||
12
component/soc/realtek/8195a/misc/driver/rtl_sec.h
Normal file
12
component/soc/realtek/8195a/misc/driver/rtl_sec.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#ifndef RTL_SEC_H
|
||||
#define RTL_SEC_H
|
||||
|
||||
#include <platform_stdlib.h>
|
||||
|
||||
#define SEC_PROCESS_OPT_ENC 1
|
||||
#define SEC_PROCESS_OPT_DEC 2
|
||||
|
||||
#define sec_process_data ProcessSecData
|
||||
uint32_t sec_process_data(uint8_t key_idx, uint32_t opt, uint8_t *iv, uint8_t *input_buf, uint32_t buf_len, uint8_t *output_buf);
|
||||
|
||||
#endif // RTL_SEC_H
|
||||
77
component/soc/realtek/8195a/misc/gcc_utility/Check_Jtag.sh
Normal file
77
component/soc/realtek/8195a/misc/gcc_utility/Check_Jtag.sh
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
#!/bin/sh
|
||||
|
||||
#===============================================================================
|
||||
CURRENT_UTILITY_DIR=$(pwd)
|
||||
GDBSCPTFILE="../../../component/soc/realtek/8195a/misc/gcc_utility/rtl_gdb_flash_write.txt"
|
||||
|
||||
#===============================================================================
|
||||
RLXSTS=$(ps -W | grep "rlx_probe_driver.exe" | grep -v "grep" | wc -l)
|
||||
echo $RLXSTS
|
||||
JLKSTS=$(ps -W | grep "JLinkGDBServer.exe" | grep -v "grep" | wc -l)
|
||||
echo $JLKSTS
|
||||
|
||||
echo $CURRENT_UTILITY_DIR
|
||||
|
||||
#===============================================================================
|
||||
#make the new string for being written
|
||||
if [ $RLXSTS = 1 ]
|
||||
then
|
||||
echo "probe get"
|
||||
|
||||
#-------------------------------------------
|
||||
LINE_NUMBER=$(grep -n "monitor reset " $GDBSCPTFILE | awk -F":" '{print $1}')
|
||||
DEFAULT_STR=$(grep -n "monitor reset " $GDBSCPTFILE | awk -F":" '{print $2}')
|
||||
#echo $LINE_NUMBER
|
||||
echo $DEFAULT_STR
|
||||
STRLEN_DFT=$(expr length "$DEFAULT_STR")
|
||||
DEFAULT_STR="#monitor reset 1"
|
||||
echo $DEFAULT_STR
|
||||
#-------------------------------------------
|
||||
SED_PARA="$LINE_NUMBER""c""$DEFAULT_STR"
|
||||
sed -i "$SED_PARA" $GDBSCPTFILE
|
||||
|
||||
#===========================================
|
||||
LINE_NUMBER=$(grep -n "monitor sleep " $GDBSCPTFILE | awk -F":" '{print $1}')
|
||||
DEFAULT_STR=$(grep -n "monitor sleep " $GDBSCPTFILE | awk -F":" '{print $2}')
|
||||
#echo $LINE_NUMBER
|
||||
echo $DEFAULT_STR
|
||||
STRLEN_DFT=$(expr length "$DEFAULT_STR")
|
||||
DEFAULT_STR="#monitor sleep 20"
|
||||
echo $DEFAULT_STR
|
||||
#-------------------------------------------
|
||||
SED_PARA="$LINE_NUMBER""c""$DEFAULT_STR"
|
||||
sed -i "$SED_PARA" $GDBSCPTFILE
|
||||
else
|
||||
|
||||
if [ $JLKSTS = 1 ]
|
||||
then
|
||||
echo "jlink get"
|
||||
|
||||
#-------------------------------------------
|
||||
LINE_NUMBER=$(grep -n "monitor reset " $GDBSCPTFILE | awk -F":" '{print $1}')
|
||||
DEFAULT_STR=$(grep -n "monitor reset " $GDBSCPTFILE | awk -F":" '{print $2}')
|
||||
#echo $LINE_NUMBER
|
||||
echo $DEFAULT_STR
|
||||
STRLEN_DFT=$(expr length "$DEFAULT_STR")
|
||||
DEFAULT_STR="monitor reset 1"
|
||||
echo $DEFAULT_STR
|
||||
#-------------------------------------------
|
||||
SED_PARA="$LINE_NUMBER""c""$DEFAULT_STR"
|
||||
sed -i "$SED_PARA" $GDBSCPTFILE
|
||||
|
||||
#===========================================
|
||||
LINE_NUMBER=$(grep -n "monitor sleep " $GDBSCPTFILE | awk -F":" '{print $1}')
|
||||
DEFAULT_STR=$(grep -n "monitor sleep " $GDBSCPTFILE | awk -F":" '{print $2}')
|
||||
#echo $LINE_NUMBER
|
||||
echo $DEFAULT_STR
|
||||
STRLEN_DFT=$(expr length "$DEFAULT_STR")
|
||||
DEFAULT_STR="monitor sleep 20"
|
||||
echo $DEFAULT_STR
|
||||
#-------------------------------------------
|
||||
SED_PARA="$LINE_NUMBER""c""$DEFAULT_STR"
|
||||
sed -i "$SED_PARA" $GDBSCPTFILE
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
#===============================================================================
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/sh
|
||||
|
||||
#===============================================================================
|
||||
CURRENT_UTILITY_DIR=$(pwd)
|
||||
echo "..."
|
||||
echo $CURRENT_UTILITY_DIR
|
||||
RAMFILENAME="./application/Debug/bin/ram_all.bin"
|
||||
echo $RAMFILENAME
|
||||
#RAMFILENAME="ram_2.bin"
|
||||
GDBSCPTFILE="../../../component/soc/realtek/8195a/misc/gcc_utility/rtl_gdb_flash_write.txt"
|
||||
|
||||
#===============================================================================
|
||||
#get file size
|
||||
RAM_FILE_SIZE=$(stat -c %s $RAMFILENAME)
|
||||
RAM_FILE_SIZE_HEX=`echo "obase=16; $RAM_FILE_SIZE"|bc`
|
||||
|
||||
echo "size "$RAM_FILE_SIZE" --> 0x"$RAM_FILE_SIZE_HEX
|
||||
|
||||
echo "set \$RamFileSize = 0x$RAM_FILE_SIZE_HEX" > fwsize.gdb
|
||||
exit
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
@echo off
|
||||
|
||||
set RAMFILENAME=".\Debug\ram_all.bin"
|
||||
::echo %RAMFILENAME%
|
||||
|
||||
cp ..\..\..\..\..\component\soc\realtek\8195a\misc\gcc_utility\target_NORMALB.axf ..\..\..\..\..\component\soc\realtek\8195a\misc\gcc_utility\target_NORMAL.axf
|
||||
|
||||
::===============================================================================
|
||||
::get file size and translate to HEX
|
||||
for %%A in (%RAMFILENAME%) do set fileSize=%%~zA
|
||||
@call :toHex %fileSize% fileSizeHex
|
||||
|
||||
::echo %fileSize%
|
||||
::echo %fileSizeHex%
|
||||
|
||||
echo set $RamFileSize = 0x%fileSizeHex% > .\Debug\fwsize.gdb
|
||||
|
||||
:: start GDB for flash write, argument 1 (%1) could be rather "openocd" or "jlink"
|
||||
::echo %1
|
||||
..\..\..\..\..\tools\arm-none-eabi-gcc\4_8-2014q3\bin\arm-none-eabi-gdb -x ..\..\..\..\..\component\soc\realtek\8195a\misc\gcc_utility\eclipse\rtl_eclipse_flash_write_%1.txt
|
||||
|
||||
exit
|
||||
|
||||
:toHex dec hex -- convert a decimal number to hexadecimal, i.e. -20 to FFFFFFEC or 26 to 0000001A
|
||||
@echo off
|
||||
SETLOCAL ENABLEDELAYEDEXPANSION
|
||||
set /a dec=%~1
|
||||
set "hex="
|
||||
set "map=0123456789ABCDEF"
|
||||
for /L %%N in (1,1,8) do (
|
||||
set /a "d=dec&15,dec>>=4"
|
||||
for %%D in (!d!) do set "hex=!map:~%%D,1!!hex!"
|
||||
)
|
||||
|
||||
( ENDLOCAL & REM RETURN VALUES
|
||||
IF "%~2" NEQ "" (SET %~2=%hex%) ELSE ECHO.%hex%
|
||||
)
|
||||
EXIT /b
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
:: application/Debug
|
||||
@echo off
|
||||
|
||||
set bindir=.
|
||||
set gccdir=..\..\..\..\..\..\tools\arm-none-eabi-gcc\4_8-2014q3\bin
|
||||
|
||||
::e.g. arm-none-eabi-gcc -c -mcpu=cortex-m3 -mthumb -std=gnu99 -DGCC_ARMCM3 -DM3 -DCONFIG_PLATFORM_8195A -DF_CPU=166000000L -I..\..\..\..\inc -I..\..\..\..\..\..\component\soc\realtek\common\bsp -I..\..\..\..\..\..\component\os\freertos -I..\..\..\..\..\..\component\os\freertos\freertos_v8.1.2\Source\include -I..\..\..\..\..\..\component\os\freertos\freertos_v8.1.2\Source\portable\GCC\ARM_CM3 -I..\..\..\..\..\..\component\os\os_dep\include -I..\..\..\..\..\..\component\soc\realtek\8195a\misc\driver -I..\..\..\..\..\..\component\common\api\network\include -I..\..\..\..\..\..\component\common\api -I..\..\..\..\..\..\component\common\api\platform -I..\..\..\..\..\..\component\common\api\wifi -I..\..\..\..\..\..\component\common\api\wifi\rtw_wpa_supplicant\src -I..\..\..\..\..\..\component\common\application -I..\..\..\..\..\..\component\common\media\framework -I..\..\..\..\..\..\component\common\example -I..\..\..\..\..\..\component\common\example\wlan_fast_connect -I..\..\..\..\..\..\component\common\mbed\api -I..\..\..\..\..\..\component\common\mbed\hal -I..\..\..\..\..\..\component\common\mbed\hal_ext -I..\..\..\..\..\..\component\common\mbed\targets\hal\rtl8195a -I..\..\..\..\..\..\component\common\network -I..\..\..\..\..\..\component\common\network\lwip\lwip_v1.4.1\port\realtek\freertos -I..\..\..\..\..\..\component\common\network\lwip\lwip_v1.4.1\src\include -I..\..\..\..\..\..\component\common\network\lwip\lwip_v1.4.1\src\include\lwip -I..\..\..\..\..\..\component\common\network\lwip\lwip_v1.4.1\src\include\ipv4 -I..\..\..\..\..\..\component\common\network\lwip\lwip_v1.4.1\port\realtek -I..\..\..\..\..\..\component\common\test -I..\..\..\..\..\..\component\soc\realtek\8195a\cmsis -I..\..\..\..\..\..\component\soc\realtek\8195a\cmsis\device -I..\..\..\..\..\..\component\soc\realtek\8195a\fwlib -I..\..\..\..\..\..\component\soc\realtek\8195a\fwlib\rtl8195a -I..\..\..\..\..\..\component\soc\realtek\8195a\misc\rtl_std_lib\include -I..\..\..\..\..\..\component\common\drivers\wlan\realtek\include -I..\..\..\..\..\..\component\common\drivers\wlan\realtek\src\osdep -I..\..\..\..\..\..\component\soc\realtek\8195a\fwlib\ram_lib\wlan\realtek\wlan_ram_map\rom -I..\..\..\..\..\..\component\common\network\ssl\polarssl-1.3.8\include -I..\..\..\..\..\..\component\common\network\ssl\ssl_ram_map\rom -I..\..\..\..\..\..\component\common\utilities -I..\..\..\..\..\..\component\soc\realtek\8195a\misc\rtl_std_lib\include -I..\..\..\..\..\..\component\soc\realtek\8195a\fwlib\ram_lib\usb_otg\include -I..\..\..\..\..\..\component\common\video\v4l2\inc -I..\..\..\..\..\..\component\common\media\codec -I..\..\..\..\..\..\component\common\drivers\usb_class\host\uvc\inc -I..\..\..\..\..\..\component\common\drivers\usb_class\device -I..\..\..\..\..\..\component\common\drivers\usb_class\device\class -I..\..\..\..\..\..\component\common\file_system\fatfs -I..\..\..\..\..\..\component\common\file_system\fatfs\r0.10c\include -I..\..\..\..\..\..\component\common\drivers\sdio\realtek\sdio_host\inc -I..\..\..\..\..\..\component\common\audio -I..\..\..\..\..\..\component\common\drivers\i2s -I..\..\..\..\..\..\component\common\application\apple\WACServer\External\Curve25519 -I..\..\..\..\..\..\component\common\application\apple\WACServer\External\GladmanAES -I..\..\..\..\..\..\component\common\application\google -I..\..\..\..\..\..\component\common\application\xmodem -O2 -g -Wno-pointer-sign -fno-common -fmessage-length=0 -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-short-enums -fsigned-char -MMD -MP -MFSDRAM/polarssl/aes.d -MTSDRAM/polarssl/aes.o -o SDRAM/polarssl/aes.o D:/test/sdk-ameba1-v3.5b_beta_v2/component/common/network/ssl/polarssl-1.3.8/library/aes.c
|
||||
|
||||
REM get last two argument which is the output object file
|
||||
call :GetLastTwoArg %*
|
||||
::echo %lastTwoArg%
|
||||
|
||||
:: check argument count
|
||||
::set argC=0
|
||||
::for %%x in (%*) do Set /A argC+=1
|
||||
::echo %argC%
|
||||
|
||||
:: gcc compile, %1 might be gcc or arm-none-eabi-gcc
|
||||
set arg1=%1
|
||||
if not "%arg1:arm-none-eabi-=%" == "%arg1%" (
|
||||
::echo is arm-none-eabi-gcc
|
||||
%gccdir%\%*
|
||||
) else (
|
||||
::echo is gcc
|
||||
%gccdir%\arm-none-eabi-%*
|
||||
)
|
||||
|
||||
:: objcopy append .sdram section info
|
||||
%gccdir%\arm-none-eabi-objcopy --prefix-alloc-sections .sdram %lastTwoArg%
|
||||
|
||||
REM This subroutine gets the last command-line argument by using SHIFT
|
||||
:GetLastTwoArg
|
||||
set "lastTwoArg=%~1"
|
||||
shift
|
||||
if not "%~2"=="" goto GetLastTwoArg
|
||||
goto :eof
|
||||
|
||||
exit
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
:: application/Debug
|
||||
@echo off
|
||||
|
||||
set bindir=.
|
||||
set tooldir=..\..\..\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\tools
|
||||
set libdir=..\..\..\..\..\..\component\soc\realtek\8195a\misc\bsp
|
||||
set gccdir=..\..\..\..\..\..\tools\arm-none-eabi-gcc\4_8-2014q3\bin
|
||||
|
||||
::echo %tooldir%
|
||||
::echo %libdir%
|
||||
|
||||
::copy bootloader and convert from image to object file
|
||||
::copy ../../../../../component/soc/realtek/8195a/misc/bsp/image/ram_1.r.bin ram_1.r.bin
|
||||
::%gccdir%/arm-none-eabi-objcopy --rename-section .data=.loader.data,contents,alloc,load,readonly,data -I binary -O elf32-littlearm -B arm ram_1.r.bin ram_1.r.o
|
||||
|
||||
::del Debug/Exe/target.map Debug/Exe/application.asm *.bin
|
||||
cmd /c "%gccdir%\arm-none-eabi-nm %bindir%/application.axf | %tooldir%\sort > %bindir%/application.nm.map"
|
||||
cmd /c "%gccdir%\arm-none-eabi-objdump -d %bindir%/application.axf > %bindir%/application.asm"
|
||||
|
||||
|
||||
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep __ram_image2_text_start__ %bindir%/application.nm.map | %tooldir%\gawk '{print $1}'"') do set ram2_start=0x%%i
|
||||
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep __sdram_data_start__ %bindir%/application.nm.map | %tooldir%\gawk '{print $1}'"') do set ram3_start=0x%%i
|
||||
|
||||
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep __ram_image2_text_end__ %bindir%/application.nm.map | %tooldir%\gawk '{print $1}'"') do set ram2_end=0x%%i
|
||||
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep __sdram_data_end__ %bindir%/application.nm.map | %tooldir%\gawk '{print $1}'"') do set ram3_end=0x%%i
|
||||
|
||||
::echo %ram1_start% > tmp.txt
|
||||
echo %ram2_start%
|
||||
echo %ram3_start%
|
||||
::echo %ram1_end% >> tmp.txt
|
||||
echo %ram2_end%
|
||||
echo %ram3_end%
|
||||
|
||||
|
||||
%gccdir%\arm-none-eabi-objcopy -j .image2.start.table -j .ram_image2.text -j .ram_image2.rodata -j .ram.data -Obinary %bindir%/application.axf %bindir%/ram_2.bin
|
||||
if NOT %ram3_start% == %ram3_end% (
|
||||
%gccdir%\arm-none-eabi-objcopy -j .sdr_text -j .sdr_rodata -j .sdr_data -Obinary %bindir%/application.axf %bindir%/sdram.bin
|
||||
)
|
||||
|
||||
%tooldir%\pick %ram2_start% %ram2_end% %bindir%\ram_2.bin %bindir%\ram_2.p.bin body+reset_offset+sig
|
||||
if defined %ram3_start (
|
||||
%tooldir%\pick %ram3_start% %ram3_end% %bindir%\sdram.bin %bindir%\ram_3.p.bin body+reset_offset
|
||||
)
|
||||
|
||||
:: check ram_1.p.bin exist, copy default
|
||||
if not exist %bindir%\ram_1.p.bin (
|
||||
copy %libdir%\image\ram_1.p.bin %bindir%\ram_1.p.bin
|
||||
)
|
||||
|
||||
::padding ram_1.p.bin to 32K+4K+4K+4K, LOADER/RSVD/SYSTEM/CALIBRATION
|
||||
%tooldir%\padding 44k 0xFF %bindir%\ram_1.p.bin
|
||||
|
||||
:: SDRAM case
|
||||
if defined %ram3_start (
|
||||
copy /b %bindir%\ram_1.p.bin+%bindir%\ram_2.p.bin+%bindir%\ram_3.p.bin %bindir%\ram_all.bin
|
||||
copy /b %bindir%\ram_2.p.bin+%bindir%\ram_3.p.bin %bindir%\ota.bin
|
||||
)
|
||||
|
||||
%tooldir%\checksum Debug\Exe\ota.bin
|
||||
|
||||
:: NO SDRAM case
|
||||
if not defined %ram3_start (
|
||||
copy /b %bindir%\ram_1.p.bin+%bindir%\ram_2.p.bin %bindir%\ram_all.bin
|
||||
copy /b %bindir%\ram_2.p.bin %bindir%\ota.bin
|
||||
)
|
||||
|
||||
del ram_1.r.*
|
||||
del ram*.p.bin
|
||||
del ram_2.bin
|
||||
if exist sdram.bin (
|
||||
del sdram.bin
|
||||
)
|
||||
|
||||
exit
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
:: application/Debug
|
||||
@echo off
|
||||
|
||||
set bindir=.
|
||||
|
||||
:: unzip arm-none-eabi-gcc\4_8-2014q3.tar
|
||||
set tooldir=..\..\..\..\..\..\component\soc\realtek\8195a\misc\gcc_utility\tools
|
||||
set currentdir=%cd%
|
||||
|
||||
:CheckOS
|
||||
if exist "%PROGRAMFILES(X86)%" (goto 64bit) else (goto 32bit)
|
||||
:64bit
|
||||
set os_prefix=x86_64
|
||||
goto next
|
||||
:32bit
|
||||
set os_prefix=x86
|
||||
:next
|
||||
|
||||
if not exist ..\..\..\..\..\..\tools\arm-none-eabi-gcc\4_8-2014q3\ (
|
||||
:: %tooldir%\%os_prefix%\gzip -dc ..\..\..\..\..\..\tools\arm-none-eabi-gcc\4.8.3-2014q1.tar.gz > ..\..\..\..\..\..\tools\arm-none-eabi-gcc\4.8.3-2014q1.tar
|
||||
cd ..\..\..\..\..\..\tools\arm-none-eabi-gcc
|
||||
..\..\component\soc\realtek\8195a\misc\gcc_utility\tools\%os_prefix%\tar -xf 4_8-2014q3.tar
|
||||
cd %currentdir%
|
||||
)
|
||||
|
||||
set gccdir=..\..\..\..\..\..\tools\arm-none-eabi-gcc\4_8-2014q3\bin
|
||||
|
||||
::echo %tooldir%
|
||||
|
||||
:: Generate build_info.h
|
||||
for /f "usebackq" %%i in (`hostname`) do set hostname=%%i
|
||||
|
||||
echo #define UTS_VERSION "%date:~0,10%-%time:~0,8%" > ..\..\..\..\inc\build_info.h
|
||||
echo #define RTL8195AFW_COMPILE_TIME "%date:~0,10%-%time:~0,8%" >> ..\..\..\..\inc\build_info.h
|
||||
echo #define RTL8195AFW_COMPILE_DATE "%date:~0,4%%date:~5,2%%date:~8,2%" >> ..\..\..\..\inc\build_info.h
|
||||
echo #define RTL8195AFW_COMPILE_BY "%USERNAME%" >> ..\..\..\..\inc\build_info.h
|
||||
echo #define RTL8195AFW_COMPILE_HOST "%hostname%" >> ..\..\..\..\inc\build_info.h
|
||||
echo #define RTL8195AFW_COMPILE_DOMAIN >> ..\..\..\..\inc\build_info.h
|
||||
echo #define RTL195AFW_COMPILER "GCC compiler" >> ..\..\..\..\inc\build_info.h
|
||||
|
||||
xcopy /Y ..\..\..\rlx8195A-symbol-v02-img2.ld .
|
||||
xcopy /Y ..\..\..\export-rom_v02.txt .
|
||||
|
||||
::copy bootloader and convert from image to object file
|
||||
xcopy /Y ..\..\..\..\..\..\component\soc\realtek\8195a\misc\bsp\image\ram_1.r.bin .
|
||||
%gccdir%\arm-none-eabi-objcopy --rename-section .data=.loader.data,contents,alloc,load,readonly,data -I binary -O elf32-littlearm -B arm ram_1.r.bin ram_1.r.o
|
||||
|
||||
exit
|
||||
|
|
@ -0,0 +1,199 @@
|
|||
# GDB script for loading ram.bin process
|
||||
|
||||
#===============================================================================
|
||||
#set GDB connection
|
||||
set remotetimeout 100000
|
||||
target remote :2331
|
||||
|
||||
#===============================================================================
|
||||
#set file path
|
||||
set $BINFILE = "./Debug/ram_all.bin"
|
||||
|
||||
#===============================================================================
|
||||
#Message display setting
|
||||
#disable all messages
|
||||
|
||||
set verbose off
|
||||
set complaints 0
|
||||
set confirm off
|
||||
set exec-done-display off
|
||||
show exec-done-display
|
||||
set trace-commands off
|
||||
#set debug aix-thread off
|
||||
#set debug dwarf2-die 0
|
||||
set debug displaced off
|
||||
set debug expression 0
|
||||
set debug frame 0
|
||||
set debug infrun 0
|
||||
set debug observer 0
|
||||
set debug overload 0
|
||||
set debugvarobj 0
|
||||
set pagination off
|
||||
set print address off
|
||||
set print symbol-filename off
|
||||
set print symbol off
|
||||
set print pretty off
|
||||
set print object off
|
||||
#set debug notification off
|
||||
set debug parser off
|
||||
set debug remote 0
|
||||
|
||||
#===============================================================================
|
||||
#set JTAG and external SRAM
|
||||
monitor reset 1
|
||||
monitor sleep 20
|
||||
monitor clrbp
|
||||
#===============================================================================
|
||||
#Variables declaration (1)
|
||||
#binary file size
|
||||
set $RamFileSize = 0x0000
|
||||
source ./Debug/fwsize.gdb
|
||||
printf "-------------------------------\n"
|
||||
printf "RamFileSize: %x\n",$RamFileSize
|
||||
printf "-------------------------------\n"
|
||||
|
||||
#===============================================================================
|
||||
set $FLASHDATBUFSIZE = 0x800
|
||||
|
||||
#===============================================================================
|
||||
#define PERI_ON_BASE 0x40000000
|
||||
set $PERI_ON_BASE = 0x40000000
|
||||
#define REG_SOC_PERI_FUNC0_EN 0x0218
|
||||
set $REG_SOC_PERI_FUNC0_EN = 0x0210
|
||||
|
||||
#define SPI_FLASH_BASE 0x4000000
|
||||
set $SPI_FLASH_BASE = 0x98000000
|
||||
|
||||
#------------------------------------------------------------------
|
||||
set $Temp = 0x0
|
||||
|
||||
#===============================================================================
|
||||
#Load flash download file
|
||||
file ../../../../../component/soc/realtek/8195a/misc/gcc_utility/target_NORMAL.axf
|
||||
|
||||
#Load the file
|
||||
lo
|
||||
|
||||
printf "Load flash controller.\n"
|
||||
|
||||
#===============================================================================
|
||||
#Set for executing flash controller funciton
|
||||
set $Temp = {int}($PERI_ON_BASE+$REG_SOC_PERI_FUNC0_EN)
|
||||
p /x $Temp
|
||||
|
||||
set $Temp = ($Temp | (0x01 << 27))
|
||||
p /x $Temp
|
||||
|
||||
set {int}($PERI_ON_BASE+$REG_SOC_PERI_FUNC0_EN) = $Temp
|
||||
printf "....\n"
|
||||
printf "wakeup bit(%x):%x\n", ($PERI_ON_BASE+$REG_SOC_PERI_FUNC0_EN), {int}($PERI_ON_BASE+$REG_SOC_PERI_FUNC0_EN)
|
||||
#===============================================================================
|
||||
#Direct the startup wake function to flash program function
|
||||
#the function pointer address
|
||||
#set $testpointer = 0x200006b4
|
||||
#set $testpointer2 = 0x200006b8
|
||||
#set $FuntionPointer = 0x200006c4
|
||||
#set $FPTemp = 0x200a08e9
|
||||
#set {int}($FuntionPointer) = $FPTemp
|
||||
#printf "testpointer(%x):%x\n", $testpointer, {int}$testpointer
|
||||
#printf "testpointer2(%x):%x\n", $testpointer2, {int}$testpointer2
|
||||
#printf "FuntionPointer(%x):%x\n", $FuntionPointer, {int}$FuntionPointer
|
||||
|
||||
#===============================================================================
|
||||
#Load file
|
||||
# restore filename [binary] bias start end
|
||||
# Restore the contents of file filename into memory.
|
||||
# The restore command can automatically recognize any known bfd file format, except for raw binary.
|
||||
# To restore a raw binary file you must specify the optional keyword binary after the filename.
|
||||
#===============================================================================
|
||||
|
||||
set $LoopNum = ($RamFileSize / $FLASHDATBUFSIZE)
|
||||
printf "LoopNum = %x\n", $LoopNum
|
||||
set $TailSize = ($RamFileSize % $FLASHDATBUFSIZE)
|
||||
printf "TailSize = %x\n", $TailSize
|
||||
|
||||
printf "global variables\n"
|
||||
|
||||
set $FLASHDATSRC = 0x0
|
||||
set $FILESTARTADDR = 0X0
|
||||
set $FILEENDADDR = $FILESTARTADDR + $FLASHDATBUFSIZE
|
||||
|
||||
#b RtlFlashProgram:StartOfFlashBlockWrite
|
||||
b rtl_flash_download.c:489
|
||||
b rtl_flash_download.c:524
|
||||
#b Rtl_flash_control.c:RtlFlashProgram
|
||||
|
||||
#continue to 489
|
||||
c
|
||||
|
||||
# Mode 0: erase full chip, Mode 1: skip calibration section and erase to firmware size
|
||||
set EraseMode=1
|
||||
print EraseMode
|
||||
set FirmwareSize=$RamFileSize
|
||||
print FirmwareSize
|
||||
|
||||
#continue to 524
|
||||
c
|
||||
|
||||
#printf "...\n"
|
||||
set $FLASHDATSRC = FlashDatSrc
|
||||
printf "FlashDatSrc:%x\n", $FLASHDATSRC
|
||||
|
||||
printf "FlashBlockWriteSize "
|
||||
set FlashBlockWriteSize = $FLASHDATBUFSIZE
|
||||
#p /x FlashBlockWriteSize
|
||||
printf "FlashBlockWriteSize:%x\n", FlashBlockWriteSize
|
||||
|
||||
printf "FlashAddrForWrite"
|
||||
set FlashAddrForWrite = 0x0
|
||||
|
||||
|
||||
|
||||
printf "Flash write start...\n"
|
||||
set $LoopCnt = 0
|
||||
while ($LoopCnt < $LoopNum)
|
||||
p /x FlashAddrForWrite
|
||||
restore ./Debug/ram_all.bin binary ($FLASHDATSRC-$FILESTARTADDR) $FILESTARTADDR $FILEENDADDR
|
||||
c
|
||||
|
||||
printf "FILEENDADDR"
|
||||
p /x $FILEENDADDR
|
||||
set FlashBlockWriteSize = $FLASHDATBUFSIZE
|
||||
set FlashAddrForWrite = $FILEENDADDR
|
||||
set $FILESTARTADDR = $FILEENDADDR
|
||||
set $FILEENDADDR = $FILESTARTADDR + $FLASHDATBUFSIZE
|
||||
|
||||
set $LoopCnt = $LoopCnt + 0x01
|
||||
end
|
||||
|
||||
#set FlashBlockWriteSize = $FLASHDATBUFSIZE
|
||||
#set FlashAddrForWrite = $FILEENDADDR
|
||||
#set $FILESTARTADDR = $FILEENDADDR
|
||||
set $FILEENDADDR = $FILESTARTADDR + $TailSize
|
||||
restore ./Debug/ram_all.bin binary ($FLASHDATSRC-$FILESTARTADDR) $FILESTARTADDR $FILEENDADDR
|
||||
c
|
||||
|
||||
#Set complete flas
|
||||
set FlashWriteComplete = 0x1
|
||||
|
||||
printf "dump for check\n"
|
||||
|
||||
set $LoopCnt = 0
|
||||
set $dumpaddr = 0
|
||||
|
||||
set $dumpstartaddr = $SPI_FLASH_BASE
|
||||
set $dumpendaddr = $SPI_FLASH_BASE + $RamFileSize
|
||||
printf "start addr of dumping"
|
||||
p /x $dumpstartaddr
|
||||
printf "end addr of dumping"
|
||||
p /x $dumpendaddr
|
||||
dump binary memory ./Debug/dump.bin $dumpstartaddr $dumpendaddr
|
||||
|
||||
|
||||
delete
|
||||
b rtl_flash_download.c:556
|
||||
c
|
||||
|
||||
quit
|
||||
#===============================================================================
|
||||
|
||||
|
|
@ -0,0 +1,198 @@
|
|||
# GDB script for loading ram.bin process
|
||||
|
||||
#===============================================================================
|
||||
#set GDB connection
|
||||
set remotetimeout 100000
|
||||
target remote :3333
|
||||
|
||||
#===============================================================================
|
||||
#set file path
|
||||
set $BINFILE = "./Debug/ram_all.bin"
|
||||
|
||||
#===============================================================================
|
||||
#Message display setting
|
||||
#disable all messages
|
||||
|
||||
set verbose off
|
||||
set complaints 0
|
||||
set confirm off
|
||||
set exec-done-display off
|
||||
show exec-done-display
|
||||
set trace-commands off
|
||||
#set debug aix-thread off
|
||||
#set debug dwarf2-die 0
|
||||
set debug displaced off
|
||||
set debug expression 0
|
||||
set debug frame 0
|
||||
set debug infrun 0
|
||||
set debug observer 0
|
||||
set debug overload 0
|
||||
set debugvarobj 0
|
||||
set pagination off
|
||||
set print address off
|
||||
set print symbol-filename off
|
||||
set print symbol off
|
||||
set print pretty off
|
||||
set print object off
|
||||
#set debug notification off
|
||||
set debug parser off
|
||||
set debug remote 0
|
||||
|
||||
#===============================================================================
|
||||
#set JTAG and external SRAM
|
||||
monitor reset init
|
||||
monitor halt
|
||||
monitor sleep 20
|
||||
#===============================================================================
|
||||
#Variables declaration (1)
|
||||
#binary file size
|
||||
set $RamFileSize = 0x0000
|
||||
source ./Debug/fwsize.gdb
|
||||
printf "-------------------------------\n"
|
||||
printf "RamFileSize: %x\n",$RamFileSize
|
||||
printf "-------------------------------\n"
|
||||
|
||||
#===============================================================================
|
||||
set $FLASHDATBUFSIZE = 0x800
|
||||
|
||||
#===============================================================================
|
||||
#define PERI_ON_BASE 0x40000000
|
||||
set $PERI_ON_BASE = 0x40000000
|
||||
#define REG_SOC_PERI_FUNC0_EN 0x0218
|
||||
set $REG_SOC_PERI_FUNC0_EN = 0x0210
|
||||
|
||||
#define SPI_FLASH_BASE 0x4000000
|
||||
set $SPI_FLASH_BASE = 0x98000000
|
||||
|
||||
#------------------------------------------------------------------
|
||||
set $Temp = 0x0
|
||||
|
||||
#===============================================================================
|
||||
#Load flash download file
|
||||
file ../../../../../component/soc/realtek/8195a/misc/gcc_utility/target_NORMAL.axf
|
||||
|
||||
#Load the file
|
||||
lo
|
||||
|
||||
printf "Load flash controller.\n"
|
||||
#===============================================================================
|
||||
#Set for executing flash controller funciton
|
||||
set $Temp = {int}($PERI_ON_BASE+$REG_SOC_PERI_FUNC0_EN)
|
||||
p /x $Temp
|
||||
|
||||
set $Temp = ($Temp | (0x01 << 27))
|
||||
p /x $Temp
|
||||
|
||||
set {int}($PERI_ON_BASE+$REG_SOC_PERI_FUNC0_EN) = $Temp
|
||||
printf "....\n"
|
||||
printf "wakeup bit(%x):%x\n", ($PERI_ON_BASE+$REG_SOC_PERI_FUNC0_EN), {int}($PERI_ON_BASE+$REG_SOC_PERI_FUNC0_EN)
|
||||
#===============================================================================
|
||||
#Direct the startup wake function to flash program function
|
||||
#the function pointer address
|
||||
#set $testpointer = 0x200006b4
|
||||
#set $testpointer2 = 0x200006b8
|
||||
#set $FuntionPointer = 0x200006c4
|
||||
#set $FPTemp = 0x200a08e9
|
||||
#set {int}($FuntionPointer) = $FPTemp
|
||||
#printf "testpointer(%x):%x\n", $testpointer, {int}$testpointer
|
||||
#printf "testpointer2(%x):%x\n", $testpointer2, {int}$testpointer2
|
||||
#printf "FuntionPointer(%x):%x\n", $FuntionPointer, {int}$FuntionPointer
|
||||
|
||||
#===============================================================================
|
||||
#Load file
|
||||
# restore filename [binary] bias start end
|
||||
# Restore the contents of file filename into memory.
|
||||
# The restore command can automatically recognize any known bfd file format, except for raw binary.
|
||||
# To restore a raw binary file you must specify the optional keyword binary after the filename.
|
||||
#===============================================================================
|
||||
|
||||
set $LoopNum = ($RamFileSize / $FLASHDATBUFSIZE)
|
||||
printf "LoopNum = %x\n", $LoopNum
|
||||
set $TailSize = ($RamFileSize % $FLASHDATBUFSIZE)
|
||||
printf "TailSize = %x\n", $TailSize
|
||||
|
||||
printf "global variables\n"
|
||||
|
||||
set $FLASHDATSRC = 0x0
|
||||
set $FILESTARTADDR = 0X0
|
||||
set $FILEENDADDR = $FILESTARTADDR + $FLASHDATBUFSIZE
|
||||
|
||||
#b RtlFlashProgram:StartOfFlashBlockWrite
|
||||
b rtl_flash_download.c:489
|
||||
b rtl_flash_download.c:524
|
||||
#b Rtl_flash_control.c:RtlFlashProgram
|
||||
|
||||
#continue to 489
|
||||
c
|
||||
|
||||
# Mode 0: erase full chip, Mode 1: skip calibration section and erase to firmware size
|
||||
set EraseMode=1
|
||||
print EraseMode
|
||||
set FirmwareSize=$RamFileSize
|
||||
print FirmwareSize
|
||||
|
||||
#continue to 524
|
||||
c
|
||||
|
||||
#printf "...\n"
|
||||
set $FLASHDATSRC = FlashDatSrc
|
||||
printf "FlashDatSrc:%x\n", $FLASHDATSRC
|
||||
|
||||
printf "FlashBlockWriteSize "
|
||||
set FlashBlockWriteSize = $FLASHDATBUFSIZE
|
||||
#p /x FlashBlockWriteSize
|
||||
printf "FlashBlockWriteSize:%x\n", FlashBlockWriteSize
|
||||
|
||||
printf "FlashAddrForWrite"
|
||||
set FlashAddrForWrite = 0x0
|
||||
|
||||
|
||||
|
||||
printf "Flash write start...\n"
|
||||
set $LoopCnt = 0
|
||||
while ($LoopCnt < $LoopNum)
|
||||
p /x FlashAddrForWrite
|
||||
restore ./Debug/ram_all.bin binary ($FLASHDATSRC-$FILESTARTADDR) $FILESTARTADDR $FILEENDADDR
|
||||
c
|
||||
|
||||
printf "FILEENDADDR"
|
||||
p /x $FILEENDADDR
|
||||
set FlashBlockWriteSize = $FLASHDATBUFSIZE
|
||||
set FlashAddrForWrite = $FILEENDADDR
|
||||
set $FILESTARTADDR = $FILEENDADDR
|
||||
set $FILEENDADDR = $FILESTARTADDR + $FLASHDATBUFSIZE
|
||||
|
||||
set $LoopCnt = $LoopCnt + 0x01
|
||||
end
|
||||
|
||||
#set FlashBlockWriteSize = $FLASHDATBUFSIZE
|
||||
#set FlashAddrForWrite = $FILEENDADDR
|
||||
#set $FILESTARTADDR = $FILEENDADDR
|
||||
set $FILEENDADDR = $FILESTARTADDR + $TailSize
|
||||
restore ./Debug/ram_all.bin binary ($FLASHDATSRC-$FILESTARTADDR) $FILESTARTADDR $FILEENDADDR
|
||||
c
|
||||
|
||||
#Set complete flas
|
||||
set FlashWriteComplete = 0x1
|
||||
|
||||
printf "dump for check\n"
|
||||
|
||||
set $LoopCnt = 0
|
||||
set $dumpaddr = 0
|
||||
|
||||
set $dumpstartaddr = $SPI_FLASH_BASE
|
||||
set $dumpendaddr = $SPI_FLASH_BASE + $RamFileSize
|
||||
printf "start addr of dumping"
|
||||
p /x $dumpstartaddr
|
||||
printf "end addr of dumping"
|
||||
p /x $dumpendaddr
|
||||
dump binary memory ./Debug/dump.bin $dumpstartaddr $dumpendaddr
|
||||
|
||||
|
||||
delete
|
||||
b rtl_flash_download.c:556
|
||||
c
|
||||
|
||||
quit
|
||||
#===============================================================================
|
||||
|
||||
124
component/soc/realtek/8195a/misc/gcc_utility/openocd/ameba1.cfg
Normal file
124
component/soc/realtek/8195a/misc/gcc_utility/openocd/ameba1.cfg
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
# Main file for Ameba1 series Cortex-M3 parts
|
||||
#
|
||||
# !!!!!!
|
||||
#
|
||||
|
||||
set CHIPNAME rtl8195a
|
||||
set CHIPSERIES ameba1
|
||||
|
||||
# Adapt based on what transport is active.
|
||||
source [find target/swj-dp.tcl]
|
||||
|
||||
if { [info exists CHIPNAME] } {
|
||||
set _CHIPNAME $CHIPNAME
|
||||
} else {
|
||||
error "CHIPNAME not set. Please do not include ameba1.cfg directly."
|
||||
}
|
||||
|
||||
if { [info exists CHIPSERIES] } {
|
||||
# Validate chip series is supported
|
||||
if { $CHIPSERIES != "ameba1" } {
|
||||
error "Unsupported chip series specified."
|
||||
}
|
||||
set _CHIPSERIES $CHIPSERIES
|
||||
} else {
|
||||
error "CHIPSERIES not set. Please do not include ameba1.cfg directly."
|
||||
}
|
||||
|
||||
if { [info exists CPUTAPID] } {
|
||||
# Allow user override
|
||||
set _CPUTAPID $CPUTAPID
|
||||
} else {
|
||||
# Ameba1 use a Cortex M3 core.
|
||||
if { $_CHIPSERIES == "ameba1" } {
|
||||
if { [using_jtag] } {
|
||||
set _CPUTAPID 0x4ba00477
|
||||
} {
|
||||
set _CPUTAPID 0x2ba01477
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
swj_newdap $_CHIPNAME cpu -irlen 4 -expected-id $_CPUTAPID
|
||||
|
||||
set _TARGETNAME $_CHIPNAME.cpu
|
||||
target create $_TARGETNAME cortex_m -chain-position $_TARGETNAME
|
||||
|
||||
|
||||
# Run with *real slow* clock by default since the
|
||||
# boot rom could have been playing with the PLL, so
|
||||
# we have no idea what clock the target is running at.
|
||||
adapter_khz 10
|
||||
|
||||
# delays on reset lines
|
||||
adapter_nsrst_delay 200
|
||||
if {[using_jtag]} {
|
||||
jtag_ntrst_delay 200
|
||||
}
|
||||
|
||||
|
||||
# Ameba1 (Cortex M3 core) support SYSRESETREQ
|
||||
if {![using_hla]} {
|
||||
# if srst is not fitted use SYSRESETREQ to
|
||||
# perform a soft reset
|
||||
cortex_m reset_config sysresetreq
|
||||
}
|
||||
|
||||
$_TARGETNAME configure -event reset-init {ameba1_init}
|
||||
|
||||
# Ameba1 SDRAM enable
|
||||
proc ameba1_init { } {
|
||||
# init System
|
||||
mww 0x40000014 0x00000021
|
||||
sleep 10
|
||||
mww 0x40000304 0x1fc00002
|
||||
sleep 10
|
||||
mww 0x40000250 0x00000400
|
||||
sleep 10
|
||||
mww 0x40000340 0x00000000
|
||||
sleep 10
|
||||
mww 0x40000230 0x0000dcc4
|
||||
sleep 10
|
||||
mww 0x40000210 0x00011117
|
||||
sleep 10
|
||||
mww 0x40000210 0x00011157
|
||||
sleep 10
|
||||
mww 0x400002c0 0x00110011
|
||||
sleep 10
|
||||
mww 0x40000320 0xffffffff
|
||||
sleep 10
|
||||
# init SDRAM
|
||||
mww 0x40000040 0x00fcc702
|
||||
sleep 10
|
||||
mdw 0x40000040
|
||||
mww 0x40005224 0x00000001
|
||||
sleep 10
|
||||
mww 0x40005004 0x00000208
|
||||
sleep 10
|
||||
mww 0x40005008 0xffffd000
|
||||
sleep 13
|
||||
mww 0x40005020 0x00000022
|
||||
sleep 13
|
||||
mww 0x40005010 0x09006201
|
||||
sleep 13
|
||||
mww 0x40005014 0x00002611
|
||||
sleep 13
|
||||
mww 0x40005018 0x00068413
|
||||
sleep 13
|
||||
mww 0x4000501c 0x00000042
|
||||
sleep 13
|
||||
mww 0x4000500c 0x700 ;# set Idle
|
||||
sleep 20
|
||||
mww 0x40005000 0x1 ;# start init
|
||||
sleep 100
|
||||
mdw 0x40005000
|
||||
mww 0x4000500c 0x600 ;# enter memory mode
|
||||
sleep 30
|
||||
|
||||
mww 0x40005008 0x00000000 ;# 0xf00
|
||||
;# mww 0x40005008 0x00000f00
|
||||
sleep 3
|
||||
mww 0x40000300 0x0006005e ;# 0x5e
|
||||
;# mww 0x40000300 0x0000005e
|
||||
sleep 3
|
||||
}
|
||||
BIN
component/soc/realtek/8195a/misc/gcc_utility/ram_all.bin
Normal file
BIN
component/soc/realtek/8195a/misc/gcc_utility/ram_all.bin
Normal file
Binary file not shown.
|
|
@ -0,0 +1,124 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program 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 General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
|
||||
*
|
||||
*
|
||||
******************************************************************************/
|
||||
#include "rtl8710b.h"
|
||||
#include "build_info.h"
|
||||
|
||||
|
||||
|
||||
#define FLASHDATALEN 2048
|
||||
BOOT_RAM_BSS_SECTION volatile u8 FlashDataBuf[FLASHDATALEN];
|
||||
BOOT_RAM_BSS_SECTION volatile u32 *pFlashDatSrc;
|
||||
BOOT_RAM_BSS_SECTION volatile u32 FlashBlockWriteSize; //The maximum size of each block write is FLASHDATALEN,
|
||||
//The actual value MUST be given by GDB.
|
||||
BOOT_RAM_BSS_SECTION volatile u32 FlashAddrForWrite; //The flash address to be written.
|
||||
//The actual value MUST be given by GDB.
|
||||
BOOT_RAM_BSS_SECTION volatile u8 FlashWriteComplete;
|
||||
BOOT_RAM_BSS_SECTION volatile u32 FlashDatSrc;
|
||||
BOOT_RAM_BSS_SECTION u32 erase_sector_addr = 0;
|
||||
|
||||
extern u8 __rom_bss_start__[];
|
||||
extern u8 __rom_bss_end__[];
|
||||
extern u8 __ram_start_table_start__[];
|
||||
|
||||
extern u32 ConfigDebugErr;
|
||||
extern u32 ConfigDebugInfo;
|
||||
extern u32 ConfigDebugWarn;
|
||||
|
||||
void BOOT_RAM_TEXT_SECTION
|
||||
RtlFlashProgram(VOID)
|
||||
{
|
||||
volatile u32 FlashWriteCnt = 0;
|
||||
u8 flash_ID[3];
|
||||
|
||||
//2 Need Modify
|
||||
VECTOR_TableInit(0x1003EFFC);
|
||||
DBG_8195A("==========================================================\n");
|
||||
DBG_8195A("Flash Downloader Build Time: "UTS_VERSION"\n");
|
||||
DBG_8195A("==========================================================\n");
|
||||
|
||||
FlashDatSrc = (u32)&FlashDataBuf;
|
||||
pFlashDatSrc = (u32 *)&FlashDataBuf;
|
||||
FlashWriteComplete = 0;
|
||||
FlashBlockWriteSize = 0;
|
||||
FlashAddrForWrite = 0;
|
||||
erase_sector_addr = 0;
|
||||
|
||||
Cache_Enable(DISABLE);
|
||||
RCC_PeriphClockCmd(APBPeriph_FLASH, APBPeriph_FLASH_CLOCK, DISABLE);
|
||||
|
||||
/* set 500MHz Div to gen spic clock 200MHz */
|
||||
FLASH_ClockDiv(FLASH_CLK_DIV2P5);
|
||||
RCC_PeriphClockCmd(APBPeriph_FLASH, APBPeriph_FLASH_CLOCK, ENABLE);
|
||||
PinCtrl(PERIPHERAL_SPI_FLASH,S0,ON);
|
||||
|
||||
DBG_8195A("Flash init start\n");
|
||||
FLASH_StructInit(&flash_init_para);
|
||||
FLASH_Init(SpicOneBitMode);
|
||||
DBG_8195A("Flash init done\n");
|
||||
|
||||
FLASH_RxCmd(flash_init_para.FLASH_cmd_rd_id, 3, flash_ID);
|
||||
if(flash_ID[0] == 0x20){
|
||||
flash_init_para.FLASH_cmd_chip_e = 0xC7;}
|
||||
|
||||
//4 Erase the flash before writing it
|
||||
//FLASH_Erase(EraseChip, 0);
|
||||
//DBG_8195A("Flash erace done\n");
|
||||
DBG_8195A("Flash download start\n");
|
||||
//4 Program the flash from memory data
|
||||
while(1)
|
||||
{
|
||||
StartOfFlashBlockWrite:
|
||||
asm("nop");
|
||||
asm("nop");
|
||||
asm("nop");
|
||||
asm("nop");
|
||||
|
||||
FlashWriteCnt = 0;
|
||||
pFlashDatSrc = (u32 *)&FlashDataBuf[0];
|
||||
if (FlashWriteComplete == 1)
|
||||
break;
|
||||
|
||||
while (FlashWriteCnt < FlashBlockWriteSize)
|
||||
{
|
||||
u32 sector_addr1 = FlashAddrForWrite & 0xFFFFF000; /* sector of first byte */
|
||||
|
||||
if(sector_addr1 >= erase_sector_addr) {
|
||||
FLASH_Erase(EraseSector, sector_addr1);
|
||||
erase_sector_addr = sector_addr1 + 0x1000; /* next sector we should erase */
|
||||
}
|
||||
|
||||
FLASH_TxData12B(FlashAddrForWrite, 4, pFlashDatSrc);
|
||||
|
||||
FlashAddrForWrite += 4;
|
||||
FlashWriteCnt += 4;
|
||||
pFlashDatSrc+= 1;
|
||||
}
|
||||
|
||||
goto StartOfFlashBlockWrite;
|
||||
}
|
||||
|
||||
DBG_8195A("Flash download done\n");
|
||||
|
||||
while(1){
|
||||
if (FlashWriteComplete == 1) {
|
||||
FlashWriteComplete = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
# GDB script for loading ram.bin process
|
||||
|
||||
#===============================================================================
|
||||
#set GDB connection
|
||||
set remotetimeout 100000
|
||||
target remote :2331
|
||||
|
||||
#===============================================================================
|
||||
#Message display setting
|
||||
#disable all messages
|
||||
|
||||
set verbose off
|
||||
set complaints 0
|
||||
set confirm off
|
||||
set exec-done-display off
|
||||
show exec-done-display
|
||||
set trace-commands off
|
||||
#set debug aix-thread off
|
||||
#set debug dwarf2-die 0
|
||||
set debug displaced off
|
||||
set debug expression 0
|
||||
set debug frame 0
|
||||
set debug infrun 0
|
||||
set debug observer 0
|
||||
set debug overload 0
|
||||
set debugvarobj 0
|
||||
set pagination off
|
||||
set print address off
|
||||
set print symbol-filename off
|
||||
set print symbol off
|
||||
set print pretty off
|
||||
set print object off
|
||||
#set debug notification off
|
||||
set debug parser off
|
||||
set debug remote 0
|
||||
|
||||
#===============================================================================
|
||||
monitor reset 1
|
||||
monitor sleep 20
|
||||
monitor clrbp
|
||||
#===============================================================================
|
||||
#Load flash download file
|
||||
file ./application/Debug/bin/application.axf
|
||||
|
||||
#x /1xw 0x40000210
|
||||
|
||||
b main
|
||||
continue
|
||||
clear main
|
||||
#Load the file
|
||||
#lo
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
# GDB script for loading ram.bin process
|
||||
|
||||
#===============================================================================
|
||||
#set GDB connection
|
||||
set remotetimeout 100000
|
||||
target remote :2331
|
||||
|
||||
#===============================================================================
|
||||
#Message display setting
|
||||
#disable all messages
|
||||
|
||||
set verbose off
|
||||
set complaints 0
|
||||
set confirm off
|
||||
set exec-done-display off
|
||||
show exec-done-display
|
||||
set trace-commands off
|
||||
#set debug aix-thread off
|
||||
#set debug dwarf2-die 0
|
||||
set debug displaced off
|
||||
set debug expression 0
|
||||
set debug frame 0
|
||||
set debug infrun 0
|
||||
set debug observer 0
|
||||
set debug overload 0
|
||||
set debugvarobj 0
|
||||
set pagination off
|
||||
set print address off
|
||||
set print symbol-filename off
|
||||
set print symbol off
|
||||
set print pretty off
|
||||
set print object off
|
||||
#set debug notification off
|
||||
set debug parser off
|
||||
set debug remote 0
|
||||
|
||||
#===============================================================================
|
||||
monitor reset 1
|
||||
monitor sleep 20
|
||||
monitor clrbp
|
||||
#===============================================================================
|
||||
#Load flash download file
|
||||
file ./application/Debug/bin/application.axf
|
||||
|
||||
#x /1xw 0x40000210
|
||||
|
||||
b main
|
||||
continue
|
||||
clear main
|
||||
#Load the file
|
||||
#lo
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
# GDB script for loading ram.bin process
|
||||
|
||||
#===============================================================================
|
||||
#set GDB connection
|
||||
set remotetimeout 100000
|
||||
target remote :3333
|
||||
|
||||
#===============================================================================
|
||||
#Message display setting
|
||||
#disable all messages
|
||||
|
||||
set verbose off
|
||||
set complaints 0
|
||||
set confirm off
|
||||
set exec-done-display off
|
||||
show exec-done-display
|
||||
set trace-commands off
|
||||
#set debug aix-thread off
|
||||
#set debug dwarf2-die 0
|
||||
set debug displaced off
|
||||
set debug expression 0
|
||||
set debug frame 0
|
||||
set debug infrun 0
|
||||
set debug observer 0
|
||||
set debug overload 0
|
||||
set debugvarobj 0
|
||||
set pagination off
|
||||
set print address off
|
||||
set print symbol-filename off
|
||||
set print symbol off
|
||||
set print pretty off
|
||||
set print object off
|
||||
#set debug notification off
|
||||
set debug parser off
|
||||
set debug remote 0
|
||||
|
||||
#===============================================================================
|
||||
monitor reset init
|
||||
monitor sleep 20
|
||||
monitor halt
|
||||
#===============================================================================
|
||||
#Load flash download file
|
||||
file ./application/Debug/bin/application.axf
|
||||
|
||||
#skip sdram init, it has been init in openocd config
|
||||
set {int}0x40000210=0x211157
|
||||
#x /1xw 0x40000210
|
||||
|
||||
b main
|
||||
continue
|
||||
clear main
|
||||
#Load the file
|
||||
#lo
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,199 @@
|
|||
# GDB script for loading ram.bin process
|
||||
|
||||
#===============================================================================
|
||||
#set GDB connection
|
||||
set remotetimeout 100000
|
||||
target remote :2331
|
||||
|
||||
#===============================================================================
|
||||
#set file path
|
||||
set $BINFILE = "./application/Debug/bin/ram_all.bin"
|
||||
|
||||
#===============================================================================
|
||||
#Message display setting
|
||||
#disable all messages
|
||||
|
||||
set verbose off
|
||||
set complaints 0
|
||||
set confirm off
|
||||
set exec-done-display off
|
||||
show exec-done-display
|
||||
set trace-commands off
|
||||
#set debug aix-thread off
|
||||
#set debug dwarf2-die 0
|
||||
set debug displaced off
|
||||
set debug expression 0
|
||||
set debug frame 0
|
||||
set debug infrun 0
|
||||
set debug observer 0
|
||||
set debug overload 0
|
||||
set debugvarobj 0
|
||||
set pagination off
|
||||
set print address off
|
||||
set print symbol-filename off
|
||||
set print symbol off
|
||||
set print pretty off
|
||||
set print object off
|
||||
#set debug notification off
|
||||
set debug parser off
|
||||
set debug remote 0
|
||||
|
||||
#===============================================================================
|
||||
#set JTAG and external SRAM
|
||||
monitor reset 1
|
||||
monitor sleep 20
|
||||
monitor clrbp
|
||||
#===============================================================================
|
||||
#Variables declaration (1)
|
||||
#binary file size
|
||||
set $RamFileSize = 0x0000
|
||||
source fwsize.gdb
|
||||
printf "-------------------------------\n"
|
||||
printf "RamFileSize: %x\n",$RamFileSize
|
||||
printf "-------------------------------\n"
|
||||
|
||||
#===============================================================================
|
||||
set $FLASHDATBUFSIZE = 0x800
|
||||
|
||||
#===============================================================================
|
||||
#define PERI_ON_BASE 0x40000000
|
||||
set $PERI_ON_BASE = 0x40000000
|
||||
#define REG_SOC_PERI_FUNC0_EN 0x0218
|
||||
set $REG_SOC_PERI_FUNC0_EN = 0x0210
|
||||
|
||||
#define SPI_FLASH_BASE 0x4000000
|
||||
set $SPI_FLASH_BASE = 0x98000000
|
||||
|
||||
#------------------------------------------------------------------
|
||||
set $Temp = 0x0
|
||||
|
||||
#===============================================================================
|
||||
#Load flash download file
|
||||
file ../../../component/soc/realtek/8195a/misc/gcc_utility/target_NORMAL.axf
|
||||
|
||||
#Load the file
|
||||
lo
|
||||
|
||||
printf "Load flash controller.\n"
|
||||
|
||||
#===============================================================================
|
||||
#Set for executing flash controller funciton
|
||||
set $Temp = {int}($PERI_ON_BASE+$REG_SOC_PERI_FUNC0_EN)
|
||||
p /x $Temp
|
||||
|
||||
set $Temp = ($Temp | (0x01 << 27))
|
||||
p /x $Temp
|
||||
|
||||
set {int}($PERI_ON_BASE+$REG_SOC_PERI_FUNC0_EN) = $Temp
|
||||
printf "....\n"
|
||||
printf "wakeup bit(%x):%x\n", ($PERI_ON_BASE+$REG_SOC_PERI_FUNC0_EN), {int}($PERI_ON_BASE+$REG_SOC_PERI_FUNC0_EN)
|
||||
#===============================================================================
|
||||
#Direct the startup wake function to flash program function
|
||||
#the function pointer address
|
||||
#set $testpointer = 0x200006b4
|
||||
#set $testpointer2 = 0x200006b8
|
||||
#set $FuntionPointer = 0x200006c4
|
||||
#set $FPTemp = 0x200a08e9
|
||||
#set {int}($FuntionPointer) = $FPTemp
|
||||
#printf "testpointer(%x):%x\n", $testpointer, {int}$testpointer
|
||||
#printf "testpointer2(%x):%x\n", $testpointer2, {int}$testpointer2
|
||||
#printf "FuntionPointer(%x):%x\n", $FuntionPointer, {int}$FuntionPointer
|
||||
|
||||
#===============================================================================
|
||||
#Load file
|
||||
# restore filename [binary] bias start end
|
||||
# Restore the contents of file filename into memory.
|
||||
# The restore command can automatically recognize any known bfd file format, except for raw binary.
|
||||
# To restore a raw binary file you must specify the optional keyword binary after the filename.
|
||||
#===============================================================================
|
||||
|
||||
set $LoopNum = ($RamFileSize / $FLASHDATBUFSIZE)
|
||||
printf "LoopNum = %x\n", $LoopNum
|
||||
set $TailSize = ($RamFileSize % $FLASHDATBUFSIZE)
|
||||
printf "TailSize = %x\n", $TailSize
|
||||
|
||||
printf "global variables\n"
|
||||
|
||||
set $FLASHDATSRC = 0x0
|
||||
set $FILESTARTADDR = 0X0
|
||||
set $FILEENDADDR = $FILESTARTADDR + $FLASHDATBUFSIZE
|
||||
|
||||
#b RtlFlashProgram:StartOfFlashBlockWrite
|
||||
b rtl_flash_download.c:489
|
||||
b rtl_flash_download.c:524
|
||||
#b Rtl_flash_control.c:RtlFlashProgram
|
||||
|
||||
#continue to 489
|
||||
c
|
||||
|
||||
# Mode 0: erase full chip, Mode 1: skip calibration section and erase to firmware size
|
||||
set EraseMode=1
|
||||
print EraseMode
|
||||
set FirmwareSize=$RamFileSize
|
||||
print FirmwareSize
|
||||
|
||||
#continue to 524
|
||||
c
|
||||
|
||||
#printf "...\n"
|
||||
set $FLASHDATSRC = FlashDatSrc
|
||||
printf "FlashDatSrc:%x\n", $FLASHDATSRC
|
||||
|
||||
printf "FlashBlockWriteSize "
|
||||
set FlashBlockWriteSize = $FLASHDATBUFSIZE
|
||||
#p /x FlashBlockWriteSize
|
||||
printf "FlashBlockWriteSize:%x\n", FlashBlockWriteSize
|
||||
|
||||
printf "FlashAddrForWrite"
|
||||
set FlashAddrForWrite = 0x0
|
||||
|
||||
|
||||
|
||||
printf "Flash write start...\n"
|
||||
set $LoopCnt = 0
|
||||
while ($LoopCnt < $LoopNum)
|
||||
p /x FlashAddrForWrite
|
||||
restore ./application/Debug/bin/ram_all.bin binary ($FLASHDATSRC-$FILESTARTADDR) $FILESTARTADDR $FILEENDADDR
|
||||
c
|
||||
|
||||
printf "FILEENDADDR"
|
||||
p /x $FILEENDADDR
|
||||
set FlashBlockWriteSize = $FLASHDATBUFSIZE
|
||||
set FlashAddrForWrite = $FILEENDADDR
|
||||
set $FILESTARTADDR = $FILEENDADDR
|
||||
set $FILEENDADDR = $FILESTARTADDR + $FLASHDATBUFSIZE
|
||||
|
||||
set $LoopCnt = $LoopCnt + 0x01
|
||||
end
|
||||
|
||||
#set FlashBlockWriteSize = $FLASHDATBUFSIZE
|
||||
#set FlashAddrForWrite = $FILEENDADDR
|
||||
#set $FILESTARTADDR = $FILEENDADDR
|
||||
set $FILEENDADDR = $FILESTARTADDR + $TailSize
|
||||
restore ./application/Debug/bin/ram_all.bin binary ($FLASHDATSRC-$FILESTARTADDR) $FILESTARTADDR $FILEENDADDR
|
||||
c
|
||||
|
||||
#Set complete flas
|
||||
set FlashWriteComplete = 0x1
|
||||
|
||||
printf "dump for check\n"
|
||||
|
||||
set $LoopCnt = 0
|
||||
set $dumpaddr = 0
|
||||
|
||||
set $dumpstartaddr = $SPI_FLASH_BASE
|
||||
set $dumpendaddr = $SPI_FLASH_BASE + $RamFileSize
|
||||
printf "start addr of dumping"
|
||||
p /x $dumpstartaddr
|
||||
printf "end addr of dumping"
|
||||
p /x $dumpendaddr
|
||||
dump binary memory ./application/Debug/bin/dump.bin $dumpstartaddr $dumpendaddr
|
||||
|
||||
|
||||
delete
|
||||
b rtl_flash_download.c:556
|
||||
c
|
||||
|
||||
quit
|
||||
#===============================================================================
|
||||
|
||||
|
|
@ -0,0 +1,199 @@
|
|||
# GDB script for loading ram.bin process
|
||||
|
||||
#===============================================================================
|
||||
#set GDB connection
|
||||
set remotetimeout 100000
|
||||
target remote :2331
|
||||
|
||||
#===============================================================================
|
||||
#set file path
|
||||
set $BINFILE = "./application/Debug/bin/ram_all.bin"
|
||||
|
||||
#===============================================================================
|
||||
#Message display setting
|
||||
#disable all messages
|
||||
|
||||
set verbose off
|
||||
set complaints 0
|
||||
set confirm off
|
||||
set exec-done-display off
|
||||
show exec-done-display
|
||||
set trace-commands off
|
||||
#set debug aix-thread off
|
||||
#set debug dwarf2-die 0
|
||||
set debug displaced off
|
||||
set debug expression 0
|
||||
set debug frame 0
|
||||
set debug infrun 0
|
||||
set debug observer 0
|
||||
set debug overload 0
|
||||
set debugvarobj 0
|
||||
set pagination off
|
||||
set print address off
|
||||
set print symbol-filename off
|
||||
set print symbol off
|
||||
set print pretty off
|
||||
set print object off
|
||||
#set debug notification off
|
||||
set debug parser off
|
||||
set debug remote 0
|
||||
|
||||
#===============================================================================
|
||||
#set JTAG and external SRAM
|
||||
monitor reset 1
|
||||
monitor sleep 20
|
||||
monitor clrbp
|
||||
#===============================================================================
|
||||
#Variables declaration (1)
|
||||
#binary file size
|
||||
set $RamFileSize = 0x0000
|
||||
source fwsize.gdb
|
||||
printf "-------------------------------\n"
|
||||
printf "RamFileSize: %x\n",$RamFileSize
|
||||
printf "-------------------------------\n"
|
||||
|
||||
#===============================================================================
|
||||
set $FLASHDATBUFSIZE = 0x800
|
||||
|
||||
#===============================================================================
|
||||
#define PERI_ON_BASE 0x40000000
|
||||
set $PERI_ON_BASE = 0x40000000
|
||||
#define REG_SOC_PERI_FUNC0_EN 0x0218
|
||||
set $REG_SOC_PERI_FUNC0_EN = 0x0210
|
||||
|
||||
#define SPI_FLASH_BASE 0x4000000
|
||||
set $SPI_FLASH_BASE = 0x98000000
|
||||
|
||||
#------------------------------------------------------------------
|
||||
set $Temp = 0x0
|
||||
|
||||
#===============================================================================
|
||||
#Load flash download file
|
||||
file ../../../component/soc/realtek/8195a/misc/gcc_utility/target_NORMAL.axf
|
||||
|
||||
#Load the file
|
||||
lo
|
||||
|
||||
printf "Load flash controller.\n"
|
||||
|
||||
#===============================================================================
|
||||
#Set for executing flash controller funciton
|
||||
set $Temp = {int}($PERI_ON_BASE+$REG_SOC_PERI_FUNC0_EN)
|
||||
p /x $Temp
|
||||
|
||||
set $Temp = ($Temp | (0x01 << 27))
|
||||
p /x $Temp
|
||||
|
||||
set {int}($PERI_ON_BASE+$REG_SOC_PERI_FUNC0_EN) = $Temp
|
||||
printf "....\n"
|
||||
printf "wakeup bit(%x):%x\n", ($PERI_ON_BASE+$REG_SOC_PERI_FUNC0_EN), {int}($PERI_ON_BASE+$REG_SOC_PERI_FUNC0_EN)
|
||||
#===============================================================================
|
||||
#Direct the startup wake function to flash program function
|
||||
#the function pointer address
|
||||
#set $testpointer = 0x200006b4
|
||||
#set $testpointer2 = 0x200006b8
|
||||
#set $FuntionPointer = 0x200006c4
|
||||
#set $FPTemp = 0x200a08e9
|
||||
#set {int}($FuntionPointer) = $FPTemp
|
||||
#printf "testpointer(%x):%x\n", $testpointer, {int}$testpointer
|
||||
#printf "testpointer2(%x):%x\n", $testpointer2, {int}$testpointer2
|
||||
#printf "FuntionPointer(%x):%x\n", $FuntionPointer, {int}$FuntionPointer
|
||||
|
||||
#===============================================================================
|
||||
#Load file
|
||||
# restore filename [binary] bias start end
|
||||
# Restore the contents of file filename into memory.
|
||||
# The restore command can automatically recognize any known bfd file format, except for raw binary.
|
||||
# To restore a raw binary file you must specify the optional keyword binary after the filename.
|
||||
#===============================================================================
|
||||
|
||||
set $LoopNum = ($RamFileSize / $FLASHDATBUFSIZE)
|
||||
printf "LoopNum = %x\n", $LoopNum
|
||||
set $TailSize = ($RamFileSize % $FLASHDATBUFSIZE)
|
||||
printf "TailSize = %x\n", $TailSize
|
||||
|
||||
printf "global variables\n"
|
||||
|
||||
set $FLASHDATSRC = 0x0
|
||||
set $FILESTARTADDR = 0X0
|
||||
set $FILEENDADDR = $FILESTARTADDR + $FLASHDATBUFSIZE
|
||||
|
||||
#b RtlFlashProgram:StartOfFlashBlockWrite
|
||||
b rtl_flash_download.c:489
|
||||
b rtl_flash_download.c:524
|
||||
#b Rtl_flash_control.c:RtlFlashProgram
|
||||
|
||||
#continue to 489
|
||||
c
|
||||
|
||||
# Mode 0: erase full chip, Mode 1: skip calibration section and erase to firmware size
|
||||
set EraseMode=1
|
||||
print EraseMode
|
||||
set FirmwareSize=$RamFileSize
|
||||
print FirmwareSize
|
||||
|
||||
#continue to 524
|
||||
c
|
||||
|
||||
#printf "...\n"
|
||||
set $FLASHDATSRC = FlashDatSrc
|
||||
printf "FlashDatSrc:%x\n", $FLASHDATSRC
|
||||
|
||||
printf "FlashBlockWriteSize "
|
||||
set FlashBlockWriteSize = $FLASHDATBUFSIZE
|
||||
#p /x FlashBlockWriteSize
|
||||
printf "FlashBlockWriteSize:%x\n", FlashBlockWriteSize
|
||||
|
||||
printf "FlashAddrForWrite"
|
||||
set FlashAddrForWrite = 0x0
|
||||
|
||||
|
||||
|
||||
printf "Flash write start...\n"
|
||||
set $LoopCnt = 0
|
||||
while ($LoopCnt < $LoopNum)
|
||||
p /x FlashAddrForWrite
|
||||
restore ./application/Debug/bin/ram_all.bin binary ($FLASHDATSRC-$FILESTARTADDR) $FILESTARTADDR $FILEENDADDR
|
||||
c
|
||||
|
||||
printf "FILEENDADDR"
|
||||
p /x $FILEENDADDR
|
||||
set FlashBlockWriteSize = $FLASHDATBUFSIZE
|
||||
set FlashAddrForWrite = $FILEENDADDR
|
||||
set $FILESTARTADDR = $FILEENDADDR
|
||||
set $FILEENDADDR = $FILESTARTADDR + $FLASHDATBUFSIZE
|
||||
|
||||
set $LoopCnt = $LoopCnt + 0x01
|
||||
end
|
||||
|
||||
#set FlashBlockWriteSize = $FLASHDATBUFSIZE
|
||||
#set FlashAddrForWrite = $FILEENDADDR
|
||||
#set $FILESTARTADDR = $FILEENDADDR
|
||||
set $FILEENDADDR = $FILESTARTADDR + $TailSize
|
||||
restore ./application/Debug/bin/ram_all.bin binary ($FLASHDATSRC-$FILESTARTADDR) $FILESTARTADDR $FILEENDADDR
|
||||
c
|
||||
|
||||
#Set complete flas
|
||||
set FlashWriteComplete = 0x1
|
||||
|
||||
printf "dump for check\n"
|
||||
|
||||
set $LoopCnt = 0
|
||||
set $dumpaddr = 0
|
||||
|
||||
set $dumpstartaddr = $SPI_FLASH_BASE
|
||||
set $dumpendaddr = $SPI_FLASH_BASE + $RamFileSize
|
||||
printf "start addr of dumping"
|
||||
p /x $dumpstartaddr
|
||||
printf "end addr of dumping"
|
||||
p /x $dumpendaddr
|
||||
dump binary memory ./application/Debug/bin/dump.bin $dumpstartaddr $dumpendaddr
|
||||
|
||||
|
||||
delete
|
||||
b rtl_flash_download.c:556
|
||||
c
|
||||
|
||||
quit
|
||||
#===============================================================================
|
||||
|
||||
|
|
@ -0,0 +1,198 @@
|
|||
# GDB script for loading ram.bin process
|
||||
|
||||
#===============================================================================
|
||||
#set GDB connection
|
||||
set remotetimeout 100000
|
||||
target remote :3333
|
||||
|
||||
#===============================================================================
|
||||
#set file path
|
||||
set $BINFILE = "./application/Debug/bin/ram_all.bin"
|
||||
|
||||
#===============================================================================
|
||||
#Message display setting
|
||||
#disable all messages
|
||||
|
||||
set verbose off
|
||||
set complaints 0
|
||||
set confirm off
|
||||
set exec-done-display off
|
||||
show exec-done-display
|
||||
set trace-commands off
|
||||
#set debug aix-thread off
|
||||
#set debug dwarf2-die 0
|
||||
set debug displaced off
|
||||
set debug expression 0
|
||||
set debug frame 0
|
||||
set debug infrun 0
|
||||
set debug observer 0
|
||||
set debug overload 0
|
||||
set debugvarobj 0
|
||||
set pagination off
|
||||
set print address off
|
||||
set print symbol-filename off
|
||||
set print symbol off
|
||||
set print pretty off
|
||||
set print object off
|
||||
#set debug notification off
|
||||
set debug parser off
|
||||
set debug remote 0
|
||||
|
||||
#===============================================================================
|
||||
#set JTAG and external SRAM
|
||||
monitor reset init
|
||||
monitor halt
|
||||
monitor sleep 20
|
||||
#===============================================================================
|
||||
#Variables declaration (1)
|
||||
#binary file size
|
||||
set $RamFileSize = 0x0000
|
||||
source fwsize.gdb
|
||||
printf "-------------------------------\n"
|
||||
printf "RamFileSize: %x\n",$RamFileSize
|
||||
printf "-------------------------------\n"
|
||||
|
||||
#===============================================================================
|
||||
set $FLASHDATBUFSIZE = 0x800
|
||||
|
||||
#===============================================================================
|
||||
#define PERI_ON_BASE 0x40000000
|
||||
set $PERI_ON_BASE = 0x40000000
|
||||
#define REG_SOC_PERI_FUNC0_EN 0x0218
|
||||
set $REG_SOC_PERI_FUNC0_EN = 0x0210
|
||||
|
||||
#define SPI_FLASH_BASE 0x4000000
|
||||
set $SPI_FLASH_BASE = 0x98000000
|
||||
|
||||
#------------------------------------------------------------------
|
||||
set $Temp = 0x0
|
||||
|
||||
#===============================================================================
|
||||
#Load flash download file
|
||||
file ../../../component/soc/realtek/8195a/misc/gcc_utility/target_NORMAL.axf
|
||||
|
||||
#Load the file
|
||||
lo
|
||||
|
||||
printf "Load flash controller.\n"
|
||||
#===============================================================================
|
||||
#Set for executing flash controller funciton
|
||||
set $Temp = {int}($PERI_ON_BASE+$REG_SOC_PERI_FUNC0_EN)
|
||||
p /x $Temp
|
||||
|
||||
set $Temp = ($Temp | (0x01 << 27))
|
||||
p /x $Temp
|
||||
|
||||
set {int}($PERI_ON_BASE+$REG_SOC_PERI_FUNC0_EN) = $Temp
|
||||
printf "....\n"
|
||||
printf "wakeup bit(%x):%x\n", ($PERI_ON_BASE+$REG_SOC_PERI_FUNC0_EN), {int}($PERI_ON_BASE+$REG_SOC_PERI_FUNC0_EN)
|
||||
#===============================================================================
|
||||
#Direct the startup wake function to flash program function
|
||||
#the function pointer address
|
||||
#set $testpointer = 0x200006b4
|
||||
#set $testpointer2 = 0x200006b8
|
||||
#set $FuntionPointer = 0x200006c4
|
||||
#set $FPTemp = 0x200a08e9
|
||||
#set {int}($FuntionPointer) = $FPTemp
|
||||
#printf "testpointer(%x):%x\n", $testpointer, {int}$testpointer
|
||||
#printf "testpointer2(%x):%x\n", $testpointer2, {int}$testpointer2
|
||||
#printf "FuntionPointer(%x):%x\n", $FuntionPointer, {int}$FuntionPointer
|
||||
|
||||
#===============================================================================
|
||||
#Load file
|
||||
# restore filename [binary] bias start end
|
||||
# Restore the contents of file filename into memory.
|
||||
# The restore command can automatically recognize any known bfd file format, except for raw binary.
|
||||
# To restore a raw binary file you must specify the optional keyword binary after the filename.
|
||||
#===============================================================================
|
||||
|
||||
set $LoopNum = ($RamFileSize / $FLASHDATBUFSIZE)
|
||||
printf "LoopNum = %x\n", $LoopNum
|
||||
set $TailSize = ($RamFileSize % $FLASHDATBUFSIZE)
|
||||
printf "TailSize = %x\n", $TailSize
|
||||
|
||||
printf "global variables\n"
|
||||
|
||||
set $FLASHDATSRC = 0x0
|
||||
set $FILESTARTADDR = 0X0
|
||||
set $FILEENDADDR = $FILESTARTADDR + $FLASHDATBUFSIZE
|
||||
|
||||
#b RtlFlashProgram:StartOfFlashBlockWrite
|
||||
b rtl_flash_download.c:489
|
||||
b rtl_flash_download.c:524
|
||||
#b Rtl_flash_control.c:RtlFlashProgram
|
||||
|
||||
#continue to 489
|
||||
c
|
||||
|
||||
# Mode 0: erase full chip, Mode 1: skip calibration section and erase to firmware size
|
||||
set EraseMode=1
|
||||
print EraseMode
|
||||
set FirmwareSize=$RamFileSize
|
||||
print FirmwareSize
|
||||
|
||||
#continue to 524
|
||||
c
|
||||
|
||||
#printf "...\n"
|
||||
set $FLASHDATSRC = FlashDatSrc
|
||||
printf "FlashDatSrc:%x\n", $FLASHDATSRC
|
||||
|
||||
printf "FlashBlockWriteSize "
|
||||
set FlashBlockWriteSize = $FLASHDATBUFSIZE
|
||||
#p /x FlashBlockWriteSize
|
||||
printf "FlashBlockWriteSize:%x\n", FlashBlockWriteSize
|
||||
|
||||
printf "FlashAddrForWrite"
|
||||
set FlashAddrForWrite = 0x0
|
||||
|
||||
|
||||
|
||||
printf "Flash write start...\n"
|
||||
set $LoopCnt = 0
|
||||
while ($LoopCnt < $LoopNum)
|
||||
p /x FlashAddrForWrite
|
||||
restore ./application/Debug/bin/ram_all.bin binary ($FLASHDATSRC-$FILESTARTADDR) $FILESTARTADDR $FILEENDADDR
|
||||
c
|
||||
|
||||
printf "FILEENDADDR"
|
||||
p /x $FILEENDADDR
|
||||
set FlashBlockWriteSize = $FLASHDATBUFSIZE
|
||||
set FlashAddrForWrite = $FILEENDADDR
|
||||
set $FILESTARTADDR = $FILEENDADDR
|
||||
set $FILEENDADDR = $FILESTARTADDR + $FLASHDATBUFSIZE
|
||||
|
||||
set $LoopCnt = $LoopCnt + 0x01
|
||||
end
|
||||
|
||||
#set FlashBlockWriteSize = $FLASHDATBUFSIZE
|
||||
#set FlashAddrForWrite = $FILEENDADDR
|
||||
#set $FILESTARTADDR = $FILEENDADDR
|
||||
set $FILEENDADDR = $FILESTARTADDR + $TailSize
|
||||
restore ./application/Debug/bin/ram_all.bin binary ($FLASHDATSRC-$FILESTARTADDR) $FILESTARTADDR $FILEENDADDR
|
||||
c
|
||||
|
||||
#Set complete flas
|
||||
set FlashWriteComplete = 0x1
|
||||
|
||||
printf "dump for check\n"
|
||||
|
||||
set $LoopCnt = 0
|
||||
set $dumpaddr = 0
|
||||
|
||||
set $dumpstartaddr = $SPI_FLASH_BASE
|
||||
set $dumpendaddr = $SPI_FLASH_BASE + $RamFileSize
|
||||
printf "start addr of dumping"
|
||||
p /x $dumpstartaddr
|
||||
printf "end addr of dumping"
|
||||
p /x $dumpendaddr
|
||||
dump binary memory ./application/Debug/bin/dump.bin $dumpstartaddr $dumpendaddr
|
||||
|
||||
|
||||
delete
|
||||
b rtl_flash_download.c:556
|
||||
c
|
||||
|
||||
quit
|
||||
#===============================================================================
|
||||
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
# GDB script for loading ram.bin process
|
||||
|
||||
#===============================================================================
|
||||
#set GDB connection
|
||||
set remotetimeout 100000
|
||||
target remote :2331
|
||||
|
||||
#===============================================================================
|
||||
#Message display setting
|
||||
#disable all messages
|
||||
|
||||
set verbose off
|
||||
set complaints 0
|
||||
set confirm off
|
||||
set exec-done-display off
|
||||
show exec-done-display
|
||||
set trace-commands off
|
||||
#set debug aix-thread off
|
||||
#set debug dwarf2-die 0
|
||||
set debug displaced off
|
||||
set debug expression 0
|
||||
set debug frame 0
|
||||
set debug infrun 0
|
||||
set debug observer 0
|
||||
set debug overload 0
|
||||
set debugvarobj 0
|
||||
set pagination off
|
||||
set print address off
|
||||
set print symbol-filename off
|
||||
set print symbol off
|
||||
set print pretty off
|
||||
set print object off
|
||||
#set debug notification off
|
||||
set debug parser off
|
||||
set debug remote 0
|
||||
|
||||
#===============================================================================
|
||||
monitor reset 1
|
||||
monitor sleep 20
|
||||
monitor clrbp
|
||||
#===============================================================================
|
||||
#Init SDRAM here
|
||||
# init System
|
||||
monitor MemU32 0x40000014=0x00000021
|
||||
monitor sleep 10
|
||||
monitor MemU32 0x40000304=0x1fc00002
|
||||
monitor sleep 10
|
||||
monitor MemU32 0x40000250=0x00000400
|
||||
monitor sleep 10
|
||||
monitor MemU32 0x40000340=0x00000000
|
||||
monitor sleep 10
|
||||
monitor MemU32 0x40000230=0x0000dcc4
|
||||
monitor sleep 10
|
||||
monitor MemU32 0x40000210=0x00011117
|
||||
monitor sleep 10
|
||||
monitor MemU32 0x40000210=0x00011157
|
||||
monitor sleep 10
|
||||
monitor MemU32 0x400002c0=0x00110011
|
||||
monitor sleep 10
|
||||
monitor MemU32 0x40000320=0xffffffff
|
||||
monitor sleep 10
|
||||
# init SDRAM
|
||||
monitor MemU32 0x40000040=0x00fcc702
|
||||
monitor sleep 10
|
||||
monitor MemU32 0x40000040
|
||||
monitor MemU32 0x40005224=0x00000001
|
||||
monitor sleep 10
|
||||
monitor MemU32 0x40005004=0x00000208
|
||||
monitor sleep 10
|
||||
monitor MemU32 0x40005008=0xffffd000
|
||||
monitor sleep 13
|
||||
monitor MemU32 0x40005020=0x00000022
|
||||
monitor sleep 13
|
||||
monitor MemU32 0x40005010=0x09006201
|
||||
monitor sleep 13
|
||||
monitor MemU32 0x40005014=0x00002611
|
||||
monitor sleep 13
|
||||
monitor MemU32 0x40005018=0x00068413
|
||||
monitor sleep 13
|
||||
monitor MemU32 0x4000501c=0x00000042
|
||||
monitor sleep 13
|
||||
monitor MemU32 0x4000500c=0x700
|
||||
monitor sleep 20
|
||||
monitor MemU32 0x40005000=0x1
|
||||
monitor sleep 100
|
||||
monitor MemU32 0x40005000
|
||||
monitor MemU32 0x4000500c=0x600
|
||||
monitor sleep 30
|
||||
|
||||
monitor MemU32 0x40005008=0x00000000
|
||||
monitor sleep 3
|
||||
monitor MemU32 0x40000300=0x0006005e
|
||||
monitor sleep 3
|
||||
#===============================================================================
|
||||
#Load flash download file
|
||||
file ./application/Debug/bin/application.axf
|
||||
|
||||
#boot from ram, igonore loading flash
|
||||
monitor MemU32 0x40000210=0x8011157
|
||||
|
||||
#Load the file
|
||||
lo
|
||||
|
||||
#Run to main
|
||||
b main
|
||||
continue
|
||||
clear main
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
# GDB script for loading ram.bin process
|
||||
|
||||
#===============================================================================
|
||||
#set GDB connection
|
||||
set remotetimeout 100000
|
||||
target remote :2331
|
||||
|
||||
#===============================================================================
|
||||
#Message display setting
|
||||
#disable all messages
|
||||
|
||||
set verbose off
|
||||
set complaints 0
|
||||
set confirm off
|
||||
set exec-done-display off
|
||||
show exec-done-display
|
||||
set trace-commands off
|
||||
#set debug aix-thread off
|
||||
#set debug dwarf2-die 0
|
||||
set debug displaced off
|
||||
set debug expression 0
|
||||
set debug frame 0
|
||||
set debug infrun 0
|
||||
set debug observer 0
|
||||
set debug overload 0
|
||||
set debugvarobj 0
|
||||
set pagination off
|
||||
set print address off
|
||||
set print symbol-filename off
|
||||
set print symbol off
|
||||
set print pretty off
|
||||
set print object off
|
||||
#set debug notification off
|
||||
set debug parser off
|
||||
set debug remote 0
|
||||
|
||||
#===============================================================================
|
||||
monitor reset 1
|
||||
monitor sleep 20
|
||||
monitor clrbp
|
||||
#===============================================================================
|
||||
#Init SDRAM here
|
||||
# init System
|
||||
monitor MemU32 0x40000014=0x00000021
|
||||
monitor sleep 10
|
||||
monitor MemU32 0x40000304=0x1fc00002
|
||||
monitor sleep 10
|
||||
monitor MemU32 0x40000250=0x00000400
|
||||
monitor sleep 10
|
||||
monitor MemU32 0x40000340=0x00000000
|
||||
monitor sleep 10
|
||||
monitor MemU32 0x40000230=0x0000dcc4
|
||||
monitor sleep 10
|
||||
monitor MemU32 0x40000210=0x00011117
|
||||
monitor sleep 10
|
||||
monitor MemU32 0x40000210=0x00011157
|
||||
monitor sleep 10
|
||||
monitor MemU32 0x400002c0=0x00110011
|
||||
monitor sleep 10
|
||||
monitor MemU32 0x40000320=0xffffffff
|
||||
monitor sleep 10
|
||||
# init SDRAM
|
||||
monitor MemU32 0x40000040=0x00fcc702
|
||||
monitor sleep 10
|
||||
monitor MemU32 0x40000040
|
||||
monitor MemU32 0x40005224=0x00000001
|
||||
monitor sleep 10
|
||||
monitor MemU32 0x40005004=0x00000208
|
||||
monitor sleep 10
|
||||
monitor MemU32 0x40005008=0xffffd000
|
||||
monitor sleep 13
|
||||
monitor MemU32 0x40005020=0x00000022
|
||||
monitor sleep 13
|
||||
monitor MemU32 0x40005010=0x09006201
|
||||
monitor sleep 13
|
||||
monitor MemU32 0x40005014=0x00002611
|
||||
monitor sleep 13
|
||||
monitor MemU32 0x40005018=0x00068413
|
||||
monitor sleep 13
|
||||
monitor MemU32 0x4000501c=0x00000042
|
||||
monitor sleep 13
|
||||
monitor MemU32 0x4000500c=0x700
|
||||
monitor sleep 20
|
||||
monitor MemU32 0x40005000=0x1
|
||||
monitor sleep 100
|
||||
monitor MemU32 0x40005000
|
||||
monitor MemU32 0x4000500c=0x600
|
||||
monitor sleep 30
|
||||
|
||||
monitor MemU32 0x40005008=0x00000000
|
||||
monitor sleep 3
|
||||
monitor MemU32 0x40000300=0x0006005e
|
||||
monitor sleep 3
|
||||
#===============================================================================
|
||||
#Load flash download file
|
||||
file ./application/Debug/bin/application.axf
|
||||
|
||||
#boot from ram, igonore loading flash
|
||||
monitor MemU32 0x40000210=0x8011157
|
||||
|
||||
#Load the file
|
||||
lo
|
||||
|
||||
#Run to main
|
||||
b main
|
||||
continue
|
||||
clear main
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
# GDB script for loading ram.bin process
|
||||
|
||||
#===============================================================================
|
||||
#set GDB connection
|
||||
set remotetimeout 100000
|
||||
target remote :3333
|
||||
|
||||
#===============================================================================
|
||||
#Message display setting
|
||||
#disable all messages
|
||||
|
||||
set verbose off
|
||||
set complaints 0
|
||||
set confirm off
|
||||
set exec-done-display off
|
||||
show exec-done-display
|
||||
set trace-commands off
|
||||
#set debug aix-thread off
|
||||
#set debug dwarf2-die 0
|
||||
set debug displaced off
|
||||
set debug expression 0
|
||||
set debug frame 0
|
||||
set debug infrun 0
|
||||
set debug observer 0
|
||||
set debug overload 0
|
||||
set debugvarobj 0
|
||||
set pagination off
|
||||
set print address off
|
||||
set print symbol-filename off
|
||||
set print symbol off
|
||||
set print pretty off
|
||||
set print object off
|
||||
#set debug notification off
|
||||
set debug parser off
|
||||
set debug remote 0
|
||||
|
||||
#===============================================================================
|
||||
monitor reset init
|
||||
monitor sleep 20
|
||||
monitor halt
|
||||
#===============================================================================
|
||||
#Load flash download file
|
||||
file ./application/Debug/bin/application.axf
|
||||
|
||||
#boot from ram, igonore loading flash
|
||||
set {int}0x40000210=0x8011157
|
||||
|
||||
#Load the file
|
||||
lo
|
||||
|
||||
#Run to main
|
||||
b main
|
||||
continue
|
||||
clear main
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
BIN
component/soc/realtek/8195a/misc/gcc_utility/target_NORMAL.axf
Normal file
BIN
component/soc/realtek/8195a/misc/gcc_utility/target_NORMAL.axf
Normal file
Binary file not shown.
BIN
component/soc/realtek/8195a/misc/gcc_utility/target_NORMALB.axf
Normal file
BIN
component/soc/realtek/8195a/misc/gcc_utility/target_NORMALB.axf
Normal file
Binary file not shown.
BIN
component/soc/realtek/8195a/misc/gcc_utility/target_NORMALC.axf
Normal file
BIN
component/soc/realtek/8195a/misc/gcc_utility/target_NORMALC.axf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
component/soc/realtek/8195a/misc/gcc_utility/tools/x86/gzip.exe
Normal file
BIN
component/soc/realtek/8195a/misc/gcc_utility/tools/x86/gzip.exe
Normal file
Binary file not shown.
BIN
component/soc/realtek/8195a/misc/gcc_utility/tools/x86/tar.exe
Normal file
BIN
component/soc/realtek/8195a/misc/gcc_utility/tools/x86/tar.exe
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,23 @@
|
|||
;; Memory information ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;; Used to define address zones within the ARM address space (Memory).
|
||||
;;
|
||||
;; Name may be almost anything
|
||||
;; AdrSpace must be Memory
|
||||
;; StartAdr start of memory block
|
||||
;; EndAdr end of memory block
|
||||
;; AccType type of access, read-only (R), read-write (RW) or SFR (W)
|
||||
|
||||
[Memory]
|
||||
;; Name AdrSpace StartAdr EndAdr AccType Width
|
||||
Memory = ROM Memory 0x00000000 0x003FFFFF RW
|
||||
Memory = SRAM Memory 0x10000000 0x1FFFFFFF RW
|
||||
Memory = DRAM Memory 0x30000000 0x30FFFFFF RW
|
||||
Memory = SFR Memory 0x40000000 0x41FFFFFF RW
|
||||
Memory = SFR_Bitband Memory 0x42000000 0x43FFFFFF RW
|
||||
Memory = PPB Memory 0xE0000000 0xFFFFFFFF RW
|
||||
|
||||
TrustedRanges = true
|
||||
UseSfrFilter = true
|
||||
|
||||
[SfrInclude]
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
__load_dram_param(){
|
||||
//DRAM_INFO
|
||||
DeviceType = 8; //DRAM_SDR
|
||||
Page = 0; //DRAM_COLADDR_8B
|
||||
Bank=0; //DRAM_BANK_2
|
||||
DqWidth=0; //DRAM_DQ_1
|
||||
|
||||
//DRAM_MODE_REG_INFO
|
||||
BstLen=0; //BST_LEN_4
|
||||
BstType=0; //SENQUENTIAL
|
||||
Mode0Cas=3;
|
||||
Mode0Wr=0;
|
||||
Mode1DllEnN=0;
|
||||
Mode1AllLat=0;
|
||||
Mode2Cwl=0;
|
||||
|
||||
//DRAM_TIMING_INFO
|
||||
DramTimingTref = 64000;
|
||||
DramRowNum = 8192;
|
||||
//SDR 100MHZ==>10000, 50MHZ==>20000, 25MHZ==>40000, 12.5MHZ==>80000
|
||||
Tck = 80000; //SDR 12.5MHZ
|
||||
|
||||
TrfcPs=60000;
|
||||
TrefiPs=((DramTimingTref*1000)/DramRowNum)*1000;
|
||||
WrMaxTck=2;
|
||||
TrcdPs=15000;
|
||||
TrpPs=15000;
|
||||
TrasPs=42000;
|
||||
TrrdTck=2;
|
||||
TwrPs=Tck*2;
|
||||
TwtrTck=0;
|
||||
TmrdTck=2;
|
||||
TrtpTck=0;
|
||||
TccdTck=1;
|
||||
TrcPs=60000;
|
||||
|
||||
//DRAM_DEVICE_INFO
|
||||
DdrPeriodPs=Tck;
|
||||
DfiRate=0; //DFI_RATIO_1
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
__load_dram_common(){
|
||||
__registerMacroFile("$PROJ_DIR$\\..\\..\\..\\component\\soc\\realtek\\8195a\\misc\\iar_utility\\common\\dram\\EM6A6165TS_7G.mac");
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
To Change DRAM setting
|
||||
|
||||
1. Create and Fill content like EM6A6165TS_7G.mac
|
||||
2. Change load file in common.mac
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<flash_board>
|
||||
<pass>
|
||||
<range>CODE 0x10000bc0 0x10003FFF</range>
|
||||
<loader>$PROJ_DIR$\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\flashloader\FlashRTL8195aMP.flash</loader>
|
||||
<abs_offset>0x00000000</abs_offset>
|
||||
<args>--head</args>
|
||||
</pass>
|
||||
<pass>
|
||||
<range>CODE 0x10004000 0x1006FFFF</range>
|
||||
<loader>$PROJ_DIR$\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\flashloader\FlashRTL8195aMP.flash</loader>
|
||||
<abs_offset>0x00000000</abs_offset>
|
||||
<args>--cascade</args>
|
||||
</pass>
|
||||
<pass>
|
||||
<range>CODE 0x30000000 0x301FFFFF</range>
|
||||
<loader>$PROJ_DIR$\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\flashloader\FlashRTL8195aMP.flash</loader>
|
||||
<abs_offset>0x00000000</abs_offset>
|
||||
<args>--cascade</args>
|
||||
</pass>
|
||||
<ignore>CODE 0x00000000 0x000FFFFF</ignore>
|
||||
<ignore>CODE 0x10000000 0x10000bbf</ignore>
|
||||
</flash_board>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<flash_device>
|
||||
<exe>$PROJ_DIR$\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\flashloader\FlashRTL8195aMP.out</exe>
|
||||
<flash_base>0x00000000</flash_base>
|
||||
<page>8</page>
|
||||
<block>512 0x1000</block>
|
||||
<macro>$PROJ_DIR$\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\flashloader\FlashRTL8195aMP.mac</macro>
|
||||
<aggregate>1</aggregate>
|
||||
</flash_device>
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
setup()
|
||||
{
|
||||
__var tmp;
|
||||
|
||||
if(__driverType("jlink")){
|
||||
__hwResetWithStrategy(0, 0);
|
||||
//__hwReset(1);
|
||||
}else{
|
||||
__hwResetWithStrategy(0, 2);
|
||||
__hwReset(1);
|
||||
}
|
||||
|
||||
tmp = __readMemory32(0x40000014,"Memory"); __delay(10);
|
||||
__message "0x40000014=",tmp:%x;
|
||||
|
||||
__writeMemory32(0x21, 0x40000014, "Memory"); __delay(10);
|
||||
|
||||
__writeMemory32(0x1FC00002, 0x40000304, "Memory"); __delay(10);
|
||||
__writeMemory32(0x400, 0x40000250, "Memory"); __delay(10);
|
||||
__writeMemory32(0x0, 0x40000340, "Memory"); __delay(10);
|
||||
__writeMemory32(0xc04, 0x40000230, "Memory"); __delay(10);
|
||||
__writeMemory32(0x1157, 0x40000210, "Memory"); __delay(10);
|
||||
__writeMemory32(0x110011, 0x400002c0, "Memory"); __delay(10);
|
||||
__writeMemory32(0xffffffff, 0x40000320, "Memory"); __delay(10);
|
||||
/*
|
||||
__writeMemory32(0x1, 0x40005224, "Memory"); __delay(10);
|
||||
__writeMemory32(0x2c8, 0x40005004, "Memory"); __delay(10);
|
||||
__writeMemory32(0xffffd000, 0x40005008, "Memory"); __delay(10);
|
||||
__delay(3);
|
||||
__writeMemory32(0x22, 0x40005020, "Memory"); __delay(10);
|
||||
__delay(3);
|
||||
__writeMemory32(0x09032001, 0x40005010, "Memory"); __delay(10);
|
||||
__delay(3);
|
||||
__writeMemory32(0x2611, 0x40005014, "Memory"); __delay(10);
|
||||
__delay(3);
|
||||
__writeMemory32(0x68413, 0x40005018, "Memory"); __delay(10);
|
||||
__delay(3);
|
||||
__writeMemory32(0x42, 0x4000501c, "Memory"); __delay(10);
|
||||
__delay(3);
|
||||
|
||||
// Enable
|
||||
__writeMemory32(0x700, 0x4000500c, "Memory"); __delay(10);
|
||||
__delay(20);
|
||||
__writeMemory32(0x1, 0x40005000, "Memory"); __delay(10);
|
||||
__delay(100);
|
||||
tmp = __readMemory32(0x40005000,"Memory"); __delay(10);
|
||||
__writeMemory32(0x600, 0x4000500c, "Memory"); __delay(10);
|
||||
__delay(30);
|
||||
*/
|
||||
}
|
||||
|
||||
execUserPreload()
|
||||
{
|
||||
__var tmp;
|
||||
setup();
|
||||
tmp = __readMemory32(0x40000210, "Memory")|(1<<27);
|
||||
__writeMemory32(tmp, 0x40000210, "Memory");
|
||||
}
|
||||
|
||||
execUserSetup()
|
||||
{
|
||||
//execUserPreload();
|
||||
//__loadImage("$TARGET_PATH$ ", 0, 0);
|
||||
//__writeMemory32(0x80000000, 0x40000218, "Memory");
|
||||
}
|
||||
|
||||
execUserFlashInit() // Called by debugger before loading flash loader in RAM.
|
||||
{
|
||||
__var tmp;
|
||||
__message "----- Prepare hardware for Flashloader -----\n";
|
||||
|
||||
__writeMemory32(0x1FFFFFF8, 0x10000000, "Memory");
|
||||
__writeMemory32(0x101, 0x10000004, "Memory");
|
||||
setup();
|
||||
tmp = __readMemory32(0x40000210, "Memory")|(1<<27);
|
||||
__writeMemory32(tmp, 0x40000210, "Memory");
|
||||
}
|
||||
Binary file not shown.
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<flash_board>
|
||||
<pass>
|
||||
<range>CODE 0x10000bc8 0x10005FFF</range>
|
||||
<loader>$PROJ_DIR$\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\flashloader\FlashRTL8195aMP.flash</loader>
|
||||
<abs_offset>0x00000000</abs_offset>
|
||||
<args>--head
|
||||
--img2_addr
|
||||
0xB000</args>
|
||||
</pass>
|
||||
|
||||
<ignore>CODE 0x00000000 0x000FFFFF</ignore>
|
||||
<ignore>CODE 0x10000000 0x10000bc7</ignore>
|
||||
<ignore>CODE 0x10006000 0x1006FFFF</ignore>
|
||||
<ignore>CODE 0x30000000 0x301FFFFF</ignore>
|
||||
</flash_board>
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<flash_board>
|
||||
<pass>
|
||||
<range>CODE 0x10000bc0 0x10005FFF</range>
|
||||
<loader>$PROJ_DIR$\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\flashloader\FlashRTL8195aMP.flash</loader>
|
||||
<abs_offset>0x00000000</abs_offset>
|
||||
<args>--head
|
||||
--img2_addr
|
||||
0xB000</args>
|
||||
</pass>
|
||||
|
||||
<ignore>CODE 0x00000000 0x000FFFFF</ignore>
|
||||
<ignore>CODE 0x10000000 0x10000bbf</ignore>
|
||||
<ignore>CODE 0x10006000 0x1006FFFF</ignore>
|
||||
<ignore>CODE 0x30000000 0x301FFFFF</ignore>
|
||||
</flash_board>
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<flash_board>
|
||||
<pass>
|
||||
<range>CODE 0x10000bc8 0x10005FFF</range>
|
||||
<loader>$PROJ_DIR$\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\flashloader\FlashRTL8195aMP.flash</loader>
|
||||
<abs_offset>0x00000000</abs_offset>
|
||||
<args>--head
|
||||
--img2_addr
|
||||
0xB000</args>
|
||||
</pass>
|
||||
<pass>
|
||||
<range>CODE 0x10006000 0x1006FFFF</range>
|
||||
<loader>$PROJ_DIR$\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\flashloader\FlashRTL8195aMP.flash</loader>
|
||||
<abs_offset>0xB000</abs_offset>
|
||||
</pass>
|
||||
<pass>
|
||||
<range>CODE 0x30000000 0x301FFFFF</range>
|
||||
<loader>$PROJ_DIR$\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\flashloader\FlashRTL8195aMP.flash</loader>
|
||||
<abs_offset>0x0000</abs_offset>
|
||||
<args>--cascade</args>
|
||||
</pass>
|
||||
<ignore>CODE 0x00000000 0x000FFFFF</ignore>
|
||||
<ignore>CODE 0x10000000 0x10000bc7</ignore>
|
||||
<ignore>CODE 0x1FFF0000 0x1FFFFFFF</ignore>
|
||||
</flash_board>
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<flash_board>
|
||||
<pass>
|
||||
<range>CODE 0x200006b4 0x2002FFFF</range>
|
||||
<loader>$PROJ_DIR$\flashloader\FlashRTL8195aQA.flash</loader>
|
||||
<abs_offset>0x00000000</abs_offset>
|
||||
</pass>
|
||||
<pass>
|
||||
<range>CODE 0x30000000 0x301FFFFF</range>
|
||||
<loader>$PROJ_DIR$\flashloader\FlashRTL8195aQA.flash</loader>
|
||||
<abs_offset>0x00010000</abs_offset>
|
||||
<ignore>DATA_Z 0x30000000 0x301FFFFF</ignore>
|
||||
</pass>
|
||||
<pass>
|
||||
<range>CODE 0x20080000 0x200BFFFF</range>
|
||||
<loader>$PROJ_DIR$\flashloader\FlashRTL8195aQA.flash</loader>
|
||||
<abs_offset>0x00020000</abs_offset>
|
||||
<ignore>DATA_Z 0x20080000 0x200BFFFF</ignore>
|
||||
</pass>
|
||||
<pass>
|
||||
<range>CODE 0x00000000 0x00000000</range>
|
||||
<loader>$PROJ_DIR$\flashloader\FlashRTL8195aQA.flash</loader>
|
||||
<abs_offset>0x00030000</abs_offset>
|
||||
</pass>
|
||||
<ignore>CODE 0x00000001 0x000BFFFF</ignore>
|
||||
<ignore>CODE 0x20000000 0x200006b3</ignore>
|
||||
</flash_board>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<flash_device>
|
||||
<exe>$PROJ_DIR$\flashloader\FlashRTL8195aQA.out</exe>
|
||||
<flash_base>0x00000000</flash_base>
|
||||
<page>8</page>
|
||||
<block>256 0x1000</block>
|
||||
<macro>$PROJ_DIR$\flashloader\FlashRTL8195aQA.mac</macro>
|
||||
<aggregate>1</aggregate>
|
||||
</flash_device>
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
setup()
|
||||
{
|
||||
__var tmp;
|
||||
|
||||
__hwReset(1);
|
||||
|
||||
__writeMemory32(0x21, 0x40000014, "Memory"); __delay(10);
|
||||
__writeMemory32(0x1FC00002, 0x40000304, "Memory"); __delay(10);
|
||||
__writeMemory32(0x400, 0x40000250, "Memory"); __delay(10);
|
||||
__writeMemory32(0x0, 0x40000340, "Memory"); __delay(10);
|
||||
__writeMemory32(0xc04, 0x40000230, "Memory"); __delay(10);
|
||||
__writeMemory32(0x1157, 0x40000210, "Memory"); __delay(10);
|
||||
__writeMemory32(0x110011, 0x400002c0, "Memory"); __delay(10);
|
||||
__writeMemory32(0xffffffff, 0x40000320, "Memory"); __delay(10);
|
||||
|
||||
__writeMemory32(0x1, 0x40005224, "Memory"); __delay(10);
|
||||
__writeMemory32(0x2c8, 0x40005004, "Memory"); __delay(10);
|
||||
__writeMemory32(0xffffd000, 0x40005008, "Memory"); __delay(10);
|
||||
__delay(3);
|
||||
__writeMemory32(0x22, 0x40005020, "Memory"); __delay(10);
|
||||
__delay(3);
|
||||
__writeMemory32(0x09032001, 0x40005010, "Memory"); __delay(10);
|
||||
__delay(3);
|
||||
__writeMemory32(0x2611, 0x40005014, "Memory"); __delay(10);
|
||||
__delay(3);
|
||||
__writeMemory32(0x68413, 0x40005018, "Memory"); __delay(10);
|
||||
__delay(3);
|
||||
__writeMemory32(0x42, 0x4000501c, "Memory"); __delay(10);
|
||||
__delay(3);
|
||||
|
||||
// Enable
|
||||
__writeMemory32(0x700, 0x4000500c, "Memory"); __delay(10);
|
||||
__delay(20);
|
||||
__writeMemory32(0x1, 0x40005000, "Memory"); __delay(10);
|
||||
__delay(100);
|
||||
tmp = __readMemory32(0x40005000,"Memory"); __delay(10);
|
||||
__writeMemory32(0x600, 0x4000500c, "Memory"); __delay(10);
|
||||
__delay(30);
|
||||
}
|
||||
|
||||
execUserPreload()
|
||||
{
|
||||
__message "----- Prepare hardware for Flashloader -----\n";
|
||||
setup();
|
||||
__writeMemory32(0x80000000, 0x40000218, "Memory");
|
||||
}
|
||||
|
||||
execUserSetup()
|
||||
{
|
||||
//execUserPreload();
|
||||
//__loadImage("$TARGET_PATH$ ", 0, 0);
|
||||
//__writeMemory32(0x80000000, 0x40000218, "Memory");
|
||||
}
|
||||
|
||||
execUserFlashInit() // Called by debugger before loading flash loader in RAM.
|
||||
{
|
||||
__message "----- Prepare hardware for Flashloader -----\n";
|
||||
setup();
|
||||
__writeMemory32(0x80000000, 0x40000218, "Memory");
|
||||
}
|
||||
Binary file not shown.
|
|
@ -0,0 +1,53 @@
|
|||
@set /a tmp = %1-1
|
||||
@call :toHex %tmp% end1
|
||||
@set /a tmp2 = %2-1
|
||||
@call :toHex %tmp2% end2
|
||||
@set /a tmp3 = %3-1
|
||||
@call :toHex %tmp3% end0
|
||||
|
||||
@echo echo image 2 start %1
|
||||
@echo echo image 1 end 0x%end1%
|
||||
@echo off
|
||||
@echo ^<?xml version="1.0" encoding="iso-8859-1"?^> > tmp.board
|
||||
@echo. >> tmp.board
|
||||
@echo ^<flash_board^> >> tmp.board
|
||||
@echo ^<pass^> >> tmp.board
|
||||
@echo ^<range^>CODE %3 0x%end1%^</range^> >> tmp.board
|
||||
@echo ^<loader^>$PROJ_DIR$\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\flashloader\FlashRTL8195aMP.flash^</loader^> >> tmp.board
|
||||
@echo ^<abs_offset^>0x00000000^</abs_offset^> >> tmp.board
|
||||
@echo ^<args^>--head^</args^> >> tmp.board
|
||||
@echo ^</pass^> >> tmp.board
|
||||
@echo ^<pass^> >> tmp.board
|
||||
@echo ^<range^>CODE %1 0x%end2%^</range^> >> tmp.board
|
||||
@echo ^<loader^>$PROJ_DIR$\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\flashloader\FlashRTL8195aMP.flash^</loader^> >> tmp.board
|
||||
@echo ^<abs_offset^>0x00000000^</abs_offset^> >> tmp.board
|
||||
@echo ^<args^>--cascade^</args^> >> tmp.board
|
||||
@echo ^</pass^> >> tmp.board
|
||||
@echo ^<pass^> >> tmp.board
|
||||
@echo ^<range^>CODE 0x30000000 0x301FFFFF^</range^> >> tmp.board
|
||||
@echo ^<loader^>$PROJ_DIR$\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\flashloader\FlashRTL8195aMP.flash^</loader^> >> tmp.board
|
||||
@echo ^<abs_offset^>0x00000000^</abs_offset^> >> tmp.board
|
||||
@echo ^<args^>--cascade^</args^> >> tmp.board
|
||||
@echo ^</pass^> >> tmp.board
|
||||
@echo ^<ignore^>CODE 0x00000000 0x000FFFFF^</ignore^> >> tmp.board
|
||||
@echo ^<ignore^>CODE 0x10000000 0x%end0%^</ignore^> >> tmp.board
|
||||
@echo ^<ignore^>CODE %2 0x1006FFFF^</ignore^> >> tmp.board
|
||||
@echo ^</flash_board^> >> tmp.board >> tmp.board
|
||||
|
||||
exit
|
||||
|
||||
:toHex dec hex -- convert a decimal number to hexadecimal, i.e. -20 to FFFFFFEC or 26 to 0000001A
|
||||
@echo off
|
||||
SETLOCAL ENABLEDELAYEDEXPANSION
|
||||
set /a dec=%~1
|
||||
set "hex="
|
||||
set "map=0123456789ABCDEF"
|
||||
for /L %%N in (1,1,8) do (
|
||||
set /a "d=dec&15,dec>>=4"
|
||||
for %%D in (!d!) do set "hex=!map:~%%D,1!!hex!"
|
||||
)
|
||||
|
||||
( ENDLOCAL & REM RETURN VALUES
|
||||
IF "%~2" NEQ "" (SET %~2=%hex%) ELSE ECHO.%hex%
|
||||
)
|
||||
EXIT /b
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
@set /a tmp = %1-1
|
||||
@call :toHex %tmp% end1
|
||||
@set /a tmp2 = %2-1
|
||||
@call :toHex %tmp2% end2
|
||||
@set /a tmp3 = %3-1
|
||||
@call :toHex %tmp3% end3
|
||||
|
||||
@set /a tmp4 = %4
|
||||
@call :toHex %tmp4% flash_run_start
|
||||
@set /a tmp4 = %5-1
|
||||
@call :toHex %tmp4% flash_run_end
|
||||
|
||||
@echo echo image 2 start %1
|
||||
@echo echo image 1 end 0x%end1%
|
||||
@echo off
|
||||
@echo ^<?xml version="1.0" encoding="iso-8859-1"?^> > tmp.board
|
||||
@echo. >> tmp.board
|
||||
@echo ^<flash_board^> >> tmp.board
|
||||
@echo ^<pass^> >> tmp.board
|
||||
@echo ^<range^>CODE 0x10000bc8 0x%end1%^</range^> >> tmp.board
|
||||
@echo ^<loader^>$PROJ_DIR$\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\flashloader\FlashRTL8195aMP.flash^</loader^> >> tmp.board
|
||||
@echo ^<abs_offset^>0x00000000^</abs_offset^> >> tmp.board
|
||||
@echo ^<args^>--head >> tmp.board
|
||||
@echo --img2_addr >> tmp.board
|
||||
@echo 0xB000^</args^> >> tmp.board
|
||||
@echo ^</pass^> >> tmp.board
|
||||
@echo ^<pass^> >> tmp.board
|
||||
@echo ^<range^>CODE %1 0x%end2%^</range^> >> tmp.board
|
||||
@echo ^<loader^>$PROJ_DIR$\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\flashloader\FlashRTL8195aMP.flash^</loader^> >> tmp.board
|
||||
@echo ^<abs_offset^>0xB000^</abs_offset^> >> tmp.board
|
||||
if "%3"=="0xFFFFFFFF" (
|
||||
@echo ^<args^>--end^</args^> >> tmp.board
|
||||
)
|
||||
@echo ^</pass^> >> tmp.board
|
||||
if NOT "%3"=="0xFFFFFFFF" (
|
||||
@echo ^<pass^> >> tmp.board
|
||||
@echo ^<range^>CODE 0x30000000 0x%end3%^</range^> >> tmp.board
|
||||
@echo ^<loader^>$PROJ_DIR$\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\flashloader\FlashRTL8195aMP.flash^</loader^> >> tmp.board
|
||||
@echo ^<abs_offset^>0x0000^</abs_offset^> >> tmp.board
|
||||
@echo ^<args^>--cascade >> tmp.board
|
||||
@echo --end^</args^> >> tmp.board
|
||||
@echo ^</pass^> >> tmp.board
|
||||
)
|
||||
if NOT "%4"=="0xFFFFFFFF" (
|
||||
@echo ^<pass^> >> tmp.board
|
||||
@echo ^<range^>CODE 0x%flash_run_start% 0x%flash_run_end%^</range^> >> tmp.board
|
||||
@echo ^<loader^>$PROJ_DIR$\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\flashloader\FlashRTL8195aMP.flash^</loader^> >> tmp.board
|
||||
@echo ^<abs_offset^>0xA4000^</abs_offset^> >> tmp.board
|
||||
@echo ^</pass^> >> tmp.board
|
||||
)
|
||||
@echo ^<ignore^>CODE 0x00000000 0x000FFFFF^</ignore^> >> tmp.board
|
||||
@echo ^<ignore^>CODE 0x10000000 0x10000bc7^</ignore^> >> tmp.board
|
||||
@echo ^<ignore^>CODE %2 0x1006FFFF^</ignore^> >> tmp.board
|
||||
@echo ^<ignore^>CODE 0x1FFF0000 0x1FFFFFFF^</ignore^> >> tmp.board
|
||||
@echo ^<ignore^>CODE %3 0x3FFFFFFF^</ignore^> >> tmp.board
|
||||
@echo ^</flash_board^> >> tmp.board >> tmp.board
|
||||
|
||||
exit
|
||||
|
||||
:toHex dec hex -- convert a decimal number to hexadecimal, i.e. -20 to FFFFFFEC or 26 to 0000001A
|
||||
@echo off
|
||||
SETLOCAL ENABLEDELAYEDEXPANSION
|
||||
set /a dec=%~1
|
||||
set "hex="
|
||||
set "map=0123456789ABCDEF"
|
||||
for /L %%N in (1,1,8) do (
|
||||
set /a "d=dec&15,dec>>=4"
|
||||
for %%D in (!d!) do set "hex=!map:~%%D,1!!hex!"
|
||||
)
|
||||
|
||||
( ENDLOCAL & REM RETURN VALUES
|
||||
IF "%~2" NEQ "" (SET %~2=%hex%) ELSE ECHO.%hex%
|
||||
)
|
||||
EXIT /b
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
cd /D %2
|
||||
set tooldir=%2\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\tools
|
||||
|
||||
del Debug/Exe/target.map Debug/Exe/target.asm *.bin
|
||||
cmd /c "%tooldir%\nm Debug/Exe/target.axf | %tooldir%\sort > Debug/Exe/target.map"
|
||||
cmd /c "%tooldir%\objdump -d Debug/Exe/target.axf > Debug/Exe/target.asm"
|
||||
|
||||
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep IMAGE1 Debug/Exe/target.map | %tooldir%\grep Base | %tooldir%\gawk '{print $1}'"') do set ram1_start=0x%%i
|
||||
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep IMAGE2 Debug/Exe/target.map | %tooldir%\grep Base | %tooldir%\gawk '{print $1}'"') do set ram2_start=0x%%i
|
||||
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep SDRAM Debug/Exe/target.map | %tooldir%\grep Base | %tooldir%\gawk '{print $1}'"') do set ram3_start=0x%%i
|
||||
::for /f "delims=" %%i in ('cmd /c "%tooldir%\grep .ram_image4 Debug/Exe/target.map | %tooldir%\grep Base | %tooldir%\gawk '{print $1}'"') do set ram4_start=0x%%i
|
||||
|
||||
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep IMAGE1 Debug/Exe/target.map | %tooldir%\grep Limit | %tooldir%\gawk '{print $1}'"') do set ram1_end=0x%%i
|
||||
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep IMAGE2 Debug/Exe/target.map | %tooldir%\grep Limit | %tooldir%\gawk '{print $1}'"') do set ram2_end=0x%%i
|
||||
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep SDRAM Debug/Exe/target.map | %tooldir%\grep Limit | %tooldir%\gawk '{print $1}'"') do set ram3_end=0x%%i
|
||||
::for /f "delims=" %%i in ('cmd /c "%tooldir%\grep .ram_image4 Debug/Exe/target.map | %tooldir%\grep Limit | %tooldir%\gawk '{print $1}'"') do set ram4_end=0x%%i
|
||||
|
||||
::echo %ram1_start% > tmp.txt
|
||||
::echo %ram2_start% >> tmp.txt
|
||||
::echo %ram3_start% >> tmp.txt
|
||||
::echo %ram1_end% >> tmp.txt
|
||||
::echo %ram2_end% >> tmp.txt
|
||||
::echo %ram3_end% >> tmp.txt
|
||||
|
||||
%tooldir%\objcopy -j "A2 rw" -Obinary Debug/Exe/target.axf Debug/Exe/ram_1.bin
|
||||
%tooldir%\objcopy -j "A3 rw" -Obinary Debug/Exe/target.axf Debug/Exe/sdram.bin
|
||||
|
||||
%tooldir%\pick %ram1_start% %ram1_end% Debug\Exe\ram_1.bin Debug\Exe\ram_1.p.bin head
|
||||
%tooldir%\pick %ram2_start% %ram2_end% Debug\Exe\ram_1.bin Debug\Exe\ram_2.p.bin body
|
||||
if defined %ram3_start (
|
||||
%tooldir%\pick %ram3_start% %ram3_end% Debug\Exe\sdram.bin Debug\Exe\ram_3.p.bin body
|
||||
)
|
||||
|
||||
:: SDRAM case
|
||||
if defined %ram3_start (
|
||||
copy /b Debug\Exe\ram_1.p.bin+Debug\Exe\ram_2.p.bin+Debug\Exe\ram_3.p.bin Debug\Exe\ram_all.bin
|
||||
)
|
||||
|
||||
:: NO SDRAM case
|
||||
if not defined %ram3_start (
|
||||
copy /b Debug\Exe\ram_1.p.bin+Debug\Exe\ram_2.p.bin Debug\Exe\ram_all.bin
|
||||
)
|
||||
|
||||
:: board generator
|
||||
%tooldir%\..\gen_board.bat %ram2_start% %ram2_end% %ram1_start%
|
||||
|
||||
exit
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
Dim WshShell
|
||||
|
||||
Set WshShell = WScript.CreateObject("WScript.Shell")
|
||||
|
||||
WshShell.Run "cmd /c """""+WScript.Arguments.Item(1)+"\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\postbuild.bat"" """+WScript.Arguments.Item(0)+""" """+WScript.Arguments.Item(1)+"""""", 0
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
set tooldir=%1\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\tools
|
||||
set alinkdir=%1\..\..\..\component\common\application\alink
|
||||
|
||||
::echo %tooldir% > %alinkdir%\test.txt
|
||||
::echo %alinkdir% >> %alinkdir%\test.txt
|
||||
|
||||
cd /D %tooldir%
|
||||
|
||||
::echo "%tooldir%\iarchive.exe --extract %alinkdir%\cloud\lib\libalink.a" >> %alinkdir%\test.txt
|
||||
|
||||
echo cmd /c iarchive.exe --create lib_alink.a >out.bat
|
||||
cmd /c "iarchive.exe -t %alinkdir%\lib_porting.a" >>out.bat
|
||||
cmd /c "iarchive.exe -t %alinkdir%\cloud\lib\libalink.a" >>out.bat
|
||||
cmd /c "iarchive.exe -t %alinkdir%\zconfig\lib\libaws.a" >>out.bat
|
||||
cmd /c sed ':a;N;$ s/\n/ /g;ba' out.bat > out1.bat
|
||||
|
||||
cmd /c "iarchive.exe --extract %alinkdir%\cloud\lib\libalink.a"
|
||||
cmd /c "iarchive.exe --extract %alinkdir%\zconfig\lib\libaws.a"
|
||||
cmd /c "iarchive.exe --extract %alinkdir%\lib_porting.a"
|
||||
|
||||
cmd /c "out1.bat"
|
||||
|
||||
del %alinkdir%\lib_porting.a
|
||||
cmd /c copy lib_alink.a %alinkdir%
|
||||
|
||||
del *.o
|
||||
del *.bat
|
||||
del *.a
|
||||
|
||||
exit
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
Dim WshShell
|
||||
|
||||
Set WshShell = WScript.CreateObject("WScript.Shell")
|
||||
|
||||
WshShell.Run "cmd /c "+WScript.Arguments.Item(0)+"\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\postbuild_alink.bat "+WScript.Arguments.Item(0), 0
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
cd /D %2
|
||||
set tooldir=%2\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\tools
|
||||
set libdir=%2\..\..\..\component\soc\realtek\8195a\misc\bsp
|
||||
|
||||
del Debug/Exe/bootloader.map Debug/Exe/bootloader.asm *.bin
|
||||
cmd /c "%tooldir%\nm Debug/Exe/bootloader.axf | %tooldir%\sort > Debug/Exe/bootloader.map"
|
||||
cmd /c "%tooldir%\objdump -d Debug/Exe/bootloader.axf > Debug/Exe/bootloader.asm"
|
||||
|
||||
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep IMAGE1 Debug/Exe/bootloader.map | %tooldir%\grep Base | %tooldir%\gawk '{print $1}'"') do set ram1_start=0x%%i
|
||||
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep IMAGE1 Debug/Exe/bootloader.map | %tooldir%\grep Limit | %tooldir%\gawk '{print $1}'"') do set ram1_end=0x%%i
|
||||
|
||||
|
||||
::echo %ram1_start% > tmp.txt
|
||||
::echo %ram2_start% >> tmp.txt
|
||||
::echo %ram3_start% >> tmp.txt
|
||||
::echo %ram1_end% >> tmp.txt
|
||||
::echo %ram2_end% >> tmp.txt
|
||||
::echo %ram3_end% >> tmp.txt
|
||||
|
||||
for /f %%i in ('cmd /c "%tooldir%\readelf -S Debug/Exe/bootloader.axf | %tooldir%\grep 10000000 | %tooldir%\cut -c 8-10"') do set sectname_img1=%%i
|
||||
::echo %sectname_img1% rw > tmp.txt
|
||||
%tooldir%\objcopy -j "%sectname_img1% rw" -Obinary Debug/Exe/bootloader.axf Debug/Exe/ram_1.bin
|
||||
|
||||
%tooldir%\pick %ram1_start% %ram1_end% Debug\Exe\ram_1.bin Debug\Exe\ram_1.p.bin head 0xb000
|
||||
%tooldir%\pick %ram1_start% %ram1_end% Debug\Exe\ram_1.bin Debug\Exe\ram_1.r.bin raw
|
||||
|
||||
:: update ram_1.p.bin, raw file for application
|
||||
copy Debug\Exe\ram_1.p.bin %libdir%\image\ram_1.p.bin
|
||||
copy Debug\Exe\ram_1.r.bin %libdir%\image\ram_1.r.bin
|
||||
|
||||
:: delete hal_spi_flash_ram.o object after image built
|
||||
del Debug\Obj\hal_spi_flash_ram.*
|
||||
|
||||
exit
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
Dim WshShell
|
||||
|
||||
Set WshShell = WScript.CreateObject("WScript.Shell")
|
||||
|
||||
WshShell.Run "cmd /c """""+WScript.Arguments.Item(1)+"\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\postbuild_img1.bat"" """+WScript.Arguments.Item(0)+""" """+WScript.Arguments.Item(1)+"""""", 0
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
cd /D %2
|
||||
set tooldir=%2\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\tools
|
||||
set libdir=%2\..\..\..\component\soc\realtek\8195a\misc\bsp
|
||||
set cfgdir=%3
|
||||
|
||||
echo config %3
|
||||
|
||||
del %cfgdir%/Exe/target.map %cfgdir%/Exe/application.asm *.bin
|
||||
cmd /c "%tooldir%\nm %cfgdir%/Exe/application.axf | %tooldir%\sort > %cfgdir%/Exe/application.map"
|
||||
cmd /c "%tooldir%\objdump -d %cfgdir%/Exe/application.axf > %cfgdir%/Exe/application.asm"
|
||||
|
||||
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep IMAGE2 %cfgdir%/Exe/application.map | %tooldir%\grep Base | %tooldir%\gawk '{print $1}'"') do set ram2_start_st=%%i
|
||||
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep SDRAM %cfgdir%/Exe/application.map | %tooldir%\grep Base | %tooldir%\gawk '{print $1}'"') do set ram3_start=0x%%i
|
||||
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep FLASH_RUN %cfgdir%/Exe/application.map | %tooldir%\grep Base | %tooldir%\gawk '{print $1}'"') do set flash_run_start=0x%%i
|
||||
|
||||
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep IMAGE2 %cfgdir%/Exe/application.map | %tooldir%\grep Limit | %tooldir%\gawk '{print $1}'"') do set ram2_end=0x%%i
|
||||
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep SDRAM %cfgdir%/Exe/application.map | %tooldir%\grep Limit | %tooldir%\gawk '{print $1}'"') do set ram3_end=0x%%i
|
||||
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep FLASH_RUN %cfgdir%/Exe/application.map | %tooldir%\grep Limit | %tooldir%\gawk '{print $1}'"') do set flash_run_end=0x%%i
|
||||
|
||||
if defined %ram2_start_st (
|
||||
set ram2_start=0x%ram2_start_st%
|
||||
)
|
||||
|
||||
::echo %ram1_start% > tmp.txt
|
||||
::echo %ram2_start% >> tmp.txt
|
||||
::echo %ram3_start% >> tmp.txt
|
||||
::echo %ram1_end% >> tmp.txt
|
||||
::echo %ram2_end% >> tmp.txt
|
||||
::echo %ram3_end% >> tmp.txt
|
||||
|
||||
for /f %%i in ('cmd /c "%tooldir%\readelf -S %cfgdir%/Exe/application.axf | %tooldir%\grep %ram2_start_st% | %tooldir%\cut -c 8-10"') do set sectname_img2=%%i
|
||||
::echo sectname_img2 is %sectname_img2% rw >> tmp.txt
|
||||
for /f %%i in ('cmd /c "%tooldir%\readelf -S %cfgdir%/Exe/application.axf | %tooldir%\grep 30000000 | %tooldir%\cut -c 8-10"') do set sectname_sdram=%%i
|
||||
::echo %sectname_sdram% rw >> tmp.txt
|
||||
for /f %%i in ('cmd /c "%tooldir%\readelf -S %cfgdir%/Exe/application.axf | %tooldir%\grep 98000000 | %tooldir%\cut -c 8-10"') do set sectname_flash=%%i
|
||||
::echo %sectname_flash% rw >> tmp.txt
|
||||
|
||||
%tooldir%\objcopy -j "%sectname_img2% rw" -Obinary %cfgdir%/Exe/application.axf %cfgdir%/Exe/ram_2.bin
|
||||
if defined %ram3_start (
|
||||
%tooldir%\objcopy -j "%sectname_sdram% rw" -Obinary %cfgdir%/Exe/application.axf %cfgdir%/Exe/sdram.bin
|
||||
)
|
||||
if defined %flash_run_start (
|
||||
%tooldir%\objcopy -j "%sectname_flash% rw" -Obinary %cfgdir%/Exe/application.axf %cfgdir%/Exe/flash_run.bin
|
||||
) else (
|
||||
set flash_run_start=0xFFFFFFFF
|
||||
set flash_run_end=0xFFFFFFFF
|
||||
)
|
||||
|
||||
%tooldir%\pick %ram2_start% %ram2_end% %cfgdir%\Exe\ram_2.bin %cfgdir%\Exe\ram_2.p.bin body+reset_offset+sig
|
||||
%tooldir%\pick %ram2_start% %ram2_end% %cfgdir%\Exe\ram_2.bin %cfgdir%\Exe\ram_2.ns.bin body+reset_offset
|
||||
if defined %ram3_start (
|
||||
%tooldir%\pick %ram3_start% %ram3_end% %cfgdir%\Exe\sdram.bin %cfgdir%\Exe\ram_3.p.bin body+reset_offset
|
||||
)
|
||||
|
||||
:: force update ram_1.p.bin
|
||||
del %cfgdir%\Exe\ram_1.p.bin
|
||||
|
||||
:: check ram_1.p.bin exist, copy default
|
||||
if not exist %cfgdir%\Exe\ram_1.p.bin (
|
||||
copy %libdir%\image\ram_1.p.bin %cfgdir%\Exe\ram_1.p.bin
|
||||
)
|
||||
|
||||
::if not exist %cfgdir%\Exe\data.p.bin (
|
||||
:: copy %tooldir%\..\image\data.p.bin %cfgdir%\Exe\data.p.bin
|
||||
::)
|
||||
|
||||
::padding ram_1.p.bin to 32K+4K+4K+4K, LOADER/RSVD/SYSTEM/CALIBRATION
|
||||
%tooldir%\padding 44k 0xFF %cfgdir%\Exe\ram_1.p.bin
|
||||
|
||||
:: SDRAM case
|
||||
if defined %ram3_start (
|
||||
copy /b %cfgdir%\Exe\ram_1.p.bin+%cfgdir%\Exe\ram_2.p.bin+%cfgdir%\Exe\ram_3.p.bin %cfgdir%\Exe\ram_all.bin
|
||||
copy /b %cfgdir%\Exe\ram_2.ns.bin+%cfgdir%\Exe\ram_3.p.bin %cfgdir%\Exe\ota.bin
|
||||
)
|
||||
|
||||
:: NO SDRAM case
|
||||
if not defined %ram3_start (
|
||||
copy /b %cfgdir%\Exe\ram_1.p.bin+%cfgdir%\Exe\ram_2.p.bin %cfgdir%\Exe\ram_all.bin
|
||||
copy /b %cfgdir%\Exe\ram_2.ns.bin %cfgdir%\Exe\ota.bin
|
||||
set ram3_end=0xFFFFFFFF
|
||||
)
|
||||
|
||||
%tooldir%\checksum %cfgdir%\Exe\ota.bin
|
||||
|
||||
:: board generator
|
||||
%tooldir%\..\gen_board_img2.bat %ram2_start% %ram2_end% %ram3_end% %flash_run_start% %flash_run_end%
|
||||
|
||||
exit
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
Dim WshShell
|
||||
|
||||
Set WshShell = WScript.CreateObject("WScript.Shell")
|
||||
|
||||
WshShell.Run "cmd /c """""+WScript.Arguments.Item(1)+"\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\postbuild_img2.bat"" """+WScript.Arguments.Item(0)+""" """+WScript.Arguments.Item(1)+""" """+WScript.Arguments.Item(2)+"""""", 0
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
cd /D %2
|
||||
set bindir=application/Debug/bin
|
||||
set bindirw=application\Debug\bin
|
||||
set tooldir=%2\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\tools
|
||||
set libdir=%2\..\..\..\component\soc\realtek\8195a\misc\bsp
|
||||
|
||||
echo %tooldir%
|
||||
echo %libdir%
|
||||
|
||||
::del Debug/Exe/target.map Debug/Exe/application.asm *.bin
|
||||
cmd /c "%tooldir%\nm %bindir%/application.elf | %tooldir%\sort > %bindir%/application.nm.map"
|
||||
cmd /c "%tooldir%\objdump -d %bindir%/application.elf > %bindir%/application.asm"
|
||||
|
||||
|
||||
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep __ram_image2_text_start__ %bindir%/application.nm.map | %tooldir%\gawk '{print $1}'"') do set ram2_start=0x%%i
|
||||
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep __sdram_data_start__ %bindir%/application.nm.map | %tooldir%\gawk '{print $1}'"') do set ram3_start=0x%%i
|
||||
|
||||
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep __ram_image2_text_end__ %bindir%/application.nm.map | %tooldir%\gawk '{print $1}'"') do set ram2_end=0x%%i
|
||||
for /f "delims=" %%i in ('cmd /c "%tooldir%\grep __sdram_data_end__ %bindir%/application.nm.map | %tooldir%\gawk '{print $1}'"') do set ram3_end=0x%%i
|
||||
|
||||
::echo %ram1_start% > tmp.txt
|
||||
echo %ram2_start%
|
||||
echo %ram3_start%
|
||||
::echo %ram1_end% >> tmp.txt
|
||||
echo %ram2_end%
|
||||
echo %ram3_end%
|
||||
|
||||
|
||||
%tooldir%\objcopy -j .image2.start.table -j .ram_image2.text -j .ram.data -Obinary %bindir%/application.elf %bindir%/ram_2.bin
|
||||
if NOT %ram3_start% == %ram3_end% (
|
||||
%tooldir%\objcopy -j .sdr_data -Obinary %bindir%/application.elf %bindir%/sdram.bin
|
||||
)
|
||||
|
||||
%tooldir%\pick %ram2_start% %ram2_end% %bindirw%\ram_2.bin %bindirw%\ram_2.p.bin body+reset_offset+sig
|
||||
if defined %ram3_start (
|
||||
%tooldir%\pick %ram3_start% %ram3_end% %bindirw%\sdram.bin %bindirw%\ram_3.p.bin body+reset_offset
|
||||
)
|
||||
|
||||
:: check ram_1.p.bin exist, copy default
|
||||
if not exist %bindirw%\ram_1.p.bin (
|
||||
copy %libdir%\image\ram_1.p.bin %bindirw%\ram_1.p.bin
|
||||
)
|
||||
|
||||
::padding ram_1.p.bin to 32K+4K+4K+4K, LOADER/RSVD/SYSTEM/CALIBRATION
|
||||
%tooldir%\padding 44k 0xFF %bindirw%\ram_1.p.bin
|
||||
|
||||
:: SDRAM case
|
||||
if defined %ram3_start (
|
||||
copy /b %bindirw%\ram_1.p.bin+%bindirw%\ram_2.p.bin+%bindirw%\ram_3.p.bin %bindirw%\ram_all.bin
|
||||
copy /b %bindirw%\ram_2.p.bin+%bindirw%\ram_3.p.bin %bindirw%\ota.bin
|
||||
)
|
||||
|
||||
%tooldir%\checksum Debug\Exe\ota.bin
|
||||
|
||||
:: NO SDRAM case
|
||||
if not defined %ram3_start (
|
||||
copy /b %bindirw%\ram_1.p.bin+%bindirw%\ram_2.p.bin %bindirw%\ram_all.bin
|
||||
copy /b %bindirw%\ram_2.p.bin %bindirw%\ota.bin
|
||||
)
|
||||
|
||||
exit
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
cd /D %1
|
||||
set tooldir=%1\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\tools
|
||||
set libdir=%1\..\..\..\component\soc\realtek\8195a\misc\bsp
|
||||
:: Generate build_info.h
|
||||
echo off
|
||||
::echo %date:~0,10%-%time:~0,8%
|
||||
::echo %USERNAME%
|
||||
for /f "usebackq" %%i in (`hostname`) do set hostname=%%i
|
||||
::echo %hostname%
|
||||
|
||||
echo #define UTS_VERSION "%date:~0,10%-%time:~0,8%" > ..\inc\build_info.h
|
||||
echo #define RTL8195AFW_COMPILE_TIME "%date:~0,10%-%time:~0,8%" >> ..\inc\build_info.h
|
||||
echo #define RTL8195AFW_COMPILE_DATE "%date:~0,10%" >> ..\inc\build_info.h
|
||||
echo #define RTL8195AFW_COMPILE_BY "%USERNAME%" >> ..\inc\build_info.h
|
||||
echo #define RTL8195AFW_COMPILE_HOST "%hostname%" >> ..\inc\build_info.h
|
||||
echo #define RTL8195AFW_COMPILE_DOMAIN >> ..\inc\build_info.h
|
||||
echo #define RTL195AFW_COMPILER "IAR compiler" >> ..\inc\build_info.h
|
||||
|
||||
echo. > main.icf
|
||||
|
||||
for /f "delims=" %%i in ('cmd /c "%tooldir%\coan defs -g e ../src/main.c | %tooldir%\grep "#define" | %tooldir%\grep __ICFEDIT_region_BD_RAM_start__ | %tooldir%\gawk '{print $3}'"') do set BD_RAM_start=%%i
|
||||
|
||||
if defined %BD_RAM_start (
|
||||
echo define symbol __ICFEDIT_region_BD_RAM_start__ = %BD_RAM_start%; >> main.icf
|
||||
echo define symbol __ICFEDIT_region_BD_RAM_end__ = 0x1006CFFF; >> main.icf
|
||||
)
|
||||
|
||||
exit
|
||||
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
Option Explicit
|
||||
DIM fso
|
||||
|
||||
Dim WshShell
|
||||
|
||||
Set fso = CreateObject("Scripting.FileSystemObject")
|
||||
|
||||
If (fso.FileExists("""" & WScript.Arguments(0) & """\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\prebuild.bat")) Then
|
||||
MsgBox "script not exist " & WScript.Arguments(0) & "\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\prebuild.bat" , vbinformation
|
||||
WScript.Quit()
|
||||
End If
|
||||
|
||||
Set WshShell = WScript.CreateObject("WScript.Shell")
|
||||
|
||||
WshShell.Run "cmd /c """"" & WScript.Arguments(0) & "\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\prebuild.bat"" """ & WScript.Arguments(0) & """""", 0, true
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
cd /D %1
|
||||
|
||||
set objdir=%1\Debug\Obj
|
||||
|
||||
echo off
|
||||
|
||||
del /q /f %objdir%\dwc*
|
||||
del /q /f %objdir%\core_otg*
|
||||
del /q /f %objdir%\usb*
|
||||
|
||||
exit
|
||||
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
Option Explicit
|
||||
DIM fso
|
||||
|
||||
Dim WshShell
|
||||
|
||||
Set fso = CreateObject("Scripting.FileSystemObject")
|
||||
|
||||
If (fso.FileExists("""" & WScript.Arguments(0) & """\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\prebuild_usb.bat")) Then
|
||||
MsgBox "script not exist " & WScript.Arguments(0) & "\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\prebuild_usb.bat" , vbinformation
|
||||
WScript.Quit()
|
||||
End If
|
||||
|
||||
Set WshShell = WScript.CreateObject("WScript.Shell")
|
||||
|
||||
WshShell.Run "cmd /c """"" & WScript.Arguments(0) & "\..\..\..\component\soc\realtek\8195a\misc\iar_utility\common\prebuild_usb.bat"" """ & WScript.Arguments(0) & """""", 0, true
|
||||
399
component/soc/realtek/8195a/misc/iar_utility/common/preload.mac
Normal file
399
component/soc/realtek/8195a/misc/iar_utility/common/preload.mac
Normal file
|
|
@ -0,0 +1,399 @@
|
|||
//DRAM_INFO
|
||||
__var DeviceType;
|
||||
__var Page;
|
||||
__var Bank;
|
||||
__var DqWidth;
|
||||
|
||||
//DRAM_MODE_REG_INFO
|
||||
__var BstLen;
|
||||
__var BstType;
|
||||
__var Mode0Cas;
|
||||
__var Mode0Wr;
|
||||
__var Mode1DllEnN;
|
||||
__var Mode1AllLat;
|
||||
__var Mode2Cwl;
|
||||
|
||||
//DRAM_TIMING_INFO, additional parameter, to config DRAM_TIMING INFO
|
||||
__var DramTimingTref;
|
||||
__var DramRowNum;
|
||||
__var Tck;
|
||||
|
||||
//DRAM_TIMING_INFO
|
||||
__var TrfcPs;
|
||||
__var TrefiPs;
|
||||
__var WrMaxTck;
|
||||
__var TrcdPs;
|
||||
__var TrpPs;
|
||||
__var TrasPs;
|
||||
__var TrrdTck;
|
||||
__var TwrPs;
|
||||
__var TwtrTck;
|
||||
__var TmrdTck;
|
||||
__var TrtpTck;
|
||||
__var TccdTck;
|
||||
__var TrcPs;
|
||||
|
||||
//DRAM_DEVICE_INFO
|
||||
__var DdrPeriodPs;
|
||||
__var DfiRate;
|
||||
|
||||
__config_dram_param(){
|
||||
__var CsBstLen;
|
||||
__var CasWr;
|
||||
__var CasRd;
|
||||
__var CasRdT;
|
||||
__var ClrSrt;
|
||||
__var AddLat;
|
||||
__var DramEmr2;
|
||||
__var DramMr0;
|
||||
__var CrTwr;
|
||||
__var DramMaxWr;
|
||||
__var DramWr;
|
||||
__var CrTrtw;
|
||||
__var CrTrtwT;
|
||||
__var DramPeriod;
|
||||
__var DdrType;
|
||||
//__var paDqWidth;
|
||||
//__var paPage;
|
||||
//__var paDfiRate
|
||||
|
||||
__var tmp;
|
||||
|
||||
// Load parameter
|
||||
__load_dram_param();
|
||||
|
||||
DfiRate = 1<<DfiRate;
|
||||
DramPeriod = DdrPeriodPs*DfiRate;
|
||||
DramMaxWr= (WrMaxTck)/(DfiRate) +1;
|
||||
DramWr = ((TwrPs) / DramPeriod)+1;
|
||||
CrTwr = ((TwrPs) / DramPeriod) + 3;
|
||||
|
||||
if (CrTwr < DramMaxWr) {
|
||||
CrTwr = CrTwr;
|
||||
}else {
|
||||
CrTwr = DramMaxWr;
|
||||
}
|
||||
|
||||
if(DeviceType==2){ // Case DDR2
|
||||
DdrType = 2;
|
||||
if (BstLen == 0){
|
||||
CsBstLen = 0;
|
||||
CrTrtwT = 4;
|
||||
DramMr0 = 2;
|
||||
}else{
|
||||
CsBstLen = 1;
|
||||
CrTrtwT = 6;
|
||||
DramMr0 = 3;
|
||||
}
|
||||
CasRd = Mode0Cas;
|
||||
AddLat = Mode1AllLat;
|
||||
CasWr = CasRd + AddLat -1;
|
||||
DramEmr2 = 0;
|
||||
DramMr0 =(((DramWr%6)-1)<<(8+1))|(0<<8)|(Mode0Cas<<4)|(BstType<<3)|DramMr0;
|
||||
}
|
||||
if(DeviceType==3){ // Case DDR3
|
||||
DdrType = 3;
|
||||
if (BstLen==0){
|
||||
CsBstLen = 0; //bst_4
|
||||
DramMr0 = 2;
|
||||
}else{
|
||||
CsBstLen = 1; // bst_8
|
||||
DramMr0 = 0;
|
||||
}
|
||||
CrlSrt = (Mode0Cas >> 1);
|
||||
if (((Mode0Cas) & 0x1) ) {
|
||||
CasRdT = CrlSrt+ 12;
|
||||
}else{
|
||||
CasRdT = CrlSrt+ 4;
|
||||
}
|
||||
|
||||
AddLat = 0;
|
||||
if (Mode1AllLat == 1) { // CL-1
|
||||
AddLat = CasRd -1;
|
||||
}
|
||||
if (Mode1AllLat == 2){ // CL-2
|
||||
AddLat = CasRd -2;
|
||||
}
|
||||
CasRd = CasRdT + AddLat;
|
||||
CasWr = Mode2Cwl + 5 + AddLat;
|
||||
DramEmr2 = Mode2Cwl << 3;
|
||||
|
||||
DramWr = (DramWr + 1) / 2;
|
||||
if (DramWr == 16) {
|
||||
DramWr = 0;
|
||||
}
|
||||
if (DramWr <= 9) { // 5< wr <= 9
|
||||
DramWr = DramWr - 4;
|
||||
}
|
||||
DramMr0 =(DramWr<<(8+1))|(0<<8)|((Mode0Cas>>1)<<4)|(BstType<<3)|((Mode0Cas&0x1)<<2)|DramMr0;
|
||||
CrTrtwT = (CasRdT + 6) - CasWr;
|
||||
}
|
||||
if (DeviceType == 8){
|
||||
DdrType = 8;
|
||||
if (BstLen == 0) {
|
||||
DramMr0 = 2; // bst_4
|
||||
CsBstLen = 0; //bst_4
|
||||
CasRd = 0x2;
|
||||
} else {
|
||||
DramMr0 = 3; // bst_8
|
||||
CsBstLen = 1; // bst_8
|
||||
CasRd = 0x3;
|
||||
}
|
||||
CasWr = 0;
|
||||
DramMr0 =(CasRd<<4)|(BstType<<3)|DramMr0;
|
||||
CrTrtwT = 0; // tic: CasRd + rd_rtw + rd_pipe
|
||||
}
|
||||
|
||||
// countting tRTW
|
||||
if ((CrTrtwT & 0x1)) {
|
||||
CrTrtw = (CrTrtwT+1) /(DfiRate);
|
||||
} else {
|
||||
CrTrtw = CrTrtwT /(DfiRate);
|
||||
}
|
||||
|
||||
DqWidth = DqWidth;
|
||||
Page = Page +1; // DQ16 -> memory:byte_unit *2
|
||||
if (DqWidth == 1) { // paralle dq_16 => Page + 1
|
||||
Page = Page +1;
|
||||
}
|
||||
|
||||
// REG_SDR_MISC
|
||||
tmp =(Page<<0)|(Bank<<4)|(CsBstLen<<6)|(DqWidth<<8);
|
||||
__writeMemory32(tmp, 0x40005224, "Memory"); __delay(10);
|
||||
// REG_SDR_DCR
|
||||
tmp =(0x2<<8)|(DqWidth<<4)|(DdrType<<0);
|
||||
__writeMemory32(tmp, 0x40005004, "Memory"); __delay(10);
|
||||
// REG_SDR_IOCR
|
||||
tmp =((CasRd-4)/(DfiRate)<<20)|(0<<17)|(((CasWr-3)/(DfiRate))<<12)|(0<<8);
|
||||
__writeMemory32(tmp, 0x40005008, "Memory"); __delay(10);
|
||||
if(DeviceType != 8){
|
||||
tmp =DramEmr2;
|
||||
__writeMemory32(tmp, 0x40005028, "Memory"); __delay(10);
|
||||
tmp =(1<<2)|(1<<1)|(Mode1DllEnN);
|
||||
__writeMemory32(tmp, 0x40005024, "Memory"); __delay(10);
|
||||
}
|
||||
tmp =DramMr0;
|
||||
__writeMemory32(tmp, 0x40005020, "Memory"); __delay(10);
|
||||
tmp =(0<<28)|(9<<24)|((((TrefiPs)/DramPeriod)+1)<<8)|((((TrfcPs)/DramPeriod)+1)<<0);
|
||||
__writeMemory32(tmp, 0x40005010, "Memory"); __delay(10);
|
||||
tmp =((((TrtpTck)/DfiRate)+1)<<13)|(CrTwr<<9)|((((TrasPs)/DramPeriod)+1)<<4)|((((TrpPs)/DramPeriod)+1)<<0);
|
||||
__writeMemory32(tmp, 0x40005014, "Memory"); __delay(10);
|
||||
tmp =(CrTrtw << 20) |
|
||||
((((TwtrTck)/DfiRate)+3) << 17) |
|
||||
((((TccdTck)/DfiRate)+1) << 14) |
|
||||
((((TrcdPs)/DramPeriod)+1) << 10) |
|
||||
((((TrcPs)/DramPeriod)+1) << 4 ) |
|
||||
(((TrrdTck/DfiRate)+1) << 0);
|
||||
__writeMemory32(tmp, 0x40005018, "Memory"); __delay(10);
|
||||
tmp =(TmrdTck<<5)|(0<<4)|(2<<0);
|
||||
__writeMemory32(tmp, 0x4000501c, "Memory"); __delay(10);
|
||||
// Set Idle
|
||||
__writeMemory32(0x700, 0x4000500c, "Memory"); __delay(10);
|
||||
// start init
|
||||
__writeMemory32(0x1, 0x40005000, "Memory"); __delay(100);
|
||||
tmp = __readMemory32(0x40005000,"Memory"); __delay(10);
|
||||
// enter memory mode
|
||||
__writeMemory32(0x600, 0x4000500c, "Memory"); __delay(10);
|
||||
}
|
||||
|
||||
__config_dram_param_fixed(){
|
||||
__var tmp;
|
||||
// Dram Attribute
|
||||
__writeMemory32(0x1, 0x40005224, "Memory"); __delay(10);
|
||||
__writeMemory32(0x2c8, 0x40005004, "Memory"); __delay(10);
|
||||
__writeMemory32(0xffffd000, 0x40005008, "Memory"); __delay(10);
|
||||
__delay(3);
|
||||
__writeMemory32(0x22, 0x40005020, "Memory"); __delay(10);
|
||||
__delay(3);
|
||||
__writeMemory32(0x09032001, 0x40005010, "Memory"); __delay(10);
|
||||
__delay(3);
|
||||
__writeMemory32(0x2611, 0x40005014, "Memory"); __delay(10);
|
||||
__delay(3);
|
||||
__writeMemory32(0x68413, 0x40005018, "Memory"); __delay(10);
|
||||
__delay(3);
|
||||
__writeMemory32(0x42, 0x4000501c, "Memory"); __delay(10);
|
||||
__delay(3);
|
||||
|
||||
// Enable
|
||||
__writeMemory32(0x700, 0x4000500c, "Memory"); __delay(10);
|
||||
__delay(20);
|
||||
__writeMemory32(0x1, 0x40005000, "Memory"); __delay(10);
|
||||
__delay(100);
|
||||
tmp = __readMemory32(0x40005000,"Memory"); __delay(10);
|
||||
__writeMemory32(0x600, 0x4000500c, "Memory"); __delay(10);
|
||||
__delay(30);
|
||||
}
|
||||
|
||||
__mem_test(){
|
||||
__var i;
|
||||
__var vaddr;
|
||||
__var tmp;
|
||||
|
||||
i=0;
|
||||
while(i<10){
|
||||
vaddr = 0x30000000+((i*23)&0x1FFFFC);
|
||||
__writeMemory32(0x55AA55AA, vaddr, "Memory");
|
||||
tmp = __readMemory32(vaddr,"Memory");
|
||||
if(tmp!=0x55AA55AA)
|
||||
return 1;
|
||||
i=i+1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
__var ok_pipe_id0;
|
||||
__var ok_pipe_id1;
|
||||
__var ok_tpc_min0;
|
||||
__var ok_tpc_max0;
|
||||
__var ok_tpc_min1;
|
||||
__var ok_tpc_max1;
|
||||
__var tpc0_cnt;
|
||||
__var tpc1_cnt;
|
||||
|
||||
// calibration result
|
||||
__var isCalibrationDone;
|
||||
|
||||
__dram_calibration(){
|
||||
__var rdp;
|
||||
__var tpc;
|
||||
__var rdp_reg;
|
||||
__var tpc_reg;
|
||||
__var err_cnt;
|
||||
__var ok_cnt;
|
||||
|
||||
|
||||
ok_cnt=0;
|
||||
ok_pipe_id0 = 15;
|
||||
ok_tpc_min0 = 12;
|
||||
ok_tpc_max0 = 0;
|
||||
|
||||
rdp_reg = __readMemory32(0x40005008,"Memory")&0xFFFF00FF;
|
||||
tpc_reg = __readMemory32(0x40000300,"Memory")&0xFF00FFFF;
|
||||
for(rdp=0;(rdp<=7)&&(err_cnt==0||ok_cnt==0);rdp++){
|
||||
err_cnt=0;
|
||||
// try pipe
|
||||
__writeMemory32(rdp_reg|rdp<<8,0x40005008, "Memory");__delay(10);
|
||||
for(tpc=0;(tpc<=12)&&(err_cnt<2);tpc++){
|
||||
// try tpc
|
||||
__writeMemory32(tpc_reg|tpc<<16,0x40000300, "Memory");__delay(10);
|
||||
if(__mem_test()==0){
|
||||
if(ok_pipe_id0==15) {ok_pipe_id0 = rdp; ok_cnt++;}
|
||||
if(ok_tpc_min0>tpc) ok_tpc_min0 = tpc;
|
||||
if(ok_tpc_max0<tpc) ok_tpc_max0 = tpc;
|
||||
}else{
|
||||
err_cnt++;
|
||||
}
|
||||
}
|
||||
if(ok_pipe_id0!=15){
|
||||
ok_pipe_id1 = ok_pipe_id0;
|
||||
ok_tpc_min1 = ok_tpc_min0;
|
||||
ok_tpc_max1 = ok_tpc_max0;
|
||||
ok_pipe_id0 = 15;
|
||||
ok_tpc_min0 = 12;
|
||||
ok_tpc_max0 = 0;
|
||||
}
|
||||
}
|
||||
tpc0_cnt = ok_tpc_max0-ok_tpc_min0;
|
||||
if(tpc0_cnt<0) tpc0_cnt = 0;
|
||||
tpc1_cnt = ok_tpc_max1-ok_tpc_min1;
|
||||
if(tpc1_cnt<0) tpc1_cnt = 0;
|
||||
|
||||
if(tpc1_cnt>tpc0_cnt){
|
||||
__writeMemory32(rdp_reg|ok_pipe_id1<<8,0x40005008, "Memory");__delay(10);
|
||||
__writeMemory32(tpc_reg|(tpc1_cnt/2)<<16,0x40000300, "Memory");__delay(10);
|
||||
}else{
|
||||
__writeMemory32(rdp_reg|ok_pipe_id0<<8,0x40005008, "Memory");__delay(10);
|
||||
__writeMemory32(tpc_reg|(tpc0_cnt/2)<<16,0x40000300, "Memory");__delay(10);
|
||||
}
|
||||
}
|
||||
|
||||
__setup_system()
|
||||
{
|
||||
__var tmp;
|
||||
|
||||
if(__driverType("jlink")){
|
||||
__hwResetWithStrategy(0, 0);
|
||||
//__hwReset(1);
|
||||
}else{
|
||||
__hwResetWithStrategy(0, 2);
|
||||
__hwReset(1);
|
||||
}
|
||||
|
||||
__writeMemory32(0x21, 0x40000014, "Memory"); __delay(10);
|
||||
__writeMemory32(0x1FC00002, 0x40000304, "Memory"); __delay(10);
|
||||
__writeMemory32(0x400, 0x40000250, "Memory"); __delay(10);
|
||||
__writeMemory32(0x0, 0x40000340, "Memory"); __delay(10);
|
||||
__writeMemory32(0xdcc4, 0x40000230, "Memory"); __delay(10);
|
||||
__writeMemory32(0x11117, 0x40000210, "Memory"); __delay(10);
|
||||
__writeMemory32(0x11157, 0x40000210, "Memory"); __delay(10);
|
||||
__writeMemory32(0x110011, 0x400002c0, "Memory"); __delay(10);
|
||||
__writeMemory32(0xffffffff, 0x40000320, "Memory"); __delay(10);
|
||||
__writeMemory32(0xfcc702, 0x40000040, "Memory"); __delay(10);
|
||||
|
||||
__config_dram_param();
|
||||
|
||||
if(isCalibrationDone){
|
||||
__var rdp_reg;
|
||||
__var tpc_reg;
|
||||
rdp_reg = __readMemory32(0x40005008,"Memory")&0xFFFF00FF;
|
||||
tpc_reg = __readMemory32(0x40000300,"Memory")&0xFF00FFFF;
|
||||
|
||||
if(tpc1_cnt>tpc0_cnt){
|
||||
__writeMemory32(rdp_reg|ok_pipe_id1<<8,0x40005008, "Memory");__delay(10);
|
||||
__writeMemory32(tpc_reg|(tpc1_cnt/2)<<16,0x40000300, "Memory");__delay(10);
|
||||
}else{
|
||||
__writeMemory32(rdp_reg|ok_pipe_id0<<8,0x40005008, "Memory");__delay(10);
|
||||
__writeMemory32(tpc_reg|(tpc0_cnt/2)<<16,0x40000300, "Memory");__delay(10);
|
||||
}
|
||||
}else{
|
||||
// Calibration
|
||||
__dram_calibration();
|
||||
isCalibrationDone = 1;
|
||||
}
|
||||
}
|
||||
|
||||
execUserPreload()
|
||||
{
|
||||
// Register dram common.mac
|
||||
__registerMacroFile("$PROJ_DIR$\\..\\..\\..\\component\\soc\\realtek\\8195a\\misc\\iar_utility\\common\\dram\\common.mac");
|
||||
__load_dram_common();
|
||||
isCalibrationDone = 0;
|
||||
|
||||
__message "User Preload....";
|
||||
if(__driverType("jlink")){
|
||||
__message "driver type J-LINK";
|
||||
}else if(__driverType("cmsisdap")){
|
||||
__message "driver type CMSIS-DAP";
|
||||
}else if(__driverType("cmsisdap")){
|
||||
__message "driver type I-JET";
|
||||
}
|
||||
__setup_system();
|
||||
}
|
||||
|
||||
execUserSetup()
|
||||
{
|
||||
__var tmp;
|
||||
__message "User Setup....";
|
||||
// if use normal reset, please unmark those 2 lines
|
||||
//execUserPreload();
|
||||
if(__driverType("jlink")){
|
||||
__loadImage("$TARGET_PATH$ ", 0, 0);
|
||||
tmp = __readMemory32(0x40000210, "Memory")|(1<<27);
|
||||
//tmp = __readMemory32(0x40000210, "Memory")|(1<<21);
|
||||
}else if(__driverType("cmsisdap") || __driverType("ijet")){
|
||||
tmp = __readMemory32(0x40000210, "Memory")|(1<<21);
|
||||
}else{
|
||||
__message "Not support drive type";
|
||||
}
|
||||
__writeMemory32(tmp, 0x40000210, "Memory");
|
||||
}
|
||||
|
||||
execUserReset()
|
||||
{
|
||||
__var tmp;
|
||||
__message "User Reset....";
|
||||
__setup_system();
|
||||
tmp = __readMemory32(0x40000210, "Memory")&(~(1<<27));
|
||||
tmp = tmp & (~(1<<21));
|
||||
__writeMemory32(tmp, 0x40000210, "Memory");
|
||||
}
|
||||
|
|
@ -0,0 +1,408 @@
|
|||
//DRAM_INFO
|
||||
__var DeviceType;
|
||||
__var Page;
|
||||
__var Bank;
|
||||
__var DqWidth;
|
||||
|
||||
//DRAM_MODE_REG_INFO
|
||||
__var BstLen;
|
||||
__var BstType;
|
||||
__var Mode0Cas;
|
||||
__var Mode0Wr;
|
||||
__var Mode1DllEnN;
|
||||
__var Mode1AllLat;
|
||||
__var Mode2Cwl;
|
||||
|
||||
//DRAM_TIMING_INFO, additional parameter, to config DRAM_TIMING INFO
|
||||
__var DramTimingTref;
|
||||
__var DramRowNum;
|
||||
__var Tck;
|
||||
|
||||
//DRAM_TIMING_INFO
|
||||
__var TrfcPs;
|
||||
__var TrefiPs;
|
||||
__var WrMaxTck;
|
||||
__var TrcdPs;
|
||||
__var TrpPs;
|
||||
__var TrasPs;
|
||||
__var TrrdTck;
|
||||
__var TwrPs;
|
||||
__var TwtrTck;
|
||||
__var TmrdTck;
|
||||
__var TrtpTck;
|
||||
__var TccdTck;
|
||||
__var TrcPs;
|
||||
|
||||
//DRAM_DEVICE_INFO
|
||||
__var DdrPeriodPs;
|
||||
__var DfiRate;
|
||||
|
||||
__config_dram_param(){
|
||||
__var CsBstLen;
|
||||
__var CasWr;
|
||||
__var CasRd;
|
||||
__var CasRdT;
|
||||
__var ClrSrt;
|
||||
__var AddLat;
|
||||
__var DramEmr2;
|
||||
__var DramMr0;
|
||||
__var CrTwr;
|
||||
__var DramMaxWr;
|
||||
__var DramWr;
|
||||
__var CrTrtw;
|
||||
__var CrTrtwT;
|
||||
__var DramPeriod;
|
||||
__var DdrType;
|
||||
//__var paDqWidth;
|
||||
//__var paPage;
|
||||
//__var paDfiRate
|
||||
|
||||
__var tmp;
|
||||
|
||||
// Load parameter
|
||||
__load_dram_param();
|
||||
|
||||
DfiRate = 1<<DfiRate;
|
||||
DramPeriod = DdrPeriodPs*DfiRate;
|
||||
DramMaxWr= (WrMaxTck)/(DfiRate) +1;
|
||||
DramWr = ((TwrPs) / DramPeriod)+1;
|
||||
CrTwr = ((TwrPs) / DramPeriod) + 3;
|
||||
|
||||
if (CrTwr < DramMaxWr) {
|
||||
CrTwr = CrTwr;
|
||||
}else {
|
||||
CrTwr = DramMaxWr;
|
||||
}
|
||||
|
||||
if(DeviceType==2){ // Case DDR2
|
||||
DdrType = 2;
|
||||
if (BstLen == 0){
|
||||
CsBstLen = 0;
|
||||
CrTrtwT = 4;
|
||||
DramMr0 = 2;
|
||||
}else{
|
||||
CsBstLen = 1;
|
||||
CrTrtwT = 6;
|
||||
DramMr0 = 3;
|
||||
}
|
||||
CasRd = Mode0Cas;
|
||||
AddLat = Mode1AllLat;
|
||||
CasWr = CasRd + AddLat -1;
|
||||
DramEmr2 = 0;
|
||||
DramMr0 =(((DramWr%6)-1)<<(8+1))|(0<<8)|(Mode0Cas<<4)|(BstType<<3)|DramMr0;
|
||||
}
|
||||
if(DeviceType==3){ // Case DDR3
|
||||
DdrType = 3;
|
||||
if (BstLen==0){
|
||||
CsBstLen = 0; //bst_4
|
||||
DramMr0 = 2;
|
||||
}else{
|
||||
CsBstLen = 1; // bst_8
|
||||
DramMr0 = 0;
|
||||
}
|
||||
CrlSrt = (Mode0Cas >> 1);
|
||||
if (((Mode0Cas) & 0x1) ) {
|
||||
CasRdT = CrlSrt+ 12;
|
||||
}else{
|
||||
CasRdT = CrlSrt+ 4;
|
||||
}
|
||||
|
||||
AddLat = 0;
|
||||
if (Mode1AllLat == 1) { // CL-1
|
||||
AddLat = CasRd -1;
|
||||
}
|
||||
if (Mode1AllLat == 2){ // CL-2
|
||||
AddLat = CasRd -2;
|
||||
}
|
||||
CasRd = CasRdT + AddLat;
|
||||
CasWr = Mode2Cwl + 5 + AddLat;
|
||||
DramEmr2 = Mode2Cwl << 3;
|
||||
|
||||
DramWr = (DramWr + 1) / 2;
|
||||
if (DramWr == 16) {
|
||||
DramWr = 0;
|
||||
}
|
||||
if (DramWr <= 9) { // 5< wr <= 9
|
||||
DramWr = DramWr - 4;
|
||||
}
|
||||
DramMr0 =(DramWr<<(8+1))|(0<<8)|((Mode0Cas>>1)<<4)|(BstType<<3)|((Mode0Cas&0x1)<<2)|DramMr0;
|
||||
CrTrtwT = (CasRdT + 6) - CasWr;
|
||||
}
|
||||
if (DeviceType == 8){
|
||||
DdrType = 8;
|
||||
if (BstLen == 0) {
|
||||
DramMr0 = 2; // bst_4
|
||||
CsBstLen = 0; //bst_4
|
||||
CasRd = 0x2;
|
||||
} else {
|
||||
DramMr0 = 3; // bst_8
|
||||
CsBstLen = 1; // bst_8
|
||||
CasRd = 0x3;
|
||||
}
|
||||
CasWr = 0;
|
||||
DramMr0 =(CasRd<<4)|(BstType<<3)|DramMr0;
|
||||
CrTrtwT = 0; // tic: CasRd + rd_rtw + rd_pipe
|
||||
}
|
||||
|
||||
// countting tRTW
|
||||
if ((CrTrtwT & 0x1)) {
|
||||
CrTrtw = (CrTrtwT+1) /(DfiRate);
|
||||
} else {
|
||||
CrTrtw = CrTrtwT /(DfiRate);
|
||||
}
|
||||
|
||||
DqWidth = DqWidth;
|
||||
Page = Page +1; // DQ16 -> memory:byte_unit *2
|
||||
if (DqWidth == 1) { // paralle dq_16 => Page + 1
|
||||
Page = Page +1;
|
||||
}
|
||||
|
||||
// REG_SDR_MISC
|
||||
tmp =(Page<<0)|(Bank<<4)|(CsBstLen<<6)|(DqWidth<<8);
|
||||
__writeMemory32(tmp, 0x40005224, "Memory"); __delay(10);
|
||||
// REG_SDR_DCR
|
||||
tmp =(0x2<<8)|(DqWidth<<4)|(DdrType<<0);
|
||||
__writeMemory32(tmp, 0x40005004, "Memory"); __delay(10);
|
||||
// REG_SDR_IOCR
|
||||
tmp =((CasRd-4)/(DfiRate)<<20)|(0<<17)|(((CasWr-3)/(DfiRate))<<12)|(0<<8);
|
||||
__writeMemory32(tmp, 0x40005008, "Memory"); __delay(10);
|
||||
if(DeviceType != 8){
|
||||
tmp =DramEmr2;
|
||||
__writeMemory32(tmp, 0x40005028, "Memory"); __delay(10);
|
||||
tmp =(1<<2)|(1<<1)|(Mode1DllEnN);
|
||||
__writeMemory32(tmp, 0x40005024, "Memory"); __delay(10);
|
||||
}
|
||||
tmp =DramMr0;
|
||||
__writeMemory32(tmp, 0x40005020, "Memory"); __delay(10);
|
||||
tmp =(0<<28)|(9<<24)|((((TrefiPs)/DramPeriod)+1)<<8)|((((TrfcPs)/DramPeriod)+1)<<0);
|
||||
__writeMemory32(tmp, 0x40005010, "Memory"); __delay(10);
|
||||
tmp =((((TrtpTck)/DfiRate)+1)<<13)|(CrTwr<<9)|((((TrasPs)/DramPeriod)+1)<<4)|((((TrpPs)/DramPeriod)+1)<<0);
|
||||
__writeMemory32(tmp, 0x40005014, "Memory"); __delay(10);
|
||||
tmp =(CrTrtw << 20) |
|
||||
((((TwtrTck)/DfiRate)+3) << 17) |
|
||||
((((TccdTck)/DfiRate)+1) << 14) |
|
||||
((((TrcdPs)/DramPeriod)+1) << 10) |
|
||||
((((TrcPs)/DramPeriod)+1) << 4 ) |
|
||||
(((TrrdTck/DfiRate)+1) << 0);
|
||||
__writeMemory32(tmp, 0x40005018, "Memory"); __delay(10);
|
||||
tmp =(TmrdTck<<5)|(0<<4)|(2<<0);
|
||||
__writeMemory32(tmp, 0x4000501c, "Memory"); __delay(10);
|
||||
// Set Idle
|
||||
__writeMemory32(0x700, 0x4000500c, "Memory"); __delay(10);
|
||||
// start init
|
||||
__writeMemory32(0x1, 0x40005000, "Memory"); __delay(100);
|
||||
tmp = __readMemory32(0x40005000,"Memory"); __delay(10);
|
||||
// enter memory mode
|
||||
__writeMemory32(0x600, 0x4000500c, "Memory"); __delay(10);
|
||||
}
|
||||
|
||||
__config_dram_param_fixed(){
|
||||
__var tmp;
|
||||
// Dram Attribute
|
||||
__writeMemory32(0x1, 0x40005224, "Memory"); __delay(10);
|
||||
__writeMemory32(0x2c8, 0x40005004, "Memory"); __delay(10);
|
||||
__writeMemory32(0xffffd000, 0x40005008, "Memory"); __delay(10);
|
||||
__delay(3);
|
||||
__writeMemory32(0x22, 0x40005020, "Memory"); __delay(10);
|
||||
__delay(3);
|
||||
__writeMemory32(0x09032001, 0x40005010, "Memory"); __delay(10);
|
||||
__delay(3);
|
||||
__writeMemory32(0x2611, 0x40005014, "Memory"); __delay(10);
|
||||
__delay(3);
|
||||
__writeMemory32(0x68413, 0x40005018, "Memory"); __delay(10);
|
||||
__delay(3);
|
||||
__writeMemory32(0x42, 0x4000501c, "Memory"); __delay(10);
|
||||
__delay(3);
|
||||
|
||||
// Enable
|
||||
__writeMemory32(0x700, 0x4000500c, "Memory"); __delay(10);
|
||||
__delay(20);
|
||||
__writeMemory32(0x1, 0x40005000, "Memory"); __delay(10);
|
||||
__delay(100);
|
||||
tmp = __readMemory32(0x40005000,"Memory"); __delay(10);
|
||||
__writeMemory32(0x600, 0x4000500c, "Memory"); __delay(10);
|
||||
__delay(30);
|
||||
}
|
||||
|
||||
__mem_test(){
|
||||
__var i;
|
||||
__var vaddr;
|
||||
__var tmp;
|
||||
|
||||
i=0;
|
||||
while(i<10){
|
||||
vaddr = 0x30000000+((i*23)&0x1FFFFC);
|
||||
__writeMemory32(0x55AA55AA, vaddr, "Memory");
|
||||
tmp = __readMemory32(vaddr,"Memory");
|
||||
if(tmp!=0x55AA55AA)
|
||||
return 1;
|
||||
i=i+1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
__var ok_pipe_id0;
|
||||
__var ok_pipe_id1;
|
||||
__var ok_tpc_min0;
|
||||
__var ok_tpc_max0;
|
||||
__var ok_tpc_min1;
|
||||
__var ok_tpc_max1;
|
||||
__var tpc0_cnt;
|
||||
__var tpc1_cnt;
|
||||
|
||||
// calibration result
|
||||
__var isCalibrationDone;
|
||||
|
||||
__dram_calibration(){
|
||||
__var rdp;
|
||||
__var tpc;
|
||||
__var rdp_reg;
|
||||
__var tpc_reg;
|
||||
__var err_cnt;
|
||||
__var ok_cnt;
|
||||
|
||||
|
||||
ok_cnt=0;
|
||||
ok_pipe_id0 = 15;
|
||||
ok_tpc_min0 = 12;
|
||||
ok_tpc_max0 = 0;
|
||||
|
||||
rdp_reg = __readMemory32(0x40005008,"Memory")&0xFFFF00FF;
|
||||
tpc_reg = __readMemory32(0x40000300,"Memory")&0xFF00FFFF;
|
||||
for(rdp=0;(rdp<=7)&&(err_cnt==0||ok_cnt==0);rdp++){
|
||||
err_cnt=0;
|
||||
// try pipe
|
||||
__writeMemory32(rdp_reg|rdp<<8,0x40005008, "Memory");__delay(10);
|
||||
for(tpc=0;(tpc<=12)&&(err_cnt<2);tpc++){
|
||||
// try tpc
|
||||
__writeMemory32(tpc_reg|tpc<<16,0x40000300, "Memory");__delay(10);
|
||||
if(__mem_test()==0){
|
||||
if(ok_pipe_id0==15) {ok_pipe_id0 = rdp; ok_cnt++;}
|
||||
if(ok_tpc_min0>tpc) ok_tpc_min0 = tpc;
|
||||
if(ok_tpc_max0<tpc) ok_tpc_max0 = tpc;
|
||||
}else{
|
||||
err_cnt++;
|
||||
}
|
||||
}
|
||||
if(ok_pipe_id0!=15){
|
||||
ok_pipe_id1 = ok_pipe_id0;
|
||||
ok_tpc_min1 = ok_tpc_min0;
|
||||
ok_tpc_max1 = ok_tpc_max0;
|
||||
ok_pipe_id0 = 15;
|
||||
ok_tpc_min0 = 12;
|
||||
ok_tpc_max0 = 0;
|
||||
}
|
||||
}
|
||||
tpc0_cnt = ok_tpc_max0-ok_tpc_min0;
|
||||
if(tpc0_cnt<0) tpc0_cnt = 0;
|
||||
tpc1_cnt = ok_tpc_max1-ok_tpc_min1;
|
||||
if(tpc1_cnt<0) tpc1_cnt = 0;
|
||||
|
||||
if(tpc1_cnt>tpc0_cnt){
|
||||
__writeMemory32(rdp_reg|ok_pipe_id1<<8,0x40005008, "Memory");__delay(10);
|
||||
__writeMemory32(tpc_reg|(tpc1_cnt/2)<<16,0x40000300, "Memory");__delay(10);
|
||||
}else{
|
||||
__writeMemory32(rdp_reg|ok_pipe_id0<<8,0x40005008, "Memory");__delay(10);
|
||||
__writeMemory32(tpc_reg|(tpc0_cnt/2)<<16,0x40000300, "Memory");__delay(10);
|
||||
}
|
||||
}
|
||||
|
||||
__setup_system()
|
||||
{
|
||||
__var tmp;
|
||||
|
||||
if(__driverType("jlink")){
|
||||
__hwResetWithStrategy(0, 0);
|
||||
//__hwReset(1);
|
||||
}else{
|
||||
__hwResetWithStrategy(0, 2);
|
||||
__hwReset(1);
|
||||
}
|
||||
|
||||
__writeMemory32(0x21, 0x40000014, "Memory"); __delay(10);
|
||||
__writeMemory32(0x1FC00002, 0x40000304, "Memory"); __delay(10);
|
||||
__writeMemory32(0x400, 0x40000250, "Memory"); __delay(10);
|
||||
__writeMemory32(0x0, 0x40000340, "Memory"); __delay(10);
|
||||
__writeMemory32(0xdcc4, 0x40000230, "Memory"); __delay(10);
|
||||
__writeMemory32(0x11117, 0x40000210, "Memory"); __delay(10);
|
||||
__writeMemory32(0x11157, 0x40000210, "Memory"); __delay(10);
|
||||
__writeMemory32(0x110011, 0x400002c0, "Memory"); __delay(10);
|
||||
__writeMemory32(0xffffffff, 0x40000320, "Memory"); __delay(10);
|
||||
__writeMemory32(0xfcc702, 0x40000040, "Memory"); __delay(10);
|
||||
|
||||
__config_dram_param();
|
||||
|
||||
if(isCalibrationDone){
|
||||
__var rdp_reg;
|
||||
__var tpc_reg;
|
||||
rdp_reg = __readMemory32(0x40005008,"Memory")&0xFFFF00FF;
|
||||
tpc_reg = __readMemory32(0x40000300,"Memory")&0xFF00FFFF;
|
||||
|
||||
if(tpc1_cnt>tpc0_cnt){
|
||||
__writeMemory32(rdp_reg|ok_pipe_id1<<8,0x40005008, "Memory");__delay(10);
|
||||
__writeMemory32(tpc_reg|(tpc1_cnt/2)<<16,0x40000300, "Memory");__delay(10);
|
||||
}else{
|
||||
__writeMemory32(rdp_reg|ok_pipe_id0<<8,0x40005008, "Memory");__delay(10);
|
||||
__writeMemory32(tpc_reg|(tpc0_cnt/2)<<16,0x40000300, "Memory");__delay(10);
|
||||
}
|
||||
}else{
|
||||
// Calibration
|
||||
__dram_calibration();
|
||||
isCalibrationDone = 1;
|
||||
}
|
||||
}
|
||||
|
||||
execUserPreload()
|
||||
{
|
||||
// Register dram common.mac
|
||||
__registerMacroFile("$PROJ_DIR$\\..\\..\\..\\component\\soc\\realtek\\8195a\\misc\\iar_utility\\common\\dram\\common.mac");
|
||||
__load_dram_common();
|
||||
isCalibrationDone = 0;
|
||||
|
||||
__message "User Preload....";
|
||||
if(__driverType("jlink")){
|
||||
__message "driver type J-LINK";
|
||||
}else if(__driverType("cmsisdap")){
|
||||
__message "driver type CMSIS-DAP";
|
||||
}else if(__driverType("cmsisdap")){
|
||||
__message "driver type I-JET";
|
||||
}
|
||||
__setup_system();
|
||||
}
|
||||
|
||||
execUserSetup()
|
||||
{
|
||||
__var tmp;
|
||||
__message "User Setup....";
|
||||
// if use normal reset, please unmark those 2 lines
|
||||
//execUserPreload();
|
||||
if(__driverType("jlink")){
|
||||
__loadImage("$TARGET_PATH$ ", 0, 0);
|
||||
tmp = __readMemory32(0x1000E000, "Memory");
|
||||
__writeMemory32(tmp, 0x10006000, "Memory");
|
||||
tmp = __readMemory32(0x1000E004, "Memory");
|
||||
__writeMemory32(tmp, 0x10006004, "Memory");
|
||||
tmp = __readMemory32(0x1000E008, "Memory");
|
||||
__writeMemory32(tmp, 0x10006008, "Memory");
|
||||
tmp = __readMemory32(0x1000E00C, "Memory");
|
||||
__writeMemory32(tmp, 0x1000600C, "Memory");
|
||||
|
||||
tmp = __readMemory32(0x40000210, "Memory")|(1<<27);
|
||||
//tmp = __readMemory32(0x40000210, "Memory")|(1<<21);
|
||||
}else if(__driverType("cmsisdap") || __driverType("ijet")){
|
||||
tmp = __readMemory32(0x40000210, "Memory")|(1<<21);
|
||||
}else{
|
||||
__message "Not support drive type";
|
||||
}
|
||||
__writeMemory32(tmp, 0x40000210, "Memory");
|
||||
}
|
||||
|
||||
execUserReset()
|
||||
{
|
||||
__var tmp;
|
||||
__message "User Reset....";
|
||||
__setup_system();
|
||||
tmp = __readMemory32(0x40000210, "Memory")&(~(1<<27));
|
||||
tmp = tmp & (~(1<<21));
|
||||
__writeMemory32(tmp, 0x40000210, "Memory");
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue