Step-by-step play pcduino3--mmc under the bare metal running lights

Source: Internet
Author: User

The first part is to play PCDUINO3 under the bare metal, this process allows us to better understand the embedded system, familiar with the platform we use.

First introduce the following development environment:

Virtual machine: Vmware®workstation 10.0.2 build-1744117

System: Linux Slackware 3.2.29-SMP #2 SMP

Cross compiler: arm-linux-gnueabihf-version number: GCC version 4.8.2 20130805 (prerelease) (Crosstool-ng Linaro-1.13.1-4.8-2013.08-linaro GCC 2013.08)

Editor: Vim


The hardware connection is as follows:

USB 5V power cable and USB to TTL line connected to the PCDUINO3, as shown in figure:

Said is running water lamp, in fact, I only use two lights, this board of LED is not many, and no special flow lamp configuration. Let's take a look at the schematic diagram:

I only use the tx_led and rx_led two lights:


We used the TX and RX two lights here, and went back to the schematic to see which two pins to control the two LEDs:


PH15 and PH16 control tx_led and rx_led respectively.


After figuring out the hardware connection, before formally writing the assembly code, we clear the boot sequence of the A20, which, according to its datasheet, supports MMC startup and NAND flash boot, and MMC boot takes precedence over NAND flash boot. A20 's datasheet did not write down the boot hardware details, presumably reckoned out the following steps: Under MMC boot conditions, the hardware automatically moves the data in the MMC card between 8K and 40K to internal SRAM1 and SRAM2:


Now the Uboot supports SPL mode, that is, the first 32k part runs in SRAM, then initializes the DRAM and MMC interfaces, and then moves the subsequent uboot into memory and then loads the kernel operation.

In addition to this, it is important to note that MMC starts with a specific header, and here we use the Mksunxiboot tool inside the Uboot/tools to add the header. This header is defined by a 32-byte structure Boot_file_head, which contains magic and check sum. Then generate a jump code to jump to the real code to execute.

The code is divided into two assembly files: start. S and Led.s. Start. s sets the stack pointer and then jumps to the LED. In the main function in S.

Start. The S code is as follows:

. Text
. Global _start


_start:

	Ldr sp, =0x00007f00

	bl	main

halt_loop:
	b	Halt_loop

Led. S as follows:

. equ	Ph_cfg1, 0x01c20900
equ	ph_cfg3, 0x01c20904

. equ ph_pull0	, 0x01c20918
.	equ Ph_ PULL1, 0x01c2091c

equ	ph_dat, 0x01c2090c


. Global main

main:
	ldr	r0,=ph_cfg1
	LDR 	r1,=0x10000000
	str	r1, [r0]

	ldr	r0,=ph_cfg2
	ldr 	r1,=0x00000001
	str	R1, [r0]

	ldr	r0,=ph_pull0
	ldr	r1,=0x55555555
	str	r1, [r0]

	LDR	r0,= Ph_pull1
	LDR	r1,=0x55555555
	str	r1, [R0]
ledloop:

	ldr	r0,=ph_dat
	LDR	r1,=0x000f0000
	str	r1, [r0]

	bl delay

	ldr	r0,=ph_dat
	ldr	r1,=0x0000f000
	str	R1, [r0]

	bl delay

	b	ledloop

delay:
	ldr	r3,=0xfffff

delay1:
	Sub	r3,r3, #1
	CMP	R3, #0x0
	bne	delay1
	mov 	PC,LR	

The code is simple, after compiling, remember to use the Mksunxiboot tool to process, and finally use the DD command burned to 8 K offset.

Finally you can see two lights flashing a twinkle, and now there is no initialization clock, pay attention to adjust the delay, otherwise the effect is not very correct.






Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.