Link here

Recover QScreen Memory


This page describes how to extract the binary image from Qscreen memory and make a downloadable file that can restore the entire application program.

 

Introduction

The Mosaic Integrated Development Environment (IDE) provides a full-featured text editor with source-code coloring of keywords and comments, plus icon-based invocation of the compiler, terminal, and graphics conversion tools. These tools enable you to build your working graphical user interface (GUI) application on the QScreen, a graphical embedded computer based on the 68HC11 microcontroller coupled with a liquid crystal display (LCD) and touch panel. Once you have finished using the development tools to debug your application software, simply invoke the Autostart command to automatically run your application each time the system boots up.

In some rare instances, it is desirable to extract a binary file that completely describes the code image residing on the QScreen. The required procedure is described here.

This document only applies to programs that were written in C. After the board is factory cleaned, as described below, the priority autostart address can easily be recovered. If the program was written in forth, it is not possible to recover this priority autostart address using the Mosaic Board alone. Please contact Mosaic Industries if you are trying to recover the binary image from a program written in Forth.

 

Getting started

After ensuring that the Mosaic Board you are working with was programmed in C, start by factory cleaning the board. To factory clean a QScreen controller, install jumper J2. With this jumper installed, power the board on and press the reset button. Now remove J2. You should see a "Coldstart QED-Forth V4.40" message displayed in the terminal window.

 

Checksum verification

To verify that this process has completed successfully, we can compare the checksums of each memory page before and after the recovery and reprogramming process. Simply copy the code below and paste it into the terminal. After sending the code below, type QScreenChecksums. The board will print out 16 bit checksums for each memory page. Copy and paste this output into a text file and keep it for your records. This checksum calculation can be repeated after memory is restored to verify that the process was successful.

hex
: QScreenChecksums
  hex
  standard.map
  cr
  ." Checksum for page 0x4: " 0 4 8000 calc.checksum . cr
  ." Checksum for page 0x5: " 0 5 8000 calc.checksum . cr
  ." Checksum for page 0x6: " 0 6 8000 calc.checksum . cr
  ." Checksum for page 0x7: " 0 7 8000 calc.checksum . cr
  ." Checksum for page 0xC: " 0 C 8000 calc.checksum . cr
  ." Checksum for page 0xD: " 0 D 8000 calc.checksum . cr
  ." Checksum for page 0x10: " 0 10 8000 calc.checksum . cr
  ." Checksum for page 0x11: " 0 11 8000 calc.checksum . cr
  ." Checksum for page 0x12: " 0 12 8000 calc.checksum . cr
  ." Checksum for page 0x13: " 0 13 8000 calc.checksum . cr
  ." Checksum for page 0x14: " 0 14 8000 calc.checksum . cr
  ." Checksum for page 0x15: " 0 15 8000 calc.checksum . cr
  ." Checksum for page 0x16: " 0 16 8000 calc.checksum . cr
  ." Checksum for page 0x17: " 0 17 8000 calc.checksum . cr
  ." Checksum for page 0x20: " 0 20 8000 calc.checksum . cr
  ." Checksum for page 0x21: " 0 21 8000 calc.checksum . cr
  ." Checksum for page 0x22: " 0 22 8000 calc.checksum . cr
  ." Checksum for page 0x23: " 0 23 8000 calc.checksum . cr
  ." Checksum for page 0x24: " 0 24 8000 calc.checksum . cr
  ." Checksum for page 0x25: " 0 25 8000 calc.checksum . cr
  ." Checksum for page 0x26: " 0 26 8000 calc.checksum . cr
  ." Checksum for page 0x27: " 0 27 8000 calc.checksum . cr
  ." Checksum for page 0x28: " 0 28 8000 calc.checksum . cr
  ." Checksum for page 0x29: " 0 29 8000 calc.checksum . cr
  ." Checksum for page 0x2A: " 0 2A 8000 calc.checksum . cr
  ." Checksum for page 0x2B: " 0 2B 8000 calc.checksum . cr
  ." Checksum for page 0x2C: " 0 2C 8000 calc.checksum . cr
  ." Checksum for page 0x2D: " 0 2D 8000 calc.checksum . cr
  ." Checksum for page 0x2E: " 0 2E 8000 calc.checksum . cr
  ." Checksum for page 0x2F: " 0 2F 8000 calc.checksum . cr

;
 

Dump

To dump all the memory on the board:

  • Copy and paste the code below into the terminal, and wait until it loads.
  • From the Terminal, click File→ Save File
  • Name the file 'RecoveredMemory.4th' and save it in a known location. You will need to edit this file later
  • Type at the terminal prompt: 'QScreenDump'
  • After text stops printing out, click File→ Close File
HEX \ Make sure we're compiling using hexadecimal numbers
: QScreenDump ( -- )
 \ This program dumps the memory contents of the application area of the EEPROM
 \ and each page of Flash memory to the terminal in standard ASCII S-records
 \ using Motorola S2 format.
 
  STANDARD.MAP \ Make sure flash is on pages 4,5,6
 
  AEC0 00 DIN 000000 0140 DUMP.S2 \ Dump 0x0140 bytes starting at EEPROM location 0xAEC0
  0000 04 DIN 040000 8000 DUMP.S2 \ Dump 32K from page 04 Flash
  0000 05 DIN 050000 8000 DUMP.S2 \ Do the same for each page of flash on the board
  0000 06 DIN 060000 8000 DUMP.S2
  0000 07 DIN 070000 8000 DUMP.S2
  0000 0C DIN 0c0000 8000 DUMP.S2
  0000 0D DIN 0d0000 8000 DUMP.S2
  0000 10 DIN 100000 8000 DUMP.S2
  0000 11 DIN 110000 8000 DUMP.S2
  0000 12 DIN 120000 8000 DUMP.S2
  0000 13 DIN 130000 8000 DUMP.S2
  0000 14 DIN 140000 8000 DUMP.S2
  0000 15 DIN 150000 8000 DUMP.S2
  0000 16 DIN 160000 8000 DUMP.S2
  0000 17 DIN 170000 8000 DUMP.S2
  0000 20 DIN 200000 8000 DUMP.S2
  0000 21 DIN 210000 8000 DUMP.S2
  0000 22 DIN 220000 8000 DUMP.S2
  0000 23 DIN 230000 8000 DUMP.S2
  0000 24 DIN 240000 8000 DUMP.S2
  0000 25 DIN 250000 8000 DUMP.S2
  0000 26 DIN 260000 8000 DUMP.S2
  0000 27 DIN 270000 8000 DUMP.S2
  0000 28 DIN 280000 8000 DUMP.S2
  0000 29 DIN 290000 8000 DUMP.S2
  0000 2A DIN 2A0000 8000 DUMP.S2
  0000 2B DIN 2B0000 8000 DUMP.S2
  0000 2C DIN 2C0000 8000 DUMP.S2
  0000 2D DIN 2D0000 8000 DUMP.S2
  0000 2E DIN 2E0000 8000 DUMP.S2
  0000 2F DIN 2F0000 8000 DUMP.S2
;
 

Edit - EEPROM

After the board stops sending data to the terminal, make sure you click File→ Close File. Now, open the file you just saved in a text editor. Delete any forth commands at the beginning of the file. Everything before the first line starting with "S009" should be deleted. Notice that each section of memory is dumped out in blocks separated by new lines. We will simply refer to these memory sections as 'blocks' when describing this file.

The first block is the memory in eeprom. This block is smaller because there is less EEPROM than Flash memory on the board. Before the first block add the following text:

HEX
: RestoreEEPROM ( -- )
    \ This program transfers 0x0140 bytes of data from page 02 of ram
    \ (the location we copied it to) into the
    \ EEPROM starting at application EEPROM area address 0xAEC0
    140 0                         \ For 0x140 (decimal 320) bytes
    DO
        I 02 C@                    \ fetch a byte from page 02
        AEC0 I+ (EEC!)  \ add to the base address and write it to the EEPROM
    LOOP
;

Before the first block, insert:

0000 02 RECEIVE.HEX

After the first block, insert:

RestoreEEPROM

It is ok to put extra new lines in-between blocks for readability.

 

EDIT - The Rest

The rest of the blocks are much longer, and all have a standard edit that needs to be applied to each one.

Before each and every large block, insert the command (we call this the "preamble"):

0000 02 RECEIVE.HEX

After the first large block, insert the command (we call this the "postamble"):

0000 02 0000 04 8000 TO.FLASH

The next large block gets the same preamble command. The postamble comand must be modified to load the memory into page 0x05. This is done by changing the number before 8000 to 05:

0000 02 0000 05 8000 TO.FLASH

And the postamble inserted after the next block is the command for page 0x06. Notice that the page in the following command is now 06:

0000 02 0000 06 8000 TO.FLASH

Look at each DUMP.S2 line in the "QScreenDump" word above. Each DUMP.S2 command results in a block of memory in this file. As you edit this file, you MUST give the correct address to the TO.FLASH command. Here is a list of all the individual TO.FLASH commands you will need to insert, in order, one after each large block. Note that the first small block does not have a TO.FLASH command:

0000 02 0000 04 8000 TO.FLASH
0000 02 0000 05 8000 TO.FLASH
0000 02 0000 06 8000 TO.FLASH
0000 02 0000 07 8000 TO.FLASH
0000 02 0000 0C 8000 TO.FLASH
0000 02 0000 0D 8000 TO.FLASH
0000 02 0000 10 8000 TO.FLASH
0000 02 0000 11 8000 TO.FLASH
0000 02 0000 12 8000 TO.FLASH
0000 02 0000 13 8000 TO.FLASH
0000 02 0000 14 8000 TO.FLASH
0000 02 0000 15 8000 TO.FLASH
0000 02 0000 16 8000 TO.FLASH
0000 02 0000 17 8000 TO.FLASH
0000 02 0000 20 8000 TO.FLASH
0000 02 0000 21 8000 TO.FLASH
0000 02 0000 22 8000 TO.FLASH
0000 02 0000 23 8000 TO.FLASH
0000 02 0000 24 8000 TO.FLASH
0000 02 0000 25 8000 TO.FLASH
0000 02 0000 26 8000 TO.FLASH
0000 02 0000 27 8000 TO.FLASH
0000 02 0000 28 8000 TO.FLASH
0000 02 0000 29 8000 TO.FLASH
0000 02 0000 2A 8000 TO.FLASH
0000 02 0000 2B 8000 TO.FLASH
0000 02 0000 2C 8000 TO.FLASH
0000 02 0000 2D 8000 TO.FLASH
0000 02 0000 2E 8000 TO.FLASH
0000 02 0000 2F 8000 TO.FLASH

For more information on these addresses, see qscreen-memory-map-by-page. This table shows each page in memory, and explains why all the memory pages are not contiguous.

Delete any forth commands or unwanted text at the end of the file. This should only be the word "ok" on the very last line of this file.

 

Autostart

In the case that the board was programmed in C, the autostart vector points at the default location, "main". To restore the board's autostart vector, insert this line at the end of the file:

CFA.FOR MAIN PRIORITY.AUTOSTART
 

Summary

Congratulations, you are done creating a file that will restore an entire program to a Qscreen. If you would like to verify that this file is correct, follow the steps in the Checksum Verification section above. Implement the checksum instructions after sending the restoration file but before resetting the board. Once the board is reset, the autostart vector may prevent any forth commands from being executed.



See also → Making Effective Use of Memory
QScreen Controller Users Guide
Forth V4.4 Function Summary

 
This page is about: Restore Application Program, Extract Code Image – This page describes how to dump the binary image from Qscreen memory and make a downloadable file that can restore the entire application program.
 
 
Navigation