ELC Multi Processor FPGA Linux Chris Martin 0316 PDF
ELC Multi Processor FPGA Linux Chris Martin 0316 PDF
Agenda
Introduction
Problem: How to Integrate Multi-Processor Subsystems
Why
Why would you do this?
Why use FPGAs?
Lab 1: Getting Started - Booting Linux and Boot-strapping NIOS
Building Hardware: FPGA Hardware Tools & Build Flow
Break (10 minutes)
Lab 2: Inter-Processor Communication and Shared Peripherals
Building/Debugging NIOS Software: Software Tools & Build Flow
Lab 3: Locking and Tetris
Building/Debugging ARM Software: Software Tools & Build Flow
References
Q&A All through out.
Periph 1
Periph 1
Processor
Subsystem
1
Periph 2
Periph 3
Processor
Subsystem
2
Periph 2
Periph 3
Real-time Considerations
Sequencers, State-machines
Experimentation
Allows you to experiment changing
microprocessor subsystem
hardware designs
Altera FPGA under-the-hood
Mailbox
NIOS
N
Peripheral
Design Starts
100,000
80,000
50%
60,000
40,000
20,000
More than 50% of FPGA designs include an embedded processor, and growing.
Many embedded designs using Linux
Open-source re-use.
Lab focus
UART
DDR3
LEDs
Buttons
ARM-to-FPGA
Bridges
Data Width
configurable
A9
I$
A9
D$
I$
D$
L2
EMIF
DMA
ROM
UART
RAM
SD/MMC
FPGA
42K Logic
Macros
Using no more
than 14%
AXI Bridge
AXI Bridge
HPS2FPGA
LWHPS2FPGA
32/64/128
32
AXI Bridge
FPGA2HPS
32/64/128
SYS ID
RAM
FPGA Fabric
Soft Logic
8
GPIO
32
NIOS
Subsystem 1
SD/MMC
EMIF
Cortex-A9
UART
ARM Subsystem
RAM
NIOS 0
GPIO
Subsystem 2
Shared Peripherals
10
Dedicated Peripherals
NIOS
11
ARM Cortex-A9
Address Base
Peripheral
Address Base
Peripheral
0xFFC0_2000
ARM UART
0xFFC0_2000
UART
0x0003_0000
GPIO (LEDs)
0xC003_0000
GPIO (LEDs)
0x0002_0000
System ID
0xC002_0000
System ID
0x0000_0000
On-chip RAM
0xC000_0000
On-chip RAM
12
Peripheral Address
Offset
Access
Bit Definitions
Sys ID
0x0
RO
GPIO
0x0
R/W
UART
0x14
RO
UART
0x30
R/W
UART
0x34
R/W
NIOS resets
connected to GPIO
13
14
15
Building Hardware:
Qsys (Hardware System Design Tool) User Interface
Interfaces Exported
In/out of system
Connections between
cores
16
Quartus
Eclipse
DS-5 & Debug Tools
Device Tree
RBF
Inputs:
Hardware Design (Qsys or RTL or Both)
SDCARD Layout
Partition 1: FAT
Uboot scripts
FPGA HW Designs (RBF)
Device Tree Blobs
zImage
Lab material
18
Updating SD Cards
File
Update Procedure
zImage
soc_system.rbf
soc_system.dtb
u-boot.scr
preloader-mkpimage.bin
$ sudo dd if=preloader-mkpimage.bin
of=/dev/sdx3 bs=64k seek=0
u-boot-socfpga_cyclone5.img
$ sudo dd if=u-boot-socfpga_cyclone5.img
of=/dev/sdx3 bs=64k seek=4
root filesystem
19
Lab 2: Mailboxes
NIOS/ARM Communication
Topics Covered:
Altera Mailbox Hardware IP
20
Subsystem 1
SD/MMC
EMIF
Cortex-A9
UART
GPIO
ARM Subsystem
MBox
RAM
RAM
NIOS 0
NIOS 1
GPIO
GPIO
Subsystem 2
Shared Peripherals
21
MBox
Subsystem 3
Dedicated Peripherals
NIOS 0 & 1
22
ARM Cortex-A9
Address Base
Peripheral
Address Base
Peripheral
0xFFC0_2000
ARM UART
0xFFC0_2000
UART
0x0007_8000
0x0007_8000
0x0007_0000
0x0007_0000
0x0005_0000
0x0006_8000
0x0003_0000
0x0006_0000
0x0002_0000
System ID
0xC003_0000
GPIO (LEDs)
0x0000_0000
On-chip RAM
0xC002_0000
System ID
0xC001_0000
NIOS 1 RAM
0xC000_0000
NIOS 0 RAM
Peripheral Address
Offset
Access
Bit Definitions
Mailbox
0x0
R/W
Mailbox
0x8
R/W
23
Partitioning peripherals
24
Design Decisions:
Short Length: A single 32-bit word
Human Readable
Message transactions are closed-
Format:
Message Length: Four Bytes
First Byte is ASCII character
Byte 0
\0
\0
Message Types:
G00: Give Access to UART
(Push)
A00: ACK
N00:NACK
A00
N00
NIOS 0
26
27
28
29
Subsystem 1
SD/MMC
EMIF
Cortex-A9
UART
GPIO
ARM Subsystem
MBox
RAM
RAM
NIOS 0
NIOS 1
GPIO
GPIO
Subsystem 2
Shared Peripherals
30
MBox
Subsystem 3
Dedicated Peripherals
NIOS 0 & 1
31
ARM Cortex-A9
Address Base
Peripheral
Address Base
Peripheral
0xFFC0_2000
ARM UART
0xFFC0_2000
UART
0x0007_8000
0x0007_8000
0x0007_0000
0x0007_0000
0x0005_0000
0x0006_8000
0x0003_0000
0x0006_0000
0x0002_0000
System ID
0xC003_0000
GPIO (LEDs)
0x0000_0000
On-chip RAM
0xC002_0000
System ID
0xC001_0000
NIOS 1 RAM
0xC000_0000
NIOS 0 RAM
Available in Linux
32
B00
NIOS 0
A00
L00
A00
B10
NIOS 1
A10
Send ACK
L10
A10
Cortex-A9
pthread_mutex_lock()
pthread_mutex_unlock()
/* Create 2 Threads */
i=0;
while(i < 1)
{
err = pthread_create(&(tid[i]), NULL,
&nios_buttons_get, &(nios_num[i]));
i++;
}
<snip Critical Section>
pthread_mutex_lock(&lock);
/* Critical Section */
pthread_mutex_unlock(&lock);
<snip Stop/Destroy>
/* Wait for threads to complete */
pthread_join(tid[0], NULL);
pthread_join(tid[1], NULL);
/* Destroy/remove lock */
pthread_mutex_destroy(&lock);
34
Pre-loader/U-Boot Generator
Device Tree Generator
Bare-metal Libraries
Compilers
GCC (for ARM and NIOS)
ARMCC (for ARM with license)
Linux Specific
Kernel Sources
Yocto & Angstrom recipes:
http://rocketboards.org/foswiki/Documentation/AngstromOnSoCFPGA_1
Buildroot:
http://rocketboards.org/foswiki/Documentation/BuildrootForSoCFPGA
36
Design
Design
Simulate
Simulate
Debug
Debug
Release
Release
37
Eclipse
GNU toolchain
OS/BSP: Linux, VxWorks
Hardware Libraries
Design Examples
Flash Programmer
Hardware Design:
Simple custom logic design in
FPGA
All source code and Quartus II /
Qsys design files for reference
Software Design:
Includes Linux Kernel and
Application Source code
Includes all compiled binaries
38
References
39
Altera References
System Design Tutorials:
http://www.alterawiki.com/wiki/Designing_with_AXI_for_Altera_SoC_ARM_Devices_Workshop_Lab__Creating_Your_AXI3_Component
Designing_with_AXI_for_Altera_SoC_ARM_Devices_Workshop_Lab
Simple_HPS_to_FPGA_Comunication_for_Altera_SoC_ARM_Devices_Workshop
http://www.alterawiki.com/wiki/Simple_HPS_to_FPGA_Comunication_for_Altera_SoC_ARM_Devices_Workshop_-_LAB2
http://www.altera.com/literature/tt/tt_nios2_multiprocessor_tutorial.pdf
Quartus Handbook:
https://www.altera.com/en_US/pdfs/literature/hb/qts/quartusii_handbook.pdf
Qsys:
Qsys Tutorial: Step-by-step procedures and design example files to create and verify a system in Qsys
https://www.altera.com/en_US/pdfs/literature/ug/ug_soc_eds.pdf
Related Articles
Performance Analysis of Inter-Processor Communication Methods
http://www.design-reuse.com/articles/24254/inter-processor-communicationmulti-core-processors-reconfigurable-device.html
OpenMCAPI:
https://bitbucket.org/hollisb/openmcapi/wiki/Home
Mutex Examples:
http://www.thegeekstuff.com/2012/05/c-mutex-examples/
41
Thank You
http://rocketboards.org/foswiki/Projects/BuildingMultiProce
ssorSystems
Includes:
Source code
Hardware source
Hardware Quartus Projects
Software Eclipse Projects