[[TOC(heading=Table of Contents, Docs/Prog/*)]] = Application Mode Startup = == Introduction == When an 825 weight indicator is first powered up the display will show a brief display test and then version and status display. 1. Application Mode 2. Standard Indicator 3. Setup When "1. Application Mode" is selected the uClinux operating system will start to allow applications to run. Linux 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. To 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. Type: {{{ # cat /etc/rc.d/rc.local }}} Output: {{{ #!Lineno #!sh #!/bin/sh # rc.local, Local initialization tasks # setup ppp options file if [ ! –f /etc/ppp/options.orig –a –f /etc/ppp/options ] then mv /etc/ppp/options /etc/ppp/options.orig ln –s options.pinpad_target /etc/ppp/options fi echo “Starting Indicator” echo “ Starting…” > /dev/carddsp modprobe mnbd-comm modprobe i2c-mcf modprobe max734x modprobe isp1520 mount –t jffs2 /dev/mtdblock1 /mnt/nand cd /mnt/nand/indicator sh appmenu.sh & }}} [[Top]] == Modules == The modprobe lines install device drivers that are installed as loadable modules. * mnbd-comm module for dma uart communications with mainboard * i2c-mcf module for coldfire i2c communications – loading this also causes i2c-core to be loaded * max734x module for keypad/beeper access * isp1520 module for i2c initialization of isp1520 usb hub You can see what modules are loaded by typing: {{{ # cat /proc/modules '''or''' # lsmod }}} Modules may be unloaded by typing: {{{ # rmmod }}} such as '''rmmod max734x'''. [[Top]] == Mounts == The 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: {{{ # cat /proc/mounts }}} Before turning off the indicator it is best to un-mount the NAND and NFS if it is mounted. {{{ # umount /mnt/nand # umount /mnt/nfs }}} [[Top]] == Appmenu Shell Script == Finally the script executes another shell script on the nand flash. {{{ # sh appmenu.sh & }}} The 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. To view this script type: {{{ # cd /mnt/nand/bin # cat appmenu.sh }}} Output: {{{ #!Lineno #!sh #!/bin/sh # App menu shell while : do /mnt/nand/bin/appmenu tmp=$? # store appmenu result in tmp so we can do something before case #echo "appmenu result" #echo $tmp case $tmp in 1) /mnt/nand/apps/std/std ;; 4) /mnt/nand/apps/ids/ids ;; 5) /mnt/nand/apps/dfc/dfc ;; 6) /mnt/nand/apps/chkwgh/chkwgh ;; 7) cd /mnt/nand/apps/788IDS /mnt/nand/bin/cardbas 788IDS.77X cd /mnt/nand/bin ;; 12) /mnt/nand/bin/touchcal ;; 13) sh /mnt/nand/bin/filemgr.sh ;; 14) /mnt/nand/bin/imageview /mnt/nand/cfg/slideshow.cfg ;; 21) sh /mnt/nand/bin/cust01.sh ;; 22) sh /mnt/nand/bin/cust02.sh ;; 23) sh /mnt/nand/bin/cust03.sh ;; 24) sh /mnt/nand/bin/cust04.sh ;; 25) sh /mnt/nand/bin/cust05.sh ;; 26) sh /mnt/nand/bin/cust06.sh ;; 27) sh /mnt/nand/bin/cust07.sh ;; 28) sh /mnt/nand/bin/cust08.sh ;; 29) sh /mnt/nand/bin/cust09.sh ;; 30) sh /mnt/nand/bin/cust10.sh ;; 31) sh /mnt/nand/bin/cust11.sh ;; 32) sh /mnt/nand/bin/cust12.sh ;; 33) sh /mnt/nand/bin/cust13.sh ;; 34) sh /mnt/nand/bin/cust14.sh ;; 35) sh /mnt/nand/bin/cust15.sh ;; 36) sh /mnt/nand/bin/cust16.sh ;; 37) sh /mnt/nand/bin/cust17.sh ;; 38) sh /mnt/nand/bin/cust18.sh ;; 99) echo "\`" > /dev/carddsp echo "Restarting...\\r" > /dev/carddsp cd / reboot & exit ;; esac done }}} This 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: {{{ “/mnt/nand/bin/appmenu /mnt/nand/cfg/appmenu2.cfg” }}} [[Top]] == Appmenu Config File == Any one item in the configuration file may end in “~XX” (where XX is a number of seconds for the item to be automatically selected). For example, type: {{{ # cat /mnt/nand/cfg/appmenu.cfg }}} Output: {{{ #!Lineno *04,%d. Truck Storage~08 #05,%d. Digital Fill Control #06,%d. Checkweigher #07,%d. 788 Compatibility *12,%d. Configuration *13,%d. File Manager *14,%d. Slide Show *99,%d. Return to Startup }}} If 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. Starting 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. This 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) If 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. When 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). The following lines check the return value from the appmenu program: {{{ #!Lineno #!sh case $tmp in 4) /mnt/nand/apps/ids/ids ;; 5) /mnt/nand/apps/dfc/dfc ;; 6) /mnt/nand/apps/chkwgh/chkwgh ;; 7) cd /mnt/nand/apps/788IDS /mnt/nand/bin/cardbas 788IDS.77X cd /mnt/nand/bin ;; }}} If 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. {{{ #!Lineno #!sh 12) /mnt/nand/bin/touchcal ;; }}} If the value is equal to 12 the configuration program “touchcal” is called. {{{ #!Lineno #!sh 13) sh /mnt/nand/bin/filemgr.sh ;; }}} If the value is equal to 13 the script calls another script “filemgr.sh” to open the file manager. {{{ #!Lineno #!sh #!/bin/sh # File manager while : do /mnt/nand/bin/filemanage tmp=$? # store appmenu result in tmp so we can do something before case echo "filemanager result" echo $tmp if [ $tmp -eq 1 ] ; then sh /tmp/filemgr_cmd.sh else exit fi done }}} Note 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. {{{ #!Lineno #!sh 14) /mnt/nand/bin/imageview /mnt/nand/cfg/slideshow.cfg ;; }}} If 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: {{{ #!Lineno /mnt/nand/images/825_Indicator_Startup_Screen_1.bmp /mnt/nand/images/825_Indicator_Startup_Screen_2.bmp /mnt/nand/images/825_Indicator_Startup_Screen_3.bmp /mnt/nand/images/825_Indicator_Startup_Screen_4.bmp /mnt/nand/images/825_Indicator_Startup_Screen_5.bmp /mnt/nand/images/825_Indicator_Startup_Screen_6.bmp /mnt/nand/images/825_Indicator_Startup_Screen_7.bmp /mnt/nand/images/825_Indicator_Startup_Screen_8.bmp }}} The image viewer program will display these images sequentially and repeat until the escape key is pressed. Control will then return to the appmenu script. If 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. If 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. The “esac” statement is needed to end the “case” conditions. (esac is case spelled backwards). When 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. If you want to stop the “indicator”, “touchcal”, or “appmenu” program you should use the “ps” command and find the 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. [[Top]] == Support Applications == '''/mnt/nand/bin/appmenu –''' The appmenu program displays the application menu. '''/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”. The command line must be specified such as: loadsrec filename type prompt delaytime filename - path and filename of S19 file type – O=OPI bootloader M=Mainboard X=Other such as image.bin prompt – (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) W=no prompt only update if newer version. delaytime – (Optional parameter – default 50ms) delay in milliseconds between writing records. Should normally not be changed. A shell script may be written to perform an update of both the OPI board boot loader and the mainboard flash. echo "Updating flash\\r" > /dev/carddsp /mnt/nand/bin/loadsrec "/mnt/nfs/Demo1 M5213EVB Boot Loader.elf.S19" M N /mnt/nand/bin/loadsrec /mnt/nfs/m5329evb_flash.S19 O N echo "** Done **" > /dev/carddsp '''/mnt/nand/bin/imageview''' – The 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. The command line must be specified such as: imageview filename If 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. '''/mnt/nand/bin/filemanage –''' The filemanage program is the file manager. The command line must be specified such as: filemanage The 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 run from a script such as: #!/bin/sh # File manager while : do /mnt/nand/bin/filemanage tmp=$? # store appmenu result in tmp so we can do something before case echo "filemanager result" echo $tmp if [ $tmp -eq 1 ] ; then sh /tmp/filemgr_cmd.sh else exit fi done The 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.