Skip to content

Commit e757040

Browse files
tung7970adbridge
authored andcommitted
rtl8195am - fix ARMCC SRAM + SDRAM porting
Signed-off-by: Tony Wu <[email protected]>
1 parent 2b06d0e commit e757040

File tree

5 files changed

+79
-95
lines changed

5 files changed

+79
-95
lines changed
Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,57 @@
1-
; *************************************************************
2-
; *** Scatter-Loading Description File for RTL8195A ***
3-
; *************************************************************
4-
LR_ROM 0x00000000 0x00030000{
5-
_ROM_CODE 0x00000000 0x00030000 {
6-
;*.o (RESET, +First)
7-
;*(InRoot$$Sections)
8-
}
9-
}
1+
; Realtek Semiconductor Corp.
2+
;
3+
; RTL8195A ARMCC Scatter File
4+
;
5+
; MEMORY
6+
; {
7+
; SROM (rx) : ORIGIN = 0x10000000, LENGTH = 0x00007000
8+
; SRAM (rwx) : ORIGIN = 0x10007000, LENGTH = 0x00070000 - 0x00007000
9+
; TCM (rwx) : ORIGIN = 0x1FFF0000, LENGTH = 0x00010000
10+
; DRAM (rwx) : ORIGIN = 0x30000000, LENGTH = 2M
11+
; }
1012

11-
LR_RAM 0x10006000 0x6FFFF {
12-
;LR_RAM 0x10000000 0x6FFFF {
13-
;ROM_BSS 0x10000000 0x0005FFF{
14-
;rtl_console.o(.mon.ram.bss*)
15-
;}
16-
17-
.image2.table 0x10006000 FIXED {
18-
rtl8195a_init.o(.image2.ram.data*)
19-
rtl8195a_init.o(.image2.validate.rodata*)
20-
}
21-
22-
.text +0 FIXED{
23-
rtl8195a_init.o(.infra.ram.start)
24-
;*.o(.mon.ram.text*)
25-
;*.o(.hal.flash.text*)
26-
;*.o(.hal.sdrc.text*)
27-
;*.o(.hal.gpio.text*)
28-
;*.o(.text*)
29-
;*.o(.rodata*)
30-
.ANY (+RO)
13+
LR_IRAM 0x10007000 (0x70000 - 0x7000) {
14+
15+
IMAGE2_TABLE 0x10007000 FIXED {
16+
*rtl8195a_init.o(.image2.ram.data*, +FIRST)
17+
*rtl8195a_init.o(.image2.validate.rodata*)
3118
}
3219

33-
.data +0 FIXED{
34-
.ANY (+RW)
20+
ER_IRAM +0 FIXED {
21+
*rtl8195a_crypto.o(.text*, .rodata*)
22+
*mbedtls*.o(.text*, .rodata*)
23+
libc.a: (.text*, .rodata*)
3524
}
3625

3726
RW_IRAM1 +0 UNINIT FIXED {
38-
.ANY (+ZI)
27+
*rtl8195a_crypto.o(.data*)
28+
*mbedtls*.o(.data*)
29+
libc.a: (.data*)
30+
*(.sdram.data*)
3931
}
4032

41-
ARM_LIB_STACK (0x10070000 - 0x1000) EMPTY 0x1000 {
33+
RW_IRAM2 +0 UNINIT FIXED {
34+
*rtl8195a_crypto.o(.bss*, COMMON)
35+
*mbedtls*.o(.bss*, COMMON)
36+
libc.a: (.bss*, COMMON)
37+
*(.bss.thread_stack_main)
4238
}
4339

44-
TCM_OVERLAY 0x1FFF0000 0x10000{
45-
lwip_mem.o(.bss*)
46-
lwip_memp.o(.bss*)
47-
*.o(.tcm.heap*)
40+
ARM_LIB_STACK (0x10070000 - 0x1000) EMPTY 0x1000 {
4841
}
4942
}
5043

51-
LR_DRAM 0x30000000 0x1FFFFF{
52-
_DRAM_CODE 0x30000000 0x1FFFFF{
53-
*.o(.text*)
54-
}
44+
LR_DRAM 0x30000000 0x200000 {
45+
46+
ER_DRAM +0 FIXED {
47+
.ANY (+RO)
48+
}
49+
50+
RW_DRAM1 +0 UNINIT FIXED {
51+
.ANY (+RW)
52+
}
53+
54+
RW_DRAM2 +0 UNINIT FIXED {
55+
.ANY (+ZI)
56+
}
5557
}
Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,24 @@
1-
/******************************************************************************
2-
* Copyright (c) 2013-2016 Realtek Semiconductor Corp.
1+
/* mbed Microcontroller Library - stackheap
2+
* Copyright (C) 2009-2011 ARM Limited. All rights reserved.
33
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*
16-
******************************************************************************
17-
* mbed Microcontroller Library - stackheap
18-
* Setup a fixed single stack/heap memory model,
19-
* between the top of the RW/ZI region and the stackpointer
20-
******************************************************************************/
21-
4+
* Setup a fixed single stack/heap memory model,
5+
* between the top of the RW/ZI region and the stackpointer
6+
*/
227
#ifdef __cplusplus
238
extern "C" {
24-
#endif
9+
#endif
2510

2611
#include <rt_misc.h>
2712
#include <stdint.h>
2813

29-
extern char Image$$RW_IRAM1$$ZI$$Limit[];
14+
extern char Image$$RW_IRAM2$$ZI$$Limit[];
15+
3016
extern __value_in_regs struct __initial_stackheap __user_setup_stackheap(uint32_t R0, uint32_t R1, uint32_t R2, uint32_t R3) {
31-
uint32_t zi_limit = (uint32_t)Image$$RW_IRAM1$$ZI$$Limit;
17+
uint32_t zi_limit = (uint32_t)Image$$RW_IRAM2$$ZI$$Limit;
3218
uint32_t sp_limit = __current_sp();
3319

3420
zi_limit = (zi_limit + 7) & ~0x7; // ensure zi_limit is 8-byte aligned
3521

36-
//push down stack pointer to recycle some of the stack space that are not use in future
37-
__asm volatile
38-
(
39-
"MRS IP, MSP \n"
40-
"ADD IP, #64 \n"
41-
"BIC IP, IP, #7 \n"
42-
"MSR MSP, IP \n"
43-
);
4422
struct __initial_stackheap r;
4523
r.heap_base = zi_limit;
4624
r.heap_limit = sp_limit;
@@ -49,4 +27,4 @@ extern __value_in_regs struct __initial_stackheap __user_setup_stackheap(uint32_
4927

5028
#ifdef __cplusplus
5129
}
52-
#endif
30+
#endif

targets/TARGET_Realtek/TARGET_AMEBA/TARGET_RTL8195A/device/rtl8195a_init.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,14 @@
2828
(defined (__ARMCC_VERSION) && __ARMCC_VERSION >= 6010050)
2929

3030
extern uint32_t Image$$ARM_LIB_STACK$$ZI$$Limit;
31-
extern uint8_t Image$$RW_IRAM1$$ZI$$Base[];
32-
extern uint8_t Image$$RW_IRAM1$$ZI$$Limit[];
33-
#define __bss_start__ Image$$RW_IRAM1$$ZI$$Base
34-
#define __bss_end__ Image$$RW_IRAM1$$ZI$$Limit
31+
extern uint8_t Image$$RW_IRAM2$$ZI$$Base[];
32+
extern uint8_t Image$$RW_IRAM2$$ZI$$Limit[];
33+
extern uint8_t Image$$RW_DRAM2$$ZI$$Base[];
34+
extern uint8_t Image$$RW_DRAM2$$ZI$$Limit[];
35+
#define __bss_sram_start__ Image$$RW_IRAM2$$ZI$$Base
36+
#define __bss_sram_end__ Image$$RW_IRAM2$$ZI$$Limit
37+
#define __bss_dram_start__ Image$$RW_DRAM2$$ZI$$Base
38+
#define __bss_dram_end__ Image$$RW_DRAM2$$ZI$$Limit
3539

3640
#elif defined (__ICCARM__)
3741

@@ -181,11 +185,11 @@ void PLAT_Start(void)
181185
#endif
182186

183187
// Clear RAM BSS
184-
#if defined (__ICCARM__) || defined (__CC_ARM)
188+
#if defined (__ICCARM__)
185189
__memset((void *)__bss_start__, 0, __bss_end__ - __bss_start__);
186190
#else
187-
__memset((void *)__bss_sram1_start__, 0, __bss_sram1_end__ - __bss_sram1_start__);
188-
__memset((void *)__bss_sram2_start__, 0, __bss_sram2_end__ - __bss_sram2_start__);
191+
__memset((void *)__bss_sram_start__, 0, __bss_sram_end__ - __bss_sram_start__);
192+
__memset((void *)__bss_dram_start__, 0, __bss_dram_end__ - __bss_dram_start__);
189193
#endif
190194

191195
#if defined (__CC_ARM)

targets/TARGET_Realtek/mbed_rtx.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,14 @@
2121
#include "rtl8195a.h"
2222

2323
#if defined(__CC_ARM)
24-
#ifdef CONFIG_RTL8195A
25-
#define INITIAL_SP 0x10070000
26-
#define ISR_STACK_START 0x1FFFEFFC
27-
#else
28-
#ERROR "NOT SUPPORT NOW"
29-
#endif
24+
extern uint32_t Image$$ARM_LIB_STACK$$ZI$$Base[];
25+
extern uint32_t Image$$ARM_LIB_STACK$$ZI$$Length[];
26+
#define ISR_STACK_START (unsigned char *)(Image$$ARM_LIB_STACK$$ZI$$Base)
27+
#define ISR_STACK_SIZE (uint32_t)(Image$$ARM_LIB_STACK$$ZI$$Length)
28+
#define INITIAL_SP (uint32_t)(Image$$ARM_LIB_STACK$$ZI$$Base)
3029
#elif defined(__GNUC__)
3130
extern uint32_t __StackTop[];
3231
extern uint32_t __StackLimit[];
33-
// extern uint32_t __end__[];
3432
extern uint32_t __HeapLimit[];
3533
#define INITIAL_SP (__StackTop)
3634
#endif
@@ -54,4 +52,3 @@
5452

5553
#endif
5654
#endif
57-

tools/targets/REALTEK_RTL8195AM.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import sys, array, struct, os, re, subprocess
88
import hashlib
9+
import shutil
910

1011
from tools.paths import TOOLS_BOOTLOADERS
1112
from datetime import datetime
@@ -59,6 +60,9 @@ def get_version_by_time():
5960
secs = int((datetime.now()-datetime(2016,11,1)).total_seconds())
6061
return RAM2_VER + secs
6162

63+
# ----------------------------
64+
# main function
65+
# ----------------------------
6266
def prepend(image, entry, segment, image_ram2, image_ota):
6367

6468
# parse input arguments
@@ -226,13 +230,6 @@ def parse_load_segment(toolchain, image_elf):
226230

227231
def write_load_segment(image_elf, image_bin, segment):
228232
file_elf = open(image_elf, "rb")
229-
#delete folder with same name when using ARMCC
230-
if os.path.isfile(image_bin):
231-
pass
232-
else:
233-
for i in os.listdir(image_bin):
234-
os.remove(os.path.join(image_bin, i))
235-
os.removedirs(image_bin)
236233
file_bin = open(image_bin, "wb")
237234
for (offset, addr, size) in segment:
238235
file_elf.seek(offset)
@@ -248,6 +245,12 @@ def write_load_segment(image_elf, image_bin, segment):
248245
# main function
249246
# ----------------------------
250247
def rtl8195a_elf2bin(t_self, image_elf, image_bin):
248+
# remove target binary file/path
249+
if os.path.isfile(image_bin):
250+
os.remove(image_bin)
251+
else:
252+
shutil.rmtree(image_bin)
253+
251254
segment = parse_load_segment(t_self.name, image_elf)
252255
write_load_segment(image_elf, image_bin, segment)
253256

0 commit comments

Comments
 (0)