* Failing to load Barebox Environment @ 2010-09-29 6:50 Gaurav Singh 2010-09-29 7:29 ` Juergen Beisert 2010-09-29 7:48 ` Sascha Hauer 0 siblings, 2 replies; 11+ messages in thread From: Gaurav Singh @ 2010-09-29 6:50 UTC (permalink / raw) To: barebox Hi all, Currently I'm trying to load a barebox environment image from NAND storage but can't load it correctly. I have given the path of my environment in the config : CONFIG_CONSOLE_FULL=y CONFIG_CONSOLE_ACTIVATE_FIRST=y # CONFIG_OF_FLAT_TREE is not set CONFIG_PARTITION=y CONFIG_DEFAULT_ENVIRONMENT=y CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/cartesio-evb2065/env/bin" After registering the NAND device I prepared a couple of Bad Block aware partitions : devfs_add_partition("nand0", 0x00000, 0x200000, PARTITION_FIXED, "self_raw"); dev_add_bb_dev("self_raw", "self0"); devfs_add_partition("nand0", 0x200000, 0x200000, PARTITION_FIXED, "env_raw"); dev_add_bb_dev("env_raw", "env0"); On compilation I get a barebox environment image - barebox_default_env. Flashed this image to the env0 partition via DFU - dfu -V 1 -P 24 /dev/env0 From host sent the barebox_default_env (the default_env file is page alinged) via DFU to the NAND. The flashing worked fine. But now when I re-boot the system : barebox 2010.09.0-00003-ge5727b1-dirty (Sep 27 2010 - 17:18:50) Board: STMicroelectronics EVB2065 with Cartesio Plus NAND device: Manufacturer ID: 0x2c, Chip ID: 0x48 (Micron NAND 2GiB 3,3V 8-bit) Scanning device for bad blocks Malloc space: 0x00860000 -> 0x00e60000 (size 6 MB) Stack space : 0x00850000 -> 0x00858000 (size 32 kB) This system is stuck at this point. Investigating further - I see that we are stuck at in the common/environment.c int envfs_load(char *filename, char *dir) { ... buf = xmalloc(size); buf_free = buf; ret = read(envfd, buf, size); - Stuck here I'm wondering why this read is failing. Could the developers shed some light on this ? Regards Gaurav _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Failing to load Barebox Environment 2010-09-29 6:50 Failing to load Barebox Environment Gaurav Singh @ 2010-09-29 7:29 ` Juergen Beisert 2010-09-29 7:48 ` Sascha Hauer 1 sibling, 0 replies; 11+ messages in thread From: Juergen Beisert @ 2010-09-29 7:29 UTC (permalink / raw) To: barebox Gaurav Singh wrote: > Hi all, > Currently I'm trying to load a barebox environment image from NAND > storage but can't load it correctly. > > I have given the path of my environment in the config : > > CONFIG_CONSOLE_FULL=y > CONFIG_CONSOLE_ACTIVATE_FIRST=y > # CONFIG_OF_FLAT_TREE is not set > CONFIG_PARTITION=y > CONFIG_DEFAULT_ENVIRONMENT=y > CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/cartesio-evb2065/env/bin" > > After registering the NAND device I prepared a couple of Bad Block > aware partitions : > > devfs_add_partition("nand0", 0x00000, 0x200000, PARTITION_FIXED, > "self_raw"); dev_add_bb_dev("self_raw", "self0"); > devfs_add_partition("nand0", 0x200000, 0x200000, PARTITION_FIXED, > "env_raw"); dev_add_bb_dev("env_raw", "env0"); > > On compilation I get a barebox environment image - barebox_default_env. > Flashed this image to the env0 partition via DFU - > dfu -V 1 -P 24 /dev/env0 > > From host sent the barebox_default_env (the default_env file is page > alinged) via DFU to the NAND. > > The flashing worked fine. > > But now when I re-boot the system : > > barebox 2010.09.0-00003-ge5727b1-dirty (Sep 27 2010 - 17:18:50) > > Board: STMicroelectronics EVB2065 with Cartesio Plus > NAND device: Manufacturer ID: 0x2c, Chip ID: 0x48 (Micron NAND 2GiB 3,3V > 8-bit) Scanning device for bad blocks > Malloc space: 0x00860000 -> 0x00e60000 (size 6 MB) > Stack space : 0x00850000 -> 0x00858000 (size 32 kB) > > > This system is stuck at this point. Investigating further - I see that > we are stuck at > in the common/environment.c > int envfs_load(char *filename, char *dir) > { > ... > buf = xmalloc(size); > buf_free = buf; > ret = read(envfd, buf, size); - Stuck here > > I'm wondering why this read is failing. Could the developers shed some > light on this ? Only some ideas: Reading data from NAND really works? When this kind of trouble hits me last time, my memory map was broken (some data transfers ruins the stack content) and the system runs amok. jbe -- Pengutronix e.K. | Juergen Beisert | Linux Solutions for Science and Industry | Phone: +49-8766-939 228 | Vertretung Sued/Muenchen, Germany | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de/ | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Failing to load Barebox Environment 2010-09-29 6:50 Failing to load Barebox Environment Gaurav Singh 2010-09-29 7:29 ` Juergen Beisert @ 2010-09-29 7:48 ` Sascha Hauer 2010-09-29 9:01 ` Gaurav Singh 1 sibling, 1 reply; 11+ messages in thread From: Sascha Hauer @ 2010-09-29 7:48 UTC (permalink / raw) To: Gaurav Singh; +Cc: barebox Hi Gaurav, On Wed, Sep 29, 2010 at 12:20:20PM +0530, Gaurav Singh wrote: > Hi all, > Currently I'm trying to load a barebox environment image from NAND > storage but can't load it correctly. > > I have given the path of my environment in the config : > > CONFIG_CONSOLE_FULL=y > CONFIG_CONSOLE_ACTIVATE_FIRST=y > # CONFIG_OF_FLAT_TREE is not set > CONFIG_PARTITION=y > CONFIG_DEFAULT_ENVIRONMENT=y > CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/cartesio-evb2065/env/bin" > > After registering the NAND device I prepared a couple of Bad Block > aware partitions : > > devfs_add_partition("nand0", 0x00000, 0x200000, PARTITION_FIXED, "self_raw"); > dev_add_bb_dev("self_raw", "self0"); > devfs_add_partition("nand0", 0x200000, 0x200000, PARTITION_FIXED, "env_raw"); > dev_add_bb_dev("env_raw", "env0"); > > On compilation I get a barebox environment image - barebox_default_env. > Flashed this image to the env0 partition via DFU - > dfu -V 1 -P 24 /dev/env0 Have you tried doing a cp /dev/env0 /somefile at this point? Have you erased /dev/env0 before doing the dfu command? > > From host sent the barebox_default_env (the default_env file is page > alinged) via DFU to the NAND. > > The flashing worked fine. > > But now when I re-boot the system : > > barebox 2010.09.0-00003-ge5727b1-dirty (Sep 27 2010 - 17:18:50) > > Board: STMicroelectronics EVB2065 with Cartesio Plus > NAND device: Manufacturer ID: 0x2c, Chip ID: 0x48 (Micron NAND 2GiB 3,3V 8-bit) > Scanning device for bad blocks > Malloc space: 0x00860000 -> 0x00e60000 (size 6 MB) > Stack space : 0x00850000 -> 0x00858000 (size 32 kB) > > > This system is stuck at this point. Investigating further - I see that > we are stuck at > in the common/environment.c > int envfs_load(char *filename, char *dir) > { > ... > buf = xmalloc(size); > buf_free = buf; > ret = read(envfd, buf, size); - Stuck here > > I'm wondering why this read is failing. Could the developers shed some > light on this ? Can you confirm that the read ends in your nand driver? Does your nand driver work properly? Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Failing to load Barebox Environment 2010-09-29 7:48 ` Sascha Hauer @ 2010-09-29 9:01 ` Gaurav Singh 2010-09-29 9:08 ` Juergen Beisert 0 siblings, 1 reply; 11+ messages in thread From: Gaurav Singh @ 2010-09-29 9:01 UTC (permalink / raw) To: Sascha Hauer; +Cc: barebox Sascha, > Can you confirm that the read ends in your nand driver? Does your nand > driver work properly? I can confirm the NAND driver is working fine in other circumstances. I have flashed a kernel zimage to NAND using DFU (at the kernel partition). Copied this zimage to RAM and booted it using bootz. LOG for Kernel booting : barebox 2010.09.0-00003-ge5727b1-dirty (Sep 27 2010 - 17:18:50) Board: STMicroelectronics EVB2065 with Cartesio Plus NAND device: Manufacturer ID: 0x2c, Chip ID: 0x48 (Micron NAND 2GiB 3,3V 8-bit) Scanning device for bad blocks Malloc space: 0x00860000 -> 0x00e60000 (size 6 MB) Stack space : 0x02000000 -> 0x02400000 (size 4 MB) Open /dev/env0 error 2 no valid environment found on /dev/env0. Using default environment Open /dev/defaultenv error 2 running /env/bin/init... not found EVB2065> ls . .. dev EVB2065> EVB2065> erase /dev/nand0 EVB2065> addpart /dev/nand0 4M(barebox)ro,2M(kernel)ro,-(root) EVB2065> nand -a /dev/nand0.kernel EVB2065> nand -a /dev/nand0.barebox EVB2065> dfu -V 1 -P 24 /dev/nand0.kernel.bb(barebox) dfu: register alt0(barebox) with device /dev/nand0.kernel.bb EVB2065> ls . .. dev EVB2065> cp /dev/nand0.kernel.bb /zimage EVB2065> bootz /zimage loaded zImage from /zimage with size 1188508 commandline: <NULL> arch_number: 2131 Linux version 2.6.32.16-svn2136 (singhg@HUMMER) (gcc version 4.2.4 (STMicroelectronics/Linux Base 4.2.4-55)) #2 PREEMPT Fri Sep 17 11:27:42 IST 2010 CPU: ARMv6-compatible processor [410fb764] revision 4 (ARMv7), cr=00c5387f CPU: VIPT aliasing data cache, VIPT aliasing instruction cache Machine: STMicroelectronics Cartesio Plus STA2065, EVB2065 Memory policy: ECC disabled, Data cache writeback Built 1 zonelists in Zone order, mobility grouping on. Total pages: 65024 Kernel command line: root=/dev/ram0 console=ttyAMA1,115200n8 init=linuxrc consoleblank=0 .... Kernel booting from this NAND partition is also working after reboot. > Have you erased /dev/env0 before doing the dfu command? I erased the entire NAND device (erase /dev/nand0) before writing using the DFU command. Also I'm padding the barebox_default_env file to 4096 (my NAND page size), before flashing it. Regards Gaurav On Wed, Sep 29, 2010 at 1:18 PM, Sascha Hauer <s.hauer@pengutronix.de> wrote: > Hi Gaurav, > > On Wed, Sep 29, 2010 at 12:20:20PM +0530, Gaurav Singh wrote: >> Hi all, >> Currently I'm trying to load a barebox environment image from NAND >> storage but can't load it correctly. >> >> I have given the path of my environment in the config : >> >> CONFIG_CONSOLE_FULL=y >> CONFIG_CONSOLE_ACTIVATE_FIRST=y >> # CONFIG_OF_FLAT_TREE is not set >> CONFIG_PARTITION=y >> CONFIG_DEFAULT_ENVIRONMENT=y >> CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/cartesio-evb2065/env/bin" >> >> After registering the NAND device I prepared a couple of Bad Block >> aware partitions : >> >> devfs_add_partition("nand0", 0x00000, 0x200000, PARTITION_FIXED, "self_raw"); >> dev_add_bb_dev("self_raw", "self0"); >> devfs_add_partition("nand0", 0x200000, 0x200000, PARTITION_FIXED, "env_raw"); >> dev_add_bb_dev("env_raw", "env0"); >> >> On compilation I get a barebox environment image - barebox_default_env. >> Flashed this image to the env0 partition via DFU - >> dfu -V 1 -P 24 /dev/env0 > > Have you tried doing a cp /dev/env0 /somefile at this point? > Have you erased /dev/env0 before doing the dfu command? > >> >> From host sent the barebox_default_env (the default_env file is page >> alinged) via DFU to the NAND. >> >> The flashing worked fine. >> >> But now when I re-boot the system : >> >> barebox 2010.09.0-00003-ge5727b1-dirty (Sep 27 2010 - 17:18:50) >> >> Board: STMicroelectronics EVB2065 with Cartesio Plus >> NAND device: Manufacturer ID: 0x2c, Chip ID: 0x48 (Micron NAND 2GiB 3,3V 8-bit) >> Scanning device for bad blocks >> Malloc space: 0x00860000 -> 0x00e60000 (size 6 MB) >> Stack space : 0x00850000 -> 0x00858000 (size 32 kB) >> >> >> This system is stuck at this point. Investigating further - I see that >> we are stuck at >> in the common/environment.c >> int envfs_load(char *filename, char *dir) >> { >> ... >> buf = xmalloc(size); >> buf_free = buf; >> ret = read(envfd, buf, size); - Stuck here >> >> I'm wondering why this read is failing. Could the developers shed some >> light on this ? > > Can you confirm that the read ends in your nand driver? Does your nand > driver work properly? > > Sascha > > -- > Pengutronix e.K. | | > Industrial Linux Solutions | http://www.pengutronix.de/ | > Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | > Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | > _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Failing to load Barebox Environment 2010-09-29 9:01 ` Gaurav Singh @ 2010-09-29 9:08 ` Juergen Beisert 2010-09-29 9:14 ` Gaurav Singh 2010-09-29 9:23 ` Juergen Beisert 0 siblings, 2 replies; 11+ messages in thread From: Juergen Beisert @ 2010-09-29 9:08 UTC (permalink / raw) To: barebox Just a note: You configure: > >> devfs_add_partition("nand0", 0x00000, 0x200000, PARTITION_FIXED, > >> "self_raw"); dev_add_bb_dev("self_raw", "self0"); > >> devfs_add_partition("nand0", 0x200000, 0x200000, PARTITION_FIXED, > >> "env_raw"); dev_add_bb_dev("env_raw", "env0"); And then: > EVB2065> addpart /dev/nand0 4M(barebox)ro,2M(kernel)ro,-(root) Both must match! Try instead: EVB2065> addpart /dev/nand0 256k(barebox)ro,256k(env),2M(kernel)ro,-(root) jbe -- Pengutronix e.K. | Juergen Beisert | Linux Solutions for Science and Industry | Phone: +49-8766-939 228 | Vertretung Sued/Muenchen, Germany | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de/ | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Failing to load Barebox Environment 2010-09-29 9:08 ` Juergen Beisert @ 2010-09-29 9:14 ` Gaurav Singh 2010-09-29 9:23 ` Juergen Beisert 1 sibling, 0 replies; 11+ messages in thread From: Gaurav Singh @ 2010-09-29 9:14 UTC (permalink / raw) To: Juergen Beisert; +Cc: barebox Hi Juergen, You are right offcourse But this is not the problem. Sorry I forgot to mention that I used a different Barebox version for the kernel boot part - one in which I had not defined any nand partitions statically using devfs_add_partition :). Thanks Regards Gaurav On Wed, Sep 29, 2010 at 2:38 PM, Juergen Beisert <jbe@pengutronix.de> wrote: > Just a note: > > You configure: > >> >> devfs_add_partition("nand0", 0x00000, 0x200000, PARTITION_FIXED, >> >> "self_raw"); dev_add_bb_dev("self_raw", "self0"); >> >> devfs_add_partition("nand0", 0x200000, 0x200000, PARTITION_FIXED, >> >> "env_raw"); dev_add_bb_dev("env_raw", "env0"); > > And then: > >> EVB2065> addpart /dev/nand0 4M(barebox)ro,2M(kernel)ro,-(root) > > Both must match! > > Try instead: > > EVB2065> addpart /dev/nand0 256k(barebox)ro,256k(env),2M(kernel)ro,-(root) > > jbe > > -- > Pengutronix e.K. | Juergen Beisert | > Linux Solutions for Science and Industry | Phone: +49-8766-939 228 | > Vertretung Sued/Muenchen, Germany | Fax: +49-5121-206917-5555 | > Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de/ | > _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Failing to load Barebox Environment 2010-09-29 9:08 ` Juergen Beisert 2010-09-29 9:14 ` Gaurav Singh @ 2010-09-29 9:23 ` Juergen Beisert 2010-09-29 10:03 ` Gaurav Singh 2010-09-30 6:39 ` Gaurav Singh 1 sibling, 2 replies; 11+ messages in thread From: Juergen Beisert @ 2010-09-29 9:23 UTC (permalink / raw) To: barebox Juergen Beisert wrote: > Just a note: > > You configure: > > >> devfs_add_partition("nand0", 0x00000, 0x200000, PARTITION_FIXED, > > >> "self_raw"); dev_add_bb_dev("self_raw", "self0"); > > >> devfs_add_partition("nand0", 0x200000, 0x200000, PARTITION_FIXED, > > >> "env_raw"); dev_add_bb_dev("env_raw", "env0"); > > And then: > > EVB2065> addpart /dev/nand0 4M(barebox)ro,2M(kernel)ro,-(root) > > Both must match! > > Try instead: > > EVB2065> addpart /dev/nand0 256k(barebox)ro,256k(env),2M(kernel)ro,-(root) > > jbe Ups, sorry: 0x200000 != 256k (didn't count the '0' right...) EVB2065> addpart /dev/nand0 2M(barebox)ro,2M(env),2M(kernel)ro,-(root) jbe -- Pengutronix e.K. | Juergen Beisert | Linux Solutions for Science and Industry | Phone: +49-8766-939 228 | Vertretung Sued/Muenchen, Germany | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de/ | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Failing to load Barebox Environment 2010-09-29 9:23 ` Juergen Beisert @ 2010-09-29 10:03 ` Gaurav Singh 2010-09-29 10:08 ` Gaurav Singh 2010-09-30 6:39 ` Gaurav Singh 1 sibling, 1 reply; 11+ messages in thread From: Gaurav Singh @ 2010-09-29 10:03 UTC (permalink / raw) To: Juergen Beisert; +Cc: barebox Just a question regarding the host generated environement file. In common/environment.c - the host specific envfs_save function is setting size = (unsigned long)data.writep; Now there is no way of ensuring that the size is padded to Page size. The script bareboxenv seems not to use the pad parameter to change the size parameter of the ENVFS superblock. Now I know that we can't issue read commands which are not multiples of Page size. But this is exactly what we are doing in envfs_load: size = ENVFS_32(super.size); buf = xmalloc(size); buf_free = buf; ret = read(envfd, buf, size); I think this explains why my read is failing ! Regards Gaurav On Wed, Sep 29, 2010 at 2:53 PM, Juergen Beisert <jbe@pengutronix.de> wrote: > Juergen Beisert wrote: >> Just a note: >> >> You configure: >> > >> devfs_add_partition("nand0", 0x00000, 0x200000, PARTITION_FIXED, >> > >> "self_raw"); dev_add_bb_dev("self_raw", "self0"); >> > >> devfs_add_partition("nand0", 0x200000, 0x200000, PARTITION_FIXED, >> > >> "env_raw"); dev_add_bb_dev("env_raw", "env0"); >> >> And then: >> > EVB2065> addpart /dev/nand0 4M(barebox)ro,2M(kernel)ro,-(root) >> >> Both must match! >> >> Try instead: >> >> EVB2065> addpart /dev/nand0 256k(barebox)ro,256k(env),2M(kernel)ro,-(root) >> >> jbe > > Ups, sorry: 0x200000 != 256k (didn't count the '0' right...) > > EVB2065> addpart /dev/nand0 2M(barebox)ro,2M(env),2M(kernel)ro,-(root) > > jbe > > -- > Pengutronix e.K. | Juergen Beisert | > Linux Solutions for Science and Industry | Phone: +49-8766-939 228 | > Vertretung Sued/Muenchen, Germany | Fax: +49-5121-206917-5555 | > Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de/ | > _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Failing to load Barebox Environment 2010-09-29 10:03 ` Gaurav Singh @ 2010-09-29 10:08 ` Gaurav Singh 0 siblings, 0 replies; 11+ messages in thread From: Gaurav Singh @ 2010-09-29 10:08 UTC (permalink / raw) To: Juergen Beisert; +Cc: barebox By the way - Just to add.. I'm using the Sept 2010 release of Barebox. 2010.09. On Wed, Sep 29, 2010 at 3:33 PM, Gaurav Singh <gausinghnsit@gmail.com> wrote: > Just a question regarding the host generated environement file. > > In common/environment.c - the host specific envfs_save function is setting > > size = (unsigned long)data.writep; > > Now there is no way of ensuring that the size is padded to Page size. > The script bareboxenv seems not to use the pad parameter to change the > size parameter of the ENVFS superblock. > Now I know that we can't issue read commands which are not multiples > of Page size. But this is exactly what we are doing in envfs_load: > > size = ENVFS_32(super.size); > buf = xmalloc(size); > buf_free = buf; > ret = read(envfd, buf, size); > > I think this explains why my read is failing ! > > Regards > Gaurav > > > > > > > On Wed, Sep 29, 2010 at 2:53 PM, Juergen Beisert <jbe@pengutronix.de> wrote: >> Juergen Beisert wrote: >>> Just a note: >>> >>> You configure: >>> > >> devfs_add_partition("nand0", 0x00000, 0x200000, PARTITION_FIXED, >>> > >> "self_raw"); dev_add_bb_dev("self_raw", "self0"); >>> > >> devfs_add_partition("nand0", 0x200000, 0x200000, PARTITION_FIXED, >>> > >> "env_raw"); dev_add_bb_dev("env_raw", "env0"); >>> >>> And then: >>> > EVB2065> addpart /dev/nand0 4M(barebox)ro,2M(kernel)ro,-(root) >>> >>> Both must match! >>> >>> Try instead: >>> >>> EVB2065> addpart /dev/nand0 256k(barebox)ro,256k(env),2M(kernel)ro,-(root) >>> >>> jbe >> >> Ups, sorry: 0x200000 != 256k (didn't count the '0' right...) >> >> EVB2065> addpart /dev/nand0 2M(barebox)ro,2M(env),2M(kernel)ro,-(root) >> >> jbe >> >> -- >> Pengutronix e.K. | Juergen Beisert | >> Linux Solutions for Science and Industry | Phone: +49-8766-939 228 | >> Vertretung Sued/Muenchen, Germany | Fax: +49-5121-206917-5555 | >> Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de/ | >> > _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Failing to load Barebox Environment 2010-09-29 9:23 ` Juergen Beisert 2010-09-29 10:03 ` Gaurav Singh @ 2010-09-30 6:39 ` Gaurav Singh 2010-10-01 11:10 ` Gaurav Singh 1 sibling, 1 reply; 11+ messages in thread From: Gaurav Singh @ 2010-09-30 6:39 UTC (permalink / raw) To: Juergen Beisert, Sascha Hauer; +Cc: barebox Hi Sascha, Juergen, I did a rather crude workaround for this. Copied the NAND partition containing the environment from NAND on startup into a file using run_command. run_command("cp /dev/env0 /env_temp",0); then envfs_load("/env_temp", "/env") This is working fine. I think - overall the enfs_load logic has to be tweaked for NAND devices. Now I wrote a new enfs_nand_load function - This basically reads a Page of NAND (which works fine if my env file is less than 4096 :)) into the buffer and manipulates it to prepare the Environment correctly. So basically we can read the entire environment partition from NAND in one go and then manipulate it to prepare the env in RAM. int envfs_nand_load(char *filename, char *dir) { struct envfs_super* super; void *buf = NULL, *buf_free = NULL; int envfd; int fd, ret = 0; char *str, *tmp; int namelen_full; unsigned long size; envfd = open(filename, O_RDONLY); if (envfd < 0) { printf("Open %s %s\n", filename, errno_str()); return -1; } /* Reading a Page into Buf */ size = ENVFS_32(4096); buf = xzalloc(size); buf_free = buf; printf("1\n"); ret = read(envfd, buf, size); if (ret < size) { perror("read"); ret = errno; goto out; } super = (struct envfs_super *)buf; if ( ENVFS_32(super->magic) != ENVFS_MAGIC) { printf("envfs: wrong magic on %s\n", filename); ret = -EIO; goto out; } if (crc32(0, (unsigned char *)super, sizeof(struct envfs_super) - 4) != ENVFS_32(super->sb_crc)) { printf("wrong crc on env superblock\n"); ret = -EIO; goto out; } void *buf2; size = ENVFS_32(super->size); /* Rest on ENV except Superblock to be kept in buf2 */ buf2 = (void *)((char *)buf + sizeof(struct envfs_super)); if (crc32(0, (unsigned char *)buf2, size) != ENVFS_32(super->crc)) { printf("wrong crc on env\n"); ret = -EIO; goto out; } while (size) { struct envfs_inode *inode; uint32_t inode_size, inode_namelen; inode = (struct envfs_inode *)buf2; if (ENVFS_32(inode->magic) != ENVFS_INODE_MAGIC) { printf("envfs: wrong magic on %s\n", filename); ret = -EIO; goto out; } inode_size = ENVFS_32(inode->size); inode_namelen = ENVFS_32(inode->namelen); debug("loading %s size %d namelen %d\n", inode->data, inode_size, inode_namelen); str = concat_path_file(dir, inode->data); tmp = strdup(str); make_directory(dirname(tmp)); free(tmp); fd = open(str, O_WRONLY | O_CREAT | O_TRUNC, 0644); free(str); if (fd < 0) { printf("Open %s\n", errno_str()); ret = fd; goto out; } namelen_full = PAD4(inode_namelen); ret = write(fd, buf2 + namelen_full + sizeof(struct envfs_inode), inode_size); if (ret < inode_size) { perror("write"); ret = errno; close(fd); goto out; } close(fd); buf2 += PAD4(inode_namelen) + PAD4(inode_size) + sizeof(struct envfs_inode); size -= PAD4(inode_namelen) + PAD4(inode_size) + sizeof(struct envfs_inode); } ret = 0; out: close(envfd); if (buf_free) free(buf_free); return ret; } On Wed, Sep 29, 2010 at 2:53 PM, Juergen Beisert <jbe@pengutronix.de> wrote: > Juergen Beisert wrote: >> Just a note: >> >> You configure: >> > >> devfs_add_partition("nand0", 0x00000, 0x200000, PARTITION_FIXED, >> > >> "self_raw"); dev_add_bb_dev("self_raw", "self0"); >> > >> devfs_add_partition("nand0", 0x200000, 0x200000, PARTITION_FIXED, >> > >> "env_raw"); dev_add_bb_dev("env_raw", "env0"); >> >> And then: >> > EVB2065> addpart /dev/nand0 4M(barebox)ro,2M(kernel)ro,-(root) >> >> Both must match! >> >> Try instead: >> >> EVB2065> addpart /dev/nand0 256k(barebox)ro,256k(env),2M(kernel)ro,-(root) >> >> jbe > > Ups, sorry: 0x200000 != 256k (didn't count the '0' right...) > > EVB2065> addpart /dev/nand0 2M(barebox)ro,2M(env),2M(kernel)ro,-(root) > > jbe > > -- > Pengutronix e.K. | Juergen Beisert | > Linux Solutions for Science and Industry | Phone: +49-8766-939 228 | > Vertretung Sued/Muenchen, Germany | Fax: +49-5121-206917-5555 | > Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de/ | > _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Failing to load Barebox Environment 2010-09-30 6:39 ` Gaurav Singh @ 2010-10-01 11:10 ` Gaurav Singh 0 siblings, 0 replies; 11+ messages in thread From: Gaurav Singh @ 2010-10-01 11:10 UTC (permalink / raw) To: Juergen Beisert, Sascha Hauer; +Cc: barebox Hi all, Well turns out my character device inode values were being overwritten by the NAND buffer contents... this was because I have to change NAND_MAX_PAGESIZE from 2048 to 4096 ! I have a NAND on my board where Page size is 4096. It is working fine now - no need for a seperate envfs_nand_load function. Thanks Regards Gaurav On Thu, Sep 30, 2010 at 12:09 PM, Gaurav Singh <gausinghnsit@gmail.com> wrote: > Hi Sascha, Juergen, > I did a rather crude workaround for this. Copied the NAND partition > containing the environment from NAND on startup into a file using > run_command. > run_command("cp /dev/env0 /env_temp",0); > then > envfs_load("/env_temp", "/env") > > This is working fine. > I think - overall the enfs_load logic has to be tweaked for NAND devices. > > Now I wrote a new enfs_nand_load function - This basically reads a > Page of NAND (which works fine if my env file is less than 4096 :)) > into the buffer and manipulates it to prepare the Environment > correctly. So basically we can read the entire environment partition > from NAND in one go and then manipulate it to prepare the env in RAM. > > int envfs_nand_load(char *filename, char *dir) > { > struct envfs_super* super; > void *buf = NULL, *buf_free = NULL; > int envfd; > int fd, ret = 0; > char *str, *tmp; > int namelen_full; > unsigned long size; > > envfd = open(filename, O_RDONLY); > if (envfd < 0) { > printf("Open %s %s\n", filename, errno_str()); > return -1; > } > /* Reading a Page into Buf */ > size = ENVFS_32(4096); > buf = xzalloc(size); > buf_free = buf; > printf("1\n"); > ret = read(envfd, buf, size); > if (ret < size) { > perror("read"); > ret = errno; > goto out; > } > > super = (struct envfs_super *)buf; > > if ( ENVFS_32(super->magic) != ENVFS_MAGIC) { > printf("envfs: wrong magic on %s\n", filename); > ret = -EIO; > goto out; > } > > if (crc32(0, (unsigned char *)super, sizeof(struct envfs_super) - 4) > != ENVFS_32(super->sb_crc)) { > printf("wrong crc on env superblock\n"); > ret = -EIO; > goto out; > } > > void *buf2; > size = ENVFS_32(super->size); > /* Rest on ENV except Superblock to be kept in buf2 */ > buf2 = (void *)((char *)buf + sizeof(struct envfs_super)); > > if (crc32(0, (unsigned char *)buf2, size) > != ENVFS_32(super->crc)) { > printf("wrong crc on env\n"); > ret = -EIO; > goto out; > } > > while (size) { > struct envfs_inode *inode; > uint32_t inode_size, inode_namelen; > > inode = (struct envfs_inode *)buf2; > > if (ENVFS_32(inode->magic) != ENVFS_INODE_MAGIC) { > printf("envfs: wrong magic on %s\n", filename); > ret = -EIO; > goto out; > } > inode_size = ENVFS_32(inode->size); > inode_namelen = ENVFS_32(inode->namelen); > > debug("loading %s size %d namelen %d\n", inode->data, > inode_size, inode_namelen); > > str = concat_path_file(dir, inode->data); > tmp = strdup(str); > make_directory(dirname(tmp)); > free(tmp); > > fd = open(str, O_WRONLY | O_CREAT | O_TRUNC, 0644); > free(str); > if (fd < 0) { > printf("Open %s\n", errno_str()); > ret = fd; > goto out; > } > > namelen_full = PAD4(inode_namelen); > ret = write(fd, buf2 + namelen_full + sizeof(struct > envfs_inode), > inode_size); > if (ret < inode_size) { > perror("write"); > ret = errno; > close(fd); > goto out; > } > > close(fd); > > buf2 += PAD4(inode_namelen) + PAD4(inode_size) + > sizeof(struct envfs_inode); > size -= PAD4(inode_namelen) + PAD4(inode_size) + > sizeof(struct envfs_inode); > } > > ret = 0; > out: > close(envfd); > if (buf_free) > free(buf_free); > return ret; > } > > > > > On Wed, Sep 29, 2010 at 2:53 PM, Juergen Beisert <jbe@pengutronix.de> wrote: >> Juergen Beisert wrote: >>> Just a note: >>> >>> You configure: >>> > >> devfs_add_partition("nand0", 0x00000, 0x200000, PARTITION_FIXED, >>> > >> "self_raw"); dev_add_bb_dev("self_raw", "self0"); >>> > >> devfs_add_partition("nand0", 0x200000, 0x200000, PARTITION_FIXED, >>> > >> "env_raw"); dev_add_bb_dev("env_raw", "env0"); >>> >>> And then: >>> > EVB2065> addpart /dev/nand0 4M(barebox)ro,2M(kernel)ro,-(root) >>> >>> Both must match! >>> >>> Try instead: >>> >>> EVB2065> addpart /dev/nand0 256k(barebox)ro,256k(env),2M(kernel)ro,-(root) >>> >>> jbe >> >> Ups, sorry: 0x200000 != 256k (didn't count the '0' right...) >> >> EVB2065> addpart /dev/nand0 2M(barebox)ro,2M(env),2M(kernel)ro,-(root) >> >> jbe >> >> -- >> Pengutronix e.K. | Juergen Beisert | >> Linux Solutions for Science and Industry | Phone: +49-8766-939 228 | >> Vertretung Sued/Muenchen, Germany | Fax: +49-5121-206917-5555 | >> Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de/ | >> > _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2010-10-01 11:10 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2010-09-29 6:50 Failing to load Barebox Environment Gaurav Singh 2010-09-29 7:29 ` Juergen Beisert 2010-09-29 7:48 ` Sascha Hauer 2010-09-29 9:01 ` Gaurav Singh 2010-09-29 9:08 ` Juergen Beisert 2010-09-29 9:14 ` Gaurav Singh 2010-09-29 9:23 ` Juergen Beisert 2010-09-29 10:03 ` Gaurav Singh 2010-09-29 10:08 ` Gaurav Singh 2010-09-30 6:39 ` Gaurav Singh 2010-10-01 11:10 ` Gaurav Singh
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox