Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions bsp/realview-a8/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Object files
*.o
*.bin
*.pyc
*.map
*.elf

# Libraries
*.lib
*.a

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app

.scons*

# directory
build/*
11 changes: 11 additions & 0 deletions bsp/realview-a8/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
VMM BSP on realview-pb-a8

This is a demo program that run RT-Thread VMM(Virtual Machine Module) on
the single core RealView-PB-A8.

To compile it, you need buildroot and a linux 3.8.x source tree. You should
build the patched Linux kernel and builroot before building the VMM. This
directory has a "mk.sh" helper script to build both the RT-Thread, Linux kernel
module and the ramdisk.

Linux console is serial0 and RT-Thread console is serial1.
14 changes: 14 additions & 0 deletions bsp/realview-a8/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# for module compiling
import os
Import('RTT_ROOT')

cwd = str(Dir('#'))
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')
38 changes: 38 additions & 0 deletions bsp/realview-a8/SConstruct
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-realview.' + 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_VMM'):
if os.system('{cppcmd} -P -C -E -I. -D__ASSEMBLY__ {ldfile}.S -o {ldfile}'.format(
cppcmd = os.path.join(rtconfig.EXEC_PATH, 'arm-none-eabi-gcc'),
ldfile = rtconfig.LINK_SCRIPT)) != 0:
print 'failed to generate linker script %s' % rtconfig.LINK_SCRIPT
sys.exit(255)
# if the linker script changed, relink the target
Depends(TARGET, rtconfig.LINK_SCRIPT)

# make a building
DoBuilding(TARGET, objs)
11 changes: 11 additions & 0 deletions bsp/realview-a8/applications/SConscript
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')
47 changes: 47 additions & 0 deletions bsp/realview-a8/applications/application.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* File : application.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2012, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2012-11-20 Bernard the first version
*/

#include <rtthread.h>
#include <components.h>

#include <pthread.h>

void *test_task(void *parameter)
{
int count = 0;

while (1)
{
rt_thread_delay(RT_TICK_PER_SECOND);
rt_kprintf("count = %d\n", count ++);
}

return RT_NULL;
}

int rt_application_init()
{
// pthread_t tid;

/* do component initialization */
rt_components_init();
#ifdef RT_USING_NEWLIB
libc_system_init(RT_CONSOLE_DEVICE_NAME);
#endif

// pthread_create(&tid, RT_NULL, test_task, RT_NULL);

return 0;
}

72 changes: 72 additions & 0 deletions bsp/realview-a8/applications/startup.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* File : startup.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Develop Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2012-12-05 Bernard the first version
*/

#include <rthw.h>
#include <rtthread.h>

#include <board.h>

extern int rt_application_init(void);
extern void rt_hw_board_init(void);

/**
* This function will startup RT-Thread RTOS.
*/
void rtthread_startup(void)
{
/* initialzie hardware interrupt */
rt_hw_interrupt_init();

/* initialize board */
rt_hw_board_init();

/* show RT-Thread version */
rt_show_version();

/* initialize memory system */
#ifdef RT_USING_HEAP
rt_system_heap_init(HEAP_BEGIN, HEAP_END);
#endif

/* initialize scheduler system */
rt_system_scheduler_init();

/* initialize timer and soft timer thread */
rt_system_timer_init();
rt_system_timer_thread_init();

/* initialize application */
rt_application_init();

/* initialize idle thread */
rt_thread_idle_init();

/* start scheduler */
rt_system_scheduler_start();

/* never reach here */
return ;
}

int main(void)
{
/* disable interrupt first */
rt_hw_interrupt_disable();

/* invoke rtthread_startup */
rtthread_startup();

return 0;
}

3 changes: 3 additions & 0 deletions bsp/realview-a8/boot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh -e
scons -j12
qemu-system-arm -M realview-pb-a8 -kernel rtthread-realview.elf -serial vc -serial stdio
22 changes: 22 additions & 0 deletions bsp/realview-a8/drivers/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import copy
Import('RTT_ROOT')
Import('rtconfig')
from building import *

cwd = GetCurrentDir()
src = Glob('*.c')

# remove no need file.
if GetDepend('RT_USING_LWIP') == False:
src_need_remove = ['dm9000.c'] # need remove file list.
SrcRemove(src, src_need_remove)

if GetDepend('RT_USING_DFS') == False:
src_need_remove = ['sd.c'] # need remove file list.
SrcRemove(src, src_need_remove)

CPPPATH = [cwd]

group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)

Return('group')
104 changes: 104 additions & 0 deletions bsp/realview-a8/drivers/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* File : board.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2012, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2012-11-20 Bernard the first version
*/

#include <rthw.h>
#include <rtthread.h>
#include <components.h>

#include "board.h"

#define TIMER_LOAD(hw_base) __REG32(hw_base + 0x00)
#define TIMER_VALUE(hw_base) __REG32(hw_base + 0x04)
#define TIMER_CTRL(hw_base) __REG32(hw_base + 0x08)
#define TIMER_CTRL_ONESHOT (1 << 0)
#define TIMER_CTRL_32BIT (1 << 1)
#define TIMER_CTRL_DIV1 (0 << 2)
#define TIMER_CTRL_DIV16 (1 << 2)
#define TIMER_CTRL_DIV256 (2 << 2)
#define TIMER_CTRL_IE (1 << 5) /* Interrupt Enable (versatile only) */
#define TIMER_CTRL_PERIODIC (1 << 6)
#define TIMER_CTRL_ENABLE (1 << 7)

#define TIMER_INTCLR(hw_base) __REG32(hw_base + 0x0c)
#define TIMER_RIS(hw_base) __REG32(hw_base + 0x10)
#define TIMER_MIS(hw_base) __REG32(hw_base + 0x14)
#define TIMER_BGLOAD(hw_base) __REG32(hw_base + 0x18)

#define SYS_CTRL __REG32(REALVIEW_SCTL_BASE)

#ifdef RT_USING_VMM
#include <vmm.h>
static rt_uint32_t timer_hw_base = 0;
#define TIMER_HW_BASE (timer_hw_base)
#else
#define TIMER_HW_BASE REALVIEW_TIMER2_3_BASE
#endif

void rt_hw_timer_ack(void)
{
/* clear interrupt */
TIMER_INTCLR(TIMER_HW_BASE) = 0x01;
}

static void rt_hw_timer_isr(int vector, void *param)
{
rt_tick_increase();

rt_hw_timer_ack();
}

int rt_hw_timer_init(void)
{
rt_uint32_t val;

#ifdef RT_USING_VMM
{
rt_uint32_t sys_ctrl;
sys_ctrl = vmm_find_iomap("SYS_CTRL");
__REG32(sys_ctrl) |= REALVIEW_REFCLK;
}

timer_hw_base = vmm_find_iomap("TIMER");
#else
SYS_CTRL |= REALVIEW_REFCLK;
#endif

/* Setup Timer0 for generating irq */
val = TIMER_CTRL(TIMER_HW_BASE);
val &= ~TIMER_CTRL_ENABLE;
val |= (TIMER_CTRL_32BIT | TIMER_CTRL_PERIODIC | TIMER_CTRL_IE);
TIMER_CTRL(TIMER_HW_BASE) = val;

TIMER_LOAD(TIMER_HW_BASE) = 1000;

/* enable timer */
TIMER_CTRL(TIMER_HW_BASE) |= TIMER_CTRL_ENABLE;

rt_hw_interrupt_install(IRQ_PBA8_TIMER2_3, rt_hw_timer_isr, RT_NULL, "tick");
rt_hw_interrupt_umask(IRQ_PBA8_TIMER2_3);

return 0;
}
INIT_BOARD_EXPORT(rt_hw_timer_init);

/**
* This function will initialize beaglebone board
*/
void rt_hw_board_init(void)
{
rt_components_board_init();
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
}

/*@}*/
32 changes: 32 additions & 0 deletions bsp/realview-a8/drivers/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* File : board.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2013, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2013-07-06 Bernard the first version
*/

#ifndef __BOARD_H__
#define __BOARD_H__

#include <realview.h>

#if defined(__CC_ARM)
extern int Image$$RW_IRAM1$$ZI$$Limit;
#define HEAP_BEGIN ((void*)&Image$$RW_IRAM1$$ZI$$Limit)
#elif defined(__GNUC__)
extern int __bss_end;
#define HEAP_BEGIN ((void*)&__bss_end)
#endif

#define HEAP_END (void*)(0x70000000 + 8 * 1024 * 1024)

void rt_hw_board_init(void);

#endif
Loading