Changes between Version 1 and Version 2 of Docs/Prog/Manual/Foundation/ApplicationModeStartup


Ignore:
Timestamp:
11/30/09 14:08:51 (15 years ago)
Author:
Don Wilson
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Docs/Prog/Manual/Foundation/ApplicationModeStartup

    v1 v2  
    1 = App =
     1[[TOC(heading=Table of Contents, Docs/Prog/*)]]
     2= Application Mode Startup =
     3== Introduction ==
     4When an 825 weight indicator is first powered up the display will show a brief display test and then version and status display.
     5
     61. Application Mode
     7
     82. Standard Indicator
     9
     103. Setup
     11
     12When "1. Application Mode" is selected the uClinux operating system will start to allow applications to run.
     13
     14Linux uses a startup script file /etc/rc.d/rc.local to provide startup instructions. This script file is a text file containing a sequence of commands. This is similar to the AUTOEXEC.BAT file in an MS-DOS environment.
     15
     16To learn more of the details of the operating system have a serial cable connected to COM1 of the 825 and to a serial port on a PC running a terminal program such as PuTTY or Minicom. Make sure the 825 setup baud rate matches the terminal program settings. Also make sure the 825 "Update Software Menu" "Setting" does not have the "console=null" statement which will prevent serial port access to the console. After this setup is accomplished uClinux shell commands may be typed in the terminal program and responses will appear in the terimal program.
     17
     18Type:
     19{{{
     20# cat /etc/rc.d/rc.local
     21}}}
     22
     23Output:
     24{{{
     25#!Lineno
     26#!sh
     27#!/bin/sh
     28# rc.local, Local initialization tasks
     29# setup ppp options file
     30
     31if [ ! –f /etc/ppp/options.orig –a –f  /etc/ppp/options ]
     32then
     33  mv /etc/ppp/options /etc/ppp/options.orig
     34  ln –s options.pinpad_target /etc/ppp/options
     35fi
     36echo “Starting Indicator”
     37echo “        Starting…” > /dev/carddsp
     38modprobe mnbd-comm
     39modprobe i2c-mcf
     40modprobe max734x
     41modprobe isp1520
     42mount –t jffs2 /dev/mtdblock1 /mnt/nand
     43cd /mnt/nand/indicator
     44sh appmenu.sh &
     45}}}
     46
     47[[Top]]
     48
     49== Modules ==
     50The modprobe lines install device drivers that are installed as loadable modules.
     51 * mnbd-comm  module for dma uart communications with mainboard
     52 * i2c-mcf    module for coldfire i2c communications – loading this also causes i2c-core to be loaded
     53 * max734x    module for keypad/beeper access
     54 * isp1520    module for i2c initialization of isp1520 usb hub
     55
     56You can see what modules are loaded by typing:
     57{{{
     58# cat /proc/modules
     59
     60'''or'''
     61
     62# lsmod
     63}}}
     64Modules may be unloaded by typing:
     65{{{
     66# rmmod <module>
     67}}}
     68
     69such as '''rmmod max734x'''.
     70[[Top]]
     71
     72== Mounts ==
     73
     74The script also mounts the 64M NAND flash as /mnt/nand and changes to the folder /mnt/nand/indicator. You can view the current mount points by typing:
     75{{{
     76# cat /proc/mounts
     77}}}
     78
     79Before turning off the indicator it is best to un-mount the NAND and NFS if it is mounted.
     80{{{
     81# umount /mnt/nand
     82# umount /mnt/nfs
     83}}}
     84
     85[[Top]]
     86
     87== Appmenu Shell Script ==
     88Finally the script executes another shell script on the nand flash.
     89{{{
     90# sh appmenu.sh &
     91}}}
     92
     93The command “sh” means to call a shell script. The “appmenu.sh” is the filename of the script, and the “&” ampersand character indicates that the script runs in a separate thread from the terminal. This allows for typing commands from the terminal while the script is running.
     94
     95To view this script type:
     96{{{
     97# cd /mnt/nand/bin
     98# cat appmenu.sh
     99}}}
     100
     101Output:
     102{{{
     103#!Lineno
     104#!sh
     105#!/bin/sh
     106# App menu shell
     107
     108while :
     109do
     110/mnt/nand/bin/appmenu
     111tmp=$?
     112# store appmenu result in tmp so we can do something before case
     113#echo "appmenu result"
     114#echo $tmp
     115case $tmp in
     116  1) /mnt/nand/apps/std/std ;;
     117  4) /mnt/nand/apps/ids/ids ;;
     118  5) /mnt/nand/apps/dfc/dfc ;;
     119  6) /mnt/nand/apps/chkwgh/chkwgh ;;
     120  7) cd /mnt/nand/apps/788IDS
     121  /mnt/nand/bin/cardbas 788IDS.77X
     122  cd /mnt/nand/bin     ;;
     123  12) /mnt/nand/bin/touchcal ;;
     124  13) sh /mnt/nand/bin/filemgr.sh ;;
     125  14) /mnt/nand/bin/imageview /mnt/nand/cfg/slideshow.cfg ;;
     126  21) sh /mnt/nand/bin/cust01.sh ;;
     127  22) sh /mnt/nand/bin/cust02.sh ;;
     128  23) sh /mnt/nand/bin/cust03.sh ;;
     129  24) sh /mnt/nand/bin/cust04.sh ;;
     130  25) sh /mnt/nand/bin/cust05.sh ;;
     131  26) sh /mnt/nand/bin/cust06.sh ;;
     132  27) sh /mnt/nand/bin/cust07.sh ;;
     133  28) sh /mnt/nand/bin/cust08.sh ;;
     134  29) sh /mnt/nand/bin/cust09.sh ;;
     135  30) sh /mnt/nand/bin/cust10.sh ;;
     136  31) sh /mnt/nand/bin/cust11.sh ;;
     137  32) sh /mnt/nand/bin/cust12.sh ;;
     138  33) sh /mnt/nand/bin/cust13.sh ;;
     139  34) sh /mnt/nand/bin/cust14.sh ;;
     140  35) sh /mnt/nand/bin/cust15.sh ;;
     141  36) sh /mnt/nand/bin/cust16.sh ;;
     142  37) sh /mnt/nand/bin/cust17.sh ;;
     143  38) sh /mnt/nand/bin/cust18.sh ;;
     144  99) echo "\`" > /dev/carddsp
     145
     146  echo "Restarting...\\r" > /dev/carddsp
     147  cd /
     148  reboot &
     149  exit ;;
     150esac
     151done
     152}}}
     153
     154This script has a couple of comment lines at the beginning starting with the “#” character. It then has a while,do – done loop. The colon “:” after the while indicates an always true condition to continue the loop. The first statement within the while-do is “/mnt/nand/bin/appmenu”. This causes the script to execute a program file called “appmenu” just as if it were typed from the command line. The “/mnt/nand/bin/” specifies the bin or binary directory the program is located in. The “appmenu” program displays a menu on the 825 indicator. The menu items presented are determined by a configuration file appmenu.cfg located in the /mnt/nand/cfg directory. Alternatively, a path and filename for the config file may be specified as a command parameter for the appmenu program, such as:
     155
     156{{{
     157“/mnt/nand/bin/appmenu /mnt/nand/cfg/appmenu2.cfg”
     158}}}
     159
     160[[Top]]
     161
     162== Appmenu Config File ==
     163
     164Any one item in the configuration file may end in “~XX” (where XX is a number of seconds for the item to be automatically selected).
     165
     166For example, type:
     167{{{
     168# cat /mnt/nand/cfg/appmenu.cfg
     169}}}
     170
     171Output:
     172{{{
     173#!Lineno
     174*04,%d. Truck Storage~08
     175#05,%d. Digital Fill Control
     176#06,%d. Checkweigher
     177#07,%d. 788 Compatibility
     178*12,%d. Configuration
     179*13,%d. File Manager
     180*14,%d. Slide Show
     181*99,%d. Return to Startup
     182}}}
     183
     184If the first character of a line is a asterisk “*” the next two digits specify the return value when the item is selected. If the first character of a line is a pound sign “#” the item is disabled and will not appear when the menu is displayed.
     185
     186Starting with version 1.19 the [wiki:Docs/Prog/Manual/ConfigurationUtility Configuration Utility] “touchcal” has an option “Configure Menu” which allows the menu to be customized. This feature makes use of the “*” and “#” symbols to enable or disable items on the menu. Also to facilitate this feature instead of having specific items numbers such as “1.”, “2.”, etc… in the configuration file the item numbers are replaced with “%d”. The “appmenu” program will fill in the appropriate item number when “%d” is encountered.
     187
     188This configuration will cause a countdown to appear on the menu next to the “Truck Storage” selection. Another menu choice may be selected by pressing the appropriate number first. Using an arrow key to change the selection will stop the countdown so the menu will stay indefinitely. When the countdown is complete the menu item will be selected automatically. A file /tmp/cntdn is written as a flag so the auto start countdown only occurs on the first power up of the indicator. (/tmp is a ramdisk directory - it does not maintain its contents after reset)
     189
     190If the configuration file specifies seven items or less the application menu is shown on one page. If more items are specified the six items are shown per page with “Prev” and “Next” buttons shown to select pages. Up to five pages are possible.
     191
     192When any of these choices is selected the “appmenu” program terminates back to the script with a return value corresponding to the menu item selected. (The return value is based only on the line count of the appmenu.cfg file, not numbers specified in the configuration file).
     193
     194The following lines check the return value from the appmenu program:
     195{{{
     196#!Lineno
     197#!sh
     198case $tmp in
     199  4) /mnt/nand/apps/ids/ids ;;
     200  5) /mnt/nand/apps/dfc/dfc ;;
     201  6) /mnt/nand/apps/chkwgh/chkwgh ;;
     202  7) cd /mnt/nand/apps/788IDS
     203  /mnt/nand/bin/cardbas 788IDS.77X
     204  cd /mnt/nand/bin     ;;
     205}}}
     206
     207If the value is equal to 4 the program “ids” is called. If the value is 5 the program “dfc” is called. If the value is 6 the program “chkwgh” is called. If the value is 7 the script will change directory to /mnt/nand/apps/788IDS and call the program “cardbas” to run the 788 program “788IDS.77X”. When finished the script will change the current directory back to /mnt/nand/bin.
     208{{{
     209#!Lineno
     210#!sh
     211  12) /mnt/nand/bin/touchcal ;;
     212}}}
     213
     214If the value is equal to 12 the configuration program “touchcal” is called.
     215{{{
     216#!Lineno
     217#!sh
     218  13) sh /mnt/nand/bin/filemgr.sh ;;
     219}}}
     220If the value is equal to 13 the script calls another script “filemgr.sh” to open the file manager.
     221
     222{{{
     223#!Lineno
     224#!sh
     225#!/bin/sh
     226# File manager
     227
     228while :
     229do
     230/mnt/nand/bin/filemanage
     231tmp=$?
     232# store appmenu result in tmp so we can do something before case
     233echo "filemanager result"
     234echo $tmp
     235if [ $tmp -eq 1 ] ; then
     236  sh /tmp/filemgr_cmd.sh
     237else
     238  exit
     239fi
     240done
     241}}}
     242
     243Note that this script contains another while-do-done loop and launches the file manager within the loop. If certain file types are selected such as an S19 file to update firmware, or a bmp file to display the file manager creates a another script /tmp/filemgr_cmd.sh and returns with an exit code 1. In this case the filemgr.sh script calls the filemgr_cmd.sh script and when complete the while loop will cause the filemgr to start again. If the file manager is exited the return value is zero and exit statement is executed so control will return to the appmenu script.
     244{{{
     245#!Lineno
     246#!sh
     247  14) /mnt/nand/bin/imageview /mnt/nand/cfg/slideshow.cfg ;;
     248}}}
     249
     250If the value is equal to 14 the script calls the image viewer program to display a slide show. Note that a parameter is passed to the image viewer program containing the path to a configuration file slideshow.cfg:
     251
     252{{{
     253#!Lineno
     254/mnt/nand/images/825_Indicator_Startup_Screen_1.bmp
     255/mnt/nand/images/825_Indicator_Startup_Screen_2.bmp
     256/mnt/nand/images/825_Indicator_Startup_Screen_3.bmp
     257/mnt/nand/images/825_Indicator_Startup_Screen_4.bmp
     258/mnt/nand/images/825_Indicator_Startup_Screen_5.bmp
     259/mnt/nand/images/825_Indicator_Startup_Screen_6.bmp
     260/mnt/nand/images/825_Indicator_Startup_Screen_7.bmp
     261/mnt/nand/images/825_Indicator_Startup_Screen_8.bmp
     262}}}
     263
     264The image viewer program will display these images sequentially and repeat until the escape key is pressed. Control will then return to the appmenu script.
     265
     266If the value is from 21 to 38 a custom application script is executed. Refer to the “[wiki:Docs/Prog/Manual/ConfigurationUtility Configuration Utility] documentation for information about configuring custom menu items.
     267
     268If the value is 99 the script will call the “reboot” function with the “&” character so that it runs in a different thread. The appmenu script will then exit. This is necessary so the reboot function can unmount the NAND. The reboot function will kill the wtsvr process if it is running and unmount the NAND then do a software restart of the OPI board microprocessor. The boot loader startup display will return. Note that this does not reboot the mainboard.
     269
     270The “esac” statement is needed to end the “case” conditions. (esac is case spelled backwards).
     271
     272When either the “touchcal” or “indicator” program exits, control will return to the script and to the statement after “esac”. This is the “done” statement which is the bottom of the while-do loop. The script execution will immediately return to the statement following “do” and display the menu again.
     273
     274If you want to stop the “indicator”, “touchcal”, or “appmenu” program you should use the “ps” command and find the <PID> process ID of the script “sh appmenu.sh” first. Use the “kill” command to stop the script before stopping the program. Otherwise, the script may immediately restart the program.
     275
     276[[Top]]
     277
     278
     279== Support Applications ==
     280'''/mnt/nand/bin/appmenu –'''
     281
     282The appmenu program displays the application menu.
     283
     284'''/mnt/nand/bin/loadrec''' – This application is normally automatically called, so a typical user need not know these details. When an “.S19” or “.bin” flash update is selected in the file manager a script file is created which calls the “loadsrec” program with the appropriate filename and options to perform the flash. It may be useful at times to call “loadsrec” manually, or to create special shell scripts which call “loadsrec”.
     285
     286The command line must be specified such as:
     287
     288loadsrec filename type prompt delaytime
     289
     290filename - path and filename of S19 file
     291
     292type – O=OPI bootloader M=Mainboard
     293
     294prompt – (Optional parameter – default prompt is enabled) P=prompt (yes/no) after showing version information N=no prompt (feature added starting with loadsrec 1.07, previous versions did not prompt)
     295
     296delaytime – (Optional parameter – default 50ms) delay in milliseconds between writing records. Should normally not be changed.
     297
     298A shell script may be written to perform an update of both the OPI board boot loader and the mainboard flash.
     299
     300echo "Updating flash\\r" > /dev/carddsp
     301
     302/mnt/nand/bin/loadsrec "/mnt/nfs/Demo1 M5213EVB Boot Loader.elf.S19" M N
     303
     304/mnt/nand/bin/loadsrec /mnt/nfs/m5329evb_flash.S19 O N
     305
     306echo "** Done **" > /dev/carddsp
     307
     308'''/mnt/nand/bin/imageview''' –
     309
     310The imageview program will display BMP bitmap images. The images to display must already be sized as 640 x 480, and 24 bit per pixel format.
     311
     312The command line must be specified such as:
     313
     314loadsrec filename
     315
     316If the filename is a BMP file the file will be displayed. If the filename is a .cfg file it will be interpreted as a text file containing the filenames of BMP files to display as a slideshow in a continuous loop.
     317
     318'''/mnt/nand/bin/filemanage –'''
     319
     320The filemanage program is the file manager.
     321
     322The command line must be specified such as:
     323
     324filemanage
     325
     326The file manager returns a result code that indicates whether it was exited or whether ENTER was pressed with file such as an S19 file was selected. The file manager is normally ran from a script such as:
     327
     328#!/bin/sh
     329
     330# File manager
     331
     332while :
     333
     334do
     335
     336/mnt/nand/bin/filemanage
     337
     338tmp=$?
     339
     340# store appmenu result in tmp so we can do something before case
     341
     342echo "filemanager result"
     343
     344echo $tmp
     345
     346if [ $tmp -eq 1 ] ; then
     347
     348  sh /tmp/filemgr_cmd.sh
     349
     350else
     351
     352  exit
     353
     354fi
     355
     356done
     357
     358The script executes the file manager in a loop. If the result is 1 the file manager created script /tmp/filemgr_cmd.sh is executed to perform the command such as displaying a bitmap (imageview) or updating flash (loadsrec). After the script is executed the loop will cause file manager to run again.  If the result is not 1 the exit statement will be reached causing the script to exit.
     359