android编译分析之7—product_config.mk

顾名思义,product_config.mk为产品相关的配置makefile。(假设lunch时选择的是aosp_arm-eng
通过该makefile,就可以将product相关makefile中定义的变量复制过来,以备其他makefile调用。这些变量包括:
TARGET_DEVICE
PRODUCT_LOCALES
PRODUCT_COPY_FILES
PRODUCT_PROPERTY_OVERRIDES
PRODUCT_PACKAGE_OVERLAYS
DEVICE_PACKAGE_OVERLAYS
等等……


首先定义了一个函数,判断字符串是否是c描述符,

###########################################################
## Return non-empty if $(1) is a C identifier; i.e., if it
## matches /^[a-zA-Z_][a-zA-Z0-9_]*$/.  We do this by first
## making sure that it isn't empty and doesn't start with
## a digit, then by removing each valid character.  If the
## final result is empty, then it was a valid C identifier.
##
## $(1): word to check
###########################################################

_ici_digits := 0 1 2 3 4 5 6 7 8 9
_ici_alphaunderscore := \
    a b c d e f g h i j k l m n o p q r s t u v w x y z \
    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z _
define is-c-identifier
$(strip \
  $(if $(1), \
    $(if $(filter $(addsuffix %,$(_ici_digits)),$(1)), \
     , \
      $(eval w := $(1)) \
      $(foreach c,$(_ici_digits) $(_ici_alphaunderscore), \
        $(eval w := $(subst $(c),,$(w))) \
       ) \
      $(if $(w),,TRUE) \
      $(eval w :=) \
     ) \
   ) \
 )
endef

检测sed的版本,如果不对,make直接就error了。

# TODO: push this into the combo files; unfortunately, we don't even
# know HOST_OS at this point.
trysed := $(shell echo a | sed -E -e 's/a/b/' 2>/dev/null)
ifeq ($(trysed),b)
  SED_EXTENDED := sed -E
else
  trysed := $(shell echo c | sed -r -e 's/c/d/' 2>/dev/null)
  ifeq ($(trysed),d)
    SED_EXTENDED := sed -r
  else
    $(error Unknown sed version)
  endif
endif

下面这个函数,在目录中找到指定的文件,然后表示成PRODUCT_COPY_FILES那种格式原文件:目标目录,例如

prodir/bootanimation/boot.wav:system/media/boot.wav 
###########################################################
## List all of the files in a subdirectory in a format
## suitable for PRODUCT_COPY_FILES and
## PRODUCT_SDK_ADDON_COPY_FILES
##
## $(1): Glob to match file name
## $(2): Source directory
## $(3): Target base directory
###########################################################

define find-copy-subdir-files
$(shell find $(2) -name "$(1)" | $(SED_EXTENDED) "s:($(2)/?(.*)):\\1\\:$(3)/\\2:" | sed "s://:/:g")
endef

默认的TARGET_BUILD_VARIANT包含user userdebug eng这三种

# These are the valid values of TARGET_BUILD_VARIANT.  Also, if anything else is passed
# as the variant in the PRODUCT-$TARGET_BUILD_PRODUCT-$TARGET_BUILD_VARIANT form,
# it will be treated as a goal, and the eng variant will be used.
INTERNAL_VALID_VARIANTS := user userdebug eng

判断make的目标是否为PRODUCT-prodname-goal这种类型,这里显然不是,

# ---------------------------------------------------------------
# Provide "PRODUCT-<prodname>-<goal>" targets, which lets you build
# a particular configuration without needing to set up the environment.
#
product_goals := $(strip $(filter PRODUCT-%,$(MAKECMDGOALS)))
ifdef product_goals
  # Scrape the product and build names out of the goal,
  # which should be of the form PRODUCT-<productname>-<buildname>.
  #
  ifneq ($(words $(product_goals)),1)
    $(error Only one PRODUCT-* goal may be specified; saw "$(product_goals)")
  endif
  goal_name := $(product_goals)
  product_goals := $(patsubst PRODUCT-%,%,$(product_goals))
  product_goals := $(subst -, ,$(product_goals))
  ifneq ($(words $(product_goals)),2)
    $(error Bad PRODUCT-* goal "$(goal_name)")
  endif

  # The product they want
  TARGET_PRODUCT := $(word 1,$(product_goals))

  # The variant they want
  TARGET_BUILD_VARIANT := $(word 2,$(product_goals))

  ifeq ($(TARGET_BUILD_VARIANT),tests)
    $(error "tests" has been deprecated as a build variant. Use it as a build goal instead.)
  endif

  # The build server wants to do make PRODUCT-dream-installclean
  # which really means TARGET_PRODUCT=dream make installclean.
  ifneq ($(filter-out $(INTERNAL_VALID_VARIANTS),$(TARGET_BUILD_VARIANT)),)
    MAKECMDGOALS := $(MAKECMDGOALS) $(TARGET_BUILD_VARIANT)
    TARGET_BUILD_VARIANT := eng
    default_goal_substitution :=
  else
    default_goal_substitution := $(DEFAULT_GOAL)
  endif

  # Replace the PRODUCT-* goal with the build goal that it refers to.
  # Note that this will ensure that it appears in the same relative
  # position, in case it matters.
  #
  # Note that modifying this will not affect the goals that make will
  # attempt to build, but it's important because we inspect this value
  # in certain situations (like for "make sdk").
  #
  MAKECMDGOALS := $(patsubst $(goal_name),$(default_goal_substitution),$(MAKECMDGOALS))

  # Define a rule for the PRODUCT-* goal, and make it depend on the
  # patched-up command-line goals as well as any other goals that we
  # want to force.
  #
.PHONY: $(goal_name)
$(goal_name): $(MAKECMDGOALS)
endif
# else: Use the value set in the environment or buildspec.mk.

判断make的目标是否为APP-appname这种类型,这里显然不是,

# ---------------------------------------------------------------
# Provide "APP-<appname>" targets, which lets you build
# an unbundled app.
#
unbundled_goals := $(strip $(filter APP-%,$(MAKECMDGOALS)))
ifdef unbundled_goals
  ifneq ($(words $(unbundled_goals)),1)
    $(error Only one APP-* goal may be specified; saw "$(unbundled_goals)"))
  endif
  TARGET_BUILD_APPS := $(strip $(subst -, ,$(patsubst APP-%,%,$(unbundled_goals))))
  ifneq ($(filter $(DEFAULT_GOAL),$(MAKECMDGOALS)),)
    MAKECMDGOALS := $(patsubst $(unbundled_goals),,$(MAKECMDGOALS))
  else
    MAKECMDGOALS := $(patsubst $(unbundled_goals),$(DEFAULT_GOAL),$(MAKECMDGOALS))
  endif

.PHONY: $(unbundled_goals)
$(unbundled_goals): $(MAKECMDGOALS)
endif # unbundled_goals

默认dalvikvm 在host主机上也要编译,

# Default to building dalvikvm on hosts that support it...
ifeq ($(HOST_OS),linux)
# ... or if the if the option is already set
ifeq ($(WITH_HOST_DALVIK),)
  WITH_HOST_DALVIK := true
endif
endif

下面要Include三个makefile,其中的函数和变量在前面已经分析过,之所以include,那肯定是要用这些函数和变量啦。

# ---------------------------------------------------------------
# Include the product definitions.
# We need to do this to translate TARGET_PRODUCT into its
# underlying TARGET_DEVICE before we start defining any rules.
#
include $(BUILD_SYSTEM)/node_fns.mk
include $(BUILD_SYSTEM)/product.mk
include $(BUILD_SYSTEM)/device.mk

TARGET_BUILD_APPS为空,走else分支,然后调用get-all-product-makefiles函数,返回所有产品的makefile列表。

ifneq ($(strip $(TARGET_BUILD_APPS)),)
# An unbundled app build needs only the core product makefiles.
all_product_configs := $(call get-product-makefiles,\
    $(SRC_TARGET_DIR)/product/AndroidProducts.mk)
else
# Read in all of the product definitions specified by the AndroidProducts.mk
# files in the tree.
# 作用是将device和vendor下的AndroidProducts.mk找出来,然后全部include进来,返回包含类似aosp_flounder.mk这种的列表
all_product_configs := $(get-all-product-makefiles)
endif

就像注释所写,为当前product找到对应的config makefile,

# Find the product config makefile for the current product.
# all_product_configs consists items like:
# <product_name>:<path_to_the_product_makefile>
# or just <path_to_the_product_makefile> in case the product name is the
# same as the base filename of the product config makefile.
# 这里all_product_configs都是类似makefile文件的列表,没有:
# 所以_cpm_word2为空,all_product_makefiles这时候是所有产品的mk的文件列表
# 而current_product_makefile为build/target/product/aosp_arm.mk
current_product_makefile :=
all_product_makefiles :=
$(foreach f, $(all_product_configs),\
    $(eval _cpm_words := $(subst :,$(space),$(f)))\
    $(eval _cpm_word1 := $(word 1,$(_cpm_words)))\
    $(eval _cpm_word2 := $(word 2,$(_cpm_words)))\
    $(if $(_cpm_word2),\
        $(eval all_product_makefiles += $(_cpm_word2))\
        $(if $(filter $(TARGET_PRODUCT),$(_cpm_word1)),\
            $(eval current_product_makefile += $(_cpm_word2)),),\
        $(eval all_product_makefiles += $(f))\
        $(if $(filter $(TARGET_PRODUCT),$(basename $(notdir $(f)))),\
            $(eval current_product_makefile += $(f)),)))
_cpm_words :=
_cpm_word1 :=
_cpm_word2 :=
current_product_makefile := $(strip $(current_product_makefile))
all_product_makefiles := $(strip $(all_product_makefiles))

调用import-products(build/target/product/aosp_arm.mk),将产品中定义的变量都import进来。例如,产品中定义了PRODUCT_NAME,则最终PRODUCT_NAME的值会保存在PRODUCTS.aosp_arm.mk.PRODUCT_NAME中。

# 如果目标是打印产品,如product-graph dump-products,打印产品,则是将所有的产品都import,
ifneq (,$(filter product-graph dump-products, $(MAKECMDGOALS)))
# Import all product makefiles.
$(call import-products, $(all_product_makefiles))
else
# Import just the current product.
ifndef current_product_makefile
$(error Can not locate config makefile for product "$(TARGET_PRODUCT)")
endif
ifneq (1,$(words $(current_product_makefile)))
$(error Product "$(TARGET_PRODUCT)" ambiguous: matches $(current_product_makefile))
endif
#将aosp_arm.mk 利用import-products import
$(call import-products, $(current_product_makefile))
endif  # Import all or just the current product makefile

然后调用check-all-products检查产品是否正确import,要保证必须的变量在product中都被定义。

# Sanity check
$(check-all-products)

如果make目标为dump-products,打印产品。

ifneq ($(filter dump-products, $(MAKECMDGOALS)),)
$(dump-products)
$(error done)
endif

INTERNAL_PRODUCT,为产品的全部路径,例如TARGET_PRODUCT=aosp_arm,则INTERNAL_PRODUCT为build/target/product/aosp_arm.mk

# Convert a short name like "sooner" into the path to the product
# file defining that product.
#
INTERNAL_PRODUCT := $(call resolve-short-product-name, $(TARGET_PRODUCT))
ifneq ($(current_product_makefile),$(INTERNAL_PRODUCT))
$(error PRODUCT_NAME inconsistent in $(current_product_makefile) and $(INTERNAL_PRODUCT))
endif
current_product_makefile :=
all_product_makefiles :=
all_product_configs :=

下面的变量都是在产品中定义的,将其拷贝到product_config.mk中,以备其他makefile使用。

#############################################################################

# A list of module names of BOOTCLASSPATH (jar files)
PRODUCT_BOOT_JARS := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_BOOT_JARS))
PRODUCT_SYSTEM_SERVER_JARS := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_SERVER_JARS))

# Find the device that this product maps to.
TARGET_DEVICE := $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEVICE)

# Figure out which resoure configuration options to use for this
# product.
# 产品中定义的语言
PRODUCT_LOCALES := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_LOCALES))
# TODO: also keep track of things like "port", "land" in product files.

# 如果CUSTOM_LOCALES中定义了PRODUCT_LOCALES中没有的,则添加到PRODUCT_LOCALES中
# If CUSTOM_LOCALES contains any locales not already included
# in PRODUCT_LOCALES, add them to PRODUCT_LOCALES.
extra_locales := $(filter-out $(PRODUCT_LOCALES),$(CUSTOM_LOCALES))
ifneq (,$(extra_locales))
  ifneq ($(CALLED_FROM_SETUP),true)
    # Don't spam stdout, because envsetup.sh may be scraping values from it.
    $(info Adding CUSTOM_LOCALES [$(extra_locales)] to PRODUCT_LOCALES [$(PRODUCT_LOCALES)])
  endif
  PRODUCT_LOCALES += $(extra_locales)
  extra_locales :=
endif

# Add PRODUCT_LOCALES to PRODUCT_AAPT_CONFIG
PRODUCT_AAPT_CONFIG := $(strip $(PRODUCT_LOCALES) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_AAPT_CONFIG))
PRODUCT_AAPT_PREF_CONFIG := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_AAPT_PREF_CONFIG))
PRODUCT_AAPT_PREBUILT_DPI := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_AAPT_PREBUILT_DPI))

# Keep a copy of the space-separated config
PRODUCT_AAPT_CONFIG_SP := $(PRODUCT_AAPT_CONFIG)

# Convert spaces to commas.
PRODUCT_AAPT_CONFIG := \
    $(subst $(space),$(comma),$(strip $(PRODUCT_AAPT_CONFIG)))

# product-scoped aapt flags
PRODUCT_AAPT_FLAGS :=
ifneq ($(filter en_XA ar_XB,$(PRODUCT_LOCALES)),)
# Force generating resources for pseudo-locales.
PRODUCT_AAPT_FLAGS += --pseudo-localize
endif

PRODUCT_BRAND := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_BRAND))

PRODUCT_MODEL := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_MODEL))
ifndef PRODUCT_MODEL
  PRODUCT_MODEL := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_NAME))
endif

PRODUCT_MANUFACTURER := \
    $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_MANUFACTURER))
ifndef PRODUCT_MANUFACTURER
  PRODUCT_MANUFACTURER := unknown
endif

ifeq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_CHARACTERISTICS),)
  TARGET_AAPT_CHARACTERISTICS := default
else
  TARGET_AAPT_CHARACTERISTICS := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_CHARACTERISTICS))
endif

PRODUCT_DEFAULT_WIFI_CHANNELS := \
    $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEFAULT_WIFI_CHANNELS))

PRODUCT_DEFAULT_DEV_CERTIFICATE := \
    $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEFAULT_DEV_CERTIFICATE))
ifdef PRODUCT_DEFAULT_DEV_CERTIFICATE
ifneq (1,$(words $(PRODUCT_DEFAULT_DEV_CERTIFICATE)))
    $(error PRODUCT_DEFAULT_DEV_CERTIFICATE='$(PRODUCT_DEFAULT_DEV_CERTIFICATE)', \
      only 1 certificate is allowed.)
endif
endif

# A list of words like <source path>:<destination path>[:<owner>].
# The file at the source path should be copied to the destination path
# when building  this product.  <destination path> is relative to
# $(PRODUCT_OUT), so it should look like, e.g., "system/etc/file.xml".
# The rules for these copy steps are defined in build/core/Makefile.
# The optional :<owner> is used to indicate the owner of a vendor file.
PRODUCT_COPY_FILES := \
    $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_COPY_FILES))

# A list of property assignments, like "key = value", with zero or more
# whitespace characters on either side of the '='.
PRODUCT_PROPERTY_OVERRIDES := \
    $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PROPERTY_OVERRIDES))

# A list of property assignments, like "key = value", with zero or more
# whitespace characters on either side of the '='.
# used for adding properties to default.prop
PRODUCT_DEFAULT_PROPERTY_OVERRIDES := \
    $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEFAULT_PROPERTY_OVERRIDES))

# Should we use the default resources or add any product specific overlays
PRODUCT_PACKAGE_OVERLAYS := \
    $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGE_OVERLAYS))
DEVICE_PACKAGE_OVERLAYS := \
        $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).DEVICE_PACKAGE_OVERLAYS))

# The list of product-specific kernel header dirs
PRODUCT_VENDOR_KERNEL_HEADERS := \
    $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_KERNEL_HEADERS)

# Add the product-defined properties to the build properties.
ADDITIONAL_BUILD_PROPERTIES := \
    $(ADDITIONAL_BUILD_PROPERTIES) \
    $(PRODUCT_PROPERTY_OVERRIDES)

# The OTA key(s) specified by the product config, if any.  The names
# of these keys are stored in the target-files zip so that post-build
# signing tools can substitute them for the test key embedded by
# default.
PRODUCT_OTA_PUBLIC_KEYS := $(sort \
    $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OTA_PUBLIC_KEYS))

PRODUCT_EXTRA_RECOVERY_KEYS := $(sort \
    $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_EXTRA_RECOVERY_KEYS))

PRODUCT_DEX_PREOPT_DEFAULT_FLAGS := \
    $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEX_PREOPT_DEFAULT_FLAGS))
PRODUCT_DEX_PREOPT_BOOT_FLAGS := \
    $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEX_PREOPT_BOOT_FLAGS))
# Resolve and setup per-module dex-preopot configs.
PRODUCT_DEX_PREOPT_MODULE_CONFIGS := \
    $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEX_PREOPT_MODULE_CONFIGS))
# If a module has multiple setups, the first takes precedence.
_pdpmc_modules :=
$(foreach c,$(PRODUCT_DEX_PREOPT_MODULE_CONFIGS),\
  $(eval m := $(firstword $(subst =,$(space),$(c))))\
  $(if $(filter $(_pdpmc_modules),$(m)),,\
    $(eval _pdpmc_modules += $(m))\
    $(eval cf := $(patsubst $(m)=%,%,$(c)))\
    $(eval cf := $(subst $(_PDPMC_SP_PLACE_HOLDER),$(space),$(cf)))\
    $(eval DEXPREOPT.$(TARGET_PRODUCT).$(m).CONFIG := $(cf))))
_pdpmc_modules :=
  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
UNICODE 全志R16平台TINAV2.1下的CSI接口摄像头ov5640的配置v1.2.txt R16_Camera模块开发说明文档_V1.8.pdf 所有步骤请按照这个说明书执行 1、驱动的编译配置: R:\wyb\gc2145_tinav2.1\lichee\linux-3.4\drivers\media\video\sunxi-vfe\device\gc2145.c R:\wyb\gc2145_tinav2.1\lichee\linux-3.4\drivers\media\video\sunxi-vfe\device\Makefile (可选操作,除了gc2145之外,其它的摄像头驱动都关闭,肯定可以减小最终生成的IMG的大小!) obj-m += ov5640.o obj-m += ov2640.o #obj-m += ov7736.o #obj-m += s5k4ec.o #obj-m += s5k4ec_mipi.o #obj-m += gc2035.o #obj-m += gt2005.o #obj-m += gc0307.o obj-m += gc0308.o #obj-m += gc0328.o #obj-m += gc0328c.o #obj-m += gc0329.o #obj-m += gc0311.o #obj-m += hi253.o #obj-m += sp2518.o #obj-m += sp2519.o #obj-m += sp0718.o #obj-m += sp0838.o #obj-m += ov16825.o #obj-m += ov5650.o #obj-m += ov5647.o #obj-m += ov5647_mipi.o #obj-m += t8et5.o #obj-m += s5k4e1.o #obj-m += s5k4e1_mipi.o #obj-m += sp2518.o #obj-m += sp0718.o #obj-m += gc5004.o #obj-m += gc5004_mipi.o #obj-m += ov5648.o #obj-m += ar0330.o #obj-m += ov5648.o #obj-m += sp5408.o #obj-m += ov12830.o #obj-m += ov8825.o #obj-m += ov8850.o #obj-m += gc2155.o obj-m += gc2145.o obj-m += gc2145d.o #obj-m += ov8858.o #obj-m += ov13850.o #obj-m += imx214.o #obj-m += ov8858_4lane.o #obj-m += sp5409.o #obj-m += s5k5e2yx.o #obj-m += ov2710_mipi.o #obj-m += siv121d.o #obj-m += ov2710_mipi.o #obj-m += bg0703.o #obj-m += gc1014_mipi.o #obj-m += imx219.o #obj-m += imx224.o #obj-m += imx322.o #obj-m += ov8858_r2a_4lane.o #obj-m += ov8865_4lane.o #obj-m += ps1210.o #obj-m += imx291.o 2、R:\wyb\gc2145_tinav2.1\lichee\linux-3.4\drivers\media\video\sunxi-vfe\vfe.c 这里修正之后就一切正常了。不然摄像头在系统启动之后就永远休眠了。 static void probe_work_handle(struct work_struct *work) { …… #ifdef CONFIG_ES dev->early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB + 1; dev->early_suspend.suspend = vfe_early_suspend; dev->early_suspend.resume = vfe_late_resume; // [hawkview_err]xxxxcan't open /dev/video0(Resource temporarily unavailable) // 2016/10/25 14:33 wenyuanbo cloase suspend. // register_early_suspend(&dev->early_suspend); vfe_print("register_early_suspend @ probe handle!\n"); #endif …… } 3、请严重注意:全志原生提供的cameratest有点错误(和tinav1.0对比得知:保存获取图片的文件名有小错误) R:\wyb\gc2145_tinav2.1\package\allwinner\cameratest\src\common\hawkview.c int fetch_sub_cmd(const char* buf,int buf_len,char** cmd,int* cmd_num,int lenght) { int i = 0,j = 0,n = 0; while(buf[i] != '#'){ //the sub cmd end by '#' while(buf[i] != 'x' && buf[i] != ':' && buf[i] != '#') { if((i+1) > buf_len) return 0; *((char*)cmd + n*lenght + j++) = buf[i++]; …… } R:\wyb\gc2145_tinav2.1\package\allwinner\cameratest\src\common\video.c static int capture_frame(void* capture,int (*set_disp_addr)(int,int,unsigned int*),pthread_mutex_t* mutex) { …… //sync capture info perp x second #define M_SECOND 200 if(is_x_msec(M_SECOND,(long long)(buf.timestamp.tv_sec),(long long)(buf.timestamp.tv_usec))){ getExifInfo(&(cap->frame.exif)); (建议关闭这里) // set_cap_info((void*)cap); } …… } R:\wyb\gc2145_tinav2.1\package\allwinner\cameratest\src\common\video_helper.c int set_cap_info(void* capture) { …… (修改这里) //strcpy(file_path, "dev/info"); sprintf(file_path, "%s/%s.info", PATH, cap->picture.path_name); …… } int do_save_sub_image(void* capture,int buf_index) { …… (增加这里) set_cap_info(capture); set_exif_info(capture); hv_dbg("--------set_exif_info end\n"); …… } 4、配置为在系统启动的时候加载gc2145.ko(SDK默认加载的是gc0308.ko) R:\wyb\gc2145_tinav2.1\target\allwinner\astar-common\modules.mk define KernelPackage/sunxi-vfe SUBMENU:=$(VIDEO_MENU) TITLE:=sunxi-vfe support FILES:=$(LINUX_DIR)/drivers/media/video/videobuf-core.ko FILES+=$(LINUX_DIR)/drivers/media/video/videobuf-dma-contig.ko FILES+=$(LINUX_DIR)/drivers/media/video/sunxi-vfe/csi_cci/cci.ko FILES+=$(LINUX_DIR)/drivers/media/video/sunxi-vfe/vfe_os.ko FILES+=$(LINUX_DIR)/drivers/media/video/sunxi-vfe/vfe_subdev.ko (修改这里) FILES+=$(LINUX_DIR)/drivers/media/video/sunxi-vfe/device/gc2145.ko FILES+=$(LINUX_DIR)/drivers/media/video/sunxi-vfe/vfe_v4l2.ko (修改这里) AUTOLOAD:=$(call AutoLoad,90,videobuf-core videobuf-dma-contig cci vfe_os vfe_subdev gc2145 vfe_v4l2) endef 5、直接使用了tinav1.0上调通ov5640后的sys_config.fex (请注意:这里修改的电源部分,其他没有用到的设备都请关闭掉。请参照您的原理图修改摄像头的供电部分!!!!) R:\wyb\gc2145_tinav2.1\target\allwinner\astar-parrot\configs\sys_config.fex [power_sply] dcdc1_vol = 3000 dcdc2_vol = 1100 dcdc3_vol = 1200 dcdc4_vol = 0 dcdc5_vol = 1500 aldo2_vol = 2500 aldo3_vol = 3000 (这里是增加的电源部分:) dldo3_vol = 2800 ;gpio0_vol = 2800 ldoio0_vol = 2800 [csi0] vip_used = 1 vip_mode = 0 vip_dev_qty = 1 vip_define_sensor_list = 0 vip_csi_pck = port:PE00 vip_csi_mck = port:PE01 vip_csi_hsync = port:PE02 vip_csi_vsync = port:PE03 vip_csi_d0 = port:PE04 vip_csi_d1 = port:PE05 vip_csi_d2 = port:PE06 vip_csi_d3 = port:PE07 vip_csi_d4 = port:PE08 vip_csi_d5 = port:PE09 vip_csi_d6 = port:PE10 vip_csi_d7 = port:PE11 ;vip_csi_sck = port:PE12 ;vip_csi_sda = port:PE13 ;vip_dev0_mname = "gc0308" ;vip_dev0_mname = "ov5640" vip_dev0_mname = "gc2145" vip_dev0_pos = "rear" vip_dev0_lane = 1 vip_dev0_twi_id = 2 ;vip_dev0_twi_addr = 0x42 vip_dev0_twi_addr = 0x78 vip_dev0_isp_used = 0 vip_dev0_fmt = 0 (2017/4/6 11:41 wenyuanbo 调试的时候这里设置为0方便测量摄像头的供电部分^_) ;vip_dev0_stby_mode = 1 vip_dev0_stby_mode = 0 vip_dev0_vflip = 0 vip_dev0_hflip = 0 vip_dev0_iovdd = "axp22_dldo3" vip_dev0_iovdd_vol = 2800000 vip_dev0_avdd = "" vip_dev0_avdd_vol = 2800000 vip_dev0_dvdd = "" vip_dev0_dvdd_vol = 1800000 vip_dev0_afvdd = "" vip_dev0_afvdd_vol = 2800000 vip_dev0_power_en = vip_dev0_reset = port:PE14 vip_dev0_pwdn = port:PE15 vip_dev0_flash_en = vip_dev0_flash_mode = vip_dev0_af_pwdn = (这个可以不改。不需要支持OTG功能。) ;usb_port_type: usb mode: 0-device, 1-host, 2-otg …… [usbc0] usb_used = 1 ;usb_port_type = 2 usb_port_type = 0 (!!!!解决重启的问题) [pmu1_para] …… ;power_start = 0 power_start = 3 pmu_temp_enable = 0 6、第一次编译之后,再次配置: 10、在menuconfig中打开sunxi-vfe support rootroot@rootroot-E400:~/wyb/gc2145_tinav2.1$ pwd /home/rootroot/wyb/gc2145_tinav2.1 rootroot@rootroot-E400:~/wyb/gc2145_tinav2.1$ source build/envsetup.sh including target/allwinner/tulip-d1/vendorsetup.sh including target/allwinner/octopus-dev/vendorsetup.sh including target/allwinner/azalea-perf3/vendorsetup.sh including target/allwinner/octopus-sch/vendorsetup.sh including target/allwinner/azalea-evb/vendorsetup.sh including target/allwinner/azalea-perf2/vendorsetup.sh including target/allwinner/astar-parrot/vendorsetup.sh including target/allwinner/generic/vendorsetup.sh including target/allwinner/astar-spk/vendorsetup.sh including target/allwinner/azalea-perf1/vendorsetup.sh including target/allwinner/astar-evb/vendorsetup.sh rootroot@rootroot-E400:~/wyb/gc2145_tinav2.1$ lunch You're building on Linux Lunch menu... pick a combo: 1. tulip_d1-tina 2. tulip_d1-dragonboard 3. octopus_dev-tina 4. octopus_dev-dragonboard 5. azalea_perf3-tina 6. azalea_perf3-dragonboard 7. octopus_sch-tina 8. octopus_sch-dragonboard 9. azalea_evb-tina 10. azalea_evb-dragonboard 11. azalea_perf2-tina 12. azalea_perf2-dragonboard 13. astar_parrot-tina 14. astar_parrot-dragonboard 15. astar_spk-tina 16. astar_spk-dragonboard 17. azalea_perf1-tina 18. azalea_perf1-dragonboard 19. astar_evb-tina Which would you like?13 ============================================ PLATFORM_VERSION_CODENAME=Neptune PLATFORM_VERSION=2.0.0 TARGET_PRODUCT=astar_parrot TARGET_BUILD_VARIANT=tina TARGET_BUILD_TYPE=release TARGET_BUILD_APPS= TARGET_ARCH=arm TARGET_ARCH_VARIANT=armv7-a-neon TARGET_CPU_VARIANT=cortex-a7 TARGET_2ND_ARCH= TARGET_2ND_ARCH_VARIANT= TARGET_2ND_CPU_VARIANT= HOST_ARCH=x86_64 HOST_OS=linux HOST_OS_EXTRA=Linux-3.13.0-24-generic-x86_64-with-Ubuntu-14.04-trusty HOST_BUILD_TYPE=release BUILD_ID=57513AA3 OUT_DIR= ============================================ rootroot@rootroot-E400:~/wyb/gc2145_tinav2.1$ make -j8 rootroot@rootroot-E400:~/wyb/gc2145_tinav2.1$ make menuconfig Kernel modules ---> Video Support ---> kmod-sunxi-vfe......................................... sunxi-vfe support 7、编译打包刷机之后的串口(debug口的)打印信息:: rootroot@cm-System-Product-Name:/home/rediron/r16/gc2145_tinav2.1$ cp .config bak2_vfe.config rootroot@rootroot-virtual-machine:~/wyb/opencv3.1_r16_tinav2.1$ make -j8 rootroot@rootroot-virtual-machine:~/wyb/opencv3.1_r16_tinav2.1$ pack -d 验证gc2145的驱动是否正常加载: Xshell 5 (Build 0964) Copyright (c) 2002-2016 NetSarang Computer, Inc. All rights reserved. Type `help' to learn how to use Xshell prompt. [c:\~]$ Connecting to COM3... Connected. BusyBox v1.24.1 () built-in shell (ash) _____ _ __ _ |_ _||_| ___ _ _ | | |_| ___ _ _ _ _ | | _ | || | | |__ | || || | ||_'_| | | | || | || _ | |_____||_||_|_||___||_,_| |_| |_||_|_||_|_| Tina is Based on OpenWrt! ---------------------------------------------- Tina Linux (Neptune, 57513AA3) ---------------------------------------------- root@TinaLinux:/# root@TinaLinux:/# cd /dev root@TinaLinux:/dev# ll v* crw-r--r-- 1 root root 7, 0 Jan 2 08:02 vcs crw-r--r-- 1 root root 7, 1 Jan 2 08:02 vcs1 crw-r--r-- 1 root root 7, 128 Jan 2 08:02 vcsa crw-r--r-- 1 root root 7, 129 Jan 2 08:02 vcsa1 crw-r--r-- 1 root root 10, 54 Jan 2 08:02 vhci crw-r--r-- 1 root root 81, 0 Jan 2 08:02 video0 root@TinaLinux:/# lsmod bcmdhd 534841 0 cci 19880 2 gc2145 gc2145 11234 0 snd_mixer_oss 11252 1 snd_pcm_oss snd_pcm_oss 29795 0 snd_seq_device 3927 0 vfe_os 3065 2 vfe_v4l2 vfe_subdev 3941 2 vfe_v4l2 vfe_v4l2 335707 0 videobuf_core 12030 2 vfe_v4l2 videobuf_dma_contig 2553 1 vfe_v4l2 root@TinaLinux:/# root@TinaLinux:/dev# cd /sys/class/i2c-adapter/i2c- i2c-0/ i2c-1/ i2c-2/ root@TinaLinux:/dev# cd /sys/class/i2c-adapter/i2c-2 root@TinaLinux:/sys/devices/platform/twi.2/i2c-2# ll drwxr-xr-x 4 root root 0 Jan 2 08:02 . drwxr-xr-x 4 root root 0 Jan 2 08:02 .. drwxr-xr-x 3 root root 0 Jan 2 08:04 2-003c --w------- 1 root root 4096 Jan 2 08:04 delete_device lrwxrwxrwx 1 root root 0 Jan 2 08:04 device -> ../../twi.2 -r--r--r-- 1 root root 4096 Jan 2 08:04 name --w------- 1 root root 4096 Jan 2 08:04 new_device drwxr-xr-x 2 root root 0 Jan 2 08:04 power lrwxrwxrwx 1 root root 0 Jan 2 08:04 subsystem -> ../../../../bus/i2c -rw-r--r-- 1 root root 4096 Jan 2 08:04 uevent root@TinaLinux:/sys/devices/platform/twi.2/i2c-2# cd 2-003c root@TinaLinux:/sys/devices/platform/twi.2/i2c-2/2-003c# ll drwxr-xr-x 3 root root 0 Jan 2 08:04 . drwxr-xr-x 4 root root 0 Jan 2 08:02 .. lrwxrwxrwx 1 root root 0 Jan 2 08:04 driver -> ../../../../../bus/i2c/drivers/ov5640 -r--r--r-- 1 root root 4096 Jan 2 08:04 modalias -r--r--r-- 1 root root 4096 Jan 2 08:04 name drwxr-xr-x 2 root root 0 Jan 2 08:04 power lrwxrwxrwx 1 root root 0 Jan 2 08:04 subsystem -> ../../../../../bus/i2c -rw-r--r-- 1 root root 4096 Jan 2 08:04 uevent root@TinaLinux:/sys/devices/platform/twi.2/i2c-2/2-003c# cat name gc2145 root@TinaLinux:/sys/devices/platform/twi.2/i2c-2/2-003c# 获取YUV格式的图片: [ 19.184637] dhd_open: Exit ret=0 [ 22.716117] sndpcm_startup,l:1688,pa_vol:40 BusyBox v1.24.1 () built-in shell (ash) _____ _ __ _ |_ _||_| ___ _ _ | | |_| ___ _ _ _ _ | | _ | || | | |__ | || || | ||_'_| | | | || | || _ | |_____||_||_|_||___||_,_| |_| |_||_|_||_|_| Tina is Based on OpenWrt! ---------------------------------------------- Tina Linux (Neptune, 57513AA3) ---------------------------------------------- root@TinaLinux:/# root@TinaLinux:/# root@TinaLinux:/# pwd / root@TinaLinux:/# root@TinaLinux:/# root@TinaLinux:/# root@TinaLinux:/# cameratest [hawkview_dbg]hawkview_init set_w 1280 [hawkview_msg]----sunxi9iw1p1 capture register sucessfully! [hawkview_dbg]hawkview_init 2 [hawkview_dbg]video pthread_create ret:0 [hawkview_dbg]video thread status 0 --> 101 [hawkview_dbg]command pthread_create ret:0 (等待输入需要获取的YUV图片的分辨率:) [hawkview_dbg]read cmd [ 181.303764] [VFE]vfe_open 146:0:1:1600x1200# [hawkview_[ 181.308582] [VFE]..........................vfe clk open!....................... dbg]cmd 0: 146 [hawkview_dbg]cm[ 181.319592] [VFE]vfe_open ok d 1: 0 [hawkview_dbg]cmd 2: 1 [hawkview_dbg]cmd 3: 1600 [hawkview_dbg]cmd 4: 1200 [hawkview_dbg]send command 146 [hawkview_dbg]video thread cmd: 0 --> 146 [hawkview_dbg]reset video capture [hawkview_msg]----open /dev/video0 [hawkview_msg]----get sensor type: 0 [ 182.325602] [VFE_ERR]set input i(1)>dev_qty(1)-1 error! [hawkview_err]xxxxVIDIOC_S_INPUT[ 182.331594] [VFE]Set vfe core clk = 108000000, after Set vfe core clk = 99000000 failed! s_input: 1 [ 182.366903] [VFE]mclk on [ 182.393862] [CSI][GC2145]enable oe! [ 182.398584] [CSI][GC2145]V4L2_IDENT_SENSOR=2145[hawkview_msg]----the tried size [ 182.875861] [VFE]buffer_setup, buffer count=10, size=2884096 is 1600x1200,the supported size is 1600x1200! [hawkview_dbg]map buffer index: 0, mem: b6bc8000, len: 2c0200, offset: 0 [hawkview_dbg]map buffer index: 1, mem: b6907000, len: 2c0200, offset: 2c1000 [hawkview_dbg]map buffer index: 2, mem: b6646000, len: 2c0200, offset: 582000 [hawkview_dbg]map buffer index: 3, mem: b6385000, len: 2c0200, offset: 843000 [hawkview_dbg]map buffer index: 4, mem: b60c4000, len: 2c0200, offset: b04000 [hawkview_dbg]map buffer index: 5, mem: b5e03000, len: 2c0200, offset: dc5000 [hawkview_dbg]map buffer index: 6, mem: b5b42000, len: 2c0200, offset: 1086000 [hawkview_dbg]map buffer index: 7, mem: b5881000, len: 2c0200, offset: 1347000 [hawkview_dbg]map buffer index: 8, mem: b55c0000, len: 2c0200, offset: 1608000 [hawkview_dbg]map buffer index: 9, mem: b52ff000, len: 2c0200, offset: 18c9000 [hawkview_dbg]video thread status 101 --> 102 [hawkview_dbg]capture frame command -1 --> 161 [hawkview_dbg]capture frame status -1 --> 0 [hawkview_dbg]capture start streaming [hawkview_dbg]capture frame command 161 --> 0 [hawkview_dbg]capture frame status 0 --> 1 [ 183.030025] [VFE]capture video mode! [ 183.132659] [VFE]capture video first frame done! (等待输入希望获取的YUV图片的文件名:) [hawkview_dbg]read cmd 149:color1013.yuv# [hawkview_dbg]cmd 0: 149 [hawkview_dbg]cmd 1: color1013.yuv [hawkview_dbg]send command 149 [hawkview_dbg]index: 3 buffers[buf.index].start = 0xb6385000 [hawkview_dbg]image_name: /tmp/color1013.yuv [hawkview_err]xxxxOpen sync file error[hawkview_dbg]image exif info: image_name = color1013.yuv width = 1600 height = 1200 exp_time_num = 0 exp_time_den = 0 sht_speed_num = 0 sht_speed_den = 0 fnumber = 0 exp_bias = 0 foc_length = 0 iso_speed = 0 flash_fire = 0 brightness = 0 # [hawkview_dbg]--------set_exif_info end (全志没有设置结束按键,只有按ctrl+C组合按键结束程序) ^C[ 270.859423] [VFE]vfe_close [ 270.862589] [CSI][GC2145]disalbe oe! [ 270.878791] [VFE]mclk off [ 270.893865] [VFE]..........................vfe clk close!....................... [ 270.902299] [VFE]vfe_close end root@TinaLinux:/# 8、在电脑的命令行中使用adb shell: Microsoft Windows [版本 6.1.7600] 版权所有 (c) 2009 Microsoft Corporation。保留所有权利。 C:\Users\Administrator>adb shell BusyBox v1.24.1 () built-in shell (ash) _____ _ __ _ |_ _||_| ___ _ _ | | |_| ___ _ _ _ _ | | _ | || | | |__ | || || | ||_'_| | | | || | || _ | |_____||_||_|_||___||_,_| |_| |_||_|_||_|_| Tina is Based on OpenWrt! ---------------------------------------------- Tina Linux (Neptune, 57513AA3) ---------------------------------------------- root@TinaLinux:/# cd tmp cd tmp root@TinaLinux:/tmp# ll ll drwxrwxrwt 9 root root 300 Jan 2 20:15 . drwxr-xr-x 1 root root 1024 Jan 2 20:15 .. drwx------ 2 root root 40 Jan 2 20:15 .uci -rw-r--r-- 1 root root 6 Jan 2 20:15 TZ -rw-r--r-- 1 root root 5 Jan 2 20:15 booting_state drwxrwxrwx 2 root root 40 Jan 2 20:15 lock drwxr-xr-x 2 root root 80 Jan 2 20:15 log lrwxrwxrwx 1 root root 21 Jan 2 20:15 resolv.conf -> /tmp/res olv.conf.auto -rw-r--r-- 1 root root 0 Jan 2 20:15 resolv.conf.auto drwxrwxrwx 2 root root 100 Jan 2 20:15 run drwxrwxrwt 2 root root 40 Jan 2 20:15 shm drwxrwxrwx 2 root root 60 Jan 2 20:15 state drwxr-xr-x 2 root root 40 Jan 2 20:15 tmp srwxr-xr-x 1 root root 0 Jan 2 20:15 wpa_ctrl_254-32 srwxr-xr-x 1 root root 0 Jan 2 20:15 wpa_ctrl_254-33 root@TinaLinux:/tmp# root@TinaLinux:/tmp# (1600x1200为您所希望获取的图片的分辨率,请根据您的需要来设置) root@TinaLinux:/tmp# echo "146:0:1:1600x1200#" > command echo "146:0:1:1600x1200#" > command (color1013.yuv为您希望保存yuv图像的文件名) root@TinaLinux:/tmp# echo "149:color1013.yuv#" > command echo "149:color1013.yuv#" > command root@TinaLinux:/tmp# ll ll drwxrwxrwt 9 root root 360 Jan 2 20:19 . drwxr-xr-x 1 root root 1024 Jan 2 20:15 .. drwx------ 2 root root 40 Jan 2 20:15 .uci -rw-r--r-- 1 root root 6 Jan 2 20:15 TZ -rw-r--r-- 1 root root 5 Jan 2 20:15 booting_state -rw-r--r-- 1 root root 1000 Jan 2 20:19 color1013.yuv.exif -rw-rw-rw- 1 root root 19 Jan 2 20:19 command drwxrwxrwx 2 root root 40 Jan 2 20:15 lock drwxr-xr-x 2 root root 80 Jan 2 20:15 log lrwxrwxrwx 1 root root 21 Jan 2 20:15 resolv.conf -> /tmp/res olv.conf.auto -rw-r--r-- 1 root root 0 Jan 2 20:15 resolv.conf.auto drwxrwxrwx 2 root root 100 Jan 2 20:15 run drwxrwxrwt 2 root root 40 Jan 2 20:15 shm drwxrwxrwx 2 root root 60 Jan 2 20:15 state drwxr-xr-x 2 root root 40 Jan 2 20:15 tmp srwxr-xr-x 1 root root 0 Jan 2 20:15 wpa_ctrl_254-32 srwxr-xr-x 1 root root 0 Jan 2 20:15 wpa_ctrl_254-33 -rw-r--r-- 1 root root 2880000 Jan 2 20:19 yuvcolor1013.yuv 可以再开一个adb窗口,adb可以开很多个的^_ Microsoft Windows [版本 6.1.7600] 版权所有 (c) 2009 Microsoft Corporation。保留所有权利。 C:\Users\Administrator>cd C:\tmp_gc2145 C:\tmp_gc2145>dir 驱动器 C 中的卷是 WIN7B64 卷的序列号是 C43E-FFB3 C:\tmp_gc2145 的目录 2017/05/23 17:04 . 2017/05/23 17:04 .. 0 个文件 0 字节 2 个目录 21,963,571,200 可用字节 获取图片:(这里使用了简单粗暴的方法,全部拿出来了。) C:\tmp_gc2145>adb pull /tmp/ . pull: building file list... skipping special file 'wpa_ctrl_254-33' skipping special file 'wpa_ctrl_254-32' skipping special file 'resolv.conf' skipping special file 'ubus.sock' pull: /tmp/log/wtmp -> ./log/wtmp pull: /tmp/log/lastlog -> ./log/lastlog pull: /tmp/state/network -> ./state/network pull: /tmp/run/config.md5 -> ./run/config.md5 pull: /tmp/run/ntpd.pid -> ./run/ntpd.pid pull: /tmp/booting_state -> ./booting_state pull: /tmp/resolv.conf.auto -> ./resolv.conf.auto pull: /tmp/TZ -> ./TZ pull: /tmp/command -> ./command pull: /tmp/color1013.yuv.exif -> ./color1013.yuv.exif pull: /tmp/yuvcolor1013.yuv -> ./yuvcolor1013.yuv 11 files pulled. 0 files skipped. 8820 KB/s (2881342 bytes in 0.319s) C:\tmp_gc2145> (可选操作:) C:\tmp_gc2145>adb pull /tmp/yuvcolor1013.yuv c:\ 现在激动人心的时刻到来了,你可以使用yuv看图工具:yuvplayer.exe 来查看你所获取的YUV格式的图片:yuvtest1013.yuv 请注意需要设置: YUV的格式设置:(NV12) 分辨率设置(1600x1200):请以您的实际分辨率为准。 9、可能会用到的调试命令: dmesg ps -aux ps -e 10、可选的改进(可以不修改的): R:\wyb\gc2145_tinav2.1\target\allwinner\generic\configs\env-3.4.cfg (uboot启动的时候延迟3秒钟) bootdelay=3 (SDK中已经修改了。调低打印等级,以便尽可能多的看到打印信息) loglevel=8

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值