一.ubuntu 18.04 开发环境配置
1.安装java sdk
sudo apt-get install openjdk-8-jdk
2.安装对应库
sudo apt-get install libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-dev g++-multilib
sudo apt-get install -y git flex bison gperf build-essential libncurses5-dev:i386
sudo apt-get install tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386
sudo apt-get install dpkg-dev libsdl1.2-dev libesd0-dev
sudo apt-get install git-core gnupg flex bison gperf build-essential
sudo apt-get install zip curl zlib1g-dev gcc-multilib g++-multilib
sudo apt-get install libc6-dev-i386
sudo apt-get install lib32ncurses5-dev x11proto-core-dev libx11-dev
sudo apt-get install libgl1-mesa-dev libxml2-utils xsltproc unzip m4
sudo apt-get install lib32z-dev ccache
ubuntu20.04 需安装如下库
FAILED: out/host/linux-x86/obj/EXECUTABLES/validatekeymaps_intermediates/Main.o
prebuilts/clang/host/linux-x86/clang-4053586/bin/clang++.real: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
sudo apt install libncurses5
3.配置jack server
export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4096m"
二、开始编译
source build/envsetup.sh
lunch 65
选full_k39tv1_bsp-userdebug后执行make ,在i5-3340M +杂牌ssd 配置下耗时约4.5 hour。
make -j4
[100% 81865/81865] Install system fs image: out/target/product/k39tv1_bsp/system.img
out/target/product/k39tv1_bsp/system.img+out/target/product/k39tv1_bsp/obj/PACKAGING/recovery_patch_intermediates/recovery_from_boot.p maxsize=2740556544 blocksize=4224 total=1009588993 reserve=27684096
#### build completed successfully (04:32:31 (hh:mm:ss)) ####
中文ubuntu 环境编译一段时间后会报错。(注意此命令只能在报错后执行)
FAILED: out/target/product/k39tv1_bsp/obj/STATIC_LIBRARIES/libedify_intermediates/lexer.cpp
/bin/bash -c "prebuilts/misc/linux-x86/flex/flex-2.5.39 -oout/target/product/k39tv1_bsp/obj/STATIC_LIBRARIES/libedify_intermediates/lexer.cpp bootable/recovery/edify/lexer.ll"
flex-2.5.39: loadlocale.c:130:_nl_intern_locale_data: ?? 'cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' ???
Aborted (core dumped)
export LC_ALL=C
单独编译内核
make bootimage -j4
三、烧录
ubuntu 下使用flash_tool
1.
sudo apt-get remove modemmanager
缺少库文件libpng12.so.0:
./flash_tool: error while loading shared libraries: libpng12.so.0: cannot open shared object file: No such file or directory
cd /usr
find -name libpng12.so.0
sudo ln -s /usr/share/sogouimebs/libs/libpng12.so.0 /usr/lib/libpng12.so.0
2.
sudo ./flash_tool
scatter选择mt6739
3.format all+download 方式会清除所有数据,包括手机激活数据。
一般选择download only.
四 、内核debug信息太少
1.增加kernel log buff
kernel/init/Kconfig
修改LOG_BUF_SHIFT 值为17,注意LOG_CPU_MAX_BUF_SHIFT >=LOG_BUF_SHIFT
config LOG_BUF_SHIFT
int "Kernel log buffer size (16 => 64KB, 17 => 128KB)"
range 12 25
default 17
depends on PRINTK
config LOG_CPU_MAX_BUF_SHIFT
int "CPU kernel log buffer size contribution (13 => 8 KB, 17 => 128KB)"
depends on SMP
range 0 21
default 17 if !BASE_SMALL
default 0 if BASE_SMALL
depends on PRINTK
2.注释psensor距离感应的log ,此部分log 会不停打印,冲掉kernel log buff
drivers/misc/mediatek/sensors-1.0/alsps/alsps.c
int ps_data_report(int value, int status)
{
int err = 0;
struct sensor_event event;
memset(&event, 0, sizeof(struct sensor_event));
// pr_notice("[ALS/PS]ps_data_report! %d, %d\n", value, status);
int ps_report_interrupt_data(int value)
{
struct alsps_context *cxt = NULL;
/* int err =0; */
cxt = alsps_context_obj;
// pr_notice("[ALS/PS] [%s]:value=%d\n", __func__, value);