wiki:Docs/Prog/Manual/Foundation/ApplicationModeStartup

Version 6 (modified by Don Wilson, 12 years ago) ( diff )

--

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
  1. Standard Indicator
  1. Legal metrology information / Setup

When "1. Application Mode" is selected the micro c Linux operating system will load 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:

#!/bin/sh
if [ "$1" = "stop" ]; then
        echo "Stopping..." > /dev/carddsp
        exit
fi
if [ -f /tmp/env.sh ]; then
        . /tmp/env.sh
fi
echo "        Starting..." > /dev/carddsp
modprobe i2c-coldfire
modprobe max734x
#sleep 1
#if [ -f /tmp/mnbdcomm2 ]; then
#       modprobe mnbd-comm2
#else
        modprobe mnbd-comm
#fi
#sleep 1
echo "  U)pdate  T)est" > /dev/carddsp
/usr/sbin/diag/waitkey 3
updkey=$?
echo "\`L" > /dev/carddsp
if [ ! -f /proc/mnbd ]; then
        modprobe isp1520
fi
passwd -z
stty -F /dev/ttyS0 -Z
stty -F /dev/ttyS1 -Z
if [ "$updkey" = "85" ]; then
        sh /usr/sbin/diag/filemgr.sh
elif [ "$updkey" = "84" ] || [ -f /proc/mnbdtest ]; then
        cd /usr/sbin/diag
        ./diag c
#       if [ "$?" = "5" ]; then
#               sh /mnt/nfs/updmnbd.sh
                exit
#       fi
elif [ "$updkey" = "79" ]; then
        echo "\`" > /dev/carddsp
        echo "Starting OPI diagnostics" > /dev/carddsp
        mount -t jffs2 /dev/mtdblock1 /mnt/nand
        /usr/sbin/diag/diag
        exit
elif [ "$updkey" = "27" ]; then
        echo "\`" > /dev/carddsp
        echo "Startup halted" > /dev/carddsp
        exit
fi
ln -s /usr/sbin/www/html/fonts/big825.fnt /etc/big825.fnt
ln -s /usr/sbin/www/html/fonts/btn825.fnt /etc/btn825.fnt
#mount -t jffs2 /dev/mtdblock1 /mnt/nand
# If nand is not yet configured - run diagnostics
#if [ -f /mnt/nand/bin/appmenu.sh ]; then
#       PATH=$PATH:/usr/sbin/diag:/mnt/nand/bin:.
#       chmod +x /mnt/nand/bin/*
#       echo "\`" > /dev/carddsp
        echo "Application Menu..." > /dev/carddsp
#       sh /mnt/nand/bin/appmenu.sh &
        sh /usr/sbin/diag/appmenu.sh &
        mount -t jffs2 /dev/mtdblock1 /mnt/nand &
        # DW Check for Cardinal 825 set to start web server - added -W command t                                                                o ifconfig to check NOR web server setting
        ifconfig -W
        if [ "$?" = "1" ]; then
                echo "Starting the boa webserver: "
#               if [ -f /mnt/nand/cfg/boa.conf ]
#               then
#                       cp /mnt/nand/cfg/boa.conf /etc/conf/boa.conf
#               fi
                boa $BOA_ARGS
    fi
        ifconfig -T
        if [ "$?" = "2" ]; then
                echo "Starting the weight server: "
                /usr/sbin/diag/wtsvr &
        fi
        #if [ -f /mnt/nand/cfg/exports ]; then
        #       cp /mnt/nand/cfg/exports /etc/exports
        #fi
        ifconfig -L
        if [ "$?" = "4" ]; then
                telnetd
    fi
#else
#       PATH=$PATH:/usr/sbin/diag:.
#       cd /usr/sbin/diag
#       ./diag
#       if [ "$?" = "10" ]; then
#               sh /mnt/nfs/cpynand.sh &
#       fi
#fi

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 (not used for newer main boards 2012 and above)

You can see what modules are loaded by typing:

# cat /proc/modules

'''or'''

# lsmod

Modules may be unloaded by typing:

# rmmod <module>

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 process 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:

Error: Failed to load processor Lineno
No macro or processor named 'Lineno' found

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:

Error: Failed to load processor Lineno
No macro or processor named 'Lineno' found

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 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:

Error: Failed to load processor Lineno
No macro or processor named 'Lineno' found

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.

Error: Failed to load processor Lineno
No macro or processor named 'Lineno' found

If the value is equal to 12 the configuration program “touchcal” is called.

Error: Failed to load processor Lineno
No macro or processor named 'Lineno' found

If the value is equal to 13 the script calls another script “filemgr.sh” to open the file manager.

Error: Failed to load processor Lineno
No macro or processor named 'Lineno' found

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.

Error: Failed to load processor Lineno
No macro or processor named 'Lineno' found

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:

Error: Failed to load processor Lineno
No macro or processor named 'Lineno' found

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 “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 as a different process. 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 <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.

Top

Support Applications

/mnt/nand/bin/appmenu –

The appmenu program displays the application menu.

/mnt/nand/bin/loadsrec – 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.

Note: See TracWiki for help on using the wiki.