
這個系列博文是關于對《嵌入式實時作業系統 μC-/OS II》(第二版)的學習筆記
μC-/OS II (一) PC編譯器環境的搭建
1.關于編譯器
采用Borland C++ 4.5作為μC-/OS II源代碼的編譯器。
下載下傳位址
還需要TASM 5.0
TASM是Borland公司推出的彙編編譯器,也是一種使用很廣泛的編譯器,到目前為止,TASM的最後一個版本是5.0版,這個版本支援WIN32程式設計,并單獨為WIN32程式設計附帶有一整套32位程式:32位的編譯器TASM32.EXE、連接配接器TLINK32.EXE和資源編譯器BRC32.EXE。
下載下傳位址
2.編譯器安裝
1.将Borland C++ 4.5解壓,運作INSTALL.EXE,盡量選擇預設安裝路徑“C:\BC45”
2.将TASM.EXE複制到Borland C++ 4.5的安裝路徑,即"C:\BC45\BIN"中。
3.編譯器設定
首先在硬碟中建立一個檔案夾用來放置整個調試工程檔案:
E:\6_OS\TEST1
在TEST1下分别建立了三個檔案夾分别用于存放源代碼,目标檔案,
E:\6_OS\TEST1\OBJ
E:\6_OS\TEST1\PROJECT
E:\6_OS\TEST1\RELEASE
E:\6_OS\TEST1\SOURCE
建立Project->New Project
選擇Dos标準平台
工程檔案設定
選擇好路徑後确認儲存
進階設定
生成的工程界面如下:
添加源檔案節點
- 将μc/os II源碼中\SOFTWARE\uCOS-II\EX1_x86L\BC45\SOURCE中的INCLUDES.H,OS_CFG.H和TEST.C三個檔案拷貝到你第一步建立的放置源檔案的檔案夾内,我的是 E:\6_OS\TEST1\SOURCE
- 添加
\SOFTWARE\uCOS-II\Ix86L\BC45\OS_CPU_A.ASM
\SOFTWARE\uCOS-II\Ix86L\BC45\OS_CPU_C.C
\SOFTWARE\uCOS-II\SOURCE\uCOS_II.C
\SOFTWARE\BLOCKS\PC\BC45\PC.C
E:\6_OS\TEST1\SOURCE\TEST.C
到代碼節點中
設定工程參數
會有錯誤,找不到頭檔案。
主要是因為源檔案中的引用路徑不對
輕按兩下報錯的位置打開源檔案,将其中的包含頭檔案代碼改為絕對路徑:
/*
*********************************************************************************************************
* uC/OS-II
* The Real-Time Kernel
*
* (c) Copyright 1992-1999, Jean J. Labrosse, Weston, FL
* All Rights Reserved
*
* MASTER INCLUDE FILE
*********************************************************************************************************
*/
#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"
改為:
INCLUDES.H
/*
*********************************************************************************************************
* uC/OS-II
* The Real-Time Kernel
*
* (c) Copyright 1992-1999, Jean J. Labrosse, Weston, FL
* All Rights Reserved
*
* MASTER INCLUDE FILE
*********************************************************************************************************
*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <conio.h>
#include <dos.h>
#include <setjmp.h>
#include "E:\6_OS\UcOS\software\ucos-ii\ix86l\bc45\os_cpu.h"
#include "os_cfg.h"
#include "E:\6_OS\UcOS\software\ucos-ii\source\ucos_ii.h"
#include "E:\6_OS\UcOS\\software\blocks\pc\bc45\pc.h"
2
/*
*********************************************************************************************************
* uC/OS-II
* The Real-Time Kernel
*
* (c) Copyright 1992-2002, Jean J. Labrosse, Weston, FL
* All Rights Reserved
*
* File : uCOS_II.C
* By : Jean J. Labrosse
*********************************************************************************************************
*/
#define OS_GLOBALS /* Declare GLOBAL variables */
#include "includes.h"
#define OS_MASTER_FILE /* Prevent the following files from including includes.h */
#include "\software\ucos-ii\source\os_core.c"
#include "\software\ucos-ii\source\os_flag.c"
#include "\software\ucos-ii\source\os_mbox.c"
#include "\software\ucos-ii\source\os_mem.c"
#include "\software\ucos-ii\source\os_mutex.c"
#include "\software\ucos-ii\source\os_q.c"
#include "\software\ucos-ii\source\os_sem.c"
#include "\software\ucos-ii\source\os_task.c"
#include "\software\ucos-ii\source\os_time.c"
改為:
/*
*********************************************************************************************************
* uC/OS-II
* The Real-Time Kernel
*
* (c) Copyright 1992-2002, Jean J. Labrosse, Weston, FL
* All Rights Reserved
*
* File : uCOS_II.C
* By : Jean J. Labrosse
*********************************************************************************************************
*/
#define OS_GLOBALS /* Declare GLOBAL variables */
#include "includes.h"
#define OS_MASTER_FILE /* Prevent the following files from including includes.h */
#include "E:\6_OS\UcOS\software\ucos-ii\source\os_core.c"
#include "E:\6_OS\UcOS\software\ucos-ii\source\os_flag.c"
#include "E:\6_OS\UcOS\software\ucos-ii\source\os_mbox.c"
#include "E:\6_OS\UcOS\software\ucos-ii\source\os_mem.c"
#include "E:\6_OS\UcOS\software\ucos-ii\source\os_mutex.c"
#include "E:\6_OS\UcOS\software\ucos-ii\source\os_q.c"
#include "E:\6_OS\UcOS\software\ucos-ii\source\os_sem.c"
#include "E:\6_OS\UcOS\software\ucos-ii\source\os_task.c"
#include "E:\6_OS\UcOS\software\ucos-ii\source\os_time.c"
接着編譯一次:
此時沒有編譯錯誤了,隻有警告,不用理他,直接運作:
終于成功了
BC工程檔案
參考了http://www.cnblogs.com/lazygunner/archive/2011/07/02/2096318.html
和http://www.cnblogs.com/lazygunner/articles/2096250.html
上的内容,感謝上兩個博文的作者