wiki:Docs/Prog/Manual/Foundation/ApplicationModeStartup

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
modprobe mnbd-comm
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
	exit
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
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 to 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
if [ -f /mnt/nand/bin/start.sh ]; then
	sh /mnt/nand/bin/start.sh &
fi

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
mnbd_comm 37136 10 - Live 0x40c90000
max734x 6108 1 - Live 0x40ba6000
i2c_coldfire 4504 0 - Live 0x40888000
i2c_core 14704 2 max734x,i2c_coldfire, Live 0x40880000

Modules may be unloaded by typing:

# rmmod <module>

such as rmmod max734x.

Appmenu Shell Script

The script starts running another script which displays the application menu.

# sh /usr/sbin/diag/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. View the "appmenu.sh" script by from a terminal window by typing:

cat /usr/sbin/diag/appmenu.sh

Output:

#!/bin/sh
while :
do
        /usr/sbin/diag/appmenu
        tmp=$?
        case $tmp in
                4)
                /usr/sbin/card/ids ;;

                5)
                /usr/sbin/card/dfc ;;

                6)
                /usr/sbin/card/chkwgh ;;

                8)
                /usr/sbin/card/hway ;;

                9)
                /usr/sbin/card/mscalemodbus ;;

                10)
                /usr/sbin/card/mscaleeip ;;

                12) /usr/sbin/diag/touchcal
                        if [ $? -eq 27 ] ; then
                                sh /usr/sbin/diag/cln_nand.sh
                                exit
                        fi ;;

                13) sh /usr/sbin/diag/filemgr.sh ;;

                14) /usr/sbin/diag/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 ;;

                98) /usr/sbin/diag/diag m ;;

                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 “/usr/sbin/diag/appmenu”. This causes the script to execute a program file called “appmenu” just as if it were typed from the command line. The “/usr/sbin/diag/” specifies the directory the program is located in. The “appmenu” program displays a menu on the 825 indicator. The menu items presented are determined by reading configuration information from the NOR flash.

Mounts

After the "appmenu.sh" script is started the "rc.local" script starts mounting the 64M NAND flash as /mnt/nand. The "&" is used to cause the mount to run in the background while the startup script continues on. You can view the current mount points by typing:

# cat /proc/mounts

The Configuration Utility “touchcal” has an option “Configure Menu” which allows the menu to be customized.

When any of these choices is selected the “appmenu” program terminates back to the appmenu.sh script with a return value corresponding to the menu item selected.

The following lines check the return value from the appmenu program:

        tmp=$?
        case $tmp in
                4)
                /usr/sbin/card/ids ;;

                5)
                /usr/sbin/card/dfc ;;

                6)
                /usr/sbin/card/chkwgh ;;


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.

  12) /mnt/nand/bin/touchcal ;;

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

               12) /usr/sbin/diag/touchcal
                        if [ $? -eq 27 ] ; then
                                sh /usr/sbin/diag/cln_nand.sh
                                exit
                        fi ;;

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

#!/bin/sh
# File manager
while :
do
/usr/sbin/diag/filemanage
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.

                14) /usr/sbin/diag/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:

/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 “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.

Support Applications

/usr/sbin/diag/appmenu –

The appmenu program displays the application menu.

/usr/sbin/diag/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

/usr/sbin/diag/loadsrec "/mnt/nfs/Demo1 M5213EVB Boot Loader.elf.S19" M N

/usr/sbin/diag/loadsrec /mnt/nfs/m5329evb_flash.S19 O N

echo " Done " > /dev/carddsp

/usr/sbin/diag/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.

/usr/sbin/diag/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:

# File manager
while :
do
/usr/sbin/diag/filemanage
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.

Last modified 12 months ago Last modified on 04/25/23 06:55:52
Note: See TracWiki for help on using the wiki.