[Aesop-embedded-devel] u-boot-aesop/board/aesop2440 README.txt aesop2440.c config.mk sd.c
Status: Beta
Brought to you by:
linuxpark
|
From: linux4go <lin...@li...> - 2005-07-07 15:47:07
|
linux4go 2005/07/07 08:47:01
Modified: board/aesop2440 aesop2440.c config.mk sd.c
Added: board/aesop2440 README.txt
Log:
Revision Changes Path
1.3 +12 -9 u-boot-aesop/board/aesop2440/aesop2440.c
Index: aesop2440.c
===================================================================
RCS file: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/aesop2440.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- aesop2440.c 5 Jul 2005 14:16:41 -0000 1.2
+++ aesop2440.c 7 Jul 2005 15:46:59 -0000 1.3
@@ -27,8 +27,11 @@
* Created date : 2005. 06. 26. 22:56:57 KST
* Description :
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
* $Log: aesop2440.c,v $
+ * Revision 1.3 2005/07/07 15:46:59 linux4go
+ * *** empty log message ***
+ *
* Revision 1.2 2005/07/05 14:16:41 jeenspa
* usbdmass fixup, nand, mkyaffs
*
@@ -38,7 +41,7 @@
*
*
*/
-#ident "@(*) $Header: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/aesop2440.c,v 1.2 2005/07/05 14:16:41 jeenspa Exp $"
+#ident "@(*) $Header: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/aesop2440.c,v 1.3 2005/07/07 15:46:59 linux4go Exp $"
#include <common.h>
#include <s3c2440.h>
@@ -107,6 +110,7 @@
int usbdmass(char *);
int do_bmpload_sub(unsigned char *, int, int, int);
+extern unsigned int SD_card_init(void);
/* ------------------------------------------------------------------------- */
void init_lcd(void)
{
@@ -259,10 +263,10 @@
return 0;
}
-#if 0
+#if 1
unsigned char scratch[4096]; // buffer for SD read/write
unsigned int scratch1[4096]; // buffer for SD read/write
-void SD_FS(void) // Check Partition table
+int SD_FS(void) // Check Partition table
{
int MBR_exist;
int i;
@@ -282,12 +286,12 @@
if(MBR_exist) printf("(with MBR)\n\n");
else printf("(without MBR)\n\n");
-
- for (i = 0; i < 512; i++) {
+#if 0
+ for (i = 0; i < 512; i++) {
if (!(i % 16)) printf("\n%04x : ", i);
printf("%02x ", scratch[i]);
}
-#if 0
+
for(i=0;i<1024;i++) scratch1[i]=i;
SD_Write((unsigned char *)scratch1, 300000 , 8);
@@ -305,14 +309,13 @@
{
init_lcd();
-#if 0
if(!SD_card_init())
return 0; // No SD/MMC found !!
else
{
SD_FS(); // Check Master boot record !!
}
-#endif
+
return 1;
}
1.3 +8 -3 u-boot-aesop/board/aesop2440/config.mk
Index: config.mk
===================================================================
RCS file: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/config.mk,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- config.mk 5 Jul 2005 14:16:41 -0000 1.2
+++ config.mk 7 Jul 2005 15:46:59 -0000 1.3
@@ -28,8 +28,11 @@
# Created date : 2005. 06. 26. 22:59:04 KST
# Description :
#
-# $Revision: 1.2 $
+# $Revision: 1.3 $
# $Log: config.mk,v $
+# Revision 1.3 2005/07/07 15:46:59 linux4go
+# *** empty log message ***
+#
# Revision 1.2 2005/07/05 14:16:41 jeenspa
# usbdmass fixup, nand, mkyaffs
#
@@ -39,7 +42,7 @@
#
#
#
-#ident "@(#) $Header: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/config.mk,v 1.2 2005/07/05 14:16:41 jeenspa Exp $"
+#ident "@(#) $Header: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/config.mk,v 1.3 2005/07/07 15:46:59 linux4go Exp $"
#
@@ -71,6 +74,8 @@
# LCD framebuffer address: 0x33000000(48M offset)
# ramdisk optionally with a ramdisk at 3080'0000
# parameter tag: 0x30000100
+# For ROM writing
TEXT_BASE = 0x33C00000
-
+# For debugging
+# TEXT_BASE = 0x33800000
1.2 +123 -9 u-boot-aesop/board/aesop2440/sd.c
Index: sd.c
===================================================================
RCS file: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/sd.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sd.c 27 Jun 2005 17:03:53 -0000 1.1
+++ sd.c 7 Jul 2005 15:46:59 -0000 1.2
@@ -27,15 +27,18 @@
* Created date : 2005. 06. 26. 23:05:59 KST
* Description :
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
* $Log: sd.c,v $
- * Revision 1.1 2005/06/27 17:03:53 linuxpark
- * Initial revision
+ * Revision 1.2 2005/07/07 15:46:59 linux4go
+ * *** empty log message ***
+ *
+ * Revision 1.1.1.1 2005/06/27 17:03:53 linuxpark
+ * Initial import.
*
*
*
*/
-#ident "@(*) $Header: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/sd.c,v 1.1 2005/06/27 17:03:53 linuxpark Exp $"
+#ident "@(*) $Header: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/sd.c,v 1.2 2005/07/07 15:46:59 linux4go Exp $"
/*
@@ -63,9 +66,23 @@
#include <common.h>
#include <s3c2440.h>
-
+#include <part.h>
#if 1
+
+
+extern int
+fat_register_device(block_dev_desc_t *dev_desc, int part_no);
+
+static block_dev_desc_t mmc_dev;
+
+block_dev_desc_t * mmc_get_dev(int dev)
+{
+ return ((block_dev_desc_t *)&mmc_dev);
+}
+
+
+//#if 1
int isMMC; // 1:MMC, 0:SD
int RCA=0; // Relative card address
@@ -129,8 +146,10 @@
{
finish0=sdi->SDICSTA;
while((finish0&0x800) != 0x800) // Check cmd end
+ {
finish0=sdi->SDICSTA;
+ }
sdi->SDICSTA=finish0;// Clear cmd end state
return 1;
@@ -235,13 +254,14 @@
return 1;
}
+CSD_regs csd;
int CMD9(void)//SEND_CSD
{
S3C2410_SDI * const sdi = S3C2410_GetBase_SDI();
unsigned char buff[16];
// unsigned long card_size;
- CSD_regs csd;
+
sdi->SDICARG=RCA<<16; // CMD9(RCA,stuff bit)
sdi->SDICCON=(0x1<<10)|(0x1<<9)|(0x1<<8)|0x49; // long_resp, wait_resp, start, CMD9
@@ -411,11 +431,63 @@
}
}
+void SD_Read(unsigned char * pucdata, unsigned long ulLBA, unsigned long ulSectors);
+void SD_Write(unsigned char * pucdata, unsigned long ulLBA, unsigned long ulSectors);
+unsigned int SD_card_init(void);
+
+ulong mmc_bread(int dev_num, ulong blknr, ulong blkcnt, ulong *dst)
+{
+// int mmc_block_size = MMC_BLOCK_SIZE;
+// ulong src = blknr * mmc_block_size + CFG_MMC_BASE;
+
+ if(blkcnt==0)
+ {
+ printf("Why block_cnt == 0?? \n");
+ return 0;
+ }
+// mmc_read(src, (uchar *)dst, blkcnt*mmc_block_size);
+// printf("mmc_bread LBA=%d, Count=%d\n",blknr,blkcnt);
+ SD_Read((uchar *)dst, blknr, blkcnt);
+// printf("mmc_bread end\n");
+ return blkcnt;
+}
+
+int mmc_write(uchar *src, ulong dst, int size)
+{
+ printf("\nmmc_write should not be called !!!!\n");
+ //SD_Write(
+}
+
+
+int mmc_read(ulong src, uchar *dst, int size)
+{
+ printf("\nmmc_read should not be called !!!!\n");
+ //SD_Write(
+}
#define INICLK 400000
#define SDCLK 25000000
#define MMCCLK 15000000
+int mmc_init_once = 0;
+
+int mmc_init(int verbose)
+{
+ SD_card_init();
+ return 0;
+}
+
+#define CFG_MMC_BASE 0
+int mmc2info(ulong addr)
+{
+ /* FIXME hard codes to 32 MB device */
+ if (addr >= CFG_MMC_BASE && addr < CFG_MMC_BASE + (CardSize/512))
+ {
+ return 1;
+ }
+ return 0;
+}
+
unsigned int SD_card_init(void)
{
@@ -423,6 +495,10 @@
unsigned long pclk;
S3C2410_SDI * const sdi = S3C2410_GetBase_SDI();
+ if(mmc_init_once==1) return 1;// already done !!
+
+
+
pclk = get_PCLK();
//printf("\nSystem Frequency is %dHz\n",pclk);
@@ -492,6 +568,7 @@
RCA=( sdi->SDIRSP0 & 0xffff0000 )>>16;
//printf("RCA=0x%x\n",RCA);
sdi->SDIPRE=pclk/(SDCLK); // Salamander pclk=66Mhz, prescaler = 2, SD_CLK = 22Mhz
+ //sdi->SDIPRE=3; // test 16Mhz
//printf("SD Frequency is %dMHz\n",(pclk/(sdi->SDIPRE+1))/1000000);
}
//--State(stand-by) check
@@ -520,18 +597,54 @@
Card_sel_desel(1); // Select
- return CardSize;
+ {
+ /* fill in device description */
+ mmc_dev.if_type = IF_TYPE_MMC;
+ mmc_dev.dev = 0;
+ mmc_dev.lun = 0;
+ mmc_dev.type = 0;
+ /* FIXME fill in the correct size (is set to 32MByte) */
+ mmc_dev.blksz = 512;
+ //mmc_dev.lba = 0x10000;
+ mmc_dev.lba = CardSize / 512;
+ mmc_dev.part_type = PART_TYPE_DOS;
+ /*
+ sprintf(mmc_dev.vendor,"Man %02x%02x%02x Snr %02x%02x%02x",
+ cid->id[0], cid->id[1], cid->id[2],
+ cid->sn[0], cid->sn[1], cid->sn[2]);
+ sprintf(mmc_dev.product,"%s",cid->name);
+ sprintf(mmc_dev.revision,"%x %x",cid->hwrev, cid->fwrev);
+ */
+
+ sprintf(mmc_dev.vendor,"Man aESOP1 Snr 123456");
+ sprintf(mmc_dev.product,"%s","SDxxxMB");
+ sprintf(mmc_dev.revision,"%x %x",0x123,0x456);
+
+ mmc_dev.removable = 0;
+ mmc_dev.block_read = mmc_bread;
+
+ fat_register_device(&mmc_dev,1); /* partitions start counting with 1 */
+
+ }
+ mmc_init_once = 1;
+ return 1;
}
+
+unsigned int *Rx_buffer1; //128[word]*16[blk]=8192[byte]
void SD_Read(unsigned char * pucdata, unsigned long ulLBA, unsigned long ulSectors)
{
S3C2410_SDI * const sdi = S3C2410_GetBase_SDI();
- int status, state, rd_cnt;
+ int status, state, rd_cnt, total_word;
+
+ //unsigned int *Rx_buffer1; //128[word]*16[blk]=8192[byte]
- unsigned int *Rx_buffer1; //128[word]*16[blk]=8192[byte]
+// unsigned int *Rx_buffer1; //128[word]*16[blk]=8192[byte]
Rx_buffer1 = (unsigned int *)(pucdata);
+// printf("Rx_buffer1 = 0x%x\n",Rx_buffer1);
+
rd_cnt=0;
sdi->SDIFSTA = sdi->SDIFSTA|(1<<16); // FIFO reset
@@ -559,7 +672,8 @@
sdi->SDICSTA = state; // Clear cmd_end(with rsp)
//printf("\n Read CMD end\n");
- while(rd_cnt < (128*ulSectors)) // 512*block bytes
+ total_word = 128*ulSectors;
+ while(rd_cnt < total_word) // 512*block bytes
{
state = sdi->SDIDSTA;
if((state&0x20)==0x20) // Check timeout
1.1 u-boot-aesop/board/aesop2440/README.txt
Index: README.txt
===================================================================
======================================================================
Changes for U-Boot 1.1.2 for aESOP-2440
======================================================================
* Add SD-card initialize/read/write by Salamander, 19 Jun 2005
- Fix SDIDAT register bug (8bit -> 32bit) in /include/s3c24x0.h
- Add sd.c & sd.h in /board/aesop2440
- Modify aesop2440.c to show SDcard status
* USB mass storage class interface to SD-card by jeenspa(6-July-2005)
* Linux booting from NAND flash file system(yaffs) by jeenspa(6-July-2005).
* DOS-FAT file I/O for SD-card by Salamander(8-July-2005)
======================================================================
To Do list
======================================================================
* LCD_printf() function implementaion for SD-file list show.
* Key input function for file select and execute.
* Unicode display for VFAT file name.
* Linux booting from SD file system.
======================================================================
Tips
======================================================================
* Temporary modification of config.mk should be applied for debugging.
- If TEXT_BASE is 0x33C00000 in NOR-flash U-boot, change it to 0x33800000.
- With this temporary change, you can download u-boot via TFTP for development.
* How to change spalsh logo
- prepare a 480x272 24bpp bmp file(true color bitmap file without palette)
- convert bmp to simple C header file (ex. xxd -i logo01.bmp > aesop-logo-02.h)
- compile and enjoy your own splash screen.
|