introduction this git repo
- DHKim's STM32F7508 Discovery kit(F7508 down below) infomation shareing
- This Git Repo contains that not only studying STM32F7508 but also Touch GFX
- This project sponsered by "STMicroelectroincs South Korea branch" and "Naver cafe 전자공작"
- my goal is get used it F7508's cotrol peri and make user application
이 깃허브 저장소 간단 소개
- 제가 STM32F7508 Discovery kit(이하 F7508)학습한 내용에 대하여 공유합니다
- F7508 뿐만 아니라 Touch GFX 에 대한 내용도 포함됩니다
- 이 프로젝트는 ST마이크로 코리아와 네이버 카페 전자공작에서 후원(보드)을 받아 진행합니다.
- 이 프로젝트를 통해 많은 분들이 F7508 을 활용한 다양한 응용 어플리케이션을 제작하는데 도움이 되기를 바랍니다
최종결과 : 원문(네이버 카페 전자공작 : https://cafe.naver.com/circuitsmanual/214004)
- 준우승 ㅎㅎ!! 화웨이 와치를 받아버렸따!! : https://cafe.naver.com/circuitsmanual/214059
Compilation of kernel:
-
Pre-requisite
-
Initialise cross-compilation via SDK
-
Prepare kernel source code
-
Manage the kernel source code
-
Configure kernel source code
-
Compile kernel source code
-
Update software on board
-
Pre-requisite:
OpenSTLinux SDK must be installed.
For kernel build, you need to install:
- libncurses and libncursesw dev package Ubuntu: sudo apt-get install libncurses5-dev libncursesw5-dev Fedora: sudo yum install ncurses-devel
- mkimage Ubuntu: sudo apt-get install u-boot-tools Fedora: sudo yum install u-boot-tools
Only if you like to have a git management of the code (see section 4 [Manage the kernel source code]):
- git: Ubuntu: sudo apt-get install git-core gitk Fedora: sudo yum install git
If you have never configured your git configuration, run the following commands:
- Initialise cross-compilation via SDK:
Source SDK environment: $> source /environment-setup-cortexa7t2hf-neon-vfpv4-openstlinux_weston-linux-gnueabi
To verify if your cross-compilation environment has been put in place correctly, run the following command: $> set | grep CROSS CROSS_COMPILE=arm-openstlinux_weston-linux-gnueabi-
Warning: the environment is valid only on the shell session where you have sourced the SDK environment.
- Prepare kernel source:
If you have the tarball and the list of patches, then you must extract the
tarball and apply the patches.
NB: if you like to have a git management of the code, see section 4 [Manage the
kernel source code]
if there is some patch, please apply it on source code
$> for p in ls -1 <path to patch>/*.patch
; do patch -p1 < $p; done
- Manage the kernel source code:
If you like to have a better management of change made on kernel source, you can use git.
- With the kernel source code extracted in the section 3 [Prepare kernel source]
$> cd $ > test -d .git || git init . && git add . && git commit -m "new kernel" && git gc$> git checkout -b WORKING Apply patches: $ > for p inls -1 <path to patch>/*.patch
; do git am $p; done NB: this is the fastest way to get your kernel source code ready for development
Or
-
With the kernel source code from the Linux kernel git repositories: URL: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git Branch: master Revision: INVALID
$> git clone https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
$> cd $ > git checkout -b WORKING INVALID $> for p inls -1 <path to patch>/*.patch
; do git am $p; done NB: this way is slightly slower than the tarball extraction but you get advantage of all git history.
If you are using git for managing your source code, kernel makefile get the SHA1
of current git and add it to kernel version number generated.
ex.: 4.9.23-g3e866b0 (kernel version + SHA1 of current git commit)
To bypass this auto-generation of kernel version number:
- With scmversion file: 4.9.23
- Without scmversion file: 4.9.23-g3e866b0 This configuration allows to build new kernel from modified source code without any issue when using the new kernel binary on target regarding any external kernel module already available on target rootfs (as built without scmversion).
- Configure kernel source code:
There are two methods to configure and compile kernel source code:
- Inside kernel source tree directory
- Outside kernel source tree in a build directory We highly preconized the build is a build directory method as:
- It avoids mixing files generated by the build with the source files inside same directories
- To remove all the files generated by the build, it's enough to remove the build directory
- You can build for different configurations in several build directories, e.g.:
- build in "build_1" for a first kernel configuration
- build in "build_2" for a second kernel configuration Then this leaves the 2 images available for tests
-
Configure on a build directory (different of kernel source code directory) Here for example, build directory is located at the same level of kernel source code
$> cd $ > mkdir -p ../build $> make ARCH=arm O="$PWD/../build" multi_v7_defconfig fragment*.configIf there are some fragments, apply them
- manually one by one:
$> scripts/kconfig/merge_config.sh -m -r -O $PWD/../build
$PWD/../build/.config ../fragment-01-xxx.config $ > scripts/kconfig/merge_config.sh -m -r -O $PWD/../build$PWD/../build/.config ../fragment-02-xxx.config ... $ > yes '' | make ARCH=arm oldconfig O="$PWD/../build" - or, by loop:
$> for f in
ls -1 ../fragment*.config
; do scripts/kconfig/merge_config.sh -m -r -O $PWD/../build $PWD/../build/.config$f; done $ > yes '' | make ARCH=arm oldconfig O="$PWD/../build"
- manually one by one:
$> scripts/kconfig/merge_config.sh -m -r -O $PWD/../build
-
Configure on the current source code directory
$> cd $ > make ARCH=arm multi_v7_defconfig fragment*.configIf there are some fragments, apply them
- manually one by one:
$> scripts/kconfig/merge_config.sh -m -r .config ../fragment-01-xxxx.config $ > scripts/kconfig/merge_config.sh -m -r .config ../fragment-02-xxxx.config ... $> yes '' | make oldconfig - or, by loop:
$> for f in
ls -1 ../fragment*.config
; do scripts/kconfig/merge_config.sh -m -r .config$f; done $ > yes '' | make ARCH=arm oldconfig
- manually one by one:
NB: Two types of fragments are provided: * official fragments (fragment-xxx.config) * optional fragments as example (optional-fragment-xxx.config) to add a feature not enabled by default. The order in which fragments are applied is determined by the number of the fragment filename (fragment-001, fragment-002, e.g.). Please pay special attention to the naming of your optional fragments to ensure you select the right features.
- Compile kernel source code:
You MUST compile from the directory on which the configuration has been done (i.e. the directory which contains the '.config' file).
It's preconized to use the method with dedicated build directory for a better managment of changes made on source code (as all build artifacts will be located inside the dedicated build directory).
-
Compile and install on a build directory (different of kernel source code directory) $> cd
- Build kernel images (uImage and vmlinux) and device tree (dtbs) $> make ARCH=arm uImage vmlinux dtbs LOADADDR=0xC2000040 O="$PWD/../build"
- Build kernel module $> make ARCH=arm modules O="$PWD/../build"
- Generate output build artifacts
$> make ARCH=arm INSTALL_MOD_PATH="$PWD/../build/install_artifact" modules_install O="$PWD/../build"
$> mkdir -p
$PWD/../build/install_artifact/boot/ $ > cp $PWD/../build/arch/arm/boot/uImage$PWD/../build/install_artifact/boot/ $ > cp $PWD/../build/arch/arm/boot/dts/st*.dtb $PWD/../build/install_artifact/boot/
or
$> cd
- Build kernel images (uImage and vmlinux) and device tree (dtbs) $> make ARCH=arm uImage vmlinux dtbs LOADADDR=0xC2000040
- Build kernel module $> make ARCH=arm modules
- Generate output build artifacts
$> make ARCH=arm INSTALL_MOD_PATH="$PWD/../build/install_artifact" modules_install
$> mkdir -p
$PWD/../build/install_artifact/boot/ $ > cp $PWD/../build/arch/arm/boot/uImage$PWD/../build/install_artifact/boot/ $ > cp $PWD/../build/arch/arm/boot/dts/st*.dtb $PWD/../build/install_artifact/boot/
-
Compile and install on the current source code directory $> cd
- Build kernel images (uImage and vmlinux) and device tree (dtbs) $> make ARCH=arm uImage vmlinux dtbs LOADADDR=0xC2000040
- Build kernel module $> make ARCH=arm modules
- Generate output build artifacts
$> make ARCH=arm INSTALL_MOD_PATH="$PWD/install_artifact" modules_install
$> mkdir -p
$PWD/install_artifact/boot/ $ > cp $PWD/arch/arm/boot/uImage$PWD/install_artifact/boot/ $ > cp $PWD/arch/arm/boot/dts/st*.dtb $PWD/install_artifact/boot/
- Update software on board:
- Bootfs: Bootfs contains the kernel and the devicetree.
- Rootfs: Rootfs contains the external kernel modules. Please refer to User guide for more details.
-
kernel + devicetree
$> cd /install_artifact if bootfs are not monted on target, mount it $ > ssh root@ df to see if there is a partition mounted on /boot else$> ssh root@ mount /boot $ > scp -r boot/* root@:/boot/ $> ssh root@ umount /boot -
kernel modules
$> cd /install_artifact Remove the link on install_artifact/lib/modules// $ > rm lib/modules//source lib/modules//build Optionally, strip kernel modules (to reduce the size of each kernel modules) $> find . -name "*.ko" | xargs $STRIP --strip-debug --remove-section=.comment --remove-section=.note --preserve-datesCopy kernel modules: $> scp -r lib/modules/* root@:/lib/modules/
Generate a list of module dependencies (modules.dep) and a list of symbols provided by modules (modules.symbols):
$> ssh root@ /sbin/depmod -a Synchronize data on disk with memory $ > ssh root@ sync Reboot the board in order to take update into account $> ssh root@ reboot
-
kernel + devicetree $> cd /install_artifact Verify sdcard are mounted on your Linux PC: /media/$USER/bootfs $> cp -r boot/* /media/$USER/bootfs/ Depending of your Linux configuration, you may call the command under sudo $> sudo cp -r boot/* /media/$USER/bootfs/ Don't forget to unmount properly sdcard
-
kernel modules
$> cd /install_artifact Remove the link on install_artifact/lib/modules// $ > rm lib/modules//source lib/modules//build Optionally, strip kernel modules (to reduce the size of each kernel modules) $> find . -name "*.ko" | xargs $STRIP --strip-debug --remove-section=.comment --remove-section=.note --preserve-datesVerify sdcard are mounted on your Linux PC: /media/$USER/rootfs Copy kernel modules: $> cp -r lib/modules/* /media/$USER/rootfs/lib/modules/ Depending of your Linux configuration, you may call the command under sudo $> sudo cp -r lib/modules/* /media/$USER/rootfs/lib/modules/ Don't forget to unmount properly sdcard
Generate a list of module dependencies (modules.dep) and a list of symbols provided by modules (modules.symbols):
$> ssh root@ depmod -a Synchronize data on disk with memory $ > ssh root@ sync Reboot the board in order to take update into account $> ssh root@ reboot
You MUST configure first, via U-Boot, the board into usb mass storage:
-
Plug the SDCARD on Board.
-
Start the board and stop on U-boot shell: Hit any key to stop autoboot: 0 STM32MP>
-
plug an USB cable between the PC and the board via USB OTG port.
-
On U-Boot shell, call the usb mass storage functionnality: STM32MP> ums 0 mmc 0 ums <dev type: mmc|usb> <dev[:part]> Example: For SDCARD: ums 0 mmc 0 For USB Disk: ums 0 usb 0
-
kernel + devicetree
$> cd /install_artifact Remove the link on install_artifact/lib/modules// $ > rm lib/modules//source lib/modules//build Optionally, strip kernel modules (to reduce the size of each kernel modules) $> find . -name "*.ko" | xargs $STRIP --strip-debug --remove-section=.comment --remove-section=.note --preserve-datesVerify sdcard mount point are mounted on your Linux PC: /media/$USER/bootfs $> cp -r boot/* /media/$USER/bootfs/ Depending of your Linux configuration, you may call the command under sudo $> sudo cp -rf boot/* /media/$USER/bootfs/ Don't forget to unmount properly sdcard Warning: kernel and device tree file name must be aligned between extlinux.conf file and file system.
-
kernel modules
$> cd /install_artifact Remove the link on install_artifact/lib/modules// $ > rm lib/modules//source lib/modules//build Optionally, strip kernel modules (to reduce the size of each kernel modules) $> find . -name "*.ko" | xargs $STRIP --strip-debug --remove-section=.comment --remove-section=.note --preserve-datesVerify sdcard mount point are mounted on your Linux PC: /media/$USER/rootfs Copy kernel modules: $> cp -rf lib/modules/* /media/$USER/rootfs/lib/modules/ Depending of your Linux configuration, you may call the command under sudo $> sudo cp -r lib/modules/* /media/$USER/rootfs/lib/modules/ Don't forget to unmount properly sdcard
At next runtime, don't forget to generate a list of module dependencies (modules.dep) and a list of symbols provided by modules (modules.symbols): $on board> depmod -a Synchronize data on disk with memory $on board> sync Reboot the board in order to take update into account $on board> reboot
- Useful information:
-
How to re-generate kernel database on board: $on board> depmod -a (don't forget to synchronize the filesystem before to reboot) $on board> sync
-
How to see the list of external kernel modules loaded: $on board> lsmod
-
How to see information about kernel module: $on board> modinfo ./install_artifact/lib/modules//kernel/drivers/leds/led-class-flash.ko Example usage: filename: ./install_artifact/lib/modules/4.9.23-g3e866b0/kernel/drivers/leds/led-class-flash.ko license: GPL v2 description: LED Flash class interface author: Jacek Anaszewski [email protected] depends: intree: Y vermagic: 4.9.23-g3e866b0 SMP mod_unload ARMv7 p2v8