Andrea Gasparini wrote:
> I'm trying to compile fw_{print,save}env from uboot-1.2.0 for 
> dm355 environment.
> I got a lot of errors for (imho) broken include directives.
> 
> fw_env has a bug,and erroneusly includes <linux/mtd/mtd.h>, 
> while it should include <mtd/mtd-user.h>.

I got this working just the other day :)

In thanks for your u-boot patch, here are the mods you need for
fw_printenv:

1. change #include as you say
2. change "TOOLSUBDIRS =" in /tools/Makefile to "TOOLSUBDIRS = env"
3. change writes to be page-aligned for NAND flash, existing code writes
   CRC and data separately.

Here is a patch that implements 1 and 3, hope it is readable, it's my
first patch file :)

--- fw_env.c.orig       Fri Nov 28 15:22:23 2008
+++ fw_env.c            Wed Nov 26 15:28:17 2008
@@ -31,7 +31,8 @@
 #include <sys/ioctl.h>
 #include <sys/stat.h>
 #include <unistd.h>
-#include <linux/mtd/mtd.h>
+#include <mtd/mtd-user.h>
+//#include <linux/mtd/mtd.h>
 #include "fw_env.h"
 
 typedef unsigned char uchar;
@@ -389,6 +390,8 @@
        int fd, fdr, rc, otherdev, len, resid;
        erase_info_t erase;
        char *data = NULL;
+       int  writesz;
+       char *writebuf = NULL;
 
        if ((fd = open (DEVNAME (curdev), mode)) < 0) {
                fprintf (stderr,
@@ -468,6 +471,28 @@
 
                printf ("Done\n");
 
+               /* Have to write NAND page-aligned, write crc and data
together */
+               writesz = len + ENV_SIZE;
+               writebuf = malloc(writesz);
+               memcpy(writebuf, &environment, len);
+               memcpy(writebuf + len, environment.data, ENV_SIZE);
+               
+               printf("Write CRC + environment (%d bytes) to %s\n",
writesz,
+                          DEVNAME (otherdev));
+
+               if (lseek (fdr, DEVOFFSET (otherdev), SEEK_SET) == -1) {
+                       fprintf (stderr,
+                               "seek error on %s: %s\n",
+                               DEVNAME (otherdev), strerror (errno));
+                       return (-1);
+               }
+               if (write (fdr, writebuf, writesz) != writesz) {
+                       fprintf (stderr,
+                               "write error on %s: %s\n",
+                               DEVNAME (otherdev), strerror (errno));
+                       return (-1);
+               }
+#if 0
                printf ("Writing environment to %s...\n", DEVNAME
(otherdev));
                if (lseek (fdr, DEVOFFSET (otherdev), SEEK_SET) == -1) {
                        fprintf (stderr,
@@ -487,6 +512,7 @@
                                DEVNAME (otherdev), strerror (errno));
                        return (-1);
                }
+#endif
                if (resid) {
                        if (write (fdr, data, resid) != resid) {
                                fprintf (stderr,

--
Jon Povey, Design Engineer
[EMAIL PROTECTED] | +44(0)1280 825983  

 
Racelogic is a limited company registered in England. Registered number 2743719 
. 
Registered Office Unit 10, Swan Business Centre, Osier Way, Buckingham, Bucks, 
MK18 1TB .
The information contained in this electronic mail transmission is intended by 
Racelogic Ltd for the use of the named individual or entity to which it is 
directed and may contain information that is confidential or privileged. If you 
have received this electronic mail transmission in error, please delete it from 
your system without copying or forwarding it, and notify the sender of the 
error by reply email so that the sender's address records can be corrected. The 
views expressed by the sender of this communication do not necessarily 
represent those of Racelogic Ltd. Please note that Racelogic reserves the right 
to monitor e-mail communications passing through its network

_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to