Skip to main content
Visitor II
February 21, 2022
Solved

Connecting cubeMX generated dts file with yocto

  • February 21, 2022
  • 1 reply
  • 4021 views

Hi everyone,

I am using stm32mp157f-dk2 with openSTLinux-5.4-dunfell-eglf distribution.

I would like to configure my device tree using cubeMX.

The generated dts file seems OK to me. However, how can I tell yocto to use my newly generated device tree?

The instruction on https://wiki.st.com/stm32mpu/wiki/How_to_create_your_own_machine

didn't mention anything about this.

I have tried to modify the meta-st-stm32mp-addons/classes/cubemx-stm32mp.bbclass but it doesn't work.

It seems to me that the default meta-st-stm32mp-addons/conf/machine/stm32mp1-mx.conf is not used.

​Regards,

Leung

    This topic has been closed for replies.
    Best answer by Kevin HUBER

    Hello @WLeun.3​ ,

    You have to use the version of CubeMX delivered with your OSTL (5.4) version which is the STM32CubeMX6.1.

    Wiki: https://wiki.st.com/stm32mpu-ecosystem-v2/wiki/STM32MP15_ecosystem_release_note_-_v2.1.0#STM32CubeMX

    STM32CubeMX v6.1 -> This one generates Device tree compliance with openstlinux-5.4-dunfell-mp1-20-11-12 tag

    0693W00000KbAVhQAN.png 

    To my knowledge there is no other way to use an old version of OpenSTLinux.

    Regards,

    Kevin

    1 reply

    Technical Moderator
    February 21, 2022

    Hello @WLeun.3​ ,

    The information that you need are in the wiki page that you shared:

    you have to browse with CubeMX until the folder "<path of STM32MP1_Distribution_Package>/layers/meta-st/meta-st-stm32mp-addons/mx/"

    • At build 3 sub-folders are created and populated with generated device tree files :

    - <ProjectName>/kernel

    - <ProjectName>/u-boot

    - <ProjectName>/tf-a

    Where <ProjectName> is the “STM32CubeMX user project name�?

    • Then you must edit the .conf file of your machine, located in "layers/meta-st/meta-st-stm32mp-addons/conf/machine/" as explained here:

    https://wiki.st.com/stm32mpu/wiki/How_to_create_your_own_machine#Edit_the_new_machine_file-_stm32mp1--3CProjectName-3E-conf

    CubeMX Project config
    You have to uncomment and configure the following variables to set your CubeMX project:
    - CUBEMX_DTB name of CubeMX generated device tree files, without file extension (e.g. stm32mp157c-<ProjectName>-mx)
    - CUBEMX_PROJECT path of CubeMX generated device tree files relative to layer path folder (e.g. mx/STM32MP157C-EV1/my-demo/DeviceTree/my-demo)

    All your modifications must be done after the lines:

    ###########################################################################
    #
    # User machine customization sections
    #
    ###########################################################################

    In order to give a better view on how to configure these variables, some machine samples are provided to show how to set-up a disco and eval board cubeMX machine: refer to conf/machine/examples from meta-st-stm32mp-addons layer.

    For example:

    layers/meta-st/meta-st-stm32mp-addons/conf/machine/examples/stm32mp1-disco-mx.conf.sample

    You will see how to set the variable CUBEMX_DTB and CUBEMX_PROJECT.

    Then when you build, follow these steps: https://wiki.st.com/stm32mpu/wiki/How_to_create_your_own_machine#Compile_your_image_with_the_yocto_build_process

    Especially this command to specify your machine and use the .conf that you edited/created:

    MACHINE=stm32mp1-<ProjectName> DISTRO=openstlinux-weston source layers/meta-st/script/envsetup.sh

    Regards,

    Kevin

    In order to give better visibility on the answered topics, please click on 'Select as Best' on the reply which solved your issue or answered your question. See also 'Best Answers'

    WLeun.3Author
    Visitor II
    February 22, 2022

    Hi Kevin,

    My problem was that I didn't re-export my MACHINE variable, as MACHINE=stm32mp1-<ProjectName>.

    After fixing this, I recompiled the image. The following error pop out:

    ERROR: /home/lascar/Qt/layers/meta-st/meta-st-stm32mp/recipes-security/optee/optee-os-stm32mp_3.9.0.bb: 
     
    [cubemx-stm32mp] Not able to find "mx/DK2/DeviceTree/CA7/DK2" path from current BBPATH var:
    	/home/lascar/Qt/build-openstlinuxeglfs-stm32mp1-DK2
    	/home/lascar/Qt/layers/meta-st/meta-st-stm32mp-addons
    	/home/lascar/Qt/layers/meta-openembedded/meta-python
    	/home/lascar/Qt/layers/meta-openembedded/meta-oe
    	/home/lascar/Qt/layers/meta-openembedded/meta-gnome
    	/home/lascar/Qt/layers/meta-openembedded/meta-initramfs
    	/home/lascar/Qt/layers/meta-openembedded/meta-multimedia
    	/home/lascar/Qt/layers/meta-openembedded/meta-networking
    	/home/lascar/Qt/layers/meta-openembedded/meta-webserver
    	/home/lascar/Qt/layers/meta-openembedded/meta-filesystems
    	/home/lascar/Qt/layers/meta-openembedded/meta-perl
    	/home/lascar/Qt/layers/meta-st/meta-st-stm32mp
    	/home/lascar/Qt/layers/meta-qt5
    	/home/lascar/Qt/layers/meta-st/meta-st-openstlinux
    	/home/lascar/Qt/layers/openembedded-core/meta.

    This is already the entire error log.

    A quick review of optee-os-stm32mp_3.9.0.bb show me the following

    COMPATIBLE_MACHINE = "(stm32mpcommon)"
     
    OPTEEMACHINE ?= "stm32mp1"
    OPTEEMACHINE_stm32mp1common = "stm32mp1"
    OPTEEOUTPUTMACHINE ?= "stm32mp1"
    OPTEEOUTPUTMACHINE_stm32mp1common = "stm32mp1"

    However, manually changing these variable to stm32mp1-<ProjectName> doesn't work as intended? stm32mp1 is the original MACHINE variable that I used.

    Any idea what may went wrong here?

    I suspect that it is something related to my image(st-example-image-qt) because the meta-st-stm32mp-addons was not included originally. I have to manually used bitbake-layers add-layer command to add it into my project.

    Regards,

    Leung

    Technical Moderator
    February 22, 2022

    Hello @WLeun.3​ ,

    I think that your error is related to:

    you have to browse with CubeMX until the folder "<path of STM32MP1_Distribution_Package>/layers/meta-st/meta-st-stm32mp-addons/mx/"

    • At build 3 sub-folders are created and populated with generated device tree files :

    - <ProjectName>/kernel

    - <ProjectName>/u-boot

    - <ProjectName>/tf-a

    Where <ProjectName> is the “STM32CubeMX user project name�?

    -----------------------

    Do you have something in your folder "<path of STM32MP1_Distribution_Package>/layers/meta-st/meta-st-stm32mp-addons/mx/" ?

    Because the error seems to indicate that these 3 folders haven't be created by CubeMx.

    Regards,

    Kevin