Copyright (C) 2005 Matt Evans (mattmon at axio dot ms) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ================== Amstrad E2 monitor ================== 29 Jan 06, v0.26 Changelog: 0.26: Added SWIs for common functions (e.g. serial I/O) 0. Intro This is a (supposedly small) monitor/bootloader for the Amstrad E2. It does not replace PBL in the NOR flash, but is designed to sit in the first 2 blocks of NAND flash, and be booted *via* PBL. To do this, you'll need David Given's pblq program in order to 'bless' the binary before installation (and probably also to install it). I CBA to add the checksum feature to the makefile just now, it will be done soon. This README assumes you know what you're doing. You know that reflashing the NAND in your em@iler means you may break it. It *could* be irreparable. There is no warranty. Features: o Peek/poke/dump/fill memory addresses - useful for probing GPIO/peripherals. o Jump to address - APCS-like call, can be used to do a proper function call & provide arguments. o XMODEM upload/download - transfers to RAM o CRC32 of memory blocks o PBL NAND flash read/write to/from RAM o Boots from PBL o Loads/executes subsequent programs from flash 1. Installation You'll need an ARM toolchain, local or cross. Edit the Makefile to point to it. You may also like to edit uart.S (at the end) to set a baudrate. 115200 is reliable for me, and is the default but some have had problems and therefore configured 57600. 'make' should spit out: monitor.elf - The linked program, suitable for downloading via JTAG or whatever. It's linked at 0x40000, and if loaded elsewhere should relocate to here. monitor.bin - The flat file of the above monitor.pbl - The flat image wrapped in a PBL-style header. BLESS THIS FILE WITH PBLQ BEFORE UPLOADING! crcfile - A host utility to CRC32 a given file. Useful to compare against DRAM version! I have not tested uploading monitor.pbl to the flash via pblq - I have written it to flash using itself (having booted the first image via a JTAG download) but it should work. Put it at flash offset 0, and it will require two 8K blocks. 2. Usage Serial console, 115200 8N1: should see welcome banner & be dropped into a mediocre CLI. There is a bit of help available. Commands generally take arguments, and all addresses/numeric values are hexadecimal! Commands are all lowercase. Command examples: > dumpm 40280 40 00040280: e24fafa2 eaffffe2 0a0d0a0d 5b2d2d2d ..O.........---[ 00040290: 4d203245 74696e6f 7320726f 74726174 E2 Monitor start 000402a0: 2c676e69 2e307620 2d5d3232 0a0d2d2d ing, v0.22]---.. 000402b0: 00000000 20555043 746e6f63 3a747865 ....CPU context: [Dump memory from absolute address + offset] > dump0 0 20 00000000: 3b513b51 00002de8 00003a8c 00000000 Q;Q;.-...:...... 00000010: 00000000 00544f42 00000000 00000000 ....BOT......... [Dump flash device 0 (only one supported as yet) - internal NAND.] > crc 0 1234 CRC32 of block = 0x03ade976 [CRC address 0 for 0x1234 bytes: can compare this to data on disc using 'crcfile'] Download something into NAND flash: I know 1MB into DRAM is free, so download to there, then flash from there. (It can only flash from DRAM - that is, large images might have to be done in two halves.) > put 100000 CC [Start XMODEM download ... completes] Transfer finished; received 00003180 bytes. > flashwr 8000 4000 100000 Writing data from RAM address 00100000 into flash offset 00008000, length 00004000 Erasing ... ...done Programming ... success. > [Note that flash offsets and addresses for flashrd/flashwr must be block(8K)-aligned] Yes, it's very rudimentary and assumes you know the machine's memory map. Briefly, all you really need to know is that DRAM is at 0 and is 0x800000 long. 0x000000-0x01xxxx [PBL's RAM image, this is used by the monitor so keep it sane] 0x020000-0x032c00 [LCD display buffer - weird pixel format (pixels seem MostSig first in byte)] 0x03xxxx-0x03f000 Monitor stack 0x040000-0x045xxx Monitor 0x045xxx-0x7fffff Free 2a: Boot images See monitor/testimage for an example of a program that can be flashed into NAND after the monitor. A little dumb header states where to load/execute it, and its name. The CRC field is unused. The monitor searches for such images on boot, and when the "listboot" command is entered. "boot" will run an image manually. 3. Caveats XMODEM: It may not work for you. I haven't got it working with with rx/sx & minicom (for me). I use ZTerm (an OS X app) which works OK. Double-relocate: PBL loads it to 0x4000n. It relocates itself to 0x40000 by moving somewhere else and back. PBL should load it somewhere out of the way, so only one relocate. --