Skip to content

Commit 2371fc2

Browse files
BernardXiongclaude
andcommitted
[bsp][k230] Clean up board definitions and add debug logging
board.h: Remove unused peripheral base address defines for blocks that are not currently supported (SRAM, GSDMA, DECOMP, ISP, VPU, GPU, VO, DSI, Audio, USB2, SDHC, BootROM, Security, DDRC, XIP Flash, etc.). This reduces clutter and keeps only actively used hardware definitions. board.c: Add DBG_TAG/DBG_LVL configuration to enable debug logging via the ulog framework. Replace Chinese comments with English descriptions for better upstream readability. Add LOG_I/LOG_D trace points in primary_cpu_entry() and rt_hw_board_init() to aid bring-up debugging. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent b017455 commit 2371fc2

2 files changed

Lines changed: 21 additions & 86 deletions

File tree

bsp/k230/board/board.c

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
#include <rtthread.h>
1313
#include <rtdevice.h>
1414

15+
#define DBG_TAG "board"
16+
#define DBG_LVL DBG_INFO
17+
#include <rtdbg.h>
18+
1519
#include "board.h"
1620
#include "tick.h"
1721

@@ -39,17 +43,14 @@ extern unsigned int __bss_end;
3943
#define RT_HW_PAGE_END ((void *)(RAM_END))
4044

4145
#ifdef RT_USING_SMART
42-
4346
rt_region_t init_page_region = {(rt_size_t)RT_HW_PAGE_START, (rt_size_t)RT_HW_PAGE_END};
4447

4548
extern size_t MMUTable[];
4649

4750
struct mem_desc platform_mem_desc[] = {
4851
{KERNEL_VADDR_START, (rt_size_t)(KERNEL_VADDR_START + CONFIG_MEM_MMZ_BASE + CONFIG_MEM_MMZ_SIZE - 1), (rt_size_t)ARCH_MAP_FAILED, NORMAL_MEM},
4952
};
50-
5153
#define NUM_MEM_DESC (sizeof(platform_mem_desc) / sizeof(platform_mem_desc[0]))
52-
5354
#endif /* RT_USING_SMART */
5455

5556
#ifndef ARCH_REMAP_KERNEL
@@ -76,34 +77,42 @@ static void __rt_assert_handler(const char *ex_string, const char *func, rt_size
7677
asm volatile("ebreak":::"memory");
7778
}
7879

79-
//BSP的C入口
80+
/* C entry point, this gets called on primary CPU after stack setup. */
8081
void primary_cpu_entry(void)
8182
{
82-
//关中断
83+
LOG_I("primary_cpu_entry");
84+
8385
rt_hw_interrupt_disable();
86+
87+
#ifdef RT_DEBUGING_ASSERT
8488
rt_assert_set_hook(__rt_assert_handler);
85-
//启动RT-Thread Smart内核
89+
#endif
90+
8691
entry();
8792
}
8893

8994
#define IOREMAP_SIZE (1ul << 30)
9095

91-
//这个初始化程序由内核主动调用,此时调度器还未启动,因此在此不能使用依赖线程上下文的函数
96+
/*
97+
* This function is called by the kernel during initialization. At this point,
98+
* the scheduler has not started, so functions that depend on thread context
99+
* cannot be used.
100+
*/
92101
void rt_hw_board_init(void)
93102
{
103+
LOG_D("board init: heap %p-%p, page %p-%p",
104+
RT_HW_HEAP_BEGIN, RT_HW_HEAP_END,
105+
RT_HW_PAGE_START, RT_HW_PAGE_END);
106+
94107
#ifdef RT_USING_SMART
95-
/* init data structure */
96108
rt_hw_mmu_map_init(&rt_kernel_space, (void *)(IOREMAP_VEND - IOREMAP_SIZE), IOREMAP_SIZE, (rt_size_t *)MMUTable, PV_OFFSET);
97-
98-
/* init page allocator */
99109
rt_page_init(init_page_region);
100110

101-
/* setup region, and enable MMU */
111+
LOG_D("mmu setup: %d regions", NUM_MEM_DESC);
102112
rt_hw_mmu_setup(&rt_kernel_space, platform_mem_desc, NUM_MEM_DESC);
103113
#endif
104114

105115
#ifdef RT_USING_HEAP
106-
/* initialize memory system */
107116
rt_system_heap_init(RT_HW_HEAP_BEGIN, RT_HW_HEAP_END);
108117
#endif
109118
/* initalize interrupt */

bsp/k230/board/board.h

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
*
2121
* See K230 Technical Reference Manual, chapter 1.5 Address Space mapping
2222
*/
23-
#define SRAM_BASE_ADDR (0x80200000UL)
24-
#define SRAM_IO_SIZE (0x00200000UL)
25-
2623
#define KPU_BASE_ADDR (0x80400000UL)
2724
#define KPU_IO_SIZE (0x00000800UL)
2825

@@ -32,43 +29,9 @@
3229
#define AI2D_BASE_ADDR (0x80400C00UL)
3330
#define AI2D_IO_SIZE (0x00000400UL)
3431

35-
#define GSDMA_BASE_ADDR (0x80800000UL)
36-
#define GSDMA_IO_SIZE (0x00004000UL)
37-
3832
#define DMA_BASE_ADDR (0x80804000UL)
3933
#define DMA_IO_SIZE (0x00004000UL)
4034

41-
#define DECOMP_BASE_ADDR (0x80808000UL)
42-
#define DECOMP_IO_SIZE (0x00004000UL)
43-
44-
#define NON_AI2D_BASE_ADDR (0x8080C000UL)
45-
#define NON_AI2D_IO_SIZE (0x00004000UL)
46-
47-
#define ISP_BASE_ADDR (0x90000000UL)
48-
#define ISP_IO_SIZE (0x00008000UL)
49-
50-
#define DEWARP_BASE_ADDR (0x90008000UL)
51-
#define DEWARP_IO_SIZE (0x00001000UL)
52-
53-
#define CSI_BASE_ADDR (0x90009000UL)
54-
#define CSI_IO_SIZE (0x00002000UL)
55-
56-
#define VPU_BASE_ADDR (0x90400000UL)
57-
#define VPU_IO_SIZE (0x00010000UL)
58-
59-
/*2.5D*/
60-
#define TAAH_GPU_BASE_ADDR (0x90800000UL)
61-
#define TAAH_GPU_IO_SIZE (0x00040000UL)
62-
63-
#define VO_BASE_ADDR (0x90840000UL)
64-
#define VO_IO_SIZE (0x00010000UL)
65-
66-
#define DSI_BASE_ADDR (0x90850000UL)
67-
#define DSI_IO_SIZE (0x00001000UL)
68-
69-
#define GPU_ENGINE_BASE_ADDR (0x90A00000UL)
70-
#define GPU_ENGINE_IO_SIZE (0x00000800UL)
71-
7235
#define PMU_BASE_ADDR (0x91000000UL)
7336
#define PMU_IO_SIZE (0x00000C00UL)
7437

@@ -105,18 +68,6 @@
10568
#define TS_BASE_ADDR (0x91107000UL)
10669
#define TS_IO_SIZE (0x00000800UL)
10770

108-
#define HDI_BASE_ADDR (0x91107800UL)
109-
#define HDI_IO_SIZE (0x00000800UL)
110-
111-
#define STC_BASE_ADDR (0x91108000UL)
112-
#define STC_IO_SIZE (0x00001000UL)
113-
114-
#define BOOTROM_BASE_ADDR (0x91200000UL)
115-
#define BOOTROM_IO_SIZE (0x00010000UL)
116-
117-
#define SECURITY_BASE_ADDR (0x91210000UL)
118-
#define SECURITY_IO_SIZE (0x00008000UL)
119-
12071
#define UART0_BASE_ADDR (0x91400000UL)
12172
#define UART0_IO_SIZE (0x00001000UL)
12273

@@ -159,35 +110,10 @@
159110
#define ADC_BASE_ADDR (0x9140D000UL)
160111
#define ADC_IO_SIZE (0x00001000UL)
161112

162-
#define CODEC_BASE_ADDR (0x9140E000UL)
163-
#define CODEC_IO_SIZE (0x00001000UL)
164-
165-
#define AUDIO_BASE_ADDR (0x9140F000UL)
166-
#define AUDIO_IO_SIZE (0x00001000UL)
167-
168-
#define USB2_BASE_ADDR (0x91500000UL)
169-
#define USB2_IO_SIZE (0x00080000UL)
170-
171-
#define SD_HC_BASE_ADDR (0x91580000UL)
172-
#define SD_HC_IO_SIZE (0x00002000UL)
173-
174113
#define SPI_QOPI_BASE_ADDR (0x91582000UL)
175114
#define SPI_QOPI_IO_SIZE (0x00002000UL)
176115

177116
#define SPI_OPI_BASE_ADDR (0x91584000UL)
178117
#define SPI_OPI_IO_SIZE (0x00001000UL)
179118

180-
#define HI_SYS_CONFIG_BASE_ADDR (0x91585000UL)
181-
#define HI_SYS_CONFIG_IO_SIZE (0x00000400UL)
182-
183-
#define DDRC_CONF_BASE_ADDR (0x98000000UL)
184-
#define DDRC_CONF_IO_SIZE (0x02000000UL)
185-
186-
#define SPI_XIP_FLASH_BASE_ADDR (0xC0000000UL)
187-
#define SPI_XIP_FLASH_IO_SIZE (0x08000000UL)
188-
189-
#define IO_SPACE_BASE_ADDR (KPU_BASE_ADDR)
190-
191-
#define TIMER_CLK_FREQ (27000000)
192-
193119
#endif // BOARD_H__

0 commit comments

Comments
 (0)