![]() |
![]() |
Using KwikNet with the ADI VDK |
![]() ![]() |
![]() |
Contents
Introduction
The KwikNet Sample Program
Building the KwikNet Library
Building the KwikNet Sample Program
Creating a Project from Scratch
![]() |
![]() |
![]() |
![]() |
||||||||||||||||||||||||||||||||||||||||||||
![]() |
|
KN_BOARD.C |
KwikNet board support for the Blackfin VDK board |
KNCONSOL.C |
KwikNet console I/O services |
KNRECORD.C |
KwikNet message logging services |
KNSAMOS.C |
KwikNet Sample Program OS interface for the Blackfin VDK |
KNBF5XXS.C |
Blackfin ADSP-BF5xx UART I/O support |
KNBF5XX.ASM |
Exception Handler Function UserExceptionHandler() UserExceptionHandler() EXCPT 1 UserExceptionHandler() |
KNSAMPLE.C |
TCP/IP client/server sample program |
KNSAMPLE.LDF |
Link Description File The size and location of all memory segments have been specified to accommodate the memory requirements of the KwikNet sample programs. |
KNSAMPLE.VDK |
VDK configuration parameters |
VDK.CPP |
VDK configuration module |
VDK.H |
VDK configuration definitions |
The KwikNet Sample Program project has a basic VDK configuration
consisting of three predefined thread types, as shown below.
![]() |
![]() |
Thread
The |
The KwikNet samples have a single boot thread,
kn_ostboot
. This boot thread is
the actual KwikNet Task thread kn_ostmain
.
The kn_ostmain
initialization code prepares
KwikNet for use, launches the sample program application
(i.e. spawns one or more apptask
threads)
and then waits for the application to start KwikNet with
a call to kn_enter()
KwikNet creates three semaphores at startup and will create a semaphore for each thread that needs to block pending completion of a KwikNet operation. As shown below, the VDK configuration must accommodate the dynamic creation of semaphores.
Prior to building the KwikNet TCP/IP Sample Program, you must build the KwikNet Library. The library and the features to be included in it are specified in the KwikNet Network Parameter File which you can edit using the KwikNet Configuration Manager. The TCP/IP Sample Program Network Parameter File
KNSAMLIB.UP
is located in directoryTOOLAD\SAM_TCP
.A make file is used to build the KwikNet Library. The make file is generated from the KwikNet Network Parameter File. To allow the KwikNet Library to be built without having to leave the IDDE environment, KADAK has provided script file
KNMKLIB.TCL
which resides in the same directory as the VisualDSP++ project file. The script generates the make file and invokes the Microsoft NMAKE utility to use it to build the KwikNet Library. You will have to modify the script fileKNMKLIB.TCL
if you wish to use a different make utility. Run the script from the IDDE as shown below.Notes:
KNMKLIB.TCL
requires that environment variableTRKPATH
be set to point to your Treck installation directory.KNMKLIB.TCL
contains relative file path information. The script may need to be modified if it is not run from one of the KwikNet Sample Program directories.- To build the KwikNet Library without using the script, read the section below, Creating a Project from Scratch.
When the script for the TCP/IP Sample Program completes, there will be one library file,
KN743IP.DLB
, in theTOOLAD\LIB
directory. If you edit your Network Parameter File, you must run theKNMKLIB.TCL
script again to regenerate your KwikNet Library.
The KwikNet Sample Program requires access to the
INCLUDE
directory of your Treck installation. The VisualDSP++ IDDE project for the KwikNet Sample Program has been configured to search directoryof the current drive for the required header files. If your Treck installation is on a different drive or has a different path, you will have to adjust the include path setting of the KwikNet Sample Program project before building the sample. \TRECK\INCLUDE
Build the sample program as shown below. A notification message may pop up indicating that the project settings have changed. To acknowledge the message, if and when it pops up, click on the Yes button. The output window will display progress messages as the various sample program modules are compiled, assembled and linked. The output window will appear as illustrated below once the sample program has been successfully built.
The program may or may not be automatically loaded by the simulator, depending on your VisualDSP++ preference settings.
To create a VisualDSP++ project to use KwikNet with the Analog Devices VDK, proceed as described in this section. It is recommended that you start with an existing project such as that used to build the KwikNet TCP/IP Sample Program. It will be assumed, for purposes of illustration, that KwikNet for Blackfin is installed in directory
and that the Treck TCP/IP stack is installed in directory C:\KNT743
. C:\TRECK
Before creating your VisualDSP++ project, use the KwikNet Configuration Builder to create your KwikNet Network Parameter File as described in Chapter 2 of the KwikNet TCP/IP Stack User's Guide. Alternatively, use the builder to edit the Network Parameter File
provided with the KwikNet TCP/IP Sample Program. If you are creating a new Network Parameter File, be sure to select the Blackfin ADSP-BF5xx target and the Analog Devices VDK operating system as shown in the following snapshots. Selecting Standard C as the Memory Allocation scheme will direct KwikNet to allocate memory from the program heap using standard calls to the C runtime library. Refer to the KwikNet TCP/IP Stack User's Guide for the memory allocation requirements of KwikNet. KNSAMLIB.UP
The Network Parameter File
KNSAMLIB.UP
is used to generate the Network Library Make FileKNSAMLIB.MAK
. If your Network Parameter File changes, you must regenerate the Network Library Make File, rebuild the KwikNet Library and rebuild your application.The KwikNet Library cannot be built until the VDK header file
VDK.H
is available. FileVDK.H
is created by the VisualDSP++ IDDE.Create a new project as shown below.
Open the Project Options window as shown below. Specify your target processor (in this case, the ADSP-BF537) and enter the path to the
INCLUDE
directory of your Treck installation. If necessary, specify directory paths for other KwikNet options used by your application.
The following table outlines the locations of the various header files relative to the installation directory. If you are creating your project in a subdirectory of the KwikNet installation directory (e.g.
), it is best to specify paths relative to the project directory. By doing so, the entire KwikNet installation directory can be copied or moved to another directory without having to revise all of the path information in the project settings. You may also need to specify the current working directory C:\KNT743\TOOLAD\MYSAMPLE
in your list of includes. The table below also lists the KwikNet runtime libraries which must be added to your link options if the indicated services are used by your application. "."
Directory Library Services \TRECK\INCLUDE
..\LIB\KN743IP.DLB
IP related header files; TCP, UDP sockets interface; SLIP, PPP, PING, DNS, DHCP, FTP, TFTP, Telnet, SMTP. This path must be specified. An up-to-date copy of file VDK.H
(produced by the IDDE) must be copied to this directory before you build the KwikNet Library...\LIB\KN743IPS.DLB
IPsec support. ..\LIB\KN743IP6.DLB
IPv6 support. \TRECK\SNMPD
..\LIB\KN743SNM.DLB
Simple Network Management Protocol (SNMP) agent and services. ..\TOOLAD\DRIVERS
Board and device driver definitions. Must be included to use any of the standard KwikNet board support modules or Ethernet or serial device drivers. ..\TOOLAD\SAM_COMN
Console and sample program O/S interface. Not needed if you have created your own equivalents.
Link options must also be entered. From the table above, determine which KwikNet runtime libraries your application will require and specify the library names in the Additional options field. All KwikNet sample programs are designed to execute from SDRAM. Define linker symbolUSE_SDRAM
, as shown, to permit the Link Discription File to locate code and data in SDRAM. You may also wish to enable the Generate symbol map option to aid in the positioning and sizing of memory sections. Note that the L1 Memory Usage has been configured for Cache.
To guard against the possibility of invalid address faults caused by speculative load execution, set the CSYNC compiler option as shown below.
Set the maximum number of running threads to a value that is reasonable for your application. Specify the predefined thread types required by KwikNet and create a boot thread as shown below.
Set the maximum number of active semaphores to values that are reasonable for your application. KwikNet requires, at most, three semaphores for its own use plus one semaphore for every application task that can be blocked waiting for access to or service by KwikNet. Set all other VDK system parameters to values that are reasonable for your application.
Note that the Tick Period is set to 1 ms. This period should be adequate for most systems without too much burden imposed by servicing clock interrupts. If you set the tick period to a value other than 1 ms, you must modify the definition of symbol
CLKFREQ
in fileand rebuild your KwikNet Library. KN_OSIF.C
At this point, you may add other VDK objects needed for your application. Once your VDK setup is complete, you must force an update of the VDK kernel source by right-clicking on Kernel in the Project pane and selecting Update Kernel Source from the pop-up menu, as shown below. Your VDK edits will be saved in file
. Remember that file VDK.H
must be copied to directory VDK.H
prior to building the KwikNet Library. C:\TRECK\INCLUDE
Add the necessary KwikNet source files (or your equivalents) to the project as shown below. Replace file
generated by VisualDSP++ with the KwikNet equivalent ExceptionHandler-BF537.asm
. Note that Link Description File KNBF5XX.ASM
and all of the Kernel Files are created automatically by VisualDSP++. VDK-BF537.ldf
When you create a project from scratch, the VisualDSP++ IDDE will select one of the default Link Description Files from directory
in your VisualDSP++ installation directory. The heap storage provided by the default Link Description Files is not sufficient for the KwikNet sample programs. Use one of the KwikNet sample Link Description Files, like BLACKFIN\LDF
, as a guide. KNSAMPLE.LDF
KwikNet for Blackfin provides function
which permits a function coded in C to execute in supervisor mode in order to perform privileged I/O operations. The function generates a software exception which causes the switch to supervisor mode. The application C function is called with the two parameters provided by the kn_syscall()
caller. Function kn_syscall()
in module kn_iouart()
provides an example of the proper use of function KNBF5XXS.C
. kn_syscall()
If you are not building for an ADSP-BF537 target, edit file
. Change all the C:\KNT743\TOOLAD\KNZZZCC.INC
compiler options to match your processor. -proc ADSP-BF537
In preparation for building the KwikNet Library, copy header file
from the project directory to directory VDK.H
. Make directory C:\TRECK\INCLUDE
the current directory. Run the Microsoft NMAKE utility, or your equivalent, using the KwikNet Network Library Make File generated earlier. Define symbols C:\KNT743\MAKE
TOOLSET
andKPF
to identify the Analog Devices toolset mnemonic (AD
) and provide the path to the KwikNet Network Parameter File.NMAKE /f..\toolad\sam_tcp\knsamlib.mak TOOLSET=AD TRKPATH=C:\treck KPF=..\toolad\sam_tcp\knsamlib.upWhen generating the library for the KwikNet TCP/IP Sample Program, KwikNet Library
will be produced in directory KN743IP.DLB
. C:\KNT743\TOOLAD\LIB
Finally, build your application as described in the section titled Building the KwikNet Sample Program.
![]() |
|
![]() |
Top of page |
![]() |
Copyright © 2002-2005
KADAK Products Ltd.
All rights reserved.
Last updated: September 15, 2005