UC/OS v2.51 installation and debugging Guide

Source: Internet
Author: User

UC/OS is a small and practical real-time operating system. Due to its open code, uC/OS has been widely concerned in recent years, many people started to study and apply this operating system. However, due to the small number of documents, especially the guidance articles on installation and use, it is not enough for many beginners, especially those who have just been familiar with embedded operating systems do not know how to install and debug the system. For this reason, I will talk about its installation and debugging problems based on my own experiences, I hope to help you.

The development tools and Development kits in this article are as follows:

  • Development Kit: uC/os2.51 click here to download
  • Development tool in this article: Borland C 3.1 click here to download

The development tools have been tailored by myself and are only applicable to the development of this project.

1 Installation

  • 1.1 Download Software Package software.rar (file size 848kb)
  • 1.2 decompress the package. We recommend that you decompress the package to the C root directory, so that the file will be installed in C:/software, requiring 2.12 MB space.
  • 1.3 Installation Complete
  • 1.4 take the default installation path as an example. The directory structure is as follows:
    • C:/software
      This is the root directory, where all software-related files are stored.

      • C:/software/blocks
        Subroutine Module Directory. I will use the examples of μC/OS-II for PC-related function modules compiled and placed in this directory.
      • C:/software/maid
        This directory stores the files related to the sample maid (see appendix D, maid and ). The maid. C is stored in the C:/software/maid/source directory. The executable files (maid. EXE) under DOS are stored in C:/software/to/EXE.
      • C:/software/
        This directory stores the files related to example to (see appendix D, maid, and ). The source file to. C is stored in C:/software/to/source, and the executable file (to. EXE) under DOS is stored in C:/software/to/EXE. Note that to needs a to. TBL file, which must be placed in the root directory. You can find the to. TBL file in the C:/software/to/EXE directory. To run to. EXE, copy to. TBL to the root directory.
      • C:/software/uCOS-II
        All files related to the μC/OS-II are stored in this directory.
        • C:/software/uCOS-II/ex1_x86l
          This directory contains the source code of Example 1 (see 1.07, Example 1), which can be run in DOS (or DOS window under Windows 95.
        • C:/software/uCOS-II/ex2_x86l
          This directory contains the source code of Example 2 (see 1.08, Example 2), which can be run in DOS (or DOS window under Windows 95.
        • C:/software/uCOS-II/ex3_x86l
          This directory contains the source code of Example 3 (see 1.09, Example 3), which can be run in DOS (or DOS window under Windows 95.
        • C:/software/uCOS-II/ix86l
          This directory contains code dependent on the processor type. At this point is to run the uC/OS-II on 80 x86 processor and some code, real mode, compile in large mode.
        • C:/software/uCOS-II/source
          This directory contains source code irrelevant to the processor type. These codes can be completely transplanted to processors in other architectures.

2 Development Tool Borland C 3.1 Installation

  • 2.1 first download Borland C 3.1 (file size: 1.65 MB)
  • 2.2 decompress the package. We recommend that you decompress the package to the C root directory so that all the files will be installed in C:/bc31. We strongly recommend that you use this path for installation, in this way, you can directly compile and debug the project without changing their configurations. The space required is 5.10 MB.
  • 2.3 If you must install it in another directory, modify the corresponding configuration file. Note the blue part:
    • 2.3.1 open <installation path>/bin/turboc. cfg, which is shown as follows:
      -Ic:/bc31/include
      -LC:/bc31/lib
      Set C:/bc31 as the installation directory. For example, if the installation directory is E:/borlandc31
      -Ie:/borlandc31/include
      -Le:/borlandc31/lib
    • 2.3.2 open <installation path>/bin/tlink. cfg, which is shown as follows:
      -LC:/bc31/lib
      Set C:/bc31 as the installation directory. For example, if the installation directory is E:/borlandc31
      -Le:/borlandc31/lib
  • 2.4 installation is complete now
  • 2.5 take the default installation path as an example. The directory structure is as follows:
    • C:/bc31
      This is the root directory, where all tool-related files are stored.

      • C:/bc31/bin
        All development tools for compiling links are stored in this directory.
      • C:/bc31/lib
        All linked library files are stored in this directory.
      • C:/bc31/include
        All header files are stored in this directory.

It should also be noted that this Borland C has been cut down by myself to reduce the required space (the original version requires 19.6 MB). If you are using the original software, you can install it, you do not need to configure the 2.3 step. If you need the original software, please contact me to send a message.

3. Project Development

The four examples included with the development kit are representative. Next we will introduce the whole process of project development in combination with example 1. Note that the installation paths are default values.

  • 3.1 go to the C:/software/uCOS-II/exdeskx86l/bc45 directory and you will see two directories. Their functions are as follows:

    • C:/software/uCOS-II/exclux86l/bc45/source
      Source file directory

      • C:/software/uCOS-II/exclux86l/bc45/source/Includes. h
        The total project header file, each source file should contain
      • C:/software/uCOS-II/exclux86l/bc45/source/OS _cfg.h
        Configuration file for operating system configuration and tailoring
      • C:/software/uCOS-II/exclux86l/bc45/source/test. c
        Application file. You can refer to the file format when developing a new project.
      • C:/software/uCOS-II/exclux86l/bc45/source/test. lnk
        The linked file contains the connected library and link parameters.
    • C:/software/uCOS-II/exclux86l/bc45/test
      Project file directory
      • C:/software/uCOS-II/exclux86l/bc45/test. Mak
        The make file of the Project. People familiar with the C compiler must know that it is very convenient to use the make file to intelligently compile the entire project. We will introduce this file in detail later.
      • C:/software/uCOS-II/exclux86l/bc45/test. Map
        The project image file maps the library file addresses and is a product of the project.
      • C:/software/uCOS-II/exclux86l/bc45/test/maketest. bat
        The batch file operated by project make, which automatically completes the whole process of the compilation link.
      • C:/software/uCOS-II/exclux86l/bc45/test. exe
        The executable file generated by the project to make the product of the project

    Start Project Development

  • 3.2 Step 1: Create a project directory based on the preceding directory structure. In this example, create a directory c:/software/uCOS-II/ex1_x86l/bc45 /, two subdirectories test and source are created below, and relevant files are copied to these two directories. Be sure to create a project based on the path and directory structure, otherwise, you may need to change the path information in the file, which is troublesome.
    The fastest recommended method is to copy the directory of an example. If your new project is named newproject, you can create a directory c under C:/software/uCOS-II: /software/uCOS-II/newproject, and then copy the two subdirectories in C:/software/uCOS-II/exclux86l to the new directory, finally, you only need to change some configurations of the internal file. C to re-write the code for the new project.
  • 3.3 Step 2: Change the file des. h with the following content:

# Include <stdio. h>
# Include <string. h>
# Include <ctype. h>
# Include <stdlib. h>
# Include <conio. h>
# Include <dos. h>
# Include <setjmp. h>

# Include "/software/uCOS-II/ix86l/bc45/OS _cpu.h"
# Include "OS _cfg.h"
# Include "/software/uCOS-II/source/ucos_ii.h"
# Include "/software/blocks/PC/bc45/PC. H"

If the installation path and Project Creation Path of your software package are set as recommended, you do not need to change this file, but you can add some header files that you want to append in the project, for example, some driver or application module header files, but be sure to check whether the path is correct. If you create a project in a standard path, you must change the blue color code line by line to make the path correct.

  • 3.4 Step 3: configure the OS _cfg.h file, because it has nothing to do with the installation of the software package and development tools. It is only used for the configuration of the operating system in the project. For details, please decide based on your project, many related introductions, you can refer to UC/OS-II ebook.
  • Step 4: Modify the test. lnk configuration. Here, you can use the editor to set some parameters and link modules when linking the development tool:

/V/S/C/P-+
C:/bc31/lib/c0l. OBJ +
../Obj/test. OBJ +
../Obj/OS _cpu_a.obj +
../Obj/OS _cpu_c.obj +
../Obj/PC. OBJ +
../Obj/ucos_ii.obj
../Obj/test, ../obj/test
C:/bc31/lib/emu. Lib +
C:/bc31/lib/mathl. Lib +
C:/bc31/lib/Cl. Lib

3.5.1/V/S/C/P-is the Link parameter. Do not change it;

3.5.2 C:/bc31/lib/c0l. OBJ is the large mode compiling library module of Turbo C. If the development tool path is not set by default, change it to the actual installation path. For example, change C:/bc31 to E:/borlandc31.

3.5.3 .. /obj/test. OBJ is the target file of the application, which is composed of test. C is generated after compilation and saved in the temporarily generated C:/software/uCOS-II/exclux86l/bc45/obj directory, this directory uses and saves the target file generated during compilation.

3.5.4 .. /obj/OS _cpu_a.obj .. /obj/OS _cpu_c.obj .. /obj/PC. OBJ .. /obj/ucos_ii.obj is the same as above. They are all the target files generated during compilation and saved in the OBJ directory as a component module of the Project LINK. If the above files are missing in the OBJ directory, the link will not succeed.

3.5.5 .. /obj/test ,.. /obj/test is the path and name of the EXE and map files generated by the specified project. They are test. EXE and test. map and save it in the OBJ directory.

3.5.6 C:/bc31/lib/EMU. lib C:/bc31/lib/mathl. lib C:/bc31/lib/Cl. lib is the library file required for linking. It must conform to the Borland C installation path. If it is installed in a non-recommended directory, you must change the blue path. EMU is the 8087 simulation library, mathl is the mathematical function library, and Cl is the running library of turboc in large mode.

  • Step 5: Modify test. mak file. This is the make file of Borland C. For the format and Writing Method of the make file, see related books. Here we only introduce some configuration-related content. open the file and you can see:

    ######################################## #####################################
    # Tools
    ######################################## #####################################

    Borland = C:/bc31

    Cc = $ (Borland)/bin/BCC
    ASM = $ (Borland)/bin/tasm
    Link = $ (Borland)/bin/tlink
    Touch = $ (Borland)/bin/touch

    ######################################## #####################################
    # Directories
    ######################################## #####################################

    Target = ../test
    Source =.../source
    Work = ../work
    OBJ = ../obj
    LST = ../lst

    OS =/software/uCOS-II/source
    PC =/software/blocks/PC/bc45
    Port =/software/uCOS-II/ix86l/bc45

    If you have Borland C not installed in the recommended installation directory, you need to change Borland = C:/bc31. For example, if you have installed Borland C in E:/borlandc31, set Borland = C: change/bc31 to Borland = E:/borlandc31.

    Cc = $ (Borland)/bin/BCC: this is the name and path of the compiler and is not changed.
    ASM = $ (Borland)/bin/tasm: the name and path of the assembler.
    Link = $ (Borland)/bin/tlink: the name and path of the linker.

    Target = ../test: project file directory. If the path is not recommended, you must change the path.
    Source = ../Source: Source file directory. If the path is not recommended, you must change the path.
    Work = ../Work: The project working directory. When maketest. bat is automatically compiled, all source files are copied to this directory. This setting must be consistent with the settings in maketest. bat.
    OBJ = ../obj: directory of the target code. This setting must be consistent with the setting in maketest. bat.
    LST = ../lst: list file directory. This setting must be consistent with the setting in maketest. bat.

    OS =/software/uCOS-II/Source: Operating System source file directory. Ensure that the path is correct. If your development kit is not installed as recommended, you must change this setting to the actual installation directory.
    PC =/software/blocks/PC/bc45: PC-related source file directory. Ensure that the path is correct. If your development kit is not installed as recommended, you must change this setting to the actual installation directory.
    Port =/software/uCOS-II/ix86l/bc45: the source file directory related to the processor. Ensure that the path is correct. If your development kit is not installed as recommended, you must change this setting to the actual installation directory. The development kit also has a floating point processor file directory Ix86L-FP. These two directories are closely related to transplantation, which is equivalent to BSP ).

  • Step 6: Configure maketest. bat.

    MD ../work
    MD ../obj
    MD ../lst
    CD ../work
    Copy ../test. Mak test. Mak
    C:/bc31/bin/make-F test. Mak
    CD ../test

    The first step is to create .. /work .. /obj .. /lst directory. The directory name and path must be the same as test. mak is consistent, and then enter .. /work directory, and .. test. copy the Mak to this directory, and finally execute the make program of Borland C to automatically compile and link it. Pay attention to the path of C:/bc31.

  • In step 8 of 3.9, you can develop related applications. For details, see test. c. If your project contains multiple source files, it is best. use the # include statement in C to include them. Otherwise, you must change the make file test. mak and several other configuration files. If you really need this, you can try it yourself and it will not be listed here.
  • 3.10 Finally, run maketest. BAT to generate the test. EXE file in the test directory.

4 others

Fortunately, many netizens have used Borland C in the PC to implement exciting debugging and development. The netizen hcompute wrote out his experiences, you can also refer to this Article in PC environment with bc3.1 compiled to connect to the uC/OS-II source file.

For more information about the application of the operating system, see the English version of its ebook.

In addition, the writing of this article is in a hurry, basically in one breath, and there are inevitably many mistakes. Some of the ideas may be wrong due to my limited level. Here, I welcome my friends who have read this article and found problems or errors to correct them in time, so as not to mislead others. I also welcome friends who have read some ideas to send you a positive letter and put forward your opinions and opinions, let's work together to find the best way to develop uC/OS.

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.