lugl4313820 发表于 2023-5-26 22:06

【米尔瑞萨RZ/G2L开发板-试用体验】安装交叉编译环境并输出hello world

<div class='showpostmsg'><p>下载sdk并上传到虚拟机,解压后执行:</p>

<p>在这对话框中输入想要保存的目录:</p>

<p> &nbsp;在下面的对话框中输入Y:</p>

<p> &nbsp;</p>

<p>&nbsp; 然后等待安装结束:</p>

<pre>
<code>Extracting SDK.......................................................................................................................................................................................................done
Setting it up...done
SDK has been successfully set up and is ready to be used.
Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
$ . /opt/yg2lx/environment-setup-aarch64-poky-linux
$ . /opt/yg2lx/environment-setup-armv7vet2hf-neon-vfpv4-pokymllib32-linux-gnueabi
</code></pre>

<div>安装完成后,使用以下命令设置环境变量,测试 SDK 是否完成:</div>

<div>
<pre>
<code>lugl@lugl-virtual-machine:~/MYD/sdk$ source /opt/yg2lx/environment-setup-aarch64-poky-linux

lugl@lugl-virtual-machine:~/MYD/sdk$ $CC -v
Using built-in specs.
COLLECT_GCC=aarch64-poky-linux-gcc
COLLECT_LTO_WRAPPER=/opt/yg2lx/sysroots/x86_64-pokysdk-linux/usr/libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/8.3.0/lto-wrapper
Target: aarch64-poky-linux
Configured with: ../../../../../../work-shared/gcc-8.3.0-r0/gcc-8-8.3.0/src/configure --build=x86_64-linux --host=x86_64-pokysdk-linux --target=aarch64-poky-linux --prefix=/usr/local/oe-sdk-hardcoded-buildpath/sysroots/x86_64-pokysdk-linux/usr --exec_prefix=/usr/local/oe-sdk-hardcoded-buildpath/sysroots/x86_64-pokysdk-linux/usr --bindir=/usr/local/oe-sdk-hardcoded-buildpath/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux --sbindir=/usr/local/oe-sdk-hardcoded-buildpath/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux --libexecdir=/usr/local/oe-sdk-hardcoded-buildpath/sysroots/x86_64-pokysdk-linux/usr/libexec/aarch64-poky-linux --datadir=/usr/local/oe-sdk-hardcoded-buildpath/sysroots/x86_64-pokysdk-linux/usr/share --sysconfdir=/usr/local/oe-sdk-hardcoded-buildpath/sysroots/x86_64-pokysdk-linux/etc --sharedstatedir=/usr/local/oe-sdk-hardcoded-buildpath/sysroots/x86_64-pokysdk-linux/com --localstatedir=/usr/local/oe-sdk-hardcoded-buildpath/sysroots/x86_64-pokysdk-linux/var --libdir=/usr/local/oe-sdk-hardcoded-buildpath/sysroots/x86_64-pokysdk-linux/usr/lib/aarch64-poky-linux --includedir=/usr/local/oe-sdk-hardcoded-buildpath/sysroots/x86_64-pokysdk-linux/usr/include --oldincludedir=/usr/local/oe-sdk-hardcoded-buildpath/sysroots/x86_64-pokysdk-linux/usr/include --infodir=/usr/local/oe-sdk-hardcoded-buildpath/sysroots/x86_64-pokysdk-linux/usr/share/info --mandir=/usr/local/oe-sdk-hardcoded-buildpath/sysroots/x86_64-pokysdk-linux/usr/share/man --disable-silent-rules --disable-dependency-tracking --with-libtool-sysroot=/home/hjx/renesas/new2-yocto/build-myir/tmp/work/x86_64-nativesdk-pokysdk-linux/gcc-cross-canadian-aarch64/8.3.0-r0/recipe-sysroot --with-gnu-ld --enable-shared --enable-languages=c,c++ --enable-threads=posix --enable-multilib --enable-default-pie --enable-c99 --enable-long-long --enable-symvers=gnu --enable-libstdcxx-pch --program-prefix=aarch64-poky-linux- --without-local-prefix --disable-install-libiberty --enable-lto --disable-libssp --enable-libitm --disable-bootstrap --disable-libmudflap --with-system-zlib --with-linker-hash-style=gnu --enable-linker-build-id --with-ppl=no --with-cloog=no --enable-checking=release --enable-cheaders=c_global --without-isl --with-gxx-include-dir=/not/exist/usr/include/c++/8.3.0 --with-build-time-tools=/home/hjx/renesas/new2-yocto/build-myir/tmp/work/x86_64-nativesdk-pokysdk-linux/gcc-cross-canadian-aarch64/8.3.0-r0/recipe-sysroot-native/usr/aarch64-poky-linux/bin --with-sysroot=/not/exist --with-build-sysroot=/home/hjx/renesas/new2-yocto/build-myir/tmp/work/x86_64-nativesdk-pokysdk-linux/gcc-cross-canadian-aarch64/8.3.0-r0/recipe-sysroot --enable-poison-system-directories --disable-static --enable-nls --with-glibc-version=2.28 --enable-initfini-array --enable-__cxa_atexit
Thread model: posix
gcc version 8.3.0 (GCC)
</code></pre>

<p>测试编译:</p>

<p>用vim 编写一个hello.c:</p>

<p>&nbsp;保存后编译:$CC hello.c -o hello</p>

<p>编译后查看hello文件类型:</p>

<pre>
<code>lugl@lugl-virtual-machine:~/MYD/sdk$ file hello
hello: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-aarch64.so.1, for GNU/Linux 3.14.0, BuildID=5aa9a4ba2a1ff9ca3ef36c5d5508eb448b8f85f1, with debug_info, not stripped
</code></pre>

<p>说明编译成功,我把hello上传到开发板,修改执行权限后运行,成功打印出hello world!</p>

<p>&nbsp; 致此,我们成功的安装的SDK,后续就可以愉快的编程了。</p>
</div>
</div><script>                                        var loginstr = '<div class="locked">查看本帖全部内容,请<a href="javascript:;"   style="color:#e60000" class="loginf">登录</a>或者<a href="https://bbs.eeworld.com.cn/member.php?mod=register_eeworld.php&action=wechat" style="color:#e60000" target="_blank">注册</a></div>';
                                       
                                        if(parseInt(discuz_uid)==0){
                                                                                                (function($){
                                                        var postHeight = getTextHeight(400);
                                                        $(".showpostmsg").html($(".showpostmsg").html());
                                                        $(".showpostmsg").after(loginstr);
                                                        $(".showpostmsg").css({height:postHeight,overflow:"hidden"});
                                                })(jQuery);
                                        }                </script><script type="text/javascript">(function(d,c){var a=d.createElement("script"),m=d.getElementsByTagName("script"),eewurl="//counter.eeworld.com.cn/pv/count/";a.src=eewurl+c;m.parentNode.insertBefore(a,m)})(document,523)</script>

wangerxian 发表于 2023-5-29 09:32

<p>其实有点好奇,交叉编译的代码怎么调试。</p>

lugl4313820 发表于 2023-5-29 10:33

wangerxian 发表于 2023-5-29 09:32
其实有点好奇,交叉编译的代码怎么调试。

<p>交叉编译的话,如果想调试,一般用日志打印来查看。</p>

wangerxian 发表于 2023-5-29 10:36

lugl4313820 发表于 2023-5-29 10:33
交叉编译的话,如果想调试,一般用日志打印来查看。

<p>那确实有点麻烦,不能实时看变量值太难受了。</p>

lugl4313820 发表于 2023-5-29 21:08

wangerxian 发表于 2023-5-29 10:36
那确实有点麻烦,不能实时看变量值太难受了。

<p>&nbsp; 我没有搞过调试列,如果是祼机的话,就是直接jatg就行了。</p>
页: [1]
查看完整版本: 【米尔瑞萨RZ/G2L开发板-试用体验】安装交叉编译环境并输出hello world