Printer Firmware Framework
Introduction
With the increased use of IT in low end and mid segment retail outlets across developing countries, there is an increasing demand for low cost, high performance label and receipt printers as the Point Of Sales (POS) printers. Most printers available today are implemented as embedded systems with a specific architecture to keep costs low.
Printer manufacturers face several challenges such as the introduction of a highly integrated MCU soc, the ever decreasing cost of silicon and the need to keep pace with market demands. Another critical concern for manufacturers is the increasing cost of software development. The introduction of a new product line or R&D requires careful planning and budgeting due to the burgeoning cost of software development.
Quite often, the migration of an existing solution to new hardware and OS platforms is made difficult by a myriad of factors like architectural suitability, modularity and maintainability. All these need to be carefully addressed to ensure that introducing the new product is viable and does not impact the performance of the product.
Calsoft Labs' 'Thermal printer firmware framework' leverages its Hardware-and–Operating-Systemindependent architecture to help printer manufacturers and OEMs reduce time to market for new and enhanced printer portfolios in different market segments. The framework uses an OSAL/HAL architecture that results in a completely portable printer firmware providing manufacturers with significant development cost savings and low cost of ownership.
What is OSAL/HAL?
OSAL
OSAL – 'Operating System Abstract Layer' is a layer of software that enables any application to interface with the required services from RTOS without actually using the RTOS's specific calling convention. This is achieved by developing the application using well defined abstracted service functions that are independent of OS – called Service Abstraction Layer (SAL)
- For example under LINUX OS, develop a SAL to LINUX Service translation layer - called operating system service translation layer (OSTL-LINUX)
- Compile
SAL + OSTL-LINUX=OSALLinuxflavor - To migrate to a new OS, example VxWorks - create new OSTL-VxWorks
- Compile
SAL + OSTL-VxWorks=OSALVxWorksflavor
To demonstrate this design technique, let us consider a simple example of an abstracted service – to create a common OS independent service function say 'Task OS_TaskCreate.' The figure below shows how this OSAL layer needs to be added when the modular application is ported under various RTOS/ OS platforms.

HAL
HAL – Hardware Abstraction Layer is a layer of software that enables developers to write device specific driver abstractions independent of the Hardware & OS and enable migration to various platforms with minimal effort both in terms of implementations and validations. When we speak about the HAL abstractions there are two distinct components that need to be dealt with. They are
1. HAL standard drivers:
These are drivers for the standard Board / MCU specific peripherals. Each OS/ RTOS has a different way of accessing these devices. Application modules interfacing with these devices need to use OS specific device interface APIs. This means that to maintain OS independent architecture for the given design, we need wrapper functions for these standard drivers too. This is best shown in the way a serial port is accessed under two different OS scenarios
- Linux -- as /dev/ttyS0 device file
- VxWorks --- via system calls sysSerialInit, sysSerialChanGet, …SIO_CHAN device
HAL standard driver wrappers allow migration of the design to a new OS environment with ease by using the appropriate HAL standard driver layer wrappers.
2. HAL Custom Device Drivers:
These are application specific custom drivers such as that actual printer driver (dealing with strobe signals, motor mechanism, sensors etc.) Their implementation depends on low level kernel APIs, which are OS specific. They also depend on the CPU/SoC that is used and would include a driver algorithm that depends on the actual printer mechanism, such as printer head driving algorithm or motor mechanism driver algorithm.
These drivers have been modularized by segregating OS dependant code. The same has been done with the CPU/SoC specific code and print mechanism specific code. This has been done by using wrapper modules/ abstractions layers to interface with the application modules to make it OS and Hardware independent.
For ex. In order to support a new printer mechanism, the modifications would be made only to the printer mechanism specific code.
Thus, HAL layers enable modular development which is OS independent.
- They provide uniform device access APIs from the application modules
- Application modules make use of wrapper APIs
- There are no changes to the individual application modules
- They include OS specific wrapper source files i.e. HAL layers at compile time
- Implementation of this wrapper module is OS specifi.
Specifications of Calsoft Labs' printer firmware framework
Calsoft Labs' engineering has developed a viable and practical approach for a completely portable Thermal printer solution framework. The approach consists of listing specifications that implement the desired portability objectives and meets certain market specifications as a part of a working solution. The details of such specifications are:
- Portability to any RTOS / OS
- Architected framework needs to have minimal adaptation cycle
- Adoptability to a new OS/RTOS with minimal cost or schedule impact
- Portable to any MCU platform
- Architected framework needs to have minimal adaptation cycle across most popular MCU platforms
- Adoptability to a new platform with minimal cost or schedule impact
- Device support
- External Blue tooth Module support on RS232 port
- External WLAN Module support on RS232 port
- USB port support to Host
- 2 inch print heads and 4 inch print heads support from ROHM
- Print head profile algorithm development for KF2002-GD45B print head
- Print head profile algorithm development for KF2002-GF94EB print head
- Performance
- 300mm/S print speed on 4 inch width print head @203 dpi resolution
- 100mm/S print speed on 2 inch width print head @203 dpi resolution
- Command Emulation support
- ZPLII command Support
- Support for 160 ZPLII commands parsing
- EM 220 command support
- Support for 58 EM 220 commands parsing
- ZPLII command Support
- Font and Barcode Engine Support
- Barcode and Font engine with OSAL layers
- Support about 20 varieties of 1D, 2D barcode generation Engine and True type and Scalable Font Engines, Bit Map Font data base, Font generation Engines
- Printer Support function
- Support MSR (magnetic stripe reader)
- System Monitor functions
- Diagnostic and self test functions
- Error handling and visual indication
- Printing hardware Support – SRP 770 print mechanism (as a testing mechanism)
- Print motor driver & head driver for an SRP 770- 4 inch print mechanism with Cutter and peelers
- Printing hardware Support – SPPR 200 print mechanism (as a testing mechanism)
- Print motor driver & head driver for an SPPR 200 -2 inch print mechanism
Calsoft Labs chose to develop the base solution on embedded Linux kernel 2.6.27 since the OS is POSIX compliant, free of licensing and available with generic open source development tools. The Hardware selected was an ARM9 based SOC and an AT91SAM9G20 as it provided all the necessary peripherals and a low-cost MCU.
Calsoft Labs' Thermal printer firmware framework with OSAL/HAL architecture
As explained earlier, the thermal printer firmware framework is based on the OSAL/ HAL based portable architecture. The following block diagram depicts a top level view of the system architecture

Challenges during print head driver development
The printer framework was first developed for a thermal printer. For a thermal printer that works on heat transfer, the driver algorithm that drives the print heads and the Motor drive movement concurrently had to be optimized. A non-optimum algorithm of controlling print heads and motor drives would result in print quality issues like:
Residual heat issue:
In the picture below, the first print labeled Normal is the desired print image. However because of the residual heat effect, printing in some cases can get distorted. The print head driver and motor driver work concurrently in a thermal printer. If the drivers are optimized, the head is heated only enough thereby transferring the correct image pattern.

In the quality print mode, this distortion can be greatly reduced by
- Use of optimized print head and motor driver algorithm
- Advanced historical data generation algorithm
Machine Gun Effect:
Machine gun effect is a phenomenon in which printing is paused until a new line of data is received and is created before printing. The machine gun effect is achieved by implementing the adoptive speed control algorithm.
In general this occurs under the following conditions:
- Standard mode (line printing)
- Low rate of data inflow from host and high speed printing
- Large data amount per a line (Print driver module should wait until all of data for one line printing is received completely).
The above mentioned problem requires an advanced printing speed control algorithm where printing speed is varied continuously during the printing operation according to the amount of data inflow and head temperature management. Proper buffer management has been added to ensure over all print quality performances.
It is worth noting that the print driver algorithm has to be tuned for every different print head type that is being deployed. Calsoft Labs' solution provides support to interface to a 2 inch mechanism or 4 inch mechanism. Drivers for each mechanism/ heads are developed separately to provide the best speed and print quality performance.
Salient features of the framework
The various market required features and functions supported by Calsoft Labs' OSAL/ HAL based, thermal printer framework are:
Historical data based printing and advanced speed control algorithm:
The thermal printer firmware framework implements the above methods in hardware and OS independent ways to get the best print quality and maximum speed performance.
Paper Sensor:
Implementation of the requisite drivers (HAL based) that senses continuous (journal / receipt papers) or label papers as and when loaded and switches the mode of the operation of the printer automatically. For label modes, the length and width are auto calibrated and various Label paper types are recognized.
Cutter peeler:
Medium and high speed printers require cutters while printing in receipt mode printing and peelers while printing in label mode. Both these features have been implemented in the framework.
1D barcode support:
Barcode is an essential part of Auto ID Data Capture (AIDC) systems. These barcode types can be made available to other Command type Emulations also based on the command set support. The barcode engine is modular and so any other popular linear Barcode type can be added as per specific OEM requirements.

2D bar code support:
2D means 'two dimensional'. 2D barcodes contain more information than conventional one dimensional linear barcodes. Conventional barcodes get wider as more data is encoded. 2D barcodes make use of the vertical dimension to pack in more data. 2D barcodes have become possible as auto scanning CCD and laser scanners have replaced the original 'light pen' type of scanner. These barcode types can be made available to other Command type Emulations also based on the command set support.

Font types supported:
Language and Font support is an essential feature for any printer solution. As the print representations in Label and receipt mode printing is based on the user's preference, both command sets and the printer product has to provide the user with choice. The Thermal printer firmware framework supports the following language and Fonts.
- Language support :
- English, Japanese, Korean, GB23129 (simplified Chinese), BIG5
- Font support* :
- Bounded TTF
- UnBounded TTF
- Bitmap Font
- Uncompressed ZA (Zebra ZB 64)
- Uncompressed TTB
*Font size depends the font type and firmware doesn't restrict the size
Compile time feature inclusion:
As the solution was initially developed on Linux environment, a Linux kernel style 'menuconfig' GUI has been implemented in the framework to enable the selection of various features to be included during compilation of the firmware.
The features (at a high level) that can be selected include:
- Target: Host (to be run on PC) / Board (to be downloaded and run on the printer)
- Communication Interfaces: UART, USB, WLAN, Bluetooth
- Font's selection: Language/Type
- Barcodes selection: 1D/2D
- Media Type Selection: Label, continuous
- Print Width selection: 2 inch, 4 inch
- Print Direction selection: Normal/Reverse
- Debug Options selection: (Debug print levels/Dynamic Memory Management)
For each of these options, sub-options can be selected wherever applicable.
Enhancements and upgrades possible:
The framework has the capability to download upgraded firmware to the printer.
Performance data:
Two methods were used to measure performance of the solution.
Method 1 was using a print mechanism that had certain physical maximum motor / head speeds and Method 2 was by checking the maximum data through put performance at the strobe and data level to the print head drive output. The results of the tests have been compiled and presented below.

The table below provides the actual performance of a market printer from an Industry leader under the same testing conditions. Under these conditions, Calsoft Labs' solution clearly outperforms the other product.


