ARM. Architecture and Assembly. Modest Goal: Turn on an LED

Similar documents
Let s put together a Manual Processor

MICROPROCESSOR. Exclusive for IACE Students iacehyd.blogspot.in Ph: /422 Page 1

4/2/2014 Linux Dev-Boards. Linux Dev Boards. Tagung Forth Gesellschaft e.v. Maerz file:///home/cas/talk/linux-boards/html/linux-boards.

CPU Organisation and Operation

MACHINE ARCHITECTURE & LANGUAGE

what operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored?

A+ Guide to Managing and Maintaining Your PC, 7e. Chapter 1 Introducing Hardware

Chapter 6. Inside the System Unit. What You Will Learn... Computers Are Your Future. What You Will Learn... Describing Hardware Performance

PowerPC 405 GP Overview

612 CHAPTER 11 PROCESSOR FAMILIES (Corrisponde al cap Famiglie di processori) PROBLEMS

Applications Development on the ARM Cortex -M0+ Free On-line Development Tools Presented by William Antunes

AN4128 Application note

Application Note: AN00141 xcore-xa - Application Development

ARM Microprocessor and ARM-Based Microcontrollers

An Introduction to Computer Science and Computer Organization Comp 150 Fall 2008

BEAGLEBONE BLACK ARCHITECTURE MADELEINE DAIGNEAU MICHELLE ADVENA

Processor Architectures

Microprocessor & Assembly Language

MICROPROCESSOR AND MICROCOMPUTER BASICS

Chapter 1 Hardware and Software Introductions of pcduino

Basic Computer Organization

l C-Programming l A real computer language l Data Representation l Everything goes down to bits and bytes l Machine representation Language

Machine Architecture and Number Systems. Major Computer Components. Schematic Diagram of a Computer. The CPU. The Bus. Main Memory.

UNIVERSITY OF CALIFORNIA, DAVIS Department of Electrical and Computer Engineering. EEC180B Lab 7: MISP Processor Design Spring 1995

Module 2. Embedded Processors and Memory. Version 2 EE IIT, Kharagpur 1

Computer organization

Building a computer. Electronic Numerical Integrator and Computer (ENIAC)

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine

Linux boot loader and boot in Raspberry Pi

Computer Architectures

A-307. Mobile Data Terminal. Android OS Platform Datasheet

Chapter 2 Topics. 2.1 Classification of Computers & Instructions 2.2 Classes of Instruction Sets 2.3 Informal Description of Simple RISC Computer, SRC

Learning Outcomes. Simple CPU Operation and Buses. Composition of a CPU. A simple CPU design

Computer System: User s View. Computer System Components: High Level View. Input. Output. Computer. Computer System: Motherboard Level

CSCA0102 IT & Business Applications. Foundation in Business Information Technology School of Engineering & Computing Sciences FTMS College Global

Banana Pi Open-Source Router Board

Industry First X86-based Single Board Computer JaguarBoard Released

An Overview of Stack Architecture and the PSC 1000 Microprocessor

Writing Assignment #2 due Today (5:00pm) - Post on your CSC101 webpage - Ask if you have questions! Lab #2 Today. Quiz #1 Tomorrow (Lectures 1-7)

Instruction Set Architecture. or How to talk to computers if you aren t in Star Trek

CSE 141L Computer Architecture Lab Fall Lecture 2

ARM Thumb Microcontrollers. Application Note. Software ISO 7816 I/O Line Implementation. Features. Introduction

Administrative Issues

Exam 1 Review Questions

Soft processors for microcontroller programming education

İSTANBUL AYDIN UNIVERSITY

Introduction. What is an Operating System?

LIVE STREAMING MOTION DETECTION CAMERA SECURITY SYSTEM WITH NOTIFICATION USING RASPBERRY PI Angela Antony 1, Prof. G. R.

UMBC. ISA is the oldest of all these and today s computers still have a ISA bus interface. in form of an ISA slot (connection) on the main board.

A-317. Mobile Data Terminal. Android Platform Datasheet

Technical Note. Micron NAND Flash Controller via Xilinx Spartan -3 FPGA. Overview. TN-29-06: NAND Flash Controller on Spartan-3 Overview

Computer Organization and Components

Develop a Dallas 1-Wire Master Using the Z8F1680 Series of MCUs

CPU Organization and Assembly Language

(Refer Slide Time: 00:01:16 min)

PART B QUESTIONS AND ANSWERS UNIT I

CHAPTER 4 MARIE: An Introduction to a Simple Computer

Advanced Computer Architecture-CS501. Computer Systems Design and Architecture 2.1, 2.2, 3.2

HARDWARE MANUAL. BrightSign HD120, HD220, HD1020. BrightSign, LLC Lark Ave., Suite 200 Los Gatos, CA

Product Brief. 2.0 microtoled. Intelligent GOLDELOX Display Module. µtoled-20-g2. Rev 1.0

Computer Organization. and Instruction Execution. August 22

Matrix 510/520 User Guide

Primary Memory. Input Units CPU (Central Processing Unit)

Logical Operations. Control Unit. Contents. Arithmetic Operations. Objectives. The Central Processing Unit: Arithmetic / Logic Unit.

A-level COMPUTER SCIENCE

AUTOMATIC NIGHT LAMP WITH MORNING ALARM USING MICROPROCESSOR

Here is a diagram of a simple computer system: (this diagram will be the one needed for exams) CPU. cache

Homework # 2. Solutions. 4.1 What are the differences among sequential access, direct access, and random access?

Byte Ordering of Multibyte Data Items

Phone: Fax: Web: info@ctiautomation.net

Computer Architecture Lecture 2: Instruction Set Principles (Appendix A) Chih Wei Liu 劉 志 尉 National Chiao Tung University

HARDWARE MANUAL HD222, HD1022. BrightSign, LLC Lark Ave., Suite B Los Gatos, CA

Chapter 4 System Unit Components. Discovering Computers Your Interactive Guide to the Digital World

SMARTCARD XPRO. Preface. SMART ARM-based Microcontrollers USER GUIDE

Raspberry-Pi VGA Fen Logic Ltd. 8 September 2014 G.J. van Loo

CS101 Lecture 26: Low Level Programming. John Magee 30 July 2013 Some material copyright Jones and Bartlett. Overview/Questions

Traditional IBM Mainframe Operating Principles

Lecture 2: Computer Hardware and Ports.

8-Bit Flash Microcontroller for Smart Cards. AT89SCXXXXA Summary. Features. Description. Complete datasheet available under NDA

Central Processing Unit (CPU)

Chapter 3: Computer Hardware Components: CPU, Memory, and I/O

PROBLEMS #20,R0,R1 #$3A,R2,R4

Data Cables. Schmitt TTL LABORATORY ELECTRONICS II

Internet Of things. Petr Ulvr, Business Development Manager Intel Corp. CEE New Biz Virtual Team

Going Linux on Massive Multicore

Block diagram of typical laptop/desktop

Discovering Computers Living in a Digital World

Programming PIC Microcontrollers in PicBasic Pro Lesson 1 Cornerstone Electronics Technology and Robotics II

M68EVB908QL4 Development Board for Motorola MC68HC908QL4

1 Mi kołaj Z Mik ar ołaj Z zyc arzy ki cki

Lecture N -1- PHYS Microcontrollers

INTRODUCTION TO SERIAL ARM

(Refer Slide Time: 02:39)

Software based Finite State Machine (FSM) with general purpose processors

Adafruit's Raspberry Pi Lesson 5. Using a Console Cable

An Introduction to MPLAB Integrated Development Environment

Quick Start Guide. The Raspberry Pi Single Board Computer. Source: Raspberry Pi & Wiki

Efficient Low-Level Software Development for the i.mx Platform

1 Classical Universal Computer 3

Transcription:

ARM Architecture and Assembly Modest Goal: Turn on an LED

Package on Package Broadcom 2865 ARM Processor Samsung 2Gb SDRAM

(John) von Neumann Architecture Instructions and data stored in the same memory Processor ADDR RW DATA Inst Data

Memory used to store information 100000000 16 Stores both instructions and data Storage locations are named using 32-bit addresses Memory Map Address refers to a byte (8-bits) Maximum memory 4 GB Actual memory is 256 MB 010000000 16 256 MB

ARM 32-bit Architecture Processor designed around 32-bit words Registers are 32-bits Arithmetic-Logic Unit (ALU) works on 32-bits Addresses are 32-bits Instructions are fixed size - 32-bits The fact that everything is 32-bits simplifies things quite a bit!

ARM Architecture Memory ADDR + Registers r15 r14 r13 r12 r11 r10 r9 r8 r7 r6 r5 r4 r3 r2 r1 r0 ALU INST DATA DATA ADDR

Memory pc=r15 Registers INST pc=pc+4 ADDR + DATA ALU DATA Instruction fetch ADDR

ra = rb OP rc Memory Registers INST ADDR + rc DATA rb ALU DATA ra ADDR

Instructions Meaning (C) r0 = r1 + 1 Assembly language add r0, r1, #1 Machine language E2 81 00 01

// Single instruction program add r0, r1, #1 // #n is an immediate

# Assemble and generate listing % arm-none-eabi-as add.s -o add.o -a # Create binary % arm-none-eabi-objdump add.o -O binary add.bin # Size % ls -l add.bin -rw-r--r--+ 1 hanrahan staff 4 add.bin # Dump binary % xxd -g 1 add.bin 0000000: 01 00 81 e2 // little-endian

ADDR+3 ADDR+2 ADDR+1 ADDR E2 81 00 01 E2 81 00 01 01 00 81 E2 little-endian (lowest byte first) big-endian (highest byte first)

The 'little-endian' and 'big-endian' terminology which is used to denote the two approaches [to addressing memory] is derived from Swift's Gulliver s Travels. The inhabitants of Lilliput, who are well known for being rather small are, in addition, constrained by law to break their eggs only at the little end. When this law is imposed, those of their fellow citizens who prefer to break their eggs at the big end take exception to the new rule and civil war breaks out. The big-endians eventually take refuge on a nearby island, which is the kingdom of Blefuscu. The civil war results in many casualties. Read: Holy Wars and a Plea For Peace, D. Cohen

Cross-Development Run tools on your personal computer Tools prefixed with arm-none-eabi- Tools generate binary for raspberry pi

Loads and Stores

Load r0 from mem[r1] Memory Registers INST + DATA ADDR r1 ALU DATA ldr r0, [r1] ADDR

Load r0 from mem[r1] Memory Registers INST + DATA ADDR ALU DATA r0 ldr r0, [r1] ADDR

Store r0 to mem[r1] Memory Registers INST + DATA ADDR r1 ALU DATA str r0, [r1] ADDR

Store r0 to mem[r1] Memory Registers INST ADDR + r0 DATA ALU DATA str r0, [r1] ADDR

Conceptual Exercises 1. Suppose you have 0x8000 stored in r0, how could you jump and start executing instructions at that location? 2. All instructions are 32-bits. Can you add any 32-bit immediate constant to a register using the add instruction? 3. What instruction do you think takes longer to execute, str or add?

Turning on an LED

Powering The USB port on my Macbook Pro provides 500 ma @ 5V Power can be provided through the GPIO header How much power does the Pi need?

General-Purpose Input/Output (GPIO)

Power 5 in a column are connected not connected across center divide Ground

Logic 1 -> 3.3V (Vcc) Logic 0 -> 0.0V (GND) 3.3V 1k GND From the datasheet: A maximum of 16mA per pin with the total current from all pins not exceeding 51mA.

Controlling GPIO Pins

Memory Map 100000000 16 4 GB Peripheral Registers 020000000 16 010000000 16 Ref: BCM2835-ARM-Peripherals.pdf

Notes 1. 0x 7E00 0000 -> 0x 2000 0000 2. 54 GPIO pins 3. 3-bits per GPIO pin 4. => 6 GPIO function select registers Ref: BCM2835-ARM-Peripherals.pdf

GPIO Function Select Register 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 GPIO 9 GPIO 8 GPIO 7 GPIO 6 GPIO 5 GPIO 4 GPIO 3 GPIO 2 GPIO 1 GPIO 0

// Turn on an LED via GPIO 20 // FSEL2 controls pins 20-29 // load r0 with GPIO FSEL2 address ldr r0, =0x20200008 // GPIO 20 function select is bits 0-2 // load r1 with 1 (OUTPUT) mov r1, #1 // store the value in r1 // to the address in r0 str r1, [r0]

20 20 00 1C : GPIO SET0 Register 20 20 00 20 : GPIO SET1 Register 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32

// load r0 with GPIO SET0 register addr ldr r0, =0x2020001C // set bit 20 in r1 mov r1, #0x100000 // 0x100000 = 1 << 20 // store bit in GPIO SET0 register str r1, [r0]

// load r0 with GPIO SET0 register addr ldr r0, =0x2020001C // set bit 20 in r1 mov r1, #(1<<20) // store bit in GPIO SET0 register str r1, [r0]

// load r0 with GPIO SET0 register addr ldr r0, =0x2020001c // set bit 20 in r1 mov r1, #(1<<20) // store bit in GPIO SET0 register str r1, [r0] // loop forever using a branch b.

# What to do on your laptop # Assemble % arm-none-eabi-as on.s -o on.o # Create binary % arm-none-eabi-objcopy on.o -O binary on.bin # Copy to SD card % cp on.bin /Volumes/BARE/kernel.img

# What to do on your laptop # Insert SD card - Volume mounts % ls /Volumes/ BARE Macintosh HD MobileBackups # Copy to SD card % cp on.bin /Volumes/BARE/kernel.img # Eject and remove SD card

# # Insert SD card into SDHC slot on pi # # Apply power using usb console cable # PWR LED - 3.3V present # ACT LED - SD card access # # Raspberry pi boots # # LED connected to GPIO20 turns on!! #

Booting on Power On 1. Run hardware boot sequence 1. Initializes the processor and memory 2. Reads files from SDHC card 2. GPU runs bootcode.bin 3. GPU runs start.elf 4. GPU loads kernel.img at 0x8000 5. ARM processor jumps to 0x8000

Memory-Mapped IO (MMIO) Peripherals which control input and output devices are controlled by special peripheral registers. These registers are mapped into the address space of the processor. These registers may not behave as memory. Memory stores values. If you write a value, then read it, you get the value you wrote. Writing a 1 into a SET registers sets the output; writing a 0 into a SET register does not effect the output value. Reading the SET register always returns 0

Details Omitted

Definitive References ARMv6 architecture reference manual BCM2865 peripherals document + errata Raspberry pi schematic