NIOS2: Added DE2 board with SD support
PATCH 1/1 NIOS2: Added DE2 board with SD support
Hi list,
I wrote about my work with u-boot in the thread "[U-Boot] DE2 board with MMC interface (PIO based) and FAT support enabled" and i decided to post a patch. I would like to discuss the changes.
I have changed the Makefile to match the binutils provided by Altera and i added the DE2 board.
I have also made changes to the files cmd_mem.c to add one more command "dmmc". Because the SD card is not a memory mapped device in the bus like a flash memory, we can't deduce the direction of data (i mean when copying data to sd or from sd) with the function mmc2info(). I tried to solve this trick by using the command dmmc.
I found problems at link level with cmd_mmc.o and cmd_mem.o because both files includes mmc.h, then i have two copies of the same functions in both objects files. I solved this problem by declaring extern the function mmc_init in cmd_mmc.c.
I think i should post the file include/asm-nios2/arch-nios2/mmc.h and the board related files but i will wait your response.
In include/asm-nios2/arch-nios2/mmc.h i implemented mmc_get_dev() and mmc_read_block() to provide access to the FAT table.
The code is working with all the examples distributed by Altera in the DE2 board and it should work with any SD socket interfaced by PIO cores.
Makefile +4 -1
@@ -163,7 +163,7 @@ ifeq ($(ARCH),nios) CROSS_COMPILE = nios-elf- endif ifeq ($(ARCH),nios2) -CROSS_COMPILE = nios2-elf- +CROSS_COMPILE = nios2-linux- endif ifeq ($(ARCH),m68k) CROSS_COMPILE = m68k-elf-
@@ -3137,6 +3137,9 @@ PK1C20_config : unconfig PCI5441_config : unconfig @$(MKCONFIG) PCI5441 nios2 nios2 pci5441 psyent +DE2_config : unconfig + @$(MKCONFIG) DE2 nios2 nios2 de2 altera + #======================================================================== ## Microblaze #========================================================================
common/cmd_mem.c +1 -0
@@ -53,6 +53,7 @@ uint dp_last_length = 0x40;uint mm_last_addr, mm_last_size;static ulong base_address =0 ; +static ulong mmc_direction =0 ;/* Memory Display *
@@ -355,6 +356,17 @@ int do_mem_cmp (cmd_tbl_t *cmdtp, int flag, int argc,
char *argv[])
return rcode;
}
+int do_dmmc( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{
+ if (argc > 1)
+ mmc_direction = simple_strtoul(argv[1], NULL, 10);
+ if (mmc_direction)
+ printf("Mem to mmc\n");
+ else
+ printf("Mmc to mem\n");
+ return 0;
+}
+
int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
ulong addr, dest, count;@@ -405,7 +417,7 @@ int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
#endif
#if defined(CONFIG_CMD_MMC)
- if (mmc2info(dest)) {
+ if (mmc_direction) {
int rc;
puts ("Copy to MMC... ");
@@ -422,9 +434,7 @@ int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc,
char *argv[])
}
puts ("done\n");
return 0;
- }
-
- if (mmc2info(addr)) {
+ } else {
int rc;
puts ("Copy from MMC... ");@@ -1221,6 +1231,14 @@ U_BOOT_CMD(
"[.b, .w, .l] address value [count]\n - write memory\n"
);
+#if defined(CONFIG_CMD_MMC)
+U_BOOT_CMD(
+ dmmc, 2, 1, do_dmmc, + "dmmc - set mmc-memory copy direction\n", + "direction\n - copy mmc<->mem\n"
+);
+#endif
+
U_BOOT_CMD(
cp, 4, 1, do_mem_cp,
"cp - memory copy\n",
common/cmd_mmc.c +2 -1
@@ -23,7 +23,8 @@#include <common.h> #include <command.h> -#include <mmc.h> + +extern int mmc_init (int );int do_mmc (cmd_tbl_t *cmdtp,int flag,int argc,char *argv[]) {
@@ -31,6 +32,7 @@ int do_mmc (cmd_tbl_t *cmdtp, int flag, int argc, char
*argv[])
printf ("No MMC card found\n");
return 1;
}
+ printf ("MMC card found\n");
return 0;}
PATCH 1/1 NIOS2: Added DE2 board with SD support
Patch is rejected -- incomplete.
Ivan,
Contact me off-list ... we can discuss how to proceed.
Regards,
--Scott
Quoted 144 lines · ivanchuklist ivanchu
Hi list,
I wrote about my work with u-boot in the thread "[U-Boot] DE2 board with MMC interface (PIO based) and FAT support enabled" and i decided to post a patch. I would like to discuss the changes.
I have changed theMakefileto match the binutils provided by Altera and i added the DE2 board.
I have also made changes to the filescmd_mem.cto add one more command "dmmc". Because the SD card is not a memory mapped device in the bus like a flash memory, we can't deduce the direction of data (i mean when copying data to sd or from sd) with the functionmmc2info(). I tried to solve this trick by using the command dmmc.
I found problems at link level with cmd_mmc.o and cmd_mem.o because both files includesmmc.h, then i have two copies of the same functions in both objects files. I solved this problem by declaring extern the functionmmc_initincmd_mmc.c.
I think i should post the fileinclude/asm-nios2/arch-nios2/mmc.hand the board related files but i will wait your response.
Ininclude/asm-nios2/arch-nios2/mmc.hi implementedmmc_get_dev()andmmc_read_block()to provide access to the FAT table.
The code is working with all the examples distributed by Altera in the DE2 board and it should work with any SD socket interfaced by PIO cores.Makefile +4
-1@@ -163,7 +163,7 @@ ifeq ($(ARCH),nios) CROSS_COMPILE = nios-elf- endif ifeq ($(ARCH),nios2) -CROSS_COMPILE = nios2-elf- +CROSS_COMPILE = nios2-linux- endif ifeq ($(ARCH),m68k) CROSS_COMPILE = m68k-elf-@@ -3137,6 +3137,9 @@ PK1C20_config : unconfig PCI5441_config : unconfig @$(MKCONFIG) PCI5441 nios2 nios2 pci5441 psyent +DE2_config : unconfig + @$(MKCONFIG) DE2 nios2 nios2 de2 altera + #======================================================================== ## Microblaze #========================================================================common/cmd_mem.c +12
-0@@ -53,6 +53,7 @@ uint dp_last_length = 0x40;uint mm_last_addr, mm_last_size;static ulong base_address =0 ; +static ulong mmc_direction =0 ;/* Memory Display * @@ -355,6 +356,17 @@ int do_mem_cmp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])return rcode; } +int do_dmmc (cmd_tbl_t *cmdtp,int flag,int argc,char *argv[]) +{ +if (argc >1 ) + mmc_direction =simple_strtoul (argv[1 ],NULL ,10 ); +if (mmc_direction) +printf ("Mem to mmc\n" ); +else +printf ("Mmc to mem\n" ); +return 0 ; +} +int do_mem_cp (cmd_tbl_t *cmdtp,int flag,int argc,char *argv[]) {ulong addr, dest, count;common/cmd_mem.c +1
-1@@ -405,7 +417,7 @@ int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])#endif #if defined(CONFIG_CMD_MMC ) -if (mmc2info (dest)) { +if (mmc_direction) {int rc;puts ("Copy to MMC... ");common/cmd_mem.c +1
-3@@ -422,9 +434,7 @@ int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) }puts ("done\n" );return 0 ; - } - -if (mmc2info (addr)) { + }else {int rc;puts ("Copy from MMC... ");common/cmd_mem.c +8
-0@@ -1221,6 +1231,14 @@ U_BOOT_CMD("[.b, .w, .l] address value [count]\n - write memory\n" ); +#if defined(CONFIG_CMD_MMC ) +U_BOOT_CMD ( + dmmc,2 ,1 , do_dmmc, +"dmmc - set mmc-memory copy direction\n" , +"direction\n - copy mmc<->mem\n" +); +#endif + U_BOOT_CMD( cp, 4, 1, do_mem_cp, "cp - memory copy\n",common/cmd_mmc.c +3
-2@@ -23,7 +23,8 @@#include <common.h> #include <command.h> -#include <mmc.h> + +extern int mmc_init (int );int do_mmc (cmd_tbl_t *cmdtp,int flag,int argc,char *argv[]) {@@ -31,6 +32,7 @@ int do_mmc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) printf ("No MMC card found\n");return 1 ; } +printf ("MMC card found\n" );return 0 ; } ------------------------------------------------------------------------_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot