Introduction
Please note:
This is likely to be replaced with a 'quick loader' on a future
release of PIC32-Basic
Micro-BOS is a software layer that sits between the boot and application. Its function is to increase the portability of the application layer.
The software provides the following services:
- Application loading via Xmodem or hex download.
- Default UART communication
- Disk operating system compatible with FAT16
- Flash writing
Software Structure
The software consists of a minimum of two layers that consist of ‘boot’ and ‘Micro-BOS’. The application layer normally sits on top of those. Some processors do not need a boot layer as they are capable of downloading the Micro-BOS from the USB using the manufactures boot process, for example the Phillips ARM. Where this is not available the boot software is installed.
Boot

Example Memory Layout for the PIC32
The boot software is provided on processors that are not capable of downloading software on to Flash without the use of a specialised programmer. The PIC32 is an example of this and the boot has been provided so that the specialised programmer is not required.
The purpose of the boot is to enable Micro-BOS to be downloaded should it become corrupt or a new version is available. For details of how to restore the system using the boot loader refer to the BV513 Hardware Section.
Micro-BOS
This section contains all of the software required to make the processor work
easily with the application. Micro-BOS stands for Microcontroller Basic
Operating System. It contains the Input / Output, SD-Card software and other
useful interfaces.
This software is designed to run with other software as it provides a single
entry point into the functions mentioned above. It is not intended to be user
interactive, although there is a small menu system if an application, in Flash,
is not detected.
Application
The application runs on top of the Micro-BOS and uses the calls into the system via this. This will allow an application to run on other kinds of microcontroller with little code change (in theory).
App.com
If this file exists on the SD Card and there is no application loaded into Flash, Micro-BOS will load this file into Flash and execute it.
Boot Process
This process is also described in the BV513 Hardware Section as a step by
step system restore.
A normal start up will go to the boot section first, continue to the Micro-BOS
and then on to the application. At each stage there is a mechanism for
interrupting this normal flow in order to change various aspects of the
software. The boot process will check the ‘prog’ pin to see if it is low, this
is normally held high by a 10k resistor. If it is low at boot time (reset or
power on) then the boot program will present the following prompt:
#>
The prompt will be displayed using 115200 Baud and so to see this it is
important to set the terminal to the correct Baud rate. At this stage page 0 of
the Flash is also erased, this contains semi permanent settings such as the
default Baud rate. If any key is pressed except ‘#’ nothing further will be done
and the boot process will go on to the next process (Micro-BOS, assuming it
exists).
If however the ‘#’ key is pressed at this stage, ALL of the Flash will be erased (except the boot area) and a prompt will be given to download a hex file. This file will normally be Micro-BOS. It is possible therefore to reinstate a corrupt system or update Micro-BOS using this mechanism without the need for a specialised programming device as it is all done through the serial port.
Micro-BOS
Micro-BOS sits between the processor and the application; it consists of a set of routines with a single entry point to access those routines. The routines are those that most applications will require such as serial I/O, access to the SD Card, access to the Real time clock etc. Its existence makes writing applications for differing processors that much simpler as it presents a common constant interface.
Start Up
At reset the ‘prog’ pin is checked to see if it is low, it is normally high. If it is low, page 0 of the Flash is erased. This contains the user settings such as a custom Baud rate and so the Micro-BOS (mBOS) reverts to its default state of 115200 Baud and presents the mBOS menu.
If ‘prog’ is high page 0 will not be erased but the program pauses momentarily to see if any key is being pressed, if so the mBOS menu will be presented. This gives the user an opportunity to install an alternative application. If no key is pressed and an application is present at 0x1d01:1000 (this address may change) mBOS instructs the processor to jump to that address and begin executing. If no application is present mBOS will remain in the user menu, waiting for user input.

Micro-BOS menu
This menu is presented when either a key is pressed before the application is run or there is no application loaded in Flash.
Loading Programs
There are two methods of loading programs into the flash memory once inside mBOS, the first is using a hex file and the second is by using X-Modem(1k). The latter should be used in preference to a hex files as it is much faster and loading a hex files requires that the host send the character 6 at the end of each line which may not be possible with all terminal software. A binary file can be created from a hex file by using the free hexfbin.exe software (see the downloads section).
X-Moden(1k) is an established and simple protocol, it transfers files 1k at a time in binary format. At 2,000,000 Baud it only takes a few seconds to Flash 200k of program memory.
Changing the Baud Rate
The default baud rate is 115,200 which will be set if the ‘prog’ pin is held low on reset. The Baud rate information is held in page 0 of the flash memory and so will remain until erased. To change the Baud rate with the menu option provided requires two pieces of information, first the baud rate and second the mode. The mode is a number between 0 and 7 and has the following meaning:
| Mode | Description |
| 0 | 8 data bits, no parity, 1 stop bit |
| 1 | 8 data bits, no parity, 2 stop bits |
| 2 | 8 data bits, even parity, 1 stop bit |
| 3 | 8 data bits, even parity, 2 stop bits |
| 4 | 8 data bits, odd parity, 1 stop bit |
| 5 | 8 data bits, odd parity, 2 stop bits |
| 6 | 9 data bits, no parity, 1 stop bit |
| 7 | 9 data bits, no parity, 2 stop bits |
It is recommended that if using the BV-Com terminal program (see downloads section) then a Baud rate of 2,000,000 is used with mode 0. The Baud rate and mode are written to Flash so that this information is retained when the power is cycled.
Functions
mBOS provides a single entry point into a suite of functions that have been especially written for the particular type of microcontroller. Each function is numbered and there is a structure used for transferring data back and forth. Because of the rich set of features on most microcontrollers it is not practical to cover all possibilities. The mBOS therefore provides mainly the following functions:
- SD Card file system, currently FAT16 with support for subdirectories, long file names and up to two SD Cards
- Default UART I/O for basic communication
- Flash writing
- Downloading with xmodem and hex file support. This has been covered in the section on Loading Programs.
To assist in using these functions if required, there is a file in the
downloads section called mbos.c (and mbos.h) which is the C source code for
interfacing with all of the BOS routines.