Skip to content

Commit

Permalink
[BSP] Add BSP for Ingenic X1000 CPU
Browse files Browse the repository at this point in the history
  • Loading branch information
BernardXiong committed Apr 24, 2016
1 parent bef87f8 commit 255f8b7
Show file tree
Hide file tree
Showing 36 changed files with 6,224 additions and 0 deletions.
1 change: 1 addition & 0 deletions bsp/x1000/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# RT-Thread for Ingenic X1000 porting.
14 changes: 14 additions & 0 deletions bsp/x1000/SConscript
Original file line number Diff line number Diff line change
@@ -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')
26 changes: 26 additions & 0 deletions bsp/x1000/SConstruct
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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-x1000.' + rtconfig.TARGET_EXT

env = Environment(tools = ['mingw'],
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
CXX = rtconfig.CC, CXXFLAGS = rtconfig.CXXFLAGS,
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)

# make a building
DoBuilding(TARGET, objs)
13 changes: 13 additions & 0 deletions bsp/x1000/applications/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from building import *

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

CPPPATH = [cwd, str(Dir('#'))]

if not GetDepend("RT_USING_DFS_ROMFS"):
SrcRemove(src, "romfs.c")

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

Return('group')
32 changes: 32 additions & 0 deletions bsp/x1000/applications/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* File : _main.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2008 - 2012, RT-Thread Development Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
* 2015-11-19 Urey the first version
*/
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char** argv)
{
printf("Hello RT-Thread!\n");

return 0;
}
50 changes: 50 additions & 0 deletions bsp/x1000/applications/mnt.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* File : mnt.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2008 - 2016, RT-Thread Development Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
* 2015-11-19 Urey the first version
*/

#include <rtthread.h>
#include <rtdevice.h>

#include <dfs_fs.h>

int mnt_init(void)
{
#ifdef RT_USING_SDIO
rt_mmcsd_core_init();
rt_mmcsd_blk_init();

jz47xx_sdio_init();
rt_thread_delay(RT_TICK_PER_SECOND * 1);

/* mount sd card fat partition 1 as root directory */
if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
{
rt_kprintf("File System initialized!\n");
}
else
{
rt_kprintf("File System initialzation failed!\n");
}
#endif
}
INIT_ENV_EXPORT(mnt_init);
11 changes: 11 additions & 0 deletions bsp/x1000/driver/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# RT-Thread building script for component

from building import *

cwd = GetCurrentDir()
src = Glob('*.c')
CPPPATH = [cwd, str(Dir('#'))]

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

Return('group')
56 changes: 56 additions & 0 deletions bsp/x1000/driver/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* File : board.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2008 - 2012, RT-Thread Development Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
* 2015-11-19 Urey the first version
*/

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

#include "board.h"
#include "drv_clock.h"
#include "drv_uart.h"
#include "drv_ost.h"

extern void rt_hw_cache_init(void);

void rt_hw_board_init(void)
{
rt_hw_cache_init();
/* init hardware interrupt */
rt_hw_interrupt_init();
rt_hw_uart_init();
#ifdef RT_USING_CONSOLE
/* set console device */
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
#endif /* RT_USING_CONSOLE */

#ifdef RT_USING_HEAP
/* init 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

rt_hw_ost_init();
}
63 changes: 63 additions & 0 deletions bsp/x1000/driver/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* File : board.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2008 - 2012, RT-Thread Development Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
* 2015-11-19 Urey the first version
*/

#ifndef _BOARD_H_
#define _BOARD_H_

#include <stdint.h>

#include "x1000.h"

#define RT_USING_JZ_X1000

// #define BOARD_PHOENIX
// #define BOARD_CANNA

#ifdef BOARD_PHOENIX
#define RT_USING_EMAC
#endif

/*********************************************************************************************************
** Clock for Board
*********************************************************************************************************/
#define BOARD_EXTAL_CLK 24000000
#define BOARD_RTC_CLK 32768
#define BOARD_CPU_CLK (1008 * 1000 * 1000UL)


/*********************************************************************************************************
** HEAP Setting
*********************************************************************************************************/
extern unsigned char __bss_start;
extern unsigned char __bss_end;

#define RT_HW_HEAP_BEGIN (void*)&__bss_end
#define RT_HW_HEAP_END (void*)(0x80000000 + 32 * 1024 * 1024)

/*********************************************************************************************************
** UART Setting
*********************************************************************************************************/
#define RT_USING_UART2

#endif
27 changes: 27 additions & 0 deletions bsp/x1000/driver/board_io.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* File : board_io.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2008 - 2012, RT-Thread Development Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
* 2015-11-19 Urey the first version
*/
#include <board.h>
#include <rtthread.h>

#include "drv_gpio.h"
Loading

0 comments on commit 255f8b7

Please sign in to comment.