Step by step play pcduino3 -- bare metal water lamp under mmc

Source: Internet
Author: User

The first part is to play bare metal in pcduino3. This process allows us to better understand embedded systems and be familiar with the platform we use.

First, we will introduce the 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: gcc version 4.8.2 20130805 (prerelool) (crosstool-NG linaro-1.13.1-4.8-2013.08-Linaro GCC 2013.08)

Editor: Vim

The hardware connection is as follows:

Connect the USB 5 V power cord and USB to TTL cable to pcduino3,

 

In fact, I only use two lamps. There are not many LEDs on this board, and there is no special configuration for the lamps. Let's take a look at the schematic diagram:

I only use TX_LED and RX_LED lights:

We use the TX and RX lights here, and return to the schematic diagram to see which two pins are used to control the two LEDs:

PH15 and PH16 control TX_LED and RX_LED respectively.

After figuring out the hardware connection, we should clarify the A20 boot sequence before writing the Assembly Code. According to its datasheet brief introduction, it supports mmc startup and nand flash startup, in addition, mmc takes precedence over nand flash. The datasheet of A20 does not detail the boot hardware details. The approximate steps are as follows, the hardware automatically moves the data in the mmccard between 8 K and 40 K to the internal SRAM1 and SRAM2:

The current uboot supports the spl mode, that is, the part located in the first 32 KB runs in the SRAM first, then initializes the DRAM and MMC interfaces, and then moves the subsequent uboot to the memory for running, then load the kernel.

In addition to this, you must add a specific header to the MMC startup. here we need to add this header to the mksunxiboot tool in uboot/tools. This header is defined by the 32-byte structure boot_file_head, which contains MAGIC and check sum. Then a jump code is generated to jump to the real code for execution.

The code is divided into two assembly files: start. S and led. S. Start. S sets the stack pointer and jumps to the main function in led. S.

The start. S Code is as follows:

 

.text.global _start_start:ldr sp, =0x00007f00blmainhalt_loop:bhalt_loop

Led. S is as follows:

.equPH_CFG1, 0x01C20900.equPH_CFG3, 0x01C20904.equPH_PULL0, 0x01C20918.equPH_PULL1, 0x01C2091C.equPH_DAT, 0x01C2090C.global mainmain:ldrr0,=PH_CFG1ldr r1,=0x10000000strr1, [r0]ldrr0,=PH_CFG2ldr r1,=0x00000001strr1, [r0]ldrr0,=PH_PULL0ldrr1,=0x55555555strr1, [r0]ldrr0,=PH_PULL1ldrr1,=0x55555555strr1, [r0]ledloop:ldrr0,=PH_DATldrr1,=0x000f0000strr1, [r0]bl delayldrr0,=PH_DATldrr1,=0x0000f000strr1, [r0]bl delaybledloopdelay:ldrr3,=0xfffffdelay1:subr3,r3,#1cmpr3,#0x0bnedelay1mov pc,lr
The code is very simple. After compilation, remember to use the mksunxiboot tool for processing. Finally, run the dd command to burn it to the 8 K offset.

At last, we can see that two lights are flashing and the clock has not yet been initialized. Pay attention to adjusting the delay. Otherwise, the effect will not be very good.

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.