Files
Gen4_R-Car_Trace32/2_Trunk/demo/arm/flash/pmb8876-nand1216.cmm
2025-10-14 09:52:32 +09:00

148 lines
5.0 KiB
Plaintext

; --------------------------------------------------------------------------------
; @Title: PMB8876 NAND FLASH Programming Script
; @Description:
; FLASH Type: NAND FLASH(SAMSUNG, k9k1216L)
;
; S(D)RAM Address : 0x00010000
; Command Register : 0xA0040000
; AddRESets Register : 0xA0020000
; Data(IO) Register : 0xA0000000
;
; @Author: jjeong
; @Chip: PMB8876
; @Keywords: SAMSUNG k9k1216L
; @Copyright: (C) 1989-2022 Lauterbach GmbH, licensed for use with TRACE32(R) only
; --------------------------------------------------------------------------------
; $Id: pmb8876-nand1216.cmm 10516 2022-02-02 11:39:30Z bschroefel $
LOCAL &arg1
ENTRY &arg1
&arg1=STRing.UPpeR("&arg1") // for example "PREPAREONLY"
//SYStem Configuration
SYStem.RESet
SYStem.CONFIG.IRPOST 8.
SYStem.CONFIG.DRPOST 1.
SYStem.CONFIG.TriState OFF
SYStem.CONFIG.Slave OFF
SYStem.CONFIG.TCKLevel 0.
SYStem.CPU PMB8876
SYStem.JtagClock RTCK
INIT_DEBUGHW:
; --------------------------------------------------------------------------------
; debugger specific initialization
; --------------------------------------------------------------------------------
SETUP.Var %Fixed %Compact %TREE %Hex %Decimal %SpotLight.on
SYStem.Down
SYStem.Up
; --------------------------------------------------------------------------------
; Target & Board specific initialization
; --------------------------------------------------------------------------------
GOSUB disable_watchdog
; disable ROM
Data.Set D:0xF440007C %Long 0x0
; --------------------------------------------------------------------------------
; set CLKCTRL
; --------------------------------------------------------------------------------
; initialize all clocks to 26MHz > Clock Configuration 1 in STD_CGUinit
Data.Set 0xf45000a8 %Word 0x0 ;CGU_CTL4 to 0 > all master clocks 26 MHz
Data.Set 0xf45000ac %Word 0x0 ;CGU_CTL5 to 0 > all master clocks 26 MHz
Data.Set 0xf45000a0 %Word 0x01070000 ;CGU_CTL1 to 0x01070000 > all master clocks 26 MHz, PLLOFF, Phaseshifters on
; --------------------------------------------------------------------------------
; set EBU
; --------------------------------------------------------------------------------
; settings for EBU region 0, Nand Flash Memory Device, Read Only starting from 0xA0000000h
Data.Set 0xf0000080 %Long 0xA0000031 ;ADDRSEL0 to 0xA0000031
Data.Set 0xf00000c0 %Long 0x00604790 ;BUSCON0 to 0x00604790
Data.Set 0xf0000100 %Long 0xD6D2C702 ;BUSAP0 to 0xD6D2C702
Data.Set 0xf0000020 %Long 0x001001d0 ;BFCON to 0x001001d0 > all master clocks 26 MHz, PLLOFF, Phaseshifters on
; settings for EBU region 1, SDRAM Memory Device, Rd/Wr starting at 0x20000000h
Data.Set 0xf0000088 %Long 0x20000021
Data.Set 0xf00000c8 %Long 0x30700200
Data.Set 0xf0000050 %Long 0x01146073
Data.Set 0xf0000040 %Long 0x00000010
Data.Set 0xf0000060 %Long 0x00000020
; settings for EBU region 2, SDRAM Memory Device, Rd/Wr starting at 0x22000000h
Data.Set 0xf0000090 %Long 0x22000021
Data.Set 0xf00000d0 %Long 0x40700200
Data.Set 0xf0000058 %Long 0x01146073
Data.Set 0xf0000048 %Long 0x00000010
Data.Set 0xf0000068 %Long 0x00000020
; Get NAND Flash Id for Samsung K9K1216Q0C (GS511V10)
Data.Set 0xA0040000 %Word 0x90 ; command
Data.Set 0xA0020000 %Word 0x0 ; addRESets
; Write Protection disable
Data.Set 0xf4300000 %Long 0x100
Data.Set 0xf4300108 %Long 0x700
Break.RESetet
FLASHFILE.RESetet
//FLASHFILE.config <Cmd_reg> <Addr_reg> <Data_reg>
FLASHFILE.CONFIG 0xA0040000 0xA0020000 0xA0000000
//FLASHFILE.target <Code_range> <Data_range> <Algorithm file>
FLASHFILE.TARGET 0x00010000++0x1FFF 0x00012000++0x1FFF ~~/demo/arm/flash/word/nand1216l.bin
//Read FLASH Manufacture and Device ID
FLASHFILE.GETID
//End of the test prepareonly
IF "&arg1"=="PREPAREONLY"
ENDDO
//Put a list of bad blocks into area window
FLASHFILE.GETBADBLOCK 0x0--0x3FFFFFF
DIALOG.YESNO "Program flash memory?"
ENTRY &progflash
IF &progflash
(
//Unlock NAND FLASH
FLASHFILE.UNLOCK 0x0--0x3FFFFFF
//Erase NAND FLASH Main and Bad block inforamtion
FLASHFILE.Erase 0x0--0x3FFFFFF /EraseBadBlocks
//Skipped way
FLASHFILE.LOAD.binary * 0x0
;FLASHFILE.LOADSPARE * 0x0
//RESeterved block area way
;FLASHFILE.LOAD * 0x0 /WriteBadBlocks
;FLASHFILE.LOADSPARE * 0x0 /WriteBadBlocks
)
ENDDO
disable_watchdog:
;BEFORE BOOTCODE:
;
Data.Set 0xf4400024 0xFFFC00F0; Clear Endinit Bit; Password access
Data.Set 0xf4400024 0xFFFC00F2; Modify access
Data.Set 0xf4400028 0x00000008; Set WDT Disable Request Bit
Data.Set 0xf4400024 0xFFFC00F8; Set Endinit Bit Password access
Data.Set 0xf4400024 0xFFFC00F3; Modify access
;
;AFTER BOOTCODE:
;
;Data.Set 0xf4400024 0xED6C00F1; Clear Endinit Bit; Password access
;Data.Set 0xf4400024 0xED6C00F2; Modify access
;Data.Set 0xf4400028 0x00000008; Set WDT Disable Request Bit
;Data.Set 0xf4400024 0xED6C00F8; Set Endinit Bit Password access
;Data.Set 0xf4400024 0xED6C00F3; Modify access
RETURN