[bsp/juicevm] Add JuiceVm BSP.

This commit is contained in:
xiaoxiaohuixxh 2021-04-26 13:46:22 +08:00
parent 1bc204722d
commit d64a11bb1e
21 changed files with 1540 additions and 0 deletions

441
bsp/juicevm/.config Executable file
View File

@ -0,0 +1,441 @@
#
# Automatically generated file; DO NOT EDIT.
# RT-Thread Project Configuration
#
#
# RT-Thread Kernel
#
CONFIG_RT_NAME_MAX=8
# CONFIG_RT_USING_SMP is not set
CONFIG_RT_ALIGN_SIZE=4
# CONFIG_RT_THREAD_PRIORITY_8 is not set
CONFIG_RT_THREAD_PRIORITY_32=y
# CONFIG_RT_THREAD_PRIORITY_256 is not set
CONFIG_RT_THREAD_PRIORITY_MAX=32
CONFIG_RT_TICK_PER_SECOND=100
CONFIG_RT_USING_OVERFLOW_CHECK=y
CONFIG_RT_USING_HOOK=y
CONFIG_RT_USING_IDLE_HOOK=y
CONFIG_RT_IDLE_HOOK_LIST_SIZE=4
CONFIG_IDLE_THREAD_STACK_SIZE=1024
# CONFIG_RT_USING_TIMER_SOFT is not set
CONFIG_RT_DEBUG=y
CONFIG_RT_DEBUG_COLOR=y
# CONFIG_RT_DEBUG_INIT_CONFIG is not set
# CONFIG_RT_DEBUG_THREAD_CONFIG is not set
# CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set
# CONFIG_RT_DEBUG_IPC_CONFIG is not set
# CONFIG_RT_DEBUG_TIMER_CONFIG is not set
# CONFIG_RT_DEBUG_IRQ_CONFIG is not set
# CONFIG_RT_DEBUG_MEM_CONFIG is not set
# CONFIG_RT_DEBUG_SLAB_CONFIG is not set
# CONFIG_RT_DEBUG_MEMHEAP_CONFIG is not set
# CONFIG_RT_DEBUG_MODULE_CONFIG is not set
#
# Inter-Thread communication
#
CONFIG_RT_USING_SEMAPHORE=y
CONFIG_RT_USING_MUTEX=y
CONFIG_RT_USING_EVENT=y
CONFIG_RT_USING_MAILBOX=y
CONFIG_RT_USING_MESSAGEQUEUE=y
# CONFIG_RT_USING_SIGNALS is not set
#
# Memory Management
#
CONFIG_RT_USING_MEMPOOL=y
# CONFIG_RT_USING_MEMHEAP is not set
# CONFIG_RT_USING_NOHEAP is not set
CONFIG_RT_USING_SMALL_MEM=y
# CONFIG_RT_USING_SLAB is not set
# CONFIG_RT_USING_MEMTRACE is not set
CONFIG_RT_USING_HEAP=y
#
# Kernel Device Object
#
CONFIG_RT_USING_DEVICE=y
# CONFIG_RT_USING_DEVICE_OPS is not set
# CONFIG_RT_USING_INTERRUPT_INFO is not set
CONFIG_RT_USING_CONSOLE=y
CONFIG_RT_CONSOLEBUF_SIZE=128
CONFIG_RT_CONSOLE_DEVICE_NAME="uart0"
CONFIG_RT_VER_NUM=0x40000
CONFIG_ARCH_RISCV=y
# CONFIG_ARCH_CPU_STACK_GROWS_UPWARD is not set
#
# RT-Thread Components
#
CONFIG_RT_USING_COMPONENTS_INIT=y
CONFIG_RT_USING_USER_MAIN=y
CONFIG_RT_MAIN_THREAD_STACK_SIZE=2048
CONFIG_RT_MAIN_THREAD_PRIORITY=10
#
# C++ features
#
# CONFIG_RT_USING_CPLUSPLUS is not set
#
# Command shell
#
CONFIG_RT_USING_FINSH=y
CONFIG_FINSH_THREAD_NAME="tshell"
CONFIG_FINSH_USING_HISTORY=y
CONFIG_FINSH_HISTORY_LINES=5
CONFIG_FINSH_USING_SYMTAB=y
CONFIG_FINSH_USING_DESCRIPTION=y
# CONFIG_FINSH_ECHO_DISABLE_DEFAULT is not set
CONFIG_FINSH_THREAD_PRIORITY=20
CONFIG_FINSH_THREAD_STACK_SIZE=4096
CONFIG_FINSH_CMD_SIZE=80
# CONFIG_FINSH_USING_AUTH is not set
CONFIG_FINSH_USING_MSH=y
CONFIG_FINSH_USING_MSH_DEFAULT=y
CONFIG_FINSH_USING_MSH_ONLY=y
CONFIG_FINSH_ARG_MAX=10
#
# Device virtual file system
#
# CONFIG_RT_USING_DFS is not set
# CONFIG_DFS_USING_WORKDIR is not set
# CONFIG_DFS_FILESYSTEMS_MAX is not set
# CONFIG_DFS_FILESYSTEM_TYPES_MAX is not set
# CONFIG_DFS_FD_MAX is not set
# CONFIG_RT_USING_DFS_MNTTABLE is not set
# CONFIG_RT_USING_DFS_ELMFAT is not set
#
# elm-chan's FatFs, Generic FAT Filesystem Module
#
# CONFIG_RT_DFS_ELM_CODE_PAGE is not set
# CONFIG_RT_DFS_ELM_WORD_ACCESS is not set
# CONFIG_RT_DFS_ELM_USE_LFN_0 is not set
# CONFIG_RT_DFS_ELM_USE_LFN_1 is not set
# CONFIG_RT_DFS_ELM_USE_LFN_2 is not set
# CONFIG_RT_DFS_ELM_USE_LFN_3=y
# CONFIG_RT_DFS_ELM_USE_LFN=3
# CONFIG_RT_DFS_ELM_MAX_LFN=255
# CONFIG_RT_DFS_ELM_DRIVES=2
# CONFIG_RT_DFS_ELM_MAX_SECTOR_SIZE=512
# CONFIG_RT_DFS_ELM_USE_ERASE is not set
# CONFIG_RT_DFS_ELM_REENTRANT=y
# CONFIG_RT_USING_DFS_DEVFS=y
# CONFIG_RT_USING_DFS_ROMFS is not set
# CONFIG_RT_USING_DFS_RAMFS is not set
# CONFIG_RT_USING_DFS_UFFS is not set
# CONFIG_RT_USING_DFS_JFFS2 is not set
#
# Device Drivers
#
CONFIG_RT_USING_DEVICE_IPC=y
CONFIG_RT_PIPE_BUFSZ=512
CONFIG_RT_USING_SERIAL=y
CONFIG_RT_SERIAL_USING_DMA=y
# CONFIG_RT_USING_CAN is not set
# CONFIG_RT_USING_HWTIMER is not set
# CONFIG_RT_USING_CPUTIME is not set
# CONFIG_RT_USING_I2C is not set
# CONFIG_RT_USING_PIN is not set
# CONFIG_RT_USING_ADC is not set
# CONFIG_RT_USING_PWM is not set
# CONFIG_RT_USING_MTD_NOR is not set
# CONFIG_RT_USING_MTD_NAND is not set
# CONFIG_RT_USING_MTD is not set
# CONFIG_RT_USING_PM is not set
# CONFIG_RT_USING_RTC is not set
# CONFIG_RT_USING_SOFT_RTC is not set
# CONFIG_RT_USING_SDIO is not set
# CONFIG_RT_USING_SPI is not set
# CONFIG_RT_USING_WDT is not set
# CONFIG_RT_USING_AUDIO is not set
#
# Using WiFi
#
# CONFIG_RT_USING_WIFI is not set
#
# Using USB
#
# CONFIG_RT_USING_USB_HOST is not set
# CONFIG_RT_USING_USB_DEVICE is not set
#
# POSIX layer and C standard library
#
CONFIG_RT_USING_LIBC=y
# CONFIG_RT_USING_PTHREADS is not set
# CONFIG_RT_USING_POSIX=y
# CONFIG_RT_USING_POSIX_MMAP is not set
# CONFIG_RT_USING_POSIX_TERMIOS is not set
# CONFIG_RT_USING_POSIX_AIO is not set
# CONFIG_RT_USING_MODULE is not set
#
# Network
#
#
# Socket abstraction layer
#
# CONFIG_RT_USING_SAL is not set
#
# light weight TCP/IP stack
#
# CONFIG_RT_USING_LWIP is not set
#
# Modbus master and slave stack
#
# CONFIG_RT_USING_MODBUS is not set
#
# AT commands
#
# CONFIG_RT_USING_AT is not set
#
# VBUS(Virtual Software BUS)
#
# CONFIG_RT_USING_VBUS is not set
#
# Utilities
#
# CONFIG_RT_USING_LOGTRACE is not set
# CONFIG_RT_USING_RYM is not set
CONFIG_RT_USING_ULOG=y
# CONFIG_ULOG_OUTPUT_LVL_A is not set
# CONFIG_ULOG_OUTPUT_LVL_E is not set
# CONFIG_ULOG_OUTPUT_LVL_W is not set
# CONFIG_ULOG_OUTPUT_LVL_I is not set
CONFIG_ULOG_OUTPUT_LVL_D=y
CONFIG_ULOG_OUTPUT_LVL=7
CONFIG_ULOG_USING_ISR_LOG=y
CONFIG_ULOG_ASSERT_ENABLE=y
CONFIG_ULOG_LINE_BUF_SIZE=128
# CONFIG_ULOG_USING_ASYNC_OUTPUT is not set
#
# log format
#
# CONFIG_ULOG_OUTPUT_FLOAT is not set
CONFIG_ULOG_USING_COLOR=y
CONFIG_ULOG_OUTPUT_TIME=y
# CONFIG_ULOG_TIME_USING_TIMESTAMP is not set
CONFIG_ULOG_OUTPUT_LEVEL=y
CONFIG_ULOG_OUTPUT_TAG=y
# CONFIG_ULOG_OUTPUT_THREAD_NAME is not set
CONFIG_ULOG_BACKEND_USING_CONSOLE=y
# CONFIG_ULOG_USING_FILTER is not set
# CONFIG_ULOG_USING_SYSLOG is not set
CONFIG_ULOG_SW_VERSION_NUM=0x00101
#
# RT-Thread online packages
#
#
# IoT - internet of things
#
# CONFIG_PKG_USING_PAHOMQTT is not set
# CONFIG_PKG_USING_WEBCLIENT is not set
# CONFIG_PKG_USING_WEBNET is not set
# CONFIG_PKG_USING_MONGOOSE is not set
# CONFIG_PKG_USING_WEBTERMINAL is not set
# CONFIG_PKG_USING_CJSON is not set
# CONFIG_PKG_USING_JSMN is not set
# CONFIG_PKG_USING_LJSON is not set
# CONFIG_PKG_USING_EZXML is not set
# CONFIG_PKG_USING_NANOPB is not set
#
# Wi-Fi
#
#
# Marvell WiFi
#
# CONFIG_PKG_USING_WLANMARVELL is not set
#
# Wiced WiFi
#
# CONFIG_PKG_USING_WLAN_WICED is not set
# CONFIG_PKG_USING_COAP is not set
# CONFIG_PKG_USING_NOPOLL is not set
# CONFIG_PKG_USING_NETUTILS is not set
# CONFIG_PKG_USING_AT_DEVICE is not set
# CONFIG_PKG_USING_WIZNET is not set
#
# IoT Cloud
#
# CONFIG_PKG_USING_ONENET is not set
# CONFIG_PKG_USING_GAGENT_CLOUD is not set
# CONFIG_PKG_USING_ALI_IOTKIT is not set
# CONFIG_PKG_USING_AZURE is not set
# CONFIG_PKG_USING_TENCENT_IOTKIT is not set
#
# security packages
#
# CONFIG_PKG_USING_MBEDTLS is not set
# CONFIG_PKG_USING_libsodium is not set
# CONFIG_PKG_USING_TINYCRYPT is not set
#
# language packages
#
# CONFIG_PKG_USING_LUA is not set
# CONFIG_PKG_USING_JERRYSCRIPT is not set
CONFIG_PKG_USING_MICROPYTHON=y
CONFIG_PKG_MICROPYTHON_PATH="/packages/language/micropython"
#
# Hardware Module
#
# CONFIG_MICROPYTHON_USING_MACHINE_I2C is not set
# CONFIG_MICROPYTHON_USING_MACHINE_SPI is not set
CONFIG_MICROPYTHON_USING_MACHINE_UART=y
#
# System Module
#
CONFIG_MICROPYTHON_USING_UOS=y
CONFIG_MICROPYTHON_USING_THREAD=y
# CONFIG_MICROPYTHON_USING_USELECT is not set
# CONFIG_MICROPYTHON_USING_UCTYPES is not set
# CONFIG_MICROPYTHON_USING_UERRNO is not set
#
# Tools Module
#
# CONFIG_MICROPYTHON_USING_CMATH is not set
# CONFIG_MICROPYTHON_USING_UBINASCII is not set
# CONFIG_MICROPYTHON_USING_UHASHLIB is not set
# CONFIG_MICROPYTHON_USING_UHEAPQ is not set
CONFIG_MICROPYTHON_USING_UJSON=y
# CONFIG_MICROPYTHON_USING_URE is not set
# CONFIG_MICROPYTHON_USING_UZLIB is not set
# CONFIG_MICROPYTHON_USING_URANDOM is not set
#
# Network Module
#
# CONFIG_MICROPYTHON_USING_USOCKET is not set
# CONFIG_MICROPYTHON_USING_USSL is not set
CONFIG_PKG_MICROPYTHON_HEAP_SIZE=8192
CONFIG_PKG_USING_MICROPYTHON_LATEST_VERSION=y
# CONFIG_PKG_USING_MICROPYTHON_V10903 is not set
CONFIG_PKG_MICROPYTHON_VER="latest"
#
# multimedia packages
#
# CONFIG_PKG_USING_OPENMV is not set
# CONFIG_PKG_USING_MUPDF is not set
#
# tools packages
#
# CONFIG_PKG_USING_CMBACKTRACE is not set
# CONFIG_PKG_USING_EASYFLASH is not set
# CONFIG_PKG_USING_EASYLOGGER is not set
# CONFIG_PKG_USING_SYSTEMVIEW is not set
# CONFIG_PKG_USING_RDB is not set
# CONFIG_PKG_USING_QRCODE is not set
# CONFIG_PKG_USING_ULOG_EASYFLASH is not set
#
# system packages
#
# CONFIG_PKG_USING_GUIENGINE is not set
# CONFIG_PKG_USING_CAIRO is not set
# CONFIG_PKG_USING_PIXMAN is not set
# CONFIG_PKG_USING_LWEXT4 is not set
# CONFIG_PKG_USING_PARTITION is not set
# CONFIG_PKG_USING_FAL is not set
# CONFIG_PKG_USING_SQLITE is not set
# CONFIG_PKG_USING_RTI is not set
# CONFIG_PKG_USING_LITTLEVGL2RTT is not set
# CONFIG_PKG_USING_CMSIS is not set
# CONFIG_PKG_USING_DFS_YAFFS is not set
# CONFIG_PKG_USING_LITTLEFS is not set
#
# peripheral libraries and drivers
#
# CONFIG_PKG_USING_REALTEK_AMEBA is not set
# CONFIG_PKG_USING_SHT2X is not set
# CONFIG_PKG_USING_AHT10 is not set
# CONFIG_PKG_USING_AP3216C is not set
# CONFIG_PKG_USING_STM32_SDIO is not set
# CONFIG_PKG_USING_ICM20608 is not set
# CONFIG_PKG_USING_U8G2 is not set
# CONFIG_PKG_USING_BUTTON is not set
# CONFIG_PKG_USING_MPU6XXX is not set
# CONFIG_PKG_USING_PCF8574 is not set
# CONFIG_PKG_USING_KENDRYTE_SDK is not set
#
# miscellaneous packages
#
# CONFIG_PKG_USING_LIBCSV is not set
# CONFIG_PKG_USING_OPTPARSE is not set
# CONFIG_PKG_USING_FASTLZ is not set
# CONFIG_PKG_USING_MINILZO is not set
# CONFIG_PKG_USING_QUICKLZ is not set
# CONFIG_PKG_USING_MULTIBUTTON is not set
# CONFIG_PKG_USING_CANFESTIVAL is not set
# CONFIG_PKG_USING_ZLIB is not set
# CONFIG_PKG_USING_DSTR is not set
# CONFIG_PKG_USING_TINYFRAME is not set
#
# sample package
#
#
# samples: kernel and components samples
#
# CONFIG_PKG_USING_KERNEL_SAMPLES is not set
# CONFIG_PKG_USING_FILESYSTEM_SAMPLES is not set
# CONFIG_PKG_USING_NETWORK_SAMPLES is not set
# CONFIG_PKG_USING_PERIPHERAL_SAMPLES is not set
#
# example package: hello
#
# CONFIG_PKG_USING_HELLO is not set
#
# Privated Packages of RealThread
#
# CONFIG_PKG_USING_CODEC is not set
# CONFIG_PKG_USING_PLAYER is not set
# CONFIG_PKG_USING_PERSIMMON_SRC is not set
# CONFIG_PKG_USING_JS_PERSIMMON is not set
# CONFIG_PKG_USING_JERRYSCRIPT_WIN32 is not set
#
# Network Utilities
#
# CONFIG_PKG_USING_WICED is not set
# CONFIG_PKG_USING_CLOUDSDK is not set
# CONFIG_PKG_USING_COREMARK is not set
# CONFIG_PKG_USING_POWER_MANAGER is not set
# CONFIG_PKG_USING_RT_OTA is not set
# CONFIG_PKG_USING_RDBD_SRC is not set
# CONFIG_PKG_USING_RTINSIGHT is not set
# CONFIG_PKG_USING_SMARTCONFIG is not set
# CONFIG_PKG_USING_RTX is not set

32
bsp/juicevm/Kconfig Executable file
View File

@ -0,0 +1,32 @@
mainmenu "RT-Thread Project Configuration"
config BSP_DIR
string
option env="BSP_ROOT"
default "."
config RTT_DIR
string
option env="RTT_ROOT"
default "../../.."
config PKGS_DIR
string
option env="PKGS_ROOT"
default "packages"
source "$RTT_DIR/Kconfig"
source "$PKGS_DIR/Kconfig"
config SOC_JUICEVM_RV64
bool
select ARCH_RISCV
config BOARD_RV64_FRDM_JUICEVM
bool
select SOC_JUICEVM_RV64
select RT_USING_COMPONENTS_INIT
select RT_USING_USER_MAIN
default y
source "driver/Kconfig"

14
bsp/juicevm/SConscript Executable file
View File

@ -0,0 +1,14 @@
# for module compiling
import os
from building import *
cwd = GetCurrentDir()
objs = []
list = os.listdir(cwd)
for d in list:
path = os.path.join(cwd, d)
if os.path.isfile(os.path.join(path, 'SConscript')):
objs = objs + SConscript(os.path.join(d, 'SConscript'))
Return('objs')

36
bsp/juicevm/SConstruct Executable file
View File

@ -0,0 +1,36 @@
import os
import sys
import rtconfig
from rtconfig import RTT_ROOT
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
from building import *
TARGET = 'rtthread.' + rtconfig.TARGET_EXT
DefaultEnvironment(tools=[])
env = Environment(tools = ['mingw'],
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
AR = rtconfig.AR, ARFLAGS = '-rc',
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
env['ASCOM'] = env['ASPPCOM']
Export('RTT_ROOT')
Export('rtconfig')
# prepare building environment
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu = False)
stack_size = 4096
stack_lds = open('link_stacksize.lds', 'w')
if GetDepend('__STACKSIZE__'): stack_size = GetDepend('__STACKSIZE__')
stack_lds.write('__STACKSIZE__ = %d;' % stack_size)
stack_lds.close()
# make a building
DoBuilding(TARGET, objs)

View File

@ -0,0 +1,9 @@
from building import *
cwd = GetCurrentDir()
src = Glob('*.c') + Glob('*.cpp')
CPPPATH = [cwd]
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
Return('group')

20
bsp/juicevm/applications/main.c Executable file
View File

@ -0,0 +1,20 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021/04/26 Juice The first version
*/
#include <stdio.h>
#include <stdlib.h>
#include <rtthread.h>
int main(int argc, char **argv)
{
rt_kprintf("Hello RT-Thread!\n");
return 0;
}

13
bsp/juicevm/board/SConscript Executable file
View File

@ -0,0 +1,13 @@
# RT-Thread building script for component
from building import *
cwd = GetCurrentDir()
src = Split('''
board.c
''')
CPPPATH = [cwd]
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)
Return('group')

38
bsp/juicevm/board/board.c Executable file
View File

@ -0,0 +1,38 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021/04/22 Juice the first version
*/
#include <rthw.h>
#include <rtthread.h>
#include "board.h"
#include "drv_uart.h"
void rt_hw_board_init(void)
{
/* initialize hardware interrupt */
rt_hw_uart_init();
// rt_hw_systick_init();
#ifdef RT_USING_CONSOLE
/* set console device */
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
#endif /* RT_USING_CONSOLE */
#ifdef RT_USING_HEAP
rt_kprintf("heap: [0x%08x - 0x%08x]\n", (rt_ubase_t) RT_HW_HEAP_BEGIN, (rt_ubase_t) RT_HW_HEAP_END);
/* initialize memory system */
rt_system_heap_init(RT_HW_HEAP_BEGIN, RT_HW_HEAP_END);
#endif
#ifdef RT_USING_COMPONENTS_INIT
rt_components_board_init();
#endif
}

24
bsp/juicevm/board/board.h Executable file
View File

@ -0,0 +1,24 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-04-24 Juice the first version
*/
#ifndef __BOARD_H__
#define __BOARD_H__
#include <stdint.h>
extern unsigned int __bss_start;
extern unsigned int __bss_end;
#define RT_HW_HEAP_BEGIN (void*)&__bss_end
#define RT_HW_HEAP_END (void*)(0x80000000 + 300 * 1024 * 1024)
void rt_hw_board_init(void);
#endif

3
bsp/juicevm/driver/Kconfig Executable file
View File

@ -0,0 +1,3 @@
config BSP_USING_UART0
bool "Enable UART0"
default y

13
bsp/juicevm/driver/SConscript Executable file
View File

@ -0,0 +1,13 @@
# RT-Thread building script for component
from building import *
cwd = GetCurrentDir()
src = Split('''
drv_uart.c
''')
CPPPATH = [cwd]
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)
Return('group')

137
bsp/juicevm/driver/drv_uart.c Executable file
View File

@ -0,0 +1,137 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021/04/22 Juice Add UART0 support for JuiceVm.
*/
#include <rthw.h>
#include <rtthread.h>
#include <rtdevice.h>
#include "board.h"
#include "drv_uart.h"
#include "rv_mtvec_map.h"
struct rt_serial_device *serial;
char *device_name = "uart0";
static rt_err_t uart_configure(struct rt_serial_device *serial, struct serial_configure *cfg);
static rt_err_t uart_control(struct rt_serial_device *serial, int cmd, void *arg);
static int uart_putc(struct rt_serial_device *serial, char c);
static int uart_getc(struct rt_serial_device *serial);
static rt_size_t uart_dma_transmit(struct rt_serial_device *serial, rt_uint8_t *buf, rt_size_t size, int direction);
void UART0_DriverIRQHandler(void);
const struct rt_uart_ops _uart_ops =
{
uart_configure,
uart_control,
uart_putc,
uart_getc,
uart_dma_transmit
};
static void uart_isr(struct rt_serial_device *serial);
#if defined(BSP_USING_UART0)
struct rt_serial_device serial0;
void UART0_DriverIRQHandler(void)
{
uart_isr(&serial0);
}
#endif
/*
* UART Initiation
*/
int rt_hw_uart_init(void)
{
int i;
struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT;
serial = &serial0;
serial->ops = &_uart_ops;
serial->config = config;
/* register UART device */
rt_hw_serial_register(serial,
device_name,
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
(void *)0);
return 0;
}
/*
* UART interface
*/
static rt_err_t uart_configure(struct rt_serial_device *serial, struct serial_configure *cfg)
{
RT_ASSERT(serial != RT_NULL);
RT_ASSERT(cfg != RT_NULL);
return RT_EOK;
}
static rt_err_t uart_control(struct rt_serial_device *serial, int cmd, void *arg)
{
RT_ASSERT(serial != RT_NULL);
return RT_EOK;
}
static int uart_putc(struct rt_serial_device *serial, char c)
{
RT_ASSERT(serial != RT_NULL);
*((char *)(pdev_uart0_write_addr)) = c;
return (1);
}
static int uart_getc(struct rt_serial_device *serial)
{
int ch;
RT_ASSERT(serial != RT_NULL);
ch = -1;
if (*(char *)(pdev_uart0_state_addr) == pdev_uart0_readbusy_state)
{
ch = *(char *)(pdev_uart0_read_addr);
*(char *)(pdev_uart0_state_addr) = pdev_uart0_free_state;
}
return ch;
}
static rt_size_t uart_dma_transmit(struct rt_serial_device *serial, rt_uint8_t *buf, rt_size_t size, int direction)
{
return (0);
}
/* UART ISR */
/**
* Uart common interrupt process. This need add to uart ISR.
*
* @param serial serial device
*/
static void uart_isr(struct rt_serial_device *serial)
{
RT_ASSERT(serial != RT_NULL);
if (*(char *)(pdev_uart0_state_addr) == pdev_uart0_readbusy_state)
{
rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND);
}
}

15
bsp/juicevm/driver/drv_uart.h Executable file
View File

@ -0,0 +1,15 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
*/
#ifndef __DRV_UART_H__
#define __DRV_UART_H__
int rt_hw_uart_init(void);
#endif /* __DRV_UART_H__ */

View File

@ -0,0 +1,22 @@
# RT-Thread building script for component
from building import *
cwd = GetCurrentDir()
src = Split('''
system.c
''')
CPPPATH = [cwd]
group = DefineGroup('JuiceVm_sdk', src, depend = [''], CPPPATH = CPPPATH)
objs = [group]
list = os.listdir(cwd)
for item in list:
if os.path.isfile(os.path.join(cwd, item, 'SConscript')):
objs = objs + SConscript(os.path.join(item, 'SConscript'))
Return('objs')

View File

@ -0,0 +1,106 @@
/*
* Copyright (c) 2006-2021, JuiceVm Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021/04/22 Juice the first version
*/
#ifndef __RV_CONFIG_H__
#define __RV_CONFIG_H__
#define RV64I_SUPPORT_ENBALE
#define RV64_MMU_ENBALE 1
#define RV_ENDLESS_LOOP_CHECK_ENBALE 1
#if defined(RV_ENDLESS_LOOP_CHECK_ENBALE) && RV_ENDLESS_LOOP_CHECK_ENBALE == 1
#define RV_ENDLESS_LOOP_CHECK_BUF_SIZE (30)
#define RV_ENDLESS_LOOP_CHECK_EXIT_CNT (3)
#define RV_ENDLESS_LOOP_CHECK_MD5_HASH 1
#endif
// #define RISCV_ANGEL_ONLY
#define Machine_Mode_SUPPORT
#define Supervisor_Mode_SUPPORT
// #define User_Mode_SUPPORT
// #define Hypervisor_Mode_SUPPORT
#define ATOMIC_Module_SUPPORT
#define RV_CPU_CSR_DEF_Vendor_ID 0
#define RV_CPU_CSR_DEF_March_ID 0
#define RV_CPU_CSR_DEF_Mimp_ID 0
#define RV_CPU_CSR_DEF_Mhart_ID 0
#define JUICE_VM_LOG_MAX_NUM (600)
#define JUICE_VM_INC_CHANGELOG 0
#define RAM_SIZE_KB (1024)
#define RAM_SIZE_MB (1024*RAM_SIZE_KB)
#define RV_CPU_SIM_RAM_START_ADDR (0x80000000)
#define RV_CPU_SIM_RAM_SIZE (300 * RAM_SIZE_MB)
#define RV_CPU_SIM_CAUSETABLE_MAX_NUM 100//MXLEN-1 bit
#define RV_CPU_SIM_PERDEV_NUM 50
#define rv_peripheral_device_add_check_dev 1
// | MXLEN-1 MXLEN-2 | MXLEN-3 26| 25 0 |
// | MXL[1:0](WARL) | WLRL | Extensions[25:0] (WARL) |
// | 2 | MXLEN-28 | 26 |
// Figure 3.1: Machine ISA register (misa).
// Bit | Character | Description
// 0 | A | Atomic extension
// 1 | B | Tentatively reserved for Bit-Manipulation extension
// 2 | C | Compressed extension
// 3 | D | Double-precision floating-point extension
// 4 | E | RV32E base ISA
// 5 | F | Single-precision floating-point extension
// 6 | G | Reserved
// 7 | H | Hypervisor extension
// 8 | I | RV32I/64I/128I base ISA
// 9 | J | Tentatively reserved for Dynamically Translated Languages extension
// 10 | K | Reserved
// 11 | L | Tentatively reserved for Decimal Floating-Point extension
// 12 | M | Integer Multiply/Divide extension
// 13 | N | User-level interrupts supported
// 14 | O | Reserved
// 15 | P | Tentatively reserved for Packed-SIMD extension
// 16 | Q | Quad-precision floating-point extension
// 17 | R | Reserved
// 18 | S | Supervisor mode implemented
// 19 | T | Tentatively reserved for Transactional Memory extension
// 20 | U | User mode implemented
// 21 | V | Tentatively reserved for Vector extension
// 22 | W | Reserved
// 23 | X | Non-standard extensions present
// 24 | Y | Reserved
// 25 | Z | Reserved
#define RV_MISA_ATOMIC_EXT (1<<0)
#define RV_MISA_INTEGER_EXT (1<<8)
#define RV_MISA_UMODE_INT_EXT (1<<13)
#define RV_MISA_SMODE_IMP_EXT (1<<18)
#define RV_MISA_UMODE_IMP_EXT (1<<20)
// | MXL | XLEN |
// | 1 | 32 |
// | 2 | 64 |
// | 3 | 128 |
#define RV_MISA_XLEN_32 (1<<(32-2))
#define RV_MISA_XLEN_64 (uint64_t)((uint64_t)(2)<<(64-2))
// #define RV_MISA_XLEN_128 ((uint128_t)(3)<<(128-2))
#define RV_MISA_CSR_REGISTER ((uint64_t)(RV_MISA_XLEN_64 | RV_MISA_ATOMIC_EXT | RV_MISA_INTEGER_EXT /*| RV_MISA_UMODE_INT_EXT*/ | RV_MISA_SMODE_IMP_EXT /*| RV_MISA_UMODE_IMP_EXT*/))
#endif // __RV_CONFIG_H__

View File

@ -0,0 +1,131 @@
/*
* Copyright (c) 2006-2021, JuiceVm Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021/04/22 Juice the first version
*/
#ifndef __RV_MTVEC_MAP_H__
#define __RV_MTVEC_MAP_H__
#include "rv_config.h"
#define rv_sim_pdev_base_addr (RV_CPU_SIM_RAM_START_ADDR+RV_CPU_SIM_RAM_SIZE)
#define rv_sim_pdev_uart0_base_addr (rv_sim_pdev_base_addr)
#define pdev_uart0_write_addr (rv_sim_pdev_uart0_base_addr)
#define pdev_uart0_read_addr (rv_sim_pdev_uart0_base_addr+1)
#define pdev_uart0_free_state 0x00
#define pdev_uart0_readbusy_state 0x01
#define pdev_uart0_state_addr (rv_sim_pdev_uart0_base_addr+2)
#define rv_sim_pdev_mtime_base_addr (rv_sim_pdev_base_addr+3)
#define pdev_mtime_mtime_addr (rv_sim_pdev_mtime_base_addr)
#define pdev_mtime_mtimecmp_addr (rv_sim_pdev_mtime_base_addr+4)
#define uart0_irq_flag 0
#define uart0_irq_ecode 24
#define RV_exception_Instruction_address_misaligned_IFLAG 0
#define RV_exception_Instruction_address_misaligned_ECODE 0
#define RV_exception_Instruction_access_fault_IFLAG 0
#define RV_exception_Instruction_access_fault_ECODE 1
#define RV_exception_Illegal_Instruction_IFLAG 0
#define RV_exception_Illegal_Instruction_ECODE 2
#define RV_exception_Breakpoint_IFLAG 0
#define RV_exception_Breakpoint_ECODE 3
#define RV_exception_LoadAddress_Misaligned_IFLAG 0
#define RV_exception_LoadAddress_Misaligned_ECODE 4
#define RV_exception_Load_access_fault_IFLAG 0
#define RV_exception_Load_access_fault_ECODE 5
#define RV_exception_Store_or_AMO_Address_Misaligned_IFLAG 0
#define RV_exception_Store_or_AMO_Address_Misaligned_ECODE 6
#define RV_exception_Store_or_AMO_access_fault_IFLAG 0
#define RV_exception_Store_or_AMO_access_fault_ECODE 7
#define RV_exception_Environment_call_from_Umode_IFLAG 0
#define RV_exception_Environment_call_from_Umode_ECODE 8
#define RV_exception_Environment_call_from_Smode_IFLAG 0
#define RV_exception_Environment_call_from_Smode_ECODE 9
#define RV_exception_Environment_Call_FromMachine_IFLAG 0
#define RV_exception_Environment_Call_FromMachine_ECODE 11
#define RV_exception_FloatingPoint_Disabled_IFLAG
#define RV_exception_FloatingPoint_Disabled_ECODE
#define RV_exception_Instruction_page_fault_IFLAG 0
#define RV_exception_Instruction_page_fault_ECODE 12
#define RV_exception_Load_page_fault_IFLAG 0
#define RV_exception_Load_page_fault_ECODE 13
#define RV_exception_Store_or_AMO_page_fault_IFLAG 0
#define RV_exception_Store_or_AMO_page_fault_ECODE 15
// Interrupt Exception Code Description
// 1 0 Reserved
// 1 1 Supervisor software interrupt not support
// 1 2 Reserved
// 1 3 Machine software interrupt not support
// 1 4 Reserved
// 1 5 Supervisor timer interrupt not support
// 1 6 Reserved
// 1 7 Machine timer interrupt support
// 1 8 Reserved
// 1 9 Supervisor external interrupt not support
// 1 10 Reserved
// 1 11 Machine external interrupt not support
// 1 12 Reserved
// 1 13 Reserved
// 1 14 Reserved
// 1 15 Reserved
// // 1 ≥16 Designated for platform use
// 0 0 Instruction address misaligned not support
// 0 1 Instruction access fault not support
// 0 2 Illegal instruction support
// 0 3 Breakpoint support
// 0 4 Load address misaligned support
// 0 5 Load access fault not support
// 0 6 Store/AMO address misaligned support
// 0 7 Store/AMO access fault not support
// 0 8 Environment call from U-mode not support
// 0 9 Environment call from S-mode not support
// 0 10 Reserved
// 0 11 Environment call from M-mode support
// 0 12 Instruction page fault not support
// 0 13 Load page fault not support
// 0 14 Reserved
// 0 15 Store/AMO page fault not support
// 0 16-23 Reserved
// // 0 2431 Designated for custom use
// 0 32-47 Reserved
// // 0 4863 Designated for custom use
// 0 ≥64 Reserved
// #define mtime_irq_flag 1
// #define mtime_irq_ecode 7
#define RV_Supervisor_software_interrupt_IFLAG 1
#define RV_Supervisor_software_interrupt_ECODE 1
#define RV_Machine_software_interrupt_IFLAG 1
#define RV_Machine_software_interrupt_ECODE 3
#define RV_Supervisor_timer_interrupt_IFLAG 1
#define RV_Supervisor_timer_interrupt_ECODE 5
#define RV_Machine_timer_interrupt_IFLAG 1
#define RV_Machine_timer_interrupt_ECODE 7
#define RV_Supervisor_external_interrupt_IFLAG 1
#define RV_Supervisor_external_interrupt_ECODE 9
#define RV_Machine_external_interrupt_IFLAG 1
#define RV_Machine_external_interrupt_ECODE 10
#endif // __RV_MTVEC_MAP_H__

View File

@ -0,0 +1,47 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021/04/22 Juice Add isrtable for JuiceVm.
*/
typedef void (*irq_handler_t)(void);
// #define DEFINE_IRQ_HANDLER(irq_handler, driver_irq_handler) \
// void __attribute__((weak)) irq_handler(void) { driver_irq_handler();}
// #define DEFINE_DEFAULT_IRQ_HANDLER(irq_handler) void irq_handler() __attribute__((weak, alias("DefaultIRQHandler")))
// DEFINE_IRQ_HANDLER(UART0_IRQHandler, UART0_DriverIRQHandler);
extern void UART0_DriverIRQHandler(void);
const irq_handler_t isrTable[] =
{
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
UART0_DriverIRQHandler, // uart0_irq_ecode = 24
};

161
bsp/juicevm/link.lds Executable file
View File

@ -0,0 +1,161 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
*/
INCLUDE "link_stacksize.lds"
/*
* The OUTPUT_ARCH command specifies the machine architecture where the
* argument is one of the names used in the Kendryte library.
*/
OUTPUT_ARCH( "riscv" )
MEMORY
{
/* 300M SRAM */
SRAM : ORIGIN = 0x80000000, LENGTH = 0x12c00000
}
ENTRY(_start)
SECTIONS
{
. = 0x80000000 ;
/* __STACKSIZE__ = 4096; */
.start :
{
*(.start);
} > SRAM
. = ALIGN(8);
.text :
{
*(.text) /* remaining code */
*(.text.*) /* remaining code */
*(.rodata) /* read-only data (constants) */
*(.rodata*)
*(.glue_7)
*(.glue_7t)
*(.gnu.linkonce.t*)
/* section information for finsh shell */
. = ALIGN(8);
__fsymtab_start = .;
KEEP(*(FSymTab))
__fsymtab_end = .;
. = ALIGN(8);
__vsymtab_start = .;
KEEP(*(VSymTab))
__vsymtab_end = .;
. = ALIGN(8);
/* section information for initial. */
. = ALIGN(8);
__rt_init_start = .;
KEEP(*(SORT(.rti_fn*)))
__rt_init_end = .;
. = ALIGN(8);
__rt_utest_tc_tab_start = .;
KEEP(*(UtestTcTab))
__rt_utest_tc_tab_end = .;
. = ALIGN(8);
_etext = .;
} > SRAM
.eh_frame_hdr :
{
*(.eh_frame_hdr)
*(.eh_frame_entry)
} > SRAM
.eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } > SRAM
. = ALIGN(8);
.data :
{
*(.data)
*(.data.*)
*(.data1)
*(.data1.*)
. = ALIGN(8);
PROVIDE( __global_pointer$ = . + 0x800 );
*(.sdata)
*(.sdata.*)
} > SRAM
/* stack for dual core */
.stack :
{
. = ALIGN(64);
__stack_start__ = .;
. += __STACKSIZE__;
__stack = .;
} > SRAM
.sbss :
{
__bss_start = .;
*(.sbss)
*(.sbss.*)
*(.dynsbss)
*(.scommon)
} > SRAM
.bss :
{
*(.bss)
*(.bss.*)
*(.dynbss)
*(COMMON)
__bss_end = .;
} > SRAM
_end = .;
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
* Symbols in the DWARF debugging sections are relative to the beginning
* of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
}

1
bsp/juicevm/link_stacksize.lds Executable file
View File

@ -0,0 +1 @@
__STACKSIZE__ = 4096;

218
bsp/juicevm/rtconfig.h Executable file
View File

@ -0,0 +1,218 @@
#ifndef RT_CONFIG_H__
#define RT_CONFIG_H__
/* Automatically generated file; DO NOT EDIT. */
/* RT-Thread Project Configuration */
/* RT-Thread Kernel */
#define RT_NAME_MAX 8
#define RT_ALIGN_SIZE 4
#define RT_THREAD_PRIORITY_32
#define RT_THREAD_PRIORITY_MAX 32
#define RT_TICK_PER_SECOND 100
#define RT_USING_OVERFLOW_CHECK
#define RT_USING_HOOK
#define RT_USING_IDLE_HOOK
#define RT_IDLE_HOOK_LIST_SIZE 4
#define IDLE_THREAD_STACK_SIZE 1024
#define RT_DEBUG
#define RT_DEBUG_COLOR
/* Inter-Thread communication */
#define RT_USING_SEMAPHORE
#define RT_USING_MUTEX
#define RT_USING_EVENT
#define RT_USING_MAILBOX
#define RT_USING_MESSAGEQUEUE
/* Memory Management */
#define RT_USING_MEMPOOL
#define RT_USING_SMALL_MEM
#define RT_USING_HEAP
/* Kernel Device Object */
#define RT_USING_DEVICE
#define RT_USING_CONSOLE
#define RT_CONSOLEBUF_SIZE 128
#define RT_CONSOLE_DEVICE_NAME "uart0"
#define RT_VER_NUM 0x40000
#define ARCH_CPU_64BIT
#define ARCH_RISCV
#define ARCH_RISCV64
/* RT-Thread Components */
#define RT_USING_COMPONENTS_INIT
#define RT_USING_USER_MAIN
#define RT_MAIN_THREAD_STACK_SIZE 2048
#define RT_MAIN_THREAD_PRIORITY 10
/* C++ features */
/* Command shell */
#define RT_USING_FINSH
#define FINSH_THREAD_NAME "tshell"
#define FINSH_USING_HISTORY
#define FINSH_HISTORY_LINES 5
#define FINSH_USING_SYMTAB
#define FINSH_USING_DESCRIPTION
#define FINSH_THREAD_PRIORITY 20
#define FINSH_THREAD_STACK_SIZE 4096
#define FINSH_CMD_SIZE 80
#define FINSH_USING_MSH
#define FINSH_USING_MSH_DEFAULT
#define FINSH_USING_MSH_ONLY
#define FINSH_ARG_MAX 10
/* Device virtual file system */
// #define RT_USING_DFS
// #define DFS_USING_WORKDIR
// #define DFS_FILESYSTEMS_MAX 4
// #define DFS_FILESYSTEM_TYPES_MAX 4
// #define DFS_FD_MAX 16
// #define RT_USING_DFS_ELMFAT
/* elm-chan's FatFs, Generic FAT Filesystem Module */
// #define RT_DFS_ELM_CODE_PAGE 437
// #define RT_DFS_ELM_WORD_ACCESS
// #define RT_DFS_ELM_USE_LFN_3
// #define RT_DFS_ELM_USE_LFN 3
// #define RT_DFS_ELM_MAX_LFN 255
// #define RT_DFS_ELM_DRIVES 2
// #define RT_DFS_ELM_MAX_SECTOR_SIZE 512
// #define RT_DFS_ELM_REENTRANT
// #define RT_USING_DFS_DEVFS
/* Device Drivers */
#define RT_USING_DEVICE_IPC
#define RT_PIPE_BUFSZ 512
#define RT_USING_SERIAL
/* Using WiFi */
/* Using USB */
/* POSIX layer and C standard library */
#define RT_USING_LIBC
// #define RT_USING_POSIX
/* Network */
/* Socket abstraction layer */
/* light weight TCP/IP stack */
/* Modbus master and slave stack */
/* AT commands */
/* VBUS(Virtual Software BUS) */
/* Utilities */
#define RT_USING_ULOG
#define ULOG_OUTPUT_LVL_D
#define ULOG_OUTPUT_LVL 7
#define ULOG_USING_ISR_LOG
#define ULOG_ASSERT_ENABLE
#define ULOG_LINE_BUF_SIZE 128
/* log format */
#define ULOG_USING_COLOR
#define ULOG_OUTPUT_TIME
#define ULOG_OUTPUT_LEVEL
#define ULOG_OUTPUT_TAG
#define ULOG_BACKEND_USING_CONSOLE
#define ULOG_SW_VERSION_NUM 0x00101
/* RT-Thread online packages */
/* IoT - internet of things */
/* Wi-Fi */
/* Marvell WiFi */
/* Wiced WiFi */
/* IoT Cloud */
/* security packages */
/* language packages */
#define PKG_USING_MICROPYTHON
/* Hardware Module */
#define MICROPYTHON_USING_MACHINE_UART
/* System Module */
#define MICROPYTHON_USING_UOS
#define MICROPYTHON_USING_THREAD
/* Tools Module */
#define MICROPYTHON_USING_UJSON
/* Network Module */
#define PKG_MICROPYTHON_HEAP_SIZE 8192
#define PKG_USING_MICROPYTHON_LATEST_VERSION
/* multimedia packages */
/* tools packages */
/* system packages */
/* peripheral libraries and drivers */
/* miscellaneous packages */
/* sample package */
/* samples: kernel and components samples */
/* example package: hello */
/* Privated Packages of RealThread */
/* Network Utilities */
#define BSP_USING_UART0
#define __STACKSIZE__ 4096
#endif

59
bsp/juicevm/rtconfig.py Executable file
View File

@ -0,0 +1,59 @@
import os
# toolchains options
ARCH ='risc-v'
CPU ='juicevm'
CROSS_TOOL ='gcc'
if os.getenv('RTT_ROOT'):
RTT_ROOT = os.getenv('RTT_ROOT')
else:
RTT_ROOT = r'../..'
if os.getenv('RTT_CC'):
CROSS_TOOL = os.getenv('RTT_CC')
if CROSS_TOOL == 'gcc':
PLATFORM = 'gcc'
EXEC_PATH = r'/opt/riscv64-unknown-elf-gcc-8.3.0-2020.04.0-x86_64-linux-ubuntu14/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'
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'
DEVICE = ' -march=rv64ima -mabi=lp64 -mcmodel=medany'
CFLAGS = DEVICE + ' -fno-builtin -fno-exceptions -ffunction-sections -static'
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp'
LFLAGS = DEVICE + ' -nostartfiles -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,Reset_Handler -T link.lds'
CPATH = ''
LPATH = ''
if BUILD == 'debug':
CFLAGS += ' -O2 -Os -g'
AFLAGS += ' -g'
else:
CFLAGS += ' -O2 -Os'
CXXFLAGS = CFLAGS
DUMP_ACTION = OBJDUMP + ' -D -S $TARGET > rtt.asm\n'
POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n'
POST_ACTION += DUMP_ACTION
# POST_ACTION = SIZE + ' $TARGET \n'