Last edited 3 weeks ago

Cross-compile with OpenSTLinux SDK: Difference between revisions

Registered User
Registered User
Tag: 2017 source edit
 
(22 intermediate revisions by 7 users not shown)
Line 1: Line 1:
<noinclude>{{ApplicableFor
|MPUs list=STM32MP13x, STM32MP15x, STM32MP21x, STM32MP23x, STM32MP25x
|MPUs checklist=STM32MP13x, STM32MP15x, STM32MP21x, STM32MP23x, STM32MP25x
}}</noinclude>
<noinclude>
<noinclude>
{{ArticleMainWriter | Jean-ChristopheT}}
{{ReviewersList | NathalieS, BernardP, RomualdJ , DenisH, Jean-PhilippeR}}
{{ArticleApprovedVersion | Jean-ChristopheT | NathalieS (Passed, 4Jun'18), BernardP (PASS, 28MAy'18), DenisH (Passed, 6Jun'18), Jean-PhilippeR (Passed, 23May'18) | No previous approved version | PhilipS  - 4Jun'18 - 7646 | 20Jun'18}}


[[Category:SDK]]
</noinclude>
<noinclude>
==Article purpose==
==Article purpose==
The pieces of software delivered as source code within the OpenSTLinux Developer Package (for example the Linux kernel) can be modified. External out-of-tree Linux kernel modules, and pieces of applicative software (for example Linux applications) can also be developed thanks to this Developer Package, and loaded onto the board.
The pieces of software delivered as source code within the OpenSTLinux Developer Package (for example the Linux kernel) can be modified. External out-of-tree Linux kernel modules, and pieces of applicative software (for example Linux applications) can also be developed thanks to this Developer Package, and loaded onto the board.


The build of all these pieces of software by means of the [[SDK for OpenSTLinux distribution]], and the deployment on-target of the resulting images is explained below.
The build of all these pieces of software by means of the [[SDK for OpenSTLinux distribution]], and the deployment on-target of the resulting images is explained below.
{{Warning|To use the cross-compilation efficiently with the OpenSTLinux SDK, it is recommended that you read the Developer Package article relative to the Series of your STM32 microprocessor: [[:Category:Developer Package]]}}
{{Warning|To use the cross-compilation efficiently with the OpenSTLinux SDK, it is recommended that you read the Developer Package article relative to the series of your STM32 microprocessor: [[:Category:Developer Package]]}}


</noinclude>
</noinclude>
===Modifying the Linux kernel===
===Modifying the Linux kernel===
Prerequisites:
Prerequisites:
* the [[STM32MP1 Developer Package#Installing the SDK|SDK is installed]]  
* the [[STM32MPU Developer Package#Installing the SDK|SDK is installed]]  
* the [[STM32MP1 Developer Package#Starting up the SDK|SDK is started up]]
* the [[STM32MPU Developer Package#Starting up the SDK|SDK is started up]]
* the [[STM32MP1 Developer Package#Installing the Linux kernel|Linux kernel is installed]]
* the [[STM32MPU Developer Package#Installing the OpenSTLinux BSP packages|BSP package is installed]]


{{highlight|'''The ''<Linux kernel installation directory>/README.HOW_TO.txt'' helper file gives the commands to:'''}} <br>
{{highlight|'''The ''<Linux kernel installation directory>/README.HOW_TO.txt'' helper file gives the commands to:'''}} <br>
Line 31: Line 28:
* [[How to cross-compile with the Developer Package#Modifying a built-in Linux kernel device driver|Modification of a built-in device driver]]
* [[How to cross-compile with the Developer Package#Modifying a built-in Linux kernel device driver|Modification of a built-in device driver]]
* [[How to cross-compile with the Developer Package#Modifying an external in-tree Linux kernel module|Modification of an external in-tree module]]
* [[How to cross-compile with the Developer Package#Modifying an external in-tree Linux kernel module|Modification of an external in-tree module]]
 
* [[How to cross-compile with the Developer Package#Adding an external out-of-tree Linux kernel module|Adding an external out-of-tree Linux kernel module]]
===Adding external out-of-tree Linux kernel modules===
Prerequisites:
* the [[STM32MP1 Developer Package#Installing the SDK|SDK is installed]]
* the [[STM32MP1 Developer Package#Starting up the SDK|SDK is started up]]
* the [[STM32MP1 Developer Package#Installing the Linux kernel|Linux kernel is installed]]
 
Most device drivers (or modules) in the Linux kernel can be compiled either into the kernel itself (built-in, or internal module) or as Loadable Kernel Modules (LKMs, or external modules) that need to be placed in the root file system under the /lib/modules directory. An external module can be in-tree (in the kernel tree structure), or out-of-tree (outside the kernel tree structure).
 
External Linux kernel modules are compiled taking reference to a Linux kernel source tree and a Linux kernel configuration file (''.config''). <br>
Thus, a makefile for an external Linux kernel module points to the Linux kernel directory that contains the source code and the configuration file, with the '''"-C <Linux kernel path>"''' option. <br>
This makefile also points to the directory that contains the source file(s) of the Linux kernel module to compile, with the '''"M=<Linux kernel module path>"''' option. <br>
 
A generic makefile for an external out-of-tree Linux kernel module looks like the following:
<pre>
# Makefile for external out-of-tree Linux kernel module
 
# Object file(s) to be built
obj-m := <module source file(s)>.o
 
# Path to the directory that contains the Linux kernel source code
# and the configuration file (.config)
KERNEL_DIR ?= <Linux kernel path>
 
# Path to the directory that contains the generated objects
DESTDIR ?= <Linux kernel installation directory>
 
# Path to the directory that contains the source file(s) to compile
PWD := $(shell pwd)
 
default:
$(MAKE) -C $(KERNEL_DIR) M=$(PWD) modules
 
install:
$(MAKE) -C $(KERNEL_DIR) M=$(PWD) INSTALL_MOD_PATH=$(DESTDIR) modules_install
 
clean: 
$(MAKE) -C $(KERNEL_DIR) M=$(PWD) clean
</pre>
 
Such module is then cross-compiled with the following commands:
$ make clean
$ make
$ make install
 
You can refer to the following simple example:
* [[How to cross-compile with the Developer Package#Adding an external out-of-tree Linux kernel module|Addition of an external out-of-tree module]]


===Adding Linux user space applications===
===Adding Linux user space applications===
Prerequisites:
Prerequisites:
* the [[STM32MP1 Developer Package#Installing the SDK|SDK is installed]]  
* the [[STM32MPU Developer Package#Installing the SDK|SDK is installed]]  
* the [[STM32MP1 Developer Package#Starting up the SDK|SDK is started up]]
* the [[STM32MPU Developer Package#Starting up the SDK|SDK is started up]]


Once a suitable cross-toolchain (OpenSTLinux SDK) is installed, it is easy to develop a project outside of the OpenEmbedded build system. <br>
Once a suitable cross-toolchain (OpenSTLinux SDK) is installed, it is easy to develop a project outside of the OpenEmbedded build system. <br>
There are different ways to use the SDK toolchain directly, among which Makefile and Autotools. <br>
There are different ways to use the SDK toolchain directly, among which Makefile and Autotools. <br>
Whatever the method, it relies on:
Whatever the method, it relies on:
* the sysroot that is associated with the cross-toolchain, and that contains the header files and libraries needed for generating binaries (see [[SDK for OpenSTLinux distribution#SDK startup|SDK startup]])
* the sysroot that is associated with the cross-toolchain, and that contains the header files and libraries needed for generating binaries (see [[SDK for OpenSTLinux distribution#Native and target sysroots|target sysroot]])
{{ReviewsComments|YCO 15-Feb-19: bad link , should be -> target sysroot}}
* the environment variables created by the SDK environment setup script (see [[SDK for OpenSTLinux distribution#SDK startup|SDK startup]])
* the environment variables created by the SDK environment setup script (see [[SDK for OpenSTLinux distribution#Native and target sysroots|target sysroot]])
{{ReviewsComments|YCO 15-Feb-19: bad link , should be -> SDK startup}}


You can refer to the following simple example:
You can refer to the following simple example:
Line 97: Line 46:
===Modifying the U-Boot===
===Modifying the U-Boot===
Prerequisites:
Prerequisites:
* the [[STM32MP1 Developer Package#Installing the SDK|SDK is installed]]  
* the [[STM32MPU Developer Package#Installing the SDK|SDK is installed]]  
* the [[STM32MP1 Developer Package#Starting up the SDK|SDK is started up]]
* the [[STM32MPU Developer Package#Starting up the SDK|SDK is started up]]
* the [[STM32MP1 Developer Package#Installing the U-Boot|U-Boot is installed]]
* the [[STM32MPU Developer Package#Installing the OpenSTLinux BSP packages|BSP package is installed]]


{{highlight|'''The ''&#60;U-Boot installation directory>/README.HOW_TO.txt'' helper file gives the commands to:'''}} <br>
{{highlight|'''The ''&#60;U-Boot installation directory>/README.HOW_TO.txt'' helper file gives the commands to:'''}} <br>
Line 110: Line 59:
===Modifying the TF-A===
===Modifying the TF-A===
Prerequisites:
Prerequisites:
* the [[STM32MP1 Developer Package#Installing the SDK|SDK is installed]]
* the [[STM32MPU Developer Package#Installing the SDK|SDK is installed]]
* the [[STM32MP1 Developer Package#Starting up the SDK|SDK is started up]]
* the [[STM32MPU Developer Package#Starting up the SDK|SDK is started up]]
* the [[STM32MP1 Developer Package#Installing the TF-A|TF-A is installed]]
* the [[STM32MPU Developer Package#Installing the OpenSTLinux BSP packages|BSP package is installed]]


{{highlight|'''The ''<TF-A installation directory>/README.HOW_TO.txt'' helper file gives the commands to:'''}} <br>
{{highlight|'''The ''<TF-A installation directory>/README.HOW_TO.txt'' helper file gives the commands to:'''}} <br>
Line 123: Line 72:
===Modifying the OP-TEE===
===Modifying the OP-TEE===
Prerequisites:
Prerequisites:
* the [[STM32MP1 Developer Package#Installing the SDK|SDK is installed]]
* the [[STM32MPU Developer Package#Installing the SDK|SDK is installed]]
* the [[STM32MP1 Developer Package#Starting up the SDK|SDK is started up]]
* the [[STM32MPU Developer Package#Starting up the SDK|SDK is started up]]
* the [[STM32MP1 Developer Package#Installing the OP-TEE|OP-TEE is installed]]
* the [[STM32MPU Developer Package#Installing the OpenSTLinux BSP packages|BSP package is installed]]


{{highlight|'''The ''<OP-TEE installation directory>/README.HOW_TO.txt'' helper file gives the commands to:'''}} <br>
{{highlight|'''The ''<OP-TEE installation directory>/README.HOW_TO.txt'' helper file gives the commands to:'''}} <br>
Line 131: Line 80:
<span style="font-size:21px">☐</span> deploy the OP-TEE (that is, update the software on board) <br>
<span style="font-size:21px">☐</span> deploy the OP-TEE (that is, update the software on board) <br>


{{ReviewsComments|YCO 15-Feb-19 : link missing "Modification of the OP-TEE"<br>
You can refer to the following simple example:
There is no link because the page "How_to_cross-compile_with_the_Developer_Package" doesn't contain a paragraph for TEE, <br>
* [[How to cross-compile with the Developer Package#Modifying the OP-TEE OS|Modification of the OP-TEE OS]]
SO THIS PARAGRAH "Modifying the OP-TEE" is not useful, it gives no more informations.<br>
 
The paragraph  "5.5 Installing the OP-TEE" is enough }}
<noinclude>
[[Category:SDK]]
{{PublicationRequestId | 7646 | 2018-06-04 | PhilipS}}
</noinclude>

Latest revision as of 14:01, 1 July 2025

Applicable for STM32MP13x lines, STM32MP15x lines, STM32MP21x lines, STM32MP23x lines, STM32MP25x lines


1. Article purpose[edit | edit source]

The pieces of software delivered as source code within the OpenSTLinux Developer Package (for example the Linux kernel) can be modified. External out-of-tree Linux kernel modules, and pieces of applicative software (for example Linux applications) can also be developed thanks to this Developer Package, and loaded onto the board.

The build of all these pieces of software by means of the SDK for OpenSTLinux distribution, and the deployment on-target of the resulting images is explained below.

Warning white.png Warning
To use the cross-compilation efficiently with the OpenSTLinux SDK, it is recommended that you read the Developer Package article relative to the series of your STM32 microprocessor: Category:Developer Package


1.1. Modifying the Linux kernel[edit | edit source]

Prerequisites:

The <Linux kernel installation directory>/README.HOW_TO.txt helper file gives the commands to:
configure the Linux kernel
cross-compile the Linux kernel
deploy the Linux kernel (that is, update the software on board)

You can refer to the following simple examples:

1.2. Adding Linux user space applications[edit | edit source]

Prerequisites:

Once a suitable cross-toolchain (OpenSTLinux SDK) is installed, it is easy to develop a project outside of the OpenEmbedded build system.
There are different ways to use the SDK toolchain directly, among which Makefile and Autotools.
Whatever the method, it relies on:

  • the sysroot that is associated with the cross-toolchain, and that contains the header files and libraries needed for generating binaries (see target sysroot)
  • the environment variables created by the SDK environment setup script (see SDK startup)

You can refer to the following simple example:

1.3. Modifying the U-Boot[edit | edit source]

Prerequisites:

The <U-Boot installation directory>/README.HOW_TO.txt helper file gives the commands to:
cross-compile the U-Boot
deploy the U-Boot (that is, update the software on board)

You can refer to the following simple example:

1.4. Modifying the TF-A[edit | edit source]

Prerequisites:

The <TF-A installation directory>/README.HOW_TO.txt helper file gives the commands to:
cross-compile the TF-A
deploy the TF-A (that is, update the software on board)

You can refer to the following simple example:

1.5. Modifying the OP-TEE[edit | edit source]

Prerequisites:

The <OP-TEE installation directory>/README.HOW_TO.txt helper file gives the commands to:
cross-compile the OP-TEE
deploy the OP-TEE (that is, update the software on board)

You can refer to the following simple example: