class notes* - umonfw.com 68 69 73 20 69 73 20 74 68 65 20 66 69 6e 61 6c his is the final 0001e040:...
TRANSCRIPT
Class: LNX-743Speaker: Ed Sutter
[email protected]: Tuesday, April 04, 2006Time: 2:00 - 3:30 PM
MicroMonitor:http://www.umonfw.com
Class Notes*
*Modified slightly (as of May 2010) to update contact information
LNX-743 pg 2
Overview
• What is MicroMonitor?• Look and Feel• Command Set• Tiny File System• uMon API• Scripting• Boot Strategy• uMon Host Tools• Porting• Linux Specific• Wrap Up
LNX-743 pg 3
What is uMon?
LNX-743 pg 4
What is uMon?
Origin of MicroMonitor
Early snippets of code now part of MicroMonitor date back to 1986… It’s been around a while!
History:
1986: CPU=16bit x86memory display commands, homegrown RTOS
1990: CPU=68K breakpoints & single stepping,integration with pSOSintegration with source level debugger
1993: CPU=AMD29Kintegration with more RTOSes
1994: CPU=MIPSstill more RTOSes
1996: Common source tree, common functionalityno hooks to any RTOS or debugger
1998: CPU=ARMmore code commonality too many ports!...porting should be easy
2000: Lucent public access2002: Firmware Demystified/Microcross2003: More public access, more cleanup
Etc, etc…
LNX-743 pg 5
What is uMon?
A Boot Monitor/Loader…
As with most embedded systems, it depends on the need…
Fundamentally:• Basic CPU initialization• Serial (i.e. communications) port• Application transfer
Most likely:• Command line interface• Ethernet (including TFTP/BOOTP etc…)• Memory display/modify/test etc…• Ability to jump into application
Sometimes:• Application can be on-board or downloaded• Bi-directional data transfer• IO-specific commands (pci, i2c, usb, etc…)• Custom hardware commands
More advanced:• Debug facilities (breakpoints, single step, gdb, etc…)• Flash file system• Application API• OS-specific hooks/capabilities• Etc…
LNX-743 pg 6
What is uMon?
Purpose of a Boot Monitor
Does it take the place of an emulator?
Does it eliminate the need for a source level debugger?
Does it eliminate the need for an operating system?
Does it make the application run faster?
Does it make the application run cooler?
LNX-743 pg 7
What is uMon?
MicroMonitor is a Platformto Build On
LNX-743 pg 8
What is uMon?
DOS/BIOS vs. Application/uMon
BIOS is to DOS and uMON is to an embedded application…•Does a DOS application know how it is being put on the PC?
•Does a DOS application have know the format of a file and how it is stored on disk?
•Does a DOS application know how it is started on the PC?
•Does a DOS application know how it is upgraded on a PC?
•Does a DOS application have know where it’s console is or how it gets input from a user?
•Does a DOS application have to use BIOS?
uMon provides the same model for an embedded application on any target; hence, from one target to the next a lot of basic facilities are reusable without any modification.
LNX-743 pg 9
What is uMon?
Linux ARM
SH2 ColdFire
uC/OS-II
pSOS
VxWorks
eCos RTEMS
PPC MIPS
WinCE
LNX-743 pg 10
Look & Feel
LNX-743 pg 11
Look & Feel
MICRO MONITOR 1.2.2Platform: Cogent CSB472
CPU: PowerPC 405GPBuilt: Sep 19 2005 @ 00:13:29Monitor RAM: 0x003000-0x01de28Application RAM Base: 0x01e000
MAC: 00:11:22:33:44:55IP: 192.168.1.110
uMON>
Typical Opening Header
LNX-743 pg 12
Look & Feel
VI MODE: (more powerful, less intuitive)ESC k step back through command historyESC j step forward through command historyh move left on linel move right on line (character “ell”)0 move to beginning of line (character zero)$ move to end of linex delete characteri begin insert mode at current positiona begin append mode at current positionR begin replace mode at current positionr replace single character at current positionD delete from current position to end of linedw delete from current position to first white spacecw replace word from current position to first white space
VT100 MODE: (less powerful, more intuitive)up step back through command historydown step forward through command historyleft move left on lineright move right on line (character “ell”)
Command Line Editing and History
LNX-743 pg 13
Look & Feel
uMON>help dmDisplay MemoryUsage: dm -[24bdefl:msv:] {addr} [byte-cnt]Options: -2 short access -4 long access -b binary -d decimal -e endian swap -f fifo mode -l# size of line (in bytes) -m use 'more' -s string -v {var} quietly load 'var' with element at addr
Required user level: 0uMON>
Command Help
LNX-743 pg 14
Look & Feel
Shell Variables & Symbols
Variable:$VARNAME
uMON> set VARNAME value
uMON> echo $VARNAMEvalueuMON>
Symbol:%SYMNAME
uMON> tfs cat symtblmain 0x14004 func 0x14800
uMON> echo %main0x14004uMON>
LNX-743 pg 15
Look & Feel
Command Line Redirection
General syntax:uMON> echo “this is text” >buffer,buffer_size,[filename]
Typical usage:uMON> echo this is some text >$APPRAMBASE,400 uMON> echo this is another line of text >> uMON> echo this is the final line >>logfile
Result:uMON>dm $APPRAMBASE0001e000: 74 68 69 73 20 69 73 20 73 6f 6d 65 20 74 65 78 this is some tex0001e010: 74 0a 74 68 69 73 20 69 73 20 61 6e 6f 74 68 65 t.this is anothe0001e020: 72 20 6c 69 6e 65 20 6f 66 20 74 65 78 74 0a 74 r line of text.t0001e030: 68 69 73 20 69 73 20 74 68 65 20 66 69 6e 61 6c his is the final0001e040: 20 6c 69 6e 65 20 6f 66 20 74 65 78 74 0a ce 3f line of text..?0001e050: fe 32 5c 7b cf 33 38 33 7e 73 ec 93 d7 3a c8 36 .2\{.383~s...:.60001e060: c9 f7 24 f6 34 33 e4 73 c4 1a ac 5b c6 40 df bb ..$.43.s...[[email protected]: 7f 43 46 3b c5 11 bc 5b ce 39 4c 57 e6 21 ce 13 .CF;...[.9LW.!..
uMON>tfs cat logfilethis is some textthis is another line of textthis is the final line of textuMON>
LNX-743 pg 16
Look & Feel
Command Concatenation & Looping
uMON> echo hellohello
uMON> echo therethere
uMON> echo hello; echo therehellothere
uMON> echo hello; echo there <hellotherehellotherehellothere… (terminated by any input character)
uMON>
LNX-743 pg 17
Command Set
LNX-743 pg 18
Command Set arp 0 Address resolution protocol call 0 Call embedded function cast 0 Cast a structure definition across data in memory. cm 0 Copy Memory dhcp 0 Issue a DHCP discover dis 0 Disassemble memory dm 0 Display Memory echo 0 Print string to local terminal edit 0 Edit file or buffer ether 0 Ethernet interface exit 0 Exit a script flash 0 Flash memory operations fm 0 Fill Memory gdb 0 Enter gdb mode gosub 0 Call a subroutine goto 0 Branch to file tag heap 0 Display heap statistics. help 0 Display command set ? 0 Display command set history 0 Display command history icmp 0 ICMP interface if 0 Conditional branching item 0 Extract an item from a list mt 0 Memory test mtrace 0 Configure/Dump memory trace. pm 0 Put to Memory read 0 Interactive shellvar entry reg 0 Display/modify content of monitor's register cache reset 0 Reset monitor firmware return 0 Return from subroutine set 0 Shell variable operations sleep 0 Second or msec delay (not precise) sm 0 Search Memory strace 0 Stack trace syslog 0 Syslog client ulvl 0 Display or modify current user level. tftp 0 Trivial file transfer protocol tfs 0 Tiny File System Interface unzip 0 Decompress memory (or file) to some other block of memory. xmodem 0 Xmodem file transfer version 0 Version information
LNX-743 pg 19
Command Set
Memory display/modify/test…
Micro-Monitor Command Set:... cast Cast a structure definition across memory. cm Copy Memory dm Display Memory fm Fill Memory mt Memory test pm Put to Memory sm Search Memory...
LNX-743 pg 20
Command Set
Scripting
Micro-Monitor Command Set:... echo Print string to local terminal exit Exit a script gosub Call a subroutine goto Branch to file tag if Conditional branching item Extract an item from a list read Interactive shellvar entry return Return from subroutine set Shell variable operations sleep Second or msec delay (not precise)...
LNX-743 pg 21
Command Set
File/Data Transfer
Micro-Monitor Command Set:... tftp Trivial file transfer protocol xmodem Xmodem file transfer...
LNX-743 pg 22
Command Set
Debugging
Micro-Monitor Command Set:... call Call embedded function cast Cast a structure across memory. dis Disassemble memory gdb Enter gdb mode mtrace Configure/Dump memory trace. strace Stack trace...
LNX-743 pg 23
Command Set
Network
Micro-Monitor Command Set:... arp Address resolution protocol dhcp Issue a DHCP or BOOTP discover ether Ethernet interface icmp ICMP interface syslog Syslog client tftp Trivial file transfer protocol...
Plus… moncmd & TFTP servers
LNX-743 pg 24
Command Set
Target and/or CPU Specific
Micro-Monitor Command Set:... date Display/modify time of day dcr Display/modify DCR register sc Use syscall instruction for breakpoints spr Display/modify SPR register mmu MMU-Specific Operations trap Use trap instruction for breakpoints wd Watchdog xsvf Reprogram on-board CPLD from xsvf file...
LNX-743 pg 25
Command Set
Linux Specific
Micro-Monitor Command Set:... lboot ldaflags...
LNX-743 pg 26
uMon API
LNX-743 pg 27
uMon APITFS:
mon_tfsadd mon_tfsclose mon_tfsctrlmon_tfseof mon_tfsfstat mon_tfsgetlinemon_tfsipmod mon_tfsinit mon_tfslinkmon_tfsnext mon_tfsopen mon_tfsreadmon_tfsrun mon_tfsseek mon_tfsstatmon_tfstell mon_tfstruncate mon_tfsunlinkmon_tfswrite
•Transfer block of ram to TFS as a file•Typical (almost standard) open/close/read/write/seek/tell model•Access to file list•File links
We’ll talk in more detail on TFS a little later.
LNX-743 pg 28
uMon APIConsole IO:
mon_getbytes mon_getchar mon_getlinemon_gotachar mon_printf mon_putcharmon_cprintf mon_sprintf mon_printmem
•put/put characters to/from the console interface.•basic printf() supports %s, %c, %d, %x, etc.. (no FP support)•print raw data, like DM output
LNX-743 pg 29
uMon APIFlash:
mon_flasherase mon_flashinfo mon_flashwrite
LNX-743 pg 30
uMon APIEnvironment/Heap:
mon_getenv mon_setenv mon_getenvpmon_free mon_heapextend mon_mallocmon_realloc
Environment variables:Very useful for adding “personality” to your target’s startup…
In monrc:set DEBUG TRUE
In application:if (mon_getenv(“DEBUG”))
….
Heap:MicroMonitor’s heap maintains statistics.Has overrun/underrun checking.Can be configured to include file/lineno in heap stats.Can help find a leak because the allocated structures can be viewed.
LNX-743 pg 31
uMon APIInterface:
mon_i2cctrl mon_i2cread mon_i2cwritemon_pcictrl mon_pcicfgread mon_pcicfgwrite
LNX-743 pg 32
uMon APIMiscellaneous:
monConnect mon_addcommand mon_appexitmon_com mon_xcrc16 mon_crc32mon_decompress mon_delay mon_docommandmon_getargv mon_getsym mon_intsoffmon_intsrestore mon_memtrace mon_profilermon_restart mon_setUserLevel mon_versionmon_watchdog mon_warmstart
LNX-743 pg 33
Tiny File System
LNX-743 pg 34
Tiny File System TFS is a…
Command
API
Environment
LNX-743 pg 35
Tiny File System The Command…
uMON>help tfsTiny File System InterfaceUsage: tfs -[df:i:mvx] operation [args]...
Options: -d tfs device -f flags (see below) -i info -m enable more throttle -v enable verbosity -x set exit flag if error
Operations (alphabetically): add {name} {src_addr} {size}, base {file} {var}, cat {name} cfg {start} {end} [spare_addr], check [var], clean cp {from} {to_name | addr}, fhdr {addr}, freemem [var] info {file} {var}, init, ld[v] {name} [sname] log {on|off} {msg}, ln {src} {lnk}, ls [filter] qclean [ramstart] [ramlen], ramdev {name} {base} {size} rm {filter}, run {name}, size {file} {var}, stat trace [lvl], uname {prefix} {var} uncmp {from} {to_name | to_addr} [var]
Flags: E=exec_elf, e=exec_script, c=compressed, l=symlink b=run_at_boot, B=qry_run_at_boot, i=inplace_modifiable 0-3=usrlvl_0-3, u=ulvl_unreadable
LNX-743 pg 36
Tiny File System The API…
mon_tfsadd: add a file from ram spacemon_tfsclose: close a previously opened filemon_tfsctrl: similar to ioctlmon_tfseof: detect end-of-filemon_tfsfstat: retrieve file header structuremon_tfsgetline: retrieve line from opened filemon_tfsipmod: insert data into in-place-modifiable filemon_tfsinit: init the flash space used by TFSmon_tfslink: link one filename to another filemon_tfsnext: get pointer to next file in listmon_tfsopen: open new filemon_tfsread: read from opened filemon_tfsrun: run an executable file in tfsmon_tfsseek: seek to some location in the filemon_tfsstat: retrieve pointer to file header structuremon_tfstell: retrieve current offset into opened filemon_tfstruncate: reduce the size of a filemon_tfsunlink: remove a filemon_tfswrite: write to a previously opened file
if (mon_tfsstat(filename)) { mon_printf("Dumping content of '%s'...\n",filename);
tfd = mon_tfsopen(filename,TFS_RDONLY,0); if (tfd >= 0) { while(mon_tfsgetline(tfd,line,sizeof(line))) mon_printf("%s",line); mon_tfsclose(tfd,0); } else { mon_printf("TFS error: %s\n", (char *)mon_tfsctrl(TFS_ERRMSG,tfd,0)); } }
LNX-743 pg 37
Tiny File System
uMON>tfs ls Name Size Location Flags Info logfile 78 0xffeffdcc monrc 143 0xffe000dc e test_bootfile 21 0xffe0005c e
Total: 3 items listed (242 bytes).
uMON>tfs cat monrcset IPADD "192.168.1.110"set NETMASK "255.255.255.0"set GIPADD "192.168.1.1"set ETHERADD 00:11:22:33:44:55tfs ramdev ram 0x300000 0x100000
Files…
LNX-743 pg 38
Tiny File System
Attribute Abbrev Descriptionexecutable script e a file of commands
auto-boot b file is to be run at boot time
query auto-boot B file is to be run at boottime, after user query
executable binary E COFF, ELF, AOUT, MSBIN,etc.
Compressed c file is zlib compressed
in-place-modifiable I file is in-place-modifiable
Unreadable u file not readable when monitor is below required user level
user_level 0-3 minimum user level required to access the file
File Attributes (flags)
LNX-743 pg 39
Tiny File System File System Configurations
• Can reside in flash, BBRAM or volatile RAM.• Can be reconfigured in run time.• Can be configured in a system with no flash.• Can co-exist with other file systems.• Can reside in multiple, non-contiguous devices.• Can co-exist with section of flash in raw mode.
TargetRAM
TFS Space Monitor’s TEXT and BSS space
Simplest:Single TFS Instanceoccupying all flash
not used by monitor binary.
Memory available to application
MAP #1
TargetFlash
TFS in Flashand a portion of
RAM
MAP #2
TFS in Flashand a portion of
RAM, with a section offlash accessible outside
of TFS space.
MAP #3
LNX-743 pg 40
Scripting
LNX-743 pg 41
Scripting
uMON>set VAR 99uMON>echo $VAR99
----------
uMON>tfs cat demo_scriptif $ARGC ne 2 goto USAGEdm -2 $ARG1 8exit# USAGE:echo Usage: $ARG0 \{hex address\}exituMON>
----------
uMON>demo_scriptUsage: demo_script {hex address}
uMON>demo_script 0x10000000100: 93a1 fffc 3ba0 0100 93a1 fff8 3fa0 fff8uMON>
Shell Variables & Argument Passing
LNX-743 pg 42
Scripting Initial Configuration
uMON>tfs cat monrcset IPADD "192.168.1.110"set NETMASK "255.255.255.0"set GIPADD "192.168.1.1"set ETHERADD 00:11:22:33:44:55set DEBUG TRUE
Inside the application…
...
int debug = 0;
voiddebug_init(void){ if (mon_getenv("DEBUG")) debug = 1;}
...
The monrc file (script) sets up the base configuration.
LNX-743 pg 43
Scripting
uMON>edit demo_scriptEdit buffer = 0x1e000.Type '?' for helpP> 1: echo Want to run application (y or n)? 2: read YORN 3: if $YORN seq y goto RUN_APP 4: echo Want to dump memory (y or n)? 5: read YORN 6: if $YORN seq y goto DUMP_MEM 7: exit 8: 9: # RUN_APP: 10: some_application 11: exit 12: 13: # DUMP_MEM: 14: dm -4 0 4 15: exit
User Interaction
LNX-743 pg 44
Scripting
uMON>edit build_monrcEdit buffer = 0x1e000.Type '?' for helpP> 1: gosub MONRC_TEST 2: 3: # TOP: 4: echo Enter IP Address: \c 5: read IPADD 6: echo Enter NET Mask: \c 7: read NETMASK 8: echo Enter Gateway IP: \c 9: read GIPADD 10: echo set IPADD $IPADD >$APPRAMBASE,500 11: echo set NETMASK $NETMASK >> 12: echo set GIPADD $GIPADD >>monrc,e 13: echo "\n\nHere's what you have:" 14: echo "IPADD: $IPADD" 15: echo "NETMASK: $NETMASK" 16: echo "GIPADD: $GIPADD" 17: echo "This ok (y or n)? \c" 18: read YORN 19: if $YORN sne y goto TOP 20: exit 21: 22: # MONRC_TEST: 23: tfs size monrc MSIZE 24: if $MSIZE seq \$MSIZE exit 25: return
User Configurable (1a)
LNX-743 pg 45
Scripting
uMON>build_monrcEnter IP Address: 1.2.3.4Enter NET Mask: 255.255.255.0Enter Gateway IP: 1.2.3.1set IPADD 1.2.3.4set NETMASK 255.255.255.0set GIPADD 1.2.3.1
Here's what you have:IPADD: 1.2.3.4NETMASK: 255.255.255.0GIPADD: 1.2.3.1This ok (y or n)? yuMON>
uMON>tfs cat monrcset IPADD 1.2.3.4set NETMASK 255.255.255.0set GIPADD 1.2.3.1uMON>
User Configurable (1b)
LNX-743 pg 46
Scripting
# build the basic ATAGS structureldatags -m -i core_pgsize=4096 core_flags=0 core_rootdev=$CORE_ROOTDEV mem32_size=$MEMSIZE mem32_start=$MEMBASE cmdline=
# ATAGS values, depending on kernel version and configuration)ldatags cmd+=" console=ttyS0,$CONSOLEBAUD"ldatags cmd+=“ ip=$IPADD:$NFSSERVER:$GIPADD:$NETMASK::eth0:off"
# add in the command lineldatags cmd+=" $ROOTDIR_PATH"
...
User Configurable (2)
Referring to the previous script example, now the entire setof kernel parameters can be created by a script for passing into
linux at startup. The script would query for the following:
NFSSERVER, GIPADD, IPADD, NETMASK, ROOTDIR_PATH, etc…
LNX-743 pg 47
Scripting
heap -m 1024pm -s $MALLOC "mem=64M console=ttyS0,38400 "pm -S $MALLOC "ip=$IPADD:$NFSSERVER:$GIPADD:$NETMASK::eth0:off"call $APPRAMBASE $MALLOC ...
User Configurable (3)
The command line (for Linux) could be allocated on the command line of uMon…
LNX-743 pg 48
Scripting
uMON>edit testEdit buffer = 0x8200000.Type '?' for helpP> 1: echo hi 2: echo this is a line in a script 3: sleep 1 4: eco hello 5: echo notice that this line will not printxuMON>
---------------
uMON>tfs -v run test[01]: echo hihi[02]: echo this is a line in a scriptthis is a line in a script[03]: sleep 1[04]: eco helloCommand not found: ecoTerminating script 'test' at line 4uMON>
Debuggable Scripts can be run in verbose mode (similar to set –x) so that each
line (and its number in the file) is printed as the script runs.
The user then, can observe the runtime path of the script…
LNX-743 pg 49
Boot Strategy
LNX-743 pg 50
Boot Strategy The monrc File Runs First
Typical configuration of a uMon based target has a monrc(monitor run control) file that sets up the basic environment.
uMON>tfs cat monrcset IPADD "192.168.1.110"set NETMASK "255.255.255.0"set GIPADD "192.168.1.1"set ETHERADD 00:11:22:33:44:55set DEBUG TRUE
Inside the application…
...
int debug = 0;
voiddebug_init(void){ if (mon_getenv("DEBUG")) debug = 1;}
...
LNX-743 pg 51
Boot Strategy Standalone
uMON>tfs ls Name Size Location Flags Info app 27964 0xfff0199c EB monrc 114 0xfff018cc e
----------
MICRO MONITOR 1.2.2Platform: Cogent CSB472CPU: PowerPC 405GPBuilt: Sep 19 2005 @ 00:13:29Monitor RAM: 0x003000-0x01de28Application RAM Base: 0x01e000MAC: 00:11:22:33:44:55IP: 192.168.1.110app? <<<< auto-start of app after reset
The application can be placed in TFS as a auto bootable executable;hence, at reset, it is automatically run after initialization has
completed...
LNX-743 pg 52
Boot Strategy DHCP/BOOTP
uMON>tfs cat monrcset IPADD BOOTP (or DHCP)----------(reset)MICRO MONITOR 1.2.2Platform: Cogent CSB472CPU: PowerPC 405GPBuilt: Sep 19 2005 @ 00:13:29Monitor RAM: 0x003000-0x01de28Application RAM Base: 0x01e000MAC: 00:11:22:33:44:55IP: BOOTPuMON> <<<< background auto-start of BOOTP/DHCP after reset
--------------------
uMON>tfs cat monrcset IPADD DHCPv (‘v’ adds verbosity)----------(reset)MICRO MONITOR 1.2.2Platform: Cogent CSB472...
DHCP/BOOTP 1 sec startup delay... DHCP startup (0 elapsed secs) DHCP request Dhcp/Bootp SetEnv: IPADD = 192.168.1.102 Dhcp/Bootp SetEnv: NETMASK = 255.255.255.0 Dhcp/Bootp SetEnv: GIPADD = 192.168.1.1
LNX-743 pg 53
Boot Strategy DHCP/BOOTP
uMON>tfs ls Name Size Location Flags Info monrc 15 0x100a404c e envsetup test 125 0x100a43bc beTotal: 4 items listed (145989 bytes).
uMON>tfs cat monrcset IPADD DHCP
uMON>tfs cat test# WAIT_FOR_DHCPsleep -m 500echo $IPADDif $IPADD seq DHCP goto WAIT_FOR_DHCPecho OK, I know my IP address now, its $IPADD
uMON>reset<07:02:33> MICRO MONITOR 1.2.3<07:02:33> Platform: Cogent CSB536FS<07:02:33> CPU: MC9328MXL ARM920T<07:02:33> Built: Sep 10 2005 @ 17:36:50<07:02:33> Monitor RAM: 0x8000000-0x801f22c<07:02:33> Application RAM Base: 0x8200000<07:02:33> MAC: 00:23:31:36:00:11<07:02:33> IP: DHCP<07:02:34> DHCP<07:02:35> DHCP<07:02:36> DHCP<07:02:36> 192.168.1.102<07:02:36> OK, I know my IP address now, its 192.168.1.102<07:02:36> uMON>
LNX-743 pg 54
Boot Strategy Fall Back to Standalone if Network
Unavailable
1: icmp -v PING_RESULT echo 135.222.140.142 2: if $PING_RESULT sne ALIVE goto LOCAL_BOOT 3: echo Attempt network boot... 4: tftp -Fnet_app -fe 135.222.140.142 get net_app 5: if $TFTPGET seq \$TFTPGET goto LOCAL_BOOT 6: net_app 7: goto DONE 8: 9: # LOCAL_BOOT: 10: echo Run local copy of application... 11: local_app 12: 13: # DONE: 14: echo Finished!
Use result of ping to determine if network is available. If yes, run tftp to retrieve new application; else use local copy.
LNX-743 pg 55
Boot Strategy Let the User (if any) Decide
1: set CHOICE 2: echo "Enter your choice: \c" 3: read -T 3000 CHOICE 4: echo 5: if $CHOICE seq \$CHOICE goto TIMEOUT 6: if $CHOICE seq 1 goto CHOICE_1 7: if $CHOICE seq 2 goto CHOICE_2 8: echo Sorry! 9: exit 10: 11: # CHOICE_1: 12: echo 1 13: exit 14: 15: # CHOICE_2: 16: echo 2 17: exit 18: 19: # TIMEOUT: 20: echo Timeout 21: exit
Assuming the system has a console, then it may be appropriate to query a user and based on the result of the query run one of several different
boot modes.
LNX-743 pg 56
Host Tools
LNX-743 pg 57
Host Tools
Use during application development: ttftp client/server moncmd client newmon client
Use with running/active system: uvi ttftp-assisted vi (or emacs or whatever) ucat ttftp-assisted cat urm moncmd-assisted file removal
Miscellaneous: elf ELF file format interface (coff & aout too) tfs fs analyzer tnt telnet and tty (non-windows)
Generic embedded system interface:uCon embedded system console
Linux/Solaris/Windows Out-of-the-Box
LNX-743 pg 58
Host Tools
TARGET_IP = 192.168.1.110APPNAME = my_app
...
####### dld:# Use the ttftp tool (supplied with MicroMonitor) to download# the application to the target.#dld: ttftp $(TARGET_IP) put $(APPNAME) $(APPNAME),E
####### zdld:# Compress the elf file using the 'elf' tool (supplied with# MicroMonitor)# The output of this is "$(APPNAME).ezip", then download that# compressed file.#zdld: elf -z6 $(APPNAME) ttftp $(TARGET_IP) put $(APPNAME).ezip $(APPNAME),Ec
####### reset:# Use ‘moncmd’ to issue a reset...#reset: moncmd –w0 $(TARGET_IP) reset
In a make file…
LNX-743 pg 59
Host Tools uCon
LNX-743 pg 60
Porting to New Hardware
LNX-743 pg 61
Easy to Port
Initial boot firmware (always required)
Polled serial port
Polled Ethernet port
Flash driver (most are written or adaptable)
LNX-743 pg 62
Easy to Port
inttarget_console_empty(void){ if (UART_OUTPUT_BUFFER_IS_EMPTY()) return(0); return(1);}
inttarget_putchar(char c){ /* Wait for transmit ready bit */ while(1) { if (UART_IS_READY_FOR_CHARACTER()) break; }
*(char *)UART_XMIT_REG = c return((int)c);}
inttarget_gotachar(void){ if (UART_INPUT_BUFFER_IS_NOT_EMPTY()) return(1); return(0);}
int target_getchar(void){ return((int) *(char *)UART_RCV_REG);}
Console Interface
LNX-743 pg 63
Easy to Port
intEtherdevStartup(int verbose){ /* Put Ethernet controller in reset: */ enreset();
/* Initialize controller and return the value returned by * eninit(). */ return(eninit());}
intsendBuffer(int length){ if (EtherVerbose & SHOW_OUTGOING) printPkt((struct ether_header *)tx_buff,length,ETHER_OUTGOING);
/* Bump up the packet length to a minimum of 64 bytes. */ if (length < 64) length = 64;
/* ADD_CODE_HERE */
EtherXFRAMECnt++; return(0);}
intpolletherdev(void){ uchar *pktbuf = (char *)0; int pktlen = 0, pktcnt = 0;
if (PACKET_AVAILABLE()) { GET_PACKET_FROM_DEVICE(); processPACKET((struct ether_header *)pktbuf, pktlen); pktcnt++; } return(pktcnt);}
Ethernet Interface
LNX-743 pg 64
Easy to Port
intFlash_erase(struct flashinfo *fdev,int snum){ return(0);}
intFlash_write(struct flashinfo *fdev,uchar *dest,uchar *src,long bytecnt){ return(0);}
intFlash_ewrite(struct flashinfo *fdev,uchar *dest,uchar *src,long bytecnt){ reset = RESETFUNC(); reset();}
intFlash_lock(struct flashinfo *fdev,int snum,int operation){ vulong add;
add = (ulong)(fdev->base);
if (operation == FLASH_LOCKABLE) { return(0); /* Return 1 if device is lockable; else 0. */ } else if (operation == FLASH_UNLOCK) { return(-1); /* Return negative for failure else 1 */
} else if (operation == FLASH_LOCK) { return(-1); /* Return negative for failure else 1 */ } else if (operation == FLASH_LOCKQRY) { return(-1); /* Return 1 if device is locked else 0. */ } else return(-1);}
Flash Interface
LNX-743 pg 65
Linux Specific
LNX-743 pg 66
Linux Specific
uMON>tfs ls Name Size Location Flags Info kernel.gz 723524 0x2060c4bc kernel_go 770 0x2060b0bc eB monrc 1127 0x207644cc e
Everything at startup is a file in TFS…
SystemFlash
TFSSpace
uMon uMon
TFSSpace
JFFS2Space
with a few adjustments…
LNX-743 pg 67
Linux Specific
Several options, similar tothose already discussed,
still apply…
* DHCP Boot
* TFTP Push to RAM (from makefile)
* Compressed TFTP Push to TFS
* Direct startup from local flash
* Scripting
LNX-743 pg 68
Linux Specific
Build, Download, Run
$ make ARCH=ppc CROSS_COMPILE=ppc_405-gcc bzImage$ ppc_405-objcopy --strip-all -S -O binary vmlinux vmlinux.bin $ ttftp 135.222.140.72 put vmlinux 0x0$ moncmd 135.222.140.72 "lboot -v"
LNX-743 pg 69
Linux Specific
Turning over control (with parameters)
to the kernel
* Customized kernel startup
* Command Line Only
* Parameter structure & Cmdline * Tag List
LNX-743 pg 70
Linux Specific
Custom Kernel Startup
uMON> unzip kernel.gz $ENTRYPOINT uMON> call $ENTRYPOINT
LNX-743 pg 71
Linux Specific
Building the Kernel Command Linepm
uMON>tfs cat kernel_go
heap –m 300
pm –s $MALLOC "console=tty1 console=ttyS0,9600 " pm –S $MALLOC "ip=on root=/dev/nfs rw " pm –S $MALLOC "nfsroot=135.222.140.159:/home/els/kernel/rootfs"
echo "Unzipping kernel..." unzip kernel.gz 0x0 call 0 $MALLOC exit
LNX-743 pg 72
Linux Specific
Parameter Structure
struct bdinfo { unsigned long memstart; unsigned long memsize; unsigned char mac[6];};
uMON>tfs cat kernel_go # kernel_go script:heap –m 32set MEMSTART $MALLOCset MEMSIZE=$MALLOC+4set MAC=$MALLOC+8
pm –4 $MEMSTART 0x10000000pm -4 $MEMSIZE 0x00800000 pm $MAC 0x00 0x60 0x1d 0x02 0x0b 0x8a unzip kernel.gz 0x0 call 0 $MALLOC exit uMON>
OR…
lboot
LNX-743 pg 73
Linux Specific
Building the Kernel Command Linelboot
uMON>tfs cat kernel_go # kernel_go script: if $ARGC eq 1 goto SET_CMDLINE if $ARG1 seq dhcp goto SET_CMDLINE_DHCP echo Usage: $ARG0 [dhcp] exit
# SET_CMDLINE: set CMDLINE00 "console=tty1 console=ttyS0,${CONSOLEBAUD} " set CMDLINE01 "ip=${IPADD}::${GIPADD}:${NETMASK}::eth0:off " set CMDLINE02 "root=/dev/nfs rw " set CMDLINE03 "nfsroot=${NFSSRVR}:${ROOTFS}" set CMDLINE04 goto LINUX_MORE
# SET_CMDLINE_DHCP: set CMDLINE00 "console=tty1 console=ttyS0,${CONSOLEBAUD} " set CMDLINE01 "ip=on root=/dev/nfs rw " set CMDLINE02 "nfsroot=${NFSSRVR}:${ROOTFS}" set CMDLINE03 goto LINUX_MORE
# LINUX_MORE: echo "Unzipping kernel..." unzip kernel.gz 0x0 lboot -v exit
LNX-743 pg 74
Linux Specific
Tag List
# build the basic ATAGS structureldatags -m -i core_pgsize=4096 core_flags=0 core_rootdev=$CORE_ROOTDEV mem32_size=$MEMSIZE mem32_start=$MEMBASE cmdline=
# ATAGS values, depending on kernel version and configuration)ldatags cmd+=" console=ttyS0,$CONSOLEBAUD"ldatags cmd+=“ ip=$IPADD:$NFSSERVER:$GIPADD:$NETMASK::eth0:off"
# add in the command lineldatags cmd+=" $ROOTDIR_PATH"
...
LNX-743 pg 75
Future Work
uMon Applets Allow the built-ins to be moved to TFS. Keeps the monitor small and secure.
uuMon:Different versions of “mini-” MicroMonitor for those targetsrunning from built-in flash (i.e. limited). This supports theoption of having uuMon boot uMon as an applet.
New Interfaces: Compact flash USB JFFS2
uConfig: A graphical interface for configuring a uMon port.
uCon: Convert to Wx Widgets for Linux/Windows portability.
Linux: A ‘tfs’ command for read/write access to the TFS partition.
LNX-743 pg 76
Conclusion
Generic
Reusable
Robust
Mature
Configurable
RTOS Independent
Plenty of Documentation