9 » IC Electronic information » Category: B

IC Electronic information

Bootloader PIC18 microcontroller-based design of novel

In Electronic Infomation Category: B | on April 15,2011

Bootloader is running in the kernel before the operating system running a small program, its main function is to complete software and LSI53C1030 datasheet and hardware initialization, the establishment of the memory space mapping, the system software and LSI53C1030 price and hardware to bring an appropriate state of the environment, or add image file containing the operating system for system software upgrades to the operating system kernel for the final call to prepare the right environment. Usually, BootLoader is heavily dependent on the hardware implementation, especially in the embedded world. Therefore, in the embedded world, the establishment of a common BootLoader is almost impossible.

For the PIC18 family of microcontrollers, there is currently only available in the market provided by HI-TECH Bootloader program, and LSI53C1030 suppliers and requires the help of serial debugging assistant. Based on Microchips MPLAB software development environment designed a new Bootloader, and supporting the preparation of the PC-side host computer interface program. It features flexible control, convenience, safety and reliability upgrades.

1 Bootloader implementation

1.1 Bootloader mode of operation

Bootloader in the MCU power / reset, the user program before running, running into the upgrade to determine whether the current state. If you do not need to upgrade to directly run the original program; If you need to upgrade, first erase the old program, and then receive the user program from the serial port, and write Flash. Bootloader has 2 operating modes:

boot loader mode, also known as the "kernel boot" mode. Bootloader from the target machine is a solid-state storage devices will be the operating system loaded into RAM to run, the whole process and no user intervention.

download mode. In this mode, the target will Bootloader on the serial port, network connection, or USB, etc., the operating system from the host computer to download the file, then save to the target of the Flash class solid-state storage device. Bootloader of this model is usually the first installation of the kernel and root file system is used, in addition, after the system update will also use Bootl-oader this operation. Bootloader

this design supports both modes, one begins to start in normal boot loader mode, it does not immediately launch into the kernel, but the prompt delay 3 s, some PC users who send information to the target machine, then switch to download mode, or to start the kernel.

1.2 Intel HEX file

Intel HEX file is the Intel HEX file with lines formatted text file composed of ASCII text. In the Intel HEX file, each line contains one HEX record. These records are machine language code and / or constant data of hexadecimal digits. Each record contains 5 fields: data length field that represents the number of data bytes in the record; address field that represents the starting address data in the record; representatives HEX record type; data field that represents a byte data, a record may have multiple data bytes, record the number of data bytes and data length of the field must match the number specified; checksum field that represents the checksum of the record, the record by all ten hex code numbers corresponding to the value of the sum, modulo 256, the remainder of the complement from the checksum.

1.3 Bootloader design Bootloader

designed this program with the compiler is software development environment mcc18 MPLAB compiler upgrade to Intel HEX format file format. According to Intel HEX file format, each line of the file contents into a package, together with the frame header and tail to ensure the reliability of data transmission, and use half-duplex communication mode, the retransmission of error frames.

Main program code is as follows:

Main program flow shown in Figure 1. Download the system image file and write program memory of the program flow shown in Figure 2.

Figure 1, the main program flow

Figure 2 update the system image system processes

1.4 PC client user interface design

PC client user interface is mainly used to achieve the following functions:

serial port parameters. Set serial port channel number, data bits, baud rate and other parameters.

user. Enter the user name, password, and the next crew to verify.

Select the system image file. Select HEX file system image, line by line and read through the serial port to the next crew, if the error re-select.

prompts the user to the system update is complete (or fail). Update progress display system, the system prompts the user to update the results.

2 design of several key technologies and Notes

If the HEX file once all the data sent through the serial port to the target chip, the communication process occurs in one byte of error transmission, will result in all data needs to be re-sent; and also to take into account the write-chip Flash processing speed and the size of the serial port speed, or else will result in the loss of received data. To enhance the reliability of communication with the serial port rate variability Bootloader designed this half-duplex communication mode to communicate with the host computer: The HEX file as a data line, after the end of each frame data check up crew send the reply data, the host computer to send data based on response data to determine the frame is wrong to choose return or continue to send the next frame; and carrying out communication with the host computer before the upgrade to check the user name and password in order to ensure that the current upgrade is not wrong operation.

PIC18 series of write program memory write 8 bytes per block, and the program can only be written to Flash units 1 to 0. But the HEX file content is not generated as needed, the length of each frame of data may be different, adjacent to the contents of the address field in the frame can be different. To this end, the program memory write operation, the need to address the contents of the domain content data field to 8 bytes combined into data blocks, less than 8 bytes to fill 0xFF. This program is designed Bootloader Buffer using a ring of structures to achieve this operation:

chip is the beginning of the default interrupt vector 0x08 and 0x18, which can not be changed, in order to change the entry address of interrupt vector address location will add these two jump instructions to jump to user program interrupt vector entry address. PIC18 family of part program memory address area with write protection to prevent Bootloader program outside of this area is erased or overwritten, need to receive data to determine the contents of the address field. If less than the starting address of the user program, you need to back up the crew, "write address error", and discard the current data frame.

3. Conclusion

Experimental results show that the designed Bootloader is stable, and easy to control, according to the users need for flexibility to change. For example, the user program can be added to the system reset mechanism to achieve online upgrade, the PC side to add a network interface module can be downloaded for remote control system upgrade, which for the release of embedded products and software upgrade is extremely important.

LSI53C1030 datasheetLSI53C1030 suppliersLSI53C1030 Price

All right © 2010-2016 Certificate