Porting and testing of embedded real-time operating system Μc/os-ⅱ on DSP chip

Source: Internet
Author: User

"abstract" in order to reduce the development difficulty of DSP system software, to ensure the real-time nature of the system, shorten the development cycle, the embedded real-time operating system Μc/os-ⅱ porting to the DSP chip is a common method at present. This paper introduces the characteristics of embedded real-time operating system (Μc/os-ⅱ), and analyzes the porting method of Μc/os-ⅱ operating system in the current popular DSP chip tms320c6713, and solves the key points and difficulties in the process of transplanting Μc/os-ⅱ. Finally, after the transplant operating system test, the final test results show that: the operating system is a stable, reliable real-time embedded operating system.

"keywords " μc/os-ⅱ; embedded real-time operating system; TMS320C6713;DSP; transplant

1μc/os-ⅱ Operating System Introduction

Μc/os-ⅱ is a free-to-use, source code open embedded operating system, with small structure, can be cut, curable, portable and other advantages, but also has a stripped core. The main features are: stability and safety performance, real-time multi-tasking, can be cut curable, and has a strong transplant. As a software platform, it provides system service functions including task management and scheduling, time management, memory management, message mailbox and communication and synchronization between tasks.

The main function of the Μc/os-ⅱ kernel is to provide system services for the task, according to the current state of the task, timely implementation of the highest priority in the ready state of the task, the use of preemptive scheduling mechanism to ensure the real-time system. The Μc/os-ⅱ software structure is shown in Figure 1.


the significance of porting 2μc/os-ⅱ operating system on DSP

With the continuous development of science and technology, we have entered the digital era, and the core engine of the digital age is digital signal processor (SIGNALPROCESSOR,DSP). Since the the 1960s digital signal processing theory, digital signal processor has made rapid development, DSP has been widely used in all areas of social life, is changing our way of life. However, with the development of society, large-scale software has become the mainstream of the current software industry. With the popularization of large-scale software, the complexity of system software is more and more high, and the requirement of system software for real-time is increasing. How to keep the system good real-time in large-scale software development has become the key point and difficulty of DSP system development, and it is also the bottleneck that restricts the further development of DSP system. Because of the embedded real-time operating system Μc/os-ⅱ on the DSP chip porting and testing this, in many practical applications, we consider the use of Μc/os-ⅱ real-time kernel to manage system software, at a small cost, more significantly reduce the development of DSP system software difficult, while taking into account the real-time system and reliability, Shorten the software development cycle, has the very strong practical significance.

DSP chip tms320c6713 is widely used because of its excellent computing ability, efficient instruction set, intelligent peripherals, large-capacity on-chip memory and wide-range addressing capability. However, the current development on the 6713 chip is mostly carried out without operating system, the efficiency is low. And there is no research on the DSP6713 of Μc/os-ⅱ operating system. Therefore, this paper aims to study the Μc/os-ⅱ operating system transplanted on TMS320C6713DSP chip and test and verify it.

the transplant of 3μc/os-ⅱ on the tms320c6713

transplant conditions of 3.1μc/os-ii

Most of Μc/os-ⅱ 's code is written in C, and it is very portable because only a small number of processor-related code is written using the assembly. The Μc/os-ⅱ operating system can now be ported on a variety of popular processors, and to port the Μc/os-ⅱ, the target processor must meet the following requirements:1) The C compiler of the processor can generate reusable code, 2) can open and close interrupts in C language, 3) the processor supports interrupts, And can produce a timed interrupt; 4) The processor supports a certain number of data storage hardware stacks; 5) The processor has instructions to read the stack pointer and register contents, and store it in the stack or in memory.

The characteristics of DSP chip tms320c6713 and its software development environment CCS can meet the porting requirements of the Μc/os-ⅱ operating system, so it can be ported on the DSP chip.

main work of 3.2ΜC/OS-II operating system porting

The architecture of the Μc/os-ⅱ is shown in Figure 2, which shows that the application software written by the user is located at the top level of the entire system and is only associated with the application-related code and the processor-independent code in the Μc/os-ⅱ. This architecture provides a good guarantee of reusability of the application, and when the application is running on a different processor, only the code associated with the processor needs to be modified.

As can be seen from the diagram, the processor-related code is mainly os_cpu. H, OS_CPU_C.C, os_cpu_a.asm three files, so to implement the porting of the Μc/os-ⅱ operating system, the code in these three files needs to be modified. The following details the issues that need to be noted in modifying these three files when porting the Μc/os-ⅱ operating system on a DSP chip tms320c6713.


1) os_cpu. H Porting Implementation

Os_cpu. h defines the type of data associated with the compiler used, as well as the macro os_critical_method that selects the switch interrupt method, the off Interrupt macro os_enter_critical (), the Interrupt Macro os_exit_critical (), The macro os_stk_growth for the task Toggle Macro OS_TASK_SW () and the stack hold order.

The number of bits in the data type defined in the C language is not the same in different processors, so this part is not portable. So Μc/os-ⅱ itself defines a series of portable and intuitive data types to ensure system portability, such as:

typedef unsigned INTINT32U;

typedef unsignedshort INT16U;

typedef Unsignedchar INT8U;

typedef Unsignedchar BOOLEAN.

Μc/os-ⅱ declares the data type of the task stack through OS_STK, the tms320c6713 chip has a processor stack of 32 bits, so the OS_STK declaration is:

typedef INT32UOS_STK.

When the interrupt response is performed, the Μc/os-ⅱ will protect the critical section code from the multi-tasking or interrupt service subroutine by first closing the interrupt and then processing the critical segment code and reopening the interrupt after processing is complete.

To increase portability, Μc/os-ⅱ defines the macro os_enter_critical () to open interrupts, and Macro os_exit_critical () to turn off interrupts.

We passed in Os_cpu. H defines Os_critical_method constants to select different implementations of os_enter_critical () and os_exit_critical ().

In this paper, the first way to achieve the protection of critical areas, the implementation code is as follows:

#defineOS_ENTER_CRITICAL () Disable_int ()

#defineOS_EXIT_CRITICAL () Enable_int ()

The role of macro OS_TASK_SW is to implement task switching, and if the task is in a ready state, Μc/os-ⅱ will resume the task's register from the task stack and perform an interrupt return. The interrupt vector address of the interrupt service subroutine must point to the assembly language function OSCTXSW ().

#define OS_TASK_SW () OSCTXSW ()

The stack order of the processors is defined by the macro os_stk_growth, and the stacking order of the DSP chip tms320c6713 we use is decremented from the high address to the low address, so we define the os_stk_growth as 1.

2) OS_CPU_C.C Porting Implementation

This section defines the 10 C-language functions, except for the Ostaskstkinit () function, where other functions can be declared only, and the corresponding code is added when it is necessary to extend the relevant functionality. When a user establishes a task, the system internally calls the Ostaskstkinit () function to initialize the user's task stack. For the porting of DSP chip tms320c6713, the initialization of stack frame init_stack_frame is established, and each register of the stack is initialized.

3) Os_cpu_a.asm

Porting o s_cpu_a.asm files requires writing several assembly-language functions such as Osstarthighrdy (), Enable_int (), Disable_int (), OSCTXSW (), and OSINTCTXSW ().

The function of the Osstarthighrdy () is to point to the highest-priority task in the ready state. The system calls the function to run the task with the highest priority ready state.

6713 the chip needs to write a OSCTXSW () function in assembly language for task switching. This function switches the DSP system from the currently running low-priority task to the higher priority task. The system implements a task-level switchover by executing a soft interrupt or trap (trap) of the vector address pointing to OSCTXSW (). If a higher-priority task enters a ready state, Μc/os-ⅱ can complete the task by locating the OSCTXSW () function by pointing to the vector address of the OSCTXSW () function. Disable_int (), the Enable_int () function enables the protection of critical sections. These two functions take advantage of the state control Register (CSR) to control global interrupts, and in the case of a masking interrupt, first write the value of the gie bit to Pgie, and then the Gie write 0 shield interrupt. In Enable_int (), the value is read from the Pgie and written to the gie. This avoids accidental changes to the system's interrupt state.

After the OS_CPU. H, OS_CPU_C.C, os_cpu_a.asm these 3 files in the function of editing, you can complete the Μc/os-ⅱ operating system on the tms320c6713 chip migration.

4 Testing the porting code

After porting the Μc/os-ⅱ operating system to the tms320c6713 chip, it is also necessary to test the migrated operating system. This test requires that the program be downloaded to the 6713 board for verification. The test is divided into two steps: first, the kernel itself is tested without adding any user tasks, and the second step is to establish multiple tasks based on the message mailbox, and then verify that the system migration is successful by verifying that the operating system kernel has multiple tasks scheduled correctly.

First do not add the task application code to test the operation of the kernel itself, the test code is:

#include "Includes.h"

void Main (void)

{

printf ("initializinguc/os-ii.\n");

Osinit ();

printf ("startinguc/os-ii.\n");

Osstart ();

}

The running result of the kernel test indicates that the Μc/os-ⅱ kernel is operating normally. On this basis to create two tasks, Task 1 is to control the 6713 Development Board on the small lights on, Task 2 is to control the small lights off, the two task technology between the use of message mailbox communication, for task switching. After the operating system is initialized, create Task 1 and task 22 tasks. When you create a task, you define task 1 with a priority higher than task 2. So the system performs task 1 first. After Task 1 executes 3S, a message is sent to Task 2, Task 1 hangs, Task 2 begins execution, Task 2 executes 1S, a message is sent to Task 1, Task 2 hangs, Task 1 begins execution, and so on. The system task scheduling flowchart is shown in 3.


After running, see the 6713 Development Board LED lights in 3S, 1S off the frequency of flashing, the result indicates that all functions called by the operating system are working properly, thus indicating that the entire migration and its testing work has been completed. At this point, you can verify that Μc/os-ⅱ is working properly, and you can add new applications on this basis to implement the functionality required by the user.

5 Concluding remarks

This paper discusses the urgent need of embedded operating system Μc/os-ⅱ on DSP, realizes the porting of embedded real-time operating system Μc/os-ⅱ on tms320c6713 chip, and tests and verifies the transplanted operating system on the TDS6713EVM Development Board. The test proves that the operation of the operating system in DSP chip can be tms320c6713, the reliability is guaranteed, and the real-time performance is greatly improved. At the same time, the porting method introduced in this paper has a strong universality in the same kind of DSP architecture processor, and it also has some instructive meanings to the porting of Μc/os-ⅱ operating system on other DSP processors.

Reference documents

[1] Jean J.labrosse. Shaoberbe. Embedded RTOs Μc/os-ⅱ (2nd edition) [M]. Beijing: Beijing University of Aeronautics and Astronautics Press, 2003.

[2] three stellar technologies. TMS320C6713DSP principle and application example [M]. Beijing: Electronic industry Press, 2009.4.

[3] Huang Fu-rui, lighthearted. Porting of embedded real-time operating system Μc/os-ⅱ on DSP [J]. Aeronautical computing Technology, 2008.38 (4).

[4] Liu Haifeng, Liu Baifen. Research on the porting of embedded operating system Μc/os-ⅱ on DSP [J]. Journal of East China Jiaotong University, 2006.23 (1).

[5] Wu Xiao-xiao. Research on Secure communication protocol model based on point-to-point instant information exchange [J]. Information network security, 2012, (04): 72-74.

[6] Wang Xizhong, Guijiaching, Huang Junqiang, etc. network database security detection and management program design and implementation [J]. Information network security, 2012, (02): 14-18.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.