forked from RT-Thread/rt-thread
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e4c3e6
commit f147f33
Showing
26 changed files
with
162,626 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
PREFIX = /home/zj/risc-v/riscv64-unknown-elf-gcc-20170612-x86_64-linux-centos6/bin/riscv64-unknown-elf- | ||
CC = $(PREFIX)gcc | ||
CPP = $(PREFIX)g++ | ||
AS = $(PREFIX)gcc | ||
AR = $(PREFIX)ar | ||
LINK = $(PREFIX)gcc | ||
SIZE = $(PREFIX)size | ||
OBJDUMP = $(PREFIX)objdump | ||
OBJCPY = $(PREFIX)objcopy | ||
GDB = $(PREFIX)gdb | ||
OPENOCD = /home/zj/risc-v/riscv-openocd-20170612-x86_64-linux-centos6/bin/openocd | ||
|
||
LIBS = | ||
DEVICE = -mcpu=arm926ej-s -ffunction-sections -fdata-sections | ||
CFLAGS = $(DEVICE) $(patsubst %, -I"%", $(CPATH)) | ||
CXXFLAGS= $(CFLAGS) | ||
AFLAGS = $(DEVICE) -c -x assembler-with-cpp | ||
LFLAGS = $(DEVICE) -Wl,-Map=$(TARGET).map,-cref,-u,Reset_Handler \ | ||
-T "ld" -nostartfiles $(patsubst %, -l%, $(LIBS)) \ | ||
$(patsubst %, -L"%", $(LPATH)) | ||
|
||
CPATH = | ||
LPATH = | ||
################################################################ | ||
BUILD = debug | ||
#BUILD = release | ||
#BUILD_LIB = yes | ||
BUILD_LIB = no | ||
################################################################ | ||
|
||
ifeq '$(BUILD)' 'debug' | ||
CFLAGS += -O0 -gdwarf-2 | ||
AFLAGS += -gdwarf-2 | ||
else | ||
CFLAGS += -O2 | ||
endif | ||
|
||
ROOT_DIR = $(shell pwd) | ||
SUB_DIR = ${shell ls -l "${ROOT_DIR}" | grep ^d | awk '{if($$9 != "build") print $$9 }'} | ||
################################################################ | ||
BUILD_DIR = $(ROOT_DIR)/build/$(BUILD) | ||
BUILD_LIB_DIR =$(LPATH) | ||
################################################################ | ||
TARGET = rtthread | ||
export CC CPP AS AR LINK SIZE OBJDUMP OBJCPY DEVICE CFLAGS CXXFLAGS ASFLAGS LFLAGS ROOT_DIR \ | ||
BUILD BUILD_DIR BUILD_LIB_DIR | ||
|
||
SRC_FILE = ${wildcard *.c} | ||
SRC_FILE += ${wildcard *.cpp} | ||
SRC_FILE += ${wildcard *.s} | ||
#SRC_FILE = ${shell ls *.c} | ||
#OBJ_FILE = ${SRC_FILE:.c=.o} | ||
TMP = ${patsubst %.c, %.o, ${SRC_FILE}} | ||
TMP += ${patsubst %.cpp, %.o, ${SRC_FILE}} | ||
TMP += ${patsubst %.s, %.o, ${SRC_FILE}} | ||
OBJ_FILE = $(filter %.o, $(TMP)) | ||
|
||
|
||
# Attempt to create a output directory. | ||
$(shell [ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR}) | ||
# Verify if it was successful. | ||
BUILD_DIR := $(shell cd $(BUILD_DIR) && /bin/pwd) | ||
$(if $(BUILD_DIR),,$(error output directory "$(saved-output)" does not exist)) | ||
|
||
#all: $(TARGET) | ||
all: | ||
scons -j4 | ||
#${SIZE} -d "$(TARGET).axf" | ||
${OBJDUMP} -S -D "$(TARGET).axf" > "${TARGET}.s" | ||
|
||
|
||
$(SUB_DIR):ECHO | ||
-make -C "${ROOT_DIR}/$@" | ||
|
||
%.o:%.cpp | ||
${CPP} ${CXXFLAGS} -c "$^" -o "${BUILD_DIR}/$@" | ||
|
||
%.o:%.c | ||
${CC} ${CFLAGS} -c "$^" -o "${BUILD_DIR}/$@" | ||
|
||
%.o:%.s | ||
${AS} ${ASFLAGS} -c "$^" -o "${BUILD_DIR}/$@" | ||
|
||
ifneq "$(BUILD_LIB)" "yes" | ||
|
||
$(TARGET): $(SUB_DIR) $(OBJ_FILE) | ||
cd "${BUILD_DIR}" && ${CC} $(filter %.o, $(shell ls "$(BUILD_DIR)")) ${LFLAGS} -o "$(ROOT_DIR)/$(TARGET)" | ||
${OBJCPY} -I elf32-littlearm -O ihex $(TARGET) $(TARGET).hex | ||
${OBJCPY} -I elf32-littlearm -O binary $(TARGET) $(TARGET).bin | ||
${SIZE} -d "$(TARGET)" | ||
|
||
else | ||
|
||
$(TARGET): $(SUB_DIR) $(OBJ_FILE) | ||
cd "${BUILD_DIR}" && ${AR} -rc "$(BUILD_LIB_DIR)/lib${TARGET}.a" $(filter %.o, $(shell ls "$(BUILD_DIR)")) | ||
|
||
endif | ||
|
||
ECHO: | ||
@echo ${SUB_DIR} | ||
|
||
|
||
DEBUG_INTERFACE = jlink | ||
#DEBUG_INTERFACE = stlink-v2 | ||
#DEBUG_INTERFACE = ftdi/openjtag | ||
|
||
|
||
run: | ||
setsid ${OPENOCD} > /dev/null 2>&1 & | ||
# (sleep 1 && echo -e "halt" && sleep 1) | telnet 127.0.0.1 4444 | ||
${GDB} ${TARGET}.axf -ex "tar ext 127.0.0.1:3333" -ex "monitor reset halt" \ | ||
-ex "monitor step 0x20400000" | ||
# arm-none-eabi-gdb ${TARGET} -ex "tar ext 127.0.0.1:3333" -ex "b main" -ex "lay n" -ex "lay n" -ex "lay n" | ||
pid=`ps -C openocd -o pid --noheader` && kill -9 $$pid | ||
|
||
programe: | ||
setsid ${OPENOCD} > /dev/null 2>&1 & | ||
${GDB} ${TARGET}.axf -ex "tar ext 127.0.0.1:3333" -ex "load ${TARGET}.axf" | ||
pid=`ps -C openocd -o pid --noheader` && kill -9 $$pid | ||
|
||
clean: | ||
-cd "${BUILD_DIR}" && rm * | ||
-rm stm32* | ||
|
||
.PHONY: all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# for module compiling | ||
import os | ||
Import('RTT_ROOT') | ||
from building import * | ||
|
||
cwd = str(Dir('#')) | ||
src = Glob('*.c') | ||
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')) | ||
|
||
group = DefineGroup('', src, depend = [''], CPPPATH = []) | ||
#objs += group | ||
Return('objs') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import os | ||
import sys | ||
import rtconfig | ||
|
||
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')] | ||
from building import * | ||
|
||
TARGET = 'rtthread.' + rtconfig.TARGET_EXT | ||
|
||
env = Environment(tools = ['mingw'], | ||
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS, | ||
CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS, | ||
AR = rtconfig.AR, ARFLAGS = '-rc', | ||
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS) | ||
env.PrependENVPath('PATH', rtconfig.EXEC_PATH) | ||
|
||
Export('RTT_ROOT') | ||
Export('rtconfig') | ||
|
||
# prepare building environment | ||
objs = PrepareBuilding(env, RTT_ROOT) | ||
|
||
if GetDepend('RT_USING_WEBSERVER'): | ||
objs = objs + SConscript(RTT_ROOT + '/components/net/webserver/SConscript', variant_dir='build/net/webserver', duplicate=0) | ||
|
||
if GetDepend('RT_USING_RTGUI'): | ||
objs = objs + SConscript(RTT_ROOT + '/examples/gui/SConscript', variant_dir='build/examples/gui', duplicate=0) | ||
|
||
# libc testsuite | ||
#objs = objs + SConscript(RTT_ROOT + '/examples/libc/SConscript', variant_dir='build/examples/libc', duplicate=0) | ||
|
||
# make a building | ||
DoBuilding(TARGET, objs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Import('RTT_ROOT') | ||
Import('rtconfig') | ||
from building import * | ||
|
||
cwd = os.path.join(str(Dir('#')), 'applications') | ||
src = Glob('*.c') | ||
CPPPATH = [cwd, str(Dir('#'))] | ||
|
||
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH) | ||
|
||
Return('group') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#include <rtthread.h> | ||
|
||
static void rt_init_thread_entry(void* parameter) | ||
{ | ||
#ifdef RT_USING_COMPONENTS_INIT | ||
/* initialization RT-Thread Components */ | ||
rt_components_init(); | ||
#endif | ||
} | ||
static void led_thread_entry(void* parameter) | ||
{ | ||
unsigned int count=0; | ||
|
||
rt_hw_led_init(); | ||
|
||
while (1) | ||
{ | ||
/* led1 on */ | ||
#ifndef RT_USING_FINSH | ||
/* rt_kprintf("led on, count : %d\r\n",count);*/ | ||
#endif | ||
count++; | ||
rt_hw_led_on(0); | ||
rt_thread_delay( RT_TIMER_TICK_PER_SECOND*2 ); /* sleep 0.5 second and switch to other thread */ | ||
|
||
/* led1 off */ | ||
#ifndef RT_USING_FINSH | ||
/* rt_kprintf("led off\r\n");*/ | ||
#endif | ||
rt_hw_led_off(0); | ||
|
||
rt_thread_delay( RT_TIMER_TICK_PER_SECOND*2); | ||
} | ||
} | ||
static rt_uint8_t led_stack[ 512 ]; | ||
static struct rt_thread led_thread; | ||
void rt_application_init() | ||
{ | ||
rt_thread_t init_thread; | ||
|
||
rt_err_t result; | ||
/* init led thread */ | ||
result = rt_thread_init(&led_thread, | ||
"led", | ||
led_thread_entry, | ||
RT_NULL, | ||
(rt_uint8_t*)&led_stack[0], | ||
sizeof(led_stack), | ||
20, | ||
5); | ||
if (result == RT_EOK) | ||
{ | ||
rt_thread_startup(&led_thread); | ||
} | ||
|
||
init_thread = rt_thread_create("init", | ||
rt_init_thread_entry, RT_NULL, | ||
2048, 8, 20); | ||
if (init_thread != RT_NULL) | ||
rt_thread_startup(init_thread); | ||
return; | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include <rtthread.h> | ||
|
||
extern void *__bss_end__; | ||
extern void *_heap_end; | ||
#define HEAP_BEGIN &__bss_end__ | ||
#define HEAP_END &_heap_end | ||
static void rtthread_startup(void) | ||
{ | ||
/* initialize board */ | ||
rt_hw_board_init(); | ||
|
||
/* show version */ | ||
rt_show_version(); | ||
|
||
#ifdef RT_USING_HEAP | ||
rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END); | ||
#endif | ||
|
||
/* initialize scheduler system */ | ||
rt_system_scheduler_init(); | ||
/* initialize system timer*/ | ||
rt_system_timer_init(); | ||
/* initialize application */ | ||
rt_application_init(); | ||
|
||
/* initialize timer thread */ | ||
rt_system_timer_thread_init(); | ||
|
||
/* initialize idle thread */ | ||
rt_thread_idle_init(); | ||
|
||
/* start scheduler */ | ||
rt_system_scheduler_start(); | ||
|
||
/* never reach here */ | ||
return; | ||
} | ||
|
||
int main(void) | ||
{ | ||
|
||
rtthread_startup(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Import('RTT_ROOT') | ||
Import('rtconfig') | ||
from building import * | ||
|
||
cwd = os.path.join(str(Dir('#')), 'drivers') | ||
|
||
# add the general drvers. | ||
src = Glob("*.c") | ||
|
||
# add Ethernet drvers. | ||
#if GetDepend('RT_USING_LED'): | ||
# src += ['led.c'] | ||
|
||
CPPPATH = [cwd] | ||
|
||
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH) | ||
|
||
Return('group') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include <interrupt.h> | ||
#include <rthw.h> | ||
#if 0 | ||
static struct mem_desc hw_mem_desc[] = | ||
{ | ||
{ 0x00000000, 0xFFFFFFFF, 0x00000000, RW_NCNB },/* None cached for 4G memory */ | ||
// visual start, visual end, phy start , props | ||
{ 0x00000000, 0x000FFFFF, 0x20000000, RW_CB }, /* ISR Vector table */ | ||
{ 0x00200000, 0x00001FFF, 0x40000000, RW_CB }, /* 8K cached SRAM 0/1 */ | ||
{ 0x20000000, 0x21FFFFFF, 0x20000000, RW_CB }, /* 32M cached SDRAM */ | ||
{ 0x90000000, 0x90001FFF, 0x40000000, RW_NCNB },/* 4K SRAM0 + 4k SRAM1 */ | ||
{ 0xA0000000, 0xA1FFFFFF, 0x20000000, RW_NCNB },/* 32M none-cached SDRAM */ | ||
}; | ||
#endif | ||
|
||
static void rt_systick_handler(int vector, void *param) | ||
{ | ||
rt_tick_increase(); | ||
return; | ||
} | ||
static void rt_hw_timer_init(void) | ||
{ | ||
return; | ||
} | ||
void rt_hw_board_init(void) | ||
{ | ||
/* initialize mmu */ | ||
/* rt_hw_mmu_init(hw_mem_desc, sizeof(hw_mem_desc)/sizeof(hw_mem_desc[0]));*/ | ||
/* initialize hardware interrupt */ | ||
rt_hw_interrupt_init(); | ||
|
||
/* initialize the system clock */ | ||
//rt_hw_clock_init(); //set each pll etc. | ||
|
||
/* initialize uart */ | ||
rt_hw_uart_init(); | ||
rt_console_set_device(RT_CONSOLE_DEVICE_NAME); | ||
|
||
/* initialize timer0 */ | ||
rt_hw_timer_init(); | ||
|
||
#ifdef RT_USING_COMPONENTS_INIT | ||
rt_components_board_init(); | ||
#endif | ||
|
||
/* HW_ICOLL_CTRL_SET(BM_ICOLL_CTRL_IRQ_FINAL_ENABLE);*/ | ||
return; | ||
} | ||
|
Empty file.
Oops, something went wrong.