!
rem 
rem  NAND flash programming include file
rem 
rem --------------------
rem Init system register
rem --------------------
rem init mpmc
long 0xb1000000  0x01
long 0xb1000200  0x80
long 0xb1000220  0x81
rem enable nand flash
long 0xb2000064  0x100
long 0xb2000008  0x1
      
$port=0xb0000000
$page=0
loop
rem -----------------------
rem  page write cycle
rem -----------------------
rem  deassert WP# Write protect
outport $port+0xa  0x1
rem  deassert SP#
outport $port+0x8  0x1
rem  assert CE#
outport $port+0x1  0x1
rem  assert CLE
outport $port+0x4  0x1
rem  Issue input data command
outport $port  0x80
rem  deassert CLE
outport $port+0x3  0x1
rem  assert ALE
outport $port+0x6  0x1
rem  Issue start address
outport $port  0x0 
outport $port  $page 
outport $port  0x0  
rem  deassert ALE
outport $port+0x5  0x1 
rem page data
watch "$page*0x200"
outport $port "e:\loader.img" $page*0x200 0x200 -B

rem assert SE#
outport $port+0x7  0x1
rem spare area (16 outports)
outport $port  0x00 0xe0 0x80 0x40 0x00 0xe8 0x80 0x40 0x00 0x80 0x08 0x3c 0x0f 0x00 0x00 0x12 

rem  assert CLE
outport $port+0x4  0x1
rem  Issue page program command
outport $port  0x10
rem  deassert CLE
outport $port+0x3  0x1
pause 1
rem  deassert CE#
outport $port+0x2  0x1
rem Assert WP# Write protect
outport $port+0x9  0x1
pause 1
$page=$page+1
loopend 15

!



