22 - Kernel driver customization
configure defconfig
Android kernel configuration
Linux kernel configuration
kernel path
kernel config command common configuration
Configuration can be tracked by build.sh
Make saveconfig generate defconfig requires cp to be compiled into the * defconfig file used by the SDK for use
Different versions of defconfig may be different, you can find the corresponding version file in the git history.
$ git log --name-only kernel-5.10/ | grep defconfig
dts
rk356x-linux
rk-android
PWM configuration
For example: Configure the GPIO0_C0 (pwm1m0) on the K1 extension pin as PWM
Note: Any IO can only be configured with one function. If you want to modify the IO that is already in use, you need to find the corresponding position and comment out the original use.
Test method reference:12-Hardware function instructions.md [PWM](12-Hardware function instructions.md#PWM)
GPIO configuration
The common configuration of GPIO is generally matched with LED output or key input. The following is an example of modifying this part of the device tree for reference and modification
Note: Any IO can only be configured with one function. If you want to modify the IO that is already in use, you need to find the corresponding position and comment out the original use.
LED configuration
For example: configure the GPIO1_D4 on the K1 extension pin to LED, you can refer to the following modification
Test method reference:12-Hardware function instructions.md [LED](12-Hardware function instructions.md#LED)
gpio-key configuration
For example: configure the GPIO1_D4 on the K1 extension pin to KEY_1, you can refer to the following modifications
Where the code value can refer to the macro definition in the driver
Test method reference document:12-Hardware function instructions.md [KEY test](12-Hardware function instructions.md#KEYtest)
LCD configuration
LCD screen configuration to light up different screens
Configuration reference documentation:[RK3568 LCD Configuration](40-RK3568 LCD Configuration.md)
External RTC module
Some boards do not have an onboard RTC module. Customers who need it can choose an external RTC module to solve the time preservation needs.
The following example is the approach of the K1B-Android external I2C-RTC module:
Device hardware connection
IO ports used on the board:
The physical wiring is as follows:
CLK_OUT are generally not used
The INT foot is connected according to demand. The K1B board does not have a pulled IO foot, so it is not connected.
device driver porting
The SDK of RK356x comes with driver porting for some models of RTC by default. If you find that you do not use the model yourself, you need to port it. The driver used in the example is hym8563 (the SDK comes with it), but the following is a brief introduction to the steps of driver porting if there is no driver.
RK-RTC drive path:
Put the kernel driver you got from the RTC manufacturer in this directory.
Some manufacturers may not have the kernel driver code, only the single-chip microcomputer, so you can only figure it out yourself.
Modify the Makefile under the driver path:
Modify Kconfig under the driver path:
kernel enable
Add rtc node on device tree I2C3
rtc-irq-gpio is the IO port corresponding to the INT pin wiring. I didn't connect it in my test, so I commented it.
Use date and hwclock to test whether the rtc driver is working properly
Display the current Linux system time
If the date time is not normal, such as 1970 or something, instead of my current time, such as 2009, then manually set the correct time yourself
MM is the month (01-12)
DD is the date (01-31)
hh is the hour (00-23)
mm is minutes (00-59) '
[[CC] YY] is the year (optional, CC is the century, YY is the year)
[.ss] is the number of seconds (optional)
3.Show hardware rtc time
Since this is the first time the RTC driver has been loaded, the correct time has not been set, so the time displayed at this time is mostly incorrect in 1969 and 1970. 4. Set Linux system time to hardware rtc
Check again whether the hardware rtc time is consistent with the system
If the driver is working correctly, the time shown here should be the same as your current system time, which is said to be synchronized... Otherwise, it means that your driver is not working correctly, and you have not correctly set the system time into the hardware RTC. You will have to go back and debug the driver yourself to find the reason. 6. Wait a few minutes for the power to be turned on after the power is cut off, and enter again:
Normally, you will see that the time here has increased by a few minutes and seconds compared to the time shown in step 5. That means the RTC is working normally.
RTC interrupt test:
empty restore
set time
+60:表示60秒后触发中断
View rtc information
Review system interrupt information:
To see the interrupt visually, you can add time to the RTC interrupt print in the RTC intermediate function. You can refer to the following modification:
Last updated