|
Part 2ıBuilding on the Basics
by Ed Sutter
Start ı The
Ethernet Interface ı The Command Line Interface
ı "Get Your Tokens Here" ı One
Last Topic About CLI ı Executable Scripts
ı Application-to-Monitor Hook-Up ı The
Moncom() Function ı The Monconnect() Function
ı Letıs Regroup ı Xmodem
and Tftp ı OK, Iım Done! ı Sources
and PDF
In last monthıs article, we initialized
the UART for printf(), the exception handlers in place, and
basic flash interfaces initialized. This month, letıs do some miscellaneous
initialization of basic monitor facilities like the command line history
buffer, malloc()ıs heap space structures, shell variable storage,
and file system control structures.
At this point, you can assume that the
basic system is initialized. Most of what I showed you in Part 1 is
typical for a monitor. But, from this point on, letıs assume the existence
of files, both data and executable, so we can start breaking away
from just being a simple boot monitor. You can now overlay a format
on the section of flash memory thatıs to be allocated to the tiny
flash file system (TFS).
TFS is a linear file storage system that
provides an embedded system with the ability to treat flash memory
as name space instead of address space. After the code accesses the
flash memory as internally organized names, a whole new level of functionality
becomes available to the monitor. [1]
First, the monitor looks to this flash
space to see if it can make any sense of it. If not, then you are
alerted that the file system is corrupted and it must be cleaned up.
If there is a valid set of files, then the monitor looks for a file
called monrc (run control file for the monitor). If this file
is found, it is automatically run as an executable file. For now,
use it for what it was originally intended for, to establish an IP,
gateway, network mask, and MAC address for the target. This is done
by setting some shell variables (IPADD, GIPADD, ETHERADD,
and NETMASK, respectively). Listing 1 is an example monrc
file for setting sell variables.
|
set IPADD 1.2.3.4 # My
IP address
set GIPADD 1.2.3.1 #
My networkıs gateway IP address
set NETMASK 255.255.255.0 #
My networkıs net mask
set ETHERADD 00:11:22:33:44:55 #
My ethernet (or MAC) address
|
| Listing 1ıHere
you can see the basic monrc file |
.
Notice that Listing 1 is a script, not
a binary executable. This is the first of several features that become
available through TFS. This monrc file simply executes the
monitor command set four times, and the result is that those four
shell variables are initialized and now accessible to other portions
of monitor code. For the immediate case, the monitor uses these variables
for initializing the Ethernet driver.
NEXT
Circuit Cellar provides up-to-date information for engineers. Visit
www.circuitcellar.com for
more information and additional articles.
For subscription information, call (860) 875-2199, subscribe@circuitcellar.com
or subscribe online.
ıCircuit Cellar, the Magazine for Computer Applications. Posted with
permission. |