{"id":16515,"date":"2024-11-18T10:16:08","date_gmt":"2024-11-18T02:16:08","guid":{"rendered":"https:\/\/fwq.ai\/blog\/16515\/"},"modified":"2024-11-18T10:16:08","modified_gmt":"2024-11-18T02:16:08","slug":"%e7%bc%96%e8%af%91linux%e5%86%85%e6%a0%b8%e4%b8%80%e5%ae%9a%e8%a6%81%e7%9f%a5%e9%81%93%e7%9a%84%e5%87%a0%e4%b8%aa%e5%b0%8ftips","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/16515\/","title":{"rendered":"\u7f16\u8bd1Linux\u5185\u6838\u4e00\u5b9a\u8981\u77e5\u9053\u7684\u51e0\u4e2a\u5c0fTips"},"content":{"rendered":"<h2> <span><\/span><span style=\"padding: 2px 10px 1px;border-top-right-radius: 3px;border-top-left-radius: 3px;margin-right: 3px\">Tip1\uff1a\u4ea4\u53c9\u7f16\u8bd1\u9009\u9879<\/span><span style=\"vertical-align: bottom;border-bottom: 36px solid #efebe9;border-right: 20px solid transparent\"> <\/span> <\/h2>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u7f16\u8bd1Linux\uff0c\u901a\u5e38\u53ea\u9700\u8981\u8fd0\u884cmake menuconfig\u914d\u7f6e\u8981\u7f16\u8bd1\u7684\u6a21\u5757\uff0c\u7136\u540e\u8fd0\u884cmake\u3002Linux\u9ed8\u8ba4\u662f\u505a\u672c\u5730\u7f16\u8bd1\uff0c\u4e5f\u5c31\u662f\u7f16\u8bd1\u4f4d\u672c\u673a\u4f7f\u7528\u7684\u5185\u6838\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5728\u5d4c\u5165\u5f0f\u5f00\u53d1\u4e2d\uff0c\u7ecf\u5e38\u9700\u8981\u4ea4\u53c9\u7f16\u8bd1\uff0c\u8981\u505a\u4ea4\u53c9\u7f16\u8bd1\u7684\u8bdd\uff0c\u9700\u8981\u5728make\u547d\u4ee4\u540e\u52a0\u4e0a\u5b8f\u5b9a\u4e49\uff0c\u5982\u4ea4\u53c9\u7f16\u8bd1\u4e3aarm\u76ee\u6807\uff1a<\/p>\n<pre>make&nbsp;ARCH=arm&nbsp;CROSS_COMPILE=arm-linux-<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">ARCH=arm\uff1a\u8868\u793a\u76ee\u6807CPU\u4e3aARM\u67b6\u6784<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">CROSS_COMPILE=arm&#8211;\uff1a<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u8868\u793a\u7f16\u8bd1\u8fc7\u7a0b\u4f7f\u7528\u7684\u4ea4\u53c9\u7f16\u8bd1\u94fe\u4e3aarm-linux<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5f53\u7136\u4e5f\u53ef\u4ee5\u76f4\u63a5\u4fee\u6539Makefile\u4e2d\u7684ARCH\u548cCROSS_COMPILE\u5b8f\u5b9a\u4e49\uff0c\u4ee5\u6b64\u5b9e\u73b0\u540c\u6837\u7684\u6548\u679c\u3002\u4f46\u662f<strong>\u4e0d\u5efa\u8bae\u76f4\u63a5\u4fee\u6539Makefile<\/strong>\u3002<\/p>\n<h2> <span><\/span><span style=\"padding: 2px 10px 1px;border-top-right-radius: 3px;border-top-left-radius: 3px;margin-right: 3px\">Tip2\uff1a\u6e90\u7801\u4e0e\u76ee\u6807\u6587\u4ef6\u5206\u79bb<\/span><span style=\"vertical-align: bottom;border-bottom: 36px solid #efebe9;border-right: 20px solid transparent\"> <\/span> <\/h2>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">Linux\u5185\u6838\u7f16\u8bd1\u8fc7\u7a0b\u4f1a\u4ea7\u751f\u5f88\u591a\u7684\u6587\u4ef6\uff0c\u5305\u62ec\u76ee\u6807\u6587\u4ef6\u3001\u4e34\u65f6\u6587\u4ef6\u7b49\u7b49\uff0c<strong>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u7f16\u8bd1\u751f\u6210\u7684\u6587\u4ef6\u4f1a\u5b58\u653e\u5728\u5185\u6838\u6e90\u7801\u76ee\u5f55<\/strong>\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5f53\u4f60\u4f7f\u7528git status\u663e\u793a\u81ea\u5df1\u5bf9\u5185\u6838\u4ee3\u7801\u7684\u4fee\u6539\u65f6\u4e5f\u4f1a\u628a\u8fd9\u4e9b\u4e34\u65f6\u6587\u4ef6\u663e\u793a\u51fa\u6765\uff0c\u800c\u4e14\u63d0\u4ea4\u8fd8\u5fc5\u987b\u4e00\u4e2a\u6587\u4ef6\u4e00\u4e2a\u6587\u4ef6\u5730\u6307\u5b9a\uff0c\u76f8\u5f53\u9ebb\u70e6\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u56e0\u6b64\u6211\u4eec\u53ef\u4ee5\u5728\u7236\u76ee\u5f55\u521b\u5efa\u4e00\u4e2a\u5b58\u653e\u7f16\u8bd1\u6587\u4ef6\u7684\u76ee\u5f55\uff0c\u5982build-kernel\uff0c\u7136\u540e\u518dmake \u547d\u4ee4\u540e\u9762\u52a0\u4e0a\u5b8f\u5b9a\u4e49\uff1a<\/p>\n<pre>make&nbsp;O=..\/build-kernel<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u8fd9\u6837\u5728\u7f16\u8bd1Linux\u5185\u6838\u65f6\uff0c<strong>\u6240\u6709\u7f16\u8bd1\u4ea7\u751f\u7684\u6587\u4ef6\uff0c\u90fd\u4f1a\u653e\u5728build-kernel\u76ee\u5f55\uff0c\u5982\u679cbuild-kernel\u76ee\u5f55\u4e0d\u5b58\u5728\uff0c\u4e5f\u4f1a\u81ea\u52a8\u521b\u5efa<\/strong>\u3002\u8fd9\u6837\u53ef\u4ee5\u5b9e\u73b0Linux\u5185\u6838\u6e90\u7801\u4e0e\u7f16\u8bd1\u4ea7\u751f\u7684\u6587\u4ef6\u5206\u79bb\u3002<\/p>\n<h2> <span><\/span><span style=\"padding: 2px 10px 1px;border-top-right-radius: 3px;border-top-left-radius: 3px;margin-right: 3px\">Tip3\uff1a\u83b7\u5f97\u7f16\u8bd1\u547d\u4ee4\u53ca\u9009\u9879<\/span><span style=\"vertical-align: bottom;border-bottom: 36px solid #efebe9;border-right: 20px solid transparent\"> <\/span> <\/h2>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u7f16\u8bd1linux\u65f6\uff0c\u9ed8\u8ba4\u4e0d\u4f1a\u663e\u793a\u7f16\u8bd1\u7684\u547d\u4ee4\uff0c\u5982\u679c\u4f60\u8981\u83b7\u5f97\u7f16\u8bd1\u547d\u4ee4\u53ca\u5176\u9009\u9879\uff0c\u53ef\u4ee5\u5728make\u547d\u4ee4\u540e\u9762\u52a0\u4e0a\u5b8f\u5b9a\u4e49\uff1a<\/p>\n<pre>make&nbsp;V=1<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5982\u679c\u5e0c\u671b\u7f16\u8bd1\u7cfb\u7edf\u544a\u8bc9\u4f60\u4e3a\u4f55\u67d0\u4e2a\u76ee\u6807\u6587\u4ef6\u9700\u8981\u91cd\u65b0\u7f16\u8bd1\uff0c\u5219\uff1a<\/p>\n<pre>make&nbsp;V=2<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h2> <span><\/span><span style=\"padding: 2px 10px 1px;border-top-right-radius: 3px;border-top-left-radius: 3px;margin-right: 3px\">\u5185\u6838\u7f16\u8bd1\u811a\u672c<\/span><span style=\"vertical-align: bottom;border-bottom: 36px solid #efebe9;border-right: 20px solid transparent\"> <\/span> <\/h2>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u6700\u540e\u5206\u4eab\u6211\u5e38\u7528\u7684\u5185\u6838\u7f16\u8bd1\u811a\u672cmk.sh\uff0c\u7ed9\u5927\u5bb6\u53c2\u8003\uff1a<\/p>\n<pre>#!\/bin\/sh\n\nexport&nbsp;ARCH=arm\nexport&nbsp;PATH=~\/toolchain\/arm_glibc\/host\/bin:$PATH\nexport&nbsp;CROSS_COMPILE=arm-linux-gnu-\n\n#make&nbsp;O=..\/bd&nbsp;defconfig\nmake&nbsp;O=..\/bd&nbsp;menuconfig&nbsp;-j32\nmake&nbsp;O=..\/bd&nbsp;dtbs\n\n#\u53cd\u6c47\u7f16\n$(CROSS_COMPILE)objdump&nbsp;-d&nbsp;..\/bd\/vmlinux&nbsp;&amp;gt;&nbsp;..\/image\/vmlinux_dump.txt\n\n#\u751f\u6210uImage\n..\/ubd\/tools\/mkimage&nbsp;-A&nbsp;arm&nbsp;-T&nbsp;kernel&nbsp;-C&nbsp;none&nbsp;-O&nbsp;linux&nbsp;-a&nbsp;0x80200000&nbsp;-e&nbsp;0x80200000&nbsp;-n&nbsp;\"debug&nbsp;kernel\"&nbsp;-d&nbsp;..\/bd\/Image&nbsp;..\/image\/uImage<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">\u5176\u4e2d\uff0cmake O=..\/bd defconfig\u53ea\u6709\u5728\u7b2c\u4e00\u6b21\u7f16\u8bd1\u5185\u6838\u7684\u624d\u4f7f\u7528\uff0c\u7b2c\u4e00\u6b21\u7f16\u8bd1\u8fc7\u540e\uff0c\u5c06\u8fd9\u53e5\u6ce8\u91ca\uff0c\u540e\u9762\u90fd\u901a\u8fc7make menuconfig\u4fee\u6539\u5185\u6838\u914d\u7f6e\u3002<\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px\">objdump\u53cd\u6c47\u7f16\u5bf9\u5927\u591a\u6570\u4eba\u6765\u8bf4\u53ef\u80fd\u7528\u4e0d\u4e0a\uff0c\u4e00\u822c\u5728\u5185\u6838\u79fb\u690d\u3001\u542f\u52a8\u5206\u6790\u65f6\u6bd4\u8f83\u6709\u7528\uff0c\u4f46\u7531\u4e8e\u5de5\u4f5c\u9700\u8981\uff0c\u6211\u901a\u5e38\u90fd\u4f1a\u628a\u53cd\u6c47\u7f16\u52a0\u4e0a\u3002<\/p>\n<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u7f16\u8bd1Linux\u5185\u6838\u4e00\u5b9a\u8981\u77e5\u9053\u7684\u51e0\u4e2a\u5c0fTips\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Tip1\uff1a\u4ea4\u53c9\u7f16\u8bd1\u9009\u9879 \u7f16\u8bd1Linux\uff0c\u901a\u5e38\u53ea\u9700\u8981\u8fd0\u884cmake menuconfig\u914d\u7f6e\u8981\u7f16\u8bd1\u7684\u6a21\u5757\uff0c\u7136\u540e\u8fd0\u884cmake\u3002Linux\u9ed8\u8ba4\u662f\u505a\u672c\u5730\u7f16\u8bd1\uff0c\u4e5f\u5c31\u662f\u7f16\u8bd1\u4f4d\u672c\u673a\u4f7f\u7528\u7684\u5185\u6838\u3002 \u5728\u5d4c\u5165\u5f0f\u5f00\u53d1\u4e2d\uff0c\u7ecf\u5e38\u9700\u8981\u4ea4\u53c9\u7f16\u8bd1\uff0c\u8981\u505a\u4ea4\u53c9\u7f16\u8bd1\u7684\u8bdd\uff0c\u9700\u8981\u5728make\u547d\u4ee4\u540e\u52a0\u4e0a\u5b8f\u5b9a\u4e49\uff0c\u5982\u4ea4\u53c9\u7f16\u8bd1\u4e3aarm\u76ee\u6807\uff1a make&nbsp;ARCH=arm&nbsp;CROSS_COMPILE=arm-linux- \u767b\u5f55\u540e\u590d\u5236 ARCH=arm\uff1a\u8868\u793a\u76ee\u6807CPU\u4e3aARM\u67b6\u6784 CROSS_COMPILE=arm&#8211;\uff1a \u8868\u793a\u7f16\u8bd1\u8fc7\u7a0b\u4f7f\u7528\u7684\u4ea4\u53c9\u7f16\u8bd1\u94fe\u4e3aarm-linux \u5f53\u7136\u4e5f\u53ef\u4ee5\u76f4\u63a5\u4fee\u6539Makefile\u4e2d\u7684ARCH\u548cCROSS_COMPILE\u5b8f\u5b9a\u4e49\uff0c\u4ee5\u6b64\u5b9e\u73b0\u540c\u6837\u7684\u6548\u679c\u3002\u4f46\u662f\u4e0d\u5efa\u8bae\u76f4\u63a5\u4fee\u6539Makefile\u3002 Tip2\uff1a\u6e90\u7801\u4e0e\u76ee\u6807\u6587\u4ef6\u5206\u79bb Linux\u5185\u6838\u7f16\u8bd1\u8fc7\u7a0b\u4f1a\u4ea7\u751f\u5f88\u591a\u7684\u6587\u4ef6\uff0c\u5305\u62ec\u76ee\u6807\u6587\u4ef6\u3001\u4e34\u65f6\u6587\u4ef6\u7b49\u7b49\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u7f16\u8bd1\u751f\u6210\u7684\u6587\u4ef6\u4f1a\u5b58\u653e\u5728\u5185\u6838\u6e90\u7801\u76ee\u5f55\u3002 \u5f53\u4f60\u4f7f\u7528git status\u663e\u793a\u81ea\u5df1\u5bf9\u5185\u6838\u4ee3\u7801\u7684\u4fee\u6539\u65f6\u4e5f\u4f1a\u628a\u8fd9\u4e9b\u4e34\u65f6\u6587\u4ef6\u663e\u793a\u51fa\u6765\uff0c\u800c\u4e14\u63d0\u4ea4\u8fd8\u5fc5\u987b\u4e00\u4e2a\u6587\u4ef6\u4e00\u4e2a\u6587\u4ef6\u5730\u6307\u5b9a\uff0c\u76f8\u5f53\u9ebb\u70e6\u3002 \u56e0\u6b64\u6211\u4eec\u53ef\u4ee5\u5728\u7236\u76ee\u5f55\u521b\u5efa\u4e00\u4e2a\u5b58\u653e\u7f16\u8bd1\u6587\u4ef6\u7684\u76ee\u5f55\uff0c\u5982build-kernel\uff0c\u7136\u540e\u518dmake \u547d\u4ee4\u540e\u9762\u52a0\u4e0a\u5b8f\u5b9a\u4e49\uff1a make&nbsp;O=..\/build-kernel \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u6837\u5728\u7f16\u8bd1Linux\u5185\u6838\u65f6\uff0c\u6240\u6709\u7f16\u8bd1\u4ea7\u751f\u7684\u6587\u4ef6\uff0c\u90fd\u4f1a\u653e\u5728build-kernel\u76ee\u5f55\uff0c\u5982\u679cbuild-kernel\u76ee\u5f55\u4e0d\u5b58\u5728\uff0c\u4e5f\u4f1a\u81ea\u52a8\u521b\u5efa\u3002\u8fd9\u6837\u53ef\u4ee5\u5b9e\u73b0Linux\u5185\u6838\u6e90\u7801\u4e0e\u7f16\u8bd1\u4ea7\u751f\u7684\u6587\u4ef6\u5206\u79bb\u3002 Tip3\uff1a\u83b7\u5f97\u7f16\u8bd1\u547d\u4ee4\u53ca\u9009\u9879 \u7f16\u8bd1linux\u65f6\uff0c\u9ed8\u8ba4\u4e0d\u4f1a\u663e\u793a\u7f16\u8bd1\u7684\u547d\u4ee4\uff0c\u5982\u679c\u4f60\u8981\u83b7\u5f97\u7f16\u8bd1\u547d\u4ee4\u53ca\u5176\u9009\u9879\uff0c\u53ef\u4ee5\u5728make\u547d\u4ee4\u540e\u9762\u52a0\u4e0a\u5b8f\u5b9a\u4e49\uff1a make&nbsp;V=1 \u767b\u5f55\u540e\u590d\u5236 \u5982\u679c\u5e0c\u671b\u7f16\u8bd1\u7cfb\u7edf\u544a\u8bc9\u4f60\u4e3a\u4f55\u67d0\u4e2a\u76ee\u6807\u6587\u4ef6\u9700\u8981\u91cd\u65b0\u7f16\u8bd1\uff0c\u5219\uff1a make&nbsp;V=2 \u767b\u5f55\u540e\u590d\u5236 \u5185\u6838\u7f16\u8bd1\u811a\u672c \u6700\u540e\u5206\u4eab\u6211\u5e38\u7528\u7684\u5185\u6838\u7f16\u8bd1\u811a\u672cmk.sh\uff0c\u7ed9\u5927\u5bb6\u53c2\u8003\uff1a #!\/bin\/sh export&nbsp;ARCH=arm export&nbsp;PATH=~\/toolchain\/arm_glibc\/host\/bin:$PATH export&nbsp;CROSS_COMPILE=arm-linux-gnu- #make&nbsp;O=..\/bd&nbsp;defconfig make&nbsp;O=..\/bd&nbsp;menuconfig&nbsp;-j32 make&nbsp;O=..\/bd&nbsp;dtbs #\u53cd\u6c47\u7f16 $(CROSS_COMPILE)objdump&nbsp;-d&nbsp;..\/bd\/vmlinux&nbsp;&amp;gt;&nbsp;..\/image\/vmlinux_dump.txt #\u751f\u6210uImage ..\/ubd\/tools\/mkimage&nbsp;-A&nbsp;arm&nbsp;-T&nbsp;kernel&nbsp;-C&nbsp;none&nbsp;-O&nbsp;linux&nbsp;-a&nbsp;0x80200000&nbsp;-e&nbsp;0x80200000&nbsp;-n&nbsp;&#8220;debug&nbsp;kernel&#8221;&nbsp;-d&nbsp;..\/bd\/Image&nbsp;..\/image\/uImage \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff0cmake O=..\/bd defconfig\u53ea\u6709\u5728\u7b2c\u4e00\u6b21\u7f16\u8bd1\u5185\u6838\u7684\u624d\u4f7f\u7528\uff0c\u7b2c\u4e00\u6b21\u7f16\u8bd1\u8fc7\u540e\uff0c\u5c06\u8fd9\u53e5\u6ce8\u91ca\uff0c\u540e\u9762\u90fd\u901a\u8fc7make menuconfig\u4fee\u6539\u5185\u6838\u914d\u7f6e\u3002 objdump\u53cd\u6c47\u7f16\u5bf9\u5927\u591a\u6570\u4eba\u6765\u8bf4\u53ef\u80fd\u7528\u4e0d\u4e0a\uff0c\u4e00\u822c\u5728\u5185\u6838\u79fb\u690d\u3001\u542f\u52a8\u5206\u6790\u65f6\u6bd4\u8f83\u6709\u7528\uff0c\u4f46\u7531\u4e8e\u5de5\u4f5c\u9700\u8981\uff0c\u6211\u901a\u5e38\u90fd\u4f1a\u628a\u53cd\u6c47\u7f16\u52a0\u4e0a\u3002 \u4ee5\u4e0a\u5c31\u662f\u7f16\u8bd1Linux\u5185\u6838\u4e00\u5b9a\u8981\u77e5\u9053\u7684\u51e0\u4e2a\u5c0fTips\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-16515","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/16515","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=16515"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/16515\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=16515"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=16515"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=16515"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}