4251|2

5979

帖子

8

TA的资源

版主

楼主
 

【咨询】FreeRTOS支持Altera SoC [复制链接]

本帖最后由 chenzhufly 于 2015-2-22 14:42 编辑


链接:http://www.freertos.org/RTOS_Altera_SoC_ARM_Cortex-A9.html

PreambleThe demo presented on this page is not yet in the main FreeRTOS .zip file download. It will be included in the next release. Until that time the necessary files are provided in a separate zip file download.

The directory structure in the separate .zip file does not match that described in the build instructions below as the project to import into the DS-5 Eclipse workspace is located in the/FreeRTOS_Altera_SoC/RTOSDemo directory.


IntroductionThis page documents a FreeRTOS demo application for a Cortex-A9 core in the Altera Cyclone V SoC Hard Processing System (HPS).

The project builds using the free Altera edition of the ARM DS-5 Eclipse based IDE and the GCC compiler, both of which come as part of the Altera Embedded Development Suite (EDS). Note only the DS-5 and compiler components of the EDS are used - it is not necessary to install any FPGA tools to build or use this RTOS demo.

The project is pre-configured to execute on the Cyclone V SoC Development Kit hardware.

FreeRTOS+CLI is used to create a command console [Note the FreeRTOS+CLI license is not the same as the FreeRTOS license]



IMPORTANT! Notes on using the FreeRTOS Cyclone V SoC ARM Cortex-A9 demoPlease read all the following points before using this RTOS port.
Also see the FAQ My application does not run, what could be wrong?, and the page that provides instruction on using FreeRTOS on ARM Cortex-A embedded processors.

Source Code OrganisationOnly a small subset of the files in the FreeRTOS .zip file download are are required by the Altera Cyclone V SoC demo. The Source Code Organization page describes the structure of the FreeRTOS zip file download.

The ARM DS-5 Eclipse project file is located in the FreeRTOS/Demo/CORTEX_A9_Cyclone_V_SoC_DK directory. Note the RTOS project includes files that are contained in the /FreeRTOS-Plus directory, so the projects will not build if the /FreeRTOS-Plus directory has been deleted or the directory structure has been changed.



The Altera Cyclone V SoC ARM Cortex-A9 Demo ApplicationHardware and software set upAlthough the RTOS demo presented on this page has been pre-configured to run on the Altera Cyclone V SoC Development Kit it can be adapted easily to run on any Cyclone V SoC evaluation board that provides access to one UART and one LED.
  • UARTA UART is used for console IO. The demo in the download uses UART 0 for this purpose. UART 0 uses a UART to USB converter, so is connected using a USB cable.
    If it is necessary to use a UART other than UART 0 then update theFreeRTOS/Demo/CORTEX_A9_Cyclone_V_SoC_DK/Altera_Code/SoCSupport/uart0_support.c source file accordingly.

  • LED digital outputA digital output is used to toggle an LED. If it is necessary to use a different digital output then updateFreeRTOS/Demo/CORTEX_A9_Cyclone_V_SoC_DK/LEDs.c accordingly.


FunctionalityThe behaviour of the demo is defined by the mainCREATE_SIMPLE_BLINKY_DEMO_ONLY #define constant, which is declared at the top of main.c.
Functionality with mainCREATE_SIMPLE_BLINKY_DEMO_ONLY set to 1If mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1 then main() will call main_blinky().

main_blinky() creates a very simple demo that includes two tasks and one queue. One task repeatedly sends the value 100 to the other task through the queue. The receiving task toggles an LED each time it receives the message. The message is sent every 200 milliseconds, so the LED toggles every 200 milliseconds.


Functionality with mainCREATE_SIMPLE_BLINKY_DEMO_ONLY set to 0

An example CLI session
If mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0 then main() will call main_full(). main_full() creates a comprehensive test and demo application that demonstrates:Connect to FreeRTOS+CLI though the UART using 115200 baud. Type 'help' in the CLI to see a list of the registered commands.

Most of the RTOS tasks created by the demo are from the set of standard demo RTOS tasks. These are used by all FreeRTOS demo applications, and have no specific functionality or purpose other than to demonstrate the FreeRTOS API being used and test the RTOS kernel port.

A 'check' RTOS task is also created. The check task periodically queries the standard demo tasks to ensure they are functioning as intended. The check task also toggles an LED to give a visual indication of the system status. If the LED toggles every 3 seconds then the check task has not discovered any problems with the executing demo. If the LED toggles every 200 milliseconds then the check task has discovered a problem in at least one task..



Build InstructionsNote that the ARM DS-5 Eclipse project uses both virtual folders and links that reference files from both the /FreeRTOS-Plus and/FreeRTOS/Demo/Common directories. The [virtual] file structure viewed in the Eclipse project explorer will not therefore match the [actual] file structure viewed on the disk.
  • Open the ARM DS-5 Eclipse IDE and either create a new workspace or select an existing workspace when prompted.
  • Select "Import" from the IDE's "File" menu to bring up the import dialog box.
  • In the Import dialog box, select "General->Existing Projects Into Workspace" then browse to and select theFreeRTOS/Demo/CORTEX_A9_Cyclone_V_SoC_DK directory. A project called "RTOSDemo" will be visible.
  • Ensure RTOSDemo is checked and that Copy Projects Into Workspace is not checked before clicking "Finish".

    Import RTOSDemo into the Eclipse workspace without copying it into the workspace.

  • The GCC compiler used to build the project is installed when the Altera EDS is installed. It is necessary to update the project to set the compiler's location.Select "Properties" from the IDE's "Project" menu to bring up the properties dialogue box. In the dialogue box select "C/C++Build->Settings-> Cross Settings", then set the path to the compiler to be correct for your installation.
    Note: If the dialogue box tab shown in the image below is missing, or contains an error message, then it is likely your version of DS-5 does not have the CDT cross compiler plug in installed. If this is the case the plug in can be installed manually by following the instructions provided on the ARM website. It will be necessary to create a new workspace after the plug-in has been installed.


    Setting the path to the compiler in the RTOS project's properties dialogue box

  • Open main.c and set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to generate either the simple blinky demo, or the full test and demo application, as required.
  • Ensure the target hardware is connected to the host computer using an appropriate debug interface. The Cycle V SoC Development Kit has a build it BitBlaster interface. Other debug interfaces, such as ARM's D-Stream, can also be used.
  • Select "Build All" from the IDE's "Project" menu.
  • After the build completes, select "Debug Configurations..." from the IDE's "Debug" menu, and configure and run a debug configuration that is appropriate for your selected connection method (BitBlaster, D-Stream, etc.). The clickable screenshots below show a configuration that is using the D-Stream debugger. Note the selection of the preloader script in third screenshot.

    Click Images to Enlarge




RTOS Configuration and Usage Details
FreeRTOS ARM Cortex-A port specific configurationAttention please!: Refer to the the page that provides instruction on using FreeRTOS on ARM Cortex-A embedded processors, paying particular attention to the value and meaning of the configMAX_API_CALL_INTERRUPT_PRIORITY setting.

In this demo configSETUP_TICK_INTERRUPT is defined to call vConfigureTickInterrupt(), which in turn is implemented in main.c. vApplicationIRQHandler() is also implemented in main.c.

Configuration items specific to this demo are contained inFreeRTOS/Demo/CORTEX_A9_Cyclone_V_SoC_DK/FreeRTOSConfig.h. The constants defined in this file can be edited to suit your application.


[Application Defined] Interrupt service routinesThis demo uses drivers provided by Altera to configure the interrupt controller but, because the driver's own interrupt table is not accessible outside of its defining source file, a FreeRTOS specific function is used to actually register interrupt handlers. vRegisterIRQHandler() is used for this purpose, and is implemented in main.c.
/* * ulID - the ID of the interrupt as defined in the Altera provided alt_interrupt_common.h * header file. * * pxHandlerFunction - the C function being registered to handle the interrupt. * * pvContext - a reference to additional data of the application writer's choice that can * be used from within the interrupt handler. */void vRegisterIRQHandler( uint32_t ulID,                          alt_int_callback_t pxHandlerFunction,                          void *pvContext );                                               
vRegisterIRQHandler() function prototype


The C handlers themselves have the following prototype;

/* * ulICCIAR - the value of the generic interrupt controller's (GIC's) IAR register * at the time the hander is called. * * pvContext - the pointer to additional data for the handler that was passed into * the call to vRegisterIRQHandler() used to register the handler. */void vAnISRHandlingFunction( uint32_t ulICCIAR, void *pvContext );                                               
The prototype of an interrupt handling function that can be registered using vRegisterIRQHandler()


If an ISR causes an RTOS task of equal or higher priority than the currently executing task to leave the Blocked state (see description of the pxHigherPriorityTaskWoken parameter in the API documentation for functions such asxSemaphoreGiveFromISR()) then the ISR must request a context switch before the ISR exits. When this is done the interrupt will interrupt one RTOS task, but return to a different RTOS task.

The macros portYIELD_FROM_ISR() (or portEND_SWITCHING_ISR()) can be used to request a context switch from within an ISR. The following source code snippet is provided as an example. The example ISR uses a semaphore to synchronise with a task (not shown), and calls portYIELD_FROM_ISR() to ensure the interrupt returns directly to the task.

void Dummy_IRQHandler( uint32_t ulUnused, void *pvUnused ){long lHigherPriorityTaskWoken = pdFALSE;    /* The parameter is not used. */    ( void ) ulUnused;    /* Clear the interrupt if necessary. */    Dummy_ClearITPendingBit();    /* This interrupt does nothing more than demonstrate how to synchronise a    task with an interrupt.  A semaphore is used for this purpose.  Note    lHigherPriorityTaskWoken is initialised to pdFALSE. */    xSemaphoreGiveFromISR( xTestSemaphore, &lHigherPriorityTaskWoken );    /* If there was a task that was blocked on the semaphore, and giving the    semaphore caused the task to unblock, and the unblocked task has a priority    higher than or equal to the currently Running task (the task that this    interrupt interrupted), then lHigherPriorityTaskWoken will have been set to    pdTRUE internally within xSemaphoreGiveFromISR().  Passing pdTRUE into the    portYIELD_FROM_ISR() macro will result in a context switch being pended to    ensure this interrupt returns directly to the unblocked, higher priority,    task.  Passing pdFALSE into portYIELD_FROM_ISR() has no effect. */    portYIELD_FROM_ISR( lHigherPriorityTaskWoken );}                                               
An example interrupt handler

Only FreeRTOS API functions that end in "FromISR" can be called from an interrupt service routine - and then only if the priority of the interrupt is less than or equal to that set by the configMAX_API_CALL_INTERRUPT_PRIORITY configuration constant (meaning a numerically higher value).


Resources used by FreeRTOSInformation is provided on the Using FreeRTOS on ARM Cortex-A Embedded Processors page. This demo is configured to generate the tick interrupt from the Cortex-A9 core's private timer.
Memory allocationSource/Portable/MemMang/heap_4.c is included in the ARM Cortex-A demo application project to provide the memory allocation required by the RTOS kernel. Please refer to the Memory Management section of the API documentation for full information.
MiscellaneousNote that vPortEndScheduler() has not been implemented.

此帖出自FPGA/CPLD论坛

最新回复

这个不错啊,可以跑AMP模式  详情 回复 发表于 2015-3-4 15:23
点赞 关注
个人签名生活就是油盐酱醋再加一点糖,快活就是一天到晚乐呵呵的忙
===================================
做一个简单的人,踏实而务实,不沉溺幻想,不庸人自扰
 

回复
举报

2144

帖子

3

TA的资源

五彩晶圆(中级)

沙发
 
不错 不错
此帖出自FPGA/CPLD论坛
个人签名电工
 
 

回复

1173

帖子

3

TA的资源

五彩晶圆(初级)

板凳
 
这个不错啊,可以跑AMP模式
此帖出自FPGA/CPLD论坛
 
 
 

回复
您需要登录后才可以回帖 登录 | 注册

查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/9 下一条

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表