開發階段可能需要一些簡單的測試程式(執行檔) , 來進行一些小功能測試 , 所以下一個階段 , 移植一個小執行檔進入 TI BSP 吧 !!
之前我們有一個 lcd-test 的程式 , 由 console press "Enter" key , 會使用 mmap 方式填寫固定 pattern 到 fb0 內. 就先移植這個吧 !!
同樣的使用自己的 makefile 方式 .
首先開一的資料夾 ( android 的 main.mk 會自己尋找 ) , 可以有兩層 , 我的方式如下:
rowboat-android/test_apps/test/lcd-test & rowboat-android/test_apps/test/lcd-test/lcd-test-0.0.1
在 lcd-test 資料夾下放入 Android.mk file , 內容如下:
# Android.mk
#
# Copyright 2012 Jeff Hsieh <jeff@instant-jeff.instant>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
#
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
CROSS_TC_PREFIX := $(shell basename $(TARGET_TOOLS_PREFIX))
CROSS_TC_DIR := $(realpath $(shell dirname $(TARGET_TOOLS_PREFIX)))
export TARGET_CC := $(CROSS_TC_DIR)/$(CROSS_TC_PREFIX)gcc
export PRODUCT_OUT := $(PRODUCT_OUT)
PACKAGE_PATH := $(LOCAL_PATH)
LOCAL_GLOBAL_CFLAGS := $(subst -I ,-I $(shell pwd)/,$(subst -include ,-include $(shell pwd)/,$(TARGET_GLOBAL_CFLAGS))) \
$(foreach f,$(TARGET_C_INCLUDES), $(addprefix -I$(shell pwd)/,$f)) \
$(foreach f,$(TARGET_PROJECT_INCLUDES), $(addprefix -I$(shell pwd)/,$f)) \
$(foreach f,$(JNI_H_INCLUDE), $(addprefix -I$(shell pwd)/,$f))
LOCAL_GLOBAL_LDFLAGS := -L$(shell pwd)/$(TARGET_OUT_STATIC_LIBRARIES)
##=======================================
## Setting source file.
##=======================================
#~ ifeq ($(CONFIG_),y)
export VERNUM = 0.0.1
export TARGET_EXE = lcd-test
#~ endif
VERSION = lcd-test-$(VERNUM)
PACKAGE = $(PACKAGE_PATH)/$(VERSION)
##=======================================
## Setting Compiler FLAGS.
##=======================================
export EXE_CFLAGS = $(LOCAL_GLOBAL_CFLAGS)
export EXE_LDFLAGS = $(LOCAL_GLOBAL_LDFLAGS)
export EXE_EXT_FILE = $(shell pwd)/$(TARGET_CRTBEGIN_DYNAMIC_O) \
$(shell pwd)/$(TARGET_CRTEND_O)
##=======================================
.PHONY: distclean install_lcd_test distclean_lcd_test
droid: install_lcd_test
install_lcd_test: $(TARGET_CRTBEGIN_DYNAMIC_O) $(TARGET_CRTEND_O) $(TARGET_OUT_STATIC_LIBRARIES)/libm.so \
$(TARGET_OUT_STATIC_LIBRARIES)/libc.so $(TARGET_OUT_STATIC_LIBRARIES)/libdl.so \
$(TARGET_OUT_STATIC_LIBRARIES)/liblog.so
$(MAKE) -C $(PACKAGE) -f Makefile all
distclean: distclean_lcd_test
distclean_lcd_test:
@$(MAKE) -C $(PACKAGE) -f Makefile distclean
##################################################
主要將一些 ldflags , cflags export 到 下一層 Makefile 使用 , 其中 EXE_EXT_FILES 是因為執行檔 , 會需要這兩個 .o file , 並且很奇怪需要放在 同一個目錄下 , 我試過使用 --sysroot=<path> 的方式 , 也是不行 , 所以只好 copy 過去 make 完畢後 delete 掉.
接著在 ./lcd-test-0.0.1/ 下建立 Makefile , 這個 makefile 就是自己的方式.內容如下:
# ./test_apps/test/lcd-test/lcd-test-0.0.1/Makefile
#
# vi: set ts=4 :
##==========================================
TARGET_OUT := $(PWD)/$(PRODUCT_OUT)/system/bin/$(TARGET_EXE)
TARGET = $(TARGET_EXE)
CFLAGS = $(EXE_CFLAGS)
LDFLAGS = $(EXE_LDFLAGS)
##==========================================
## Setting target & source file.
##==========================================
CPP_SRCS = $(wildcard *.cpp)
C_SRCS = $(wildcard *.c)
CPP_OBJS = $(CPP_SRCS:.cpp=.opp)
C_OBJS = $(C_SRCS:.c=.o)
DEPEND_FILE = .depend
##==========================================
## Make Rules.
##==========================================
.PHONY: all distclean
all: $(DEPEND_FILE) $(TARGET_OUT)
$(TARGET_OUT): $(TARGET) Makefile
@echo " Install $(TARGET) ==> $(PRODUCT_OUT)/system/bin/"
@cp $(TARGET) $(PWD)/$(PRODUCT_OUT)/system/bin/
$(TARGET): $(C_OBJS) $(CPP_OBJS)
@echo " Building '$@' ... "
@cp $(foreach f,$(EXE_EXT_FILE), $(shell echo $f)) ./
@$(TARGET_CC) -o $@ $(C_OBJS) $(CPP_OBJS) $(LDFLAGS)
@rm $(foreach f,$(EXE_EXT_FILE), $(shell echo $f | sed 's/.*\///g'))
%.opp: %.cpp
@echo " Compiling '$<' ..."
@$(TARGET_CC) $(CFLAGS) -o $@ -c $<
%.o: %.c
@echo " Compiling '$<' ..."
@$(TARGET_CC) $(CFLAGS) -o $@ -c $<
distclean:
@echo " Distcleaning '$(TARGET)' ..."
@rm -f $(TARGET) $(C_OBJS) $(CPP_OBJS) $(DEPEND_FILE)
$(DEPEND_FILE):
@if [ -n "$(C_SRCS)" ] || [ -n "$(CPP_SRCS)" ] ; then \
echo " Generating '$@' ..." ;\
for i in $(C_SRCS) $(CPP_SRCS) ; do \
j=`echo $$i | sed 's/\.c/.o/g' ` ;\
$(TARGET_CC) $(CFLAGS) -M $$i -MT"$$j" >> $@ ;\
done ; \
fi
ifeq ($(DEPEND_FILE),$(wildcard $(DEPEND_FILE)))
include $(DEPEND_FILE)
endif
##==========================================
build 完畢後 ,利用 lrz 傳到 EVB 上的 /system/bin/ 下 . 執行看看 !!
成功....... ^^ , 不過會被原本 的畫面 re-flash 掉 , 所以建議找畫面更新率最低的頁面測試 , 或是使用 stop command 讓 java machine 暫停 , 在利用 console 執行測試程式.
Android 的 fb0 位置和一般linux 不同 , 移動到 /dev/graphics/fb0 位置.
沒有留言:
張貼留言