Embedded Development Path (1) bare-board program led

Source: Internet
Author: User

Development Board: tx2440

Development Environment: ubuntu12.04

 

In Linux, use Vim to compile program code (startup code, main program, and makefile), and perform cross-compilation in Linux to generate binary arm executable files, the shared directory of VMware is transmitted to the Window environment, and is directly run in arm norflash with jflash.

 

Goals: 1) light up a single LED lamp

2) Light up multiple LED lights

3) Test the flux Lamp

 

Experiment experience: 1) learn to write startup code by yourself. Arm's startup code compilation differs from traditional compilation. The startup code mainly initializes the hardware, disables watchdog to prevent repeated CPU startup, sets the stack, and helps the program jump to the main function entry of the main program.

2) makefile writing needs to be enhanced

3) the code of the 32-bit processor is quite different from that of the traditional 8-bit MCU. It should be said that the difficulty of code writing is obviously increased, and more registers need to be controlled. At the same time, this is proportional to the more powerful performance of arm.

 

 

Summary:

1) Startup code reference

  1. . Text
  2. . Global _ start
  3. _ Start:
  4. LDR r0, = 0x56000010
  5. LDR R1, = 0x00155555
  6. STR R1, [R0]
  7. LDR r0, = 0x56000014
  8. MoV R1, #0x0
  9. STR R1, [R0]
  10. Main_loop:
  11. B main_loop

Makefile reference

Led. Bin: LED. c
Arm-Linux-gcc-g-c-o led. O led. c
Arm-Linux-LD-ttext 0x30000000-G led. O-o led. Elf-E Main
Arm-Linux-objcopy-O Binary-s led. Elf led. Bin
. Python: clean
Clean:
RM *. O led. Elf led. Bin

 

 

Main program code:

 

# Define gpbcon (* (volatile unsigned *) 0x56000010)
# Define gpbdat (* (volatile unsigned *) 0x56000014)
# Define gpbup (* (volatile unsigned *) 0x56000018)
# Define mpll100mhz 0x0007f022
# Define clkdiv2 0x02
# Define rmpllcon (* (volatile unsigned *) 0x4c000004)
# Define rclkdivn (* (volatile unsigned *) 0x4c000014)
Int main ()
{
Int I = 0;
Int COUNT = 0;
Int LEDs [4] = {0x1c0, 0x1a0, 0x160, 0xe0 };

Rmpllcon = mpll100mhz;
Rclkdivn = clkdiv2;
Gpbcon = 0x00155555;
Gpbup = gpbup & 0xff00;

While (1)
{
For (COUNT = 0; count! = 4; ++ count)
{
Gpbdat = LEDs [count];
For (I = 0; I <0x30000; I ++ );
}
}
}

 

 

New knowledge point

1) nandflash and norflash:

 

S3C2440

The first command read at startup is

0x00

,

Divided

NAND Flash

And

Nor flash

.

 

Nor flash

Has its own address line and data line,

Similar

Memory

Random Access Method,

In

Nor flash

You can directly run the program,

So

Nor flash

Can be directly used

Boot

,

Use

Nor flash

During startup

Address

Ing

To

0x00

.

Mini2440

Directly

Vivi

Directly burned in

Nor flash

.

 

NAND Flash

Yes

Io

Devices, Data, addresses, and control lines are all shared, and the read sequence needs to be controlled in the software area,

So

Not like

Nor flash

And random access with the same memory.

EIP

(Running on Chip), so it cannot be directly used

Boot

.

 

S3C2440

Set

Boot Loader

Burned

NAND Flash

Start up,

Because

In

S3C2440

There is a built-in

SRAM

,

Called

Stepping Stone

(

Stepping stone, very image

...)

After the system starts power-on

NAND Flash

Start

4 kb

To

SRAM

,

In this way

NAND Flash

Start

.

If

Bootloader

Less

4 kb

Words (like

Vboot

), In

SRAM

You can

Boot

, Greater

4 kb

Words

(

U-boot

,

Vivi

)

, In

SRAM

Do 1

After some basic initialization

Bootloader

To

SDRAM

Li (

> 0x30000000

).

 

// ================================================ ================================================= //

Note:

Bootloader

It is a small program that runs before the operating system kernel runs. Through this small program, I

You can initialize hardware devices,

Create a map of memory space,

So as to bring the system's hardware and software environment to a suitable

Status,

In order to prepare the correct environment for the final call to the operating system kernel.

Generally,

Bootloader

Is heavily dependent on

Hardware, especially in the embedded world.

Therefore, a general

Bootloader

Almost impossible.

However, we can still

 

Boot Loader

To summarize some general concepts

Guides user-specific

 

Bootloader

Design and implementation.

 

// ================================================ ================================================= //

We use

S3C2440

When,

Frequently passed

Nor flash

Start,

Enter

Vivi

Menu

(

S3C2440

Of

Nor flash

Burned

Vivi

)

,

After

Pass

Vivi

Of

USB

Download function,

Put other

Bootloader

Download

NAND Flash

.

NAND Flash

Start and test our

Boot Loader

.

 

 

Nor flash

Suitable for code storage and

EIP

,

NAND Flash

Suitable for storing large amounts of data.

 

Nand

Flash

Start:

Nand

Flash

Before memory

4 K

Will be automatically loaded

Stepping

Stone

(Internal

SRAM

Buffer), and then the system automatically executes the loaded startup code, which

4 K

The startup code

NAND Flash

Copy content

SDRAM

.

NAND Flash

Before

4 K

Space and start code,

SDRAM

Fast,

To execute the code of the main program.

 

// ================================================ ================================================= //

Note:

SDRAM (synchronous dynamic random access memory)

, Synchronization

Dynamic Random storage

Tool

,

Synchronization refers

 

Memory

Clock Synchronization is required for work,

The internal commands and data transmission are based on them;

Dynamic refers

Storage Array

It is necessary to refresh constantly to ensure that data is not lost;

Random is exponential data is not stored in linear order,

While

Allows you to read and write data at a specified address.

Embedded Development Path (1) bare-board program led

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.