This commit is contained in:
pvvx 2018-01-20 20:52:27 +03:00
parent 54bf751b9c
commit 3a9b303c84
11 changed files with 46 additions and 18 deletions

18
USDK/Realtek.lic Normal file
View file

@ -0,0 +1,18 @@
/******************************************************************************
*
* Copyright(c) 2007 - 2016 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
*
******************************************************************************/

View file

@ -40,7 +40,7 @@ HalPinCtrlRtl8195A(
IN BOOL Operation IN BOOL Operation
); );
extern _LONG_CALL_ VOID extern _LONG_CALL_ int
HalSerialPutcRtl8195a( HalSerialPutcRtl8195a(
IN u8 c IN u8 c
); );

View file

@ -86,7 +86,7 @@ HalLogUartInit(
); );
extern _LONG_CALL_ROM_ VOID extern _LONG_CALL_ROM_ int
HalSerialPutcRtl8195a( HalSerialPutcRtl8195a(
IN u8 c IN u8 c
); );

View file

@ -1,5 +1,6 @@
/* /*
* BootLoader Ver 0.3 (19/10/2017) * BootLoader Ver 0.3 (19/10/2017)
* + Ver 0.4 (20/01/2018)
* Created on: 12/02/2017 * Created on: 12/02/2017
* Author: pvvx * Author: pvvx
*/ */
@ -508,9 +509,14 @@ LOCAL const char * const txt_tab_seg[] = {
"ROM" // 7 "ROM" // 7
}; };
LOCAL const uint32 tab_seg_def[] = { 0x10000000, 0x10070000, 0x1fff0000, LOCAL const uint32 tab_seg_def[] = {
0x20000000, 0x30000000, 0x30200000, 0x40000000, 0x40800000, 0x98000000, 0x10000000, 0x10070000,
0xA0000000, 0xE0000000, 0xE0010000, 0x00000000, 0x00050000 }; 0x1fff0000, 0x20000000,
0x30000000, 0x30200000,
0x40000000, 0x40800000,
0x98000000, 0xA0000000,
0xE0000000, 0xE0010000,
0x00000000, 0x00050000 };
LOCAL uint32 BOOT_RAM_TEXT_SECTION get_seg_id(uint32 addr, int32 size) { LOCAL uint32 BOOT_RAM_TEXT_SECTION get_seg_id(uint32 addr, int32 size) {
uint32 ret = SEG_ID_ERR; uint32 ret = SEG_ID_ERR;
@ -518,7 +524,7 @@ LOCAL uint32 BOOT_RAM_TEXT_SECTION get_seg_id(uint32 addr, int32 size) {
if (size > 0) { if (size > 0) {
do { do {
ret++; ret++;
if (addr >= ptr[0] && addr + size <= ptr[1]) { if (addr >= ptr[0] && addr + size <= ptr[1] && size <= ptr[1] - ptr[0]) {
return ret; return ret;
}; };
ptr += 2; ptr += 2;

View file

@ -185,7 +185,12 @@ extern HAL_GPIO_ADAPTER gBoot_Gpio_Adapter;
_pHAL_Gpio_Adapter = &gBoot_Gpio_Adapter; _pHAL_Gpio_Adapter = &gBoot_Gpio_Adapter;
VectorTableInitRtl8195A(STACK_TOP); // 0x1FFFFFFC VectorTableInitRtl8195A(STACK_TOP); // 0x1FFFFFFC
loguart_wait_tx_fifo_empty(); // иначе глючит LogUART, если переключение CLK приходится на вывод символов ! loguart_wait_tx_fifo_empty(); // иначе глючит LogUART, если переключение CLK приходится на вывод символов !
#if 1 // if set CLK CPU uint8 ChipId = HalGetChipId();
#ifdef ARDUINO
// 0 - 166666666 Hz, 1 - 83333333 Hz
*((int *) (SYSTEM_CTRL_BASE + REG_SYS_SYSPLL_CTRL1)) &= ~(1 << 17); // REG_SYS_SYSPLL_CTRL1 &= ~BIT_SYS_SYSPLL_DIV5_3
HalCpuClkConfig(ChipId < CHIP_ID_8195AM);
#else // if set CLK CPU
if(HalGetCpuClk() != PLATFORM_CLOCK) { if(HalGetCpuClk() != PLATFORM_CLOCK) {
//----- CLK CPU //----- CLK CPU
#if CPU_CLOCK_SEL_DIV5_3 #if CPU_CLOCK_SEL_DIV5_3
@ -198,7 +203,7 @@ extern HAL_GPIO_ADAPTER gBoot_Gpio_Adapter;
HalCpuClkConfig(CPU_CLOCK_SEL_VALUE); HalCpuClkConfig(CPU_CLOCK_SEL_VALUE);
#endif // CPU_CLOCK_SEL_DIV5_3 #endif // CPU_CLOCK_SEL_DIV5_3
}; };
#endif #endif // ARDUINO
PSHalInitPlatformLogUart(); // HalInitPlatformLogUartV02(); // Show "<RTL8195A>"... :( PSHalInitPlatformLogUart(); // HalInitPlatformLogUartV02(); // Show "<RTL8195A>"... :(
HalReInitPlatformTimer(); // HalInitPlatformTimerV02(); HalTimerOpInit_Patch((VOID*) (&HalTimerOp)); HalReInitPlatformTimer(); // HalInitPlatformTimerV02(); HalTimerOpInit_Patch((VOID*) (&HalTimerOp));
SystemCoreClockUpdate(); SystemCoreClockUpdate();
@ -225,7 +230,7 @@ extern HAL_GPIO_ADAPTER gBoot_Gpio_Adapter;
*/ */
// SpicFlashInitRtl8195A(SpicDualBitMode); // SpicReadIDRtl8195A(); SpicDualBitMode // SpicFlashInitRtl8195A(SpicDualBitMode); // SpicReadIDRtl8195A(); SpicDualBitMode
//---- SDRAM //---- SDRAM
uint8 ChipId = HalGetChipId(); // uint8 ChipId = HalGetChipId();
if (ChipId >= CHIP_ID_8195AM) { if (ChipId >= CHIP_ID_8195AM) {
if((HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) & BIT(21)) == 0) { // SDR not init? if((HAL_PERI_ON_READ32(REG_SOC_FUNC_EN) & BIT(21)) == 0) { // SDR not init?
#ifdef FIX_SDR_CALIBRATION // for speed :) #ifdef FIX_SDR_CALIBRATION // for speed :)

View file

@ -4,7 +4,7 @@ r1
trst1 trst1
h h
r r
loadbin build/bin/ram_1.r.bin 0x10000bc8 loadbin build/bin/ram_1.bin 0x10000bc8
loadbin build/bin/ram_2.bin 0x10006000 loadbin build/bin/ram_2.bin 0x10006000
r r
w4 0x40000210,0x20011113 w4 0x40000210,0x20011113

View file

@ -4,7 +4,7 @@ r1
trst1 trst1
h h
r r
loadbin build/bin/ram_1.r.bin 0x10000bc8 loadbin build/bin/ram_1.bin 0x10000bc8
loadbin build/bin/ram_2.bin 0x10006000 loadbin build/bin/ram_2.bin 0x10006000
r r
w4 0x40000210,0x20011113 w4 0x40000210,0x20011113

View file

@ -4,7 +4,7 @@ r1
trst1 trst1
r r
h h
loadbin build/bin/ram_1.r.bin 0x10000bc8 loadbin build/bin/ram_1.bin 0x10000bc8
loadbin build/bin/ram_2.bin 0x10006000 loadbin build/bin/ram_2.bin 0x10006000
r r
w4 0x40000210,0x20011113 w4 0x40000210,0x20011113

View file

@ -10,7 +10,7 @@ import os
import struct import struct
import sys import sys
__version__ = "17.01.18" __version__ = "20.01.18"
PYTHON2 = sys.version_info[0] < 3 # True if on pre-Python 3 PYTHON2 = sys.version_info[0] < 3 # True if on pre-Python 3
@ -255,7 +255,7 @@ class xFirmwareImage(object):
print('Error: Segment %s is big!' % self.name) print('Error: Segment %s is big!' % self.name)
f.write(self.data) f.write(self.data)
while i < gap: while i < gap:
f.write('\0') f.write('\xff')
i += 1 i += 1
else: else:
f.write(self.data) f.write(self.data)
@ -310,7 +310,6 @@ def elf2image(args):
try: try:
with open(fn, "wb") as f: with open(fn, "wb") as f:
for s in image: for s in image:
if s.hm & HM_IS_SRAM:
s.save_sram(f, fn) s.save_sram(f, fn)
f.close() f.close()

View file

@ -6,8 +6,8 @@ SDK_PATH = USDK/
#GCC_PATH = d:/MCU/GNU_Tools_ARM_Embedded/6.2017-q1-update/bin/# + or set in PATH #GCC_PATH = d:/MCU/GNU_Tools_ARM_Embedded/6.2017-q1-update/bin/# + or set in PATH
#OPENOCD_PATH = D:/MCU/OpenOCD/bin/# + or set in PATH #OPENOCD_PATH = D:/MCU/OpenOCD/bin/# + or set in PATH
TOOLS_PATH ?= $(SDK_PATH)component/soc/realtek/8195a/misc/iar_utility/common/tools/ TOOLS_PATH ?= $(SDK_PATH)component/soc/realtek/8195a/misc/iar_utility/common/tools/
#FLASHER_TYPE = Jlink FLASHER_TYPE = Jlink
FLASHER_TYPE = cmsis-dap #FLASHER_TYPE = cmsis-dap
FLASHER_SPEED = 3500 FLASHER_SPEED = 3500
FLASHER_PATH = flasher/ FLASHER_PATH = flasher/
JLINK_PATH ?= D:/MCU/SEGGER/JLink_V612i/ JLINK_PATH ?= D:/MCU/SEGGER/JLink_V612i/