Commit ae3b5b55 authored by Benoit Rat's avatar Benoit Rat

usb-loader: Dirty and magical fix to make work the DDR with v3.1

parent c8827958
......@@ -303,8 +303,6 @@ int samba_connect(int board_rev)
int tstart,i,length,npages;
int c;
serial_write(handshake,3);
sys_delay(100);
......@@ -314,22 +312,28 @@ int samba_connect(int board_rev)
if(board_rev == BOARD_REV_V2 && id != ID_SAM9263) die ("Not a 9263 CPU");
if(board_rev == BOARD_REV_V3 && id != ID_SAM9G45) die ("Not a 9G45 CPU");
}
int ddr_init(int board_rev, int NR)
{
if(board_rev == BOARD_REV_V2)
samba_load_applet("isp-extram-at91sam9263", INTERNAL_SRAM_BUF);
else if(board_rev == BOARD_REV_V3)
samba_load_applet("isp-extram-at91sam9g45", INTERNAL_SRAM_BUF);
else if(board_rev == BOARD_REV_V3)
{
if(NR==14) samba_load_applet("isp-extram-at91sam9g45-NR14", INTERNAL_SRAM_BUF);
else samba_load_applet("isp-extram-at91sam9g45-NR13", INTERNAL_SRAM_BUF);
}
mbox_write(INTERNAL_SRAM_BUF, MBOX_COMMAND, APPLET_CMD_INIT);
mbox_write(INTERNAL_SRAM_BUF, MBOX_TRACELEVEL, 0);
mbox_write(INTERNAL_SRAM_BUF, MBOX_EXTRAM_RAMTYPE, 1);
mbox_write(INTERNAL_SRAM_BUF, MBOX_EXTRAM_VDDMEM, 0);
mbox_write(INTERNAL_SRAM_BUF, MBOX_EXTRAM_BUSWIDTH, 16);
mbox_write(INTERNAL_SRAM_BUF, MBOX_EXTRAM_DDRMODEL, 0);
samba_run(INTERNAL_SRAM_BUF, 100000000);
if((samba_read(INTERNAL_SRAM_BUF + MBOX_COMMAND, 4, 10000000)) != ~APPLET_CMD_INIT) die("invalid response from applet init");
if((samba_read(INTERNAL_SRAM_BUF + MBOX_STATUS, 4, 10000000)) != APPLET_SUCCESS) die("invalid response from applet status");
return 0;
......@@ -439,6 +443,14 @@ main(int argc, char *argv[])
serial_open(serial_port, PORT_SPEED);
fprintf(stderr,"Initializing SAM-BA: ");
samba_connect(board_rev);
fprintf(stderr,"Initializing DDR...\n\n");
ddr_init(board_rev,14);
sys_delay(100);
fprintf(stderr,"Initializing DDR...\n\n");
ddr_init(board_rev,13);
fprintf(stderr,"Checking DDR...\n\n");
ddr_check(board_rev);
......@@ -446,14 +458,14 @@ main(int argc, char *argv[])
fprintf(stderr,"Initializing DataFlash...\n\n");
dataflash_init(board_rev);
//fprintf(stderr,"Erasing DataFlash...\n\n");
//dataflash_erase_all();
fprintf(stderr,"Erasing DataFlash...\n\n");
dataflash_erase_all();
fprintf(stderr,"Programming DataFlash...\n");
dataflash_program(argv[1]);
printf("Programming done!\n");
serial_close();
serial_close();
return 0;
}
......@@ -32,6 +32,13 @@ compile_module()
CROSS_COMPILE=/opt/wrs/misc/cd-g++lite/bin/arm-none-eabi-
root="$(dirname $(pwd)/$0)"
#### Check compiler
if [[ -z $(${CROSS_COMPILE}gcc --version | grep "Sourcery G++ Lite 2008q3-39") ]]; then
echo "You should use Sourcery G++ Lite 2008q3-39 to compile samba-applets"
echo "see reference: http://www.at91.com/forum/viewtopic.php/f,8/t,5352/"
exit 1;
fi
#### Compilation of dataflash module
compile_module dataflash $1
......@@ -44,7 +51,6 @@ DEFINES="-DAT91C_DDRC2_NR_XX=AT91C_DDRC2_NR_14"
compile_module extram $1
cp ${root}/../isp-extram-at91sam9g45.bin ${root}/../isp-extram-at91sam9g45-NR14.bin
DEFINES="-DAT91C_DDRC2_NR_XX=$1"
#### Compilation of extern ram module
compile_module extram
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment