OpenOCD安装与使用(JTAG调试) (2)

解决方案 1: 通过源码分析可以看出,这块的报错只是因为在switch case语句中一个case没有写break,编译器识别到可能会跳到下一个case语句中,因此在这里直接忽略该错误继续编译即可。

imaginemiracle@:openocd$ make -j8 CFLAGS='-Wno-implicit-fallthrough'

<4.2> 报错 2: src/target/arm_disassembler.c:1499:30: error: bitwise comparison always evaluates to false [-Werror=tautological-compare]

#错误2 src/target/arm_disassembler.c: In function ‘evaluate_misc_instr’: src/target/arm_disassembler.c:1499:30: error: bitwise comparison always evaluates to false [-Werror=tautological-compare] 1499 | if (((opcode & 0x00600000) == 0x00100000) && (x == 0)) { | ^~ src/target/arm_disassembler.c:1521:29: error: bitwise comparison always evaluates to false [-Werror=tautological-compare] 1521 | if ((opcode & 0x00600000) == 0x00300000) { | ^~ src/target/arm_disassembler.c:1542:30: error: bitwise comparison always evaluates to false [-Werror=tautological-compare] 1542 | if (((opcode & 0x00600000) == 0x00100000) && (x == 1)) { | ^~

解决方案 2: 按照道理说这种写法是没什么问题的,但还是会报错,因此将报错的三个位置进行修改,修改后的代码如下。

imaginemiracle@:openocd$ vim src/target/arm_disassembler.c +1499 //File src/target/arm_disassembler.c +1499:In function 'evaluate_misc_instr' /* SMLAW < y> */ //============================Alter by me============================== if (!(((opcode & 0x00600000) - 0x00100000)) && (x == 0)) { //============================ End Alter ============================== uint8_t Rd, Rm, Rs, Rn; instruction->type = ARM_SMLAWy; Rd = (opcode & 0xf0000) >> 16; Rm = (opcode & 0xf); Rs = (opcode & 0xf00) >> 8; Rn = (opcode & 0xf000) >> 12; snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tSMLAW%s%s r%i, r%i, r%i, r%i", address, opcode, (y) ? "T" : "B", COND(opcode), Rd, Rm, Rs, Rn); } /* SMUL < x><y> */ //============================Alter by me============================== if (!((opcode & 0x00600000) - 0x00300000)) { //============================ End Alter ============================== uint8_t Rd, Rm, Rs; instruction->type = ARM_SMULxy; Rd = (opcode & 0xf0000) >> 16; Rm = (opcode & 0xf); Rs = (opcode & 0xf00) >> 8; snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tSMULW%s%s%s r%i, r%i, r%i", address, opcode, (x) ? "T" : "B", (y) ? "T" : "B", COND(opcode), Rd, Rm, Rs); } /* SMULW < y> */ //============================Alter by me============================== if (!(((opcode & 0x00600000) - 0x00100000)) && (x == 1)) { //============================ End Alter ============================== uint8_t Rd, Rm, Rs; instruction->type = ARM_SMULWy; Rd = (opcode & 0xf0000) >> 16; Rm = (opcode & 0xf); Rs = (opcode & 0xf00) >> 8; snprintf(instruction->text, 128, "0x%8.8" PRIx32 "\t0x%8.8" PRIx32 "\tSMULW%s%s r%i, r%i, r%i", address, opcode, (y) ? "T" : "B", COND(opcode), Rd, Rm, Rs); }

<4.3> 报错 3: src/target/nds32_cmd.c:824:21: error: ‘sprintf’ writing a terminating nul past the end of the destination [-Werror=format-overflow=]

#错误3 src/target/nds32_cmd.c: In function ‘jim_nds32_bulk_read’: src/target/nds32_cmd.c:824:21: error: ‘sprintf’ writing a terminating nul past the end of the destination [-Werror=format-overflow=] 824 | sprintf(data_str, "0x%08" PRIx32 " ", data[i]); | ^~~~~~~ src/target/nds32_cmd.c:824:38: note: format string is defined here 824 | sprintf(data_str, "0x%08" PRIx32 " ", data[i]); | ^ src/target/nds32_cmd.c:824:3: note: ‘sprintf’ output 12 bytes into a destination of size 11 824 | sprintf(data_str, "0x%08" PRIx32 " ", data[i]); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

解决方案 3: 从错误类型format-overflow,格式溢出,一看就是不重要的错误,直接忽略就好继续编译。

imaginemiracle@:openocd$ make -j8 CFLAGS='-Wno-implicit-fallthrough -Wno-format-overflow'

<4.4> 报错 4: /usr/include/x86_64-linux-gnu/sys/sysctl.h:21:2: error: #warning "The <sys/sysctl.h> header is deprecated and will be removed." [-Werror=cpp]

#错误4 In file included from src/helper/options.c:38: /usr/include/x86_64-linux-gnu/sys/sysctl.h:21:2: error: #warning "The <sys/sysctl.h> header is deprecated and will be removed." [-Werror=cpp] 21 | #warning "The <sys/sysctl.h> header is deprecated and will be removed." | ^~~~~~~ cc1: all warnings being treated as errors

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wspgpw.html