; -------------------------------------------------------------------------------- ; @Title: eMMC FLASH Programming Script for AM3715 ; @Description: ; eMMC FLASH(Numonyx, NAND16GXH) is connected ; ; Internal SRAM: 0x40200000 ; ; SD/MMC Controller Register : 0x4809C100 ; ; @Author: jjeong ; @Copyright: (C) 1989-2022 Lauterbach GmbH, licensed for use with TRACE32(R) only ; @Chip: AM3715 ; @Keywords: Numonyx NAND16GXH flash eMMC ; -------------------------------------------------------------------------------- ; $Id: am3715-emmc.cmm 10516 2022-02-02 11:39:30Z bschroefel $ LOCAL &arg1 ENTRY &arg1 &arg1=STRing.UPpeR("&arg1") // for example "PREPAREONLY" &MMC_BASE=0x4809C100 PRINT "initializing..." SYStem.CPU AM3715 SYStem.JtagClock 1Mhz ; start with a fix JTAG clock, ; otherwise every second system.up fails with an RTCK error SYStem.Option DACR ON ; give Debugger global write permissions SYStem.Option ResBreak OFF ; hardware dependent (see manual) SYStem.Option WaitReset ON ; hardware dependent (see manual) TrOnchip.Set DABORT OFF ; used by Linux for page miss! TrOnchip.Set PABORT OFF ; used by Linux for page miss! TrOnchip.Set UNDEF OFF ; my be used by Linux for FPU detection SYStem.Option MMUSpaces OFF ; enable space ids to virtual addresses SYStem.Up SYStem.JtagClock RTCK ; switch to RTCK mode, after initialization SETUP.IMASKASM ON ; lock interrupts while single stepping ; Target Setup: initialize DRAM controller and peripherals ; Either let the boot monitor setup the board Go.direct PRINT "target setup..." WAIT 200.ms Break.direct IF STATE.RUN() Break.direct PER.Set.simple C15:0x1 %Long (Data.Long(C15:0x1)&~(0x1005)) ; disable MMU and cache Data.Set 0x4809C12C %Long 0x000E3C07 Data.Set 0x4809C134 %Long 0x307f0033 ; enable the BRR bit GOSUB disable_watchdog GOSUB READ_ID_TEST FLASHFILE.RESet //FLASHFILE.CONFIG 0x0 0x0 FLASHFILE.CONFIG 0x4809C100 0x0 0x0 //FLASHFILE.target FLASHFILE.TARGET 0x40200000++0x1FFF 0x40204000++0x1FFF ~~/demo/arm/flash/byte/emmc_omap.bin Data.Set 0x4809C12C %Long 0x000E3C07 ; 400Khz , the Card identification mode //Read FLASH Manufacture and Device ID FLASHFILE.GETID Data.Set 0x4809C12C %Long 0x000E0807 ; higher clock speed for the Data transfer mode FLASHFILE.GETEXTCSD //End of the test prepareonly IF "&arg1"=="PREPAREONLY" ENDDO ;FLASHFILE.DUMP 0x0 ; Read eMMC ;FLASHFILE.ERASE 0x0--0xFFFFF ; Erase eMMC ;FLASHFILE.LOAD * 0x0 ; Write eMMC ENDDO disable_watchdog: ; Enable Interface Clock Data.Set 0x48004C10 %Long 0x20 ; Enable functional clock Data.Set 0x48004C00 %Long 0x20 ; Check that module is IDLE WAIT (Data.Long(SD:0x48004C20)&0x20)==0 ; Disable watchdog timer Data.Set SD:0x48314048 %Long 0x0000AAAA WAIT (Data.Long(SD:0x48314034)&0x10)==0 Data.Set SD:0x48314048 %Long 0x00005555 WAIT (Data.Long(SD:0x48314034)&0x10)==0 ; Check if the watchdog timer is running IF (Data.Long(SD:0x48314048)!=0x00005555) ( ; Disable Watchdog 2 ; Wait until reset complete WAIT (Data.Long(SD:0x48314014)&0x01)!=0 ; Disable 32Khz watchdog timer Data.Set 0x48314048 %Long 0x0000AAAA WAIT (Data.Long(SD:0x48314034)&0x10)==0 ; Disable 32Khz watchdog timer Data.Set 0x48314048 %Long 0x00005555 WAIT (Data.Long(SD:0x48314034)&0x10)==0 ) RETURN READ_ID_TEST: //MMC interface, not SD(HC) //CMD0 RePeaT 2. ( Data.Set &MMC_BASE+0x30 %Long 0xFFFFFFFF ;clear status Data.Set &MMC_BASE+0x8 %Long 0x0 ;arg Data.Set &MMC_BASE+0xc %Long 0x0 ;cmd WAIT 10.ms ) //CMD1 RePeaT 10. ( Data.Set &MMC_BASE+0x30 %Long 0xFFFFFFFF ;clear status Data.Set &MMC_BASE+0x8 %Long 0x40FF8000 ;arg Data.Set &MMC_BASE+0xc %Long 0x01020000 ;cmd1 WAIT 100.ms &resp=Data.Long(A:(&MMC_BASE+0x10)) //print "CMD1 resp: 0x" &resp IF (&resp&0x80000000)==0x80000000 ( GOTO jump_cmd2 ) ) PRINT "CMD1 fail" END jump_cmd2: //CMD2 Data.Set &MMC_BASE+0x30 %Long 0xFFFFFFFF ;clear status Data.Set &MMC_BASE+0x8 %Long 0x0 ;arg Data.Set &MMC_BASE+0xc %Long 0x02010000 ;cmd2 WAIT 10.ms //CMD3 Data.Set &MMC_BASE+0x30 %Long 0xFFFFFFFF ;clear status Data.Set &MMC_BASE+0x8 %Long 0x00010000 ; arg, MMC RCA is (0x0001<<16.) Data.Set &MMC_BASE+0xc %Long 0x03020000 ;cmd3 WAIT 10.ms //CMD10 Data.Set &MMC_BASE+0x30 %Long 0xFFFFFFFF ;clear status Data.Set &MMC_BASE+0x8 %Long 0x00010000 ; arg, MMC RCA is (0x0001<<16.) Data.Set &MMC_BASE+0xc %Long 0x0A010000 ;cmd10 WAIT 10.ms //Response2 PRINT "CID register" PRINT "[127:104] 0x" Data.Long(A:(&MMC_BASE+0x1c)) PRINT "[103:72] 0x" Data.Long(A:(&MMC_BASE+0x18)) PRINT "[71:40] 0x" Data.Long(A:(&MMC_BASE+0x14)) PRINT "[39:8] 0x" Data.Long(A:(&MMC_BASE+0x10)) RETURN