User Tools

Site Tools

blog:2024-01-30_imx6_linux_bsp_porting_guide



2024-01-30 iMX6 Linux BSP Porting Guide

  • This is the LInux BSP porting guide in a project based on iMX6 in 2018.
  • Just memo this process.

1, Introduction

  • The document is provided for customers and related 3rd parties to obtain the system information while developing system applications.
  • The following contents are included in the document.
    • (1) Image build
    • (2) Driver function and interface description

2, Image Build

  • The board support package for the project is based on the Linux formal release, L4.1.15_1.2.0, from the NXP website. People who want to know how to fetch the source code, setup the build environments, and then compile the default image can refer to the document.
  • (1) Freescale Yocto Project User's Guide (IMXLXYOCTOUG) contains the instructions for setting up and building Linux in the Yocto Project.
  • (2) i.MX 6 BSP Porting Guide (IMX6XBSPPG) contains the instructions on porting the BSP to a new board
  • To build the project specific image, please follow the steps listed below.
    • (1) Download DMS-XX Yocto project
      • $mkdir DMS_SEXX
        $cd DMS_SEXX
        $repo init -u https://github.com/DMS-XX.git -b vendor
        $repo sync
    • (2) Build DMS-SE23 image
      • $EULA=1 DISTRO=fsl-imx-x11 MACHINE=imx6dl-dmsxx source fsl-setup-release.sh
        -b build_Customer
        $bitbake vendor-image-qt5
      • It would take times to complete the compilation of the whole Yocto system. The root file system, kernel, modules, and the U-Boot binary are available in the following directory.
        <source directory>/build_ Customer/tmp/deploy/images/imx6dl-dmsxx

3. Device functions description

3.1 Power button

  • The power button is the mandatory component for most of embedded systems. It takes care of the power on and off mechanism and triggers some specific events if needed. The system block of the power button is shown below. The VPM is an MCU receiving the hardware signal from the power button and then turning on the system. It is designed to communicate with i.MX6 through the i2c interface to notify after the system is booted up.
  • The behavior of the power button is shown as a flowchart below. According to the specification provided by Fresenius, the press time distinguishes the short press and long press events.
  • The input key event, KEY_POWER, notifies the user of space applications continuously until the power button is up or over 7 seconds arrives, and the hard shutdown timer is expired.

3.2 Battery and Charger

  • The battery and charger IC are controlled by VPM which can provide the capacity and charging status. The system block of the battery and charger IC are shown below.
  • The battery and charger driver obtain several statuses from VPM and export them for developers use through sysfs. The support functions and the related sysfs paths are listed below.
  • Moreover, the following command can check if the power supply is present or not
    #cat /sys/class/power_supply/ac/online
    6

3.3 Buzzer

  • The buzzer receives the PWM signal generated from i.MX6 to make a noise with a specific frequency. The system block of the buzzer is shown below.
  • The frequency of PWM is configurable by operating the sysfs entries exported by the PWM driver. There are two variables, period and duty cycle, need to be calculated first. For example, if we want to generate a 2700Hz PWM signal with 50% duty cycle, the following formula is used to calculate the value of period and duty.
  • period = 10^9/2700 = 370370
  • duty = 370370 * 0.5 = 185185
  • After obtaining the required variables,
    #echo 0 > /sys/class/pwm/pwmchip1/export
    #echo 370370 > /sys/class/pwm/pwmchip1/pwm0/period
    #echo 185185 > /sys/class/pwm/pwmchip1/pwm0/duty_cycle
    #echo 1 > /sys/class/pwm/pwmchip1/pwm0/enable

3.4 Backlight

  • The backlight controller receives the fixed frequency of PWM signal generated from i.MX6. According to the specification of backlight controller, the typical value of frequency, 200Hz, is used.
  • The brightness of the backlight can be adjusted by the duty cycle of PWM signal.
  • Currently, there are 255 levels of brightness are provided by backlight driver.
  • The value of brightness levels can be adjusted from 0 to 255 by editing the sysfs entry exported by backlight driver. For example, the following command can be used to modify the brightness to level 64.
  • #echo 64 > /sys/class/backlight/backlight/brightness
  • In order to check the existence of the display, the ADC is used to monitor the backlight current. The developer can read the value from the following sysfs entry to obtain the current of backlight.
    #cat /sys/devices/soc0/soc/2100000.aips-bus/21a0000.i2c/i2c-0/\
    0-0068/vpmbl_curr_sense

3.5 Audio - Speaker and Microphone

  • The low power stereo codec with headphone Amp from Freescale, SGTL5000, is designed to provide a complete audio solution for portable products needing line-in, micin, line-out, headphone-out, and digital I/O. The system block of the audio codec is shown below.
  • The basic audio functions are available through the common used audio applications.
  • The following table simply describes how to setup the volume, play an audio file and record a sound wave to an audio file.

3.6 Ambient light sensor

  • DMS-XX can sense the ambient luminance through the light sensor which is located at the external carrier board. The system block of the ambient light sensor is shown below.
  • The Linux OS can query the current value of luminance by i2c. Developers who want to obtain the current luminance can use the following command.
    #cat /sys/devices/soc0/soc/2100000.aips-bus/21a8000.i2c/i2c-2/2-0029\
    /iio:device0/in_illuminance0_input

3.7 Auto brightness mechanism

  • DMS-XX has implemented the auto brightness mechanism. It can adjust the brightness of backlight according to the illuminance value sensed from light sensor. The development can modify the mapping table during runtime for system tuning and then save it to the related configuration files to make it as the default settings. Please download the document talking about the detail of the auto brightness mechanism from the following path.
  • https://drive.google.com/file/d/1f3Ys-pd-Not-Avaliable-Anymore/view?usp=sharing

3.8 Obtain device serial number

  • DMS-XX contains an SPI-NOR flash which is utilized to save the serial number and related system information during production. Developers can use the following sysfs entry to access the value of serial number.
  • #cat /sys/class/spi_master/spi0/spi0.0/serial_number

TAGS

  • 50 person(s) visited this page until now.

Permalink blog/2024-01-30_imx6_linux_bsp_porting_guide.txt · Last modified: 2024/01/30 13:57 by jethro

oeffentlich