Pages

2017-02-24

STM32 Toolchain and Flash Loader


[Toolchain]

  * use "GNU ARM Embedded Toolchain]



[Flash Loader]


  * Windows
    - use the "STM32 Flash Loader Demonstrator"
    - http://www.st.com/en/development-tools/flasher-stm32.html

  * Linux / Mac
    - Java      : STM32 USART Bootloader => https://sourceforge.net/projects/bootstm32/
    - Python : stm32loader script             => https://github.com/jsnyder/stm32loader
    - C          : stm32ld                              => https://github.com/jsnyder/stm32ld



2017-02-22

Yocto:i.MX6ULL - Customize Kernel Modules


1) Raspberry Pi - loaded network modules for NAT
pi@T0020:~ $ lsmod

Module                  Size  Used by
iptable_filter          1245  1 
cdc_acm                16033  2 
rndis_host              5252  0 
cdc_ether               4293  1 rndis_host
ip_tables              11417  1 iptable_filter
x_tables               12611  2 ip_tables,iptable_filter
bcm2835_gpiomem         2860  0 
i2c_bcm2708             4920  0 
bcm2835_rng             1763  0 
cp210x                  8363  1 
usbserial              21779  3 cp210x
uio_pdrv_genirq         2944  0 
uio                     7753  1 uio_pdrv_genirq
snd_bcm2835            19802  0 
snd_pcm                73474  1 snd_bcm2835
snd_timer              18848  1 snd_pcm
snd                    50779  3 snd_bcm2835,snd_timer,snd_pcm
i2c_dev                 5671  2 
fuse                   80694  1 
ipv6                  338660  30


2) Yocto Kernel Build Structure

  * linux-imx
./meta-fsl-arm/recipes-kernel/linux/linux-imx-4.1.15
./meta-fsl-arm/recipes-kernel/linux/linux-imx_4.1.15.bb
./meta-fsl-arm/recipes-kernel/linux/linux-imx-mfgtool_4.1.15.bb
./meta-fsl-arm/recipes-kernel/linux/linux-imx.inc
./meta-fsl-bsp-release/imx/meta-bsp/recipes-kernel/linux/linux-imx_4.1.15.bb
./meta-fsl-bsp-release/imx/meta-bsp/recipes-kernel/linux/linux-imx-mfgtool_4.1.15.bb
./meta-fsl-bsp-release/imx/meta-bsp/recipes-kernel/linux/linux-imx_%.bbappend

  * imx_v7_defconfig
./imx6ull14x14evk-fb/tmp/work-shared/imx6ull14x14evk/kernel-source/arch/arm/configs/imx_v7_defconfig


[Before starting the next steps, Read the manual]
* http://www.yoctoproject.org/docs/1.8/kernel-manual/kernel-manual.html
* http://www.yoctoproject.org/docs/1.8/dev-manual/dev-manual.html#understanding-and-creating-layers


3) Add T0040 Layer to BitBake

  * Folder Structure
${fsl-release-bsp}/sources/meta-t0040
${fsl-release-bsp}/sources/meta-t0040/conf
${fsl-release-bsp}/sources/meta-t0040/recipes-kernel
${fsl-release-bsp}/sources/meta-t0040/recipes-kernel/linux
${fsl-release-bsp}/sources/meta-t0040/recipes-kernel/linux/files

  * ${fsl-release-bsp}/sources/meta-t0040/conf/layer.conf
 # We have a conf and classes directory, append to BBPATH
BBPATH .= ":${LAYERDIR}"

# We have a recipes directory, add to BBFILES
BBFILES += "${LAYERDIR}/recipes-*/*/*.bb ${LAYERDIR}/recipes-*/*/*.bbappend"

BBFILE_COLLECTIONS    += "t0040"
BBFILE_PATTERN_t0040  := "^${LAYERDIR}/"
BBFILE_PRIORITY_t0040  = "9"
LAYERVERSION_t0040     = "1"

  * ${fsl-release-bsp}/sources/meta-t0040/recipes-kernel/linux/linux-imx_%.bbappend
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI += "file://fragment-t0040.cfg"

# support for TUN / RNDIS / IP_TABLES
do_configure_prepend () {
    echo "CONFIG_NETFILTER=y"               >>  ${B}/.config
    echo "CONFIG_NETFILTER_DEBUG=y"         >>  ${B}/.config
    echo "CONFIG_NETFILTER_ADVANCED=n"      >>  ${B}/.config

    echo "CONFIG_TUN=m"                     >>  ${B}/.config

    echo "CONFIG_USB_ETH_RNDIS=m"           >>  ${B}/.config
    echo "CONFIG_USB_NET_RNDIS_HOST=m"      >>  ${B}/.config

    echo "CONFIG_NETFILTER_XTABLES=m"       >>  ${B}/.config

    echo "CONFIG_NF_CONNTRACK=m"            >>  ${B}/.config
    echo "CONFIG_NF_TABLES=m"               >>  ${B}/.config
    echo "CONFIG_NF_NAT=m"                  >>  ${B}/.config
    echo "CONFIG_NF_NAT_MASQUERADE_IPV4=m"  >>  ${B}/.config

    echo "CONFIG_IP_NF_CONNTRACK=m"         >>  ${B}/.config
    echo "CONFIG_IP_NF_NAT=m"               >>  ${B}/.config
    echo "CONFIG_IP_NF_TARGET_MASQUERADE=m" >>  ${B}/.config
}

  * ${fsl-release-bsp}/sources/meta-t0040/recipes-kernel/linux/files/fragment-t0040.cfg
- It is created by below sequence
bitbake linux-imx -c menuconfig
bitbake linux-imx -c diffconfig
- And copy the fragment in 
./imx6ull14x14evk-fb/tmp/work/imx6ull14x14evk-poky-linux-gnueabi/linux-imx/4.1.15-r0/fragment.cfg
  to the destination directory(.../recipes-kernel/linux/!!)


4) Enable T0040 Layer on the Build Configuration

  * ${fsl-release-bsp}/imx6ull14x14evk-fb/conf/bblayers.conf
LCONF_VERSION = "6"

BBPATH = "${TOPDIR}"
BSPDIR := "${@os.path.abspath(os.path.dirname(d.getVar('FILE', True)) + '/../..')}"

BBFILES ?= ""
BBLAYERS = " \
  ${BSPDIR}/sources/poky/meta \
  ${BSPDIR}/sources/poky/meta-yocto \
  \
  ${BSPDIR}/sources/meta-openembedded/meta-oe \
  ${BSPDIR}/sources/meta-openembedded/meta-multimedia \
  \
  ${BSPDIR}/sources/meta-fsl-arm \
  ${BSPDIR}/sources/meta-fsl-arm-extra \
  ${BSPDIR}/sources/meta-fsl-demos \
  ${BSPDIR}/sources/meta-t0040 \
"
##Freescale Yocto Project Release layer
BBLAYERS += " ${BSPDIR}/sources/meta-fsl-bsp-release/imx/meta-bsp "
BBLAYERS += " ${BSPDIR}/sources/meta-fsl-bsp-release/imx/meta-sdk "
BBLAYERS += " ${BSPDIR}/sources/meta-browser "
BBLAYERS += " ${BSPDIR}/sources/meta-openembedded/meta-gnome "
BBLAYERS += " ${BSPDIR}/sources/meta-openembedded/meta-networking "
BBLAYERS += " ${BSPDIR}/sources/meta-openembedded/meta-python "
BBLAYERS += " ${BSPDIR}/sources/meta-openembedded/meta-filesystems "
BBLAYERS += " ${BSPDIR}/sources/meta-qt5 "


4) Rebuild the Image!!
bitbake -c clean virtual/kernel 
bitbake fsl-image-gui


2017-02-20

Yocto Project - useful 'bitbake' commands


bitbake commandDescription
bitbake <image>Bake an image (add -k to continue building even errors are found in the tasks execution)
bitbake <package> -c <task>Execute a particular package's task. Default Tasks names: fetch, unpack, patch, configure, compile, install, package, package_write, and build.

Example: To (force) compiling a kernel and then build, type:
$ bitbake  linux-imx -f -c compile
$ bitbake linux-imx
bitbake <image > -g -u depexpShow the package dependency for image.

Example: To show all packages included on fsl-image-gui
$ bitbake fsl-image-gui -g -u depexp

NOTE: This command will open a UI window, so it must be execute on a console inside the host machine (either virtual or native).
bitbake <package> -c  devshellOpen a new shell where with neccesary system values already defined for package
hobbitbake frontend/GUI.
bitbake <package> -c listtasksList all tasks for package
bitbake virtual/kernel -c menuconfigInteractive kernel configuration
bitbake <image> -c fetchallFetch sources for a particular image
bitbake-layers show-layersShow layers
bitbake-layers show-recipes "*-image-*"Show possible images to bake. Without "*-images-*", it shows ALL recipes
bitbake -g <image> && cat pn-depends.dot | grep -v -e '-native' | grep -v digraph | grep -v -e '-image' | awk '{print $1}' | sort | uniqShow image's packages
bitbake -g <pkg> && cat pn-depends.dot | grep -v -e '-native' | grep -v digraph | grep -v -e '-image' | awk '{print $1}' | sort | uniqShow package's dependencies
bitbake –v <image> 2>&1 | tee image_build.log Print (on console) and store verbose baking
bitbake -s | grep <pkg>Check if certain package is present on current Yocto Setup



Freescale - Yocto - openssl (perl error)


The meta-toolchain of NXP(Freescale) i.MX6ULL BSP Package for Yocto can not build the openssl library, because of failing on running 'Configure'.

So, the below script is needed.
(sysroot-path must be adjusted to your directory structure.)


#!/bin/bash

export SDKTARGETSYSROOT=/opt/toolchains/fsl-imx-fb-4.1.15-2.0.1/sysroots/cortexa7hf-neon-poky-linux-gnueabi
export PKG_CONFIG_SYSROOT_DIR=$SDKTARGETSYSROOT
export PKG_CONFIG_PATH=$SDKTARGETSYSROOT/usr/lib/pkgconfig
export CONFIG_SITE=/opt/toolchains/fsl-imx-fb-4.1.15-2.0.1/site-config-cortexa7hf-neon-poky-linux-gnueabi
export OECORE_NATIVE_SYSROOT="/opt/toolchains/fsl-imx-fb-4.1.15-2.0.1/sysroots/x86_64-pokysdk-linux"
export OECORE_TARGET_SYSROOT="$SDKTARGETSYSROOT"
export OECORE_ACLOCAL_OPTS="-I /opt/toolchains/fsl-imx-fb-4.1.15-2.0.1/sysroots/x86_64-pokysdk-linux/usr/share/aclocal"
unset command_not_found_handle
export CC="arm-poky-linux-gnueabi-gcc  -march=armv7ve -mfpu=neon  -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=$SDKTARGETSYSROOT"
export CXX="arm-poky-linux-gnueabi-g++  -march=armv7ve -mfpu=neon  -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=$SDKTARGETSYSROOT"
export CPP="arm-poky-linux-gnueabi-gcc -E  -march=armv7ve -mfpu=neon  -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=$SDKTARGETSYSROOT"
export AS="arm-poky-linux-gnueabi-as "
export LD="arm-poky-linux-gnueabi-ld  --sysroot=$SDKTARGETSYSROOT"
export GDB=arm-poky-linux-gnueabi-gdb
export STRIP=arm-poky-linux-gnueabi-strip
export RANLIB=arm-poky-linux-gnueabi-ranlib
export OBJCOPY=arm-poky-linux-gnueabi-objcopy
export OBJDUMP=arm-poky-linux-gnueabi-objdump
export AR=arm-poky-linux-gnueabi-ar
export NM=arm-poky-linux-gnueabi-nm
export M4=m4
#export TARGET_PREFIX=arm-poky-linux-gnueabi-
export CONFIGURE_FLAGS="--target=arm-poky-linux-gnueabi --host=arm-poky-linux-gnueabi --build=x86_64-linux --with-libtool-sysroot=$SDKTARGETSYSROOT"
export CFLAGS=" -O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/home/cmjo/gitLocal/fsl-release-bsp/imx6ull14x14evk-fb/tmp/work/x86_64-nativesdk-pokysdk-linux/meta-environment-imx6ull14x14evk/1.0-r8=/usr/src/debug/meta-environment-imx6ull14x14evk/1.0-r8 -fdebug-prefix-map=/home/cmjo/gitLocal/fsl-release-bsp/imx6ull14x14evk-fb/tmp/sysroots/x86_64-linux= -fdebug-prefix-map=/home/cmjo/gitLocal/fsl-release-bsp/imx6ull14x14evk-fb/tmp/sysroots/x86_64-nativesdk-pokysdk-linux= "
export CXXFLAGS=" -O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/home/cmjo/gitLocal/fsl-release-bsp/imx6ull14x14evk-fb/tmp/work/x86_64-nativesdk-pokysdk-linux/meta-environment-imx6ull14x14evk/1.0-r8=/usr/src/debug/meta-environment-imx6ull14x14evk/1.0-r8 -fdebug-prefix-map=/home/cmjo/gitLocal/fsl-release-bsp/imx6ull14x14evk-fb/tmp/sysroots/x86_64-linux= -fdebug-prefix-map=/home/cmjo/gitLocal/fsl-release-bsp/imx6ull14x14evk-fb/tmp/sysroots/x86_64-nativesdk-pokysdk-linux= "
export LDFLAGS="-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed"
export CPPFLAGS=""
export KCFLAGS="--sysroot=$SDKTARGETSYSROOT"
export OECORE_DISTRO_VERSION="4.1.15-2.0.1"
export OECORE_SDK_VERSION="4.1.15-2.0.1"
export ARCH=arm
#export CROSS_COMPILE=arm-poky-linux-gnueabi-

./Configure linux-armv4 --prefix=/home/cmjo/build-pack-openssl zlib-dynamic shared

According to the manual, 'environment-setup-cortexa7hf-neon-poky-linux-gnueabi' must be loaded with 'source' or '.'.

But, after loading that script, the [perl] is not running properly for lack of dependent modules.

Above script must be executed directly on host shell.
(DO NOT load the Build-ENV script)

Then, you can compile the openssl successfully.




2017-02-08

Freescale i.MX6ULL 14x14 EVK - Yocto Build


1) Host Package

   * for Yocto Project
     $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib \
build-essential chrpath socat libsdl1.2-dev

   * for iMX
    $ sudo apt-get install libsdl1.2-dev xterm sed cvs subversion coreutils texi2html \
docbook-utils python-pysqlite2 help2man make gcc g++ desktop-file-utils \
libgl1-mesa-dev libglu1-mesa-dev mercurial autoconf automake groff curl lzop asciidoc

   * for Ubuntu 12.04
    $ sudo apt-get install uboot-mkimage

   * for Ubuntu 14.04
    $ sudo apt-get install u-boot-tools


2) repo

   $ mkdir ~/bin
   $ curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
   $ chmod 755 ~/bin/repo


3) Get source code

   $ mkdir fsl-release-bsp
   $ cd fsl-release-bsp
   $ repo init -u git://git.freescale.com/imx/fsl-arm-yocto-bsp.git -b imx-4.1-krogoth
   $ repo sync


4) Build Configuration

   $ DISTRO=fsl-imx-fb MACHINE=imx6ull14x14evk source fsl-setup-release.sh -b imx6ull14x14evk-fb


5) Build

   $ bitbake fsl-image-gui


5) QEMU test

   $ runqemu qemux86-64 ./tmp/deploy/images/imx6qsabresd/zImage-imx6qsabresd.bin ./tmp/deploy/images/imx6qsabresd/core-image-minimal-imx6qsabresd.ext4


6) Build Toolchain

   # Using the Build-Directory
     $ bitbake meta-ide-support

   # Create the Toolchain Installer and Install
     $ bitbake meta-toolchain
     $ sh tmp/deploy/sdk/poky-eglibc-x86_64-arm-toolchain-1.4.1.sh
     $ source /opt/poky/1.4.1/environment-setup-armv7a-vfp-neon-poky-linux-gnueabi
     $ arm-poky-linux-gnueabi-gcc -v

  # More Advanced Toolchain!!!
     $ bitbake fsl-image-gui -c populate_sdk


7) Kernel Config and Rebuild

   # check the python script
   $ bitbake -e virtual/kernel

   $ bitbake linux-imx -c menuconfig
   $ bitbake linux-imx -c diffconfig

   # re-compile kernel, forcely!!
   $ bitbake linux-imx -c compile -f

   # clean kernel only
   $ bitbake linx-imx -c clean

   # rebuild image
   $ bitbake fsl-image-gui


8) Post Build
   # It is not required if you build the [populate_sdk]!!!
    [add libraries] zlib, openssl