How to measure temperature of CPU and stress individual cores of CPU?

Showing results for 
Search instead for 
Did you mean: 

How to measure temperature of CPU and stress individual cores of CPU?

No ratings

How to measure temperature of CPU and stress individual cores of CPU?

The below steps describe how to measure CPU temperature and how to stress individual cores of CPU.

Steps are explained with an example of LX2160A SoC. However, these steps are applicable to all Layerscape devices.

  1. Download Flexbuild and add packages in Yocto tiny
  2. Generate Yocto tiny userland
  3. Enable thermal monitoring unit and build kernel
  4. Generate .itb image
  5. Load .itb image from TFTP server to Layerscape board
  6. Validate stress package and measure CPU temperature before and after stress

Step 1: Download Flexbuild and add packages in Yocto tiny

  1. On a Linux machine, download Layerscape Software Development Kit - <version>.
  2. Go to Download tabs at Enter login details, accept the agreement to download the Flexbuild source tarball in the name format flexbuild_<version>.tgz.
  3. Run the following commands to extract Flexbuild files from tar archived file.

    $ tar xvzf flexbuild_<version>.tgz

    $ cd flexbuild_<verison>

    $ source setup.env

    $ flex-builder -h

  4. Add “stress” package to "IMAGE_INSTALL_append" parameter of local_arm64_tiny.conf file available in flexbuild_<version>/configs/yocto/ folder.Package.GIF
  5. Save and exit the file.

Step 2 – Generate Yocto tiny userland

  1. Change directory to flexbuild_<version>.
  2. Clean obsolete cache data. This step is needed in case source/config has changed.

    $ source setup.env

    $ flex-builder -i clean-rfs -r yocto

  3. Run the following commands to generate Yocto-based tiny userland:

    $ flex-builder -i mkrfs -r yocto:tiny

    $flex-builder -i mklinux -r yocto:tiny

    $ flex-builder -i mkfw -m <machine_name> -b sd

    This generates the following images: rootfs_lsdk<version>_yocto_tiny_arm64.cpio.gz (~22M), lsdk<version>_yocto_tiny_LS_arm64.itb, and firmware_<machine_name>_uboot_sdboot.img.

    For example: rootfs_lsdk2004_yocto_tiny_arm64.cpio.gz (~22M), lsdk2004_yocto_tiny_LS_arm64.itb, and firmware_lx2160ardb_rev2_uboot_sdboot.img

Step 3 Enable system monitoring unit and build kernel

  1. Change directory to flexbuild_<version>/packages/linux/linux.
  2. Enable environmental setting for cross-compiling. The following setting is applicable when you configure and build kernel on a different architecture from the target. For example, compiling an Armv8 kernel on an X86 computer. Run the following commands on Ubuntu Linux:

    $ export CROSS_COMPILE=aarch64-linux-gnu-

    $ export ARCH=arm64

  3. Run make menuconfig command to configure settings to enable thermal monitoring unit.

    $ make menuconfig

    The command opens the kernel configuration [tree-view structure] prompt. Use the Arrow keys to navigate the menu and Enter to select the submenu.

  4. Navigate to Device Drivers --> <*> Generic Thermal sysfs driver --> [ ] Generic CPU cooling support option.


  5. Press Y key to include the option. [*] symbol indicates the option is included (shown in below figure).

    configure Enable.png

  6. Similarly, include the following options to enable thermal management framework.

    Thermal options table.GIF

  7. After you include all options as mentioned in the above table, save the configuration with a file name. For example,  save the configuration file as thermal.config.
  8. Exit to come out of the Kernel Configuration prompt.
  9. Copy the configuration file to arch/arm64/configs folder.

    $ cp <config filename> arch/arm64/configs/

    For example, $ cp thermal.config arch/arm64/configs/

  10. Configure the kernel. Load the changed configuration for Layerscape Armv8 platform in 64-bit mode for LSDK.

    $ export CROSS_COMPILE=aarch64-linux-gnu-

    $ export ARCH=arm64

    $ make distclean

    $ make defconfig <config filename>

  11. Build kernel image and device tree image.

    $ make -j8

Step 4 - Generate .itb file

Generate .itb file, which includes stress package and thermal monitoring unit installed, for kernel booting.

  1. Copy the Image and Image.gz files from the /flexbuild_<version>/packages/linux/linux/arch/arm64/boot folder and to the /flexbuild_<version>/build/linux/kernel/arm64/LS folder.
  2. Change directory to flexbuild_<version>.
  3. Generate .itb image using flex-builder.

    $ source setup.env

    $ flex-builder -i mkitb -r yocto:tiny

    This generates lsdk2<version>_yocto_tiny_LS_arm64.itb file. For example, lsdk2004_yocto_tiny_LS_arm64.itb file.

  4. Copy the .itb image to the TFTP server.

Step 5 - Load .itb image from TFTP server to Layerscape board

  1. Set up Ethernet connection between the board (for example, LX2160ARDB) and host machine on which you have configured the TFTP server.
    1. Boot the board to U-Boot prompt. U-Boot prints a list of enabled Ethernet interfaces. For example, LX2160ARDB U-Boot prints following Ethernet interfaces.

      DPMAC2@xlaui4, DPMAC3@xgmii, DPMAC4@xgmii, DPMAC5@25g-aui, DPMAC6@25g-aui, DPMAC17@rgmii-id, DPMAC18@rgmii-id 

    2. Set server IP address to the IP address of the host machine on which you have configured the TFTP server.

      => setenv serverip <ipaddress1>

    3. Set ethact and ethprime as the ethernet interface connected to the TFTP server.

      See LX2160ARDB Ethernet Port Mapping for the mapping of Ethernet port names appearing on the chassis front panel with the port names in U-Boot and Linux.

      => setenv ethprime <name of interface connected to TFTP server>

      For example:

      => setenv ethprime DPMAC3@xgmii

      => setenv ethact <name of interface connected to TFTP server>

      For example:

      => setenv ethact DPMAC3@xgmii

    4. Set IP address of the board. You can set a static IP address or, if the board can connect to a dhcp server, you can use the dhcp command. 

      Static IP address assignment:
      => setenv ipaddr <ipaddress2>
      => setenv netmask <subnet mask>

      Dynamic IP address assignment:
      => dhcp

    5. Save the settings.

      => saveenv

    6. Check the connection between the board and the TFTP server.

      => ping $serverip

      Using DPMAC3@xgmii device

      host is alive

  2. Load the .itb image from TFTP server to DDR memory of the board.

    => tftp 0xa0000000 <itb_file_name>

    For example: => tftp 0xa0000000 lsdk2004_yocto_tiny_LS_arm64.itb

  3. Boot the kernel with .itb image as follows:

    => bootm 0xa0000000#<board_name>

    For example: => bootm 0xa0000000#lx2160ardb

    Let the board boots to Tiny Linux.

Step 6 – Validate stress package and measure CPU temperature before and after stress

  1. Check stress-ng package using which stress-ng command:

    # which stress-ng


  2. Check scaling_current_frequency of the cores.

    # cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq

     For example: Check frequency of 16 cores of LX2160ARDB as follows:temp validate-1.gif

  3. Check the temperature of the CPU before applying stress.

    # cat /sys/class/thermal/thermal_zone*/temp

  4. Apply stress by executing following command:

    # stress-ng -c 8 -i 1 -m 1 --vm-bytes 128M -t 60s &

    The command applies stress for 60 seconds. For more information on stress-ng command, run stress-ng -h command for help.

  5. Check the temperature of the CPU after applying stress.
  6. # cat /sys/class/thermal/thermal_zone*/temp

    For example:

    temp result.gif

Version history
Revision #:
6 of 6
Last update:
‎12-21-2020 03:44 AM
Updated by: