C6000 Embedded Design Workshop Using SYS/BIOS: Student Guide
C6000 Embedded Design Workshop Using SYS/BIOS: Student Guide
Student Guide
Notice
Creation of derivative works unless agreed to in writing by the copyright owner is forbidden. No
portion of this publication may be reproduced, stored in a retrieval system or transmitted in any
form or by any means, electronic, mechanical, photocopying, recording or otherwise, without the
prior written permission from the copyright holder.
Texas Instruments reserves the right to update this Guide to reflect the most current product
information for the spectrum of users. If there are any differences between this Guide and a
technical reference manual, references should always be made to the most current reference
manual. Information contained in this publication is believed to be accurate and reliable.
However, responsibility is assumed neither for its use nor any infringement of patents or rights of
others that may result from its use. No license is granted by implication or otherwise under any
patent or patent right of Texas Instruments or others.
Revision History
Note: all previous versions used CCSv3.3 and the DM6437 EVM. All future versions of this
workshop will use CCSv4+, C6748 EVM and BIOS 5.41+.
Module Topics
Welcome ......................................................................................................................................................0-1
Module Topics..........................................................................................................................................0-2
Welcome ...................................................................................................................................................0-3
Administrative Topics .........................................................................................................................0-3
Goals of the Workshop ........................................................................................................................0-3
What is “Outside the Scope”?..............................................................................................................0-4
Workshop Outline – 4 Levels of Experience .......................................................................................0-4
Introductions ........................................................................................................................................0-5
For More Information… ......................................................................................................................0-6
Texas Instruments Wiki Site................................................................................................................0-6
BIOS Workshop - Online ....................................................................................................................0-7
Questionnaire (fill out after Lab 1) ..........................................................................................................0-9
Welcome
Administrative Topics
Introductions
*** why are you staring at a blank page? Do you need therapy? ***
Objectives
Objectives
Module Topics
Devices .........................................................................................................................................................1-1
Module Topics..........................................................................................................................................1-2
TI Embedded Processor Families ............................................................................................................1-3
C6000 DSPs .............................................................................................................................................1-4
Classic DSP Problem ...........................................................................................................................1-4
DSP Core .............................................................................................................................................1-4
C6000 DSP Family Roadmap ..............................................................................................................1-5
Peripherals...............................................................................................................................................1-7
Overview (the whole grab bag) ...........................................................................................................1-7
Programmable Real-Time Unit (PRU) ................................................................................................1-8
Switched Central Resource (SCR) & EDMA ......................................................................................1-9
SCR – Connection Matrix ...................................................................................................................1-9
Pin Muxing ........................................................................................................................................1-10
Example Device – TMS320C6748 .........................................................................................................1-11
ARM-based Device Families ..................................................................................................................1-12
Choosing A Device .................................................................................................................................1-13
Chapter Quiz ..........................................................................................................................................1-14
OMAP-L138 (C6748) EVM ...................................................................................................................1-15
Lab 1 – System Setup .............................................................................................................................1-17
A. Computer Login ........................................................................................................................1-17
B. Connecting the OMAP-L138 EVM to the PC ..........................................................................1-18
C. Launch CCS ..............................................................................................................................1-19
Additional Information...........................................................................................................................1-24
C6000 DSPs
Classic DSP Problem
x Y
ADC DSP DAC
DSP Core
Peripherals
Overview (the whole grab bag)
C6x DSP
Graphics
ARM
Accelerator
Video Accelerator(s)
Pin Muxing
Development tools
ARM ® Cortex™ -M ARM ® Cortex™ -M3 ARM® Cortex™-R4 ARM Cortex-A8
Fixed and floating-point Plus C28x Floating Pt Fixed and floating-point
26
Choosing A Device
Chapter Quiz
Chapter Quiz
1. How many functional units does the C6000 CPU have?
256
CPU
128
*** this page is empty, so why are you reading this? ***
A. Computer Login
1. If the computer is not already logged-on, check to see if the log-on information is posted.
If not, please ask the instructor (student/student is a common ID/psw to try).
http://processors.wiki.ti.com/index.php/TMS320C64x%2B_DSP_System_Integration_Workshop_using_DSP/BIOS
The software should already be installed on the lab workstation. All that should have to be done is
to physically connect the EVM.
2. Connect the XDS510 pod to the board and the other end to the to a USB port on the PC.
If you connect the USB cable to a USB Hub, be sure the hub is connected to the PC or laptop
and power is applied to the hub). If you ever use the on-board emulation (EVM USB jack),
there are actually two mini-USB connectors on the baseboard – make sure you use the proper
one – it is located next to the serial port on the top left-hand part of the board.
Note: Note: If, after plugging in the USB cable, a found new hardware message appears
indicating that the USB driver needs to be installed, notify your instructor and simply go
through the wizard to install “this time only” the “recommended” driver. In most
classroom installations, this has already been performed.
C. Launch CCS
Code Composer Studio (CCS) supports numerous TI processors (including the C6000 and C5000
series) and a variety of target boards (simulators, EVMs, DSKs, and XDS emulators).
1. Play some music on the PC.
On the desktop, locate the “MP3” folder and pick out a song. Double-
click on the song to play it. You may have to plug your headphones in to
hear it. Make sure the volume is at an appropriate level. When Windows
Media Player opens, ensure that “Play Forever” or “Repeat” are selected
so that the music never stops.
2. Launch CCSv5.
Launch CCSv5 by double-clicking on the CCSv5 icon on the desktop as shown. If the
“startup” screen appears (like it is the first time CCSv5 has ever launched on this PC), simply
click in the upper right-hand corner to “Start Using CCS”. If asked to choose a “workspace”,
just choose the default and check “don’t ask again”.
3. Check the Target Config File.
On the menu, select:
View Target Configurations
Make sure that the following target config file is the “Default”:
XDS510_USB_EVM6748_TTO.ccxml
As shown here:
CCSv5 is basically built using two parts: the Editor and the Debugger. In the older CCS 3.3,
the editor and debugger were combined together. In CCSv5, they are separate.
In order to run code on the EVM, we must complete three steps:
• launch the debugger
• connect to the board
• load the program
As you’ll learn soon, all three of these steps can be combined together for convenience.
Launching the Debugger should take about 5-7 seconds. Thankfully, most of the time, we
will leave this “Debug Session” open as we build new code and then the code simply loads
itself to the board and we don’t have to “re-launch” the debugger each time.
Note the change in the “perspective” of the windows. You just launched a “Debug Session”
which contains a set of windows that are different than the C/C++ Edit Perspective.
This little “connection” icon is greyed out because we are NOT connected to the board yet.
When you click this button, and connection is successful, it will “light up”. Well, that’s our
next step – to connect to the target. You can simply click this button or…
On the menu, select:
Run → Connect Target
During this step, you will see some “Console” comments that are generated by CCS running
the GEL file associated with this EVM/device. The GEL file is setting up the clocks and
memories so that programs will run correctly. Much more on this later…
Note: This is the step where the GEL script runs to initialize the board and memory. The default
GEL file that you download from LogicPD is FLAWED. It gets hung up in the DDR init
phase. We are using a “new and improved” and “yet unreleased” version of this GEL file
– oh, that actually WORKS. It is on the BIOS workshop website. It actually works for
BOTH the C6748 and OMAP-L138 SOMs (it is a thing of beauty). If you are using this
EVM, please download this GEL file from the BIOS workshop wiki and use it –
otherwise, you’ll have a less healthy experience. You have a copy of this file in the
labs/techdocs folder that you will take home on a USB stick at the end of class.
Load the executable to the board by clicking Ok. You will see the progress indicator while
the program loads. Again, this should only take a few moments. You will see something
similar to the following screen when the program has loaded:
You may see a “Source Not Found” message. Just ignore it.
You’re finished with this lab. If time permits, you may move on to additional
“optional” steps on the following pages if they exist.
Additional Information
M
SCR & Megamodule S
Master Slave 32
EDMA3 SCR = Switched Central Resource
TC0
CC TC1
TC2 McBSP L1P
PCI
Utopia
C64x+ MegaModule L1P PERIPH
DDR2
EMAC Mem AET
HPI EMIF Ctrl M S
PCI Cfg
D D
L2
L2 Mem IDMA CPU S
M
S
M
Ctrl
L L
External L1D
S M Mem
128 Cntl Mem
Ctrl PERIPH =
M S M All peripheral’s
128
Cfg registers
L1D S
DATA 32
SCR
CFG
Master: has its own DMA – can initiate a transfer
Example: CPU programs EDMA3 Cfg regs (via CFG SCR). EDMA xfrs McBSP DRR L2
SCR
Not all connections in DATA SCR are valid (see connection matrix)
Objectives
Objectives
C6000 Embedded Design Workshop Using BIOS - Code Composer Studio v5 2-1
Module Topics
Module Topics
Code Composer Studio v5 .........................................................................................................................2-1
Module Topics..........................................................................................................................................2-2
Code Composer Studio v5 - Intro.............................................................................................................2-3
Functional Overview ...........................................................................................................................2-3
Perspectives .........................................................................................................................................2-5
Projects ................................................................................................................................................2-5
Eclipse – “Workspaces” ......................................................................................................................2-7
Target Configuration File (.ccxml) ......................................................................................................2-7
GEL Files ............................................................................................................................................2-8
Build Configurations, Build Options ...................................................................................................2-8
Licensing & Pricing .............................................................................................................................2-9
For More Information... .......................................................................................................................2-9
Device Memory ......................................................................................................................................2-10
C6748 Internal & External Memory ..................................................................................................2-10
Code & Data “Sections” ....................................................................................................................2-11
Linking & Linker Command Files ....................................................................................................2-12
Chapter Quiz ..........................................................................................................................................2-14
Lab 2 – CCSv5 Projects .........................................................................................................................2-15
Lab 2A – Hello World – Procedure ...................................................................................................2-16
BIOS Workshop File Management - Intro ....................................................................................2-16
Create a New Project .....................................................................................................................2-17
Create hello_world main(). ...........................................................................................................2-20
Add a Linker Command File .........................................................................................................2-21
Create a New Target Configuration File (.ccxml) .........................................................................2-22
Analyze the Linker Command File ...............................................................................................2-25
Build, Load & Run. .......................................................................................................................2-25
That’s It. You’re Done!!................................................................................................................2-30
Lab 2B – Test Audio – Procedure .....................................................................................................2-31
File Management ...........................................................................................................................2-31
Create a New Project. ....................................................................................................................2-32
Analyze the Test Audio Example Files .........................................................................................2-34
Play the Test Audio Example ........................................................................................................2-35
Basic Debugging Techniques ........................................................................................................2-36
That’s It. You’re Done!!................................................................................................................2-37
Additional Info & Notes .........................................................................................................................2-38
2-2 C6000 Embedded Design Workshop Using BIOS - Code Composer Studio v5
Code Composer Studio v5 - Intro
C6000 Embedded Design Workshop Using BIOS - Code Composer Studio v5 2-3
Code Composer Studio v5 - Intro
2-4 C6000 Embedded Design Workshop Using BIOS - Code Composer Studio v5
Code Composer Studio v5 - Intro
Perspectives
Projects
C6000 Embedded Design Workshop Using BIOS - Code Composer Studio v5 2-5
Code Composer Studio v5 - Intro
2-6 C6000 Embedded Design Workshop Using BIOS - Code Composer Studio v5
Code Composer Studio v5 - Intro
Eclipse – “Workspaces”
C6000 Embedded Design Workshop Using BIOS - Code Composer Studio v5 2-7
Code Composer Studio v5 - Intro
GEL Files
2-8 C6000 Embedded Design Workshop Using BIOS - Code Composer Studio v5
Code Composer Studio v5 - Intro
http://processors.wiki.ti.com/index.php/Video_Tutorials_CCSv5
23
C6000 Embedded Design Workshop Using BIOS - Code Composer Studio v5 2-9
Device Memory
Device Memory
C6748 Internal & External Memory
L1D L3 FFFF_FFFF
26
-stack 0x800
STACK/HEAP SIZES
-heap 0x800
SECTIONS {
.bss {} > IRAM
.far {} > IRAM CODE/DATA SECTIONS
.text {} > DDR
.cinit {} > FLASH Note: later on, BIOS config
} (.cfg) generates this file for us…
33
Chapter Quiz
Chapter Quiz
1. Name the two CCS perspectives and the differences between them:
3. Which file specifies the target, target connection and GEL file?
5. What is the purpose of a linker.cmd file and what are the two main
items it specifies?
• C:\SYSBIOSv4\Labs & Sols – In \Labs, notice the numbered labs (e.g. Lab3)
and open one or two of them to see the directories they contain. Each Lab directory will
contain at least two directories – one called \Files and the other named \Project.
“Files” will always contain the “starter files” needed for that lab. \Project is where we
will create each project for each lab. \Sols is where you will find all solution files. If
you get stuck on a particular lab and aren’t sure exactly how to do something, check out
the solution for that lab for a hint.
• C:\TI\– contains other software components such as Codec Engine, xDAIS and PSP
drivers. We will refer to these later on in the workshop.
This little exercise will help you navigate your way around as we progress through the labs in
the workshop.
You will then see a window as follows (do NOT click Finish until told to do so):
Name your project “hello_world” and UNCHECK the “Use default location” checkbox. Then
browse to the path shown to locate your project SPECIFICALLY in this folder. Choose all
other settings as shown (Empty Project, no main.c) but DO NOT CLICK FINISH YET !!
Click Finish.
5. Edit Perspective.
Please note (at the moment), you are already experiencing a “different perspective”. Look up
in the right-hand corner to see the two default perspectives:
Note that “CCS Edit” is highlighted. We are editing files and working with projects (build
kind of stuff). The windows and views you see in this perspective are “default” and can be
changed to your liking later.
6. Check the Includes Directory.
Well, you’ve done it. You’ve created (maybe) your first CCSv5 project. Congrats. Let’s go
see what it looks like.
Click on the + next to Includes. Notice that CCS automagically included all of the compiler
header files. If you click the + next to this directory of header files, you’ll see the vast sea of
standard TI compiler header files.
These are the “barebones” files you need to describe your project. Later, when we add
SYS/BIOS to our project, CCS will create another directory called “.config”. These files
together form an “Eclipse” project along with our source files. As we add files to our project,
we will watch the Windows Explorer view reflect our movements.
When the next window pops up, type “hello_world.c” in as the filename:
Notice the inclusion of this source file in the project view. I wonder if this source file now
exists in our \Project directory in Windows Explorer – well, GO SEE. Aha. It does.
Double-click the third option because we’re not using DSP/BIOS 6 (which is actually
SYS/BIOS and therefore poorly named) at the moment.
As a Batman cartoon would say “KA-BLAAMMMMM !!!!”
How’s that for speed…?? Now, if only you were paid well for creating complex code like
this, you could tell your boss it will take a week, hit CTRL-SPACE, make the Batman noise
and then go play golf or poker with your friends…
Save your new source file.
Reminder – any starter files that are needed for a lab will be located in the \Labx\Files
directory. In this case, browse to \Labs\Lab2A\Files and select the linker command
file: linker_dsp.cmd.
Note: this file will be slightly different than what was shown in the slides.
When the dialogue appears with the choice of “copy” or “link” – select “copy”.
Hint: Whenever you ADD a file to your project, you will have a choice to “copy” or
“link/reference” the file. If you choose “copy”, CCS will COPY that file from its original
location to the location of the project. Due to this, any EDITs to this file will be done on a
local copy versus the original file. In the next lab, we will LINK a file to our project in
which case a “pointer” to that file will be used. Any edits to a LINKED file actually
occur to the original file.
Right-click on the “User Defined” directory and choose “New Target Configuration”.
The following dialogue box will appear. Check the “Use shared location” box if it is not
already checked:
Note: FYI – the following setup instructions work for either the C6748 SOM or the OMAP-
L138 SOM – we are ONLY using the C6748 DSP in this workshop (no ARM code
development). The GEL file we plan to use configures both the ARM and DSP, wakes up
the DSP and loads the code to the DSP (basically the ARM9 is ignored in either case).
When you are ready to proceed, follow the directions for the emulator used in this workshop
– XDS510.
When finished providing a name and connection type, click on the Advanced tab. For those of
you who are familiar with the old CCS Setup, the left side of the window should look
familiar.
Click on the “Plug” that says “C674x_0” which signifies the CPU layer. On the right-hand
side of the window, you’ll see the following screen.
THIS is where you specify the GEL script that CCS runs each time you “Connect to Target”.
Of course, this is in a very NON-intuitive place.
Hint: If you are able to select a BOARD in the target configuration file – vs. a DEVICE – it
will most likely come with a GEL file for the entire BOARD and be auto-loaded by CCS
correctly (i.e. without you even knowing it happens). However, when you choose a
DEVICE (like we did), no GEL is specified automatically and will most likely cause
memory read/write errors as you continue development. Word to the wise…
Browse to:
C:\SYSBIOSv4\Labs\DSP_BSL\gel\OMAPL138_EVM_TTO.gel. When you
find this file and your target config file is done – ASK THE INSTRUCTOR TO
CHECK YOUR WORK before saving….
Hint: This GEL file has been updated by TI and recently released by Logic PD. Logic PD’s
default GEL file is not stable – it tends to get hung up in the DDR init code. TI came with
a new one that LogicPD released with a “_TI” suffix. This same GEL file is used in this
workshop with the addition of the _TTO on the name.
12. Instructor check – then save your file and set as default.
Ask the instructor to check your target config file first. If it is not correct now, problems will
occur later. If the instructor approves your target config file, click the “Save” button.
To locate your new target config file, select:
View Target Configurations
Then, click on the + sign next to the User-Defined folder. You will see others listed there that
the workshop author created for the workshop.
Right-click on this new file (your student target config file) and make sure “Set as Default”
is selected (the default ccxml file will be in BOLD letters).
Now imagine, for a moment, that you had two development boards or two processors on one
board that could be used as “targets”. All you simply have to do within CCS is view the target
configs, set the proper one as default, rebuild/load/run – oh, and connect the right board, of
course.
Active means that this project is the Active project. Doesn’t mean much for now because this
is likely the only project in your project view. As we build up more labs, however, ALL of
the projects listed in your workspace will show up in your project directory. Debug means
that the Debug build configuration is being used – i.e. no optimizations are turned on and
symbolic debug IS turned on.
Click on “Release” and see “Debug” changed to “Release” in the project. This is how you
change build configurations (set of build options) when you build your code.
Hint: Build Configurations not only contain standard build options like levels of optimization
and debug symbols, but also contain specifc “file search paths” for libraries (-l) and
“include search paths” (-i) for include directories. If you specify these paths in a Debug
configuration and you switch to Release, those paths do NOT copy over to the next
configuration. Why? Because often you have a “debug” or “instrumented” library you are
using during initial debug and a completely different “optimized” library when
attempting to optimize your code.
Near the top left-hand corner of CCS, you will see the build HAMMER:
If you simply click the hammer, it will build whichever configuration is set as the default
(either Debug or Release).It will always do an INCREMENTAL build – i.e. build only those
files that have changed since the last build (it is much faster this way). Building “clean” will
be discussed later.
If you want to build a different configuration (e.g. release), simply click the down arrow and
choose Release. This will switch the configuration to Release AND BUILD THE PROJECT
with these settings. We will try this later, but for now, let’s stick with the Debug
Configuration.
Click the HAMMER and build the Debug Configuration. and watch the progress in the
console window. If you get any errors, go fix them. If not, you can move on…
c. Load the newly created .OUT file. When connected, load your .out file using: Run
Load Load Program. When the dialogue box pops up, choose “browse project” which
will show your latest build (.out).
FYI – The next time you want to launch, you can simply click the “Bug” to launch
your debug session. You can click on the down arrow next to the bug to see your options.
Ok – what has changed? Have you noticed that your “perspective” has changed to Debug –
different windows, views, buttons, etc.? In the upper window, you see a “call stack”. This can
be handy when you set breakpoints or your code goes off into the weeds – this helps you
answer “how did we get here?”. You will also notice the “Play”, “Pause”, and “Terminate”
action buttons at the top of the screen.
In the main “source” window, you will see the following:
Notice the arrow on the left-hand side. This indicates that the processor is “at main()” and
ready to run. But wait, didn’t the processor hit reset and do a bunch of stuff already before it
got here? Yes. We’ll investigate that more later. However, for now, it is a nice convenience to
show up at main() ready to go.
I’d like you to meet “Play” – the green dude, “Pause” the yellow light, and “Terminate”, the
red “kill” or “stop completely and terminate your debug session – darn I shouldn’t have hit
that button because now it will take forever to get back to this point” button. Green and
yellow are your friends. Use the red dude with CAUTION.
Hint: Often, during the initial stages of learning a new tool, some buttons are intuitive and
some are not. The green “Play” is great. However, your mind will think “red” means stop
and you’ll forget about “yellow”. Well, “red” means close completely TERMINATE the
debug session and disconnect from the target. The next time you build code, you will
need to RE-LAUNCH the TI Debugger and RE-CONNECT to the target and RE-RUN
the GEL script. So, learn quickly to only use “Play” and “Pause” frequently and
“Terminate” only when necessary. If you’re familiar with CCSv3.3, “Pause” is the old
“Halt” button. ‘Terminate” is equivalent to shutting down CCS in v3.3.
In the DEBUG Perspective, select Window Customize Perspective. Select the “Command
Groups Availability” tab and check the “Build Configuration” box as shown. This will add
the “Hammer” build button to the Debug perspective. In your personal version of CCS (at
work), you can customize either the Edit or Debug perspectives in the same way to your
liking.
File Management
1. Locate the original audio test files from Logic PD’s BSL.
The files you are about to use came directly from Logic PD’s BSL (board support library)
download. They have many test examples that you can choose from – one of which is an
“audio test” routine. You can find these files at:
You can see the linker_dsp.cmd file above. Click on the \inc and \src directories to locate
the other source files. The author has copied these exact files into the local Labs directory for
you already. Now you know where they came from.
If you browse the following folder, you can see the original contents of the BSL as it looks
when you download it:
C:\SYSBIOSv4\Labs\DSP_BSL\ORIGINAL_LOGIC_PD_FILES
The contents of this folder should look like the above. If not, ask your instructor for help.
Right-click on the project and choose “Add Files” and browse to:
Select the .lib file shown and when the dialogue asks you to “copy” or “link”, choose LINK.
Notice that this file has a little “arrow” indicating it is a LINKED file.
Pause for a moment and MAKE SURE your project looks exactly like this picture. If you’re
missing something, go back and determine what you’re missing and add it. All future steps
assume your project has the exact contents shown above.
Right-click on your project and select “Properties”. Under the “C6000 Compiler” listing,
select “Include Options”:
We need to ADD a path to this list for the BSL library include directory.
Click OK.
You should now see your new path added to the “include” list. All of the other paths shown
may or may not have been included AUTOMATICALLY based on your configuration
settings. There is only ONE path you needed to add – the path to the \inc folder for the BSL
library.
Note: Again – we just added a path to our Build Properties for the Debug Build Configuration.
If you were to switch to Release right now, the path you just added would disappear. So,
when switching between build configurations, BOTH need to have the proper paths set to
work properly. Just beware of this when we ask you to switch modes in the middle of a
lab and Release has errors when Debug doesn’t. Well, now you know what, most likely,
is causing the problem. You can also use “Manage” for configs to delete/copy or create a
new custom configuration.
Open the test_audio.c file and set a breakpoint (double-click to the left of the line
number) on line 265 as shown:
Click “Play”. The breakpoint will get hit after you hear the sine tone. At this point, what if
you wanted to know the contents of the dat variable. You should be able to already see the
“Variables” tab showing near the upper right-hand part of the screen. If not, select:
View → Variables
FYI – when we BREAK the McASP (stop feeding it), it actually breaks. So, don’t expect to
run again and see what happens next. You’re dead.
Right-click on the VALUE of dat and select “Number Format”. Here, you can choose a
variety of formats to view your variables.
Click the + next to Core Registers. This is the entire contents of all of the CPU registers. You
can also see in the previous list all of the peripheral registers and their contents. Very handy.
16. View CCSv5 Scripts.
In the older CCSv3.3, there was a GEL menu where you could write a GEL file and load it
and it would show up under that menu. GEL scripts are simply a set of commands to help
CCS peform certain duties – like setting up the clocks, PLL, memory, etc.
In CCSv5, these are called SCRIPTS. The scripts are loaded when you pointed to the
OMAPL138_EVM_TTO.gel file way back in the last lab. To view what capabilities these
scripts offer, click on “Scripts” on the menu bar. Don’t run any of them – this is just an
awareness exercise. Also, take a moment and open this gel file in a Window’s editor and scan
the contents. Do NOT make any changes…when done…close the GEL file.
17. Conclusion
FYI – this test code from LogicPD was the seed for most of the labs we use in this workshop.
Over the next 4 days, you will become very familiar with some of the operations of this code
as we build on the McASP/AIC3106 setup and use it to perform certain tasks within the
system – all the while playing with the audio piece.
You’re finished with this lab. Please let your instructor know when you have
finished this lab…
Objectives
Objectives
Module Topics
Introduction to SYS/BIOS .........................................................................................................................3-1
Module Topics..........................................................................................................................................3-2
Intro to SYS/BIOS ....................................................................................................................................3-3
Overview .............................................................................................................................................3-3
DSP/BIOS vs. SYS/BIOS – Comparison...................................................................................................3-6
Threads & Scheduling..............................................................................................................................3-7
Thread Types .......................................................................................................................................3-7
Creating A BIOS Resource – Example: Hwi Object ...........................................................................3-9
System Timeline .....................................................................................................................................3-10
Real-Time Analysis Tools.......................................................................................................................3-11
SYS/BIOS Projects .................................................................................................................................3-12
Creating a New Project ......................................................................................................................3-12
BIOS Configuration (.CFG) ..............................................................................................................3-13
Platforms ...........................................................................................................................................3-16
Version Control Suggestions .............................................................................................................3-16
For More Info… .....................................................................................................................................3-17
DSP/BIOS Configuration – FYI [OPTIONAL] ......................................................................................3-20
Chapter Quiz ..........................................................................................................................................3-22
Lab 3 – SYS/BIOS Blink LED ................................................................................................................3-23
Lab 3 – Procedure .................................................................................................................................3-24
Download Latest Tools .................................................................................................................3-24
Create New blinkLed Project ........................................................................................................3-25
Add and Link Files ........................................................................................................................3-27
Explore the New CFG File ............................................................................................................3-30
Register ledToggle() as an Idle Thread Function ..........................................................................3-31
Final Modifications Before Build..................................................................................................3-33
Build, Load, Run ! .........................................................................................................................3-34
View the Platform File ..................................................................................................................3-35
ROV At A Glance .........................................................................................................................3-37
Explore SYS/BIOS folders............................................................................................................3-38
That’s It, You’re Done !!...............................................................................................................3-38
Additional Information & Notes ............................................................................................................3-39
More Notes… .........................................................................................................................................3-40
Intro to SYS/BIOS
Overview
SYS/BIOS Overview
Idle
Multiple Idle functions
Runs as an infinite loop (like traditional while(1) loop)
Background Single priority level
14
System Timeline
SYS/BIOS Projects
Creating a New Project
33
Platforms
Chapter Quiz
Chapter Quiz
1. What is the main purpose and benefit of using an RTOS?
4. What does a .cfg file contain and how do you add services to it?
Lab 3 – Procedure
Typically when you first acquire a new development board, you want to make sure that all the
development tools are in the right place, your IDE is working and you have some baseline code
that you can build and test with. While this is not the “ultimate” test that exposes every problem
you might have, it at least gives you a “warm fuzzy” that the major stuff is working properly.
So, in this lab, we will use a few Board Support Library (BSL) functions provided by LogicPD to
blink an LED on the EVM. While this is not “killer code”, it will allow us to explore some basic
concepts in using SYS/BIOS.
After downloading these tools, you must then close CCS and re-launch it. If you place these
tools in CCS install dir (as they are in this workshop), CCS will recognize them and ask you
to “enable them” when you re-launch CCS. Then, they will show up in the RTSC
configuration box later on and you can choose the latest tools.
• Location: C:\SYSBIOSv4\Lab3\Project
When you get to the Project Settings tab, make sure the appropriate selections are there – as
shown:
As you can see, you have several options. “Minimal” would work just fine in our case
because we end up adding what we need to get the project to work. However, the “dummy
mode” choice (safest one) is “Typical” which is a great starting point for any project and you
can add/delete items from there.
Choose the “Typical” CFG file as shown above. This choice gives you two items – a main.c
with the proper header files (.h) added and a starter .CFG file.
Then, make sure you select the proper platform: evm6748 and the release build profile.
• main.c – this is a generic main.c file that contains a “shell” for you to use in your own
project. The key items are the include statements at the top. For each BIOS MODULE
(Task, Swi, Hwi, Idle, etc), you must include the corresponding header file. More on this
later…
• app.cfg – this is our starter CFG file. We will modify this file as we move through the
lab.
Right-click on the project and LINK the following library to your project:
This is Logic PD’s board support library (BSL) that contains functions we need to access to
initialize the I2C communications channel and toggle the LED on the EVM board.
Then click on the “+” sign to add the other path indicated to the BSL \inc folder as you did in
the previous lab:
C:\SYSBIOSv4\Labs\DSP_BSL\bsl\inc
Click OK. Notice that this path is now added to the include search path.
Click OK again.
You are looking at the XDC Tools GUI (called XGCONF) which allows users to create BIOS
objects statically. The available products window reflects the checkboxes you checked when
you created the project. The outline view shows currently configured static objects.
We will use both of these dialogues to configure SYS/BIOS throughout all of the labs.
This will enable you to see the source script – the actual contents of the .CFG file. If you
click on a BIOS module in the outline view (on the right), e.g. Clock, it will show you the
exact script that was used to create that configuration. Feel free to click around some, but
don’t change anything. More on this later…
c) Configure that instance (e.g. name of Semaphore and starting count value)
d) Include a proper header file to your code (e.g. main.h) for Semaphores
In our case, we want to USE the Idle Module and then configure it to call our
ledToggle() function when it reaches the Idle thread. Because we are STATICALLY
configuring our objects for now, we’ll use the available GUI vs. creating it dynamically.
First, under the heading Scheduling in the Available Products window, right-click on Idle and
select “Use Idle”.
The Idle module will now show up in the outline view (on the right). Click on the Source tab
to see the script that was added to the .CFG file for Idle. Cool. Now it’s time to configure the
Idle thread…
16. Configure Idle thread to call ledToggle().
Click on the Idle tab next to Source. This should bring up the configuration box for the Idle
module. All we have to do is type in the name of the function(s) we want to run during the
Idle thread.
Type in the ledToggle function name into the first slot:
If you have 3 Idle functions and you want them to run in order, place them here in the order
you want them to run. They will then run in a round-robin fashion. If you want to
GUARANTEE the order, then use one Idle function that calls the three functions in order.
Save the CFG file. If you’re curious, you can select the Source tab again and see this function
added to the script near the bottom.
If you DYNAMICALLY create a BIOS object in your code, you would then need to
explicitly add the header file for that module to main.h. In that case, we would add:
#include <ti/sysbios/knl/Idle.h>
For xdc.runtime modules, like Timestamp, an explicit header file is required. So, for this
workshop, we simply add all of the header files in main.h to cover us for both static,
dynamic and runtime cases.
Getting started with SYS/BIOS can be a challenging proposition at times. Without some
decent labs/material to guide you through this, it is sometimes frustrating to put all the pieces
together in a timely manner. But hey, you’re here – and reading this, so you’re the
beneficiary. Trust the author when he says these can be huge stumbling blocks if you didn’t
have someone to walk you through the basics the first time…
Timestamp should show up in the Outline view. Save your .CFG file.
19. Explore SYS/BIOS System Configuration
The “global” configuration for SYS/BIOS is located in the BIOS module in the outline view.
Click the app.cfg tab to make sure you are viewing this file.
Click the “BIOS” module in the outline view and you’ll see a configuration box which has
the following buttons on top:
The Welcome screen has some text that is interesting and the System Overview has a pretty
diagram. Click on System Overview and notice the green checkmarks – they should match the
BIOS services you have added to your .cfg file.
Now click on the Runtime button. This is where you can modify the global settings for
SYS/BIOS, namely:
• SYS/BIOS library type – instrumented is used during your application’s debug phase and
therefore is the default setting. For production, you may select the non-instrumented
version of the library. The other two are not really used.
• Threading Options – make sure each of these are checked. If not, stuff might not work!
• Runtime Memory Options – the default is dynamic creation/deletion. This covers
STATIC also. This is the proper all-encompassing setting.
• Heap Settings – SYS/BIOS requires a heap. This is where the size is defined.
• Stack Settings – Whoops, where are those? Click on Program in Outline view.
Your code will most likely NOT run properly – the rest of this page helps you find your error.
Use the Debug build configuration and click Build. If your code builds with errors, fix them.
If your build is successful, let’s open a new debug session.
In the previous lab, you used the 3-step process: launch, connect, load. Just follow this
process again to load your program (don’t forget to “browse project”).
The second time you build (with an open debug session), CCS will auto load the new .out
file.
If you terminate the debug session after launching a program at least ONCE, then you can
simply hit the “bug” below and it will do all 3 steps for you.
After the GEL file runs and program loads, click Run (Play).
Did it work? Is the LED blinking? If so, you can move on to the next part. If not, please
read on – you probably made a common mistake…
If you didn’t already find the API and put it in main(), add the proper function call to start the
scheduler to the end of main() and build/run again. At this point, the LED should blink.
Ok, so this might have been a MEAN thing to do…but sometimes it is the simplest things
like this that can cause you hours of debug, frustration and forum msgs to TI only to find out
“golly, Sarge, I forgot to start the doggone scheduler!” Ok, Gomer…
Ok, now the trouble begins. If you did NOT know how this new SYS/BIOS stuff was
packaged up and this dialogue is asking you for the repository for where these platforms are
stored, you’d go nuts. How would YOU know? That’s what the E2E forum is for.
Ok, so you’re running this lab and here’s your answer. The platforms are stored in the XDC
Tools path (use latest tools path) (as shown) under \packages. Intuitive right? Wrong.
Your path will be different. It will have “_v5” without the “.1.0” and also point to the
LATEST XDC Tools version. FYI.
Browse to that directory and then select the evm6748 platform as shown. Click Ok.
So, for this target (evm6748), it looks like the DEFAULT platform file allocates all code,
data and stack into external DDR memory. Ok. We’ll change some of this later.
ROV At A Glance
22. Inspect the contents of the ROV tool.
As stated in the discussion material, the Run-time Object Viewer (ROV) provides great
information about the state of the scheduler, BIOS threads and memory objects. We will dive
deeper into the contents of ROV in a later chapter, but wanted to open it in this lab and just
browse its contents.
You will see a list of modules on the left and if you click on a module, you can see the status
of each along with different tabbed views. The following “headings” like “ROV-BIOS”
indicate the module to click on in the ROV to find the answers. Also, some questions are not
easy – but will allow you to EXPLORE ROV to hopefully find the answers.
Let’s look at (click on) a few in particular and answer some questions:
ROV-BIOS
Are clocks, Swis and Tasks enabled? Yes No
What is the frequency this processor is running at ? _______MHz
ROV-Idle
How many Idle functions are there? 0 1 2
Where are the BIOS benchmarks located? These will tell us how long each API takes to run
on our system – i.e. the SYS/BIOS overhead.
C:\CCStudio_v5\bios_6_32_05_54\docs\cdoc\ti\sysbios\benchmarks\doc-files
What is the interrupt latency for the ARM Cortex-M3 in cycles? ________
(Hint, click on Results.html)
How many bytes does the bare bones SYS/BIOS kernel require (code)? ________bytes
(Hint, use Sizes_M3.html)
Hey, TI said they shipped SOURCE CODE with SYS/BIOS. Prove it. In fact, I’d like to see
the source code for a Swi_post() – I’m wondering if they disable interrupts – if that call is
“thread safe” or “atomic”. Ok…locate:
C:\CCStudio_v5\bios_6_32_05_54\packages\ti\sysbios\knl
See all the header and source files there? Ok. Open Swi.c and browse down to about line 582.
Do you see an API called Hwi_disable() near the top? Yes No
Lastly, where are those platform files (or packages) stored? Browse to:
C:\CCStudio_v5\xdctools_3_22_04_46\packages\ti\platforms\evm6748
This is the actual package we are using in the labs. The XDC tools understand how to
consume this library and metadata.
You’re finished with this lab. Please raise your hand and let the instructor
know you are finished with this lab.
55
More Notes…
Objectives
Objectives
C6000 Embedded Design Workshop Using BIOS - C6000 Hardware Interrupts (Hwi) 4-1
Module Topics
Module Topics
C6000 Hardware Interrupts (Hwi) ...........................................................................................................4-1
Module Topics..........................................................................................................................................4-2
System Concepts.......................................................................................................................................4-3
Remember Lab2B ? .............................................................................................................................4-3
McASP Overview ................................................................................................................................4-4
IDL Thread ..............................................................................................................................................4-5
Concepts ..............................................................................................................................................4-5
C64x+ Interrupts .....................................................................................................................................4-6
Interrupts – How they Work… ............................................................................................................4-6
HWI – Creation ...................................................................................................................................4-7
Reminder – Can Create via Static, Dynamic, CFG .............................................................................4-8
HWI – Interrupt Sources......................................................................................................................4-8
HWI – Example ISR ............................................................................................................................4-9
Interrupt Pre-emption ........................................................................................................................4-10
Event Combiner .................................................................................................................................4-10
Creating Custom Platforms ...................................................................................................................4-11
Chapter Quiz ..........................................................................................................................................4-13
Using Double Buffers .............................................................................................................................4-14
Lab 4: An Hwi-Based Audio System ......................................................................................................4-15
Lab 4 – Procedure ..............................................................................................................................4-16
Import Existing Project .................................................................................................................4-16
Application (Audio Pass-Thru) Overview.....................................................................................4-17
Source Code Overview..................................................................................................................4-17
More Detailed Code Analysis .......................................................................................................4-18
Creating A Custom Platform .........................................................................................................4-20
Add Hwi to the Project ..................................................................................................................4-22
Build, Load, Run. ..........................................................................................................................4-23
Debug Interrupt Problem ...............................................................................................................4-23
Other Debug/Analysis Items .........................................................................................................4-24
Conclusion ....................................................................................................................................4-25
That’s It. You’re Done!!................................................................................................................4-25
PART B (Optional) – Using the Profiler Clock .................................................................................4-26
Additional Information...........................................................................................................................4-27
Notes ......................................................................................................................................................4-30
4-2 C6000 Embedded Design Workshop Using BIOS - C6000 Hardware Interrupts (Hwi)
System Concepts
System Concepts
Remember Lab2B ?
C6000 Embedded Design Workshop Using BIOS - C6000 Hardware Interrupts (Hwi) 4-3
System Concepts
McASP Overview
4-4 C6000 Embedded Design Workshop Using BIOS - C6000 Hardware Interrupts (Hwi)
IDL Thread
IDL Thread
Concepts
C6000 Embedded Design Workshop Using BIOS - C6000 Hardware Interrupts (Hwi) 4-5
C64x+ Interrupts
C64x+ Interrupts
Interrupts – How they Work…
4-6 C6000 Embedded Design Workshop Using BIOS - C6000 Hardware Interrupts (Hwi)
C64x+ Interrupts
HWI – Creation
C6000 Embedded Design Workshop Using BIOS - C6000 Hardware Interrupts (Hwi) 4-7
C64x+ Interrupts
4-8 C6000 Embedded Design Workshop Using BIOS - C6000 Hardware Interrupts (Hwi)
C64x+ Interrupts
C6000 Embedded Design Workshop Using BIOS - C6000 Hardware Interrupts (Hwi) 4-9
C64x+ Interrupts
Interrupt Pre-emption
Event Combiner
Event Combiner (ECM)
Use only if you need more than 12 interrupt events
ECM combines multiple events (e.g. 4-31) into one event (e.g. EVT0)
EVTx ISR must parse MEVTFLAG to determine which event occurred
Interrupt
Occur? Care? Both Yes? Selector
EVTFLAG[0] EVTMASK[0] MEVTFLAG[0]
EVT 4-31 EVT0
EVT 4-127
25
4 - 10 C6000 Embedded Design Workshop Using BIOS - C6000 Hardware Interrupts (Hwi)
Creating Custom Platforms
C6000 Embedded Design Workshop Using BIOS - C6000 Hardware Interrupts (Hwi) 4 - 11
Creating Custom Platforms
4 - 12 C6000 Embedded Design Workshop Using BIOS - C6000 Hardware Interrupts (Hwi)
Chapter Quiz
Chapter Quiz
Chapter Quiz
1. What typically causes an interrupt from a peripheral?
3. Which parts of the INT sequence does BIOS handle vs. the user?
4. How do you create a new Hwi and what configuration options exist?
C6000 Embedded Design Workshop Using BIOS - C6000 Hardware Interrupts (Hwi) 4 - 13
Using Double Buffers
4 - 14 C6000 Embedded Design Workshop Using BIOS - C6000 Hardware Interrupts (Hwi)
Lab 4: An Hwi-Based Audio System
• isrAudio() – responds to McASP interrupt, read data from RCV XBUF – put in RCV
buffer, acquire data from XMT buffer, write to XBUF. When buffer is full, copy RCV to
XMT buffer. Repeat.
• FIR_process() – memcpy RCV to XMT buffer. Dummy “algo” for FIR later on…
C6000 Embedded Design Workshop Using BIOS - C6000 Hardware Interrupts (Hwi) 4 - 15
Lab 4: An Hwi-Based Audio System
Lab 4 – Procedure
If you can’t remember how to perform some of these steps, please refer back to the previous labs
for help. Or, if you really get stuck, ask your neighbor. If you AND your neighbor are stuck, then
ask the instructor (who is probably doing absolutely NOTHING important) for help.
To import the starter project, select the following and navigate to the \Lab4\Project folder:
Do NOT (we said NOT) copy the project into the workspace. This will cause some
referencing errors underneath the hood – not pretty. So, LEAVE THE FOLLOWING
CHECK BOX BLANK !!
3. Check the Properties to ensure you are using the latest XDC and BIOS.
For every imported project in this workshop, ALWAYS check to make sure the latest tools
(XDC and BIOS) are being used. The author created those projects at time “x” and then may
have updated the tools on your student PC at “x+1” – some time later – and didn’t redo every
starter project with the latest tools. Therefore, you may be importing a project that is NOT
using the latest versions of the tools (XDC and BIOS).
4 - 16 C6000 Embedded Design Workshop Using BIOS - C6000 Hardware Interrupts (Hwi)
Lab 4: An Hwi-Based Audio System
Several source files are needed to create this application. Let’s explore those briefly…
C6000 Embedded Design Workshop Using BIOS - C6000 Hardware Interrupts (Hwi) 4 - 17
Lab 4: An Hwi-Based Audio System
Notice that we have separate buffers for Ping and Pong for both RCV and XMT. Where is
BUFFSIZE defined? Main.h. We’ll see him in a minute.
As you go into main(), you’ll see the zeroing of the buffers to provide initial conditions of
ZERO. Think about this for a minute. Is that ok? Well, it depends on your system. If
BUFFSIZE is 256, that means 256 ZEROs will be transmitted to the DAC during the first
256 interrupts. What will that sound like? Do we care? Some systems require solid initial
conditions – so keep that in mind. We will just live with the zeros for now.
Then, you’ll see the calls to the init routines for the McASP and AIC3106. Previously, with
DSP/BIOS, this is where an explicit call to init interrupts was located. However, with
SYS/BIOS, this is done via the GUI. Lastly, there is a call to McASP_Start(). This is
where the McASP is taken out of reset and the clocks start operating and data starts being
shifted in/out. Soon thereafter, we will get the first interrupt.
4 - 18 C6000 Embedded Design Workshop Using BIOS - C6000 Hardware Interrupts (Hwi)
Lab 4: An Hwi-Based Audio System
C6000 Embedded Design Workshop Using BIOS - C6000 Hardware Interrupts (Hwi) 4 - 19
Lab 4: An Hwi-Based Audio System
Click Next.
4 - 20 C6000 Embedded Design Workshop Using BIOS - C6000 Hardware Interrupts (Hwi)
Lab 4: An Hwi-Based Audio System
When the new platform dialogue appears, click the IMPORT button to copy the seed file we
used before:
This will copy all of the initial default settings for the board and then we can modify them. A
dialogue box should pop up and select the proper seed file as shown (select the _TTO version
of the platform file that the author already created for you:
Modify the memory settings to allocate all code, data and stacks into internal memory
(IRAM) as shown. They may already be SET this way – just double check.
BEFORE YOU SAVE – HAVE THE INSTRUCTOR CHECK THIS FILE.
Then save the new platform. This will build a new platform package.
12. Tell the tools to use this new custom platform in your project.
We have created a new platform file, but we have not yet ATTACHED it to our project.
When the project was created, we were asked to specify a platform file and we chose the
default seed platform. How do we get back to the configuration screen?
Right-clickon the project and select Properties General and then select the RTSC tab.
Look near the bottom and you’ll see that the default seed platform is still specified. We need
to change this.
Click on the down arrow next to the Platform File. The tools should access your new
repository with your new custom platform file: evmc6748_student.
evmc6748_student
Select YOUR STUDENT PLATFORM FILE and click Ok. Now, your project is using the
new custom platform. Very nice…
C6000 Embedded Design Workshop Using BIOS - C6000 Hardware Interrupts (Hwi) 4 - 21
Lab 4: An Hwi-Based Audio System
Make sure “Enabled at startup” is NOT checked (this sets the IER bit on the
C6748). This will provide us with something to debug later. Once again, you can click on the
new HWI and see the corresponding Source script code.
4 - 22 C6000 Embedded Design Workshop Using BIOS - C6000 Hardware Interrupts (Hwi)
Lab 4: An Hwi-Based Audio System
Build and fix any errors. After a successful build, debug the application. Once the program is
loaded, click Run. Do you hear audio? If not, it’s debug time. One quick tip for debug is to
place a breakpoint in the isrAudio routine and see if the program stops there. If not, no
interrupt is being generated. Move on to the next steps to debug the problem…
Hint: The McASP on the C6748 cannot be restarted after a halt – i.e. you can’t just hit halt,
then Run. Once you halt the code, you must click the restart button and then Play.
C6000 Embedded Design Workshop Using BIOS - C6000 Hardware Interrupts (Hwi) 4 - 23
Lab 4: An Hwi-Based Audio System
So, try this now. Run your code and halt (pause). Run again. Do you hear audio? Nope. Click
the restart button and run again. Now it should work.
These will be handy tips for all lab steps now and in the future.
4 - 24 C6000 Embedded Design Workshop Using BIOS - C6000 Hardware Interrupts (Hwi)
Lab 4: An Hwi-Based Audio System
Conclusion
20. Use ROV to see Hwi status.
Run, then halt your code. Click on Hwi to see the status.
21. Conclusion – Hwi.
So, at this point, how many threads are running? 1 2 3 4
Which threads are active? Hwi Swi Task Idle
Which thread contains our algorithm? Hwi Swi Task Idle
Right now, we’re doing all of the work (algo) inside an interrupt service routine. Hwi’s
should only be used to read/write hard real-time registers (like the McASP). The
PROCESSING (our algo) should be handed off to the BIOS scheduler via a Swi or Task. This
allows the user to easily modify priorities and let the scheduler do its job effectively.
In this part of the lab, we simply added an Hwi thread to our system and configured it to call
the isrAudio() function. The two key pieces of information were the event id (for the
McASP event) and the CPU interrupt number (INT5 in our case). For each interrupt you have
in your system, you will need to create an Hwi instance and configure it.
In the next lab, we will offload the PROCESSING (algo) to a Swi and a Task – like we should
have. One step at a time.
Before you move on to the next chapter, what steps do you think are required to turn the
FIR_process() function into a Swi ?
RAISE YOUR HAND and get the instructor’s attention when you have
completed PART A of this lab. If time permits, you can quickly do the
next optional part…
C6000 Embedded Design Workshop Using BIOS - C6000 Hardware Interrupts (Hwi) 4 - 25
Lab 4: An Hwi-Based Audio System
In the bottom right-hand part of the screen, you should see a little CLK symbol that looks like
this:
Run to the first breakpoint, then double-click on the clock symbol to zero it. Run again and
the number of CPU cycles will display.
4 - 26 C6000 Embedded Design Workshop Using BIOS - C6000 Hardware Interrupts (Hwi)
Additional Information
Additional Information
C6000 Embedded Design Workshop Using BIOS - C6000 Hardware Interrupts (Hwi) 4 - 27
Additional Information
4 - 28 C6000 Embedded Design Workshop Using BIOS - C6000 Hardware Interrupts (Hwi)
Additional Information
C6000 Embedded Design Workshop Using BIOS - C6000 Hardware Interrupts (Hwi) 4 - 29
Notes
Notes
4 - 30 C6000 Embedded Design Workshop Using BIOS - C6000 Hardware Interrupts (Hwi)
Using Swi's and Tasks
Introduction
There is a “thread” of truth in this chapter – it’s all about thread types in SYS/BIOS. In the
previous chapter, we covered hardware interrupts (Hwi). In this chapter, you will learn how to
post a “follow up” activity as either a software interrupts (Swi) or a task (Tasks).
In the lab, you will modify your previous solution to use Swi’s and Tasks.
Objectives
Objectives
C6000 Embedded Design Workshop Using SYS/BIOS - Using Swi's and Tasks 5-1
Module Topics
Module Topics
Using Swi's and Tasks ................................................................................................................................5-1
Module Topics..........................................................................................................................................5-2
Using Swi .................................................................................................................................................5-3
Using Tasks ..............................................................................................................................................5-6
Using Semaphores ...................................................................................................................................5-9
Scheduler ...............................................................................................................................................5-11
Scheduling Strategies .............................................................................................................................5-12
Chapter Quiz ..........................................................................................................................................5-13
Lab 5: Using Swi’s and Tasks ................................................................................................................5-15
Lab 5A – Procedure – Using Swi ......................................................................................................5-16
Import Project – From Lab 5 .........................................................................................................5-16
Add a Swi to the System ...............................................................................................................5-16
Build, Load, Run. ..........................................................................................................................5-17
Inspect Your Code Using ROV .....................................................................................................5-17
Lab 5B – Procedure – Using Tasks and Semaphores ........................................................................5-18
Add a Task and Semaphore to the System ....................................................................................5-18
Build, Load, Run. ..........................................................................................................................5-19
Inspect Execution States Using ROV ............................................................................................5-19
That’s It. You’re Done !! ...................................................................................................................5-19
Notes ......................................................................................................................................................5-20
5-2 C6000 Embedded Design Workshop Using SYS/BIOS - Using Swi's and Tasks
Using Swi
Using Swi
C6000 Embedded Design Workshop Using SYS/BIOS - Using Swi's and Tasks 5-3
Using Swi
5-4 C6000 Embedded Design Workshop Using SYS/BIOS - Using Swi's and Tasks
Using Swi
C6000 Embedded Design Workshop Using SYS/BIOS - Using Swi's and Tasks 5-5
Using Tasks
Using Tasks
5-6 C6000 Embedded Design Workshop Using SYS/BIOS - Using Swi's and Tasks
Using Tasks
C6000 Embedded Design Workshop Using SYS/BIOS - Using Swi's and Tasks 5-7
Using Tasks
15
5-8 C6000 Embedded Design Workshop Using SYS/BIOS - Using Swi's and Tasks
Using Semaphores
Using Semaphores
C6000 Embedded Design Workshop Using SYS/BIOS - Using Swi's and Tasks 5-9
Using Semaphores
5 - 10 C6000 Embedded Design Workshop Using SYS/BIOS - Using Swi's and Tasks
Scheduler
Scheduler
C6000 Embedded Design Workshop Using SYS/BIOS - Using Swi's and Tasks 5 - 11
Scheduling Strategies
Scheduling Strategies
5 - 12 C6000 Embedded Design Workshop Using SYS/BIOS - Using Swi's and Tasks
Chapter Quiz
Chapter Quiz
Chapter Quiz
1. Compare and contrast Swi’s and Tasks:
4. What does Semaphore_post() do, where is this fxn call typically found?
C6000 Embedded Design Workshop Using SYS/BIOS - Using Swi's and Tasks 5 - 13
Chapter Quiz
*** SECURITY BREACH – Trojan Horse inserted this blank page… ***
5 - 14 C6000 Embedded Design Workshop Using SYS/BIOS - Using Swi's and Tasks
Lab 5: Using Swi’s and Tasks
C6000 Embedded Design Workshop Using SYS/BIOS - Using Swi's and Tasks 5 - 15
Lab 5: Using Swi’s and Tasks
This requires registering FIR_process() as a Swi and modifying isrAudio() to post it.
• Function: ________________
• Priority: 1
5 - 16 C6000 Embedded Design Workshop Using SYS/BIOS - Using Swi's and Tasks
Lab 5: Using Swi’s and Tasks
8. Modify main.h.
In main.h, there are two prototypes for FIR_process(). Again, uncomment the (void)
version and comment out the prototype for the one with 3 arguments.
Hint: When looking at dialogues that have columns like ROV, it is sometimes helpful to click
the Auto Fit Columns button. Why this isn’t the default is beyond me:
11. Conclusion
So, which threads are alive now? Hwi Swi Task Idle
Now we need to convert a Swi to a Task. What needs to be done to accomplish this?
swi_task.cfg changes:
_____________________________________________________
_____________________________________________________
C6000 Embedded Design Workshop Using SYS/BIOS - Using Swi's and Tasks 5 - 17
Lab 5: Using Swi’s and Tasks
Hint: When you are modifying the .cfg file and add or delete something, the tools will always
validate your selections. Sometimes, this can take time. The author would like to see a
beach ball or hourglass icon when this is going on, but that’s not a feature yet.
Sometimes, when you click again quickly, the tools aren’t DONE validating and it can
mess up your typing or delay your fast clicking. To see the validation process occurring,
look in the bottom right-hand portion of the screen:
5 - 18 C6000 Embedded Design Workshop Using SYS/BIOS - Using Swi's and Tasks
Lab 5: Using Swi’s and Tasks
You’re finished with this lab. Please raise your hand and let the instructor
know you are finished with this lab (maybe throw something heavy at them to
get their attention or say “CCS crashed – AGAIN !” – that will get them
running…)
C6000 Embedded Design Workshop Using SYS/BIOS - Using Swi's and Tasks 5 - 19
Notes
Notes
5 - 20 C6000 Embedded Design Workshop Using SYS/BIOS - Using Swi's and Tasks
Clock Functions & RTA Tools
Introduction
This chapter is all about the SYS/BIOS Clock module and Clock functions as well as exploring
stop-mode RTA tools like the Execution Graph and Logs.
.
Objectives
Objectives
C6000 Embedded Design Workshop Using SYS/BIOS - Clock Functions & RTA Tools 6-1
Module Topics
Module Topics
Clock Functions & RTA Tools ..................................................................................................................6-1
Module Topics..........................................................................................................................................6-2
Clock Functions .......................................................................................................................................6-3
Clock Module ......................................................................................................................................6-3
Using Clock Functions ........................................................................................................................6-4
Timestamp ...........................................................................................................................................6-5
Basic Debug Tools ...................................................................................................................................6-6
CCS Views ..........................................................................................................................................6-6
System_printf() ....................................................................................................................................6-6
RTOS Object Viewer (ROV)...............................................................................................................6-7
RTA Tools (Stop Mode) ............................................................................................................................6-8
RTA Agent ..........................................................................................................................................6-8
Logs .....................................................................................................................................................6-9
Execution Graph ................................................................................................................................6-10
CPU/Thread Loading.........................................................................................................................6-11
Chapter Quiz ..........................................................................................................................................6-12
Lab 6: Clock Functions & RTA Tools ....................................................................................................6-13
Lab 6 – Clock Fxns & RTA – Procedure...........................................................................................6-14
Import & Verify Existing Project ..................................................................................................6-14
Use Custom Platform Package From Previous Lab ......................................................................6-15
Add Periodic Clock Function – ledToggle() .................................................................................6-17
Build, Load and Run. ....................................................................................................................6-18
Configure Real-Time Analysis Tools – RTA Agent .....................................................................6-19
View Log Messages ......................................................................................................................6-20
Audio Problem – Explanation .......................................................................................................6-21
View Execution Graph ..................................................................................................................6-22
Audio Glitch ..................................................................................................................................6-23
Profling Code Segments – Using Timestamp_get32() ..................................................................6-26
That’s It. You’re Done !!! .............................................................................................................6-27
Additional Information & Notes ............................................................................................................6-28
6-2 C6000 Embedded Design Workshop Using SYS/BIOS - Clock Functions & RTA Tools
Clock Functions
Clock Functions
Clock Module
C6000 Embedded Design Workshop Using SYS/BIOS - Clock Functions & RTA Tools 6-3
Clock Functions
6-4 C6000 Embedded Design Workshop Using SYS/BIOS - Clock Functions & RTA Tools
Clock Functions
Timestamp
C6000 Embedded Design Workshop Using SYS/BIOS - Clock Functions & RTA Tools 6-5
Basic Debug Tools
System_printf()
6-6 C6000 Embedded Design Workshop Using SYS/BIOS - Clock Functions & RTA Tools
Basic Debug Tools
C6000 Embedded Design Workshop Using SYS/BIOS - Clock Functions & RTA Tools 6-7
RTA Tools (Stop Mode)
6-8 C6000 Embedded Design Workshop Using SYS/BIOS - Clock Functions & RTA Tools
RTA Tools (Stop Mode)
Logs
C6000 Embedded Design Workshop Using SYS/BIOS - Clock Functions & RTA Tools 6-9
RTA Tools (Stop Mode)
Execution Graph
6 - 10 C6000 Embedded Design Workshop Using SYS/BIOS - Clock Functions & RTA Tools
RTA Tools (Stop Mode)
CPU/Thread Loading
C6000 Embedded Design Workshop Using SYS/BIOS - Clock Functions & RTA Tools 6 - 11
Chapter Quiz
Chapter Quiz
Chapter Quiz
1. What is the clock module used for and how do you configure it?
4. Name the RTA Tools and the key module you MUST include in the
.cfg file for ANY RTA tool to work?
6 - 12 C6000 Embedded Design Workshop Using SYS/BIOS - Clock Functions & RTA Tools
Lab 6: Clock Functions & RTA Tools
C6000 Embedded Design Workshop Using SYS/BIOS - Clock Functions & RTA Tools 6 - 13
Lab 6: Clock Functions & RTA Tools
Make sure this project is active and the build configuration is set to Debug. Also, if TWO .cfg
files exist, erase app.cfg and KEEP clk_rta.cfg.
4. Check build properties to verify that the LATEST XDC/BIOS tools are selected.
6 - 14 C6000 Embedded Design Workshop Using SYS/BIOS - Clock Functions & RTA Tools
Lab 6: Clock Functions & RTA Tools
Right-click on the project and select Properties. Click on General and then click on the RTSC
tab – you should be familiar with this process by now.
We need to do two things: (1) ADD the repository; (2) select the custom platform package.
Look at the bottom of the screen and you’ll notice that the seed platform
(ti.platforms.evm6748) is being used in this project. We want to choose our custom
platform instead.
Click on the down arrow next to platform. Is your platform listed? Nope. The tools are
checking all of the tools paths you have checked up above – namely the XDC tools path for
platforms. Well, our platform repository isn’t listed there.
So, click the Add button on the right to add a repository and browse to the following:
\Labs\SYSBIOS_Platforms
Click OK.
C6000 Embedded Design Workshop Using SYS/BIOS - Clock Functions & RTA Tools 6 - 15
Lab 6: Clock Functions & RTA Tools
Make sure the checkbox next to this new repository is checked. Then, click on the down
arrow next to platforms and the tools will scan the new path and find the custom platform
package – evmc6748_student. Select that platform:
Click OK.
You have now added a “package” to your project – which is simply a custom platform
package. If, in the future, someone (or TI) delivers you a “package” (which is a library +
metadata), you now know how to add this package to your project and use it.
This simple click will build the project, launch the debugger session, connect to the target and
load your program. If there are build errors, CCS will “stop short” and not launch the
debugger.
Get some music playing and run the code. The audio should be working fine. This is the
Task-based audio application from the previous lab.
6 - 16 C6000 Embedded Design Workshop Using SYS/BIOS - Clock Functions & RTA Tools
Lab 6: Clock Functions & RTA Tools
In the Outline view, add a new Clock function with the following parameters (USE 2 ticks):
This creates a Clock object that will run ledToggle() every 2 ticks – or every 200ms –
since the tick rate is 100ms.
8. Inspect ledToggle().
Open led.c and inspect the ledToggle() function. We made a few changes from the
earlier version. First, we added a count value so that we could see how many times the LED
was toggled later when we debug our code. This information is sent to the RTA tools during
the Idle thread via the Log_info1() function call.
The other change was removing the half-second “delay” call to the BSL library. We no
longer need a “delay” because this function will run every 200ms.
C6000 Embedded Design Workshop Using SYS/BIOS - Clock Functions & RTA Tools 6 - 17
Lab 6: Clock Functions & RTA Tools
Circle the threads that are active now: Hwi Swi Task Idle
FYI. If you haven’t been circling Idle the past few times we’ve asked this question, you
should be. Idle is always active even if there is no explicit Idle function added to the system.
All runtime debug information (ROV and other RTA tools) is collected during the Idle thread
and then displayed to the user when the application halts.
Did you circle Swi? If not, well, you should have. What thread type is a Clock function? It is
a Swi.
How many Hwi’s are in the system? 1 2 3
Remember that the Clock Module in SYS/BIOS uses a hardware timer to create periodic
ticks. Every time a “tick” happens, a timer ISR is run to determine which of the Clock
functions should be executed. So, we’re getting a timer interrupt every 100ms and ledToggle
will run every 2 ticks.
So, right now, we have TWO Hwis (McASP interrupt, Timer interrupt), Swi
(ledToggleClock), Task (audio copy algo) and Idle (background, RTA). Wow, 5 threads
already. And who executes the threads in our application? The BIOS scheduler. Who sets the
priorities within each thread type? The user. More on that in a few more steps…
Rebuild your application and run again. Is the LED blinking now? It should be. If not, try to
debug the problem for a few minutes before asking your instructor.
11. Which interrupt is the Timer using?
Our target device (C6748) has 16 CPU interrupts. Which interrupt number is associated with
the hardware timer the Clock module is using? We know the McASP Hwi is using interrupt
#5. Which interrupt # is the timer using (check ROVHwi)?
_________
6 - 18 C6000 Embedded Design Workshop Using SYS/BIOS - Clock Functions & RTA Tools
Lab 6: Clock Functions & RTA Tools
This will allow us to see the Swi (ledToggleClock) interrupting our audio Task
(firProcessTask) in the execution graph. Also, adding the Agent to our project will
allow us to see the Log info that we sent inside the ledToggle() function.
Save clk_rta.cfg.
C6000 Embedded Design Workshop Using SYS/BIOS - Clock Functions & RTA Tools 6 - 19
Lab 6: Clock Functions & RTA Tools
Select Tools from the menu and open the RTA “Raw Logs” window:
Hint: In the current release of the tools, there is a small bug in the stop-mode RTA display. If
you halt your program and then open and RTA window, there is no “stop” (breakpoint) to
trigger the action of reading the data. You can simply hit the single-step button and then
the window will read the proper data. Another option is to open the window BEFORE
you click halt – as we are doing here.
Click Run, wait a few seconds, then click halt. What you see are ALL of the Log messages
being sent to the logger object. This includes a bunch of SYSBIOS logs you may not be
interested in.
How can we see JUST the stuff WE want? Wow that is selfish. So be it. In the right-hand
portion of the Raw Logs window, do you see the dropdown where it says “All Log Buffers” ?
Select “Main Logger” in that window to only show the Log info from our ledToggle()
function:
Now you can see the messages from our ledToggle() function:
6 - 20 C6000 Embedded Design Workshop Using SYS/BIOS - Clock Functions & RTA Tools
Lab 6: Clock Functions & RTA Tools
You should be hearing a small to medium disruption in the audio stream. You may need to
play “lighter” music to hear it. Rock music will probably mask the disruption. When you
play the audio, watch the LED blinking – does the disruption correlate to the LED blink?
Yep.
Houston, we have a problem. Over the next few steps, we’ll investigate this problem further
by using some of our RTA tools – namely the Execution Graph.
Our two main threads are the audio processing Task and the blinking of the LED (Clock).
So, our LED toggle routine is HIGHER priority than the audio processing. That’s not a good
thing – unless you want your audio to sound glitchy. Would checking a user input button
every 200ms be more important than the MP3 algo itself? Nope.
Jot down a few notes indicating how YOU would solve this problem…
______________________________________________________________
______________________________________________________________
C6000 Embedded Design Workshop Using SYS/BIOS - Clock Functions & RTA Tools 6 - 21
Lab 6: Clock Functions & RTA Tools
BEFORE YOU RUN, open the Execution Graph window (Note: RTA tools need a “trigger”
like a breakpoint to occur when the window is OPEN to display the data you want. If you
forget to open the window first, simply clicking “single step” might help). Then click Run,
wait a few seconds, then halt. Make sure you increae the vertical size so that you can see the
Legend.
The execution graph shows exact timing of events within the system. Zoom in/out and go
left/right so that you find an area of the graph similar to this screen shot. You can hold down
[Alt] and drag an area to zoom in on specifically:
Let’s dissect this graph piece by piece (your colors may vary):
• The first thick line is the Idle thread. When nothing else is running, Idle is executed.
• Notice when the BIOS Scheduler runs. Very cool.
• FIR_process() fxn is shown on the bottom of this graph and contains our algo (copy
function) which occurs when the audio buffers fill up – it is periodic. An Hwi (not
shown) posts the semaphore – which you can see and unblocks the FIR_process()
function to run (you can also see the unblocking flag).
• Every 100ms, the Clock module interrupts the system with the timer interrupt – the
second long thick line in the graph above – again, periodic. Every 2 times the clock
function runs, the ledToggle() function runs.
6 - 22 C6000 Embedded Design Workshop Using SYS/BIOS - Clock Functions & RTA Tools
Lab 6: Clock Functions & RTA Tools
When you click on this button, you will then be able to “lay down” a starting point for the
time measurement. Place the first line at the beginning of the ledToggle fxn starting to run.
Click this button again and place the other vertical measurement marker at the end of the
ledToggle audio-killer.
Notice you now have two markers (X1 and X2). Look in the upper left-hand part of the
window to see the measurement:
So, this ledToggle() routine takes 10.6 million nanoseconds. Pull out the calculator,
attempt to find the engineering notation button, check the calculator user guide for some help,
etc, then finally realize the answer is: 10.7ms. Holy “audio-killer” batman. That is a LONG
routine – as we can observe in the Execution Graph.
What is the time between periodic ticks? (of the Clk fxn): ______________ns
What is the time between audio frames being processed? ______________ns
These are very handy tools for debug – not only the visual for the thread scheduling but also
being able to measure times between events and events themselves.
Audio Glitch
18. Audio Glitch – Solution - Discussion.
So, how would fix this problem?
Hopefully you came up with an idea or two earlier. Here’s a hint…
ledToggle() is currently running as a Swi. How can we run it as a Task? Sure. Here’s the
procedure to do this:
• Turn ledToggle() into a Task.
• Have the periodic clock function call a “helper function” (Swi) that posts a semaphore to
unblock the new ledToggle() Task. So, the Swi is very short instead of spending all those
cycles toggling the LED.
• Last item is priority. Set the audio Task at a higher priority than the new ledToggle Task.
• Rebuild, load, run.
So, let’s go do it !
C6000 Embedded Design Workshop Using SYS/BIOS - Clock Functions & RTA Tools 6 - 23
Lab 6: Clock Functions & RTA Tools
In led.c:
• Add a while(1) loop and a Semaphore_pend to the ledToggle() function – just
like you did for FIR_process() in the previous lab.
• At the bottom of the file, uncomment the “helper” function ledTogglePost() and
modify the Semaphore name.
In rta.cfg:
• Create a new Task named ledToggleTask. Point this Task object to the proper
function (ledToggle) and give it priority #1. Is ledToggle() the proper function?
• Create a Semaphore named LedToggleSem.
• Modify Clock Function to call the ledTogglePost (Swi) helper function.
• Make sure firProcessTask is at priority #2 (higher than ledToggleTask).
We will hopefully be able to see this in action once we rebuild, run and view the Execution
Graph.
6 - 24 C6000 Embedded Design Workshop Using SYS/BIOS - Clock Functions & RTA Tools
Lab 6: Clock Functions & RTA Tools
As you can see, the FIR_process() function preempts the ledToggle() function and
you hear almost no noise in the system. Any noise left is simply an issue of the I2C channel
being driven on board – those LED and other BSL functions are NOT tuned for pure audio –
they are only used for proving board connectivity.
23. View Execution Graph options.
Right-click on the graph and view the options like “deleting measurement markers”.
24. See Raw Logs synced with the Execution Graph.
Open the Raw Logs window and click on a point in the graph OR the log – you will see that
the log window and execution graph are SYNCED with each other. Right-click on the Logs
window and DETACH so you can see them at the same time. Then click. Very nice.
25. View the CPU and Thread Loading.
Open the CPU and Thread Load Graph windows. Your CPU load should be around 40% and
you can see two threads in the Thread Load graph. If these windows don’t have any data in
them, reload your program, run for a few seconds and halt.
26. Add “dynamic view” of CPU load to your code.
Really? We can determine our CPU load when we’re running our code? That’s a great debug
tool and might be handy in our main production code also.
Open led.c and add the following two lines of code as shown. The declaration for
cpu_load should already be near the top of ledToggle() – just uncomment it:
C6000 Embedded Design Workshop Using SYS/BIOS - Clock Functions & RTA Tools 6 - 25
Lab 6: Clock Functions & RTA Tools
6 - 26 C6000 Embedded Design Workshop Using SYS/BIOS - Clock Functions & RTA Tools
Lab 6: Clock Functions & RTA Tools
Yes, this is a long function – hey, it’s BSL code – not meant to be efficient. But, the point
here is that you gained the skill of learning how to profile code in real-time and see it in a
Log message.
Ok, so we got 10.7ms when we measured ledToggle with the Execution Graph markers, but
only 3.2M cycles when we profiled it with Timestamp. Do these numbers jive? Well, if the
target device (6748) is running at 300Mhz, one cycle is 3.3ns. 3.3ns * 3.2M cycles = 10.6ms.
Hey, they do match.
So, the key thing to remember is that the Execution Graph shows benchmarks in
NANOSECONDS. The benchmarking with Timestamp_get32() provides results in CYCLES.
You’re finished with this lab. Take a break, you’ve earned it. If you’re the first
one done, gloat a bit. If you’re the last one done, tell everyone you did all of
the “optional labs” at the end and watch them squirm because they didn’t
“see them”. Then smile and take your seat.
C6000 Embedded Design Workshop Using SYS/BIOS - Clock Functions & RTA Tools 6 - 27
Additional Information & Notes
6 - 28 C6000 Embedded Design Workshop Using SYS/BIOS - Clock Functions & RTA Tools
Inter-thread Communication
Introduction
This chapter covers the basics of inter-thread communication – the multiple ways to pass data
from one thread to another and also synchronize threads through the use of Mutexs and Events.
Several other communication methods are discussed as well as shown below…
.
Objectives
Objectives
Module Topics
Inter-thread Communication ....................................................................................................................7-1
Module Topics..........................................................................................................................................7-2
Overview of the Problem..........................................................................................................................7-3
Producer – Consumer Model ...................................................................................................................7-4
Introduction .........................................................................................................................................7-4
Events ..................................................................................................................................................7-5
Queues .................................................................................................................................................7-6
Mailboxes ............................................................................................................................................7-7
Advanced Issue-Reclaim Services .......................................................................................................7-8
Concurrent Access Model ........................................................................................................................7-9
Introduction .........................................................................................................................................7-9
Using Globals ....................................................................................................................................7-10
Critical Resource Protection (Enter/Exit Gates) ................................................................................7-10
Modifying Scheduler Behavior..........................................................................................................7-11
Using MUTEXs .................................................................................................................................7-11
Shared Semaphores (Semaphore Queue) ...........................................................................................7-12
Priority Inversion ...............................................................................................................................7-12
Modifying Task Priority Using Task_setPri() ...................................................................................7-13
Using MUTEX Gates ........................................................................................................................7-13
Understanding Deadlock ...................................................................................................................7-14
Threads at SAME Priority......................................................................................................................7-15
Chapter Quiz ..........................................................................................................................................7-16
Additional Information...........................................................................................................................7-17
Notes ......................................................................................................................................................7-18
Yes, BIOS can help...but let's first look at the types of "sharing" that are possible...
Thread A Msg
Thread B
BIOS “Container”
• Thread A produces a buffer or Msg and places it in a container.
• Thread B blocks until it is available, then consumes it when signaled (no contention)
• Data communication is achieved using BIOS “containers” (objects)
• Any thread could access “Resource” at any time (no structured protocol or container)
• Pre-emption of one thread by another can cause contention or priority inversion
Advantages:
Both threads use same protocol – contention is often avoided
Threads become more “modular” and therefore reuse improves
Examples:
BIOS: Queue, Mailbox, Stream I/O
May have built-in synchronization or user can add signaling via
Semaphores and Events (discussed next…)
8
Events
Other APIs, as shown above, can also post events – implicitly – the
eventId is part of the params structure:
Specify Event
Id here…
Queues
Queue Concepts…
Queue
A Queue is a BIOS object that can contain anything you like
“Data” is called a “Msg” and is simply a structure defined by the user
Msgs are “reclaimed” on a FIFO basis
Key APIs:
Queue_put();
Queue_get();
Synchronizing Queues…
Queue
TALKER LISTENER
Queue_put(&myQ, msg); Semaphore_pend(&Sem, -1);
Semaphore_post(&Sem); msg = Queue_get(&myQ);
Note: “Queue+Sem” is the basis for how “streams” are built to interface with I/O drivers –
e.g. Platform Support Package (PSP) drivers from TI. (More in a later chapter…)
Mailboxes
Using Mailboxes
Mailbox
Mailboxes – a fixed-size BIOS Object that can contain anything you like
Fixed length defined by:
• Number of Msgs (length of mailbox)
• Message Size (MAUs)
Key APIs (both can block):
Mailbox_post (&Mbx, &Msg, timeout); // blocks if full
Mailbox_pend (&Mbx, &Mail, timeout); // blocks if empty
Advantages: simple FIFO, easy to use, contains built-in semaphore for signaling
Disadvantage: copy-based (both reader/writer own a copy) – best if used to pass
pointers or small Msgs
Advanced producer/consumer uses...
17
How it Works:
Data is “up for grabs” – often first-come, first-serve
User must add “protection” to avoid contention between different priority threads
Advantages:
Common usage – many systems use MUTEXs for resource protection
Disadvantages:
MUTEXs can cause priority inversion or deadlock – both ugly scenarios
Modifying scheduler behavior (e.g. disabling INTs) can cause jitter in the system
Examples:
BIOS: Scheduler Mgmt, Gates, MUTEX (Semaphore), Task_setPri
Note: watch out for “globals” accessed by multiple threads w/no protection…
Using Globals
Thread
CRITICAL SECTION
Task
CRITICAL SECTION
MUTEXs, between Tasks, could also be used during Enter/Exit
What other forms of “protection” exist? 24
26
Using MUTEXs
Using MUTEXs
Thread A Data Thread B
Shared Semaphores…
INT! post
Hwi
Enter (pend)
INT!
BLOCKED !! ACCESS
TSK Hi
Enter (pend) Exit (post)
block ACCESS
TSK Lo
Therefore, TSK Lo runs first. This is ok, but CAN lead to priority inversion…
What if some TSK MEDiums were living in the system?
29
Priority Inversion
Priority Inversion
INT! Post (sems)
Hwi
Enter (pend)
INT!
BLOCKED !!
TSK Hi
RUN !
TSK MED
Enter (pend)
block
TSK Lo
TSK MED (and all other priorities between Hi and Lo) get to RUN first
Then, TSK Lo runs before TSK Hi because Lo pended on Sem first
TSK Hi is VERY FRUSTRATED
What could you do with TSK Lo’s priority just
before the “Enter” to avoid this priority inversion?
30
Hwi
INT!
Ready Running (data access) !!
TSK Hi
Enter - setPri(Hi) Exit - setPri(Lo)
data access pre-empted
TSK Lo
TSK Lo can elevate its priority just before data access and then
lower its priority just after data access using: Task_setPri();
Advantage: no semaphore/mutex required !
Mutex Priority Gates can come in handy for situations like this…
31
Understanding Deadlock
35
Chapter Quiz
Chapter Quiz
1. Name the two basic data sharing models and examples of each:
4. What problems can occur when using MUTEX’s, what is the sol’n?
Additional Information
QUE API Summary
QUE API Description
QUE_put Add a message to end of queue – atomic write
QUE_get Get message from front of queue – atomic read
QUE_enqueue Non-atomic QUE_put
QUE_dequeue Non-atomic QUE_get
QUE_head Returns ptr to head of queue (no de-queue performed)
QUE_empty Returns TRUE if queue has no messages
QUE_next Returns next element in queue
QUE_prev Returns previous element in queue
QUE_insert Inserts element into queue in front of specified element
QUE_remove Removes specified element from queue
QUE_new ….
QUE_create Create a queue
Mod 10
QUE_delete Delete a queue
Notes
Objectives
Objectives
C6000 Embedded Design Workshop Using SYS/BIOS - Using Dynamic Memory 8-1
Module Topics
Module Topics
Using Dynamic Memory ............................................................................................................................8-1
Module Topics..........................................................................................................................................8-2
Static vs. Dynamic ....................................................................................................................................8-3
Memory Policies ..................................................................................................................................8-3
Dynamic Memory Concepts .....................................................................................................................8-4
Using Dynamic Memory .....................................................................................................................8-4
Creating A Heap ..................................................................................................................................8-6
Different Types of Heaps..........................................................................................................................8-7
HeapMem ............................................................................................................................................8-7
HeapBuf...............................................................................................................................................8-8
HeapMultiBuf ......................................................................................................................................8-9
Default System Heap .........................................................................................................................8-10
Dynamic Module Creation .....................................................................................................................8-11
Using Error Block..............................................................................................................................8-12
Memory/Section Placement (Fine Tuning) ............................................................................................8-13
Chapter Quiz ..........................................................................................................................................8-14
Lab 8 – Using Dynamic Memory ...........................................................................................................8-15
Lab 8 – Using Dynamic Memory – Procedure .................................................................................8-16
Create Project & View New Items ................................................................................................8-16
Modify Platform ............................................................................................................................8-17
Inspect New Dynamic Code ..........................................................................................................8-17
Create ledToggle Task and Semaphore Dynamically ...................................................................8-19
Exploring the HEAP......................................................................................................................8-20
Build, Load, Run. ..........................................................................................................................8-20
Create firProcessTask and mcaspReady Dynamically ..................................................................8-21
Build, load and Run.......................................................................................................................8-21
That’s It. You’re Done !!...............................................................................................................8-21
Notes ......................................................................................................................................................8-22
8-2 C6000 Embedded Design Workshop Using SYS/BIOS - Using Dynamic Memory
Static vs. Dynamic
Memory Policies
C6000 Embedded Design Workshop Using SYS/BIOS - Using Dynamic Memory 8-3
Dynamic Memory Concepts
Delete free(x);
free(a);
8-4 C6000 Embedded Design Workshop Using SYS/BIOS - Using Dynamic Memory
Dynamic Memory Concepts
C6000 Embedded Design Workshop Using SYS/BIOS - Using Dynamic Memory 8-5
Dynamic Memory Concepts
Creating A Heap
8-6 C6000 Embedded Design Workshop Using SYS/BIOS - Using Dynamic Memory
Different Types of Heaps
HeapMem
C6000 Embedded Design Workshop Using SYS/BIOS - Using Dynamic Memory 8-7
Different Types of Heaps
HeapBuf
8-8 C6000 Embedded Design Workshop Using SYS/BIOS - Using Dynamic Memory
Different Types of Heaps
HeapMultiBuf
C6000 Embedded Design Workshop Using SYS/BIOS - Using Dynamic Memory 8-9
Different Types of Heaps
GUI
CFG script
32
33
Chapter Quiz
Chapter Quiz
1. Compare/Contrast static/dynamic memory use and when to use each:
4. Can you create BIOS threads and modules during runtime? If so, how?
So, it’s been awhile – do you remember how? Name the project “dyn_audio” and create
the project in the above folder. As a reminder, don’t forget the following steps:
Modify Platform
3. Ensure you are using the correct platform.
Access the RTSC configuration via Properties General RTSC tab. If the custom
platform repository (\Labs\SYSBIOS_Platforms) is not added to the list (beneath
XDAIS), add it. If it is there, change the platform file to the one you created in the previous
labs (the STUDENT version) – the one that places all code/data/stacks in IRAM.
Hint: The Logic PD BSL functions that use I2C (namely LED, DIP, etc) are so inefficient that
they have a hard time running reliably out of DDR. This is why we keep using IRAM vs.
DDR in the platform once we added those capabilities.
Near the top of the file, observe the following globals for the Task and Semaphore handles:
They are currently commented out, but we will “uncomment” them as the need arises.
This is where all the action is. This code is NOT COMPLETE. Most of it is there, but you’ll
need to edit some of it and uncomment lines of code as the lab progresses.
The first two chunks of code create the Semaphore and Task for ledToggle.
The 2nd two pieces of code do the same for our FIR_process() function and Semaphore.
What we plan to do is ONE AT A TIME. We’ll get the ledToggle working dynamically
first, then do the same thing for FIR_process and mcaspReady.
6. Inspect main.h.
The only items in main.h are the externs for the global variables:
8. Edit main.c and uncomment code to create ledToggle Task and Semaphore.
Open main.c and uncomment the global declarations for ledToggleTask and
ledToggleSem. These create our handles to these two objects.
This creates a structure called taskParams that holds the parameters for a Task – namely
priority and other items you can set dynamically. We will use it in this lab only to set priority.
Next, uncomment the line of code that creates ledToggleSem. Modify the name “Sem” to
use the proper name. We are setting the initial semaphore count to 0.
Now, uncomment the three lines of code that create ledToggleTask. Modify the priority
number and name of the function that this Task object is pointing to. If you can’t figure this
out, just think about what you used in the STATIC configuration – it’s the same stuff.
9. Open main.h and uncomment a few lines.
In main.h, uncomment the two externs for ledToggleSem and ledToggleTask.
This is where the default heap size is set – 4K or 0x1000. Up above, you’ll notice that the
default instance creation is set to dynamic creation and deletion – which ALSO supports
static configuration. In the author’s opinion, there is never a need to change this – even if
you’re static only – like we have been until this lab.
So, when we look at ROV shortly, we’ll see the Heap size at 0x1000 and, if things work
properly, we should see some of that heap used for our dynamic Task and Semaphore we
created.
Hint: In the current tools shipped with CCS5.1, you can also see the Heap size listed under the
Program module. It is always ZERO and does NOT reflect the setting under BIOS
Runtime. This can be confusing to new users. So, just stick with the BIOS module in
the Outline View for heaps and you’re fine. Just FYI…
Notice anything alarming about these sizes? ___________________ Ok. So we now proved
that the heap is being used for our stuff. Let’s do it again with FIR_process()…
You’re finished with this lab. RAISE YOUR HAND AND SAY “DONE !!” so
the instructor knows – thanks. If the instructor pays you no attention or acts
like he doesn’t care, make sure you note that on the review form later.
Notes
Outline
Objectives
C6000 Embedded Design Workshop Using BIOS - C64x+/C674x+ CPU Architecture 9-1
Module Topics
Module Topics
C64x+/C674x+ CPU Architecture .............................................................................................................9-1
Module Topics..........................................................................................................................................9-2
C64x+ CPU Architecture ........................................................................................................................9-3
What Does a DSP Do?.........................................................................................................................9-3
CPU – From the Inside…Out ..............................................................................................................9-4
Instruction Sets ......................................................................................................................................9-10
“MAC Instructions”...............................................................................................................................9-12
C66x MAC Instructions (whoa !) ...........................................................................................................9-14
Hardware Pipeline .................................................................................................................................9-15
Software Pipelining ................................................................................................................................9-16
Instruction Delays ..............................................................................................................................9-16
Scheduling an Algorithm ...................................................................................................................9-16
Resulting Pipelined Code… ..............................................................................................................9-17
Chapter Quiz ..........................................................................................................................................9-18
9-2 C6000 Embedded Design Workshop Using BIOS - C64x+/C674x+ CPU Architecture
C64x+ CPU Architecture
C6000 Embedded Design Workshop Using BIOS - C64x+/C674x+ CPU Architecture 9-3
C64x+ CPU Architecture
9-4 C6000 Embedded Design Workshop Using BIOS - C64x+/C674x+ CPU Architecture
C64x+ CPU Architecture
C6000 Embedded Design Workshop Using BIOS - C64x+/C674x+ CPU Architecture 9-5
C64x+ CPU Architecture
9-6 C6000 Embedded Design Workshop Using BIOS - C64x+/C674x+ CPU Architecture
C64x+ CPU Architecture
C6000 Embedded Design Workshop Using BIOS - C64x+/C674x+ CPU Architecture 9-7
C64x+ CPU Architecture
9-8 C6000 Embedded Design Workshop Using BIOS - C64x+/C674x+ CPU Architecture
C64x+ CPU Architecture
C6000 Embedded Design Workshop Using BIOS - C64x+/C674x+ CPU Architecture 9-9
Instruction Sets
Instruction Sets
“MAC Instructions”
single .M unit
Hardware Pipeline
Software Pipelining
Instruction Delays
Scheduling an Algorithm
Chapter Quiz
Chapter Quiz
1. Name the four functional units and types of instructions they execute:
2. How many 16x16 MACs can a C674x CPU perform in 1 cycle? C66x ?
3. Where are CPU operands stored and how do they get there?
5. What is the purpose of s/w pipelining, which tool does this for you?
Outline
Objectives
Module Topics
C and System Optimizations ...................................................................................................................10-1
Module Topics........................................................................................................................................10-2
Introduction – “Optimal” and “Optimization” .....................................................................................10-3
C Compiler and Optimizer .....................................................................................................................10-5
“Debug” vs. “Optimized” ..................................................................................................................10-5
Levels of Optimization ......................................................................................................................10-6
Build Configurations .........................................................................................................................10-7
Code Space Optimization (–ms) ........................................................................................................10-7
File and Function Specific Options ...................................................................................................10-8
Coding Guidelines .............................................................................................................................10-9
Data Types and Alignment ...................................................................................................................10-10
Data Types .......................................................................................................................................10-10
Data Alignment ...............................................................................................................................10-11
Using DATA_ALIGN .....................................................................................................................10-12
Upcoming Changes – ELF vs. COFF ..............................................................................................10-13
Restricting Memory Dependencies (Aliasing)......................................................................................10-14
Access Hardware Features – Using Intrinsics .....................................................................................10-16
Give Compiler MORE Information ......................................................................................................10-17
Pragma – Unroll() ............................................................................................................................10-17
Pragma – MUST_ITERATE() .........................................................................................................10-18
Keyword - Volatile ..........................................................................................................................10-18
Setting MAX interrupt Latency (-mi option) ...................................................................................10-19
Compiler Directive - _nassert() .......................................................................................................10-20
Using Optimized Libraries ...................................................................................................................10-21
Libraries – Download and Support ..................................................................................................10-23
System Optimizations ...........................................................................................................................10-24
BIOS Libraries.................................................................................................................................10-24
Custom Sections ..............................................................................................................................10-26
Use Cache ........................................................................................................................................10-27
Use EDMA ......................................................................................................................................10-28
System Architecture – SCR .............................................................................................................10-29
Chapter Quiz ........................................................................................................................................10-30
Lab 10 – C Optimizations ....................................................................................................................10-31
Lab 10 – C Optimizations – Procedure................................................................................................10-32
PART A – Goals and Using Compiler Options ...............................................................................10-32
Determine Goals and CPU Min...................................................................................................10-32
Using Debug Configuration (–g, NO opt) ...................................................................................10-33
Using Release Configuration (–o2, no –g) ..................................................................................10-34
Using “Opt” Configuration .........................................................................................................10-36
Part B – Code Tuning ......................................................................................................................10-38
Part C – Minimizing Code Size (–ms) .............................................................................................10-41
Part D – Using DSPLib ...................................................................................................................10-42
Conclusion .......................................................................................................................................10-43
Additional Information.........................................................................................................................10-44
Y = Σ coeffi * xi
for (i = 0; i < count; i++){
Y += coeff[i] * x[i]; }
i = 1
Goals:
A typical goal of any system’s algo is to meet real-time
You might also want to approach or achieve “CPU Min” in
order to maximize #channels processed
CPU Min (the “limit”):
The minimum # cycles the algo takes based on architectural
limits (e.g. data size, #loads, math operations required)
Benchmarks:
Algo FIR (256, 64) DOTP (256-term)
Debug (no opt, –g) 817K 4109
“Opt” (-o3, no –g) 18K 42
Add’l pragmas 7K 42
(DSPLib) 7K 42
CPU Min 4096 42
Debug – get your code LOGICALLY correct first (no optimization)
“Opt” – increase performance using compiler options (easier)
“CPU Min” – it depends. Could require extensive time… 10
Levels of Optimization
Levels of Optimization
FILE1.C -o0, -o1 -o2 -o3 -pm -o3
{
{ LOCAL
single block
}
FUNCTION
{ across
... blocks
FILE
} across
} functions PROGRAM
across files
{
. . . Increasing levels of opt:
} • scope, code motion
• build times
FILE2.C
{ • visibility
. . .
}
12
Build Configurations
Coding Guidelines
T TO
Technical Training
Organization 22
Data Alignment
Using DATA_ALIGN
Aliasing?
What happens if the function is void fcn(*in, *out)
called like this? {
fcn(*myVector, *myVector+1) LDW *in++, A0
ADD A0, 4, A1
STW A1, *out++
in }
a in + 4
• Definitely Aliased pointers
• *in and *out could point to
b the same address
Pragma – Unroll()
Pragma – MUST_ITERATE()
4. MUST_ITERATE(min, max, %factor)
#pragma UNROLL(2);
#pragma MUST_ITERATE(10, 100, 2);
for(i = 0; i < count ; i++) {
sum += a[i] * x[i];
}
Keyword - Volatile
-mi Details
-mi0
Compiler’s code is not interruptible
User must guarantee no interrupts will occur
-mi1
Compiler uses single assignment and never produces a loop
less than 6 cycles
-mi1000 (or any number > 1)
Tells the compiler your system must be able to see interrupts
every 1000 cycles
When not using –mi (compiler’s default)
Compiler will software pipeline (when using –o2 or –o3)
Interrupts are disabled for s/w pipelined loops
Notes:
Be aware that the compiler is unaware of issues such as memory
wait-states, etc.
Using –mi, the compiler only counts instruction cycles
56
MUST_ITERATE Example
int dot_prod(short *a, Short *b, int n)
{
int i, sum = 0;
#pragma MUST_ITERATE ( ,512)
for (i = 0; i < n; i++)
sum += a[i] * b[i];
return sum;
}
Provided:
If interrupt threshold was set at 1000 cycles (-mi 1000),
Assuming this can compile as a single-cycle loop,
And 512 = max# for Loop count (per MUST_ITERATE pragma).
Result:
The compiler knows a 1-cycle kernel will execute no more than 512 times
which is less than the 1000 cycle interrupt disable option (–mi1000)
Uninterruptible loop works fine
Verdict:
3072 cycle loop (512 x 6) can become a 512 cycle loop
T TO
Technical Training
Organization 57
System Optimizations
BIOS Libraries
Custom Sections
Use Cache
Use EDMA
DMA QDMA
Enhanced DMA (version 3) Quick DMA
DMA to/from peripherals DMA between memory
Can be sync’d to peripheral events Async – must be started by CPU
Handles up to 64 events 4-8 channels available
HPI Utopia
EMAC
Chapter Quiz
Chapter Quiz
1. How do you turn ON the optimizer ?
Lab 10 – C Optimizations
In the following lab, you will gain some experience benchmarking the use of optimizations using
the C optimizer switches. While your own mileage may vary greatly, you will gain an
understanding of how the optimizer works and where the switches are located and their possible
affects on speed and size.
Can anyone say “heck no”. The audio sounds terrible. We have failed to meet our only real-
time goal.
But hey, it’s using the Debug Configuration. And if we wanted to single step our code, we
can. It is a very nice debug-friendly environment – although the performance is abysmal. This
is to be expected.
My goodness – a number WELL greater than zero. We are definitely not meeting realtime.
9. View Debug compiler options.
FYI – if you looked at the options for the Debug configuration, you’d see the following:
Full symbolic debug is turned on and NO optimizations. Ok, nice fluffy debug environment
to make sure we’re getting the right answers, but not good enough to meet realtime. Let’s
“kick it up a notch”…
Check Properties Include directory. Make sure the BSL \inc folder is specified.
Also, double-check your PLATFORM file. Make sure all code/data/stacks are in internal
memory and that your project is USING the proper platform in this NEW build configuration.
Once again, these configurations are containers of options. Even though Debug had the
proper platform file specified, Release might NOT !!
Ok, now we’re talkin’ – it went from 913K to 37K – just by switching to the release
configuration. So, the bottom line is TURN ON THE OPTIMIZER !!
13. Study release configuration build properties.
Here’s a picture of the build options for release:
Click New:
(also note the Remove button – where you can delete build configurations).
Give the new configuration a name: “Opt” and choose to copy the existing configuration
from “Release”. Click Ok.
15. Change the “Opt” build properties to use –o3 and NO –g (the “blank” choice).
The only change that needs to be made is to turn UP the optimization level to –o3 vs. –o2
which was used in the Release Configuration. Also, make sure –g is turned OFF (which it
should already be).
Open the “Opt” Config Build Properties and verify it contains NO –g (blank) and
optimization level of –o3.Rebuild your code and benchmark (FYI – LED may stop
blinking…don’t worry).
Follow the same procedure as before to benchmark cfir:
The author’s number was about 18K cycles – another pretty significant performance increase
over –o2, -g. We simply went to –o3 and killed –g and WHAM, we went from 37K to 18K.
This is why the author has stated before that the Opt settings we used in this lab SHOULD be
the RELEASE settings. But I am not king.
So, as you can see, we went from 913K to 18K in about 30 minutes. Wow. But what was the
CPU Min? About 7K? Ok…we still have some room for improvement…
Just for kicks and grins, try single stepping your code and/or adding breakpoints in the middle
of a function (like cfir). Is this a bit more difficult with –g turned OFF and –o3 applied? Yep.
With –g turned OFF, you still get symbol capability – i.e. you can enter symbol names
into the watch and memory windows. However, it is nearly impossible to single step C
code – hence the suggestion to create test vectors at function boundaries to check the
LOGICAL part of your code when you build with the Debug Configuration. When you
turn off –g, you need to look at the answers on function boundaries to make sure it is
working properly.
16. Turn on verbose and interlist – and then see what the .asm file looks like for fir.asm.
As noted in the discussion material, to “see it all”, you need to turn on three switches. Turn
them on now, then build, then peruse the fir.asm file. You will see some interesting
information about software pipelining for the loops in fir.c.
Turn on:
• RunTime Model Options → Verbose pipeline info (-mw)
The author’s results were close to the previous results – about 15K. Well, this code tuning
didn’t help THIS algo much, but it might help yours. At least you know how to apply it now.
18. Use restrict keyword on the results array.
You actually have a few options to tell the compiler there is NO ALIASING. The first
method is to tell the compiler that your entire project contains no aliasing (using the –mt
compiler option). However, it is best to narrow the scope and simply tell the compiler that the
results array has no aliasing (because the WRITES are destructive, we RESTRICT the output
array).
So, in fir.c, add the following keyword (restrict) to the results (r) parameter of the fir
algorithm as shown:
Build, then run again. Now benchmark your code again. Did it improve?
Well, getting rid of ALIASING was a big help to our algo. We went from about 15K down to 7K
cycles. You could achieve the same result by using “-mt” compiler switch, but that tells the
compiler that there is NO aliasing ANYWHERE – scope is huge. Restrict is more restricted.
The execution pointer is at main, but do you see your main() source file? Probably not. Ok,
pop over to Edit perspective and open fir.c. Set a breakpoint at the beginning of the
function. Hit RUN. Your program will stop at that breakpoint, but in the Debug perspective,
do you see your source file associated with the disassembly? Again, probably not. Again, hit
Restart to start your program at main() again.
How do you tell the compiler to add JUST ENOUGH debug info to allow your source files to
SYNC with the disassembly but not affect optimization? There is a little known option that
allows this…
Make sure you have the Opt configuration selected, right click and choose Properties. Next,
check the box below (at C6000 Compiler Runtime Model Options) to turn on symbolic
debug with FULL Optimization (-mn):
TURN ON –g (symbolic debug). –mn only makes sense if –g is turned ON. Go back to the
basic options and select Full Symbolic Debug.
Rebuild and load your program. The execution pointer should now show up along with your
main.c file. Hit Restart again. Set a breakpoint in the middle of FIR_process() function
inside fir.c. You can’t do it. The breakpoint snaps to the beginning or end of the function,
right? Make sure the breakpoint is at the beginning of FIR_process() and hit RUN. You can
now see your source code synced with the disassembly. Very nice.
But did this affect your optimization and your benchmark? Go try it. Hit Restart again and
remove all breakpoints. Then RUN. Halt your program and check your benchmark. Is it about
the same? It should be…
Open the .map file generated by the linker. Hmmm. Where is it located? Try to find it
yourself without asking anyone else. Hint: which build config did you use when you hit
“build” ?
22. Add –ms3 to Opt Config.
Open the build properties and add –ms3 to the compiler options (under Basic Options). We
will just put the “pedal to the metal” for code size optimizations and go all the way to –ms3
first. Note here that we also have –o3 set also (which is required for the –ms option).
In this scenario, the compiler may choose to keep the “slow version” of the redundant loops
(fast or slow) due to the presence of –ms.
Rebuild and run.
Did your benchmark get worse with –ms3? How much code size did you save? What
conclusions would you draw from this?
____________________________________________________________________
____________________________________________________________________
Keep in mind that you can also apply –ms3 (or most of the basic options) to a specific
function using #pragma FUNCTION_OPTIONS( ).
FYI – the author saved about 2.2K bytes total out of the .text section and the benchmark was
about 33K. HOWEVER, most of the .text section is LIBRARY code which is not affected by
–ms3. So, of the NON .lib code which IS affected by –ms3, using –ms3 saved 50% on code
size (original byte count was 6881 bytes and was reduced to 3453 bytes). This is pretty
significant. Yes, the benchmark ended up being 33K, but now you know the tradeoff.
Also remember that you can apply –ms3 on a FILE BY FILE basis. So, a smart way to apply
this is to use it on init routines – and keep it far away from your algos that require the best
performance.
Wow, for what we wanted in THIS system (a fast simple FIR routine), we would have been
better off just using DSPLib. Yep. But, in the process, you’ve learned a great deal about
optimization techniques across the board that may or may not help your specific system.
Remember, your mileage may vary.
Conclusion
Hopefully this exercise gave you a feel for how to use some of the basic compiler/optimizer
switches for your own application. Everyone’s mileage may vary and there just might be a
magic switch that helps your code and dosen’t help someone else’s. That’s the beauty of trial
and error.
Conclusion? TURN ON THE OPTIMIZER ! Was that loud enough?
Here’s what the author came up with – how did your results compare?
Optimizations Benchmark
Debug Bld Config – No opt 913K
Release (-o2, -g) 37K
Opt (-o3, no –g) 18K
Opt + MUST_ITERATE 15K
Opt + MUST_ITERATE + restrict 7K
DSPLib (FIR) 7K
Regarding –ms3, use it wisely. It is more useful to add this option to functions that are large
but not time critical – like IDL functions, init code, maintenance type items.You can save
some code space (important) and lose some performance (probably a don’t care). For your
time-critical functions, do not use –ms ANYTHING. This is just a suggestion – again, your
mileage may vary.
CPU Min was 4K cycles. We got close, but didn’t quite reach it. The authors believe that it is
possible to get closer to the 4K benchmark by using intrinsics and the DDOTP instruction.
The biggest limiting factor in optimizing the cfir routine is the “sliding window”. The
processor is only allowed ONE non-aligned load each cycle. This would happen 75% of the
time. So, the compiler is already playing some games and optimizing extremely well given
the circumstances. It would require “hand-tweaking” via intrinsics and intimate knowledge of
the architecture to achieve much better.
29. Terminate the Debug session, close the project and close CCS. Power-cycle the board.
Throw something at the instructor to let him know that you’re done with the
lab. Hard, sharp objects are most welcome…
Additional Information
Example Transfer using MASK (not all regs typically need to be programmed):
Source Destination
0 1 4 5 6 0 1 4 5 6
address address
8 10 12 8 10 12
22 23 22 23
27 29 31 27 29 31
Mask = 01010111001111111110101010001100
User must write to IDMA0 registers in the following order (COUNT written – triggers transfer):
IDMA0_MASK = 0x573FEA8C; //set mask for 13 regs above
IDMA0_SOURCE = reg_ptr; //set src addr in L1D/L2
IDMA0_DEST = MMR_ADDRESS; //set dst addr to config location
IDMA0_COUNT = 0; //set mask for 1 block of 32 registers
95
Objectives
Objectives
C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory 11 - 1
Module Topics
Module Topics
Cache & Internal Memory ......................................................................................................................11-1
Module Topics........................................................................................................................................11-2
Why Cache? ...........................................................................................................................................11-3
Cache Basics – Terminology..................................................................................................................11-4
Cache Example ......................................................................................................................................11-7
L1P – Program Cache .........................................................................................................................11-10
L1D – Data Cache ...............................................................................................................................11-13
L2 – RAM or Cache ? ..........................................................................................................................11-15
Cache Coherency (or Incoherency?) ...................................................................................................11-17
Coherency Example .........................................................................................................................11-17
Coherency – Reads & Writes ..........................................................................................................11-18
Cache Functions – Summary ...........................................................................................................11-21
Coherency – Use Internal RAM ! ....................................................................................................11-22
Coherency – Summary ....................................................................................................................11-22
Cache Alignment .............................................................................................................................11-23
Turning OFF Cacheability (MAR) .......................................................................................................11-24
Additional Topics .................................................................................................................................11-26
Chapter Quiz ........................................................................................................................................11-29
Lab 11 – Using Cache..........................................................................................................................11-31
Lab Overview: .................................................................................................................................11-31
Lab 11 – Using Cache – Procedure .................................................................................................11-32
A. Run System From Internal RAM ..........................................................................................11-32
B. Run System From External DDR2 (no cache) .......................................................................11-33
C. Run System From DDR2 (cache ON) ....................................................................................11-34
11 - 2 C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory
Why Cache?
Why Cache?
C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory 11 - 3
Cache Basics – Terminology
11 - 4 C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory
Cache Basics – Terminology
C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory 11 - 5
Cache Basics – Terminology
11 - 6 C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory
Cache Example
Cache Example
C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory 11 - 7
Cache Example
11 - 8 C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory
Cache Example
C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory 11 - 9
L1P – Program Cache
11 - 10 C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory
L1P – Program Cache
Direct 64 bytes
C62x/C67x Mapped
4K bytes
(16 instr)
N/A
Direct 32 bytes
C64x Mapped
16K bytes
(8 instr)
N/A
C64x+ Cache/RAM
Direct 32 bytes
C674x 32K bytes Cache Freeze
C66x Mapped (8 instr)
Memory Protection
C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory 11 - 11
L1P – Program Cache
11 - 12 C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory
L1D – Data Cache
C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory 11 - 13
L1D – Data Cache
11 - 14 C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory
L2 – RAM or Cache ?
L2 – RAM or Cache ?
C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory 11 - 15
L2 – RAM or Cache ?
11 - 16 C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory
Cache Coherency (or Incoherency?)
C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory 11 - 17
Cache Coherency (or Incoherency?)
11 - 18 C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory
Cache Coherency (or Incoherency?)
C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory 11 - 19
Cache Coherency (or Incoherency?)
XmtBuf XmtBuf
CPU writeback
EDMA
When the CPU is finished with the data (and has written it to XmtBuf in L2), it can
be sent to ext. memory with a cache writeback
A writeback is a copy operation from cache to memory, writing back the modified
(i.e. dirty) memory locations – all writebacks operate on full cache lines
Use BIOS Cache APIs to force a writeback:
BIOS: Cache_wb (XmtBuf, BUFFSIZE, CACHE_NOWAIT);
What happens with the "next" RCV buffer? 64
11 - 20 C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory
Cache Coherency (or Incoherency?)
C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory 11 - 21
Cache Coherency (or Incoherency?)
Coherency – Summary
11 - 22 C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory
Cache Coherency (or Incoherency?)
Cache Alignment
C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory 11 - 23
Turning OFF Cacheability (MAR)
XmtBuf
CPU
11 - 24 C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory
Turning OFF Cacheability (MAR)
C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory 11 - 25
Additional Topics
Additional Topics
11 - 26 C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory
Additional Topics
C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory 11 - 27
Additional Topics
11 - 28 C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory
Chapter Quiz
Chapter Quiz
Chapter Quiz
1. How do you turn ON the cache ?
3. All cache operations affect an aligned cache line. How big is a line?
4. Which bit(s) turn on/off “cacheability” and where do you set these?
5. How do you fix coherency when two bus masters access ext’l mem?
C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory 11 - 29
Chapter Quiz
*** HTTP ERROR 404 – PAGE NOT FOUND – CONTACT ADMINISTRATOR ***
11 - 30 C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory
Lab 11 – Using Cache
Lab Overview:
There are two goals in this lab: (1) to learn how to turn on and off cache and the effects of each
on the data buffers and program code; (2) to optimize a hi-pass FIR filter written in C. To gain
this basic knowledge you will:
A. Learn to use the platform and CFG files to setup cache memory address range (MAR bits)
and turn on L2 and L1 caches.
B. Benchmark the system performance with running code/data externally (DDR2) vs. with the
cache on vs. internal (IRAM).
C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory 11 - 31
Lab 11 – Using Cache
Note: For all benchmarks throughout this lab, use the “Opt” build configuration when you
build. Do NOT use the Debug or Release config.
Click Run and write down below the benchmarks for cfir():
The benchmark from the Log_info should be around 8K cycles. We’ll compare this “internal
RAM” benchmark to “all external” and “all external with cache ON” numbers. You just
might be surprised…
11 - 32 C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory
Lab 11 – Using Cache
6. Place the buffers (data) in external DDR2 memory and turn OFF the cache.
Edit your platform file and place the data external (DDR). Leave stacks and code in IRAM.
Modify the L1P/D cache sizes to ZERO (0K).
In this scenario, the audio data buffers are all external. Cache is not turned on. This is the
worst case situation.
Do you expect the audio to sound ok? ____________________
Match the settings you see below (0K for all cache sizes, Data Memory in DDR) :
Did you get a cycle count? The author experienced a total loss – absolute NOTHING. I think
the system is so out of it, it crashes. In fact, CCS crashed a few times in this mode. Yikes. I
vote for calling it “the national debt” #cycles – uh, what is it now – $15 Trillion? Ok, 15
trillion cycles… ;-)
C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory 11 - 33
Lab 11 – Using Cache
Set L1D/P to 32K and L2 to 64K – IF YOU DON’T SET L2 CACHE ON, YOU WILL
CACHE IN L1 ONLY. Watch it, though, when you reconfigure cache sizes, it wipes your
memory sections selections. Redo those properly after you set the cache sizes.
These sizes are larger than we need, but it is good enough for now. Leave code/data in DDR
and stacks in IRAM. Click Ok to rebuild the platform package.
The system we now have is identical to one of the slides in the discussion material.
9. Wait – what about the MAR bits?
In the discussion material, we talked about the MAR bits specifying which regions were
cacheable and which were not. Don’t we have to set the MAR bits for the external region of
DDR for them to get cached? Yep.
In order to modify (or even SEE) the MAR bits OR use any BIOS Cache APIs (like
invalidate or writeback), you need to add the C64p Cache Module to your .cfg file. Or, you
can simply right-click (and Use) the Cache module listed under: Available Products
SYS/BIOS Target Specific Support C674 Cache (as shown in the discussion material).
11 - 34 C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory
Lab 11 – Using Cache
Save the .cfg file. This SHOULD add the module to your outline view. When it shows up in
the outline view, click on it. Do you see the MAR bits?
The MAR region we are interested in, by the way, for DDR2 is MAR 192-223. As a courtesy
to users, the platform file already turned on the proper MAR bits for us for the DDR2 region.
Check it out:
The good news is that we don’t need to worry about the MAR bits for now.
10. Build, load, run –using the Opt (duh) Configuration.
Run the program. View the CPU load graph and benchmark stat and write them down below:
With code/data external AND the cache ON, the benchmark should be close to 8K cycles –
the SAME as running from internal IRAM (L2). In fact, what you’re seeing is the L1D/P
numbers. Why? Because L2 is cached in L1D/P – the closest memory to the CPU. This is
what a cache does for you – especially with this architecture.
Here’s what the author got:
C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory 11 - 35
Lab 11 – Using Cache
You’re finished with this lab. If time permits, you may move on to additional
“optional” steps on the following pages if they exist.
11 - 36 C6000 Embedded Design Workshop Using BIOS - Cache & Internal Memory
Using EDMA3
Introduction
In this chapter, you will learn the basics of the EDMA3 peripheral. This transfer engine in the
C64x+ architecture can perform a wide variety of tasks within your system from memory to
memory transfers to event synchronization with a peripheral and auto sorting data into separate
channels or buffers in memory. No programming is covered. For programming concepts, see
ACPY3/DMAN3, LLD (Low Level Driver – covered in the Appendix) or CSL (Chip Support
Library). Heck, you could even program it in assembly, but don’t call ME for help.
Objectives
At the conclusion of this module, you should be able to:
• Understand the basic terminology related to EDMA3
• Be able to describe how a transfer starts, how it is configured and what happens after the
transfer completes
• Undersand how EDMA3 interrupts are generated
• Be able to easily read EDMA3 documentation and have a great context to work from to
program the EDMA3 in your application
Module Topics
Using EDMA3 ...........................................................................................................................................12-1
Module Topics........................................................................................................................................12-2
Overview ................................................................................................................................................12-3
What is a “DMA” ? ...........................................................................................................................12-3
Multiple “DMAs” ..............................................................................................................................12-4
EDMA3 in C64x+ Device .................................................................................................................12-5
Terminology ...........................................................................................................................................12-6
Overview ...........................................................................................................................................12-6
Element, Frame, Block – ACNT, BCNT, CCNT ..............................................................................12-7
Simple Example.................................................................................................................................12-7
Channels and PARAM Sets ...............................................................................................................12-8
Examples ................................................................................................................................................12-9
Synchronization....................................................................................................................................12-12
Indexing ...............................................................................................................................................12-13
Events – Transfers – Actions ................................................................................................................12-15
Overview .........................................................................................................................................12-15
Triggers ...........................................................................................................................................12-16
Actions – Transfer Complete Code .................................................................................................12-16
EDMA Interrupt Generation ................................................................................................................12-17
Linking .................................................................................................................................................12-18
Chaining...............................................................................................................................................12-19
Channel Sorting ...................................................................................................................................12-21
Architecture & Optimization ................................................................................................................12-22
Programming EDMA3 – Using Low Level Driver (LLD) ....................................................................12-23
Chapter Quiz ........................................................................................................................................12-24
Additional Information.........................................................................................................................12-25
Notes ....................................................................................................................................................12-28
Overview
What is a “DMA” ?
Multiple “DMAs”
DMA QDMA
Enhanced DMA (version 3) Quick DMA
DMA to/from peripherals DMA between memory
Can be sync’d to peripheral events Async – must be started by CPU
Handles up to 64 events 4-8 channels available
M
SCR & EDMA3 S
Master Slave 32
EDMA3 SCR = Switched Central Resource L3
McASP
TC0
TC1
CC McBSP
x2 TC2 L1P
PCI
DDR2/3
C64x+ MegaModule L1P PERIPH
EMAC EMIF Mem AET
HPI Ctrl M S
PCI Cfg
D D
L2
L2 Mem IDMA CPU S
M
S
M
ARM Ctrl
L L
External L1D
S M Mem
128 Cntl Mem
Ctrl PERIPH =
M S M All peripheral’s
128
Cfg registers
L1D S
DATA 32
SCR
CFG
EDMA3 is a master on the DATA SCR – it can initiate data transfers
EDMA3’s configuration registers are accessed via the CFG SCR (by the CPU)
SCR
Each TC has its own connection (and priority) to the DATA SCR. Refer to the connection matrix to determine valid connections
6
Terminology
Overview
Transfer Configuration
Options
Source
B
Transfer CountA
Destination B Count (# Elements) A Count (Element Size)
Index 31 16 15 0
Cnt Reload Link Addr
Index Index
C Count (# Frames)
Rsvd C 31 16 15 0
Let's look at a simple example... 9
Simple Example
Examples
Synchronization
Indexing
Triggers
Linking
Chaining
Channel Sorting
Periphs
E63 E1 E0
EDMA Architecture
Evt Reg (ER) Queue
PSET 0
CC TC
Evt Enable Reg Q0 PSET 1 TC0
(EER)
Q1 .. TR TC1 DATA
Evt Set Reg
(ESR) Q2
. Submit
TC2
SCR
PSET 254
Chain Evt Reg Q3 Early TC3
PSET 255 TCC
(CER)
EDMA consists of two parts: Channel Controller (CC) and Transfer Controller (TC)
An event (from periph-ER/EER, manual-ESR or via chaining-CER) sends the transfer
to 1 of 4 queues (Q0 is mapped to TC0, Q1-TC1, etc. Note: McBSP can use TC1 only)
Xfr mapped to 1 of 256 PSETs and submitted to the TC (1 TR – transmit request – per ACNT
bytes or “A*B” CNT bytes – based on sync). Note: Dst FIFO allows buffering of writes while more reads occur.
The TC performs the transfer (read/write) and then sends back a transfer completion code (TCC)
The EDMA can then interrupt the CPU and/or trigger another transfer (chaining – Chap 6)
42
Chapter Quiz
Chapter Quiz
1. Name the 4 ways to trigger a transfer?
3. Fill out the following values for this channel sorting example (5 min):
PERIPH MEM • 16-bit stereo audio (interleaved)
L0 L0 • Use EDMA to auto “channel sort” to memory
R0 L1
L1 L2 ACNT: _____
R1 L3 BCNT: _____
BUFSIZE
L2 R0 CCNT: _____
R2 R1 ‘BIDX: _____
L3 R2 ‘CIDX: _____
R3 R3 Could you calculate these ?
Additional Information
Notes
Topic Choices
Objectives
Objectives
C6000 Embedded Design Workshop Using BIOS - Intro to DSP/BIOS GrabBag - 13a - 1
Module Topics
Module Topics
Intro to DSP/BIOS ...................................................................................................................................13-1
Module Topics........................................................................................................................................13-2
DSP/BIOS Overview ..............................................................................................................................13-3
Threads and Scheduling .........................................................................................................................13-4
Real-Time Analysis Tools ......................................................................................................................13-6
DSP/BIOS Configuration – Using TCF Files ........................................................................................13-7
Creating A DSP/BIOS Project ...............................................................................................................13-8
Memory Management – Using the TCF File .......................................................................................13-10
Lab 12a: Intro to DSP/BIOS ................................................................................................................13-11
Lab 12a – Procedure ........................................................................................................................13-12
Create a New Project ...................................................................................................................13-12
Add a New TCF File and Modify the Settings ............................................................................13-14
Build, Load, Play, Verify… ........................................................................................................13-16
Benchmark and Use Runtime Object Viewer (ROV) .................................................................13-19
Additional Information & Notes ..........................................................................................................13-22
GrabBag - 13a - 2 C6000 Embedded Design Workshop Using BIOS - Intro to DSP/BIOS
DSP/BIOS Overview
DSP/BIOS Overview
C6000 Embedded Design Workshop Using BIOS - Intro to DSP/BIOS GrabBag - 13a - 3
Threads and Scheduling
GrabBag - 13a - 4 C6000 Embedded Design Workshop Using BIOS - Intro to DSP/BIOS
Threads and Scheduling
C6000 Embedded Design Workshop Using BIOS - Intro to DSP/BIOS GrabBag - 13a - 5
Real-Time Analysis Tools
GrabBag - 13a - 6 C6000 Embedded Design Workshop Using BIOS - Intro to DSP/BIOS
DSP/BIOS Configuration – Using TCF Files
C6000 Embedded Design Workshop Using BIOS - Intro to DSP/BIOS GrabBag - 13a - 7
Creating A DSP/BIOS Project
GrabBag - 13a - 8 C6000 Embedded Design Workshop Using BIOS - Intro to DSP/BIOS
Creating A DSP/BIOS Project
filecfg.h
filecfg.cmd
19
C6000 Embedded Design Workshop Using BIOS - Intro to DSP/BIOS GrabBag - 13a - 9
Memory Management – Using the TCF File
How do you define the memory segments (e.g. IRAM, FLASH, DDR2) ?
How do you place the sections into these memory segments ?
GrabBag - 13a - 10 C6000 Embedded Design Workshop Using BIOS - Intro to DSP/BIOS
Lab 12a: Intro to DSP/BIOS
C6000 Embedded Design Workshop Using BIOS - Intro to DSP/BIOS GrabBag - 13a - 11
Lab 12a: Intro to DSP/BIOS
When the following screen appears, make sure you click Next instead of Finish:
GrabBag - 13a - 12 C6000 Embedded Design Workshop Using BIOS - Intro to DSP/BIOS
Lab 12a: Intro to DSP/BIOS
As you can see, there are many choices. Empty Projects are just that – empty – just a path to
the include files for the selected processor. Go ahead and click on “Basic Exmaples” to see
what’s inside. Click on all the other + signs to see what they contain. Ok, enough playing
around. We are using BIOS 5.41.xx.xx in this workshop. So, the correct + sign to choose in
the end is the one that is highlighted above.
3. Choose the specific BIOS template for this workshop.
Next, you’ll see the following screen:
Select “Empty Example”. This will give us the paths to the BIOS include directories. The
other examples contain example code and .tcf files. NOW you can click Finish.
C6000 Embedded Design Workshop Using BIOS - Intro to DSP/BIOS GrabBag - 13a - 13
Lab 12a: Intro to DSP/BIOS
At this point in time, what files are we missing? There are 3 of them. Can you name them?
______________ ______________ ______________
GrabBag - 13a - 14 C6000 Embedded Design Workshop Using BIOS - Intro to DSP/BIOS
Lab 12a: Intro to DSP/BIOS
Check the box that says “create a heap in this memory” (if not already checked) and change
and change the heap size to 4000h.
Click Ok.
Now that we HAVE a heap in IRAM (that’s another name for L2 by the way), we need to tell
the mother ship (MEM) where our heap is.
Right-click on MEM and select Properties. Click on both down arrows and select IRAM for
both (again, this is probably already done for you). Click OK. Now she’s happy…
Note: FYI – throughout the labs, we will throw in the “top 10 or 20” tips that cause Debug
nightmares during development. Here’s your first one…
C6000 Embedded Design Workshop Using BIOS - Intro to DSP/BIOS GrabBag - 13a - 15
Lab 12a: Intro to DSP/BIOS
Hint: TIP #1 – Always create a HEAP when working with BIOS projects.
Hint: TIP #2 – Always #include the cfg.h file in your application code when using BIOS as
the FIRST included header file.
11. Inspect the “generated” files resulting from our new TCF file.
In the project view, locate the following files and inspect them (actually, you’ll need to
BUILD the project before these show up):
bios_ledcfg.h
bios_ledcfg.cmd
There are other files that get generated by the existence of .tcf which we will cover in later
labs. The .cmd file is automatically added to your project as a source file. However, your
code must #include the cfg.h file or the compiler will think all the BIOS stuff is “declared
implicitly”.
GrabBag - 13a - 16 C6000 Embedded Design Workshop Using BIOS - Intro to DSP/BIOS
Lab 12a: Intro to DSP/BIOS
Hint: TIP #3 – BIOS will NOT run if you don’t exit main().
C6000 Embedded Design Workshop Using BIOS - Intro to DSP/BIOS GrabBag - 13a - 17
Lab 12a: Intro to DSP/BIOS
Hint: TIP #4 – When entering a fxn name into BIOS objects, precede the name with an
underscore – “_”. Otherwise you will get a symbol referencing error which is difficult to
locate.
SO, the fxn name you type in here must be preceded by an underscore:
You have now created an IDL object that is associated with a fxn. By the way, when you
create HWI, SWI and TSK objects later on, guess what? It is the SAME procedure. You’ll get
sick of this by the end of the week – right-click, insert, rename, right-click and select
Properties, type some stuff. There – that is DSP/BIOS in a nutshell.
14. Build and Debug AGAIN.
When the execution arrow hits main(), click “Play”. You should now see the LED
blinking. If you ever HALT/PAUSE, it will probably pause inside a library fxn that has no
source associated with it. Just X that thing.
At this point, your first BIOS project is working. Do NOT “terminate all” yet. Simply click
on the C/C++ perspective and move on to a few more goodies…
GrabBag - 13a - 18 C6000 Embedded Design Workshop Using BIOS - Intro to DSP/BIOS
Lab 12a: Intro to DSP/BIOS
Don’t type in the call to LOG_printf() just yet. We’ll do that in a few moments…
C6000 Embedded Design Workshop Using BIOS - Intro to DSP/BIOS GrabBag - 13a - 19
Lab 12a: Intro to DSP/BIOS
Are you serious? 1.57M CPU cycles. Of course. This mostly has to do with going through
I2C and a PLD and waiting forever for acknowledge signals (can anyone say “BUS
HOLD”?). Also, don’t forget we’re using the “Debug” build configuration with no
optimization. More on that later. Nonetheless, we have our benchmark.
17. Open up TWO .tcf files – is this a problem?
The author has found a major “uh oh” that you need to be aware of. Open your .tcf file and
keep it open. Double-click on the project’s TCF file AGAIN. Another “instance” of this
window opens. Nuts. If you change one and save the other, what happens? Oops. So, we
recommend you NOT minimize TCF windows and then forget you already have one open
and open another. Just BEWARE…
18. Add LOG Object and LOG_printf() API to display benchmark.
Open led.c for editing and add the LOG_printf() statement as shown in a previous
diagram.
Open the TCF for editing. Under Instrumentation, add a new LOG object named “trace”.
Remember? Right-click on LOG, insert log, rename to trace, click OK.
GrabBag - 13a - 20 C6000 Embedded Design Workshop Using BIOS - Intro to DSP/BIOS
Lab 12a: Intro to DSP/BIOS
19. Pop over to Windows Explorer and analyse the \Project folder.
Remember when we said that another folder would be created if you were using BIOS? It
was called .gconf. This is the GRAPHICAL config tool in action that is fed by the .cdb
file. When you add a .tcf file, the graphical and textual tools must both exisit and follow each
other. Go check it out. Is it there? Ok…back to the action…
20. Build, Debug, Play – use ROV.
When the code loads, remove the breakpoint in led.c. Then, click Play. PAUSE the execution
after about 5 seconds. Open the ROV tool via Tools → ROV. When ROV opens, select LOG
and one of the sequence numbers – like 2 or 3:
Notice the result of the LOG_printf() under “message”. You can choose other sequence
numbers and see what their times were.
You can also choose to see the LOG messages via Tools RTA Printf Logs. Try that now and
see what you get. If you’d like to change the behaviour of the LOGging, go back to the LOG
object and try a bigger buffer, circular (last N samples) or fixed (first N samples). Experiment
away…
When we move on to a TSK-based system, the ROV will come in very handy. This tool
actually replaced the older KOV (kernel object viewer) in the previous CCS. Also, in future
labs, we’ll use the RTA (Real-time Analysis) tools to view Printf logs directly. By then,
you’ll know two different ways to access debug info.
Note: Explain this to me – so, the tool is called ROV which stands for RUNTIME Object
Viewer. But the only way to VIEW the OBJECT is in STOP time. Hmmm. Marketing?
Illegal drug use? Ok, so it “collects” the data during runtime…but still…to the author,
this is a stretch and confuses new users. Ah, but now you know the “rest of the story”…
You’re finished with this lab. Please raise your hand and let the instructor
know you are finished with this la (maybe throw something heavy at them to
get their attention or say “CCS crashed – AGAIN !” – that will get them
running…)
C6000 Embedded Design Workshop Using BIOS - Intro to DSP/BIOS GrabBag - 13a - 21
Additional Information & Notes
GrabBag - 13a - 22 C6000 Embedded Design Workshop Using BIOS - Intro to DSP/BIOS
Additional Information & Notes
C6000 Embedded Design Workshop Using BIOS - Intro to DSP/BIOS GrabBag - 13a - 23
Additional Information & Notes
GrabBag - 13a - 24 C6000 Embedded Design Workshop Using BIOS - Intro to DSP/BIOS
Booting From Flash
Introduction
In this chapter the steps required to migrate code from being loaded and run via CCS to running
autonomously in flash will be considered. Given the AISgen and SPIWriter tools, this is a simple
process that is desired toward the end of the design cycle.
Objectives
Objectives
C6000 Embedded Design Workshop Using BIOS - Booting From Flash GrabBag - 13b - 1
Module Topics
Module Topics
Booting From Flash ..................................................................................................................................13-1
Module Topics........................................................................................................................................13-2
Booting From Flash ...............................................................................................................................13-3
Boot Modes – Overview ....................................................................................................................13-3
System Startup ...................................................................................................................................13-4
Init Files .............................................................................................................................................13-4
AISgen Conversion............................................................................................................................13-5
Build Process .....................................................................................................................................13-5
SPIWriter Utility (Flash Programmer) ..............................................................................................13-6
ARM + DSP Boot ..............................................................................................................................13-7
Additonal Info…................................................................................................................................13-8
C6748 Boot Modes (S7, DIP_x) ........................................................................................................13-9
Lab 13b: Booting From Flash .............................................................................................................13-11
Lab13b – Booting From Flash - Procedure......................................................................................13-12
Tools Download and Setup (Students: SKIP STEPS 1-6 !!) .......................................................13-12
Build Keystone Project: [Src → .OUT File] ..............................................................................13-16
Use AISgen To Convert [.OUT → .BIN]...................................................................................13-21
Program the Flash: [.BIN → SPI1 Flash] ...................................................................................13-29
Optional – DDR Usage ...............................................................................................................13-31
Additional Information.........................................................................................................................13-32
Notes ....................................................................................................................................................13-33
More Notes… .......................................................................................................................................13-34
GrabBag - 13b - 2 C6000 Embedded Design Workshop Using BIOS - Booting From Flash
Booting From Flash
C6000 Embedded Design Workshop Using BIOS - Booting From Flash GrabBag - 13b - 3
Booting From Flash
System Startup
Init Files
GrabBag - 13b - 4 C6000 Embedded Design Workshop Using BIOS - Booting From Flash
Booting From Flash
AISgen Conversion
Build Process
C6000 Embedded Design Workshop Using BIOS - Booting From Flash GrabBag - 13b - 5
Booting From Flash
GrabBag - 13b - 6 C6000 Embedded Design Workshop Using BIOS - Booting From Flash
Booting From Flash
C6000 Embedded Design Workshop Using BIOS - Booting From Flash GrabBag - 13b - 7
Booting From Flash
Additonal Info…
GrabBag - 13b - 8 C6000 Embedded Design Workshop Using BIOS - Booting From Flash
Booting From Flash
C6000 Embedded Design Workshop Using BIOS - Booting From Flash GrabBag - 13b - 9
Booting From Flash
*** this page was accidentally created by a virus – please ignore ***
GrabBag - 13b - 10 C6000 Embedded Design Workshop Using BIOS - Booting From Flash
Lab 13b: Booting From Flash
C6000 Embedded Design Workshop Using BIOS - Booting From Flash GrabBag - 13b - 11
Lab 13b: Booting From Flash
GrabBag - 13b - 12 C6000 Embedded Design Workshop Using BIOS - Booting From Flash
Lab 13b: Booting From Flash
C6000 Embedded Design Workshop Using BIOS - Booting From Flash GrabBag - 13b - 13
Lab 13b: Booting From Flash
From here, locate the following and click “here” to go to the download page:
This will take you to a SourceForge site that will contain the tools you need to download.
Click on the latest version under OMAP-L138 and download the tar.gz file. UnTAR the
contents and you’ll see this:
The path we need is \OMAP-L138. If we dive down a bit, we will find the
SPIWriter.out file that is used to program the flash with our boot image (.bin).
GrabBag - 13b - 14 C6000 Embedded Design Workshop Using BIOS - Booting From Flash
Lab 13b: Booting From Flash
5. Install AISgen.
Find the download of the AISgen.exe file and double-click it to install. After installation,
copy a shortcut to the desktop for this program:
C6000 Embedded Design Workshop Using BIOS - Booting From Flash GrabBag - 13b - 15
Lab 13b: Booting From Flash
SYS/BIOS Users – must add two lines of script code to the CFG file as shown. This script
forces the reset vector address for the DSP to 0x11830000. Locate this in the given .cfg file
and UNCOMMENT these two lines of code.
DSP/BIOS Users – must create a linker.cmd file as shown below to force the address of the
reset vector. This little command file specifies EXACTLY where the .boot section should go
for a BIOS project (this is not necessary for a non-BIOS program).
GrabBag - 13b - 16 C6000 Embedded Design Workshop Using BIOS - Booting From Flash
Lab 13b: Booting From Flash
C6000 Embedded Design Workshop Using BIOS - Booting From Flash GrabBag - 13b - 17
Lab 13b: Booting From Flash
11. Determine silicon rev of the device you are currently using.
AISgen will want to know which silicon rev you are using. Well, you can either attempt to
read it off the device itself (which is nearly impossible) or you can visit a convenient place in
memory to see it.
Now that you have the Debug perspective open, this should be relatively straightforward.
Open a memory view window and type in the following address:
0x11700000
Can you see it? No? Shame on you. Ok. Try changing the style view to “Character” instead.
See something different?
Like this?
That says “d800k002” which means rev2 of the silicon. That’s an older rev…but whatever
yours is…write it down below:
Silicon REV: ____________________
GrabBag - 13b - 18 C6000 Embedded Design Workshop Using BIOS - Booting From Flash
Lab 13b: Booting From Flash
12. Use the Debug GEL script to locate the Silicon Rev.
This script can be run at any time to debug the state of your silicon and all of the important
registers and frequencies your device is running at. This file works for both OMAP-L137/8
and C6747/8 devices. It is a great script to provide feedback for your hardware engineer.
It goes kind of like this: we want a certain frequency for PLL1. We read the documentation
and determine that these registers need to be programmed to a, b and c. You write the code,
program them and then build/run. Well, is PLL1 set to the frequency you thought it should
be? Run the debug script and find out what the processor is “reporting” the setting is. Nice.
This script outputs its results to the Console window.
Let’s use the debug script to determine the silicon rev as in the previous step.
First, we need to LOAD the gel file. This file can be downloaded from the wiki shown in the
chapter. We have already done that for you and placed that GEL file in the \gel directory next
to the GEL file you’ve been using for CCS.
Right-click in the empty area under the currently loaded GEL file and select: Load Gel.
The \gel directory should show up and the file OMAPL1x_debug.gel should be listed. If
not, browse to C:\SYSBIOSv4\Labs\DSP_BSL\gel.
Click Open.
C6000 Embedded Design Workshop Using BIOS - Booting From Flash GrabBag - 13b - 19
Lab 13b: Booting From Flash
This will load the new GEL file and place the scripts under the “Scripts” menu.
Select “Scripts” Diagnostics Run All:
You can choose to run only a specific script or “All” of them. Notice the output in the
Console window. Scroll up and find the silicon revision. Also make note of all of the registers
and settings this GEL file reports. Quite extensive.
Does your report show the same rev as you found in the previous step? Let’s hope so…
GrabBag - 13b - 20 C6000 Embedded Design Workshop Using BIOS - Booting From Flash
Lab 13b: Booting From Flash
This is the INSTALL file (fyi). You don’t need to use this if the tool is already installed on
your computer…
14. Run AISgen.
There should be an icon on your desktop that looks like this:
If not, you will need to install the tool by double-clicking on the install file, installing it and
then creating a shortcut to it on the desktop (you’ll find it in Programs → Texas Instruments
→ AISgen).
Double-click on the icon to launch AISgen and fill out the dialogue box as shown on the next
page…there are several settings you need…so be careful and go SLOWLY here…
It is usually BEST to place all of your PLL and DDR settings in the flash image and have the
bootloader set these up vs. running code on the DSP to do it. Why? Because the DSP then
comes out of reset READY to go at the top speeds vs. running “slow” until your code in
main() is run. So, that’s what we plan to do….
Note: Each dialogue has its own section below. It is quite a bit of setup…but hey, you are
enabling the bootloader to set up your entire system. This is good stuff…but it takes some
work…
Hint: When you actually use the DSP to burn the flash in a later step, the location you store
your .bin file too (name of the .bin file AND the directory path you place the .bin file in)
CANNOT have ANY SPACES IN THE PATH OR FILENAME.
C6000 Embedded Design Workshop Using BIOS - Booting From Flash GrabBag - 13b - 21
Lab 13b: Booting From Flash
Note: you will type in these paths in a future step – do NOT do it now…
GrabBag - 13b - 22 C6000 Embedded Design Workshop Using BIOS - Booting From Flash
Lab 13b: Booting From Flash
On the “General” tab, check the box for “Configure PLL0” as shown:
Then click on the PLL0 tab and view these settings. You will see the defaults show up. Make
the following modifications as shown below.
Change the multiplier value from 20 to 25 and notice the values in the bottom RH corner
change.
Peripheral Tab
Next, click on the Peripheral tab. This is where you will set the SPI Clock. It is a function
(divide down) from the CPU clock. If you leave it at 1MHz, well, it will work, but the
bootload will take WAY longer. So, this is a “speed up” enhancement.
Type “20” into the SPI Clock field as shown:
Also check the “Enable Sequential Read” checkbox. Why is this important? Speed of the boot
load. If this box is unchecked, the ROM code will send out a read command (0x03) plus a 24-
bit address before every single BYTE. That is a TON of read commands.
However, if we CHECK this box, the ROM code will send out a single 24-bit address
(0x000000) and then proceed to read out the ENTIRE boot image. WAY WAY faster.
C6000 Embedded Design Workshop Using BIOS - Booting From Flash GrabBag - 13b - 23
Lab 13b: Booting From Flash
Configure PLL1
Just in case you EVER want to put code or data into the DDR, PLL1 needs to be set in the
flash image and therefore configured by the bootloader.
So, click the checkbox next to “Configure PLL1”, click on that tab, and use the following
settings:
This will clock the DDR at 300MHz. This is equivalent to what our GEL file sets the DDR
frequency to. We don’t have any code in DDR at the moment – but now we have it setup just
in case we ever do later on. Now, we need to write values to the DDR config registers…
Configure DDR
You know the drill. Click the proper checkbox on the main dialogue page and click on the
DDR tab. Fill in the following values as shown. If you want to know what each of the values
are on the right, look it up in the datasheet.
GrabBag - 13b - 24 C6000 Embedded Design Workshop Using BIOS - Booting From Flash
Lab 13b: Booting From Flash
This would Enable module 15 of the PSC which says “de-assert the reset on the DSP
megamodule” and enable the clocks so that the ARM can write to the DSP memory located in
L2. However, this setting does NOT match what the GEL file did for us. So, we need to
enable MORE of the PSC modules so that we match the GEL file.
Note: When doing this for your own system, you’ll need to pick and choose the PSC modules
that are important to your specific system.
Better Setting (USE THIS ONE for the lab – or as a starting point for your own system)
Note: Note: PSC1 is MISSING modules 8, 22-23 (see datasheet for more details on these).
C6000 Embedded Design Workshop Using BIOS - Booting From Flash GrabBag - 13b - 25
Lab 13b: Booting From Flash
Save your .cfg file in the \Lab13b_AIS folder for potential use later on – you don’t want
to have to re-create all of these steps again if you can avoid it. If you look in that folder, it
already contains this .cfg file done for you. Ok, so we could have told you that earlier, but
then the learning would have been crippled.
The author named the solution’s config file:
OMAP-L138-ARM-DSP-LAB13B_TTO.cfg
Hint: C6748 Users: You will only specify ONE output file (DSP.out)
Hint: OMAP-L138 Users: You will specify TWO files (an ARM.out and a DSP.out).
GrabBag - 13b - 26 C6000 Embedded Design Workshop Using BIOS - Booting From Flash
Lab 13b: Booting From Flash
Hint: 6748 SOM Users – follow THESE directions (OMAP Users can skip this part)
For the “DSP Application File”, browse to the .OUT file that was created when you built your
keystone project: keystone_flash.out
Click the “…” button shown above next to “ARM Application File” to browse to (use \Lab13b
instead):
Click Open.
Your screen should now look like this (except for using \Lab13b…):
This ARM code is for rev1 silicon. It should also work on Rev2 silicon – but not tested.
C6000 Embedded Design Workshop Using BIOS - Booting From Flash GrabBag - 13b - 27
Lab 13b: Booting From Flash
and browse to your keystone_flash.out file you built earlier. You should now have two
.out files listed under “ARM Application File” – first the ARM.out, then the DSP.out files
separated by a semicolon. Double-check this is the case.
The AISgen software won’t allow you to see both paths at once in that tiny box, but here is a
picture of the “middle” of the path showing the “semicolon” in the middle of the two .out files –
again, the ARM.out file needs to be first followed by the DSP.out file (use \Lab13b instead):
Hint: Again, the path and filename CANNOT contain any spaces. When you run the flash
writer later on, that program will barf on the file if there are any spaces in the path or
filename.
Before you click the “Generate AIS” button, notice the other configuration options you have here.
If you wanted AIS to write the code to configure any of these options, simply check them and fill
out the info on the proper tab. This is a WAY cool interface. And, the bootloader does “system”
setup for you instead of writing code to do it – and making mistakes and debugging those
mistakes…and getting frustrated…like getting tired of reading this rambling text from the
author….
GrabBag - 13b - 28 C6000 Embedded Design Workshop Using BIOS - Booting From Flash
Lab 13b: Booting From Flash
In CCS,
Launch a debug session (right-click on the target config file and click “launch”)
Connect to target
Select “Load program” and browse to this location:
C:\SYSBIOSv4\Labs\Lab13b_SPIWriter\SPIWriter_OMAP-L138.out
C6000 Embedded Design Workshop Using BIOS - Booting From Flash GrabBag - 13b - 29
Lab 13b: Booting From Flash
18. PLAY !
Click Play. The console window will pop up and ask you a question about whether this is a
UBL image. The answer is NO. Only if you were using a TI UBL which would then boot
Uboot, the answer is no. This assumes that Linux is running. Our ARM code has no O/S.
Type a smallcase “n” and hit [ENTER]. To respond to the next question, provide the path
name for your .BIN file (flash.bin) created in a previous step, i.e.:
C:\SYSBIOSv4\Labs\Lab13b_AIS\flash.bin
Hint: Do NOT have any spaces in this path name for SPIWriter – it NO WORK that way.
Here’s a screen capture from the author (although, you are using the \Lab13b_ais dir, not
\Lab12b) :
Let it run – shouldn’t take too long. 15-20 seconds (with an XDS510 emulator). You will see
some progress msgs and then see “success” – like this:
21. Change the boot mode pins on the EVM back to their original state.
Please ensure DIP_5 and DIP_8 of S7 (the one on the right) are UP [ON].
GrabBag - 13b - 30 C6000 Embedded Design Workshop Using BIOS - Booting From Flash
Lab 13b: Booting From Flash
When running AISgen, you can simply load this config file and it contains ALL of the settings
from this lab. Edit, recompile, load this cfg, generate .bin, burn, reset. Quick.
Or, you can simply use the .cfg file you saved earlier in this lab…
C6000 Embedded Design Workshop Using BIOS - Booting From Flash GrabBag - 13b - 31
Additional Information
Additional Information
GrabBag - 13b - 32 C6000 Embedded Design Workshop Using BIOS - Booting From Flash
Notes
Notes
C6000 Embedded Design Workshop Using BIOS - Booting From Flash GrabBag - 13b - 33
More Notes…
More Notes…
GrabBag - 13b - 34 C6000 Embedded Design Workshop Using BIOS - Booting From Flash
Stream I/O and Drivers (PSP/IOM)
Introduction
In this chapter a technique to exchange buffers of data between input/output devices and
processing threads will be considered. The BIOS „stream‟ interface will be seen to provide a
universal intervace between I/O and processing threads, making coding easier and more easily
reused.
Objectives
Objectives
C6000 Embedded Design Workshop Using BIOS - Stream I/O and Drivers (PSP/IOM) GrabBag - 13c - 1
Module Topics
Module Topics
Stream I/O and Drivers (PSP/IOM) .......................................................................................................13-1
Module Topics........................................................................................................................................13-2
Driver I/O - Intro ...................................................................................................................................13-3
Using Double Buffers .............................................................................................................................13-5
PSP/IOM Drivers ...................................................................................................................................13-7
Lab 11f: Emulator and CCS Troubleshooting .....................................................................................13-11
[OPTIONAL] Lab 13c – EMU and CCS Troubleshooting .............................................................13-12
PART A – Compare/Contrast Emulators ....................................................................................13-12
XDS100v1 Emulation .................................................................................................................13-12
XDS510 Emulation .....................................................................................................................13-14
XDS560v2 Emulation .................................................................................................................13-15
Conclusions .................................................................................................................................13-16
PART B – Troubleshooting CCS ................................................................................................13-17
General IDE Troubleshooting .....................................................................................................13-17
Debugging the Debugger… ........................................................................................................13-18
Additional Information.........................................................................................................................13-19
Notes ....................................................................................................................................................13-21
Notes ....................................................................................................................................................13-22
GrabBag - 13c - 2 C6000 Embedded Design Workshop Using BIOS - Stream I/O and Drivers (PSP/IOM)
Driver I/O - Intro
C6000 Embedded Design Workshop Using BIOS - Stream I/O and Drivers (PSP/IOM) GrabBag - 13c - 3
Driver I/O - Intro
GrabBag - 13c - 4 C6000 Embedded Design Workshop Using BIOS - Stream I/O and Drivers (PSP/IOM)
Using Double Buffers
C6000 Embedded Design Workshop Using BIOS - Stream I/O and Drivers (PSP/IOM) GrabBag - 13c - 5
Using Double Buffers
GrabBag - 13c - 6 C6000 Embedded Design Workshop Using BIOS - Stream I/O and Drivers (PSP/IOM)
PSP/IOM Drivers
PSP/IOM Drivers
C6000 Embedded Design Workshop Using BIOS - Stream I/O and Drivers (PSP/IOM) GrabBag - 13c - 7
PSP/IOM Drivers
GrabBag - 13c - 8 C6000 Embedded Design Workshop Using BIOS - Stream I/O and Drivers (PSP/IOM)
PSP/IOM Drivers
C6000 Embedded Design Workshop Using BIOS - Stream I/O and Drivers (PSP/IOM) GrabBag - 13c - 9
PSP/IOM Drivers
GrabBag - 13c - 10 C6000 Embedded Design Workshop Using BIOS - Stream I/O and Drivers (PSP/IOM)
Lab 13c: Emulator and CCS Troubleshooting
C6000 Embedded Design Workshop Using BIOS - Stream I/O and Drivers (PSP/IOM) GrabBag - 13c - 11
Lab 13c: Emulator and CCS Troubleshooting
However, you still might run into some problems along the way. Good luck…
As this is possibly the last lab in the workshop and part of the “Advanced” section, little help will
be provided and the explanations below won‟t hand-hold you through every minor detail. Hey,
you‟re at the END of this workshop, so, you need less help. Right? ;-)
XDS100v1 Emulation
1. Run Keystone project using XDS100v1 emulation.
The XDS100v1 emulator is actually built into the OMAP-L138 EVM. All you have to do is
connect a USB cable to it (pick the right USB port – nearest the serial port) and your PC. If
you want the CHEAPEST solution out there for getting started with CCS, then the simulator
is your best option – it is completely free. However, if you want to emulate real hardware,
after you purchase the development kit, you have a cost-free option with the XDS100v1 and
CCSv4.
But, it is also the slowest option. Well, you get what you pay for.
In CCS, import the keystone project and build it. Make sure you are using the RELEASE
build configuration.
View the target config files and pick the one you think will work. ALWAYS check to make
sure the GEL files are correct inside each configuration. Select this .ccxml file as [Default].
GrabBag - 13c - 12 C6000 Embedded Design Workshop Using BIOS - Stream I/O and Drivers (PSP/IOM)
Lab 13c: Emulator and CCS Troubleshooting
C6000 Embedded Design Workshop Using BIOS - Stream I/O and Drivers (PSP/IOM) GrabBag - 13c - 13
Lab 13c: Emulator and CCS Troubleshooting
XDS510 Emulation
6. Run keystone project using the XDS510.
Ok, so you‟ve “been here, done that” already, but it is good practice to switch emulators on
the fly and see if you run into any problems. Do the same process as before, but switch to the
XDS510 emulator (hardware and target config file). Don‟t forget to TIME the “launch” and
“rebuild”…
The price of this emulator is $989 on Digikey.com (actually, that‟s the truth as of the time of
this writing). So, now rate your overall experience (price/performance, ease of use) for this
emulator:
GrabBag - 13c - 14 C6000 Embedded Design Workshop Using BIOS - Stream I/O and Drivers (PSP/IOM)
Lab 13c: Emulator and CCS Troubleshooting
XDS560v2 Emulation
Now, this guy is supposed to be “screaming fast”. Others who have purchased this guy have
been SO thoroughly impressed, they talked to ME about it. No one talks to me – so, it must
have been out of this world.
But it takes a little work to get it there. Let‟s see what you find out…
7. Hook up the Spectrum Digital XDS560v2 emulator.
Ok, so this pod has a few more wires and adaptors to hook up. And, it‟s a little bigger in size.
Make sure you have the power supply and connectors properly attached and you see LED
lights on. The connector should have a 14-pin JTAG header on the end of it. If not, ask the
instructor for help. Connect the cable to the board. Be careful, it “stacks” up kind of high –
sometimes it is easy to topple the tower.
The XDS560v2 ships with 4-5 different connector types – including the 14-pin JTAG header.
Good for flexibility – bad if you lose the one you needed. ;-)
8. Run the keystone project using this emulator.
9. Write down the pertinent stats:
The price of this emulator is $1495 on the Spectrum Digital website. So, now rate your
overall experience (price/performance, ease of use) for this emulator:
10. Conclusions
C6000 Embedded Design Workshop Using BIOS - Stream I/O and Drivers (PSP/IOM) GrabBag - 13c - 15
Lab 13c: Emulator and CCS Troubleshooting
The current speed is set at 35MHz. Sounds fast – sounds appealing - and it works pretty well.
Depending on the board (OMAP3530, OMAP-L138, etc), you may find that setting
“Adaptive without any limit at all” could significantly improve your performance. The word
on the street is that the BlackHawk XDS560v2 is screaming fast with this setting. I guess it
doesn‟t affect the SD one as much. So, your mileage may vary. But, at least you know where
the settings are.
Try the “Adaptive without any limit at all” setting and see if that works better. Also, keep in
mind that this emulator‟s system trace mode is known to be excellent (something we‟re not
investigating at all here). Did the speed improve? Did it get worse? What was your
experience? _______________________________________________________________
Conclusions
12. So, what are your final thoughts about your experiences with these different emulators?
___________________________________________________________________________
Which one is the best choice? _________________________________________________
GrabBag - 13c - 16 C6000 Embedded Design Workshop Using BIOS - Stream I/O and Drivers (PSP/IOM)
Lab 13c: Emulator and CCS Troubleshooting
C6000 Embedded Design Workshop Using BIOS - Stream I/O and Drivers (PSP/IOM) GrabBag - 13c - 17
Lab 13c: Emulator and CCS Troubleshooting
Sometimes, a fresh start helps. It works for humans and it works for CCS. ;-) CCS stores
metadata for the environment in the \metadata folder in the workspace. Sometimes, it gets
corrupted and needs to be reset.
There are several different ways to do this:
File Switch Workspace
Delete the metadata folder from your current workspace
Try them both.
You’re finished with this lab. If time permits, you may move on to additional
“optional” steps on the following pages if they exist.
GrabBag - 13c - 18 C6000 Embedded Design Workshop Using BIOS - Stream I/O and Drivers (PSP/IOM)
Additional Information
Additional Information
C6000 Embedded Design Workshop Using BIOS - Stream I/O and Drivers (PSP/IOM) GrabBag - 13c - 19
Additional Information
GrabBag - 13c - 20 C6000 Embedded Design Workshop Using BIOS - Stream I/O and Drivers (PSP/IOM)
Notes
Notes
C6000 Embedded Design Workshop Using BIOS - Stream I/O and Drivers (PSP/IOM) GrabBag - 13c - 21
Notes
Notes
GrabBag - 13c - 22 C6000 Embedded Design Workshop Using BIOS - Stream I/O and Drivers (PSP/IOM)
C66x Introduction
Introduction
This chapter provides a high-level overview of the architecture of the C66x devices along with a
brief overview of the MCSDK (Multicore Software Development Kit).
Objectives
Objectives
C6000 Embedded Design Workshop Using BIOS - C66x Introduction GrabBag - 13d - 1
Module Topics
Module Topics
C66x Introduction ....................................................................................................................................13-1
Module Topics........................................................................................................................................13-2
C66x Family Overview ..........................................................................................................................13-3
C6000 Roadmap ................................................................................................................................13-3
C667x Architecture Overview ...........................................................................................................13-4
C665x Low-Power Devices ..................................................................................................................13-11
MCSDK Overview ................................................................................................................................13-13
What is the MCSDK ? .....................................................................................................................13-13
Software Architecture ......................................................................................................................13-14
For More Info… ...................................................................................................................................13-16
Notes ....................................................................................................................................................13-17
Notes ....................................................................................................................................................13-18
GrabBag - 13d - 2 C6000 Embedded Design Workshop Using BIOS - C66x Introduction
C66x Family Overview
4x performance improvement
for multiply operation
32 16-bit MACs
C674x C64x+
C67x+
SPLOOP and 16-bit
C67x 2x registers
100% upward object code
compatible with C64x, C64x+,
instructions for
smaller code size
C64x
C67x and c67x+ Advanced fixed-
IEEE 754 Native Flexible level one point instructions
Instructions for memory architecture
SP & DP Enhanced
Best of fixed-point and
Four 16-bit or eight
floating-point architecture for
iDMA for rapid data 8-bit MACs
Advanced VLIW floating-point better system performance transfers between
architecture add capabilities and faster time-to-market. local memories Two-level cache
C6000 Embedded Design Workshop Using BIOS - C66x Introduction GrabBag - 13d - 3
C66x Family Overview
CorePac
Memory Subsystem
MSM
Application-Specific
Coprocessors CorePac
64-bit
SRAM
DDR3 EMIF 1 to 8 C66x CorePac DSP Cores
MSMC
operating at up to 1.25 GHz
• Fixed/Floating-pt operations
• Code compatible with other
C66x™ C64x+ and C67x+ devices
CorePac
L1 Memory
L1P L1D
• Partition as Cache or RAM
L2
1 to 8 Cores @ up to 1.25 GHz
• 32KB L1P/D per core
HyperLink TeraNet Dedicated L2 Memory
Multicore Navigator • Partition as Cache or RAM
• 512 KB to 1 MB per core
Direct connection to memory
subsystem
Memory Subsystem
Memory Subsystem Application-Specific
Coprocessors
CorePac
MSM
64-bit
DDR3 EMIF
SRAM Memory Subsystem
MSMC
Multicore Shared Memory
(MSM SRAM)
• 2 to 4MB (Program or Data)
C66x™
CorePac • Available to all cores
L1P L1D Multicore Shared Mem (MSMC)
L2 • Arbitrates access to shared
1 to 8 Cores @ up to 1.25 GHz memory and DDR3 EMIF
HyperLink TeraNet • Provides CorePac access to
Multicore Navigator coprocessors and I//O
• Provides address extension
to 64G (36 bits)
DDR3 External Memory Interface
(EMIF) – 8GB
• Support for 16/32/64-bit
Network modes
Common and App-specific I/O
Coprocessor • Specified at up to 1600 MT/s
GrabBag - 13d - 4 C6000 Embedded Design Workshop Using BIOS - C66x Introduction
C66x Family Overview
Multicore Navigator
Memory Subsystem Application-Specific
Coprocessors
CorePac
MSM
64-bit SRAM Memory Subsystem
DDR3 EMIF
MSMC Multicore Navigator
Provides seamless inter-core
communications (msgs and
C66x™ data) between cores, IP, and
CorePac
peripherals. “Fire and forget”
L1P L1D
Low-overhead processing and
L2
routing of packet traffic to/from
1 to 8 Cores @ up to 1.25 GHz
cores and I/O
HyperLink TeraNet
Supports dynamic load
Multicore Navigator
Queue Packet
optimization
Manager DMA
Consists of a Queue Manager
Subsystem (QMSS) and
multiple, dedicated Packet DMA
engines
VBUS
Config RAM
Interrupt Distributor
Rx Channel Tx Channel Tx DMA
Register I/F
Ctrl / Fifos Ctrl / Fifos Scheduler Queue Interrupts
queue pend
Rx Streaming I/F Tx Streaming I/F
Queue
Tx Scheduling I/F Config RAM
Output Input Manager
(AIF2 only) queue
(egress) (ingress) pend
Register I/F
PKTDMA Control Link RAM
(internal)
C6000 Embedded Design Workshop Using BIOS - C66x Introduction GrabBag - 13d - 5
C66x Family Overview
Network Coprocessor
Memory Subsystem Application-Specific
Coprocessors
CorePac
MSM
64-bit SRAM Memory Subsystem
DDR3 EMIF
MSMC Multicore Navigator
Network Coprocessor
Provides H/W accelerators to
C66x™
CorePac perform L2, L3, L4 processing
and encryption (often done in
L1P L1D S/W)
L2 Packet Accelerator (PA)
1 to 8 Cores @ up to 1.25 GHz • 8K multi-in/out HW queues
HyperLink TeraNet • Single IP address option
Multicore Navigator
• UDP/TCP checksum and CRCs
• Quality of Service (QoS)
support
• Multi-cast to multiple queues
Ethernet
Switch
SA
Switch
Security Accelerator (SA)
PA • HW encryption, decryption
and authentication
SGMII
Network
x2
11
External Interfaces
Memory Subsystem Application-Specific
Coprocessors
CorePac
MSM
64-bit SRAM Memory Subsystem
DDR3 EMIF
MSMC Multicore Navigator
Network Coprocessor
External Interfaces
C66x™
CorePac 2x SGMII ports – support
10/100/1000 Ethernet
L1P L1D
L2 4x SRIO lanes for inter-DSP xfrs
1 to 8 Cores @ up to 1.25 GHz SPI for boot operations
HyperLink TeraNet
UART for development/test
Multicore Navigator
2x PCIe at 5Gbps
I2C for EPROM at 400 Kbps
SRIO x4
Application
Specific I/O
PCIe x2
Application
Specific I/O
GPIO
Ethernet
UART
Switch
GPIO
SPI
I 2C
App-specific interfaces
SGMII
Network
x2
12
GrabBag - 13d - 6 C6000 Embedded Design Workshop Using BIOS - C66x Introduction
C66x Family Overview
13
S DDR3 M
CPUCLK/2
S Shared L2 MSMC
HyperLink M
S S S S M DDR3
TPCC TC0 M
16ch QDMA TC1 M
EDMA_0
• Facilitates high-bandwidth
XMC
communication links between
DSP cores, subsystems,
SRIO
M
SS Core
L2 0-3 M
Core M peripherals, and memories.
SS Core M • Supports parallel orthogonal
M
M
Network M
Coprocessor communication links
S SRIO
TPCC TC2 M
128bit TeraNet
TPCC TC3
64ch M
TC6
TC4 M
M S TCP3e_W/R
QDMA64ch TC5TC7
M
M
CPUCLK/3
TC8 M
QDMA TC9 M
S TCP3d
EDMA_1,2 S TCP3d
TAC_FE M S TAC_BE
S RAC_FE
RAC_BE0,1
RAC_BE0,1 MM S RAC_FE
FFTC / PktDMA M
FFTC / PktDMA M
S SVCP2 (x4)
AIF / PktDMA M SVCP2
SVCP2
(x4)
VCP2(x4)
(x4)
QMSS M
PCIe M S QMSS
S PCIe
DebugSS M
C6000 Embedded Design Workshop Using BIOS - C66x Introduction GrabBag - 13d - 7
C66x Family Overview
Diagnostic Enhancements
Memory Subsystem Application-Specific
Coprocessors
CorePac
MSM
64-bit SRAM Memory Subsystem
DDR3 EMIF
MSMC Multicore Navigator
Debug & Network Coprocessor
Trace
External Interfaces
C66x™ TeraNet Switch Fabric
CorePac Diagnostic Enhancements
L1P L1D
L2 Embedded Trace Buffers (ETB)
1 to 8 Cores @ up to 1.25 GHz enhance CorePac’s diagnostic
HyperLink TeraNet capabilities
Multicore Navigator CP Monitor provides diagnostics
on TeraNet data traffic
Automatic statistics collection
and exporting (non-intrusive)
Can monitor individual events
Monitor all memory transactions
Common and App-specific I/O Network Configure triggers to determine
Coprocessor
when data is collected
15
HyperLink Bus
Memory Subsystem Application-Specific
Coprocessors
CorePac
MSM
64-bit SRAM Memory Subsystem
DDR3 EMIF
MSMC Multicore Navigator
Network Coprocessor
External Interfaces
C66x™ TeraNet Switch Fabric
CorePac Diagnostic Enhancements
L1P L1D HyperLink Bus
L2
1 to 8 Cores @ up to 1.25 GHz
Expands the TeraNet Bus to
external devices
HyperLink TeraNet
Multicore Navigator
Supports 4 lanes with up to
12.5Gbaud per lane
16
GrabBag - 13d - 8 C6000 Embedded Design Workshop Using BIOS - C66x Introduction
C66x Family Overview
Miscellaneous Elements
Memory Subsystem Application-Specific
Coprocessors
CorePac
MSM
64-bit SRAM Memory Subsystem
DDR3 EMIF
MSMC Multicore Navigator
Network Coprocessor
Boot ROM External Interfaces
HW Sem C66x™ TeraNet Switch Fabric
Power
Mgmt
CorePac Diagnostic Enhancements
PLL L1P L1D HyperLink Bus
EDMA
x3
L2 Miscellaneous
1 to 8 Cores @ up to 1.25 GHz
x3
Boot ROM
HyperLink TeraNet
HW Semaphore provides atomic
Multicore Navigator access to shared resources
Power Management
PLL1 (Corepacs), PLL2 (DDR3),
PLL3 (Packet Acceleration)
Three EDMA Controllers
Network Eight 64-bit Timers
Common and App-specific I/O
Coprocessor Inter-Processor Communication
(IPC) Registers
17
C6000 Embedded Design Workshop Using BIOS - C66x Introduction GrabBag - 13d - 9
C66x Family Overview
• Three modes:
TSIP x2
• Synchronized SRAM
• NAND Flash
Common and App-specific I/O Network • NOR Flash
Coprocessor
19
GrabBag - 13d - 10 C6000 Embedded Design Workshop Using BIOS - C66x Introduction
C665x Low-Power Devices
EDMA
1 or 2 Cores @ up to 1.25 GHz
VCP2 x2
Hardware Coprocessors
HyperLink TeraNet
• TCP3d, VCP2
Multicore Navigator Multicore Navigator
Queue Packet Interfaces
Manager DMA
• 2x McBSP, SPI, I2C, UPP, UART
• 1x 10/100/1000 SGMII port
x2
McBSP x2
x2
x4
EMIF16
Ethernet
GPIO
UART
I2 C
MAC
SPI
SRIO
PCIe
22
Power
Management
32KB L1 32KB L1
PLL
P-Cache D-Cache Multicore Navigator
x2 1024KB L2 Cache
EDMA Interfaces
1 Core @ 850 MHz
• 2x McBSP, SPI, I2C, UPP, UART
TeraNet
Multicore Navigator
• 1x 10/100/1000 SGMII port
Queue
Manager
Packet • EMIF 16, GPIO
DMA
Debug and Trace (ETB/STB)
x2
McBSP x2
x2
EMIF16
Ethernet
GPIO
UPP
UART
I2 C
MAC
SPI
PCIe
SGMII
23
C6000 Embedded Design Workshop Using BIOS - C66x Introduction GrabBag - 13d - 11
C665x Low-Power Devices
HyperLink No Yes
24
GrabBag - 13d - 12 C6000 Embedded Design Workshop Using BIOS - C66x Introduction
MCSDK Overview
MCSDK Overview
What is the MCSDK ?
What is MCSDK?
The Multicore Software Development Kit (MCSDK)
provides the core foundational building blocks for
customers to quickly start developing embedded
applications on TI high performance multicore DSPs.
Uses the SYS/BIOS or Linux real-time operating system
Accelerates customer time to market by focusing on ease
of use and performance
Provides multicore programming methodologies
28
Eclipse
Code Third
Composer Party
StudioTM Plug-Ins
Editor PolyCore
CodeGen ENEA
OpenMP Optima
3L
Multicore Software Development Kit
Profiler
Critical
Debugger Blue
Remote
Debug
Multicore System
Analyzer
Visualization
29
C6000 Embedded Design Workshop Using BIOS - C66x Introduction GrabBag - 13d - 13
MCSDK Overview
Software Architecture
No modifications required
Software may be
different, but API
May be used “as is” or customer can
implement value-add modifications remain the same
(CSL, LLD, etc.)
Needs to be modified or replaced
with customer version
32
BIOS-MCSDK Software
Demonstration Applications
Image
HUA/OOB IO Bmarks
Processing
Transports SYS/BIOS
DSPLIB IMGLIB MATHLIB Platform RTOS
- IPC
Library
- NDK
OSAL Bootloader
PCIe QMSS CPPI HyperLink …
Hardware
33
GrabBag - 13d - 14 C6000 Embedded Design Workshop Using BIOS - C66x Introduction
MCSDK Overview
Process
Process
Process
Process
Process
Process
Process
Process
Shared Memory x x
2
1
1
BIOS
BIOS
BIOS
BIOS
Navigator/QMSS x x
PCIe x x x
SoC Hardware and Peripherals SoC Hardware and Peripherals
HyperLink x x x
Device 1
Process
Process
Process
Process
Process
Process
Process
2
2
1
1
Linux
BIOS
BIOS
BIOS
SysLink IPC IPC IPC
34
C6000 Embedded Design Workshop Using BIOS - C66x Introduction GrabBag - 13d - 15
For More Info…
CCS v5
http://processors.wiki.ti.com/index.php/Category:Code_Composer_Studio_v5
Developer’s website
Linux: http://linux-c6x.org/
BIOS: http://processors.wiki.ti.com/index.php/BIOS_MCSDK_2.0_User_Guide
Download User’s
Software Guide
For questions regarding topics covered in this training, visit the following e2e support forums:
http://e2e.ti.com/support/dsp/c6000_multi-core_dsps/f/639.aspx http://e2e.ti.com/support/embedded/f/355.aspx
Software
Forums
38
GrabBag - 13d - 16 C6000 Embedded Design Workshop Using BIOS - C66x Introduction
Notes
Notes
C6000 Embedded Design Workshop Using BIOS - C66x Introduction GrabBag - 13d - 17
Notes
Notes
GrabBag - 13d - 18 C6000 Embedded Design Workshop Using BIOS - C66x Introduction