If you destroy the application in the internal Flash, you must use the NXP ISP loader to reload an Intel Hex file. A suitable baud rate is 38400 baud. To use this, ensure that port P2.10 is low. There is a link on the board that (when installed) enforces this. Then reset the board and use the Philips loader. Then close the Philips loader. Ensure that the P2.10 link is removed before resetting the board. Then connect using AIDE's PowerTerm or HyperTerm.
Once the Forth system is running again, you can use the word
REFLASH ( -- )
to download a new binary image.
Note that REFLASH
only handles binary memory image
files. These should transferred using the XModem 128
(checksum) protocol. If you are using AIDE with the file
server enabled, a file selection dialog will appear
automatically after you have executed REFLASH
.
The LPC17xx can only be reflashed from an application by
a program running from RAM. A separate application built
by a control file Reprog\Reprog*.CTL is used to do this. A
binary image REPROG*.IMG
is inserted into the application.
When required, the code is copied into the internal RAM and
executed from RAM.
Return is by rebooting the system. The contents of the internal RAM and Flash are destroyed, therefore any data that must be preserved should be saved externally to the chip. Alternatively, modify the reprogramming code to use the last sector to hold data to be preserved.
The layout of the RAM code is defined in the control file for the RAM application. This defines the first cell as the Forth word to execute.
create reprog.img \ -- addr
The start address of the reprogramming code
data-file %HwDir%/ReProg/REPROG17XX.IMG equ /reprog \ -- len
Generic 17xx:The length of the reprogramming code loaded into
the dictionary.
$1000:0200 equ reprogrun \ -- addr
The run time address of the reprogramming code.
This must match the start address of the CDATA
section defined in Reprog17xx.ctl, and that section
must not overlap the run-time stacks and user area.
0 value ReflashDev \ -- addr
Holds 0 or a UART base address. If set to 0, the reflash
code will use the default device for the XModem transfer.
Otherwise it will use the value here as the base address
of the UART to use.
The start of the RAM code block holds data about the running Forth.
ReprogFlash
to run,CopyFlash
to run,
: callit \ xt --
Load the reprogramming code and execute the xt.
: reflash \ -- ; no exit
Copies the reprogramming code to the run-time address
and executes it.
: CopyFlash \ src dest len --
Copy the flash. The parameters are as for CMOVE
.
The process is repeated until there are no errors, and
the system is then rebooted.