关于ProjectConfig.mk文件相关配置编译名字长度规定

本文探讨了谷歌对Android内部相关镜像文件头的字节限制规定,并具体介绍了在ProjectConfig.mk文件中CUSTOM_BUILD_VERNO变量遇到的问题及解决办法。文章还详细解释了bootimg.h和Makefile中的相关配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

谷歌本身对Android内部相关镜像文件头有字节的规定限制。

近期发现在项目文件rlk_projects\cxlite_z3713_a1_zmvf#####\ProjectConfig.mk中:

CUSTOM_BUILD_VERNO = CY-CxAir-z3713-L  工具校验的一个编译版本名,L没有显示出来,导致使用工具加载代码时校验匹配出错。

 

最后发现该长度在文件bootimg.h被定义为最长16字节,而且在文件build\core\Makefile中要求,只能为15个字节,如下代码:

build\core\Makefile:

# Pick a reasonable string to use toidentify files.

ifneq "" "$(filtereng.%,$(BUILD_NUMBER))"

  #BUILD_NUMBER has a timestamp in it, which means that

  #it will change every time.  Pick a stablevalue.

 FILE_NAME_TAG := eng.$(USER)

else

 FILE_NAME_TAG := $(BUILD_NUMBER)

Endif

 

ifeq """$(CUSTOM_BUILD_VERNO)"

 CUSTOM_BUILD_VERNO := $(BUILD_NUMBER)

 CUSTOM_BUILD_VERNO := $(subst eng.$(USER).,,$(CUSTOM_BUILD_VERNO))

endif

CUSTOM_BUILD_VERNO_HDR := $(shell echo$(firstword $(CUSTOM_BUILD_VERNO)) | cut -b 1-15)   //这里不写成1-16,我想有\0的关系

关于详细说明:

1、只显示文件中1-10位置的字符(省略10,到末尾):
    cut -c 1-10 <file>
2、只显示文件中1-10位置的字节:
    cut -b 1-10 <file>
    英文环境中和-c选项一样,但国际语言环境中有区别(如中文,字节和字符含义不同)。
3、显示第1-3字段
    cut -f 1-2 <file>
    缺省以TAB为字段分隔符,可以用-d指定分隔符。

 

在文件vendor\mediatek\proprietary\bootable\bootloader\lk\platform\mt6735\include\platform\bootimg.h中 [好像在kernel中也有相关的定义]

#define BOOT_MAGIC "ANDROID!"

#define BOOT_MAGIC_SIZE 8   //镜像头的限制,一定是8个以内

#define BOOT_NAME_SIZE 16    //软件编译的名字一定要小于16,注意\0

#define BOOT_ARGS_SIZE 512  //命令行参数一定小于512字节

 

struct boot_img_hdr

{

         unsigned charmagic[BOOT_MAGIC_SIZE];

 

         unsignedkernel_size;  /* size in bytes */

         unsignedkernel_addr;  /* physical load addr */

 

         unsigned ramdisk_size;/* size in bytes */

         unsigned ramdisk_addr;/* physical load addr */

 

         unsignedsecond_size;  /* size in bytes */

         unsignedsecond_addr;  /* physical load addr */

 

         unsignedtags_addr;    /* physical addr for kerneltags */

         unsignedpage_size;    /* flash page size weassume */

         unsigned unused;       /* future expansion: should be 0 */

         unsigned os_version;

 

         unsigned char name[BOOT_NAME_SIZE]; /* asciiz product name */

 

         unsigned charcmdline[BOOT_ARGS_SIZE];

 

         unsigned id[8]; /*timestamp / checksum / sha1 / etc */

};

/*

 ** +-----------------+

 ** | boot header     | 1 page

 ** +-----------------+

 ** | kernel          | n pages

 ** +-----------------+

 ** | ramdisk         | m pages

 ** +-----------------+

 ** | second stage    | o pages

 ** +-----------------+

 **

** n = (kernel_size + page_size - 1) / page_size

 ** m = (ramdisk_size +page_size - 1) / page_size

 ** o = (second_size +page_size - 1) / page_size

 **

 ** 0. all entities arepage_size aligned in flash

 ** 1. kernel and ramdisk arerequired (size != 0)

 ** 2. second is optional(second_size == 0 -> no second)

 ** 3. load each element(kernel, ramdisk, second) at

**    the specified physicaladdress (kernel_addr, etc)

 ** 4. prepare tags attag_addr.  kernel_args[] is

 **    appended to the kernel commandline in thetags.

 ** 5. r0 = 0, r1 =MACHINE_TYPE, r2 = tags_addr

 ** 6. if second_size != 0:jump to second_addr

 **    else: jump to kernel_addr

 */


07:39:05 **** 项目czhidao配置Debug的增量构建 **** make -j16 all arm-none-eabi-gcc "../Core/Src/dma_tim_config.c" -mcpu=cortex-m3 -std=gnu11 -g3 -DDEBUG -DUSE_HAL_DRIVER -DSTM32F103xB -c -I../Core/Inc -I../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -I../Drivers/STM32F1xx_HAL_Driver/Inc -I../Drivers/CMSIS/Device/ST/STM32F1xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Core/Src/dma_tim_config.d" -MT"Core/Src/dma_tim_config.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Core/Src/dma_tim_config.o" arm-none-eabi-gcc "../Core/Src/main.c" -mcpu=cortex-m3 -std=gnu11 -g3 -DDEBUG -DUSE_HAL_DRIVER -DSTM32F103xB -c -I../Core/Inc -I../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -I../Drivers/STM32F1xx_HAL_Driver/Inc -I../Drivers/CMSIS/Device/ST/STM32F1xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Core/Src/main.d" -MT"Core/Src/main.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Core/Src/main.o" arm-none-eabi-gcc "../Core/Src/ws2812.c" -mcpu=cortex-m3 -std=gnu11 -g3 -DDEBUG -DUSE_HAL_DRIVER -DSTM32F103xB -c -I../Core/Inc -I../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -I../Drivers/STM32F1xx_HAL_Driver/Inc -I../Drivers/CMSIS/Device/ST/STM32F1xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Core/Src/ws2812.d" -MT"Core/Src/ws2812.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Core/Src/ws2812.o" In file included from ../Core/Src/main.c:21: ../Core/Src/main.c: In function 'Generate_WS2812_Data': ../Core/Inc/ws2812.h:14:28: error: 'WS2812_BIT_1_PULS' undeclared (first use in this function); did you mean 'WS2812_BIT_1_PULSE'? 14 | #define WS2812_CCR_HIGH WS2812_BIT_1_PULS | ^~~~~~~~~~~~~~~~~ ../Core/Src/main.c:75:27: note: in expansion of macro 'WS2812_CCR_HIGH' 75 | *buffer++ = bit_val ? WS2812_CCR_HIGH : WS2812_CCR_LOW; | ^~~~~~~~~~~~~~~ ../Core/Inc/ws2812.h:14:28: note: each undeclared identifier is reported only once for each function it appears in 14 | #define WS2812_CCR_HIGH WS2812_BIT_1_PULS | ^~~~~~~~~~~~~~~~~ ../Core/Src/main.c:75:27: note: in expansion of macro 'WS2812_CCR_HIGH' 75 | *buffer++ = bit_val ? WS2812_CCR_HIGH : WS2812_CCR_LOW; | ^~~~~~~~~~~~~~~ ../Core/Src/main.c: In function 'main': ../Core/Src/main.c:91:5: warning: implicit declaration of function 'TIM2_DMA_Init'; did you mean 'MX_DMA_Init'? [-Wimplicit-function-declaration] 91 | TIM2_DMA_Init(); | ^~~~~~~~~~~~~ | MX_DMA_Init ../Core/Src/ws2812.c: In function 'Start_TIM2_DMA_Transfer': ../Core/Src/ws2812.c:54:9: error: 'BUFFER_SIZE' undeclared (first use in this function) 54 | BUFFER_SIZE | ^~~~~~~~~~~ ../Core/Src/ws2812.c:54:9: note: each undeclared identifier is reported only once for each function it appears in ../Core/Src/main.c:93:25: error: 'BUFFER_SIZE' undeclared (first use in this function) 93 | uint16_t led_buffer[BUFFER_SIZE]; | ^~~~~~~~~~~ In file included from ../Core/Src/ws2812.c:1: ../Core/Src/ws2812.c: In function 'Generate_WS2812_Data': ../Core/Inc/ws2812.h:14:28: error: 'WS2812_BIT_1_PULS' undeclared (first use in this function); did you mean 'WS2812_BIT_1_PULSE'? 14 | #define WS2812_CCR_HIGH WS2812_BIT_1_PULS | ^~~~~~~~~~~~~~~~~ ../Core/Src/ws2812.c:74:40: note: in expansion of macro 'WS2812_CCR_HIGH' 74 | *buffer++ = (grb & (1 << i)) ? WS2812_CCR_HIGH : WS2812_CCR_LOW; | ^~~~~~~~~~~~~~~ make: *** [Core/Src/subdir.mk:40: Core/Src/ws2812.o] Error 1 make: *** Waiting for unfinished jobs.... ../Core/Src/main.c:97:9: warning: implicit declaration of function 'Start_TIM2_DMA_Transfer' [-Wimplicit-function-declaration] 97 | Start_TIM2_DMA_Transfer(led_buffer); | ^~~~~~~~~~~~~~~~~~~~~~~ ../Core/Src/main.c:99:16: error: 'dma_transfer_complete' undeclared (first use in this function) 99 | while(!dma_transfer_complete); // 等待传输完成 | ^~~~~~~~~~~~~~~~~~~~~ ../Core/Src/main.c:93:14: warning: unused variable 'led_buffer' [-Wunused-variable] 93 | uint16_t led_buffer[BUFFER_SIZE]; | ^~~~~~~~~~ make: *** [Core/Src/subdir.mk:40: Core/Src/main.o] Error 1 "make -j16 all"以退出代码2结尾。构建可能不完整。 07:39:05 构建失败。 8 错误,3 警告。 (使用675ms) 再次报错请继续给出完整文件
最新发布
06-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值