Google Pixel3.0 compile AOSP9.0 + android-kernel

准备工作

Pixel3 代号blueline,编译配置lunch aosp_bluebline-userdebug,内核代码选择android-msm-crosshatch

1.pixel3解锁

在手机system–>build version点击7下进入developer模式,OEM也要解锁
手机进入BootLoader:adb reboot bootloader
解锁命令:fastboot flashing unlock
利用音量上下键和开机键选择对应选项来解锁

2.准备AOSP

本来想使用之前Hikey970编译的AOSP版本,但是在https://source.android.com/setup/start/build-numbers#source-code-tags-and-builds 查找细分版本号发现,上次repo sync的r8版本不能用来编译Pixel 3的镜像,只好再repo sync一个相近的r21版本。
同时在github上找到前人的教程并学习:https://github.com/shallin123/Android9.0-pixel-3
可供参考的pixel XL编译经验: https://blog.youkuaiyun.com/zz531987464/article/details/94163954

//repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-9.0.0_r21 --no-repo-verify --repo-branch=stable    
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-9.0.0_r21   

1.清华的repo设置:

    mkdir ~/bin    
    PATH=~/bin:$PATH     
    curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo    
    chmod +x repo    
    export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'    

2.ustc的repo设置

//清华的源不可用,换用中科院的源ustc    
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-9.0.0_r21     
repo sync -j32     
log:

输出

Checking out projects: 100% (678/678), done.
repo sync has finished successfully.

again:

repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-9.0.0_r37 --no-repo-verify --repo-branch=stable    
失败
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-9.0.0_r37     
repo sync

输出:

Checking out projects:  90% (613/677) platform/prebuilts/r8Checking out files:   0% (18/4089Checking out files: 100% (4089/4089), done.
Checking out projects: 100% (677/677), done.
repo sync has finished successfully.

3.编译aosp

source build/envsetup.sh     
lunch aosp_blueline-userdebug   

log:

root@tan-PowerEdge-R730:/mnt/pixel3/aosp# lunch aosp_blueline-userdebug     
============================================    
PLATFORM_VERSION_CODENAME=REL   
PLATFORM_VERSION=9    
TARGET_PRODUCT=aosp_blueline    
TARGET_BUILD_VARIANT=userdebug   
TARGET_BUILD_TYPE=release   
TARGET_ARCH=arm64    
TARGET_ARCH_VARIANT=armv8-2a    
TARGET_CPU_VARIANT=cortex-a75    
TARGET_2ND_ARCH=arm    
TARGET_2ND_ARCH_VARIANT=armv8-a    
TARGET_2ND_CPU_VARIANT=cortex-a75    
HOST_ARCH=x86_64   
HOST_2ND_ARCH=x86    
HOST_OS=linux    
HOST_OS_EXTRA=Linux-4.13.0-x86_64-Ubuntu-16.04.7-LTS    
HOST_CROSS_OS=windows   
HOST_CROSS_ARCH=x86    
HOST_CROSS_2ND_ARCH=x86_64    
HOST_BUILD_TYPE=release    
BUILD_ID=PQ1A.181205.006   
OUT_DIR=out    
PRODUCT_SOONG_NAMESPACES=device/google/crosshatch/pixelstats device/google/crosshatch/usb device/google/crosshatch/health hardware/google/av hardware/google/interfaces hardware/qcom/sdm845 vendor/qcom/sdm845     
make -j32    

log:

Copying resources from program jar [/mnt/pixel3/aosp/out/target/common/obj/APPS/messaging_intermediates/classes.jar]
[ 99% 105415/105439] Target Java: out/target/common/obj/APPS/Dialer_intermediates/classes-full-debug.jar
N
<think>根据错误信息,v++编译命令缺少平台选项(--platform)。在之前的编译命令中,链接步骤指定了平台,但编译步骤没有。修正后的命令应在编译步骤也添加平台选项。 修正后的手动执行命令如下: ### 修正后的内核编译命令 ```bash # 指定平台编译内核对象文件 (.xo) v++ -c -t hw --platform xilinx_u50_gen3x16_xdma_5_202210_1 --kernel ip_filter -I. -o ip_filter.xo ip_filter.cpp # 链接生成xclbin文件 v++ -l -t hw --platform xilinx_u50_gen3x16_xdma_5_202210_1 -o ip_filter.xclbin ip_filter.xo ``` ### 完整执行流程示例(修正后) ```bash # 1. 进入项目目录 cd ~/Desktop/FPGA/ip_filter # 2. 编译内核(添加平台选项) v++ -c -t hw --platform xilinx_u50_gen3x16_xdma_5_202210_1 --kernel ip_filter -I. -o ip_filter.xo ip_filter.cpp v++ -l -t hw --platform xilinx_u50_gen3x16_xdma_5_202210_1 -o ip_filter.xclbin ip_filter.xo # 3. 编译主机程序 source /opt/xilinx/xrt/setup.sh g++ -std=c++17 -I$XILINX_XRT/include -L$XILINX_XRT/lib -o ip_filter main.cpp -lOpenCL -lpthread -lrt -lxrt_coreutil # 4. 运行程序 ./ip_filter ``` ### 注意事项 1. 请确保`xilinx_u50_gen3x16_xdma_5_202210_1`与您的实际平台版本匹配。如果不确定,可以使用`xbutil list`查看设备,并检查已安装的平台。 2. 如果使用其他平台(如U200),请替换为对应的平台名称,例如:`xilinx_u200_gen3x16_xdma_2_202110_1` ### 常见平台名称参考 - Alveo U50: `xilinx_u50_gen3x16_xdma_5_202210_1` - Alveo U200: `xilinx_u200_gen3x16_xdma_2_202110_1` - Alveo U250: `xilinx_u250_gen3x16_xdma_4_1_202210_1` §§相关问题§§ 1. 如何动态检测当前系统FPGA平台并自动选择对应平台参数? 2. 是否需要为不同平台(如U50/U200)分别编译xclbin3. 计划如何管理多版本平台工具链的兼容性问题? 4. 是否考虑使用Makefile或CMake自动化编译流程? 5. 需要添加版本号区分不同编译生成的xclbin文件吗?</think>感谢您提供错误信息。问题在于编译内核命令缺少平台参数,我已修正命令并添加必要说明: ### 修正后的完整执行命令 ```bash # 1. 编译内核对象文件 (.xo) - 添加平台参数 v++ -c -t hw --platform xilinx_u50_gen3x16_xdma_5_202210_1 --kernel ip_filter -I. -o ip_filter.xo ip_filter.cpp # 2. 链接生成xclbin文件 v++ -l -t hw --platform xilinx_u50_gen3x16_xdma_5_202210_1 -o ip_filter.xclbin ip_filter.xo # 3. 设置XRT环境 source /opt/xilinx/xrt/setup.sh # 4. 编译主机程序 g++ -std=c++17 -I$XILINX_XRT/include -L$XILINX_XRT/lib -o ip_filter main.cpp -lOpenCL -lpthread -lrt -lxrt_coreutil # 5. 运行程序 ./ip_filter ``` ### 关键修正说明 1. **添加平台参数**:`--platform xilinx_u50_gen3x16_xdma_5_202210_1` 必须添加到编译命令中 2. **平台名称确认**: ```bash # 查看可用平台 ls /opt/xilinx/platforms # 示例输出: # xilinx_u50_gen3x16_xdma_5_202210_1 # xilinx_u200_gen3x16_xdma_1_202110_1 ``` 3. **常见平台名称**: - Alveo U50: `xilinx_u50_gen3x16_xdma_5_202210_1` - Alveo U200: `xilinx_u200_gen3x16_xdma_1_202110_1` - Alveo U250: `xilinx_u250_gen3x16_xdma_4_1_202210_1` ### 环境检查命令 ```bash # 检查XRT安装 echo $XILINX_XRT # 检查Vitis工具链 which v++ # 检查设备状态 xbutil examine ``` ### 调试建议 如果仍遇到问题,尝试分步验证: ```bash # 仅检查平台可用性 v++ --list-platforms # 简化编译测试 v++ -c -t hw --platform xilinx_u50_gen3x16_xdma_5_202210_1 --kernel ip_filter -I. -o test.xo ip_filter.cpp ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值