Application Mode Startup


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.


# cat /etc/rc.d/rc.local


if [ "$1" = "stop" ]; then
	echo "Stopping..." > /dev/carddsp
if [ -f /tmp/ ]; then
	. /tmp/
echo "        Starting..." > /dev/carddsp
modprobe i2c-coldfire
modprobe max734x
modprobe mnbd-comm
echo "  U)pdate  T)est" > /dev/carddsp
/usr/sbin/diag/waitkey 3
echo "\`L" > /dev/carddsp
if [ ! -f /proc/mnbd ]; then
	modprobe isp1520
passwd -z
stty -F /dev/ttyS0 -Z
stty -F /dev/ttyS1 -Z
if [ "$updkey" = "85" ]; then
	sh /usr/sbin/diag/
elif [ "$updkey" = "84" ] || [ -f /proc/mnbdtest ]; then
	cd /usr/sbin/diag
	./diag c
elif [ "$updkey" = "79" ]; then
	echo "\`" > /dev/carddsp
	echo "Starting OPI diagnostics" > /dev/carddsp
	mount -t jffs2 /dev/mtdblock1 /mnt/nand
elif [ "$updkey" = "27" ]; then
	echo "\`" > /dev/carddsp
	echo "Startup halted" > /dev/carddsp
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/ &
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
	boa $BOA_ARGS
ifconfig -T
if [ "$?" = "2" ]; then
	echo "Starting the weight server: "
	/usr/sbin/diag/wtsvr &
	if [ -f /mnt/nand/cfg/exports ]; then
		cp /mnt/nand/cfg/exports /etc/exports
ifconfig -L
if [ "$?" = "4" ]; then
if [ -f /mnt/nand/bin/ ]; then
	sh /mnt/nand/bin/ &



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


# 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/ &

The command “sh” means to call a shell script. The “” 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 "" script by from a terminal window by typing:

cat /usr/sbin/diag/


while :
        case $tmp in
                /usr/sbin/card/ids ;;

                /usr/sbin/card/dfc ;;

                /usr/sbin/card/chkwgh ;;

                /usr/sbin/card/hway ;;

                /usr/sbin/card/mscalemodbus ;;

                /usr/sbin/card/mscaleeip ;;

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

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

                14) /usr/sbin/diag/imageview /mnt/nand/cfg/slideshow.cfg ;;

                21) sh /mnt/nand/bin/ ;;
                22) sh /mnt/nand/bin/ ;;
                23) sh /mnt/nand/bin/ ;;
                24) sh /mnt/nand/bin/ ;;
                25) sh /mnt/nand/bin/ ;;
                26) sh /mnt/nand/bin/ ;;
                27) sh /mnt/nand/bin/ ;;
                28) sh /mnt/nand/bin/ ;;
                29) sh /mnt/nand/bin/ ;;
                30) sh /mnt/nand/bin/ ;;
                31) sh /mnt/nand/bin/ ;;
                32) sh /mnt/nand/bin/ ;;
                33) sh /mnt/nand/bin/ ;;
                34) sh /mnt/nand/bin/ ;;
                35) sh /mnt/nand/bin/ ;;
                36) sh /mnt/nand/bin/ ;;
                37) sh /mnt/nand/bin/ ;;
                38) sh /mnt/nand/bin/ ;;

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

                99) echo "\`" > /dev/carddsp
                echo "Restarting...\\r" > /dev/carddsp
                cd /
                reboot &
                exit ;;

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.


After the "" 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 script with a return value corresponding to the menu item selected.

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

1        tmp=$?
2        case $tmp in
3                4)
4                /usr/sbin/card/ids ;;
6                5)
7                /usr/sbin/card/dfc ;;
9                6)
10                /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.

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

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

1               12) /usr/sbin/diag/touchcal
2                        if [ $? -eq 27 ] ; then
3                                sh /usr/sbin/diag/
4                                exit
5                        fi ;;

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

2# File manager
3while :
7if [ $tmp -eq 1 ] ; then
8        sh /tmp/
10        exit

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/ and returns with an exit code 1. In this case the script calls the 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.

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


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


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:


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 :
if [ $tmp -eq 1 ] ; then
        sh /tmp/


The script executes the file manager in a loop. If the result is 1 the file manager created script /tmp/ 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 5 years ago Last modified on Jan 23, 2013, 9:51:18 AM