自己動手做OS, micro kernel develop on Beagleboard-XM(ARMv7) lab1


This is a tutorial on bare-metal [OS] development on the Beagleboard-XM.
I will show you how to implement a Helloworld image in this article.
在這篇文章中,我會介紹如何寫一個Helloworld的image. 

1. From BeagleBoard-xM System Reference Manual, we can get, "A single RS232 port is provided on the BeagleBoard and provides access to the TX and
RX lines of UART3 on the processor."
2. From DM3730 Technical Reference Manual- we can get "THR_REG W UART3 base address is 0x49020000"  -

首先我們可以從BeagleBoard-xM System Reference Manual,查到板上子上的RS-232是接在UART3上,再從DM3730 Technical Reference Manual,得知,UART3的THR_REG的位址是0x49020000.

I've already added  comments in source file, please refer to source code(github) for details.
我把註解加入到檔案中了,請到github下載source。

1.boot.asm
#UART3 THR_REG register address
.equ UART3_THR_REG, 0x49020000
.arm
_start:
ldr r0,=UART3_THR_REG
adr r1,.L0
bl helloworld
.L1:
b .L1
.align 2
.L0: 
.ascii "helloworld\n\0"
2.Helloworld.c
int helloworld(unsigned int *addr,const char *p){
while(*p){
*addr=*p++;
};
return 0;
}
3.linker script
MEMORY
{
ram : ORIGIN = 0x80300000, LENGTH = 0x10000
}
SECTIONS
{
.text : { *(.text*) } > ram
}
4.Makefile
ARMGNU = arm-elf
AOPS = --warn --fatal-warnings
COPS = -Wall -Werror -O2 -nostdlib -nostartfiles -ffreestanding
boot.bin: boot.asm
$(ARMGNU)-gcc -O2 -c helloworld.c
$(ARMGNU)-as boot.asm -o boot.o
$(ARMGNU)-ld -T linker.ld boot.o helloworld.o -o boot.elf
$(ARMGNU)-objcopy boot.elf -O binary boot.bin
clean:
rm *.elf *.o *.bin -f


U-Boot 2014.01-00014-gcc58fc1 (Feb 10 2014 - 16:24:52)

OMAP3630/3730-GP ES1.1, CPU-OPP2, L3-200MHz, Max CPU Clock 1 Ghz
OMAP3 Beagle board + LPDDR/NAND
I2C:   ready
DRAM:  512 MiB
NAND:  0 MiB
MMC:   OMAP SD/MMC: 0
*** Warning - readenv() failed, using default environment

In:    serial
Out:   serial
Err:   serial
Beagle xM Rev A/B
No EEPROM on expansion board
No EEPROM on expansion board
Die ID #692000019ff80000015eeaa10201402e
Net:   usb_ether
Hit any key to stop autoboot:  0
OMAP3 beagleboard.org # fatload mmc 0:1 0x80300000 boot.bin
reading boot.bin
68 bytes read in 4 ms (16.6 KiB/s)
OMAP3 beagleboard.org # go 0x80300000
## Starting application at 0x80300000 ...
helloworld



原始碼下載:
https://github.com/tzuCarlos/v1OS.git



Reference:
李無言, 一步步寫嵌入式操作系統︰ARM編程的方法與實踐,.
http://www.books.com.tw/products/CN10720115
http://stackoverflow.com/questions/6870712/beagleboard-bare-metal-programming
http://wiki.osdev.org/ARM_Beagleboard

留言

這個網誌中的熱門文章

Raspberry Pi (ARMv6)上自幹一個微小作業系統

Linux VLAN 筆記

C語言,大數運算,階層筆記