Navigation

    全志在线开发者论坛

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • 在线文档
    • 社区主页

    T113: Python 3.5 Package Cross-Compile

    其它全志芯片讨论区
    2
    5
    1445
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      dazb3 LV 5 last edited by

      大家好,
      在 Tina Linux 中,我尝试安装适用于 Python 3.5 的 spidev Python 包。它不包含在 SDK make menuconfig 中
      我一直在尝试交叉编译,但到目前为止还没有成功。
      有人可以提供有关如何安装 Python 包的建议或说明吗?
      谢谢!

      Hi all,
      In Tina Linux, I'm trying to install the spidev Python package for Python 3.5. It's not included in the SDK make menuconfig
      I've been trying to cross compile, but so far I've had no success.
      Can anyone provide advice or instructions on how to install a Python package.
      Thank you!

      1 Reply Last reply Reply Quote Share 0
      • Z
        zoengjay LV 5 last edited by

        more details will help.
        I'm not sure but if you are using builtroot, python-spidev should be the package?

        like this:
        https://gerrit.cesnet.cz/plugins/gitiles/github/buildroot/buildroot/+/63d0762ab72a3536ea2e07ac75327c7556ed72c1/package/python-spidev/

        D 1 Reply Last reply Reply Quote Share 1
        • D
          dazb3 LV 5 @zoenggit last edited by

          @zoenggit appreciate the response and link. I'm using the Tina Linux 2.0 SDK, which is based on OpenWRT. I'm using the Tina Linux build downloaded from this forum.

          I believe the packaging system is a bit different to buildroot. I did attempt to include the spidev package in the build system, but couldn't figure how to make it work.

          Do you have any experience or advice in how to get it to work?

          Z 1 Reply Last reply Reply Quote Share 0
          • Z
            zoengjay LV 5 @dazb3 last edited by

            @dazb3

            chatgpt suggested no python-spidev is included by default, and should check python before add python-spidev.

            3. Install python-spidev
            
            python-spidev is usually not included directly in OpenWRT feeds, but it can be compiled from source as part of the build.
            
            First, check for python3:
            
            ./scripts/feeds install python3
            

            following is a link include python-spidev package by OnionIoT, switch to the right branch which matches tina sdk openwrt version:
            https://github.com/OnionIoT/OpenWRT-Packages

            D 1 Reply Last reply Reply Quote Share 0
            • D
              dazb3 LV 5 @zoenggit last edited by

              @zoenggit Many thanks for your suggestion and link. Using it, I was able to figure out how to edit the makefile to get spidev to correct build.

              I created folder tina-d1-h/package/lang/python3-spidev, and in it I create Makefile. Below is the Makefile:

              # Copyright (C) 2017 Onion Corporation
              #
              # Author: Lazar Demin  <lazar@onion.io>
              #
              # This is free software, licensed under the GNU General Public License v2.
              # See /LICENSE for more information.
              #
              
              include $(TOPDIR)/rules.mk
              PKG_NAME:=python-spidev
              PKG_VERSION:=4.0.1
              PKG_RELEASE:=2
              
              
              PKG_SOURCE_PROTO:=git
              PKG_SOURCE_VERSION:=HEAD
              PKG_SOURCE_URL:=https://github.com/OnionIoT/python-spidev.git
              PKG_SOURCE_SUBDIR:=$(PKG_NAME)
              PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE).tar.gz
              PKG_BUILD_DIR:=$(COMPILE_DIR)/$(PKG_NAME)
              
              include $(BUILD_DIR)/package.mk
              
              # python module package
              define Package/python3-spidev
              	SECTION:=lang
              	CATEGORY:=Languages
              	SUBMENU:=Python
              	TITLE:=Python3 module with object that implements SPI transactions
              	DEPENDS:=+python3
              endef
              
              define Package/python3-spidev/description
              Python3 module with object that implements SPI transactions
              endef
              
              
              TARGET_CFLAGS += $(FPIC)
              TARGET_LIBS += -l m
              
              PYTHON3_VERSION = 3.5
              TARGET_PYTHON3_INC += "-I$(STAGING_DIR)/usr/include/python$(PYTHON3_VERSION)/"
              
              define Build/Compile	
              	$(MAKE) -C $(PKG_BUILD_DIR) wipe
              	
              	$(MAKE) -C $(PKG_BUILD_DIR) \
              	CC="$(TARGET_CC)" \
              	CFLAGS="$(TARGET_CFLAGS)" \
              	LDFLAGS="$(TARGET_LDFLAGS)" \
              	LIB="$(TARGET_LIBS)" \
              	PYTHON_VERSION="$(PYTHON3_VERSION)" \
              	PYINC="$(TARGET_PYTHON3_INC)"
              endef
              
              define Package/python3-spidev/install
              	# install the python module
              	$(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON3_VERSION)
              	$(CP)   $(PKG_BUILD_DIR)/lib/python$(PYTHON3_VERSION)/spidev.so $(1)/usr/lib/python$(PYTHON3_VERSION)
              endef
              
              $(eval $(call BuildPackage,python3-spidev))
              

              I then included the package in "make menuconfig". Then I did make, and it seems that I do now have the spidev package!

              Many thanks for your assistance!

              1 Reply Last reply Reply Quote Share 1
              • 1 / 1
              • First post
                Last post

              Copyright © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号

              行为准则 | 用户协议 | 隐私权政策