码迷,mamicode.com
首页 > 移动开发 > 详细

uCOS 在 NIOS II 上的移植

时间:2014-11-27 22:12:55      阅读:369      评论:0      收藏:0      [点我收藏+]

标签:ucos   nios   移植   

工具:Quartus II

器件:EP4CE15F17C8

1.File->New Project Wizard:

bubuko.com,布布扣

2.点击两个Next,进入Family&Device Settings,选择器件

bubuko.com,布布扣

3.Finish,建立工程完毕,点击Tools->SOPC Builder,输入名字后,OK

bubuko.com,布布扣

4.修改clk_0为100MHz

bubuko.com,布布扣

5.component library中搜索nios,双击Nios II Processer

bubuko.com,布布扣

6.Finish

bubuko.com,布布扣

7.搜索epcs,双击epcs Serial。。。Finish

bubuko.com,布布扣

8.搜索sdram,双击sdram controller,配置如下,sdram芯片为H57V2562GTR

bubuko.com,布布扣

9.搜索sysid,双击system id,finish

bubuko.com,布布扣

10.搜索jtag,双击JTAG UART,finish。搜索timer,双击Interval timer,finish。

bubuko.com,布布扣bubuko.com,布布扣

11.修改epcs和sdram基址:0x0000000,0x04000000

bubuko.com,布布扣

12.双击cpu_0,配置reset vector和exception vector。

bubuko.com,布布扣

13.修改各个模块的base地址,如图:

bubuko.com,布布扣

bubuko.com,布布扣

14.点击Generate

bubuko.com,布布扣

15.Generate成功。

bubuko.com,布布扣

16.File-New

bubuko.com,布布扣

17.save as nios.bdf,空白处双击,添加mynios kernel,OK

bubuko.com,布布扣

18.双击空白处:MegaWizard Plug-In Manager

bubuko.com,布布扣

19.设置时钟:

bubuko.com,布布扣

bubuko.com,布布扣

bubuko.com,布布扣

bubuko.com,布布扣

20.Finish,此时nios.bdf

bubuko.com,布布扣

21.分别右键模块,选择Generate Pins。。。在分别对引脚名字进行重新命名。

bubuko.com,布布扣

bubuko.com,布布扣

22.Assignments->Import Assignments,导入mynios.csv,这是之前编好的引脚配置信息:

下载地址:http://download.csdn.net/detail/wu20093346/8205265

编译时发现问题,NIOS II模块和工程名字一样引起冲突,打开Tools->SOPC Builder,打开之前的SOPC文件,Save as kernel.sopc,Generate。将mynios用kernel替换掉,如图:(另外将nios.bdf重新命名为mynios.bdf,与工程名保持一致)

bubuko.com,布布扣

23.Assignments->Device,选择Device and Pins Options,Dual-purpose中全部设置为regular IO:

bubuko.com,布布扣

24.编译整个工程,生成mynios.sof文件。Tools->NIOS II Software Build Tools for Eclipse,new->NIOS II Application and BSP from Template。选择SOPC information file,并给工程名字起名,template选择Hello uCOS II开始uCOS的工程建立:

bubuko.com,布布扣

25.finish。编译整个工程,Run as-> NIOS II Hardware。其中hello_ucosii.c:

/*************************************************************************
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA.      *
* All rights reserved. All use of this software and documentation is     *
* subject to the License Agreement located at the end of this file below.*
**************************************************************************
* Description:                                                           *
* The following is a simple hello world program running MicroC/OS-II.The * 
* purpose of the design is to be a very simple application that just     *
* demonstrates MicroC/OS-II running on NIOS II.The design doesn't account*
* for issues such as checking system call return codes. etc.             *
*                                                                        *
* Requirements:                                                          *
*   -Supported Example Hardware Platforms                                *
*     Standard                                                           *
*     Full Featured                                                      *
*     Low Cost                                                           *
*   -Supported Development Boards                                        *
*     Nios II Development Board, Stratix II Edition                      *
*     Nios Development Board, Stratix Professional Edition               *
*     Nios Development Board, Stratix Edition                            *
*     Nios Development Board, Cyclone Edition                            *
*   -System Library Settings                                             *
*     RTOS Type - MicroC/OS-II                                           *
*     Periodic System Timer                                              *
*   -Know Issues                                                         *
*     If this design is run on the ISS, terminal output will take several*
*     minutes per iteration.                                             *
**************************************************************************/


#include <stdio.h>
#include "includes.h"

/* Definition of Task Stacks */
#define   TASK_STACKSIZE       2048
OS_STK    task1_stk[TASK_STACKSIZE];
OS_STK    task2_stk[TASK_STACKSIZE];

/* Definition of Task Priorities */

#define TASK1_PRIORITY      1
#define TASK2_PRIORITY      2

/* Prints "Hello World" and sleeps for three seconds */
void task1(void* pdata)
{
  while (1)
  { 
    printf("Hello from task1\n");
    OSTimeDlyHMSM(0, 0, 3, 0);
  }
}
/* Prints "Hello World" and sleeps for three seconds */
void task2(void* pdata)
{
  while (1)
  { 
    printf("Hello from task2\n");
    OSTimeDlyHMSM(0, 0, 3, 0);
  }
}
/* The main function creates two task and starts multi-tasking */
int main(void)
{
  
  OSTaskCreateExt(task1,
                  NULL,
                  (void *)&task1_stk[TASK_STACKSIZE-1],
                  TASK1_PRIORITY,
                  TASK1_PRIORITY,
                  task1_stk,
                  TASK_STACKSIZE,
                  NULL,
                  0);
              
               
  OSTaskCreateExt(task2,
                  NULL,
                  (void *)&task2_stk[TASK_STACKSIZE-1],
                  TASK2_PRIORITY,
                  TASK2_PRIORITY,
                  task2_stk,
                  TASK_STACKSIZE,
                  NULL,
                  0);
  OSStart();
  return 0;
}

/******************************************************************************
*                                                                             *
* License Agreement                                                           *
*                                                                             *
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA.           *
* All rights reserved.                                                        *
*                                                                             *
* Permission is hereby granted, free of charge, to any person obtaining a     *
* copy of this software and associated documentation files (the "Software"),  *
* to deal in the Software without restriction, including without limitation   *
* the rights to use, copy, modify, merge, publish, distribute, sublicense,    *
* and/or sell copies of the Software, and to permit persons to whom the       *
* Software is furnished to do so, subject to the following conditions:        *
*                                                                             *
* The above copyright notice and this permission notice shall be included in  *
* all copies or substantial portions of the Software.                         *
*                                                                             *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,    *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      *
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING     *
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER         *
* DEALINGS IN THE SOFTWARE.                                                   *
*                                                                             *
* This agreement shall be governed in all respects by the laws of the State   *
* of California and by the laws of the United States of America.              *
* Altera does not recommend, suggest or require that this reference design    *
* file be used in conjunction or combination with any other product.          *
******************************************************************************/
26.在Nios II Console中打印出多任务并行的语句。

bubuko.com,布布扣
27.以上是uCOS在NIOS处理器上的移植,边操作边记录,如有不妥还请指教。

uCOS 在 NIOS II 上的移植

标签:ucos   nios   移植   

原文地址:http://blog.csdn.net/wu20093346/article/details/41546955

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!