blog:2024-01-30_imx6_linux_bsp_porting_guide
2024-01-30 iMX6 Linux BSP Porting Guide
1, Introduction
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.
3. Device functions description
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
3.7 Auto brightness mechanism
3.8 Obtain device serial number
Permalink blog/2024-01-30_imx6_linux_bsp_porting_guide.txt · Last modified: 2024/01/30 13:57 by
jethro