ARM嵌入式移植学习笔记

移植基本步骤:

  • 确定目标机、主机的连接方式 

           UART异步串行通信接口、USB串行通信接口、TCP/IP网络通信接口、Debug Jtag调试接口

  • 安装交叉编译器

安装芯片厂商已经编译好的工具链

        (eabi是嵌入式的意思)

         解压缩厂商提供的交叉编译工具链压缩包---》添加PATH环境变量

         #echo $PATH   //查看环境变量

         #PATH=$PATH:编译器路径     //添加环境变量

        或者vi /etc/environment打开文件在PATH里面添加一个“:”,后面更上新添加的环境变量路径即可。

         添加环境变量之后需要source之后才能生效

       

root@ubuntu:/# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/ndk/android-ndk-r8b:/usr/local/arm/arm-2009q3/bin
root@ubuntu:/# vi /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
~                                                                              
~                                                                              
      

编译使用方法:

例:#arm-linux-gcc -o build helloworld.c    //本例将helloworld.c源程序通过arm-linux-gcc编译器编译成build文件

附:

file <filename>     //可查看文件信息,x86等格式信息;

 

自己动手编译交叉工具链

       这个太难了,新手就请暂时放弃好了。

  • 搭建主机-目标机数据传输通道

 

  •  交叉编译工具集:

       readelf  <filename>

              -h  读头

              包含入口点地址信息,可通过文件IO更改其值,程序将从那个地址运行

root@ubuntu:/home/topeet/Android# readelf -h adctest
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0x8120
  Start of program headers:          52 (bytes into file)
  Start of section headers:          553144 (bytes into file)
  Flags:                             0x5000002, has entry point, Version5 EABI
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         6
  Size of section headers:           40 (bytes)
  Number of section headers:         28
  Section header string table index: 25

       size  <filename>

               看文件每个段的信息

例:

root@ubuntu:/home/topeet/Android# size adc
   text	   data	    bss	    dec	    hex	filename
   1943	    544	     16	   2503	    9c7	adc

 

           nm   <filename>

                   查看符号标签,函数在内存中一一对应的地址

           strip   <filename>

                   删去文件符号信息,减少占用空间大小,一般嵌入式都要删去符号信息

root@ubuntu:/home/topeet/Android# nm adc
0000000000600e50 d _DYNAMIC
0000000000600fe8 d _GLOBAL_OFFSET_TABLE_
00000000004008b8 R _IO_stdin_used
                 w _Jv_RegisterClasses
0000000000600e30 d __CTOR_END__
0000000000600e28 d __CTOR_LIST__
0000000000600e40 D __DTOR_END__
0000000000600e38 d __DTOR_LIST__
00000000004009e0 r __FRAME_END__
0000000000600e48 d __JCR_END__
//部分信息
root@ubuntu:/home/topeet/Android# strip adc
root@ubuntu:/home/topeet/Android# ls
adc  adctest  adctest.c  buzzer  buzzer.c  leds  leds.c
root@ubuntu:/home/topeet/Android# nm adc
nm: adc: no symbols

          strings  <filename>

                查看文件中定义了哪些字符串,可以知道有什么字符串

           objdump  <filename>

                 反汇编  -d   可以看到地址,函数名代码,汇编代码等

            objcopy  <filename>

            addr2line   <filename>     

 

 

  • pc---开发板  环境搭建

          主机中的数据如何传递到开发板?

                  普通数据   uboot   kernel        传递           串口 uart   、   网络接口TFTP

                  调试:挂载           u盘挂载,走的串口

                                               远程共享目录挂载,走的TCP/IP协议

  •  UBOOT

           uboot是bootloader功能的一个软件,做的比较好,比较著名的一款软件

           学uboot就是学命令,像shell命令一样

           uboot常用命令:

                               print                         //查看 uboot这个软件的环境变量

                               变量名=变量值

                               setenv  abc  100   200        //将100  200变量值设置给abc变量

                               setenv  abc                       // 删除这个变量

                               如果只是设置了,那么,只是保存在RAM中,断电就丢失了,而想要永久保存这个变量,就得将其保存进断电不丢失的存储体ROM中,saveenv命令就是用来实现这个目标的。

                               saveenv                   //把本次设置的环境变量写回存储体

                               tftp  20008000  a.txt        //下载到开发板

                               nand 

                              bootm                           //

                               go

                              md   20008000                 //内存显示

猜你喜欢

转载自blog.csdn.net/qq_42371913/article/details/88342319