* Can i access the barebox env from linux
@ 2014-03-26 5:55 Ashutosh Singh
2014-03-26 6:26 ` Sascha Hauer
0 siblings, 1 reply; 10+ messages in thread
From: Ashutosh Singh @ 2014-03-26 5:55 UTC (permalink / raw)
To: barebox
Dear All,
Can i access the barebox env from linux.
Once the kernel boot if i want to create a directory and store some parameter
in default barebox /env folder without going to barebox from kernel.
For Eg.
I booted the board i get the linux promt and depending on some condition
i want to update the barebox env and create a directory in /env so the
next time
when barebox is loading the kernel image it can check that directory
and according
to that it can select the kernel from any source such as mmc, nand, nor, tftp.
What i observe that after the kernel boot i can see the barebox.env is
mounted as mtdblock5 (case of Nand)
now according to my understanding can i mount this partition modify
with my custom directory
and again boot so that this directory is available in barebox /env .
Thanks
Ashu
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Can i access the barebox env from linux
2014-03-26 5:55 Can i access the barebox env from linux Ashutosh Singh
@ 2014-03-26 6:26 ` Sascha Hauer
2014-03-26 6:57 ` Alexander Aring
0 siblings, 1 reply; 10+ messages in thread
From: Sascha Hauer @ 2014-03-26 6:26 UTC (permalink / raw)
To: Ashutosh Singh; +Cc: barebox
On Wed, Mar 26, 2014 at 11:25:07AM +0530, Ashutosh Singh wrote:
> Dear All,
>
> Can i access the barebox env from linux.
> Once the kernel boot if i want to create a directory and store some parameter
> in default barebox /env folder without going to barebox from kernel.
> For Eg.
> I booted the board i get the linux promt and depending on some condition
> i want to update the barebox env and create a directory in /env so the
> next time
> when barebox is loading the kernel image it can check that directory
> and according
> to that it can select the kernel from any source such as mmc, nand, nor, tftp.
>
> What i observe that after the kernel boot i can see the barebox.env is
> mounted as mtdblock5 (case of Nand)
> now according to my understanding can i mount this partition modify
> with my custom directory
> and again boot so that this directory is available in barebox /env .
There is no filesystem support for the barebox environment, but you can
access the barebox env under Linux using the bareboxenv tool. Enable
[x] build bareboxenv tool for target
and you'll find the tool under scripts/
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] 10+ messages in thread
* Re: Can i access the barebox env from linux
2014-03-26 6:26 ` Sascha Hauer
@ 2014-03-26 6:57 ` Alexander Aring
2014-03-26 11:14 ` Ashutosh Singh
0 siblings, 1 reply; 10+ messages in thread
From: Alexander Aring @ 2014-03-26 6:57 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox, Ashutosh Singh
Hi Sascha and Ashutosh,
On Wed, Mar 26, 2014 at 07:26:19AM +0100, Sascha Hauer wrote:
> On Wed, Mar 26, 2014 at 11:25:07AM +0530, Ashutosh Singh wrote:
> > Dear All,
> >
> > Can i access the barebox env from linux.
> > Once the kernel boot if i want to create a directory and store some parameter
> > in default barebox /env folder without going to barebox from kernel.
> > For Eg.
> > I booted the board i get the linux promt and depending on some condition
> > i want to update the barebox env and create a directory in /env so the
> > next time
> > when barebox is loading the kernel image it can check that directory
> > and according
> > to that it can select the kernel from any source such as mmc, nand, nor, tftp.
> >
> > What i observe that after the kernel boot i can see the barebox.env is
> > mounted as mtdblock5 (case of Nand)
> > now according to my understanding can i mount this partition modify
> > with my custom directory
> > and again boot so that this directory is available in barebox /env .
>
> There is no filesystem support for the barebox environment, but you can
> access the barebox env under Linux using the bareboxenv tool. Enable
> [x] build bareboxenv tool for target
> and you'll find the tool under scripts/
>
I wrote fast some skript to handle a automatic write of the bareboxenv On
env changes. It use inotify to detect changes at the environment.
--- snip
#!/bin/sh
MNT=$1
ENV=$2
bareboxenv -l $MNT $ENV
while true
do
inotifywait -e modify $MNT --excludei ".*.swp"
bareboxenv -s $MNT $ENV
done
--- snap
NOTE: Don't use this on nand partitions!
This script can be run as daemon on the target and will automatic write
the environment back. Usage: "./script $MNTPOINT $BBENV".
I hacked this in 10 seconds but it depends if it a mtd device then we
should use nandwrite etc... but maybe we can write a proper C
implementation, with inotify, mtd ioctl calls (if mtd), etc...
I mean this would be very easy to implemented. :-)
- Alex
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Can i access the barebox env from linux
2014-03-26 6:57 ` Alexander Aring
@ 2014-03-26 11:14 ` Ashutosh Singh
2014-03-26 11:31 ` Alexander Aring
0 siblings, 1 reply; 10+ messages in thread
From: Ashutosh Singh @ 2014-03-26 11:14 UTC (permalink / raw)
To: Alexander Aring; +Cc: barebox
Thanks Alex,
The script is quite helpful.
But since i am saving my barebox.env in nand and want to mount, modify
and write it back to nand.
Do you have a safer solution so that complete env data won't corrupted.
Here is my nand partition list created while booting :
Creating 8 MTD partitions on "omap2-nand.0":
[ 1.127990] 0x000000000000-0x000000020000 : "nand0.xload"
[ 1.135498] 0x000000020000-0x000000040000 : "nand0.xload_backup1"
[ 1.143615] 0x000000040000-0x000000060000 : "nand0.xload_backup2"
[ 1.151733] 0x000000060000-0x000000080000 : "nand0.xload_backup3"
[ 1.159942] 0x000000080000-0x000000100000 : "nand0.barebox"
[ 1.167755] 0x000000100000-0x000000120000 : "nand0.bareboxenv"
[ 1.175506] 0x000000120000-0x000000920000 : "nand0.kernel"
[ 1.189666] 0x000000920000-0x000020000000 : "nand0.root"
And the list in my rfs :
ls -l /dev/mtd
mtd0 mtd2 mtd4 mtd6 mtd8 mtdblock2 mtdblock6
mtd0ro mtd2ro mtd4ro mtd6ro mtd8ro mtdblock3 mtdblock7
mtd1 mtd3 mtd5 mtd7 mtdblock0 mtdblock4 mtdblock8
mtd1ro mtd3ro mtd5ro mtd7ro mtdblock1 mtdblock5
~ Ashu
On Wed, Mar 26, 2014 at 12:27 PM, Alexander Aring <alex.aring@gmail.com> wrote:
> Hi Sascha and Ashutosh,
>
> On Wed, Mar 26, 2014 at 07:26:19AM +0100, Sascha Hauer wrote:
>> On Wed, Mar 26, 2014 at 11:25:07AM +0530, Ashutosh Singh wrote:
>> > Dear All,
>> >
>> > Can i access the barebox env from linux.
>> > Once the kernel boot if i want to create a directory and store some parameter
>> > in default barebox /env folder without going to barebox from kernel.
>> > For Eg.
>> > I booted the board i get the linux promt and depending on some condition
>> > i want to update the barebox env and create a directory in /env so the
>> > next time
>> > when barebox is loading the kernel image it can check that directory
>> > and according
>> > to that it can select the kernel from any source such as mmc, nand, nor, tftp.
>> >
>> > What i observe that after the kernel boot i can see the barebox.env is
>> > mounted as mtdblock5 (case of Nand)
>> > now according to my understanding can i mount this partition modify
>> > with my custom directory
>> > and again boot so that this directory is available in barebox /env .
>>
>> There is no filesystem support for the barebox environment, but you can
>> access the barebox env under Linux using the bareboxenv tool. Enable
>> [x] build bareboxenv tool for target
>> and you'll find the tool under scripts/
>>
>
> I wrote fast some skript to handle a automatic write of the bareboxenv On
> env changes. It use inotify to detect changes at the environment.
>
> --- snip
>
> #!/bin/sh
>
> MNT=$1
> ENV=$2
>
> bareboxenv -l $MNT $ENV
>
> while true
> do
> inotifywait -e modify $MNT --excludei ".*.swp"
> bareboxenv -s $MNT $ENV
> done
>
> --- snap
>
> NOTE: Don't use this on nand partitions!
>
> This script can be run as daemon on the target and will automatic write
> the environment back. Usage: "./script $MNTPOINT $BBENV".
>
>
> I hacked this in 10 seconds but it depends if it a mtd device then we
> should use nandwrite etc... but maybe we can write a proper C
> implementation, with inotify, mtd ioctl calls (if mtd), etc...
>
> I mean this would be very easy to implemented. :-)
>
> - Alex
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Can i access the barebox env from linux
2014-03-26 11:14 ` Ashutosh Singh
@ 2014-03-26 11:31 ` Alexander Aring
2014-03-26 11:33 ` Alexander Aring
0 siblings, 1 reply; 10+ messages in thread
From: Alexander Aring @ 2014-03-26 11:31 UTC (permalink / raw)
To: Ashutosh Singh; +Cc: barebox
On Wed, Mar 26, 2014 at 04:44:30PM +0530, Ashutosh Singh wrote:
> Thanks Alex,
>
> The script is quite helpful.
> But since i am saving my barebox.env in nand and want to mount, modify
> and write it back to nand.
> Do you have a safer solution so that complete env data won't corrupted.
1. You need to save the bareboxenv as image, the right place would be
/tmp which is tmpfs and this uses ram for storing data. You need inotify
support in kernel and I am sure tmpfs also supports inotify. You also need
the inotify userspace utilities.
2. The image should write via nandwrite from mtd-utils [1]. Look for
the nandwrite manpage. nandwrite should write the tmp-image from bbenv
to your nand mtd device.
I know the nandwrite will make a better badblock handling... but if you
set your bbenv size exactly the eraseblock size so it doesn't matter...
because after badblock marking that eraseblock you don't have any bbenv
partition anymore :/
nandwrite uses the mtd api to write and I suppose they do something more
than only badblock handling, ECC calculation.... Nevertheless you should
ever use nandwrite to write images to your nand /dev/*.nand partition.
I don't have any time now to change the script for nandwrite and extract
to /tmp/bbenv/, etc..., sorry. We should do it right and implement a C
solution for that. :-) I don't have time to do that also, maybe at weekend.
I don't have also no nand device here, I need to use the nandsim module.
This will take some time to setup.
Sorry, but try to change the script yourself and then share it with us. I
will take a look and review it.
- Alex
[1] http://git.infradead.org/mtd-utils.git
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Can i access the barebox env from linux
2014-03-26 11:31 ` Alexander Aring
@ 2014-03-26 11:33 ` Alexander Aring
2014-03-26 11:53 ` Michel Stam
[not found] ` <CA+dawz2HSTYcR4Lv_0Q_ECELh2i9kq6vnZTEdnD8e+qu4pyamA@mail.gmail.com>
0 siblings, 2 replies; 10+ messages in thread
From: Alexander Aring @ 2014-03-26 11:33 UTC (permalink / raw)
To: Ashutosh Singh; +Cc: barebox
On Wed, Mar 26, 2014 at 12:31:03PM +0100, Alexander Aring wrote:
> On Wed, Mar 26, 2014 at 04:44:30PM +0530, Ashutosh Singh wrote:
> > Thanks Alex,
> >
> > The script is quite helpful.
> > But since i am saving my barebox.env in nand and want to mount, modify
> > and write it back to nand.
> > Do you have a safer solution so that complete env data won't corrupted.
>
> 1. You need to save the bareboxenv as image, the right place would be
> /tmp which is tmpfs and this uses ram for storing data. You need inotify
> support in kernel and I am sure tmpfs also supports inotify. You also need
> the inotify userspace utilities.
>
> 2. The image should write via nandwrite from mtd-utils [1]. Look for
> the nandwrite manpage. nandwrite should write the tmp-image from bbenv
> to your nand mtd device.
>
3. To read the image from bbenv partition you should also not use
bareboxenv tool directly. Use nanddump for that and then use
bareboxenv to extract these files to /tmp/bbenv or whatever.
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Can i access the barebox env from linux
2014-03-26 11:33 ` Alexander Aring
@ 2014-03-26 11:53 ` Michel Stam
2014-03-26 11:58 ` Alexander Aring
[not found] ` <CA+dawz2HSTYcR4Lv_0Q_ECELh2i9kq6vnZTEdnD8e+qu4pyamA@mail.gmail.com>
1 sibling, 1 reply; 10+ messages in thread
From: Michel Stam @ 2014-03-26 11:53 UTC (permalink / raw)
To: Alexander Aring, Ashutosh Singh; +Cc: barebox
[-- Attachment #1.1: Type: text/plain, Size: 1691 bytes --]
In case anyone is interested; for a barebox x86 project I wrote a
library that overrides fopen/fclose/open/close/etc a while back, which
allows read access to the environment sector if properly configured. I
managed to get it working on arm/mips with mtdblock as well.
In the near future I'd like to write a kernel driver to read the
filesystem properly, this was more of an experiment.
Cheers,
Michel
On 03/26/2014 12:33 PM, Alexander Aring wrote:
> On Wed, Mar 26, 2014 at 12:31:03PM +0100, Alexander Aring wrote:
>> On Wed, Mar 26, 2014 at 04:44:30PM +0530, Ashutosh Singh wrote:
>>> Thanks Alex,
>>>
>>> The script is quite helpful.
>>> But since i am saving my barebox.env in nand and want to mount, modify
>>> and write it back to nand.
>>> Do you have a safer solution so that complete env data won't corrupted.
>> 1. You need to save the bareboxenv as image, the right place would be
>> /tmp which is tmpfs and this uses ram for storing data. You need inotify
>> support in kernel and I am sure tmpfs also supports inotify. You also need
>> the inotify userspace utilities.
>>
>> 2. The image should write via nandwrite from mtd-utils [1]. Look for
>> the nandwrite manpage. nandwrite should write the tmp-image from bbenv
>> to your nand mtd device.
>>
> 3. To read the image from bbenv partition you should also not use
> bareboxenv tool directly. Use nanddump for that and then use
> bareboxenv to extract these files to /tmp/bbenv or whatever.
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
[-- Attachment #1.2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4278 bytes --]
[-- Attachment #2: Type: text/plain, Size: 149 bytes --]
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Can i access the barebox env from linux
2014-03-26 11:53 ` Michel Stam
@ 2014-03-26 11:58 ` Alexander Aring
2014-03-26 12:14 ` Michel Stam
0 siblings, 1 reply; 10+ messages in thread
From: Alexander Aring @ 2014-03-26 11:58 UTC (permalink / raw)
To: Michel Stam; +Cc: barebox, Ashutosh Singh
On Wed, Mar 26, 2014 at 12:53:03PM +0100, Michel Stam wrote:
> In case anyone is interested; for a barebox x86 project I wrote a library
> that overrides fopen/fclose/open/close/etc a while back, which allows read
> access to the environment sector if properly configured. I managed to get it
> working on arm/mips with mtdblock as well.
>
> In the near future I'd like to write a kernel driver to read the filesystem
> properly, this was more of an experiment.
>
How does it work? As a kernel module, as registered filesystem under
/proc/filesystems ?
With fuse as userspace filesystem?
Or like the inotify solution?
- Alex
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Can i access the barebox env from linux
2014-03-26 11:58 ` Alexander Aring
@ 2014-03-26 12:14 ` Michel Stam
0 siblings, 0 replies; 10+ messages in thread
From: Michel Stam @ 2014-03-26 12:14 UTC (permalink / raw)
To: Alexander Aring; +Cc: barebox, Ashutosh Singh
[-- Attachment #1.1: Type: text/plain, Size: 1502 bytes --]
Hey Alex,
The current version? That is a library, quite ugly actually.
LD_PRELOAD=/lib/LIBRARY /command/to/execute
The preload overrides the libc calls to open/read/write files.
The command can then access the environment sector, read only. If the
environment contains a /bin/init, then the file will be available from
/bin/init if the library is preloaded. Memory footprint is around
10kbyte RAM, or something like that. Its probably only usable for root,
as it requires read access to the block device, something you wouldn't
want to give all users.
As a kernel module I would make it a proper filesystem so you can do
something like mount /dev/blockdev /path -t bbfs.
That kernel driver will probably be a long-term project, though.
Cheers,
Michel
On 03/26/2014 12:58 PM, Alexander Aring wrote:
> On Wed, Mar 26, 2014 at 12:53:03PM +0100, Michel Stam wrote:
>> In case anyone is interested; for a barebox x86 project I wrote a library
>> that overrides fopen/fclose/open/close/etc a while back, which allows read
>> access to the environment sector if properly configured. I managed to get it
>> working on arm/mips with mtdblock as well.
>>
>> In the near future I'd like to write a kernel driver to read the filesystem
>> properly, this was more of an experiment.
>>
> How does it work? As a kernel module, as registered filesystem under
> /proc/filesystems ?
>
> With fuse as userspace filesystem?
>
> Or like the inotify solution?
>
> - Alex
[-- Attachment #1.2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4278 bytes --]
[-- Attachment #2: Type: text/plain, Size: 149 bytes --]
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Can i access the barebox env from linux
[not found] ` <20140328095241.GB21559@omega.Speedport_W_921V_1_24_000>
@ 2014-03-31 0:12 ` Alexander Aring
0 siblings, 0 replies; 10+ messages in thread
From: Alexander Aring @ 2014-03-31 0:12 UTC (permalink / raw)
To: Ashutosh Singh; +Cc: barebox
Hi,
On Fri, Mar 28, 2014 at 10:52:41AM +0100, Alexander Aring wrote:
> On Fri, Mar 28, 2014 at 03:04:40PM +0530, Ashutosh Singh wrote:
> > ya i tried with that too please have a look over barebox log after reboot:
> >
> > nand: ONFI param page 0 valid
> > nand: ONFI flash detected ...
> > nand: Manufacturer ID: 0x2c, Chip ID: 0xdc (Micron MT29F4G08ABADAH4),
> > page size: 2048, OOB size: 64
> > malloc space: 0x83ff4000 -> 0x87ff3fff (size 64 MiB)
> > err -74
> well, 74 is EBADMSG.
>
> I run a 'grep -nr "EBADMSG" .' into the current barebox directory and it
> seems that the uncompress env functions doesn't return this errno. So
> maybe your enviroment is correct (I can't check it I need a hexdump for
> this).
>
>
> What I can see is:
> ./drivers/mtd/nand/nand_base.c:1464: return -EBADMSG;
> ./drivers/mtd/nand/nand_base.c:1739: return -EBADMSG;
> ./drivers/mtd/nand/nand_ecc.c:192: return -EBADMSG;
>
>
> and especially "./drivers/mtd/nand/nand_ecc.c", try to enable more debug
> functionality in barebox "make menuconfig" there exist some option to
> enable set some debug level in "Debugging --->".
>
> Or maybe try to instrument the code there to see if it's really some ecc
> failure.
>
today I tested it with nandsim but I can't use a real barebox to read
the environment.
I used nandwrite and nanddump afterwards. Maybe you can run a easy test,
too. Read the image back after you ran nandwrite and extract the image
wit bareboxenv. Then we know the env is successful written and there
exists some other problem between linux<->barebox.
... and please keep the mailinglist in cc.
- Alex
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2014-03-31 0:12 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-26 5:55 Can i access the barebox env from linux Ashutosh Singh
2014-03-26 6:26 ` Sascha Hauer
2014-03-26 6:57 ` Alexander Aring
2014-03-26 11:14 ` Ashutosh Singh
2014-03-26 11:31 ` Alexander Aring
2014-03-26 11:33 ` Alexander Aring
2014-03-26 11:53 ` Michel Stam
2014-03-26 11:58 ` Alexander Aring
2014-03-26 12:14 ` Michel Stam
[not found] ` <CA+dawz2HSTYcR4Lv_0Q_ECELh2i9kq6vnZTEdnD8e+qu4pyamA@mail.gmail.com>
[not found] ` <20140328091854.GA20774@omega.Speedport_W_921V_1_24_000>
[not found] ` <CA+dawz3gfhFv3mtAOjXVoooE5WqJb6sH1qbMmPw--OD-p_N4Qg@mail.gmail.com>
[not found] ` <20140328095241.GB21559@omega.Speedport_W_921V_1_24_000>
2014-03-31 0:12 ` Alexander Aring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox