ARM-開発ツール-コンパイラ
ARM開発といえば、コンパイラと言わざるを得ません.皆さんおなじみのgcc、このプラットフォームもあります.
どうせ組み込み開発といえば、toolchain、ツールチェーンとも呼ばれます.クロス(CROSS)というツールチェーンもあります.実はあまり差がありません.なぜこんなに多くのバージョンのコンパイラがあるのですか?
主に市場が決めているのでしょう.異なる開発ボードではgnu規格に基づいて修正されたgcc、as、ldが提供され、一般的なelfファイルは同じです.ほとんどの原因は、異なる周辺機器などのハードウェアによるものです.
主流のARMコンパイラを見てみましょう.
1.armccはARM公式コンパイラであり、DS-5にはこのツールが含まれている.料金を取る.
2.asm-linux-gnueabihfはGNUが提供するコンパイラで、ubuntuは直接sudo apt-get install gcc-arm-linux-gnueabihfでダウンロードすることができます.DS-5はこのコンパイラを提供する.
3.asm-linux-gnueabiはGNUが提供するコンパイラであり、ubuntuはapt-get install gcc-arm-linux-gnueabi binutils-arm-linux-gnueabiを直接sudoすることができる.
4.asm-none-gnueabiはCodeSourceryが提供するコンパイラです.ネット上のLiteバージョンは無料ですが、登録が必要です.多くのオープンソースプロジェクトはこのコンパイラを採用しています.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ここでは、asm-none-gnueabiのインストールについて簡単に紹介しましょう.最初の2つはGUIインストールで、難易度はありません.今の道具は実は簡単です.
1.arm-2010 q 1-202-arm-none-linux-gnueabiをダウンロードする.bin、これは教えなくてもいいでしょう.
2.インストール./arm-2010q1-202-arm-none-linux-gnueabi.bin.実行できない場合はchmod 755を使用します.実行できるように設定します.ヒントがインストールできない場合は、よく見て、YかNを選んでインストールできます.
3:環境変数の設定
$gedit ~/.bashrc
はい.bashrcファイルの最後に行を追加し、環境変数を追加します.
export PATH="/opt/arm-2009q1/bin:$PATH"
4:先ほどの設定を有効にする$source/.bashrc 5 linuxの環境変数の表示
$echo $PATH
$printenv
6テストインストール結果入力
$arm-none-linux-gnueabi-gcc
ヒントNO input file、これで大成功です.コードを探してコンパイルしましょう.このときarm-を入力しtabすると、関連するツールが表示されるはずです.異なるものをコンパイルするには、ツールチェーンを交換する必要がある場合があります.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
各コンパイルツールの使用について簡単に説明します.
1.これはDS-5のツールです.IDEインタフェース.Makefileを見ればわかります.
2.DS-5でcプロジェクトを作成し、Makefileを見てみましょう.
3.これはGNUのコンパイラです.Makefileを見てください.実は2番目と何の違いもありません.しかもコンパイルできます.開発ボードに焼き付けるだけでは動作しません.
4.これはCodeSourceryのコンパイラです.Makefileを見てください.
どうせ組み込み開発といえば、toolchain、ツールチェーンとも呼ばれます.クロス(CROSS)というツールチェーンもあります.実はあまり差がありません.なぜこんなに多くのバージョンのコンパイラがあるのですか?
主に市場が決めているのでしょう.異なる開発ボードではgnu規格に基づいて修正されたgcc、as、ldが提供され、一般的なelfファイルは同じです.ほとんどの原因は、異なる周辺機器などのハードウェアによるものです.
主流のARMコンパイラを見てみましょう.
1.armccはARM公式コンパイラであり、DS-5にはこのツールが含まれている.料金を取る.
2.asm-linux-gnueabihfはGNUが提供するコンパイラで、ubuntuは直接sudo apt-get install gcc-arm-linux-gnueabihfでダウンロードすることができます.DS-5はこのコンパイラを提供する.
3.asm-linux-gnueabiはGNUが提供するコンパイラであり、ubuntuはapt-get install gcc-arm-linux-gnueabi binutils-arm-linux-gnueabiを直接sudoすることができる.
4.asm-none-gnueabiはCodeSourceryが提供するコンパイラです.ネット上のLiteバージョンは無料ですが、登録が必要です.多くのオープンソースプロジェクトはこのコンパイラを採用しています.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ここでは、asm-none-gnueabiのインストールについて簡単に紹介しましょう.最初の2つはGUIインストールで、難易度はありません.今の道具は実は簡単です.
1.arm-2010 q 1-202-arm-none-linux-gnueabiをダウンロードする.bin、これは教えなくてもいいでしょう.
2.インストール./arm-2010q1-202-arm-none-linux-gnueabi.bin.実行できない場合はchmod 755を使用します.実行できるように設定します.ヒントがインストールできない場合は、よく見て、YかNを選んでインストールできます.
3:環境変数の設定
$gedit ~/.bashrc
はい.bashrcファイルの最後に行を追加し、環境変数を追加します.
export PATH="/opt/arm-2009q1/bin:$PATH"
4:先ほどの設定を有効にする$source/.bashrc 5 linuxの環境変数の表示
$echo $PATH
$printenv
6テストインストール結果入力
$arm-none-linux-gnueabi-gcc
ヒントNO input file、これで大成功です.コードを探してコンパイルしましょう.このときarm-を入力しtabすると、関連するツールが表示されるはずです.異なるものをコンパイルするには、ツールチェーンを交換する必要がある場合があります.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
各コンパイルツールの使用について簡単に説明します.
1.これはDS-5のツールです.IDEインタフェース.Makefileを見ればわかります.
# TrustZone Example Makefile
#
# Copyright (C) ARM Limited, 2011. All rights reserved.
#
# This makefile is intended for use with GNU make
# This example is intended to be built with the ARM Compiler armcc
TARGET=TrustZone-versatile.axf
CC=armcc
AS=armasm
LD=armlink
AR=armar
FE=fromelf
# Select build rules based on Windows or Unix
ifdef WINDIR
DONE=@if exist $(1) echo Build completed.
RM=if exist $(1) del /q $(1)
SHELL=$(WINDIR)\system32\cmd.exe
else
ifdef windir
DONE=@if exist $(1) echo Build completed.
RM=if exist $(1) del /q $(1)
SHELL=$(windir)\system32\cmd.exe
else
DONE=@if [ -f $(1) ]; then echo Build completed.; fi
RM=rm -f $(1)
endif
endif
all: $(TARGET)
$(call DONE,$(TARGET))
rebuild: clean all
clean:
$(call RM,*.o)
$(call RM,$(TARGET))
$(TARGET): startup_normal.s main_normal.c scatter_normal.scat startup_secure.s main_secure.c bp147_tzpc.c bp147_tzpc.h monitor.s scatter_secure.scat
# Assemble common routines
$(AS) -g --cpu=Cortex-A9.no_neon.no_vfp v7.s -o v7.o
# Compile normal world code
$(AS) -g --cpu=Cortex-A9.no_neon.no_vfp startup_normal.s -o startup_normal.o
$(CC) -c -g --cpu=Cortex-A9.no_neon.no_vfp -O1 main_normal.c -o main_normal.o
# Link normal world code and create binary
$(LD) main_normal.o startup_normal.o v7.o --scatter=scatter_normal.scat --entry=normalStart -o normal.axf
$(FE) --bin -o normal.bin normal.axf
# Compile secure world code
$(AS) -g --cpu=Cortex-A9.no_neon.no_vfp startup_secure.s -o startup_secure.o
$(CC) -c -g --cpu=Cortex-A9.no_neon.no_vfp -O1 main_secure.c -o main_secure.o
$(CC) -c -g --cpu=Cortex-A9.no_neon.no_vfp -O1 bp147_tzpc.c -o bp147_tzpc.o
$(AS) -g --cpu=Cortex-A9.no_neon.no_vfp monitor.s -o monitor.o
# Link final executable (secure + normal)
$(LD) main_secure.o startup_secure.o v7.o monitor.o bp147_tzpc.o --scatter=scatter_secure.scat --entry=secureStart --keep="startup_secure.o(NORMAL_IMAGE)" -o $(TARGET)
2.DS-5でcプロジェクトを作成し、Makefileを見てみましょう.
# C Application Example for ARM Linux
#
# Copyright (C) ARM Limited, 2007-2012. All rights reserved.
# This makefile is intended for use with GNU make
#
# This project can be built as hard-float ABI or full software floating point ABI:
# FLOAT = hf
# or
# FLOAT = soft
FLOAT = soft
TARGET = hello
ifeq ($(strip $(FLOAT)),hf)
ABI = -marm -mfloat-abi=hard
else
ABI = -marm -march=armv4t -mfloat-abi=soft
endif
CC_OPTS = -c -O1 -g -fno-omit-frame-pointer $(ABI)
OBJS = hello.o
STRIPPED_DIR = stripped
##########################################################################
CPP = arm-linux-gnueabihf-c++
CC = arm-linux-gnueabihf-gcc
AR = arm-linux-gnueabihf-ar
STRIP_APP = arm-linux-gnueabihf-strip -R .comment --strip-all
STRIP_LIB = arm-linux-gnueabihf-strip -R .comment --strip-unneeded
# Select build rules based on Windows or Linux
ifdef WINDIR
# Building on Windows
RPATH=$$ORIGIN
WINPATH=$(subst /,\,$(1))
DONE=@if exist $(call WINPATH,$(1)) echo Build completed.
define REAL_RM
if exist $(call WINPATH,$(1)) del /q $(call WINPATH,$(1))
endef
RM=$(foreach file,$(1),$(call REAL_RM,$(file)))
SHELL=$(windir)\system32\cmd.exe
MD=if not exist $(1) mkdir $(1)
CP=copy
else
ifdef windir
# Building on Windows
RPATH=$$ORIGIN
WINPATH=$(subst /,\,$(1))
DONE=@if exist $(call WINPATH,$(1)) echo Build completed.
define REAL_RM
if exist $(call WINPATH,$(1)) del /q $(call WINPATH,$(1))
endef
RM=$(foreach file,$(1),$(call REAL_RM,$(file)))
SHELL=$(windir)\system32\cmd.exe
MD=if not exist $(1) mkdir $(1)
CP=copy
else
# Building on Linux
RPATH='$$ORIGIN'
DONE=@if [ -f $(1) ]; then echo Build completed.; fi
RM=rm -f $(1)
MD=@if [ ! -d $(1) ]; then mkdir $(1); fi
CP=cp
endif
endif
##########################################################################
all: $(TARGET)
$(call DONE,$(TARGET))
rebuild: clean all
clean:
$(call RM,$(OBJS))
$(call RM,$(TARGET))
$(call RM,$(STRIPPED_DIR)/$(TARGET))
# Compile the sources
$(OBJS): %.o: %.c
$(CC) $(CC_OPTS) $< -o $@
# Link the objects together to create an executable
# Strip the host/debug version to create a stripped/nodebug version for downloading to the target
$(TARGET): $(OBJS)
$(call MD,$(STRIPPED_DIR))
$(CC) $(OBJS) -o $(TARGET) $(ABI)
$(STRIP_APP) $(TARGET) -o $(STRIPPED_DIR)/$(TARGET)
3.これはGNUのコンパイラです.Makefileを見てください.実は2番目と何の違いもありません.しかもコンパイルできます.開発ボードに焼き付けるだけでは動作しません.
# C Application Example for ARM Linux
#
# Copyright (C) ARM Limited, 2007-2012. All rights reserved.
# This makefile is intended for use with GNU make
#
# This project can be built as hard-float ABI or full software floating point ABI:
# FLOAT = hf
# or
# FLOAT = soft
FLOAT = soft
TARGET = hello
ifeq ($(strip $(FLOAT)),hf)
ABI = -marm -mfloat-abi=hard
else
ABI = -marm -march=armv4t -mfloat-abi=soft
endif
CC_OPTS = -c -O1 -g -fno-omit-frame-pointer $(ABI)
OBJS = hello.o
STRIPPED_DIR = stripped
##########################################################################
CPP = arm-linux-gnueabi-c++
CC = arm-linux-gnueabi-gcc
AR = arm-linux-gnueabi-ar
STRIP_APP = arm-linux-gnueabi-strip -R .comment --strip-all
STRIP_LIB = arm-linux-gnueabi-strip -R .comment --strip-unneeded
# Select build rules based on Windows or Linux
ifdef WINDIR
# Building on Windows
RPATH=$$ORIGIN
WINPATH=$(subst /,\,$(1))
DONE=@if exist $(call WINPATH,$(1)) echo Build completed.
define REAL_RM
if exist $(call WINPATH,$(1)) del /q $(call WINPATH,$(1))
endef
RM=$(foreach file,$(1),$(call REAL_RM,$(file)))
SHELL=$(windir)\system32\cmd.exe
MD=if not exist $(1) mkdir $(1)
CP=copy
else
ifdef windir
# Building on Windows
RPATH=$$ORIGIN
WINPATH=$(subst /,\,$(1))
DONE=@if exist $(call WINPATH,$(1)) echo Build completed.
define REAL_RM
if exist $(call WINPATH,$(1)) del /q $(call WINPATH,$(1))
endef
RM=$(foreach file,$(1),$(call REAL_RM,$(file)))
SHELL=$(windir)\system32\cmd.exe
MD=if not exist $(1) mkdir $(1)
CP=copy
else
# Building on Linux
RPATH='$$ORIGIN'
DONE=@if [ -f $(1) ]; then echo Build completed.; fi
RM=rm -f $(1)
MD=@if [ ! -d $(1) ]; then mkdir $(1); fi
CP=cp
endif
endif
##########################################################################
all: $(TARGET)
$(call DONE,$(TARGET))
rebuild: clean all
clean:
$(call RM,$(OBJS))
$(call RM,$(TARGET))
$(call RM,$(STRIPPED_DIR)/$(TARGET))
# Compile the sources
$(OBJS): %.o: %.c
$(CC) $(CC_OPTS) $< -o $@
# Link the objects together to create an executable
# Strip the host/debug version to create a stripped/nodebug version for downloading to the target
$(TARGET): $(OBJS)
$(call MD,$(STRIPPED_DIR))
$(CC) $(OBJS) -o $(TARGET) $(ABI)
$(STRIP_APP) $(TARGET) -o $(STRIPPED_DIR)/$(TARGET)
4.これはCodeSourceryのコンパイラです.Makefileを見てください.
# Build an ELF linux image
BOOTLOADER = boot.S
#KERNEL = ../../../kernel/linux-2.6.38-ael-11.06-patched/built/VE_V7/arch/arm/boot/Image
IMAGE = ../normal.elf
LD_SCRIPT = model.lds
CROSS_COMPILE = arm-none-linux-gnueabi-
AS = $(CROSS_COMPILE)as -g
LD = $(CROSS_COMPILE)ld -g
all: $(IMAGE)
clean:
rm -f $(IMAGE) boot.o
$(IMAGE): boot.o $(LD_SCRIPT) $(KERNEL)
$(LD) -o $@ --script=$(LD_SCRIPT)
boot.o: $(BOOTLOADER)
$(AS) -o $@ $<