Chinaunix首页 | 论坛 | 博客
  • 博客访问: 72768
  • 博文数量: 73
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 675
  • 用 户 组: 普通用户
  • 注册时间: 2013-06-29 09:58
个人简介

兴趣是坚持一件事永不衰竭的动力

文章分类

全部博文(73)

文章存档

2018年(4)

2016年(23)

2015年(43)

2013年(3)

我的朋友

分类: LINUX

2018-11-07 16:27:44

StarterWare linux下裸机实验

1. 下载StarterWare SDK

http://software-dl.ti.com/dsps/dsps_public_sw/am_bu/starterware/latest/index_FDS.html

这里下载需要ti帐号,下载AM335X_StarterWare_02_00_01_01_Setup.bin

2.安装StarterWare SDK

./AM335X_StarterWare_02_00_01_01_Setup.bin 选择默认安装即可,安装完成后,在home目录下

3.编译器gcc version 6.2.1 20161016 (Linaro GCC 6.2-2016.11)

使用ti-processor-sdk-linux-am335x-evm-04.00.00.04自带的gcc

arm-linux-gnueabihf-gcc

4.编译配置

/home/fang/AM335X_StarterWare_02_00_01_01/build/armv7a/gcc/makedef

修改3个地方

LIB_GCC=/home/fang/ti-processor-sdk-linux-am335x-evm-04.00.00.04/linux-devkit/sysroots/x86_64-arago-linux/usr/lib/gcc/arm-linux-gnueabihf/6.2.1

LIB_C=/home/fang/ext-disk/workdir/src/glibc-2.26/install/lib

PREFIX=arm-linux-gnueabihf-

4.编译libc

由于tigcc缺少libc,这里我自行编译了libc-2.26

cd glibc-2.26

make build install

cd build

CC=arm-linux-gnueabihf-gcc ../configure --prefix=/home/fang/ext-disk/workdir/src/glibc-2.26/install --host=arm-linux --cache-file=arm-linux.cache

make install

5.编译uart编译链接地址

cd  ~/AM335X_StarterWare_02_00_01_01/build/armv7a/gcc/am335x/evmAM335x/uart

ls

makefile  uartEcho.lds 

这里修改一下链接地址

修改makefile

IMG_LOAD_ADDR = 0x402f0400

修改uartEcho.ld

DDR0 :   o = 0x402f0400,  l = 0xFBFF  /* 512MB external DDR Bank 0 */

5.编译uart

make

生成的二进制在

 ~/AM335X_StarterWare_02_00_01_01/binary/armv7a/gcc/am335x/evmAM335x/uart/Release

uartEcho_ti.bin就是可以在Sdram中执行的二进制了

6.串口下载uartEcho_ti.bin

等待上电启动,打印CCC时,将uartEcho_ti.bin下载

这时发现并没有像例程说明那样,在终端输入,并没有回显字符

7.加入led调试

led.S文件复制到~/AM335X_StarterWare_02_00_01_01/system_config/armv7a/gcc

修改 ~/AM335X_StarterWare_02_00_01_01/build/armv7a/gcc/am335x/system_config/makefile

SOURCE变量(大约在第56行)

增加led.S编译,如下

SOURCE= ${SYSCONFIG_SRC}/mmu.c                 \

        ${SYSCONFIG_SRC}/cache.c               \

        ${SYSCONFIG_SRC}/${COMPILER}/led.S     \

        ${SYSCONFIG_SRC}/${COMPILER}/cpu.c     \

8.修改~/AM335X_StarterWare_02_00_01_01/system_config/armv7a/gcc /init.S ,在第一条指令前插入点灯指令,如下

Entry:

@

@ Set up the Stack for Undefined mode

@

         BL     led_init

         BL     led_on

         LDR   r0, =_stack                     @ Read the stack address

         MSR   cpsr_c, #MODE_UND|I_F_BIT       @ switch to undef  mode

         MOV   sp,r0                           @ write the stack pointer

         SUB   r0, r0, #UND_STACK_SIZE         @ give stack space

9.再次下载运行,发现灯可以点亮了,可以慢慢调试了
============

led.S源码(GPIO3Pin16

.global led_init

.global led_on

.global led_off

led_init:

@@@@@@FOR CM_PER_GPIO3_CLKCTRL_MODULEMODE_ENABLE

         LDR R1,=0x44E000B4

         LDR R3,[R1] @read CM_PER_GPIO3_CLKCTRL     

         ORR R0,R3,#0x2              @R0=R3 | 0x2

         STR R0,[R1] @write to CM_PER_GPIO3_CLKCTRL

wait1:      

         LDR R0,[R1] @read CM_PER_GPIO3_CLKCTRL     

         TST R0,#0x2

@     BNE wait1

 

@@@@@@FOR CM_PER_GPIO3_CLKCTRL_OPTFCLKEN_GPIO_1_GDBCLK

        

         LDR R1,=0x44E000B4;

         LDR R3,[R1] @read CM_PER_GPIO3_CLKCTRL

         ORR R0,R3,#0x00040000                 @R0=R3 | 0x00040000

         STR R0,[R1] @write to CM_PER_GPIO3_CLKCTRL

wait2:      

         LDR R0,[R1] @read CM_PER_GPIO3_CLKCTRL     

         TST R0,#0x00040000

@     BNE wait2

@@@@@@Waiting for IDLEST field in CM_PER_GPIO3_CLKCTRL register to attain the desired value.

         LDR R1,=0x44E000B4;

wait3:

         LDR R0,[R1] @read CM_PER_GPIO3_CLKCTRL     

         TST R0,#0x00030000

@     BNE wait3

@@@@@ Waiting for CLKACTIVITY_GPIO_1_GDBCLK bit in CM_PER_L4LS_CLKSTCTRL register to attain desired value.

         LDR R1,=0x44E00000;

wait4:      

         LDR R0,[R1] @read CM_PER_L4LS_CLKSTCTRL    

         TST R0,#0x00080000

@     BNE wait4

 

         @@@GPIO3Pin16PinMuxSetup    

        

         ldr r0, =0x481AE134 @GPIO_OE

         ldr r1, =0xfffEffff  @0x00010000 set to output mode

         str r1, [r0]

         mov pc, lr

        

        

led_on:

 

         ldr r0, =0x481AE194 @GPIO_SETDATAOUT

         ldr r1, =0x00010000

         str r1, [r0]

         mov pc, lr

        

 

led_off:

         ldr r0, =0x481AE190 @GPIO_CLEARDATAOUT

         ldr r1, =0x00010000

         str r1, [r0]

         mov pc, lr

 

阅读(56) | 评论(0) | 转发(1) |
0

上一篇:dev: no symbol version for my_bus_type

下一篇:没有了

给主人留下些什么吧!~~
评论热议
请登录后评论。

登录 注册