📄 norloader.cmm
字号:
;T32 Wed Jan 06 12:32:10 1999
&FLASH_START=0xbfc00000
&FLASH_SIZE=200000
&FLASH_SECTOR_SIZE=2000
&FLASH_END=&FLASH_START+&FLASH_SIZE-1
&FLASH_TYPE="AM29F100"
&BUS_WIDTH="WORD"
D.S 0xb1000220 %LONG 0x81 0 0 0xa 0x1f 0xa 0x5
;-----------------------------
; declar global variables
;-------------------------------
global &addr_from &addr_to &sel &instr
;
winclear
area
gosub create_flash
while 1==1
(
print "==========================="
print "== FLASH Programming =="
print "==========================="
print "Address Range: " &FLASH_START "--" &FLASH_END
print "Flash Type: " "&FLASH_TYPE"
print "Flash Size: " &FLASH_SIZE
print "Sector Size: " &FLASH_SECTOR_SIZE
print "Bus Width: " "&BUS_WIDTH"
print "--------------------------"
print "0. Branch to romInit"
print "1. Setup Flash parameter"
print "2. Erase Bootrom Flash memory"
print "3. Erase Loader Flash memory"
print "4. Erase NVRAM"
print "5. Program Flash with Loader file"
print "8. Branch to self"
print "-----------------"
print "9. Quit"
print ""
print "Enter Selection: "
enter &sel
if "&sel"=="0"
gosub BranchRomInit
if "&sel"=="1"
gosub CreateFlash
if "&sel"=="2"
gosub EraseBootrom
if "&sel"=="3"
gosub EraseLoader
if "&sel"=="4"
gosub EraseNV
if "&sel"=="5"
gosub ProgFile
if "&sel"=="8"
gosub BranchSelf
if "&sel"=="9"
goto flash_end
)
BranchRomInit:
flash.erase 00000000--00001000
d.s 0x0 %B 0xf0
d.s 0x5555 %B 0xaa
d.s 0x2aaa %B 0x55
d.s 0x5555 %B 0xa0
d.s 0x0 %B 0xfe
d.s 0x5555 %B 0xaa
d.s 0x2aaa %B 0x55
d.s 0x5555 %B 0xa0
d.s 0x1 %B 0x17
d.s 0x5555 %B 0xaa
d.s 0x2aaa %B 0x55
d.s 0x5555 %B 0xa0
d.s 0x2 %B 0x00
d.s 0x5555 %B 0xaa
d.s 0x2aaa %B 0x55
d.s 0x5555 %B 0xa0
d.s 0x3 %B 0xea
d.s 0x3 %B 0xf0
return
BranchSelf:
flash.erase 00000000--00001000
d.s 0x0 %B 0xf0
d.s 0x5555 %B 0xaa
d.s 0x2aaa %B 0x55
d.s 0x5555 %B 0xa0
d.s 0x0 %B 0xfe
d.s 0x5555 %B 0xaa
d.s 0x2aaa %B 0x55
d.s 0x5555 %B 0xa0
d.s 0x3 %B 0xea
d.s 0x3 %B 0xf0
return
flash_end:
; flash.res
print "===================="
print "Finished ...."
print ""
end
CreateFlash:
&sel="0"
while "&sel"<>"q"
(
print "****** FLASH Create ******"
print "Please enter the following data to create Flash"
print "Flash start address (" &FLASH_START "): "
enter &value
if "&value"<>""
&FLASH_START=&value
print "Flash size (" &FLASH_SIZE "): "
enter &value
if "&value"<>""
&FLASH_SIZE=&value
print "Flash Type(&FLASH_TYPE): "
enter &value
if "&value"<>""
&FLASH_TYPE=&value
print "Flash Sector Size(" &FLASH_SECTOR_SIZE "): "
enter &value
if "&value"<>""
&FLASH_SECTOR_SIZE=&value
print "Bus With (Byte, Word, Long): "
enter &value
if "&value"<>""
&BUS_WIDTH=&value
print "================="
print "Sector Size = " &FLASH_SECTOR_SIZE
print "flash.creat " &FLASH_START "--" &FLASH_START+&FLASH_SIZE-1 " &FLASH_TYPE" " &BUS_WIDTH"
print "Process the command ? <Y/N/Quit>"
enter &sel
if "&sel"=="Y"
&sel="y"
if "&sel"=="Q"
&sel="q"
if "&sel"=="y"
(
gosub create_flash
&sel="q"
)
)
return
;--------------------
; Erase NV flash
;--------------------
EraseNV:
flash.erase 00004000--00006000
flash.erase 00006000--00008000
return
;--------------------
; Erase Runtime flash
;--------------------
EraseLoader:
&from= &FLASH_START
&to= &from+0010000
§or_size=&FLASH_SECTOR_SIZE
while &from<&to
(
&erase_to=&from+§or_size-1
print "Erasing flash: " &from " -- " &erase_to
flash.erase &from--&erase_to
&from=&from+§or_size
)
return
;--------------------
; Erase bootrom flash
;--------------------
EraseBootrom:
; print "****** Erase All Flash Sectors ******"
; print "This command will erase all data sectors in Flash"
; print "All data in flash memory will be lost"
; print "Are you sure <y/n> ?"
; enter &sel
; if "&sel"=="Y"
; &sel="y"
; if "&sel"=="y"
; (
; gosub erase_flash &FLASH_START &FLASH_END &FLASH_SECTOR_SIZE
; )
; flash.program 1
&from=00010000
&to=00020000
§or_size=&FLASH_SECTOR_SIZE
while &from<&to
(
&erase_to=&from+§or_size-1
print "Erasing flash: " &from " -- " &erase_to
flash.erase &from--&erase_to
&from=&from+§or_size
)
;flash.program
return
EnterRange:
while 1==1
(
print "Enter start address: "
enter &addr_from
print "Enter end address: "
enter &addr_to
print "Address range: " &addr_from " -- " &addr_to
print "Is that right <y/n/q> ? "
enter &sel
if "&sel"=="Y"
&sel="y"
if "&sel"=="Q"
&sel="q"
if "&sel"=="q"
return
if "&sel"=="y"
return
)
return
EraseFlash:
local &erase_from &erase_to
print "****** Erase Flash Sectors ******"
print "This command will erase some sectors in Flash"
print "Data in flash memory will be lost"
gosub EnterRange
if "&sel"=="y"
(
gosub erase_flash &addr_from &addr_to &FLASH_SECTOR_SIZE
)
return
; gosub EraseFlash 3000000 300ffff
gosub ProgFlash
FillFlash:
print "***** Fill Data ********"
gosub EnterRange
if "&sel"<>"y"
return
print "Enter the data to fill: "
enter &fill_value
print "Fill address: " &addr_from "--" &addr_to " with " &fill_value
print "Is that Right <y/n> ?"
enter &sel
if "&sel"=="Y"
&sel="y"
if "&sel"<>"y"
return
gosub erase_flash &addr_from &addr_to &FLASH_SECTOR_SIZE
&count=&FLASH_SECTOR_SIZE
flash.program all
while &addr_from<&addr_to
(
if &count>=&FLASH_SECTOR_SIZE
(
&count=&addr_from+&FLASH_SECTOR_SIZE-1
print "Programming " &addr_from "--" &count " with " &fill_value
&count=0
)
d.s &addr_from %l &fill_value
&addr_from=&addr_from+4
&count=&count+4
)
flash.program off
print "finished..."
return
read_mem:
return d.i 0
ProgFile:
print "***** Programming Flash with object file ******"
print "Make sure you have erased all flash sectors to program"
; print "Enter the command and file to load"
; print "Such as: data.load.binary rom.bin "
; print "Command: "
; enter &sel
; if "&sel"==""
; return
; &cmd="&sel"
; print "file name:"
; enter &sel
; &cmd="&cmd"+" &sel"
; print "start address:"
; enter &sel
; &cmd="&cmd"+" &sel"
; if "&cmd"<>""
; (
; print "Loading file..."
; &cmd
; print "Finished..."
; )
print "Loading file..."
flash.program all
data.load.binary D:\TEMP\adm5120\bin\eb\NOR_FLASH\norloader.img &FLASH_START
flash.program off
print "Finished..."
; local &src_addr
; local &dst_addr
; local &size
; local &count
; local &i_data
; local &i
; print "Enter file dir/name: "
; enter &f_name
; &f_name="c:\tornado\target\config\morpheusBSP\bootrom.bin"
; print "Enter file size(hex): "
; enter &size
; &src_addr=0x1000000
; &dst_addr=0x0
; &count=0
; &i=1
; d.load.binary &f_name 0x1000000
;
; flash.program all
;
; print "Programming flash"
; while &count<&size
; (
; &i_data= Data.Word(d:&src_addr)
; d.s &dst_addr %W &i_data
; &src_addr=&src_addr+2
; &dst_addr=&dst_addr+2
;
; if &count==&i*100
; (
; print "Programed " &count "bytes"
; &i=&i+1
; )
;
; &count=&count+2
; )
return
ProgFlash:
print "***** Programming Flash sectors ********"
gosub EnterRange
if "&sel"<>"y"
return
gosub erase_flash &addr_from &addr_to &FLASH_SECTOR_SIZE
print "programming flash: " &addr_from "--" &addr_to
&count=&FLASH_SECTOR_SIZE
flash.program all
while &addr_from<&addr_to
(
if &count>=&FLASH_SECTOR_SIZE
(
&count=&addr_from+&FLASH_SECTOR_SIZE-1
print "Programming " &addr_from "--" &count
&count=0
)
d.s &addr_from %l &addr_from
&addr_from=&addr_from+4
&count=&count+4
)
flash.program off
print "finished..."
return
;------------------------------------
; Flash Memory operation Routines
;------------------------------------
create_flash:
print "--- Setting Flash ---"
&FLASH_END=&FLASH_START+&FLASH_SIZE-1
flash.res
flash.create &FLASH_START--&FLASH_END &FLASH_TYPE &BUS_WIDTH
print "Setup finished !!"
return
;-----------------------------
;--------------------
; ERASE Flash Memory
;--------------------
erase_flash:
entry &from &to §or_size
local &erase_to
flash.program all
while &from<&to
(
&erase_to=&from+§or_size-1
print "Erasing flash: " &from " -- " &erase_to
flash.erase &from--&erase_to
&from=&from+§or_size
)
flash.program off
print "finished ..."
return
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -