mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-10-07 00:59:00 +08:00
[bsp/xuantie] 添加E901BSP #10836
This commit is contained in:
@@ -482,6 +482,7 @@
|
||||
"RTT_BSP": "xuantie",
|
||||
"RTT_TOOL_CHAIN": "sourcery-Xuantie-900-gcc-elf-newlib",
|
||||
"SUB_RTT_BSP": [
|
||||
"xuantie/smartl/e901",
|
||||
"xuantie/smartl/e902",
|
||||
"xuantie/smartl/e906",
|
||||
"xuantie/smartl/e907",
|
||||
|
||||
@@ -177,10 +177,10 @@ jobs:
|
||||
- name: Install Xuantie-900-gcc-elf-newlib Tools
|
||||
if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-Xuantie-900-gcc-elf-newlib' && success() }}
|
||||
run: |
|
||||
wget -q https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1744884010580/Xuantie-900-gcc-elf-newlib-x86_64-V3.0.2-20250410.tar.gz
|
||||
sudo tar -zxvf Xuantie-900-gcc-elf-newlib-x86_64-V3.0.2-20250410.tar.gz -C /opt
|
||||
/opt/Xuantie-900-gcc-elf-newlib-x86_64-V3.0.2/bin/riscv64-unknown-elf-gcc --version
|
||||
echo "RTT_EXEC_PATH=/opt/Xuantie-900-gcc-elf-newlib-x86_64-V3.0.2/bin" >> $GITHUB_ENV
|
||||
wget -q https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1751370399722/Xuantie-900-gcc-elf-newlib-x86_64-V3.2.0-20250627.tar.gz
|
||||
sudo tar -zxvf Xuantie-900-gcc-elf-newlib-x86_64-V3.2.0-20250627.tar.gz -C /opt
|
||||
/opt/Xuantie-900-gcc-elf-newlib-x86_64-V3.2.0/bin/riscv64-unknown-elf-gcc --version
|
||||
echo "RTT_EXEC_PATH=/opt/Xuantie-900-gcc-elf-newlib-x86_64-V3.2.0/bin" >> $GITHUB_ENV
|
||||
|
||||
- name: Install Xuantie-900-gcc-linux-musl Tools
|
||||
if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-Xuantie-900-gcc-linux-musl' && success() }}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+273
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,13 @@
|
||||
from building import *
|
||||
import os
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
CPPPATH = [cwd]
|
||||
src = ['startup.S']
|
||||
src += ['system.c']
|
||||
src += ['trap_c.c']
|
||||
src += ['vectors.S']
|
||||
|
||||
group = DefineGroup('sys', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
#include <soc.h>
|
||||
#include <csi_core.h>
|
||||
#include <drv/irq.h>
|
||||
#include <drv/dma.h>
|
||||
#include <drv/tick.h>
|
||||
#include <drv/etb.h>
|
||||
#include <drv/spiflash.h>
|
||||
#include "riscv_csr.h"
|
||||
|
||||
#if (defined(CONFIG_KERNEL_RHINO) || defined(CONFIG_KERNEL_FREERTOS) || defined(CONFIG_KERNEL_RTTHREAD)) && defined(CONFIG_KERNEL_NONE)
|
||||
#error "Please check the current system is baremetal or not!!!"
|
||||
#endif
|
||||
|
||||
extern void section_data_copy(void);
|
||||
extern void section_ram_code_copy(void);
|
||||
extern void section_bss_clear(void);
|
||||
|
||||
static void cache_init(void)
|
||||
{
|
||||
csi_icache_enable();
|
||||
}
|
||||
|
||||
static void section_init(void)
|
||||
{
|
||||
#if CONFIG_XIP
|
||||
section_data_copy();
|
||||
section_ram_code_copy();
|
||||
#endif
|
||||
|
||||
section_bss_clear();
|
||||
}
|
||||
|
||||
static void clic_init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* get interrupt level from info */
|
||||
CLIC->CLICCFG = (((CLIC->CLICINFO & CLIC_INFO_CLICINTCTLBITS_Msk) >> CLIC_INFO_CLICINTCTLBITS_Pos) << CLIC_CLICCFG_NLBIT_Pos);
|
||||
|
||||
for (i = 0; i < 64; i++)
|
||||
{
|
||||
CLIC->CLICINT[i].IP = 0;
|
||||
#ifndef CONFIG_SUPPORT_NON_VECTOR_IRQ
|
||||
CLIC->CLICINT[i].ATTR = 1; /* use vector interrupt */
|
||||
#else
|
||||
CLIC->CLICINT[i].ATTR = 0; /* use non-vector interrupt */
|
||||
#endif
|
||||
csi_vic_set_prio(i, 3);
|
||||
}
|
||||
/* tspend use vector&positive interrupt */
|
||||
CLIC->CLICINT[Machine_Software_IRQn].ATTR = 0x3;
|
||||
csi_vic_set_prio(Machine_Software_IRQn, 1);
|
||||
csi_irq_enable(Machine_Software_IRQn);
|
||||
}
|
||||
|
||||
static void interrupt_init(void)
|
||||
{
|
||||
clic_init();
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
__enable_excp_irq();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief initialize the system
|
||||
* Initialize the psr and vbr.
|
||||
* @param None
|
||||
* @return None
|
||||
*/
|
||||
void SystemInit(void)
|
||||
{
|
||||
extern int cpu_features_init(void);
|
||||
cpu_features_init();
|
||||
|
||||
/* enable XUANTIEISAEE & COPINSTEE */
|
||||
uint32_t status = __get_MXSTATUS();
|
||||
status |= (1 << 22) | (1 << 24);
|
||||
__set_MXSTATUS(status);
|
||||
|
||||
cache_init();
|
||||
section_init();
|
||||
interrupt_init();
|
||||
soc_set_sys_freq(20000000);
|
||||
csi_tick_init();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <csi_core.h>
|
||||
#if defined(AOS_COMP_DEBUG) && (AOS_COMP_DEBUG > 0)
|
||||
#include <debug/dbg.h>
|
||||
#else
|
||||
#define printk printf
|
||||
#endif
|
||||
|
||||
void (*trap_c_callback)(void);
|
||||
|
||||
void trap_c(uintptr_t *regs)
|
||||
{
|
||||
int i;
|
||||
unsigned long vec = 0;
|
||||
|
||||
vec = __get_MCAUSE();
|
||||
|
||||
printk("CPU Exception(mcause);: NO.0x%lx", vec);
|
||||
printk("\n");
|
||||
|
||||
for (i = 0; i < 15; i++)
|
||||
{
|
||||
printk("x%d: %p\t", i + 1, (void *)regs[i]);
|
||||
|
||||
if ((i % 4) == 3)
|
||||
{
|
||||
printk("\n");
|
||||
}
|
||||
}
|
||||
|
||||
printk("\n");
|
||||
printk("mepc : %p\n", (void *)regs[15]);
|
||||
printk("mstatus: %p\n", (void *)regs[16]);
|
||||
|
||||
if (trap_c_callback)
|
||||
{
|
||||
trap_c_callback();
|
||||
}
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void exceptionHandler(void *context)
|
||||
{
|
||||
trap_c((uintptr_t *)context);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -9,6 +9,7 @@ src += ['sys_clk.c']
|
||||
src += ['tick.c']
|
||||
src += ['target_get.c']
|
||||
src += ['devices.c']
|
||||
src += ['feature.c']
|
||||
|
||||
group = DefineGroup('sys', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -704,15 +704,19 @@ __STATIC_INLINE uint8_t __get_PMPxCFG(unsigned long idx)
|
||||
{
|
||||
unsigned long pmpcfgx = 0;
|
||||
|
||||
if (idx < 4) {
|
||||
if (idx < 4)
|
||||
{
|
||||
pmpcfgx = __get_PMPCFG0();
|
||||
} else if (idx >= 4 && idx < 8) {
|
||||
} else if (idx >= 4 && idx < 8)
|
||||
{
|
||||
idx -= 4;
|
||||
pmpcfgx = __get_PMPCFG1();
|
||||
} else if (idx >= 8 && idx < 12) {
|
||||
} else if (idx >= 8 && idx < 12)
|
||||
{
|
||||
idx -= 8;
|
||||
pmpcfgx = __get_PMPCFG2();
|
||||
} else if (idx >= 12 && idx < 16) {
|
||||
} else if (idx >= 12 && idx < 16)
|
||||
{
|
||||
idx -= 12;
|
||||
pmpcfgx = __get_PMPCFG3();
|
||||
} else {
|
||||
@@ -757,21 +761,25 @@ __STATIC_INLINE void __set_PMPxCFG(unsigned long idx, uint8_t pmpxcfg)
|
||||
{
|
||||
unsigned long pmpcfgx = 0;
|
||||
|
||||
if (idx < 4) {
|
||||
if (idx < 4)
|
||||
{
|
||||
pmpcfgx = __get_PMPCFG0();
|
||||
pmpcfgx = (pmpcfgx & ~(0xFF << (idx << 3))) | ((unsigned long)(pmpxcfg) << (idx << 3));
|
||||
__set_PMPCFG0(pmpcfgx);
|
||||
} else if (idx >= 4 && idx < 8) {
|
||||
} else if (idx >= 4 && idx < 8)
|
||||
{
|
||||
idx -= 4;
|
||||
pmpcfgx = __get_PMPCFG1();
|
||||
pmpcfgx = (pmpcfgx & ~(0xFF << (idx << 3))) | ((unsigned long)(pmpxcfg) << (idx << 3));
|
||||
__set_PMPCFG1(pmpcfgx);
|
||||
} else if (idx >= 8 && idx < 12) {
|
||||
} else if (idx >= 8 && idx < 12)
|
||||
{
|
||||
idx -= 8;
|
||||
pmpcfgx = __get_PMPCFG2();
|
||||
pmpcfgx = (pmpcfgx & ~(0xFF << (idx << 3))) | ((unsigned long)(pmpxcfg) << (idx << 3));
|
||||
__set_PMPCFG2(pmpcfgx);
|
||||
} else if (idx >= 12 && idx < 16) {
|
||||
} else if (idx >= 12 && idx < 16)
|
||||
{
|
||||
idx -= 12;
|
||||
pmpcfgx = __get_PMPCFG3();
|
||||
pmpcfgx = (pmpcfgx & ~(0xFF << (idx << 3))) | ((unsigned long)(pmpxcfg) << (idx << 3));
|
||||
@@ -922,7 +930,8 @@ __ALWAYS_STATIC_INLINE unsigned long __get_PMPADDR15(void)
|
||||
*/
|
||||
__STATIC_INLINE unsigned long __get_PMPADDRx(unsigned long idx)
|
||||
{
|
||||
switch (idx) {
|
||||
switch (idx)
|
||||
{
|
||||
case 0:
|
||||
return __get_PMPADDR0();
|
||||
|
||||
@@ -1069,7 +1078,8 @@ __ALWAYS_STATIC_INLINE void __set_PMPADDR15(unsigned long pmpaddr)
|
||||
*/
|
||||
__STATIC_INLINE void __set_PMPADDRx(unsigned long idx, unsigned long pmpaddr)
|
||||
{
|
||||
switch (idx) {
|
||||
switch (idx)
|
||||
{
|
||||
case 0:
|
||||
__set_PMPADDR0(pmpaddr);
|
||||
break;
|
||||
@@ -1627,7 +1637,8 @@ __ALWAYS_STATIC_INLINE uint32_t __RBIT(uint32_t value)
|
||||
|
||||
result = value; /* r will be reversed bits of v; first get LSB of v */
|
||||
|
||||
for (value >>= 1U; value; value >>= 1U) {
|
||||
for (value >>= 1U; value; value >>= 1U)
|
||||
{
|
||||
result <<= 1U;
|
||||
result |= value & 1U;
|
||||
s--;
|
||||
@@ -1659,26 +1670,30 @@ __ALWAYS_STATIC_INLINE int32_t __SSAT(int32_t x, uint32_t y)
|
||||
|
||||
posMax = 1;
|
||||
|
||||
for (i = 0; i < (y - 1); i++) {
|
||||
for (i = 0; i < (y - 1); i++)
|
||||
{
|
||||
posMax = posMax * 2;
|
||||
}
|
||||
|
||||
if (x > 0) {
|
||||
if (x > 0)
|
||||
{
|
||||
posMax = (posMax - 1);
|
||||
|
||||
if (x > posMax) {
|
||||
if (x > posMax)
|
||||
{
|
||||
x = posMax;
|
||||
}
|
||||
|
||||
// x &= (posMax * 2 + 1);
|
||||
/* x &= (posMax * 2 + 1); */
|
||||
} else {
|
||||
negMin = -posMax;
|
||||
|
||||
if (x < negMin) {
|
||||
if (x < negMin)
|
||||
{
|
||||
x = negMin;
|
||||
}
|
||||
|
||||
// x &= (posMax * 2 - 1);
|
||||
/* x &= (posMax * 2 - 1); */
|
||||
}
|
||||
|
||||
return (x);
|
||||
@@ -1695,7 +1710,8 @@ __ALWAYS_STATIC_INLINE uint32_t __USAT(uint32_t value, uint32_t sat)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
if ((((0xFFFFFFFF >> sat) << sat) & value) != 0) {
|
||||
if ((((0xFFFFFFFF >> sat) << sat) & value) != 0)
|
||||
{
|
||||
result = 0xFFFFFFFF >> (32 - sat);
|
||||
} else {
|
||||
result = value;
|
||||
@@ -1715,9 +1731,11 @@ __ALWAYS_STATIC_INLINE uint32_t __IUSAT(uint32_t value, uint32_t sat)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
if (value & 0x80000000) { /* only overflow set bit-31 */
|
||||
if (value & 0x80000000)
|
||||
{ /* only overflow set bit-31 */
|
||||
result = 0;
|
||||
} else if ((((0xFFFFFFFF >> sat) << sat) & value) != 0) {
|
||||
} else if ((((0xFFFFFFFF >> sat) << sat) & value) != 0)
|
||||
{
|
||||
result = 0xFFFFFFFF >> (32 - sat);
|
||||
} else {
|
||||
result = value;
|
||||
@@ -2943,14 +2961,17 @@ __ALWAYS_STATIC_INLINE int32_t __QADD(int32_t x, int32_t y)
|
||||
{
|
||||
int32_t result;
|
||||
|
||||
if (y >= 0) {
|
||||
if ((int32_t)((uint32_t)x + (uint32_t)y) >= x) {
|
||||
if (y >= 0)
|
||||
{
|
||||
if ((int32_t)((uint32_t)x + (uint32_t)y) >= x)
|
||||
{
|
||||
result = x + y;
|
||||
} else {
|
||||
result = 0x7FFFFFFF;
|
||||
}
|
||||
} else {
|
||||
if ((int32_t)((uint32_t)x + (uint32_t)y) < x) {
|
||||
if ((int32_t)((uint32_t)x + (uint32_t)y) < x)
|
||||
{
|
||||
result = x + y;
|
||||
} else {
|
||||
result = 0x80000000;
|
||||
@@ -2976,9 +2997,11 @@ __ALWAYS_STATIC_INLINE int32_t __QSUB(int32_t x, int32_t y)
|
||||
|
||||
tmp = (long)x - (long)y;
|
||||
|
||||
if (tmp > 0x7fffffff) {
|
||||
if (tmp > 0x7fffffff)
|
||||
{
|
||||
tmp = 0x7fffffff;
|
||||
} else if (tmp < (-2147483647 - 1)) {
|
||||
} else if (tmp < (-2147483647 - 1))
|
||||
{
|
||||
tmp = -2147483647 - 1;
|
||||
}
|
||||
|
||||
@@ -3284,3 +3307,4 @@ __ALWAYS_STATIC_INLINE uint32_t __UXTB16(uint32_t x)
|
||||
#endif
|
||||
|
||||
#endif /* _CSI_RV32_GCC_H_ */
|
||||
|
||||
|
||||
@@ -1589,7 +1589,8 @@ __ALWAYS_STATIC_INLINE uint32_t __RBIT(uint32_t value)
|
||||
|
||||
result = value; /* r will be reversed bits of v; first get LSB of v */
|
||||
|
||||
for (value >>= 1U; value; value >>= 1U) {
|
||||
for (value >>= 1U; value; value >>= 1U)
|
||||
{
|
||||
result <<= 1U;
|
||||
result |= value & 1U;
|
||||
s--;
|
||||
@@ -1621,26 +1622,30 @@ __ALWAYS_STATIC_INLINE int32_t __SSAT(int32_t x, uint32_t y)
|
||||
|
||||
posMax = 1;
|
||||
|
||||
for (i = 0; i < (y - 1); i++) {
|
||||
for (i = 0; i < (y - 1); i++)
|
||||
{
|
||||
posMax = posMax * 2;
|
||||
}
|
||||
|
||||
if (x > 0) {
|
||||
if (x > 0)
|
||||
{
|
||||
posMax = (posMax - 1);
|
||||
|
||||
if (x > posMax) {
|
||||
if (x > posMax)
|
||||
{
|
||||
x = posMax;
|
||||
}
|
||||
|
||||
// x &= (posMax * 2 + 1);
|
||||
/* x &= (posMax * 2 + 1); */
|
||||
} else {
|
||||
negMin = -posMax;
|
||||
|
||||
if (x < negMin) {
|
||||
if (x < negMin)
|
||||
{
|
||||
x = negMin;
|
||||
}
|
||||
|
||||
// x &= (posMax * 2 - 1);
|
||||
/* x &= (posMax * 2 - 1); */
|
||||
}
|
||||
|
||||
return (x);
|
||||
@@ -1657,7 +1662,8 @@ __ALWAYS_STATIC_INLINE uint32_t __USAT(uint32_t value, uint32_t sat)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
if ((((0xFFFFFFFF >> sat) << sat) & value) != 0) {
|
||||
if ((((0xFFFFFFFF >> sat) << sat) & value) != 0)
|
||||
{
|
||||
result = 0xFFFFFFFF >> (32 - sat);
|
||||
} else {
|
||||
result = value;
|
||||
@@ -1677,9 +1683,11 @@ __ALWAYS_STATIC_INLINE uint32_t __IUSAT(uint32_t value, uint32_t sat)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
if (value & 0x80000000) { /* only overflow set bit-31 */
|
||||
if (value & 0x80000000)
|
||||
{ /* only overflow set bit-31 */
|
||||
result = 0;
|
||||
} else if ((((0xFFFFFFFF >> sat) << sat) & value) != 0) {
|
||||
} else if ((((0xFFFFFFFF >> sat) << sat) & value) != 0)
|
||||
{
|
||||
result = 0xFFFFFFFF >> (32 - sat);
|
||||
} else {
|
||||
result = value;
|
||||
@@ -1729,7 +1737,7 @@ __ALWAYS_STATIC_INLINE uint32_t __RRX(uint32_t op1)
|
||||
__ALWAYS_STATIC_INLINE uint8_t __LDRBT(volatile uint8_t *addr)
|
||||
{
|
||||
uint32_t result;
|
||||
//#warning "__LDRBT"
|
||||
/* #warning "__LDRBT" */
|
||||
__ASM volatile("ldb %0, (%1, 0)" : "=r"(result) : "r"(addr));
|
||||
return ((uint8_t) result); /* Add explicit type cast here */
|
||||
}
|
||||
@@ -1745,7 +1753,7 @@ __ALWAYS_STATIC_INLINE uint16_t __LDRHT(volatile uint16_t *addr)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
//#warning "__LDRHT"
|
||||
/* #warning "__LDRHT" */
|
||||
__ASM volatile("ldh %0, (%1, 0)" : "=r"(result) : "r"(addr));
|
||||
return ((uint16_t) result); /* Add explicit type cast here */
|
||||
}
|
||||
@@ -1761,7 +1769,7 @@ __ALWAYS_STATIC_INLINE uint32_t __LDRT(volatile uint32_t *addr)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
//#warning "__LDRT"
|
||||
/* #warning "__LDRT" */
|
||||
__ASM volatile("ldw %0, (%1, 0)" : "=r"(result) : "r"(addr));
|
||||
return (result);
|
||||
}
|
||||
@@ -1775,7 +1783,7 @@ __ALWAYS_STATIC_INLINE uint32_t __LDRT(volatile uint32_t *addr)
|
||||
*/
|
||||
__ALWAYS_STATIC_INLINE void __STRBT(uint8_t value, volatile uint8_t *addr)
|
||||
{
|
||||
//#warning "__STRBT"
|
||||
/* #warning "__STRBT" */
|
||||
__ASM volatile("stb %1, (%0, 0)" :: "r"(addr), "r"((uint32_t)value) : "memory");
|
||||
}
|
||||
|
||||
@@ -1788,7 +1796,7 @@ __ALWAYS_STATIC_INLINE void __STRBT(uint8_t value, volatile uint8_t *addr)
|
||||
*/
|
||||
__ALWAYS_STATIC_INLINE void __STRHT(uint16_t value, volatile uint16_t *addr)
|
||||
{
|
||||
//#warning "__STRHT"
|
||||
/* #warning "__STRHT" */
|
||||
__ASM volatile("sth %1, (%0, 0)" :: "r"(addr), "r"((uint32_t)value) : "memory");
|
||||
}
|
||||
|
||||
@@ -1801,7 +1809,7 @@ __ALWAYS_STATIC_INLINE void __STRHT(uint16_t value, volatile uint16_t *addr)
|
||||
*/
|
||||
__ALWAYS_STATIC_INLINE void __STRT(uint32_t value, volatile uint32_t *addr)
|
||||
{
|
||||
//#warning "__STRT"
|
||||
/* #warning "__STRT" */
|
||||
__ASM volatile("stw %1, (%0, 0)" :: "r"(addr), "r"(value) : "memory");
|
||||
}
|
||||
|
||||
@@ -1826,7 +1834,7 @@ __ALWAYS_STATIC_INLINE void __STRT(uint32_t value, volatile uint32_t *addr)
|
||||
*/
|
||||
__ALWAYS_STATIC_INLINE uint32_t __get_FPUType(void)
|
||||
{
|
||||
//FIXME:
|
||||
/* FIXME: */
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2951,14 +2959,17 @@ __ALWAYS_STATIC_INLINE int32_t __QADD(int32_t x, int32_t y)
|
||||
{
|
||||
int32_t result;
|
||||
|
||||
if (y >= 0) {
|
||||
if (x + y >= x) {
|
||||
if (y >= 0)
|
||||
{
|
||||
if (x + y >= x)
|
||||
{
|
||||
result = x + y;
|
||||
} else {
|
||||
result = 0x7FFFFFFF;
|
||||
}
|
||||
} else {
|
||||
if (x + y < x) {
|
||||
if (x + y < x)
|
||||
{
|
||||
result = x + y;
|
||||
} else {
|
||||
result = 0x80000000;
|
||||
@@ -2984,9 +2995,11 @@ __ALWAYS_STATIC_INLINE int32_t __QSUB(int32_t x, int32_t y)
|
||||
|
||||
tmp = (int64_t)x - (int64_t)y;
|
||||
|
||||
if (tmp > 0x7fffffff) {
|
||||
if (tmp > 0x7fffffff)
|
||||
{
|
||||
tmp = 0x7fffffff;
|
||||
} else if (tmp < (-2147483647 - 1)) {
|
||||
} else if (tmp < (-2147483647 - 1))
|
||||
{
|
||||
tmp = -2147483647 - 1;
|
||||
}
|
||||
|
||||
@@ -3291,3 +3304,4 @@ __ALWAYS_STATIC_INLINE uint32_t __UXTB16(uint32_t x)
|
||||
}
|
||||
|
||||
#endif /* _CSI_GCC_H_ */
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -123,7 +123,67 @@
|
||||
})
|
||||
#endif
|
||||
|
||||
#define CSR_MCOR 0x7c2
|
||||
#define CSR_MHCR 0x7c1
|
||||
#define CSR_MCCR2 0x7c3
|
||||
#define CSR_MHINT 0x7c5
|
||||
#define CSR_MHINT2 0x7cc
|
||||
#define CSR_MHINT3 0x7cd
|
||||
#define CSR_MHINT4 0x7ce
|
||||
#define CSR_MXSTATUS 0x7c0
|
||||
#define CSR_PLIC_BASE 0xfc1
|
||||
#define CSR_MRMR 0x7c6
|
||||
#define CSR_MRVBR 0x7c7
|
||||
#define CSR_MCOUNTERWEN 0x7c9
|
||||
#define CSR_MSMPR 0x7f3
|
||||
|
||||
#define CSR_MARCHID 0xf12
|
||||
#define CSR_MIMPID 0xf13
|
||||
#define CSR_MHARTID 0xf14
|
||||
#define CSR_MCPUID 0xfc0
|
||||
|
||||
#define CSR_MSTATUS 0x300
|
||||
#define CSR_MISA 0x301
|
||||
#define CSR_MEDELEG 0x302
|
||||
#define CSR_MIDELEG 0x303
|
||||
#define CSR_MIE 0x304
|
||||
#define CSR_MTVEC 0x305
|
||||
#define CSR_MCOUNTEREN 0x306
|
||||
#define CSR_MENVCFG 0x30a
|
||||
#define CSR_MSTATUSH 0x310
|
||||
#define CSR_MSCRATCH 0x340
|
||||
#define CSR_MEPC 0x341
|
||||
#define CSR_MCAUSE 0x342
|
||||
#define CSR_MTVAL 0x343
|
||||
#define CSR_MIP 0x344
|
||||
#define CSR_MTINST 0x34a
|
||||
#define CSR_MTVAL2 0x34b
|
||||
|
||||
/* Machine Memory Protection */
|
||||
#define CSR_PMPCFG0 0x3a0
|
||||
#define CSR_PMPCFG1 0x3a1
|
||||
#define CSR_PMPCFG2 0x3a2
|
||||
#define CSR_PMPCFG3 0x3a3
|
||||
#define CSR_PMPCFG4 0x3a4
|
||||
#define CSR_PMPCFG5 0x3a5
|
||||
#define CSR_PMPCFG6 0x3a6
|
||||
#define CSR_PMPCFG7 0x3a7
|
||||
#define CSR_PMPCFG8 0x3a8
|
||||
#define CSR_PMPCFG9 0x3a9
|
||||
#define CSR_PMPCFG10 0x3aa
|
||||
#define CSR_PMPCFG11 0x3ab
|
||||
#define CSR_PMPCFG12 0x3ac
|
||||
#define CSR_PMPCFG13 0x3ad
|
||||
#define CSR_PMPCFG14 0x3ae
|
||||
#define CSR_PMPCFG15 0x3af
|
||||
#define CSR_PMPADDR0 0x3b0
|
||||
#define CSR_PMPADDR1 0x3b1
|
||||
#define CSR_PMPADDR2 0x3b2
|
||||
#define CSR_PMPADDR3 0x3b3
|
||||
#define CSR_PMPADDR4 0x3b4
|
||||
#define CSR_PMPADDR5 0x3b5
|
||||
#define CSR_PMPADDR6 0x3b6
|
||||
#define CSR_PMPADDR7 0x3b7
|
||||
|
||||
#endif /* __CSI_RV_COMMON_H__ */
|
||||
|
||||
|
||||
@@ -54,7 +54,9 @@
|
||||
|
||||
#if CONFIG_CPU_XUANTIE_E906 || CONFIG_CPU_XUANTIE_E906F || CONFIG_CPU_XUANTIE_E906FD || CONFIG_CPU_XUANTIE_E906P || CONFIG_CPU_XUANTIE_E906FP || CONFIG_CPU_XUANTIE_E906FDP \
|
||||
|| CONFIG_CPU_XUANTIE_E907 || CONFIG_CPU_XUANTIE_E907F || CONFIG_CPU_XUANTIE_E907FD || CONFIG_CPU_XUANTIE_E907P || CONFIG_CPU_XUANTIE_E907FP || CONFIG_CPU_XUANTIE_E907FDP \
|
||||
|| CONFIG_CPU_XUANTIE_E902 || CONFIG_CPU_XUANTIE_E902M || CONFIG_CPU_XUANTIE_E902T || CONFIG_CPU_XUANTIE_E902MT
|
||||
|| CONFIG_CPU_XUANTIE_E902 || CONFIG_CPU_XUANTIE_E902M || CONFIG_CPU_XUANTIE_E902T || CONFIG_CPU_XUANTIE_E902MT \
|
||||
|| CONFIG_CPU_XUANTIE_E901PLUS_CP || CONFIG_CPU_XUANTIE_E901PLUS_B_CP || CONFIG_CPU_XUANTIE_E901PLUS_M_CP || CONFIG_CPU_XUANTIE_E901PLUS_BM_CP \
|
||||
|| CONFIG_CPU_XUANTIE_E901_CP || CONFIG_CPU_XUANTIE_E901_B_CP || CONFIG_CPU_XUANTIE_E901_ZM_CP || CONFIG_CPU_XUANTIE_E901_BZM_CP
|
||||
#include <core/core_rv32.h>
|
||||
#include <core/csi_rv32_gcc.h>
|
||||
#else
|
||||
@@ -112,18 +114,28 @@ __STATIC_INLINE const char* csi_get_cpu_name()
|
||||
return "c908v";
|
||||
#elif CONFIG_CPU_XUANTIE_C908I
|
||||
return "c908i";
|
||||
#elif CONFIG_CPU_XUANTIE_C908X
|
||||
return "c908x";
|
||||
#elif CONFIG_CPU_XUANTIE_C908X_CP
|
||||
return "c908x-cp";
|
||||
#elif CONFIG_CPU_XUANTIE_C908X_CP_XT
|
||||
return "c908x-cp-xt";
|
||||
#elif CONFIG_CPU_XUANTIE_C910V2
|
||||
return "c910v2";
|
||||
#elif CONFIG_CPU_XUANTIE_C910V3
|
||||
return "c910v3";
|
||||
#elif CONFIG_CPU_XUANTIE_C910V3_CP
|
||||
return "c910v3-cp";
|
||||
#elif CONFIG_CPU_XUANTIE_C910V3_CP_XT
|
||||
return "c910v3-cp-xt";
|
||||
#elif CONFIG_CPU_XUANTIE_C920V2
|
||||
return "c920v2";
|
||||
#elif CONFIG_CPU_XUANTIE_C920V3
|
||||
return "c920v3";
|
||||
#elif CONFIG_CPU_XUANTIE_C920V3_CP
|
||||
return "c920v3-cp";
|
||||
#elif CONFIG_CPU_XUANTIE_C920V3_CP_XT
|
||||
return "c920v3-cp-xt";
|
||||
#elif CONFIG_CPU_XUANTIE_R910
|
||||
return "r910";
|
||||
#elif CONFIG_CPU_XUANTIE_R920
|
||||
@@ -140,7 +152,28 @@ __STATIC_INLINE const char* csi_get_cpu_name()
|
||||
return "r908fd-cp";
|
||||
#elif CONFIG_CPU_XUANTIE_R908FDV_CP
|
||||
return "r908fdv-cp";
|
||||
|
||||
#elif CONFIG_CPU_XUANTIE_R908_CP_XT
|
||||
return "r908-cp-xt";
|
||||
#elif CONFIG_CPU_XUANTIE_R908FD_CP_XT
|
||||
return "r908fd-cp-xt";
|
||||
#elif CONFIG_CPU_XUANTIE_R908FDV_CP_XT
|
||||
return "r908fdv-cp-xt";
|
||||
#elif CONFIG_CPU_XUANTIE_E901PLUS_CP
|
||||
return "e901plus-cp";
|
||||
#elif CONFIG_CPU_XUANTIE_E901PLUS_B_CP
|
||||
return "e901plusb-cp";
|
||||
#elif CONFIG_CPU_XUANTIE_E901PLUS_M_CP
|
||||
return "e901plusm-cp";
|
||||
#elif CONFIG_CPU_XUANTIE_E901PLUS_BM_CP
|
||||
return "e901plusbm-cp";
|
||||
#elif CONFIG_CPU_XUANTIE_E901_CP
|
||||
return "e901-cp";
|
||||
#elif CONFIG_CPU_XUANTIE_E901_B_CP
|
||||
return "e901b-cp";
|
||||
#elif CONFIG_CPU_XUANTIE_E901_ZM_CP
|
||||
return "e901zm-cp";
|
||||
#elif CONFIG_CPU_XUANTIE_E901_BZM_CP
|
||||
return "e901bzm-cp";
|
||||
#elif CONFIG_CPU_XUANTIE_E902
|
||||
return "e902";
|
||||
#elif CONFIG_CPU_XUANTIE_E902M
|
||||
@@ -184,3 +217,4 @@ __STATIC_INLINE const char* csi_get_cpu_name()
|
||||
#endif
|
||||
|
||||
#endif /* _CORE_H_ */
|
||||
|
||||
|
||||
@@ -119,3 +119,4 @@ extern const char *PFORMAT_E;
|
||||
#endif
|
||||
|
||||
#endif /* _SYSLOG_H_ */
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>project</name>
|
||||
<comment />
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
</natures>
|
||||
<linkedResources />
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,3 @@
|
||||
content-types/enabled=true
|
||||
content-types/org.eclipse.cdt.core.asmSource/file-extensions=s
|
||||
eclipse.preferences.version=1
|
||||
@@ -0,0 +1,20 @@
|
||||
#RT-Thread Studio Project Configuration
|
||||
# Mon Sep 22 13:30:04 2025
|
||||
cfg_version=v3.0
|
||||
|
||||
board_name=
|
||||
bsp_version=
|
||||
bsp_path=
|
||||
chip_name=
|
||||
project_base_rtt_bsp=true
|
||||
is_use_scons_build=true
|
||||
hardware_adapter=
|
||||
selected_rtt_version=latest
|
||||
board_base_nano_proj=false
|
||||
is_base_example_project=false
|
||||
example_name=
|
||||
project_type=rt-thread
|
||||
os_branch=master
|
||||
os_version=latest
|
||||
project_name=project
|
||||
output_project_path=E:\rt-thread\bsp\xuantie\smartl\e901
|
||||
@@ -0,0 +1,18 @@
|
||||
mainmenu "RT-Thread Configuration"
|
||||
|
||||
BSP_DIR := .
|
||||
|
||||
RTT_DIR := ../../../../
|
||||
|
||||
PKGS_DIR := packages
|
||||
|
||||
config XUANTIAN_SMARTL_E901
|
||||
bool
|
||||
select ARCH_RISCV32
|
||||
select RT_USING_COMPONENTS_INIT
|
||||
select RT_USING_USER_MAIN
|
||||
default y
|
||||
|
||||
source "$(RTT_DIR)/Kconfig"
|
||||
source "$PKGS_DIR/Kconfig"
|
||||
source "$BSP_DIR/board/Kconfig"
|
||||
@@ -0,0 +1,100 @@
|
||||
# XuanTie - E901 Series
|
||||
|
||||
## 一 简介
|
||||
|
||||
### 1. 内核
|
||||
|
||||
玄铁 E901+ 是基于 RISC-V 指令架构的低成本、高能效的 32 位嵌入式 CPU 处理器,用户可以以近似 8 位CPU 的成本获得 32 位嵌入式处理器的效率与性能。E901+ 处理器兼容 RV32E[M] [B]_Zc 指令架构,采用 16/32 位混合编码系统,指令系统与流水线硬件结构精简高效。同时支持配置协处理器接口,用于满足用户 DSA(Domain Specific Accelerator)需求,加速特定应用执行,并支持用户进行自定义指令扩展。
|
||||
|
||||
E901+ 主要针对智能卡、智能电网、低成本微控制器、无线传感网络等嵌入式应用。
|
||||
|
||||
### 2.特点
|
||||
|
||||
E902 处理器体系结构的主要特点如下:
|
||||
|
||||
E901+ 处理器体系结构的主要特点如下:
|
||||
|
||||
• 支持 RV32E [M] [B]_Zc 指令集
|
||||
|
||||
• 16 个 32 位通用寄存器
|
||||
|
||||
• 两级顺序执行流水线
|
||||
|
||||
• 支持 RISC-V 机器模式和用户模式
|
||||
|
||||
• 支持 RISC-V Debug 架构,支持标准五线 JTAG 调试接口,支持 CJTAG 两线调试接口
|
||||
|
||||
• 支持以下硬件乘/除法器配置:
|
||||
|
||||
**–** 不配置硬件乘/除法器
|
||||
|
||||
**–** 配置单周期快速硬件乘法器,以及多周期(1-33)慢速硬件除法器
|
||||
|
||||
**–** 配置多周期(3-33)慢速硬件乘法器,以及多周期(1-33)慢速硬件除法器
|
||||
|
||||
• 兼容 RISC-V CLIC 中断标准,支持中断优先级可配置,支持中断嵌套和中断咬尾
|
||||
|
||||
• 外部中断源数量最高可配置为 112 个
|
||||
|
||||
• 兼容 RISC-V PMP 内存保护标准,0/2/4/8/16 区域可配置
|
||||
|
||||
• 支持指令总线和系统总线,指令总线支持 AHB-Lite(即 AHB 3.0)协议,系统总线协议支持 AHB 2.0
|
||||
|
||||
和 AHB-Lite
|
||||
|
||||
• 支持指令高速缓存,缓存行 16 字节,容量 2KiB/4KiB/8KiB 可配
|
||||
|
||||
• 支持玄铁扩展编程模型
|
||||
|
||||
• 支持复位启动地址硬件集成时可配置
|
||||
|
||||
• 支持软复位操作
|
||||
|
||||
• 支持协处理器接口可配置
|
||||
|
||||
### 3.BSP支持情况
|
||||
|
||||
- 当前BSP支持下述内核:
|
||||
|
||||
```asciiarmor
|
||||
e901plusbm-cp
|
||||
```
|
||||
|
||||
- 当前BSP默认设置的内核是e901plusbm-cp。
|
||||
|
||||
- 当使用其他内核架构时需要修改,rtconfig.py文件中的`MCPU`字段。
|
||||
|
||||
### 4.运行QEMU
|
||||
|
||||
- BSP根目录下存在`qemu.bat`脚本,生成可执行文件后可点击该脚本直接启动QEMU.
|
||||
|
||||
## 二 工具
|
||||
|
||||
- 编译器: https://www.xrvm.cn/community/download?id=4433353576298909696
|
||||
- 模拟器: https://www.xrvm.cn/community/download?id=4397435198627713024
|
||||
|
||||
注:若上述链接中的编译器与模拟器不能使用,可以使用下述CDK中的编译器与模拟器
|
||||
|
||||
- SDK:https://www.xrvm.cn/community/download?id=4397799570420076544
|
||||
|
||||
## 三 调试方法
|
||||
|
||||
**下述调试方法以E902举例,本BSP操作方式一致**,搭建完成RT-Thread开发环境,在BSP根目录使用env工具在当前目录打开env。
|
||||
|
||||

|
||||
|
||||
使用前执行一次**menuconfig**命令,更新rtconfig.h配置,然后在当前目录执行**scons -j12**命令编译生成可可执行文件。
|
||||
|
||||
<img src="figures/2.scons.png" alt="env" style="zoom: 95%;" />
|
||||
|
||||
生成可执行文件,可以直接在命令行启动qemu或者配置vscode脚本借助vscode强大的插件进行图形化调试,qemu的相关命令可以查看玄铁qemu的[用户手册](https://www.xrvm.cn/community/download?id=4397435198627713024),下述是启动qemu的命令,在powershell或命令行可直接执行下述命令,注意qemu需要导出至环境变量或者使用绝对路径。
|
||||
|
||||
```shell
|
||||
qemu-system-riscv64 -machine smartl -nographic -kernel rtthread.elf -cpu e906
|
||||
```
|
||||
|
||||
下述是使用vscode调试的展示。
|
||||
|
||||
<img src="figures/3.vscode.png" alt="env" style="zoom: 63%;" />
|
||||
|
||||
一起为RISC-V加油!
|
||||
@@ -0,0 +1,19 @@
|
||||
# for module compiling
|
||||
import os
|
||||
Import('RTT_ROOT')
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
objs = []
|
||||
list = os.listdir(cwd)
|
||||
|
||||
for item in list:
|
||||
path = os.path.join(cwd, item)
|
||||
if item == 'libraries' or not os.path.isdir(path):
|
||||
continue
|
||||
|
||||
sconscript_path = os.path.join(path, 'SConscript')
|
||||
if os.path.isfile(sconscript_path):
|
||||
objs.extend(SConscript(os.path.join(item, 'SConscript')))
|
||||
|
||||
Return('objs')
|
||||
@@ -0,0 +1,54 @@
|
||||
import os
|
||||
import sys
|
||||
import rtconfig
|
||||
from SCons.Script import *
|
||||
|
||||
if os.getenv('RTT_ROOT'):
|
||||
RTT_ROOT = os.getenv('RTT_ROOT')
|
||||
else:
|
||||
RTT_ROOT = os.path.normpath(os.getcwd() + '/../../../..')
|
||||
|
||||
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
|
||||
|
||||
try:
|
||||
from building import *
|
||||
except:
|
||||
print('Cannot found RT-Thread root directory, please check RTT_ROOT')
|
||||
print(RTT_ROOT)
|
||||
exit(-1)
|
||||
|
||||
TARGET = 'rtthread.' + rtconfig.TARGET_EXT
|
||||
|
||||
DefaultEnvironment(tools=[])
|
||||
env = Environment(tools = ['mingw'],
|
||||
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
|
||||
CC = rtconfig.CC, CFLAGS = rtconfig.CFLAGS,
|
||||
AR = rtconfig.AR, ARFLAGS = '-rc',
|
||||
CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
|
||||
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
|
||||
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
|
||||
|
||||
Export('RTT_ROOT')
|
||||
Export('rtconfig')
|
||||
|
||||
SDK_ROOT = os.path.abspath('./')
|
||||
|
||||
if os.path.exists(SDK_ROOT + '/libraries'):
|
||||
libraries_path_prefix = SDK_ROOT + '../libraries'
|
||||
else:
|
||||
libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/../libraries'
|
||||
|
||||
SDK_LIB = libraries_path_prefix
|
||||
Export('SDK_LIB')
|
||||
|
||||
# prepare building environment
|
||||
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
|
||||
|
||||
bsp_vdir = 'build'
|
||||
library_vdir = 'build/libraries'
|
||||
|
||||
# common include drivers
|
||||
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'SConscript'), variant_dir=library_vdir, duplicate=0))
|
||||
|
||||
# make a building
|
||||
DoBuilding(TARGET, objs)
|
||||
@@ -0,0 +1,10 @@
|
||||
from building import *
|
||||
import os
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
CPPPATH = [cwd]
|
||||
src = ['main.c']
|
||||
|
||||
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2025, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2025-04-21 Wangshun first version
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
#include "pre_main.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
rt_kprintf("Hello RT-Thread!\r\n");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
menu "Hardware Drivers Config"
|
||||
|
||||
config SOC_XUANTIE
|
||||
bool
|
||||
select RT_USING_COMPONENTS_INIT
|
||||
select RT_USING_USER_MAIN
|
||||
default y
|
||||
|
||||
|
||||
menu "On-chip Peripheral Drivers"
|
||||
|
||||
menuconfig BSP_USING_UART
|
||||
bool "Enable UART"
|
||||
select RT_USING_SERIAL
|
||||
default n
|
||||
|
||||
if BSP_USING_UART
|
||||
config BSP_USING_UART0
|
||||
bool "Enable UART0"
|
||||
default n
|
||||
endif
|
||||
|
||||
menuconfig ENABLE_FPU
|
||||
bool "Enable FPU"
|
||||
select ARCH_RISCV_FPU
|
||||
default n
|
||||
|
||||
endmenu
|
||||
|
||||
endmenu
|
||||
@@ -0,0 +1,33 @@
|
||||
import os
|
||||
import rtconfig
|
||||
from building import *
|
||||
|
||||
Import('SDK_LIB')
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
|
||||
# add general drivers
|
||||
src = ['board.c']
|
||||
|
||||
path = [cwd]
|
||||
|
||||
CPPDEFINES = [
|
||||
'CONFIG_KERNEL_RTTHREAD=1',
|
||||
'__RT_KERNEL_SOURCE__=1',
|
||||
'CONFIG_CSI_V2=1',
|
||||
'CONFIG_CSI=csi2',
|
||||
'CONFIG_INIT_TASK_STACK_SIZE=4096',
|
||||
'CONFIG_APP_TASK_STACK_SIZE=8192',
|
||||
'CONFIG_ARCH_MAINSTACK=4096',
|
||||
'CONFIG_ARCH_INTERRUPTSTACK=4096',
|
||||
'CONFIG_XIP=1',
|
||||
'CONFIG_LIBC_MINI_PRINTF_SUPPORT=1',
|
||||
'CONFIG_SYSTICK_HZ=100',
|
||||
'CONFIG_BOARD_SMARTL_EVB=1',
|
||||
'CONFIG_DEBUG=1',
|
||||
'CLI_CONFIG_STACK_SIZE=4096',
|
||||
'CONFIG_CPU_XUANTIE_E901PLUS_BM_CP=1',
|
||||
]
|
||||
|
||||
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)
|
||||
Return('group')
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2025, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2025-04-23 Wangshun first version
|
||||
*/
|
||||
|
||||
#include <board.h>
|
||||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
#include <drv_usart.h>
|
||||
|
||||
extern unsigned long __heap_start;
|
||||
extern unsigned long __heap_end;
|
||||
|
||||
/**
|
||||
* This function will initialize your board.
|
||||
*/
|
||||
void rt_hw_board_init()
|
||||
{
|
||||
rt_hw_interrupt_init();
|
||||
|
||||
#ifdef RT_USING_HEAP
|
||||
rt_system_heap_init((void *)&__heap_start, (void *)&__heap_end);
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_UART
|
||||
rt_hw_usart_init();
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_CONSOLE
|
||||
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_COMPONENTS_INIT
|
||||
rt_components_board_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 27 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 49 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 164 KiB |
@@ -0,0 +1,8 @@
|
||||
@echo off
|
||||
set OBJDUMP=D:\RT-ThreadStudio\repo\Extract\ToolChain_Support_Packages\RISC-V\XTGccElfNewlib\V3.0.1\R\bin\riscv64-unknown-elf-objdump
|
||||
set TARGET=E:\rt-thread\bsp\xuantie\smartl\e901\rtthread.elf
|
||||
set OUTPUT=rtthread.asm
|
||||
|
||||
%OBJDUMP% -d %TARGET% > %OUTPUT%
|
||||
echo Disassembly generated to %OUTPUT%
|
||||
pause
|
||||
@@ -0,0 +1,91 @@
|
||||
@echo off
|
||||
cls
|
||||
|
||||
echo /*
|
||||
echo * Copyright (c) 2006 - 2025, RT-Thread Development Team
|
||||
echo *
|
||||
echo * SPDX-License-Identifier: Apache-2.0
|
||||
echo *
|
||||
echo * Change Logs:
|
||||
echo * Date Author Notes
|
||||
echo * 2025/04/29 Wangshun first version
|
||||
echo * 2025/05/14 Optimized Improved robustness and error handling
|
||||
echo */
|
||||
echo.
|
||||
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
set "CONFIG_FILE=qemu_config.txt"
|
||||
set "CPU_CONFIG_FILE=cpu_config.txt"
|
||||
set "DEFAULT_QEMU_DIR=E:\XuanTieCore\6.QEMU"
|
||||
set "ELF_PATH=%CD%\rtthread.elf"
|
||||
|
||||
:: Load QEMU directory from config file or set default
|
||||
if exist "!CONFIG_FILE!" (
|
||||
set /p QEMU_DIR=<"!CONFIG_FILE!"
|
||||
if not defined QEMU_DIR set "QEMU_DIR=!DEFAULT_QEMU_DIR!"
|
||||
) else (
|
||||
set "QEMU_DIR=!DEFAULT_QEMU_DIR!"
|
||||
)
|
||||
|
||||
:: Load CPU parameter from config file or set default
|
||||
if exist "!CPU_CONFIG_FILE!" (
|
||||
set /p CPU_PARAM=<"!CPU_CONFIG_FILE!"
|
||||
if not defined CPU_PARAM set "CPU_PARAM=e901"
|
||||
) else (
|
||||
set "CPU_PARAM=e901"
|
||||
)
|
||||
|
||||
:: Prompt for new QEMU directory
|
||||
set /p "USER_INPUT=Enter new QEMU directory (Enter for default: !QEMU_DIR!): "
|
||||
if defined USER_INPUT (
|
||||
set "USER_INPUT=!USER_INPUT: =!"
|
||||
if not "!USER_INPUT!"=="" (
|
||||
set "QEMU_DIR=!USER_INPUT!"
|
||||
echo !QEMU_DIR!>"!CONFIG_FILE!"
|
||||
)
|
||||
)
|
||||
|
||||
:: Validate QEMU path
|
||||
set "QEMU_PATH=!QEMU_DIR!\qemu-system-riscv32.exe"
|
||||
if not exist "!QEMU_PATH!" (
|
||||
echo Error: QEMU executable not found at "!QEMU_PATH!".
|
||||
echo Please verify the QEMU directory and try again.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
:: Prompt for new CPU parameter
|
||||
echo Current CPU parameter: !CPU_PARAM!
|
||||
set /p "CPU_INPUT=Enter new -cpu parameter (Enter for default): "
|
||||
if defined CPU_INPUT (
|
||||
set "CPU_INPUT=!CPU_INPUT: =!"
|
||||
if not "!CPU_INPUT!"=="" (
|
||||
set "CPU_PARAM=!CPU_INPUT!"
|
||||
echo !CPU_PARAM!>"!CPU_CONFIG_FILE!"
|
||||
)
|
||||
)
|
||||
|
||||
:: Validate ELF file
|
||||
if not exist "!ELF_PATH!" (
|
||||
echo Error: rtthread.elf not found at "!ELF_PATH!".
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
:: Display QEMU version
|
||||
echo.
|
||||
"!QEMU_PATH!" --version
|
||||
|
||||
:: Run QEMU
|
||||
echo.
|
||||
"!QEMU_PATH!" -machine smartl -kernel "!ELF_PATH!" -nographic -cpu !CPU_PARAM!
|
||||
if !ERRORLEVEL! neq 0 (
|
||||
echo Error: QEMU failed to run. Check configuration or paths.
|
||||
pause
|
||||
exit /b !ERRORLEVEL!
|
||||
)
|
||||
|
||||
echo QEMU terminated.
|
||||
pause
|
||||
endlocal
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,98 @@
|
||||
import os
|
||||
ARCH = 'risc-v'
|
||||
CPU = 'e901'
|
||||
# toolchains options
|
||||
CROSS_TOOL = 'gcc'
|
||||
|
||||
#------- toolchains path -------------------------------------------------------
|
||||
if os.getenv('RTT_CC'):
|
||||
CROSS_TOOL = os.getenv('RTT_CC')
|
||||
|
||||
if CROSS_TOOL == 'gcc':
|
||||
PLATFORM = 'gcc'
|
||||
EXEC_PATH = r'D:\C-Sky\CDKRepo\Toolchain\XTGccElfNewlib\V3.2.0\R\bin'
|
||||
else:
|
||||
print('Please make sure your toolchains is GNU GCC!')
|
||||
exit(0)
|
||||
|
||||
if os.getenv('RTT_EXEC_PATH'):
|
||||
EXEC_PATH = os.getenv('RTT_EXEC_PATH')
|
||||
|
||||
BUILD = 'debug'
|
||||
#BUILD = 'release'
|
||||
|
||||
CORE = 'risc-v'
|
||||
MAP_FILE = 'rtthread.map'
|
||||
LINK_FILE = '../../libraries/xuantie_libraries/chip_riscv_dummy/gcc_flash_smartl_lite.ld'
|
||||
if os.path.exists('./libraries'):
|
||||
LINK_FILE = './libraries/xuantie_libraries/chip_riscv_dummy/gcc_flash_smartl_lite.ld'
|
||||
TARGET_NAME = 'rtthread.bin'
|
||||
|
||||
#------- GCC settings ----------------------------------------------------------
|
||||
if PLATFORM == 'gcc':
|
||||
# toolchains
|
||||
PREFIX = 'riscv64-unknown-elf-'
|
||||
CC = PREFIX + 'gcc'
|
||||
CXX= PREFIX + 'g++'
|
||||
AS = PREFIX + 'gcc'
|
||||
AR = PREFIX + 'ar'
|
||||
LINK = PREFIX + 'gcc'
|
||||
TARGET_EXT = 'elf'
|
||||
SIZE = PREFIX + 'size'
|
||||
OBJDUMP = PREFIX + 'objdump'
|
||||
OBJCPY = PREFIX + 'objcopy'
|
||||
|
||||
MCPU = ' -mcpu=e901plusbm-cp ' # Modify here based on CPU architecture.
|
||||
MCPU_DEFINE = ' -DCONFIG_CPU_XUANTIE_E901PLUS_BM_CP=1 ' # Modify here based on CPU architecture.
|
||||
DEVICE = MCPU + MCPU_DEFINE + ' -Wno-main -mcmodel=medany'
|
||||
|
||||
GLOBAL_DEFINES = (
|
||||
'-DCONFIG_KERNEL_RTTHREAD=1 '
|
||||
'-D__RT_KERNEL_SOURCE__=1 '
|
||||
'-DCONFIG_CSI_V2=1 '
|
||||
'-DCONFIG_CSI=csi2 '
|
||||
'-DCONFIG_INIT_TASK_STACK_SIZE=4096 '
|
||||
'-DCONFIG_APP_TASK_STACK_SIZE=8192 '
|
||||
'-DCONFIG_ARCH_MAINSTACK=4096 '
|
||||
'-DCONFIG_ARCH_INTERRUPTSTACK=4096 '
|
||||
'-DCONFIG_XIP=1 '
|
||||
'-DCONFIG_LIBC_MINI_PRINTF_SUPPORT=1 '
|
||||
'-DCONFIG_SYSTICK_HZ=100 '
|
||||
'-DCONFIG_BOARD_SMARTL_EVB=1 '
|
||||
'-DCONFIG_DEBUG=1 '
|
||||
'-DCLI_CONFIG_STACK_SIZE=4096 '
|
||||
)
|
||||
|
||||
CFLAGS = DEVICE + ' -g -Wall -Wno-unused-function -Wformat -Wformat-security -Warray-bounds -Wuninitialized \
|
||||
-Wreturn-type -Wcomment -Wswitch -Wparentheses -specs=minilibc.specs -MP -MMD -Os -Wpointer-arith \
|
||||
-Wno-undef -ffunction-sections -fdata-sections -fno-inline-functions -fno-builtin \
|
||||
-fno-strict-aliasing -Wno-char-subscripts -Wno-unused-but-set-variable ' + GLOBAL_DEFINES
|
||||
|
||||
AFLAGS = DEVICE + ' -g -Wall -Wno-unused-function -Wformat -Wformat-security -Warray-bounds -Wuninitialized \
|
||||
-Wreturn-type -Wcomment -Wswitch -Wparentheses -specs=minilibc.specs -MP -MMD -Os -Wpointer-arith \
|
||||
-Wno-undef -ffunction-sections -fdata-sections -fno-inline-functions -fno-builtin \
|
||||
-fno-strict-aliasing -Wno-char-subscripts -Wno-unused-but-set-variable ' + ' -MP -MMD -D"Default_IRQHandler=SW_handler" ' + GLOBAL_DEFINES
|
||||
|
||||
LFLAGS = DEVICE + ' -MP -MMD -Wl,-zmax-page-size=1024 -Wl,-Map=yoc.map -Wl,-zmax-page-size=1024 -Wl,-Map=yoc.map -Wl,--whole-archive -Wl,--no-whole-archive -specs=minilibc.specs -nostartfiles -Wl,--gc-sections '
|
||||
LFLAGS += ' -T ' + LINK_FILE
|
||||
|
||||
CPATH = ''
|
||||
LPATH = ''
|
||||
|
||||
if BUILD == 'debug':
|
||||
CFLAGS += ' -Os -g3'
|
||||
AFLAGS += ' -g3'
|
||||
else:
|
||||
CFLAGS += ' -O2 -g2'
|
||||
|
||||
CXXFLAGS = CFLAGS
|
||||
|
||||
POST_ACTION = OBJCPY + ' -O binary $TARGET ' + TARGET_NAME + '\n'
|
||||
POST_ACTION += SIZE + ' $TARGET\n'
|
||||
|
||||
def dist_handle(BSP_ROOT, dist_dir):
|
||||
import sys
|
||||
cwd_path = os.getcwd()
|
||||
sys.path.append(os.path.join(os.path.dirname(BSP_ROOT), '../tools'))
|
||||
from sdk_dist import dist_do_building
|
||||
dist_do_building(BSP_ROOT, dist_dir)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CDK_Workspace Name="template" Database="LanguageSever" DoubleClick="Yes">
|
||||
<DefaultPackPath>$(CDKWS)\__workspace_pack__</DefaultPackPath>
|
||||
<Project Name="xuantie_rtthread" Path="template.cdkproj" RootPath="" Active="Yes"/>
|
||||
<BuildMatrix>
|
||||
<WorkspaceConfiguration Name="Debug" Selected="yes">
|
||||
<Environment/>
|
||||
<Project Name="xuantie_rtthread" ConfigName="BuildSet"/>
|
||||
</WorkspaceConfiguration>
|
||||
</BuildMatrix>
|
||||
</CDK_Workspace>
|
||||
@@ -0,0 +1,6 @@
|
||||
set *(int *)0x0=0x6f
|
||||
si
|
||||
reset
|
||||
set *(int *)0x40011008=0x0
|
||||
set *(int *)0x4001101c=0x0
|
||||
|
||||
Reference in New Issue
Block a user