BeagleBoard的裸机编程 [英] Beagleboard bare metal programming

查看:157
本文介绍了BeagleBoard的裸机编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚得到了我的BeagleBoard-XM,我不知道是否有关于如何得到的硬件上运行一个非常简单的裸机软件吗?任何详细的步骤指南

I just got my BeagleBoard-Xm and I'm wondering if there is any detailed step by step tutorials on how to get a very simple bare metal software running on the hardware?

我想问的原因是我想深入了解硬件体系结构是如何工作的,从引导程序的一切,连接器,中断,异常,MMU等我想出最好的办法是让一个简单的Hello World程序的执行XM的BeagleBoard无需操作系统。没有先进的,刚刚启动的董事会,并获得在屏幕上的Hello World的输出。而已!

The reason I ask is I want to deeply understand how the hardware architecture works, everything from the bootloader, linkers, interrupts, exceptions, MMU etc. I figured the best way is to get a simple hello world program to execute on the beagleboard xm without an OS. Nothing advanced, just start up the board and get a "hello world" output on the screen. thats it!

下一步会得到一个很小的操作系统来运行,也可以安排一些很简单的任务。没有文件系统的需要,只是为了了解操作系统的基础知识。

The next step would be getting an tiny OS to run, that can schedule some very simple tasks. No filesystem needed, just to understand the basics of the OS.

任何帮助AP preciated!

Any help appreciated!

此致

Gigu先生

推荐答案

绝对没问题...

首先获得串口和运行,我有旧/较早beagleboards之一,记得串行端口和几乎对I / O是痛苦的一切,但得到它的串行端口,所以你可以看到它启动。

First off get the serial port up and running, I have one of the older/earlier beagleboards and remember the serial port and just about everything about the I/O being painful, nevertheless get a serial port on it so you can see it boot.

它的启动uboot的,我认为,你可以preSS一个键或Esc键或类似的东西中断正常启动(进入Linux)。从uboot的提示很容易加载您的第一个简单的程序。

It boots uboot I think and you can press a key or esc or something like that to interrupt the normal boot (into linux). From the uboot prompt it is easy to load your first simple programs.

我有一些的BeagleBoard code此刻方便,但不要有我的BeagleBoard本身得心应手尝试​​。所以去 http://sam7stuff.blogspot.com/ 得到的想法如何搭配一些启动汇编语言和C code表示OSless嵌入式程序(手臂,我有很多的例子在那里为其他拇指/ Cortex-M3的平台,但是这些引导方式略有不同)。

I have some beagleboard code handy at the moment but dont have my beagleboard itself handy to try them. So go to http://sam7stuff.blogspot.com/ to get an idea of how to mix some startup assembler and C code for OSless embedded programs (for arm, I have a number of examples out there for other thumb/cortex-m3 platforms, but those boot a little differently).

有关的事物和内存地址空间的SAM7港口距离的BeagleBoard / OMAP完全不同。以上是可以更改或重新发明了一个框架。

The sam7 ports for things and memory address space is totally different from the beagleboard/omap. The above is a framework that you can change or re-invent.

您将需要ti.com的OMAP 35X工艺的技术参考手册。搜索在其网站上的OMAP3530 OMAP一部分。

You will need the OMAP 35x techincal reference manual from ti.com. Search for the omap part on their site OMAP3530.

另外,BeagleBoard的文档。例如以下语句:

Also the beagleboard documentation. For example this statement:

设置在BeagleBoard的一个单一的RS232端口,并提供到TX和访问
UART3的RX线

A single RS232 port is provided on the BeagleBoard and provides access to the TX and RX lines of UART3

所以在TRM的OMAP搜索UART3表明,它是在0x49020000一个基本地址。 (通常是非常困难的,以计算出整个地址的东西作为手册通常具有存储器映射的一部分在这里,而另一部分在那里,并且邻近的寄存器说明只有地址的低数位被称为出)。

So in the trm for the omap searching for UART3 shows that it is at a base address of 0x49020000. (often it is very difficult to figure out the entire address for something as the manuals usually have part of the memory map here, and another part there, and near the register descriptions only the lower few bits of the address are called out.)

纵观UART寄存器THR_REG是你写发送出的UART字节,请注意,这是一个16位的寄存器。

Looking at the uart registers THR_REG is where you write bytes to be sent out the uart, note that it is a 16 bit register.

知道了这一点,我们可以做的第一个程序:

Knowing this we can make the first program:

.globl _start
_start:
    ldr r0,=0x49020000
    mov r1,#0x55
    strh r1,[r0]
    strh r1,[r0]
    strh r1,[r0]
    strh r1,[r0]
    strh r1,[r0]
hang: b hang

下面是一个makefile吧:

Here is a makefile for it:

ARMGNU = arm-none-linux-gnueabi

AOPS = --warn --fatal-warnings
COPS = -Wall -Werror -O2 -nostdlib -nostartfiles -ffreestanding 

uarttest.bin : uarttest.s
    $(ARMGNU)-as $(AOPS) uarttest.s -o uarttest.o
    $(ARMGNU)-ld -T rammap uarttest.o -o uarttest.elf
    $(ARMGNU)-objdump -D uarttest.elf > uarttest.list
    $(ARMGNU)-objcopy uarttest.elf -O srec uarttest.srec
    $(ARMGNU)-objcopy uarttest.elf -O binary uarttest.bin

和链接脚本用于:

/* rammap */
MEMORY
{
    ram : ORIGIN = 0x80300000, LENGTH = 0x10000
}

SECTIONS
{
    .text : { *(.text*) } > ram
}

请注意从codesourcery Linux的版本叫出来,你并不需要该版本在GNU交叉编译器,实际上这code是ASM只需要一个汇编器和连接器(binutils的东西)。臂无 - EABI -...型交叉编译器会工作,以及(假设你从codesourcery的是精简版工具)。

Note the linux version from codesourcery is called out, you do not need that version of a gnu cross compiler, in fact this code being asm only needs an assembler and linker (binutils stuff). The arm-none-eabi-... type cross compiler will work as well (assuming you get the lite tools from codesourcery).

一旦你有一个.bin文件看看上uboot的帮助下,我不记得确切的命令,但它可能是一个l 0x80300000或load_xmodem或一些这样的事情。基本上你想x或Y或Z调制解调器通过串口.bin文件到内存空间处理器,然后使用去或任何命令告诉uboot的跳转到你的程序。

Once you have a .bin file look at the help on uboot, I dont remember the exact command but it is probably an l 0x80300000 or load_xmodem or some such thing. Basically you want to x, or y or z modem the .bin file over the serial port into memory space for the processor, then using a go or whatever the command is tell uboot to branch to your program.

您应该看到的字符ü一把(是将0x55'U')出来串口运行时。

You should see a handful of U characters (0x55 is 'U') come out the serial port when run.

您的主要目标前面是得到一个简单的串行端口常规,以便您可以打印出东西来调试并以其他方式看到你的程序在做什么。稍后,您可以进入图形等,但首先使用串行端口。

Your main goal up front is to get a simple serial port routine up so you can print stuff out to debug and otherwise see what your programs are doing. Later you can get into graphics, etc. but first use the serial port.

有一些作弊的事情。由于uboot的走过来初始化串口,我们没有必须,只是推字节到THR。但很快你就会溢出THR的存储和输字节,那么你需要阅读的OMAP的TRM并找到某种位,表明发送器是空的,它传递的一切,然后创建一个uart_send类型的函数,轮询发送器空然后发送一个字节的。

There was some cheating going on. Since uboot came up and initialized the serial port we didnt have to, just shove bytes into the thr. but quickly you will overflow the thr's storage and lose bytes, so you then need to read the trm for the omap and find some sort of bit that indicates the transmitter is empty, it has transmitted everything, then create a uart_send type function that polls for transmitter empty then sends the one byte out.

也忘了printf()的,您需要创建自己的打印的数字(八进制或十六进制是最容易),也许打印字符串。我做这样的工作了一整天,整夜的99%的时间都我用的是一个小程序,它打印32位十六进制数出UART。从这些数字,我可以调试,看看程序的状态。

also forget about printf(), you need to create your own print a number (octal or hex are the easiest) and perhaps print string. I do this sort of work all day and all night and 99% of the time all I use is a small routine that prints 32 bit hex numbers out the uart. from the numbers I can debug and see the status of the programs.

因此​​,采取的SAM7模型或类似的东西(注意编译器和链接器命令行选项也很重要的是链接命令行上的文件的顺序,第一个文件必须是你的入口点,如果你想拥有在.bin文件第一条指令/字是你的切入点,如在路上你想知道如何控制这从一个ROM启动),这通常是一个不错的主意。

So take the sam7 model or something like it (note the compiler and linker command line options are important as is the order of files on the link command line, the first file has to be your entry point if you want to have the first instruction/word in the .bin file be your entry point, which is usually a good idea as down the road you want to know how to control this for booting from a rom).

您也许可以做相当多的位,但不拆除或更换的uboot,如果你开始看的uboot的基于Linux的启动命令,你会看到它正在复制什么是pretty太大的闪光灯或.bin文件到某处RAM中的位置,然后转移到它。现在转移到Linux上,ESP ARM Linux上的涉及到一些手臂表,并有可能建立一些寄存器,在你的程序不会想要或需要的。基本上任何命令你找出使用,已复制你的程序RAM中之后,是你将在一个启动脚本脚本uboot的你应该选择什么样的有板引导和运行像它与Linux一样。

You can probably do quite a bit without removing or replacing uboot, if you start to look at the linux based boot commands for uboot you will see that it is copying what is pretty much a .bin file from flash or somewhere into a spot in ram, then branching to it. Now branching to linux, esp arm linux involves some arm tables and possible setting up some registers, where your programs wont want or need that. basically whatever command you figure out to use, after you have copied your program to ram, is what you will script in a boot script for uboot should you choose to have the board boot and run like it does with linux.

说,你可以使用JTAG和不依赖于uboot的工作,当你虽然有可能的事情一定数目,你必须做引导,以获得芯片和运行走这条道路,特别是配置UART可能是几个时钟分频器的地方,时钟使能,I / O实现,各种类的东西。这就是为什么SAM7例如使用使LED闪烁的东西,而不是一个UART的事情开始。该amotek JTAG纤巧是一个很好的JTAG摇摆,长期的工作,每天我已经相当满意,使用这些整天。该BeagleBoard的大概使用了TI引脚,而不是标准的ARM引脚,所以你可能需要改变布线。我不知道是否该OMAP为您提供了手臂TAP控制器的直接访问,如果你要做的TI一些具体的事情。你是关闭只是去了uboot的路线暂时越好。

Saying that you can use jtag and not rely on uboot to work, when you go that path though there are likely a certain number of things you have to do on boot to get the chip up and running, in particular configuring the uart is likely a few clock dividers somewhere, clock enables, I/O enables, various things like that. Which is why the sam7 example starts with a blink the led thing instead of a uart thing. The amotek jtag-tiny is a good jtag wiggler, I have been quite pleased, use these all day long every day at work. The beagleboard probably uses a TI pinout and not the standard ARM pinout so you will likely need to change the cabling. And I dont know if the OMAP gives you direct access to the arm tap controller or if you have to do something ti specific. You are better off just going the uboot route for the time being.

一旦你有了一个框架,你有ASM少量设置堆栈并跳转到您的入口点C code,你就可以开始把将c code到OS或做任何你想做。如果你看看chibios或preX或其他类似的,你会发现他们有小ASM启动code,获取他们进入他们的系统。同样,也有在那里UART调试和非​​调试程序。许多实时操作系统会想使用中断而不是轮询THR是空的。

Once you have a framework where you have a small amount of asm to setup the stack and branch to your entrypoint C code, you can start to turn that C code into an OS or do whatever you want. If you look at chibios or prex or others like it you will find they have small asm boot code that gets them into their system. Likewise there are uart debug and non-debug routines in there. Many rtoses are going to want to use interrupts and not poll for thr to be empty.

如果这个职位犯规让你和你的hello world运行(让你做一些工作),让我知道,我会挖掘出我的BeagleBoard,并创建一个完整的例子。我的主板犯规完全匹配你的,但尽可能的hello world的推移它应该是足够接近。

If this post doesnt get you up and running with your hello world (letting you do some of the work), let me know and i will dig out my beagleboard and create a complete example. My board doesnt exactly match yours but as far as hello world goes it should be close enough.

这篇关于BeagleBoard的裸机编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆