在使用MT7628芯片时,下载的工程编译后自带的wifi驱动不能正常运行,手机搜索不到对应WIFI。
工程文件:mtk-openwrt-sdk-20151231-185ab215.tar.bz2
下载路径:https://www.openwrtdl.com/wordpress/?s=7628
因此又从网络上寻找最新的MT7628 WIFI驱动:
MT7628_LinuxAP_V4.1.0.0_DPA_20161216.rar
将此驱动添加进下载的工程中,编译出现以下错误:
/home/lc/openwrt_mtk/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/mt7628-p4rev-190515/build//../src/embedded/../rate_ctrl/alg_grp.c: In function 'NewRateAdaptMT':
/home/lc/openwrt_mtk/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/mt7628-p4rev-190515/build//../src/embedded/../rate_ctrl/alg_grp.c:839:5: error: suggest parentheses around comparison in operand of '&' [-Werror=parentheses]
((pEntry->SupportRateMode&(SUPPORT_HT_MODE|SUPPORT_OFDM_MODE|SUPPORT_CCK_MODE)==0x07)&&((CurrRateIdx <= MCS_3)||(pCurrTxRate->Mode==MODE_OFDM)||(pCurrTxRate->Mode==MODE_CCK)))|| /* B/G/N MIX Mode */
^
/home/lc/openwrt_mtk/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/mt7628-p4rev-190515/build//../src/embedded/../rate_ctrl/alg_grp.c:840:5: error: suggest parentheses around comparison in operand of '&' [-Werror=parentheses]
((pEntry->SupportRateMode&(SUPPORT_HT_MODE|SUPPORT_OFDM_MODE|SUPPORT_CCK_MODE)==0x03)&&(CurrRateIdx <= MCS_3))/* B/G MIX Mode*/) )
^
/home/lc/openwrt_mtk/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/mt7628-p4rev-190515/build//../src/embedded/../rate_ctrl/alg_grp.c:935:5: error: suggest parentheses around comparison in operand of '&' [-Werror=parentheses]
((pEntry->SupportRateMode&(SUPPORT_HT_MODE|SUPPORT_OFDM_MODE|SUPPORT_CCK_MODE)==0x07)&&((CurrRateIdx <= MCS_3)||(pCurrTxRate->Mode==MODE_OFDM)||(pCurrTxRate->Mode==MODE_CCK)))|| /* B/G/N MIX Mode */
^
/home/lc/openwrt_mtk/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/mt7628-p4rev-190515/build//../src/embedded/../rate_ctrl/alg_grp.c:936:5: error: suggest parentheses around comparison in operand of '&' [-Werror=parentheses]
((pEntry->SupportRateMode&(SUPPORT_HT_MODE|SUPPORT_OFDM_MODE|SUPPORT_CCK_MODE)==0x03)&&(CurrRateIdx <= MCS_3))/* B/G MIX Mode*/) )
^
cc1: all warnings being treated as errors
scripts/Makefile.build:308: recipe for target '/home/lc/openwrt_mtk/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/mt7628-p4rev-190515/build//../src/embedded/../rate_ctrl/alg_grp.o' failed
make[5]: *** [/home/lc/openwrt_mtk/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/mt7628-p4rev-190515/build//../src/embedded/../rate_ctrl/alg_grp.o] Error 1
Makefile:1224: recipe for target '_module_/home/lc/openwrt_mtk/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/mt7628-p4rev-190515/build/' failed
make[4]: *** [_module_/home/lc/openwrt_mtk/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/mt7628-p4rev-190515/build/] Error 2
make[4]: Leaving directory '/home/lc/openwrt_mtk/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/linux-3.10.14'
Makefile:86: recipe for target '/home/lc/openwrt_mtk/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/mt7628-p4rev-190515/.built' failed
make[3]: *** [/home/lc/openwrt_mtk/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/mt7628-p4rev-190515/.built] Error 2
make[3]: Leaving directory '/home/lc/openwrt_mtk/openwrt-sdk/package/ramips/drivers/mt7628'
package/Makefile:173: recipe for target 'package/ramips/drivers/mt7628/compile' failed
make[2]: *** [package/ramips/drivers/mt7628/compile] Error 2
make[2]: Leaving directory '/home/lc/openwrt_mtk/openwrt-sdk'
package/Makefile:170: recipe for target '/home/lc/openwrt_mtk/openwrt-sdk/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/stamp/.package_compile' failed
make[1]: *** [/home/lc/openwrt_mtk/openwrt-sdk/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/stamp/.package_compile] Error 2
make[1]: Leaving directory '/home/lc/openwrt_mtk/openwrt-sdk'
/home/lc/openwrt_mtk/openwrt-sdk/include/toplevel.mk:171: recipe for target 'world' failed
make: *** [world] Error 2
从以上信息中我们可以清晰的知道错误发生的位置:
190515/build//../src/embedded/../rate_ctrl/alg_grp.c:839:5: error: suggest parentheses around comparison in operand of '&' [-Werror=parentheses]
((pEntry->SupportRateMode&(SUPPORT_HT_MODE|SUPPORT_OFDM_MODE|SUPPORT_CCK_MODE)==0x07)&&((CurrRateIdx <= MCS_3)||(pCurrTxRate->Mode==MODE_OFDM)||(pCurrTxRate->Mode==MODE_CCK)))|| /* B/G/N MIX Mode */
^
/home/lc/openwrt_mtk/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/mt7628-p4rev-190515/build//../src/embedded/../rate_ctrl/alg_grp.c:840:5: error: suggest parentheses around comparison in operand of '&' [-Werror=parentheses]
((pEntry->SupportRateMode&(SUPPORT_HT_MODE|SUPPORT_OFDM_MODE|SUPPORT_CCK_MODE)==0x03)&&(CurrRateIdx <= MCS_3))/* B/G MIX Mode*/) )
^
/home/lc/openwrt_mtk/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/mt7628-p4rev-190515/build//../src/embedded/../rate_ctrl/alg_grp.c:935:5: error: suggest parentheses around comparison in operand of '&' [-Werror=parentheses]
((pEntry->SupportRateMode&(SUPPORT_HT_MODE|SUPPORT_OFDM_MODE|SUPPORT_CCK_MODE)==0x07)&&((CurrRateIdx <= MCS_3)||(pCurrTxRate->Mode==MODE_OFDM)||(pCurrTxRate->Mode==MODE_CCK)))|| /* B/G/N MIX Mode */
^
/home/lc/openwrt_mtk/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/mt7628-p4rev-190515/build//../src/embedded/../rate_ctrl/alg_grp.c:936:5: error: suggest parentheses around comparison in operand of '&' [-Werror=parentheses]
((pEntry->SupportRateMode&(SUPPORT_HT_MODE|SUPPORT_OFDM_MODE|SUPPORT_CCK_MODE)==0x03)&&(CurrRateIdx <= MCS_3))/* B/G MIX Mode*/) )
^
cc1: all warnings being treated as errors
关键错误信息: error: suggest parentheses around comparison in operand of ‘&’ [-Werror=parentheses]
原因分析:
该警告希望你在&(逻辑与)表达式左右加上括号。有的时候&&(逻辑且)少写了一个&,也会产生该警告。
例如:
if((a[2]>>1)&0x1 == 1){
…
}
应该将 (a[2]>>1)&0x1 用()号括起来。因为&运算符的优先级较低,低于==和!=运算符。
于是找到相应错误代码(839行,840行,935行和936行),
修改前:
/*Ivan Lee add add for 360 promote middle sta performance*/
/*If B/G/N MIX Mode but pCurrTxRate <= MCS_3, ,not drop rate*/
/*If B/G MIX Mode but pCurrTxRate <= MCS_3 ,not drop rate*/
if( (Rssi > pAd->CommonCfg.MidRssiSet) && (
((pEntry->SupportRateMode&(SUPPORT_HT_MODE|SUPPORT_OFDM_MODE|SUPPORT_CCK_MODE)==0x07)&&((CurrRateIdx <= MCS_3)||(pCurrTxRate->Mode==MODE_OFDM)||(pCurrTxRate->Mode==MODE_CCK)))|| /* B/G/N MIX Mode */
((pEntry->SupportRateMode&(SUPPORT_HT_MODE|SUPPORT_OFDM_MODE|SUPPORT_CCK_MODE)==0x03)&&(CurrRateIdx <= MCS_3))/* B/G MIX Mode*/) )
{
......
......
修改后
/*Ivan Lee add add for 360 promote middle sta performance*/
/*If B/G/N MIX Mode but pCurrTxRate <= MCS_3, ,not drop rate*/
/*If B/G MIX Mode but pCurrTxRate <= MCS_3 ,not drop rate*/
if( (Rssi > pAd->CommonCfg.MidRssiSet) && (
(((pEntry->SupportRateMode&(SUPPORT_HT_MODE|SUPPORT_OFDM_MODE|SUPPORT_CCK_MODE))==0x07)&&((CurrRateIdx <= MCS_3)||(pCurrTxRate->Mode==MODE_OFDM)||(pCurrTxRate->Mode==MODE_CCK)))|| /* B/G/N MIX Mode */
(((pEntry->SupportRateMode&(SUPPORT_HT_MODE|SUPPORT_OFDM_MODE|SUPPORT_CCK_MODE))==0x03)&&(CurrRateIdx <= MCS_3))/* B/G MIX Mode*/) )
{
.....
.....