Skip to content

2 How to blink led on tiny210 board

limingth edited this page Sep 8, 2012 · 10 revisions

all source code you need in this section can be found here

https://github.com/limingth/ARM-Codes/tree/master/tiny210-linux-codes/1-led-s

How to blink led of tiny210 using SD-boot

Hint: Only 8K binary file with checksum code at the beginning (byte 0xc) can be executed. so we get a tool mktiny210spl.exe from uboot, make the .bin file to size 8K then burn it to SD card.

get mktiny210spl.exe from uboot

mkdir 1-led-s
cd 1-led-s
    -> copy tiny210-u-boot-version2.1.tar.gz in 1-led-s
tar zxf tiny210-u-boot-version2.1.tar.gz 
cp tiny210-u-boot-version2.1/board/samsung/tiny210/tools/mktiny210spl.exe .

write led.s (source code) and Makefile

vi led.s

.global _start
_start:
	ldr r0, =0x1
	ldr r1, =0xe0200280
	str r0, [r1]	

loop:
	ldr r0, =0x0
	ldr r1, =0xe0200284
	str r0, [r1]	
	bl delay

	ldr r0, =0x1
	ldr r1, =0xe0200284
	str r0, [r1]	
	bl delay

	b loop

delay:
	ldr r0, =0x100000
go_on:	
	sub r0, r0, #1
	cmp r0, #0
	bne go_on
	mov pc, lr		

vi Makefile

all:
	arm-linux-as led.s -o led.o
	arm-linux-ld led.o -o led.elf
	arm-linux-objcopy -O binary led.elf led.bin
	arm-linux-objdump -d led.elf > led.lst
	./mktiny210spl.exe led.bin sd-led.bin

make

-> ls -l *.bin
   -rwxr-xr-x 1 limingth limingth   76 2012-05-11 18:21 led.bin
   -rw-r--r-- 1 limingth limingth 8192 2012-05-11 18:21 sd-led.bin

write sd-led.bin to SD-Card

insert sd card 
dmesg | grep sdb
    -> /dev/sdb should be found
sudo dd iflag=dsync oflag=dsync if=sd-led.bin of=/dev/sdb seek=1
    -> 记录了16+0 的读入
       记录了16+0 的写出
       8192字节(8.2 kB)已复制,0.209805 秒,39.0 kB/秒

fdisk SD card to a Win95-FAT32 partition

if you just buy a new SD card, here we do it from the very beginning
sudo fdisk /dev/sdb
Command (m for help): m (help)
Command (m for help): p (print the partition table)
Command (m for help): d (delete the old partition)
Command (m for help): n (add a new partition)
Command action
   e   extended
   p   primary partition (1-4)
p (for primary) -> 
Partition number (1-4): 1
First cylinder (1-121, default 1): 1
Last cylinder, +cylinders or +size{K,M,G} (1-121, default 121):  (Enter)
Using default value 121

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): L

Hex code (type L to list codes): b 
Changed system type of partition 1 to b (W95 FAT32)

Command (m for help): p

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         121      971901    b  W95 FAT32

Command (m for help): w
The partition table has been altered!

Syncing disks.

format FAT32 (This is VERY important for later use! However, it is not a must for led blink)

sudo mkfs.vfat /dev/sdb1

now you can test if SD-boot can blink led1

insert SD card to slot (CON10 of tiny210)
>> switch to SDBOOT of S2
reset and see if it works!
Clone this wiki locally