Skip to content

Commit

Permalink
first working version of the flash loader.. its buggy, but it works. …
Browse files Browse the repository at this point in the history
…clean up the code on next commit, just uploading current kinda working version for now
  • Loading branch information
ingeniously.stupid@gmail.com committed Mar 19, 2013
1 parent c3e6eb1 commit 030ee61
Show file tree
Hide file tree
Showing 9 changed files with 367 additions and 305 deletions.
2 changes: 1 addition & 1 deletion XenoFlash/Makefile
Expand Up @@ -33,7 +33,7 @@ LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -logc -lm
LIBS := -logc -lm -lz

#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
Expand Down
Binary file modified XenoFlash/data/XenoAT.bin
Binary file not shown.
Binary file not shown.
Binary file not shown.
45 changes: 45 additions & 0 deletions XenoFlash/flashloader/Makefile
@@ -0,0 +1,45 @@
############################################################################################################
############################################################################################################
# Makefile - Flashloader.bin LINUX
############################################################################################################
############################################################################################################

# TARGET = Target File to Compile
# MNDIR = Path to MN10200 ELF
# MNDIR1 = Path to MN10200 Binutils
# MNDIR2 = Path to MN10200 Binutils ELF


TARGET = flashloader

MNDIR = /opt/XenoTools/mn10200/bin
MNDIR1 = /opt/XenoTools/mn10200_binutils/bin
MNDIR2 = /opt/XenoTools/mn10200_binutils-elf/bin

GCC = $(MNDIR)/mn10200-elf-gcc
AS = $(MNDIR1)/mn10200-as
LD = $(MNDIR1)/mn10200-ld
OBJCOPY = $(MNDIR2)/mn10200-elf-objcopy

############################################################################################################
# Build rules
all: clean $(TARGET).bin move

move:
cp flashloader.bin ../data/flashloader.bin

clean:
rm -rf ../data/flashloader.bin
rm -rf flashloader.bin
rm -rf flashloader.elf
rm -rf flashloader.o

flashloader.o: flashloader.S
$(AS) -L flashloader.S -o flashloader.o

flashloader.elf: flashloader.o
$(LD) -Ttext 0x40D000 --section-start absolute=0x00 -O $(GCC) flashloader.o -o flashloader.elf

flashloader.bin: flashloader.elf
$(OBJCOPY) -O binary flashloader.elf flashloader.bin

35 changes: 17 additions & 18 deletions XenoFlash/flashloader/QLite.h
Expand Up @@ -16,39 +16,38 @@
#------------------------------------------------------------------------------------------
# Read ahead dma buffer addresses
#------------------------------------------------------------------------------------------
.equ LBA_READAHEAD_BUFFER, 0x417100
.equ LBA0, LBA_READAHEAD_BUFFER + (0x810 * 0)
.equ LBA4, LBA_READAHEAD_BUFFER + (0x810 * 4)
.equ LBA7, LBA_READAHEAD_BUFFER + (0x810 * 7)
.equ LBA_APPL, LBA4 + 0x440
.equ LBA_APPL_EPVEC, LBA_APPL + 0x12
.equ LBA_APPL_SIZE, LBA_APPL + 0x16
.equ LBA_APPL_CODE, LBA_APPL + 0x20
.equ LBA_READAHEAD_BUFFER, 0x417100
.equ LBA0, LBA_READAHEAD_BUFFER + (0x810 * 0)
.equ LBA4, LBA_READAHEAD_BUFFER + (0x810 * 4)
.equ LBA7, LBA_READAHEAD_BUFFER + (0x810 * 7)
.equ LBA_APPL, LBA4 + 0x440
.equ LBA_APPL_EPVEC, LBA_APPL + 0x12
.equ LBA_APPL_SIZE, LBA_APPL + 0x16
.equ LBA_APPL_CODE, LBA_APPL + 0x20


#------------------------------------------------------------------------------------------
# firmware fixed addresses
#------------------------------------------------------------------------------------------
.equ FwIrqVec, 0x804c
.equ FwIrqDepth, 0x805b
.equ FwData1, 0x008000
.equ FwData1_Size, 0x6e
.equ FwBSS, 0x00806e
.equ FwInitDrive, 0x0808aa
.equ FwIntHandler, 0x80a74
.equ FwHLECmdBuffer, 0x40ebe6
.equ FwIrqVec, 0x804c
.equ FwIrqDepth, 0x805b
.equ FwData1, 0x008000
.equ FwData1_Size, 0x6e
.equ FwBSS, 0x00806e
.equ FwInitDrive, 0x0808aa
.equ FwIntHandler, 0x80a74
.equ FwHLECmdBuffer, 0x40ebe6

#------------------------------------------------------------------------------------------
# firmware version addresses
#------------------------------------------------------------------------------------------

/* macro already defined? --infact
.macro IMM24Bit Addr
.byte (\Addr & 0xFF)
.byte (\Addr >> 8 & 0xFF)
.byte (\Addr >> 16 & 0xFF)
.endm
*/

.macro FwAddrImp16 Name P1, P2, P3
X\Name:
IMM24Bit \P1
Expand Down
52 changes: 46 additions & 6 deletions XenoFlash/source/dvd.c
Expand Up @@ -5,6 +5,7 @@ volatile long *dvd = (volatile long *) 0xCC006000;
void DVD_CallFunc(u32 fnAddress)
{
dvd[0] = 0x14; //DEINT clr, TCINT clr
// dvd[0] = 0x2e;
dvd[1] = 0;
dvd[2] = 0xFE120000;
dvd[3] = fnAddress;
Expand All @@ -29,7 +30,7 @@ int DVD_WaitImmediate()

int DVD_CustomDbgCommand(u32 dwCommand, u32 dwOffset, u32 dwLength, u32* pBuffer)
{
dvd[0] = 0x2e;
dvd[0] = 0x10;//2e;
dvd[1] = 0;
dvd[2] = dwCommand;
dvd[3] = dwOffset;
Expand All @@ -50,6 +51,7 @@ int DVD_CustomDbgCommand(u32 dwCommand, u32 dwOffset, u32 dwLength, u32* pBuffer
u32 DVD_ReadDriveMemDword(u32 dwAddress)
{
dvd[0] = 0x14;
// dvd[0] = 0x2e;
dvd[1] = 0;
dvd[2] = 0xFE010000;
dvd[3] = dwAddress;
Expand Down Expand Up @@ -110,17 +112,38 @@ int DVD_SetDebugMode2()
return 0;
}


void dvd_unlock()
{

dvd[0] |= 0x00000014;
dvd[1] = 0;
dvd[2] = 0xFF014D41;
dvd[3] = 0x54534849;
dvd[4] = 0x54410200;
dvd[7] = 1;
while ((dvd[0] & 0x14) == 0) { }
dvd[0] |= 0x00000014;
dvd[1] = 0;
dvd[2] = 0xFF004456;
dvd[3] = 0x442D4741;
dvd[4] = 0x4D450300;
dvd[7] = 1;
while ((dvd[0] & 0x14) == 0) { }
}

int DVD_SetDebugMode()
{
DVD_SetDebugMode1();
DVD_SetDebugMode2();

//dvd_unlock();

return 0;
}

int DVD_WriteDriveMemDword(u32 dwAddress, u32 dwData)
{
// int nCount = 0;
int nCount = 0;

dvd[0] = 0x2e;
dvd[1] = 0;
Expand All @@ -134,6 +157,7 @@ int DVD_WriteDriveMemDword(u32 dwAddress, u32 dwData)

DVD_WaitImmediate();


dvd[0] = 0x2e;
dvd[1] = 0;
dvd[2] = dwData;
Expand All @@ -144,17 +168,33 @@ int DVD_WriteDriveMemDword(u32 dwAddress, u32 dwData)
return 0;
}


int DVD_WriteDriveMemBlock(u32 dwAddress, void* pData, u32 dwSize)
{
u32* pSource = (u32*)pData;
// u32 dwDest = dwAddress;
u32 dwDest = dwAddress;
int nLeft = dwSize;

while (nLeft > 0)
{
DVD_WriteDriveMemDword(dwAddress, *pSource++);
dwAddress += 4;
DVD_WriteDriveMemDword(dwDest, *pSource++);//(dwAddress, *pSource++);
dwDest += 4;
nLeft -= 4;
}
return 0;
}

int DVD_ReadDriveMemBlock(u32 dwAddress, void* pData, u32 dwSize)
{
u32* pSource = (u32 *) pData;
u32 dwDest = dwAddress;
int nLeft = dwSize;

while(nLeft > 0) {
*pSource++ = DVD_ReadDriveMemDword(dwDest);//(dwAddress);
// dwAddress += 4;
dwDest += 4;
nLeft -= 4;
}
return 0;
}
4 changes: 4 additions & 0 deletions XenoFlash/source/dvd.h
Expand Up @@ -43,3 +43,7 @@ int DVD_WaitImmediate();
int DVD_WriteDriveMemBlock(u32 dwAddress, void* pData, u32 dwSize);

int DVD_WriteDriveMemDword(u32 dwAddress, u32 dwData);

int DVD_ReadDriveMemBlock(u32 dwAddress, void* pData, u32 dwSize);

void dvd_unlock();

0 comments on commit 030ee61

Please sign in to comment.