UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

Adam Taylor’s MicroZed Chronicles Part 50: AMP and the Zynq SoC’s OCM (On-Chip Memory)

by Xilinx Employee on ‎09-22-2014 09:36 AM (16,080 Views)

 

By Adam Taylor

 

In my last blog we had looked at the Zynq SoC’s OCM (On-Chip Memory) for inter-processor communications in an AMP environment. Now let’s write come code and use this facility.

 

The demo for this will use CPU0 to communicate over the UART link to a laptop. We’ll send an 8-bit ASCII value from the laptop to the Zynq Soc’s UART. Once received, this 8-bit value will be transferred into the selected OCM memory address, which is shared between the two processors. Each time its private timer expires, CPU1 will read this memory address and set its GPIO output pins accordingly. LED’s on the MicroZed I/O Carrier Card connected to these Zynq SoC pins through the inter-board headers will display the received ASCII pattern. We’ll be able to visually confirm that the correct value has been passed between the CPUs from the display on the LED.

 

Obviously the first thing to do is select the memory address to be used. We’re only passing one 8-bit unsigned integer, so we only need one address location. I have chosen to use the highest 64 Kbytes of the Zynq SoC’s OCM for this work and so I have disabled the cache for this memory location. You do this in both processors’ applications using the command:

 

 

Xil_SetTlbAttributes(0xFFFF0000,0x14de2);

 

 

I will be using the memory address 0XFFFF0000 to transfer my byte of data from CPU0 to CPU1. There are a number of ways that we can do this, however the two most common are the following:

The first method uses the generic Xilinx I/O functions to read from and write to the selected memory address. These functions are contained within Xil_IO.h and allow for storing and accessing 8-, 16-, or 32-bit char, short, or int values within the CPU address space. Using these functions just requires the address you wish to access and the value you wish to store if the memory access is a write:

 

 

Xil_Out8(0xFFFF0000,0x55);

 

read_char = Xil_In8(0xFFFF0000);

 

 

To ensure that the addresses are both targeting the same OCM location, especially if different people are working on the different CPU0 and CPU1 programs, is to have a common header file containing macro definitions of the address of interest for that particular transfer. This is just good engineering practice. For example:

 

 

#define LED_PAT 0xFFFF0000

 

 

The second method is for both programs to access the memory location using pointers. We can do this by defining a pointer that points to a constant address. Normally in C we do this using a macro:

 

 

#define LED_OP (*(volatileunsignedint *)(0xFFFF0000))

 

 

This approach does not require the use of the Xilinx I/O library functions and instead allows simple access via a pointer.

 

Both of these approaches result in successful communication from my laptop via the UART to CPU0 and then into CPU1 and on to the MicroZed I/O Carrier Card LEDS, as shown in the image below (tastefully captured in black and white to stop the glare from the LEDs LSB is far right).

 

 Image 1.jpg

 

 

Here’s the messaging received from the Zynq SoC:

 

 

Image 2.jpg

 

Of course when we are communicating between the Zynq SoC’s processors through OCM, we must remember that the register can be updated more often than we can currently see due to the use of the timer within CPU1 to trigger the read of the memory. In the next blog, we will look at more complex communication between the two processor cores and we’ll focus on software interrupts from one processor to the other.

 

 

Please see the previous entries in this MicroZed series by Adam Taylor:

 

Adam Taylor’s MicroZed Chronicles Part 49: Using the Zynq SoC’s On-Chip Memory for AMP Communications

 

 

Adam Taylor’s MicroZed Chronicles Part 48: Bare-Metal AMP (Asymmetric Multiprocessing)

 

Adam Taylor’s MicroZed Chronicles Part 47: AMP—Asymmetric Multiprocessing on the Zynq SoC

 

Adam Taylor’s MicroZed Chronicles Part 46: Using both of the Zynq SoC’s ARM Cortex-A9 Cores

 

Adam Taylor’s MicroZed Chronicles Part 44: MicroZed Operating Systems—FreeRTOS

 

Adam Taylor’s MicroZed Chronicles Part 43: XADC Alarms and Interrupts 

 

Adam Taylor’s MicroZed Chronicles MicroZed Part 42: MicroZed Operating Systems Part 4

 

Adam Taylor’s MicroZed Chronicles MicroZed Part 41: MicroZed Operating Systems Part 3

 

Adam Taylor’s MicroZed Chronicles MicroZed Part 40: MicroZed Operating Systems Part Two

 

Adam Taylor’s MicroZed Chronicles MicroZed Part 39: MicroZed Operating Systems Part One

 

Adam Taylor’s MicroZed Chronicles MicroZed Part 38 – Answering a question on Interrupts

 

Adam Taylor’s MicroZed Chronicles Part 37: Driving Adafruit RGB NeoPixel LED arrays with MicroZed Part 8

 

Adam Taylor’s MicroZed Chronicles Part 36: Driving Adafruit RGB NeoPixel LED arrays with MicroZed Part 7

 

Adam Taylor’s MicroZed Chronicles Part 35: Driving Adafruit RGB NeoPixel LED arrays with MicroZed Part 6

 

Adam Taylor’s MicroZed Chronicles Part 34: Driving Adafruit RGB NeoPixel LED arrays with MicroZed Part 5

 

Adam Taylor’s MicroZed Chronicles Part 33: Driving Adafruit RGB NeoPixel LED arrays with the Zynq SoC

 

Adam Taylor’s MicroZed Chronicles Part 32: Driving Adafruit RGB NeoPixel LED arrays

 

Adam Taylor’s MicroZed Chronicles Part 31: Systems of Modules, Driving RGB NeoPixel LED arrays

 

 Adam Taylor’s MicroZed Chronicles Part 30: The MicroZed I/O Carrier Card

 

Zynq DMA Part Two – Adam Taylor’s MicroZed Chronicles Part 29

 

The Zynq PS/PL, Part Eight: Zynq DMA – Adam Taylor’s MicroZed Chronicles Part 28  

 

The Zynq PS/PL, Part Seven: Adam Taylor’s MicroZed Chronicles Part 27

 

The Zynq PS/PL, Part Six: Adam Taylor’s MicroZed Chronicles Part 26

 

The Zynq PS/PL, Part Five: Adam Taylor’s MicroZed Chronicles Part 25

 

The Zynq PS/PL, Part Four: Adam Taylor’s MicroZed Chronicles Part 24

 

The Zynq PS/PL, Part Three: Adam Taylor’s MicroZed Chronicles Part 23

 

The Zynq PS/PL, Part Two: Adam Taylor’s MicroZed Chronicles Part 22

 

The Zynq PS/PL, Part One: Adam Taylor’s MicroZed Chronicles Part 21

 

Introduction to the Zynq Triple Timer Counter Part Four: Adam Taylor’s MicroZed Chronicles Part 20

 

Introduction to the Zynq Triple Timer Counter Part Three: Adam Taylor’s MicroZed Chronicles Part 19

 

Introduction to the Zynq Triple Timer Counter Part Two: Adam Taylor’s MicroZed Chronicles Part 18

 

Introduction to the Zynq Triple Timer Counter Part One: Adam Taylor’s MicroZed Chronicles Part 17

 

The Zynq SoC’s Private Watchdog: Adam Taylor’s MicroZed Chronicles Part 16

 

Implementing the Zynq SoC’s Private Timer: Adam Taylor’s MicroZed Chronicles Part 15

 

MicroZed Timers, Clocks and Watchdogs: Adam Taylor’s MicroZed Chronicles Part 14

 

More About MicroZed Interrupts: Adam Taylor’s MicroZed Chronicles Part 13

 

MicroZed Interrupts: Adam Taylor’s MicroZed Chronicles Part 12

 

Using the MicroZed Button for Input: Adam Taylor’s MicroZed Chronicles Part 11

 

Driving the Zynq SoC's GPIO: Adam Taylor’s MicroZed Chronicles Part 10

 

Meet the Zynq MIO: Adam Taylor’s MicroZed Chronicles Part 9

 

MicroZed XADC Software: Adam Taylor’s MicroZed Chronicles Part 8

 

Getting the XADC Running on the MicroZed: Adam Taylor’s MicroZed Chronicles Part 7

 

A Boot Loader for MicroZed. Adam Taylor’s MicroZed Chronicles, Part 6 

 

Figuring out the MicroZed Boot Loader – Adam Taylor’s MicroZed Chronicles, Part 5

 

Running your programs on the MicroZed – Adam Taylor’s MicroZed Chronicles, Part 4

 

Zynq and MicroZed say “Hello World”-- Adam Taylor’s MicroZed Chronicles, Part 3

 

Adam Taylor’s MicroZed Chronicles: Setting the SW Scene

 

Bringing up the Avnet MicroZed with Vivado

 

 

 

 

Labels
About the Author
  • Be sure to join the Xilinx LinkedIn group to get an update for every new Xcell Daily post! ******************** Steve Leibson is the Director of Strategic Marketing and Business Planning at Xilinx. He started as a system design engineer at HP in the early days of desktop computing, then switched to EDA at Cadnetix, and subsequently became a technical editor for EDN Magazine. He's served as Editor in Chief of EDN Magazine, Embedded Developers Journal, and Microprocessor Report. He has extensive experience in computing, microprocessors, microcontrollers, embedded systems design, design IP, EDA, and programmable logic.