Subject: [E3-hacking] [E2 hacking] E2 monitor v0.22

From: Matt Evans <[email-masked]>
Date: Thu, 5 May 2005 01:25:31 +0100

Hello,

I've uploaded the state-so-far of my monitor to:

http://www.axio.ms/projects/e2/e2-monitor-0.22.tgz

(the README from the tar is also at 
http://www.axio.ms/projects/e2/e2-monitor-0.22-README )

What it can do:
o Provides basic monitor with commands such as peek/poke/go
o XMODEM upload/download RAM over serial (though this is currently 
v.picky about terminal s/w used)
o Read NAND flash to RAM
o Write/erase NAND flash from RAM data
o CRC32 chunks of memory
o Initialise LCD a bit/provide simple string/hex printing to it
o Boot from PBL

What it can't yet do:
o Search the rest of NAND for executable client programs, and boot them
o Access SMC cards (I have been unable to coax PBL into accessing them, 
but it looks like much of the support is there in PBL.  (Not 
necessarily complete/functional of course))

It's pretty fast at downloading data and writing it to flash, or just 
executing code, so I find it's a better development environment than 
EXP'ing stuff down with pblq-alikes.  I've usually started up the E2, 
interrupted the splash screen over JTAG and downloaded the ELF (over 
jtag); now that it boots from flash, it'll accept a new version of 
itself via XMODEM and run that happily.  (Whew, my Windows box is now 
unnecessary!)

I don't know if anyone's interested in trying it out or using it;  I'd 
be grateful for any comments, suggestions or code contributions!  It's 
not really there yet - well, XMODEM works for me but probably won't for 
anyone else =]  That's next on my list.

-Matt

ps:  Here are the supported commands, from its help text:
Help (commands are case-sensitive):
         h/?                             - This help
         dump <m|fd> <addr> <len>        - Hexdump RAM or flash
         crc <addr> <len>                - CRC32 memory
         get <addr> <len>                - XMODEM download from RAM
         put <addr>                      - XMODEM upload to RAM
         flashwr <flash offset> <len> <ram address>
                                         - Write RAM data into flash 
device
         flashrd <flash offset> <len> <ram address>
                                         - Copy flash data into RAM
         listdevs                        - List flash devices
         go <addr>                       - Jump to address
         r{b|w} <addr>                   - Read byte/word
         w{b|w} <addr> <data>            - Write byte/word
         fill <addr> <len> <byte>        - Fill memory
         lcd <string>                    - Write string to LCD console
  [ fd above is a flash device ID, 0 = internal, 1 = external etc., as 
listed in listdevs ]
  [      All numbers/addresses/offsets are hexadecimal - zero padding is 
unnecessary      ]

pps: Any better names..?

---

From: Adam Coventry <[email-masked]>
Date: Wed, 25 May 2005 19:00:44 +0100 (BST)

Hi

I have been lurking here for a little while and
finally  bought an E2 from ebay about a month ago
(followed by a much cheaper one from a car boot
sale!).

I was very happy when I got pblq to work with my level
shifter but unfortunately lost my splash screen (no
big deal) when I tried out the Hello World example.

Tonight I thought I'd try the monitor program because
I liked the idea of browsing the NAND 'live' rather
than downloading.

Unfortunately, on downloading my monitor.pbl using
pblq it looks as if my pbl has been trashed i.e. the
E2 boots straight into the monitor's LCD debug console
without the flashing lights of the pbl.
Incidentally, I used "pblq writeflash monitor.pbl 0".

So:
is this a one-way trip for this E2 i.e. Monitor-only -
no pbl possible, or is there some other path?
(I mean via the ext port rather than JTAG)

Another mistake was that my 115200 is a little flaky
and I meant to see if I could drop the monitor
terminal speed a little before loading it. I guess its
all good experience!

NB: still one untouched E2 to play with!

Adam.

> (the README from the tar is also at 
http://www.axio.ms/projects/e2/e2-monitor-0.22-README
> )
> 
> 
> _______________________________________________
> e3-hacking mailing list
> [email-masked]
>
http://www.earth.li/cgi-bin/mailman/listinfo/e3-hacking

___________________________________________________________ 
How much free photo storage do you get? Store your holiday 
snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com

---

From: Matt Evans <[email-masked]>
Date: Wed, 25 May 2005 19:19:43 +0100

Evening Adam,

> big deal) when I tried out the Hello World example.

Hello welcome!

> no pbl possible, or is there some other path?

:-)  That's what's supposed to happen.  (It sounds like you see the 
monitor message on the LCD, right?  And you get serial port output?)  I 
think there's some confusion about what PBL is.  There are two flash 
chips; one is a NOR flash chip of 64K in which PBL lives.  The other is 
an 8MB NAND flash chip that PBL then accesses and loads the main OS 
from (including the splash screen).  The splash screen is the first 
chunk in the NAND flash, offset zero.  The rest of the OS appears to 
live +1MB into the NAND, and the splash screen 'chains' onto the rest.  
i.e. the boot sequence is:

1. CPU starts at phys addr. 0 where NOR flash is mapped, & executes PBL.
2. PBL trawls the NAND flash and finds a valid bootable block at 0.  
(This is the splashscreen (or helloWorld, or monitor))
3. The block, the splashscreen, is loaded to RAM and executed and then 
either it or PBL loads the next block in flash (the machine OS).

So what you have done is replaced the splash screen with the monitor 
code; the machine boots and runs the monitor straight off instead of 
the splash screen and the rest of the OS.  I'm not sure if I understand 
your question correctly - are you wondering whether it will 
'dual-boot', i.e. if the monitor can then boot the main Amstrad OS?  No 
is the short answer - though it ought to be possible.

When you say "no pbl possible" what do you mean?  PBL is still there - 
it's what boots the monitor from NAND.  If you want the splash screen 
back you could reflash the first 2 blocks (16K) of NAND with the blocks 
you backed up with pblq before reflashing ;-)

> terminal speed a little before loading it.

Ahhh yep; well, you can download a replacement monitor into the monitor 
you've already got running (if your serial is reliable enough to do 
so).  Edit uart.S:uart_init, there's a comment for some other baud rate 
divisors.  You can "put 100000" to XMODEM the resulting (blessed) 
'monitor.pbl' into RAM, and then "flashwr 0 4000 100000" to reflash 
over itself.

Glad to hear you got it working thus far, though!  I've a newer version 
of the monitor I'll upload tonight.

-Matt

---

From: Adam Coventry <[email-masked]>
Date: Fri, 27 May 2005 08:02:03 +0100 (BST)

OK - panic over.

I had assumed the rapid light flashing was driven by
an active pbl and that the absence of those lights
meant that I had somehow trashed pbl.  I assume what
actually happens is that the lights flash as pbl scans
the NAND for headers.  Since the monitor was loaded
into address 0 and did not chain other blocks there
was no searching to do and therefore no reassuring
light show.

I _did_ manage to interrupt my (failed?) monitor
program with pblq and reloaded a 57600 version (to
overcome my flaky serial).  Now I am presented with a
proper monitor prompt, and all is well!

Thanks for the great work you guys are doing - I don't
mind hanging on to your coat tails!

Adam.

--- Matt Evans <[email-masked]> wrote:
[deleted - I don't know if etiquette demands I leave
the original text, but I worry about bandwidth ;-)]

Adam Coventry
BSc.  MCP
[email-masked]

___________________________________________________________ 
Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com

---

From: Matt Evans <[email-masked]>
Date: Fri, 27 May 2005 11:44:13 +0100

Hi Adam,

> was no searching to do and therefore no reassuring

Ah yes, I think that's what happens.  (Or, it's flashing when it's 
loading the first splashscreen thing - which is much larger.  Maybe it 
currently does flash but only once, really quickly, so you don't see it 
or something... my E2 is out of the case so I don't have LEDs wired 
up.)

> proper monitor prompt, and all is well!

Good stuff!  I forgot to upload the other night, but there's a new 
version of the monitor that you may find more useful:

http://www.axio.ms/projects/e2/e2-monitor-0.24-README
..contained in..
http://www.axio.ms/projects/e2/e2-monitor-0.24.tgz

This version boots other stuff from flash (so is actually useful (he 
says - my biggest test program so far splats a big image on the 
screen...)).  The XMODEM stuff should be slightly more 
resilient/well-behaved but still isn't perfect.

Cheers,

Matt