Top Banner
1 uClinux course uClinux course Day 4 of 5 Day 4 of 5
30
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: uClinux course Day 4 of 5

1

uClinux courseuClinux courseuClinux courseuClinux course

Day 4 of 5Day 4 of 5

Page 2: uClinux course Day 4 of 5

2Author: D L Johnson

CPU ArchitecturesCPU Architectures

Page 3: uClinux course Day 4 of 5

3Author: D L Johnson

The ARM architectureThe ARM architecture

The ARM AT91 architectureThe ARM AT91 architecture

Page 4: uClinux course Day 4 of 5

4Author: D L Johnson

The ARM architectureThe ARM architecture

Incorporates the ARM7TDMI™ ARM® Thumb® Processor Incorporates the ARM7TDMI™ ARM® Thumb® Processor CoreCore

High-performance 32-bit RISC ArchitectureHigh-performance 32-bit RISC Architecture High-density 16-bit Instruction Set using THUMBHigh-density 16-bit Instruction Set using THUMB Leader in MIPS/WattLeader in MIPS/Watt Embedded ICE (In-Circuit Emulation)Embedded ICE (In-Circuit Emulation) On-chip SRAM and/or ROMOn-chip SRAM and/or ROM 32-bit Data Bus32-bit Data Bus Single-clock Cycle AccessSingle-clock Cycle Access Fully Programmable External Bus Interface (EBI)Fully Programmable External Bus Interface (EBI) Maximum External Address Space of 64M BytesMaximum External Address Space of 64M Bytes Up to 8 Chip SelectsUp to 8 Chip Selects Software Programmable 8/16-bit External DatabusSoftware Programmable 8/16-bit External Databus 8-level Priority, Individually Maskable, Vectored Interrupt 8-level Priority, Individually Maskable, Vectored Interrupt

ControllerController

Page 5: uClinux course Day 4 of 5

5Author: D L Johnson

The ARM architectureThe ARM architecture

4 External Interrupts, Including a High-priority Low-4 External Interrupts, Including a High-priority Low-latency Interrupt Requestlatency Interrupt Request

32 Programmable I/O Lines32 Programmable I/O Lines 3-channel 16-bit Timer/Counter3-channel 16-bit Timer/Counter 3 External Clock Inputs3 External Clock Inputs 2 Multi-purpose I/O Pins per Channel2 Multi-purpose I/O Pins per Channel 2 USARTs2 USARTs 2 Dedicated Peripheral Data Controller (PDC) Channels 2 Dedicated Peripheral Data Controller (PDC) Channels

per USARTper USART Programmable Watchdog TimerProgrammable Watchdog Timer Advanced Power-saving FeatureAdvanced Power-saving Feature

Page 6: uClinux course Day 4 of 5

6Author: D L Johnson

ARM board memory layoutARM board memory layout

Memory map of EB40 + expansion boardMemory map of EB40 + expansion board EB40 boardEB40 board

+FLASH memory– (4k) 0x01000000 – 0x01001FFF Bootcode– (60k) 0x01002000 – 0x0100FFFF angel debugger– (64k) 0x01010000 – 0x0101FFFF Application (select with SW1)

+SRAM– (512k) 0x02000000 – 0x0207FFFF RAM space

Expansion board (MEC01)Expansion board (MEC01)+FLASH memory

– (2MB) 0x03000000 – 0x031FFFFF eg. Linux kernel– (1MB) 0x04000000 – 0x040FFFFF eg. romfs

+SRAM– (2MB) 0x05000000 – 0x051FFFFF eg. .data .bss stack

Page 7: uClinux course Day 4 of 5

7Author: D L Johnson

Atmel EB40 board memory layoutAtmel EB40 board memory layout

Page 8: uClinux course Day 4 of 5

8Author: D L Johnson

MEC01 memory expansion board memory layoutMEC01 memory expansion board memory layout

Page 9: uClinux course Day 4 of 5

9Author: D L Johnson

Memory mapping techniquesMemory mapping techniques

16M byte devices16M byte devices

Page 10: uClinux course Day 4 of 5

10Author: D L Johnson

Memory mapping techniquesMemory mapping techniques

1M byte devices1M byte devices

Page 11: uClinux course Day 4 of 5

11Author: D L Johnson

External bus interfaceExternal bus interface

Page 12: uClinux course Day 4 of 5

12Author: D L Johnson

External bus interfaceExternal bus interface

Page 13: uClinux course Day 4 of 5

13Author: D L Johnson

External bus interfaceExternal bus interface

Page 14: uClinux course Day 4 of 5

14Author: D L Johnson

External bus interfaceExternal bus interface

Page 15: uClinux course Day 4 of 5

15Author: D L Johnson

External bus interfaceExternal bus interface

Page 16: uClinux course Day 4 of 5

16Author: D L Johnson

Memory inititalization scriptsMemory inititalization scripts

#!/bin/sh#!/bin/sh

## # board initializaton for ATMEL EB40 + MEC01 expansion board# board initializaton for ATMEL EB40 + MEC01 expansion board ## # ATMEL EB40# ATMEL EB40 ## # FLASH: 0x01000000# FLASH: 0x01000000 64KB64KB Bootcode,AngelBootcode,Angel ## 0x01010000 0x01010000 64KB64KB ApplicationApplication ## 0x01020000 0x01020000

# RAM: # RAM: 0x02000000 0x02000000 512K 512K RAMRAM ## 0x0207FFFF 0x0207FFFF ## ## # ATMEL MEC01# ATMEL MEC01 ## # FLASH0: 0x03000000# FLASH0: 0x03000000 2M2M User FlashUser Flash ## 0x031FFFFF 0x031FFFFF ## # FLASH1: 0x04000000# FLASH1: 0x04000000 1M1M User FlashUser Flash ## 0x040FFFFF 0x040FFFFF ## # SRAM: 0x05000000# SRAM: 0x05000000 2M2M User RAMUser RAM ## 0x051FFFFF 0x051FFFFF ##

Page 17: uClinux course Day 4 of 5

17Author: D L Johnson

Memory inititalization scriptsMemory inititalization scripts

## # board initializaton for ATMEL EB40 + MEC01 expansion board# board initializaton for ATMEL EB40 + MEC01 expansion board

echo "initialize board"echo "initialize board" # EBI_CSR0 (EB40 128k FLash)# EBI_CSR0 (EB40 128k FLash) # 16MB, 2 tdf, 16 bits, 3WS# 16MB, 2 tdf, 16 bits, 3WS ./armtool write 0xffe00000 0x01002529./armtool write 0xffe00000 0x01002529

# EBI_CSR1 (EB40 512k SRAM)# EBI_CSR1 (EB40 512k SRAM) # 16MB, 0hold, 16 bits, 1WS# 16MB, 0hold, 16 bits, 1WS ./armtool write 0xffe00004 0x02002121./armtool write 0xffe00004 0x02002121

# EBI_CSR2 (MEC01 2MB Flash)# EBI_CSR2 (MEC01 2MB Flash) # 16MB, 2 tdf, 16 bits, 3WS# 16MB, 2 tdf, 16 bits, 3WS ./armtool write 0xffe00008 0x030024B5./armtool write 0xffe00008 0x030024B5

# EBI_CSR3 (MEC01 1MB Flash)# EBI_CSR3 (MEC01 1MB Flash) # 1MB, 2 tdf, 16 bits, 3WS# 1MB, 2 tdf, 16 bits, 3WS ./armtool write 0xffe0000c 0x040024B5./armtool write 0xffe0000c 0x040024B5

# EBI_CSR4 (MEC01 2MB SRAM - block1 0x05000000 - 0x050FFFFF)# EBI_CSR4 (MEC01 2MB SRAM - block1 0x05000000 - 0x050FFFFF) # 1MB, 0 hold, 16 bits, 1WS# 1MB, 0 hold, 16 bits, 1WS ./armtool write 0xffe00010 0x05002021./armtool write 0xffe00010 0x05002021

# EBI_CSR5 (MEC01 2MB SRAM - block2 0x05100000 - 0x051FFFFF)# EBI_CSR5 (MEC01 2MB SRAM - block2 0x05100000 - 0x051FFFFF) # 1MB, 0 hold, 16 bits, 1WS# 1MB, 0 hold, 16 bits, 1WS ./armtool write 0xffe00014 0x05102021./armtool write 0xffe00014 0x05102021

Page 18: uClinux course Day 4 of 5

18Author: D L Johnson

Memory inititalization scriptsMemory inititalization scripts

/linux-2.4.x/arch/armnommu/vmlinux-armv.lds.in/linux-2.4.x/arch/armnommu/vmlinux-armv.lds.in /* ld script to make ARM Linux kernel/* ld script to make ARM Linux kernel * taken from the i386 version by Russell King* taken from the i386 version by Russell King * Written by Martin Mares <[email protected]>* Written by Martin Mares <[email protected]> */*/ OUTPUT_ARCH(arm)OUTPUT_ARCH(arm) ENTRY(stext)ENTRY(stext) SECTIONSSECTIONS {{ . = TEXTADDR;. = TEXTADDR; .init : { /* Init code and data */.init : { /* Init code and data */ _stext = .;_stext = .; __init_begin = .;__init_begin = .; *(.text.init)*(.text.init) __proc_info_begin = .;__proc_info_begin = .; *(.proc.info)*(.proc.info) __proc_info_end = .;__proc_info_end = .; __arch_info_begin = .;__arch_info_begin = .; *(.arch.info)*(.arch.info) __arch_info_end = .;__arch_info_end = .; *(.data.init)*(.data.init) . = ALIGN(16);. = ALIGN(16); __setup_start = .;__setup_start = .; *(.setup.init)*(.setup.init) __setup_end = .;__setup_end = .; __initcall_start = .;__initcall_start = .; *(.initcall.init)*(.initcall.init) __initcall_end = .;__initcall_end = .; . = ALIGN(4096);. = ALIGN(4096); __init_end = .;__init_end = .;

Page 19: uClinux course Day 4 of 5

19Author: D L Johnson

External bus interfaceExternal bus interface

. = ALIGN(8192);. = ALIGN(8192);

.data : {.data : { /*/* * first, the init task union, aligned* first, the init task union, aligned * to an 8192 byte boundary.* to an 8192 byte boundary. */*/ *(.init.task)*(.init.task)

/*/* * then the cacheline aligned data* then the cacheline aligned data */*/ . = ALIGN(32);. = ALIGN(32); *(.data.cacheline_aligned)*(.data.cacheline_aligned)

/*/* * and the usual data section* and the usual data section */*/ *(.data)*(.data) CONSTRUCTORSCONSTRUCTORS

Page 20: uClinux course Day 4 of 5

20Author: D L Johnson

Memory mappingMemory mapping

Ways of changing address locationsWays of changing address locations+Objcopy change-section options+Make menuconfig - Kernel settings - System type -

Change RAM settings and FLASH settings

Page 21: uClinux course Day 4 of 5

21Author: D L Johnson

BootloadersBootloaders

Bootloader good for debugging phase of projectBootloader good for debugging phase of project Can choose from multiple startupsCan choose from multiple startups Can do initialisation in kernelCan do initialisation in kernel Penalty - Increases boot timePenalty - Increases boot time

Page 22: uClinux course Day 4 of 5

22Author: D L Johnson

Bootloaders - RedbootBootloaders - Redboot

Boot scripting support Simple command line interface for RedBoot configuration and

management, accessible via serial (terminal) or Ethernet (telnet) Integrated GDB stubs for connection to a host-based debugger via

serial or ethernet. (Ethernet connectivity is limited to local network only)

Attribute Configuration - user control of aspects such as system time and date (if applicable), default Flash image to boot from, default failsafe image, static IP address, etc.

Configurable and extensible, specifically adapted to the target environment

Network bootstrap support including setup and download, via BOOTP, DHCP and TFTP

X/YModem support for image download via serial Power On Self Test

Page 23: uClinux course Day 4 of 5

23Author: D L Johnson

Programming the RAM and FLASHProgramming the RAM and FLASH

Programming and debugging can be done through the Programming and debugging can be done through the JTAG port or the serial portJTAG port or the serial port

Page 24: uClinux course Day 4 of 5

24Author: D L Johnson

Programming the RAM and FLASHProgramming the RAM and FLASH

Programming and debugging through the JTAG port is Programming and debugging through the JTAG port is faster than the serial portfaster than the serial port

Programming and debugging with JTAG on Linux/Unix is Programming and debugging with JTAG on Linux/Unix is done using the arm-elf-gdb softwaredone using the arm-elf-gdb software+ cd /tmp/OCDemon/arm/AtmelAT91+ make+ /usr/local/bin/OcdLibRemote –c arm7 &+ /usr/local/arm/bin/arm-elf-gdb –n test+ (arm-gdb) target remote localhost:8888+ (arm-gdb) load+ (arm-gdb) b main+ (arm-gdb) c

Page 25: uClinux course Day 4 of 5

25Author: D L Johnson

Programming the RAM and FLASHProgramming the RAM and FLASH

OcdLibRemote is a program which translates commands OcdLibRemote is a program which translates commands arriving on port 8888 to jtag commands on the parallel arriving on port 8888 to jtag commands on the parallel portport

In gdb, the command: In gdb, the command: target remote localhost:8888target remote localhost:8888 connects to the local port 8888 which in turn connects to connects to the local port 8888 which in turn connects to the Atmel board through the JTAGthe Atmel board through the JTAG

In gdb: the command In gdb: the command loadload loads the test program into the loads the test program into the memory address specified by the elf file formatmemory address specified by the elf file format

Following this command normal gdb commands which Following this command normal gdb commands which will be covered in a later section can be issued such as will be covered in a later section can be issued such as + (arm-gdb) b main --- set a breakpoint in the main

function+ (arm-gdb) c --- continues execution of the program

Page 26: uClinux course Day 4 of 5

26Author: D L Johnson

Programming the RAM and FLASHProgramming the RAM and FLASH

Serial port programming is done using a programming Serial port programming is done using a programming stub running on the the atmel board called Angelstub running on the the atmel board called Angel

Gdb can connect to this stub using the target command Gdb can connect to this stub using the target command in gdbin gdb

For the same test program do the followingFor the same test program do the following+ cd /tmp/OCDemon/arm/AtmelAT91+ make+ /usr/local/arm/bin/arm-elf-gdb –n+ (arm-gdb) target rdi s=/dev/ttyS0+ (arm-gdb) load test+ (arm-gdb) symbol-file test+ (arm-gdb) b main+ (arm-gdb) c

Page 27: uClinux course Day 4 of 5

27Author: D L Johnson

Programming the RAM and FLASHProgramming the RAM and FLASH

Bootloaders such as redboot often have programming Bootloaders such as redboot often have programming functionality built infunctionality built in

The Atmel board already has redboot in the upper The Atmel board already has redboot in the upper memory of its built in flashmemory of its built in flash

To activate redboot move the SW1 switch to the upper To activate redboot move the SW1 switch to the upper memory position memory position

Run the minicom terminal emulatorRun the minicom terminal emulator+Minicom

Press reset on the Atmel boardPress reset on the Atmel board

Page 28: uClinux course Day 4 of 5

28Author: D L Johnson

Programming the RAM and FLASHProgramming the RAM and FLASH

The following should appear on your screenThe following should appear on your screen

You can now upload programs to memory usingYou can now upload programs to memory using+ Redboot> load –m ymodem –b 0x02040000

You can execute the code by typingYou can execute the code by typing+ Redboot> go 0x02040000

Page 29: uClinux course Day 4 of 5

29Author: D L Johnson

Programming the RAM and FLASHProgramming the RAM and FLASH

On the Atmel EB40 board you can only program the RAM On the Atmel EB40 board you can only program the RAM directly, FLASH is programmed by first moving code to directly, FLASH is programmed by first moving code to RAM and then running an internal program which moves RAM and then running an internal program which moves code from RAM to FLASHcode from RAM to FLASH

The redboot bootloader has commands to do thisThe redboot bootloader has commands to do this+ Redboot> fi wr –f 0x01010000 –b 0x02040000 –l 0xe000

This command will move the block of memory at RAM This command will move the block of memory at RAM location 0x02040000 of length 0xe000 to the flash location location 0x02040000 of length 0xe000 to the flash location 0x010100000x01010000

Page 30: uClinux course Day 4 of 5

30Author: D L Johnson

Assignment 4Assignment 4

Write a program which calculates the solution to ax^2 +bx Write a program which calculates the solution to ax^2 +bx + c = 0 using no output or input screens (enter the values + c = 0 using no output or input screens (enter the values for a,b, and c inside your code)for a,b, and c inside your code)+Hint modify the code in /tmp/OCDemon/arm/AtmelAT91

Create a breakpoint in the debugger to examine your Create a breakpoint in the debugger to examine your resultsresults

Use two different tools to program it into memoryUse two different tools to program it into memory Run it from RAM and FLASHRun it from RAM and FLASH

+Hint: Remember when running from FLASH the .data section needs to be copied to RAM

If this is too easy – then try to run this as an application If this is too easy – then try to run this as an application inside the kernel and include input and outputinside the kernel and include input and output