NET+OS with GNU Tools
BSP Programmer’s Guide
Operating system/version: NET+OS 6.0
Part number/version: 90000332_B
Release date: March 2006
www.digi.com
NET+Works with GNU Tools
BSP Porting Guide
©2006 Digi International Inc.
Printed in the United States of America. All rights reserved.
a Digi, Digi International, the Digi logo, the Making Device Networking Easy logo, NetSilicon,
Digi International Company, NET+OS and NET+Works are trademarks or registered
trademark of Digi International, Inc. in the United States and other countries worldwide. All
other trademarks are the property of the respective owners.
Information in this document is subject to change without notice and does not represent a
commitment on the part of Digi International.
Digi provides this document "as is," without warranty of any kind, either expressed or
implied, including, but not limited to, the implied warranties of, fitness or merchantability
for a particular purpose. Digi may make improvements and/or changes in this manual or in
the product(s) and/or the program(s) described in this manual at any time.
This product could include technical inaccuracies or typographical errors. Changes are made
periodically to the information herein; these changes may be incorporated in new editions
of the publication.
Contents
      v
Chapter 1:
BSP Overview .................................................................... 1
Overview ........................................................................................................................2
Hardware reset .............................................................................................................. 2
ROM startup...................................................................................................................3
ncc_init routine ....................................................................................................4
C library startup.............................................................................................................4
main routine......................................................................................................... 5
NABoardInit routine.....................................................................................................5
netosStartup routine ...........................................................................................6
Chapter 2:
Processor Modes and Exceptions................................9
Overview ...................................................................................................................... 10
Vector table................................................................................................................... 10
IRQ handler .................................................................................................................. 11
Servicing interrupts........................................................................................... 12
Changing interrupt priority............................................................................. 13
Interrupt sources and default priorities................................................................... 13
Interrupt service routines........................................................................................... 14
FIQ handlers................................................................................................................. 15
Installing a FIQ handler....................................................................................15
vi      
Chapter 3: Customizing the BSP
for Application Hardware ................................................................................ 1
7
Overview ...................................................................................................................... 18
Before you begin.......................................................................................................... 18
Task 1: Purchase Ethernet MAC addresses from the IEEE ................................... 19
Task 2: Create a new platform directory ................................................................. 20
Task 3: Modify the BSP configuration settings ....................................................... 20
Task 4: Modify the BSP makefile .............................................................................. 21
Task 5: Modify the linker scripts............................................................................... 21
Bootloader considerations ............................................................................... 22
Task 6: Modify the new BSP to support your application hardware .................. 22
Phase Lock Loop ............................................................................................... 23
Memory timing settings................................................................................... 23
Chip select settings ........................................................................................... 24
General purpose I/O settings ......................................................................... 25
Ethernet PHY..................................................................................................... 28
Simple serial driver........................................................................................... 28
Task 7: Modify the format of BSP arguments in NVRAM.................................... 28
Task 8: Modify error and exception handlers......................................................... 29
Task 9: Create the debugger initialization files....................................................... 30
Task 10: Debug the initialization code ..................................................................... 32
Working with a locked-up ICE ....................................................................... 32
Preparing to debug ........................................................................................... 33
Debugging the initialization code .................................................................. 34
Task 11: Modify the Startup dialog .......................................................................... 37
Task 12: Modify the POST ......................................................................................... 37
Task 13: Modify the ACE ........................................................................................... 37
Chapter 4:
Device Drivers............................................................................. 39
Overview ...................................................................................................................... 40
Adding devices............................................................................................................ 40
deviceInfo structure.................................................................................................... 40
Device driver functions.............................................................................................. 42
      vii
deviceEnter ........................................................................................................ 43
deviceInit ........................................................................................................... 44
deviceOpen........................................................................................................ 45
deviceClose ........................................................................................................ 47
deviceConfig ..................................................................................................... 48
deviceRead ........................................................................................................ 49
deviceWrite ....................................................................................................... 51
deviceIoctl .......................................................................................................... 53
Modifications to Cygwin’s standard C library and startup file ........................... 54
Modifying the libc.a library and crt0.o startup file ...................................... 54
Chapter 5:
Updating Flash Support......................................................55
Overview ...................................................................................................................... 56
Flash table data structure ........................................................................................... 57
Adding new flash ........................................................................................................ 59
Supporting larger flash...............................................................................................60
Chapter 6:
Bootloader Utility Overview........................................... 61
Overview ...................................................................................................................... 62
Bootloader application images ..................................................................................62
ROM image ........................................................................................................ 63
RAM image ........................................................................................................ 63
Application image structure ......................................................................................64
Application image header................................................................................ 64
Boothdr utility.............................................................................................................. 66
Generating an image................................................................................................... 67
Configuration file .............................................................................................. 67
viii      
Chapter 7: Customizing the Bootloader Utility ........................ 69
Overview ...................................................................................................................... 70
Customization hooks.................................................................................................. 70
NABlReportError ............................................................................................. 71
getMacAddress ................................................................................................. 72
isImageValid ..................................................................................................... 73
shouldDownloadImage ................................................................................... 74
getDefaultFilename.......................................................................................... 75
downloadImage ............................................................................................... 76
Chapter 8:
Linker Files .................................................................................... 77
Overview ...................................................................................................................... 78
Linker files provided for sample projects................................................................ 78
Basic GNU Tools sections of the linker files.................................................. 79
NET+OS section of the linker files.................................................................. 79
Memory aliasing in NET+OS .................................................................................... 80
Address mapping.............................................................................................. 82
Chapter 9:
Hardware Dependencies ..................................................... 83
Overview ...................................................................................................................... 84
DMA channels ............................................................................................................. 84
Ethernet PHY ............................................................................................................... 85
ENI controller .............................................................................................................. 85
Serial ports....................................................................................................................86
Software watchdog ..................................................................................................... 86
Big Endian mode ......................................................................................................... 86
System clock................................................................................................................. 86
PLLTST_SELECT............................................................................................... 87
XTAL1_FREQUENCY...................................................................................... 87
CRYSTAL_OSCILLATOR_FREQUENCY..................................................... 87
PLL_CONTROL_REGISTER_N_VALUE...................................................... 88
      ix
System timers ...............................................................................................................88
Timer 1 ................................................................................................................ 88
Timer 2 ................................................................................................................ 88
Interrupts ......................................................................................................................89
Memory map................................................................................................................ 90
Index
x      
Using This Guide
      xi
Review this section for basic information about the guide you are using, as well
as general support and contact information.
About this guide
This guide provides general information for porting the NET+OS Board Support
Package (BSP) with GNU Tools to a new hardware platform based on the Digi
development board. NET+OS, a network software suite optimized for
the NET+ARM devices, is part of the NET+Works integrated product family.
Software Release
This guide supports NET+OS 6.0. By default, this software is installed in the
C:/NETOS60_GNU/directory.
Using This Guide
xii      
NET+Works with GNU Tools BSP Porting Guide
Who should read this guide
This guide is for engineers who are developing applications with NET+OS.
To complete the tasks described in this guide, you must:
Be familiar with installing and configuring network software and
development board systems
Have sufficient system or user privileges to do these tasks
What’s in this guide
This table shows where you can find specific information in this guide:
To read about See
The BSP and how it works Chapter 1, “BSP Overview”
The modes in which NET+OS operates, and
how interrupts are handled
Chapter 2, “Processor Modes and
Exceptions”
How to modify the BSP to support your
application hardware
Chapter 3, “Customizing the BSP for
Application Hardware”
Device driver functions and device definitions Chapter 4, “Device Drivers”
Adding new flash ROM parts to the existing
table of supported flash ROM parts
Chapter 5, “Updating Flash Support”
What the bootloader utility is Chapter 6, “Bootloader Utility
Overview”
How to customize the bootloader utility to
support your applications
Chapter 7, “Customizing the
Bootloader Utility”
The linker files provided for sample projects,
including basic GNU and NET+OS sections of
the linker files
Chapter 8, “Linker Files”
Hardware dependencies for porting NET+OS
to your application hardware
Chapter 9, “Hardware Dependencies”
www.digi.com
     xiii
Conventions used in this guide
This table describes the typographic conventions used in this guide:
Related documentation
NET+Works Quick Install Guide explains how to install the hardware.
NET+Works with GNU Tools Programmer’s Guide describes how to use
NET+OS to develop programs for your application and hardware.
The NET+Works online help provides reference information on the
NET+OS application programming interfaces (APIs).
Review the documentation CD-ROM that came with your development kit for
information on third-party products and other components.
For information about
your processor, see your hardware documentation.
Customer support
To get help with a question or technical problem with this product, or to make
comments and recommendations about our products or documentation, use this
This convention Is used for
italic type
Emphasis, new terms, variables, and document titles.
Select menu menu
option or options.
Menu selections. The first word is the menu name; the
words that follow are menu selections.
monospaced type
Filenames, pathnames, and code examples.
contact information:
xiv       
NET+Works with GNU Tools BSP Porting Guide
United State telephone: 1 877 912-3444
International telephone: 1 952 912-3444
Web site: http://digi.com
       1
BSP Overview
CHAPTER 1
This chapter provides general information about the NET+OS Board Support
Package (BSP) and also describes how it operates.
Overview
2       
NET+Works with GNU Tools BSP Porting Guide
Overview
The BSP consists of the hardware-dependent parts of the real-time operating
system (RTOS), which includes:
Initializing the hardware after a hard reset or a restart
Exception handling
Device drivers
Starting the ThreadX kernel
Starting the TCP/IP stack
The NET+OS BSP that is provided with the NET+Works development kit is
designed to work on NET+Works development boards. Because most user
applications require custom hardware, you will need to modify the NET+OS
BSP to work correctly on your application hardware.
The rest of this chapter describes how the BSP initializes the hardware.
Hardware reset
At startup, the NET+ARM reads the state of all external address lines to determine
how to configure itself. All NET+ARM address lines have input current sources so
that, if left unchanged, the address lines are in the high state.
Hardware configuration settings are implemented through pull-up and pull-down
resistors attached to these pins.
NET+OS requires these configuration settings:
Configuration Address Mode State
Endian A27 Big Endian High
CPU bootstrap A28 ARM CPU enabled High
www.digi.com
       3
BSP Overview
At startup, the NET+ARM performs these steps:
1 Resets all internal devices
2 Disables all chip selects except CS0
3 Configures CS0 to map the contents of the ROM to all memory
4 Disables cache
At reset, the ARM processor core performs these steps:
1 Enables ARM mode
2 Sets Supervisor mode
3 Disables IRQ and FIQ interrupts
4 Sets the program counter (PC) to 0
5 Starts executing at 0 (512 clocks after reset is de-asserted)
ROM startup
After a hardware reset, the first code executed is in C:/NETOS60_GNU/src/bsp/
common/reset.s.
This code jumps to the Reset_Handler_Rom routine, in
C:/NETOS60_GNU/src/bsp/arm7init/init.s, which performs these steps:
1 Sets the processor mode and disables all interrupts.
2 Initializes the phase lock loop (PLL) on the NET+50.
3 Sets the BSPEED field in the System Control register to enable full bus speed.
4 Executes a soft reset.
5 Places the direct memory access (DMA) controller into test mode.
The on-chip static RAM, which normally stores DMA context
information and register values, becomes available as RAM.
6 Sets the SVC stack pointer to point to the DMA RAM.
7 Calls the ncc_init routine to initialize the application hardware.
8 Sets up stacks for all processor modes.
C library startup
4       
NET+Works with GNU Tools BSP Porting Guide
9 Releases the DMA controller from test mode.
10 Calls the C library startup routines. These routines do not return.
ncc_init routine
To complete the basic hardware initialization of the system, Reset_Handler_Rom
calls the ncc_init routine. The routine performs this process:
1 Calls customizeSetupMMCR to set the Memory Management Control register.
2 Calls customizeGetScr to set the System Control register.
3 Determines whether a software restart has occurred.
4 Determines whether a debugger is attached.
5 Calls customizeSetupPortX routines to set up the general-purpose I/O
(GPIO) ports.
6 Calls customizeSetupCS0 to set up CS0.
7 Sets up the other chip selects.
If a startup reset has occurred, all the chip selects are initialized.
Otherwise, the default implementation assumes that the RAM chip
selects have already been set up and reinitializes only
CS3, which is
normally used to support non-volatile RAM (NVRAM).
8 Calls customizeReadPowerOnButtons to read and save the state of buttons and
jumpers.
9 Verifies that the application can fit in available RAM.
10 Sets flags in memory (which is now set up) to indicate whether a debugger
is present and whether a software reset has occurred.
C library startup
The C library startup sets up the C runtime environment in two steps:
1 Copies initialized data from ROM to RAM and resets uninitialized
data to
0
2 Calls the main routine
www.digi.com
       5
BSP Overview
main routine
After the C runtime environment is set up, the C runtime code calls the main
routine. The
main routine performs this process:
1 Calls customizeSetupLedTable to initialize the LED driver
2 Executes a power-on self-test (POST) if a hard reset has occurred and
APP_POST is set
3 Sets up the system vector table
4 Calls NABoardInit to shut down DMA, the Ethernet media access controller
(MAC), ENI, and serial ports; initialize the low-level flash and NVRAM
APIs; and turn on cache if the NET+ARM supports it.
5 Calls DDIFirstLevelInitilize to perform preliminary initialization of
system device drivers
6 Calls NAGetAppCpp, which initializes the C++ runtime environment if APP_CPP
is defined
7 Calls tx_kernel_enter to start the ThreadX kernel
NABoardInit routine
The NABoardInit routine in the narmbrd.c file performs this process:
1 Reads the chip revision and stores it in the g_NAChipRevision global variable
2 Shuts down all DMA channels, the Ethernet controller, and all serial ports
3 Masks all interrupts
4 Initializes the flash and NVRAM read and write APIs
5 Calls NACacheSetDefaults to initialize and turn on cache
NABoardInit routine
6       
NET+Works with GNU Tools BSP Porting Guide
netosStartup routine
The startup sequence is completed in the netosStartup routine, which performs
these steps:
1 Sets up the semaphores that the flash driver uses in a multithreaded
environment.
2 Sets up the sleep function that the NAWait function uses.
3 Loads default NVRAM parameters from the appconf.h file.
4 Calls DDISecondLevelInitialize to load the system device drivers.
This function calls the
deviceInit function defined for each device in
the device table.
5 Creates the TCP timer thread to trigger calls to tcp_down_function, which
calls the
TcpDown application each second.
6 Calls customizeDialog to prompt the user with a configuration dialog box.
7 Calls netosConfigStdio.
If
APP_STDIO_PORT is defined in appconf.h as a valid device name,
netosConfigStdio redirects stdin, stdout, and stderr to the indicated
device.
8 Starts the time APIs and sets the time zone to the value stored in NVRAM,
which is
EST by default.
9 Calls filesystem_init if BSP_INCLUDE_FILESYSTEM_For_CLIBRARY is defined as
1. The filesystem_init call initializes the filesystem for C library file
functions.
10 Calls netosStartTCP to create and initialize resources (for example,
semaphores and memory), and to start up all threads required by the
TCP/IP stack.
The Address Configuration Executive (ACE) is used to set the IP
parameters. The parameters may be stacked in NVRAM, or the ACE
may set them from the network.
The application startup is delayed
BSP_STARTUP_DELAY seconds.
(
BSP_STARTUP_DELAY is defined in bsp.h.)
11 Calls TcpDown once every tick until the TCP/IP stack is initialized.
  • Page 1 1
  • Page 2 2
  • Page 3 3
  • Page 4 4
  • Page 5 5
  • Page 6 6
  • Page 7 7
  • Page 8 8
  • Page 9 9
  • Page 10 10
  • Page 11 11
  • Page 12 12
  • Page 13 13
  • Page 14 14
  • Page 15 15
  • Page 16 16
  • Page 17 17
  • Page 18 18
  • Page 19 19
  • Page 20 20
  • Page 21 21
  • Page 22 22
  • Page 23 23
  • Page 24 24
  • Page 25 25
  • Page 26 26
  • Page 27 27
  • Page 28 28
  • Page 29 29
  • Page 30 30
  • Page 31 31
  • Page 32 32
  • Page 33 33
  • Page 34 34
  • Page 35 35
  • Page 36 36
  • Page 37 37
  • Page 38 38
  • Page 39 39
  • Page 40 40
  • Page 41 41
  • Page 42 42
  • Page 43 43
  • Page 44 44
  • Page 45 45
  • Page 46 46
  • Page 47 47
  • Page 48 48
  • Page 49 49
  • Page 50 50
  • Page 51 51
  • Page 52 52
  • Page 53 53
  • Page 54 54
  • Page 55 55
  • Page 56 56
  • Page 57 57
  • Page 58 58
  • Page 59 59
  • Page 60 60
  • Page 61 61
  • Page 62 62
  • Page 63 63
  • Page 64 64
  • Page 65 65
  • Page 66 66
  • Page 67 67
  • Page 68 68
  • Page 69 69
  • Page 70 70
  • Page 71 71
  • Page 72 72
  • Page 73 73
  • Page 74 74
  • Page 75 75
  • Page 76 76
  • Page 77 77
  • Page 78 78
  • Page 79 79
  • Page 80 80
  • Page 81 81
  • Page 82 82
  • Page 83 83
  • Page 84 84
  • Page 85 85
  • Page 86 86
  • Page 87 87
  • Page 88 88
  • Page 89 89
  • Page 90 90
  • Page 91 91
  • Page 92 92
  • Page 93 93
  • Page 94 94
  • Page 95 95
  • Page 96 96
  • Page 97 97
  • Page 98 98
  • Page 99 99
  • Page 100 100
  • Page 101 101
  • Page 102 102
  • Page 103 103
  • Page 104 104
  • Page 105 105
  • Page 106 106
  • Page 107 107
  • Page 108 108
  • Page 109 109
  • Page 110 110
  • Page 111 111
  • Page 112 112

Ask a question and I''ll find the answer in the document

Finding information in a document is now easier with AI