can u-boot tools fw_{printenv, setenv} work with eMMC HW partition?
i'm sure there's a simple answer to this -- i built u-boot for my
beaglebone black using the "am335x_boneblack" config, which supports saving env info to the eMMC HW partition boot1. but now that it's there, is there a way i can manipulate that info with fw_printenv and fw_setenv?
that info is actually visible from the linux command line via the
special device file /dev/mmcblk1boot1, which i can hexdump if i wish:
# hexdump -C /dev/mmcblk1boot1 | less 00000000 fc d7 b6 21 61 72 63 68 3d 61 72 6d 00 62 61 75 |...!arch=arm.bau| 00000010 64 72 61 74 65 3d 31 31 35 32 30 30 00 62 6f 61 |drate=115200.boa| 00000020 72 64 3d 61 6d 33 33 35 78 00 62 6f 61 72 64 5f |rd=am335x.board_| 00000030 6e 61 6d 65 3d 41 33 33 35 42 4e 4c 54 00 62 6f |name=A335BNLT.bo| 00000040 61 72 64 5f 72 65 76 3d 30 41 35 43 00 62 6f 6f |ard_rev=0A5C.boo| 00000050 74 5f 66 64 74 3d 74 72 79 00 62 6f 6f 74 61 72 |t_fdt=try.bootar| ... snip ...
so it's clearly there, but i have no idea what i'd put in /etc/fw_env.config to refer to that partition.
i tried adding the simple line:
/dev/mmcblk1boot1 0x0 0x4000
to (allegedly) represent a block device, but i got the error:
# fw_printenv Cannot access MTD device /dev/mmcblk1boot: No such file or directory #
so i'm guessing that was a really bad initial guess. i'm guessing i'd need to add a line referring to the existing device file /dev/mmcblk1, and add the actual HW partition offset and size, yes? i just have to figure out what that is, if that's the way it's done.
rday
Signature · 7 lines
========================================================================
Robert P. J. Day Ottawa, Ontario, CANADA
http://crashcourse.ca
Twitter: http://twitter.com/rpjday
LinkedIn: http://ca.linkedin.com/in/rpjday
========================================================================Dear Robert P. J. Day,
On 08/23/2013 02:25 PM, Robert P. J. Day wrote:
<snip>
Quoted 5 lines
so it's clearly there, but i have no idea what i'd put in
/etc/fw_env.configto refer to that partition.i tried adding the simple line:
Quoted 7 lines
/dev/mmcblk1boot10x00x4000to (allegedly) represent a block device, but i got the error:
# fw_printenv Cannot access MTD device /dev/mmcblk1boot: No such file or directory #
I think you stumble over this:
---8<---
abiessmann@punisher % grep -C 4 'struct envdev_s' tools/env/fw_env.c
typeof(y) _min2 = (y); \ (void) (&_min1 == &_min2); \ _min1 < _min2 ? _min1 : _min2; })
struct envdev_s {
char devname[16]; /* Device name */
ulong devoff; /* Device offset */
ulong env_size; /* environment size */
ulong erase_size; /* device erase size */
ulong env_sectors; /* number of environment sectors */
uint8_t mtd_type; /* type of the MTD device */
};
--->8---
An device name can only have 16 char by this declaration ;)
Quoted 4 lines
so i'm guessing that was a really bad initial guess. i'm guessing i'd need to add a line referring to the existing device file
/dev/mmcblk1, and add the actual HW partition offset and size, yes? i just have to figure out what that is, if that's the way it's done.
Dunno if that'd be all to support RAW eMMC partition. As long as thy behave like raw MTD partition it should work out.
Best regards
Andreas Bie?mann
Quoted 37 lines · Andreas Bie?mann
Dear Robert P. J. Day,
On 08/23/2013 02:25 PM, Robert P. J. Day wrote:
<snip>
Quoted 5 lines
so it's clearly there, but i have no idea what i'd put in
/etc/fw_env.configto refer to that partition.i tried adding the simple line:
Quoted 7 lines
/dev/mmcblk1boot10x00x4000to (allegedly) represent a block device, but i got the error:
# fw_printenv Cannot access MTD device /dev/mmcblk1boot: No such file or directory #I think you stumble over this:
---8<---
abiessmann at punisher % grep -C 4 'structenvdev_s'tools/env/fw_env.ctypeof(y) _min2 = (y); \ (void) (&_min1 == &_min2); \ _min1 < _min2 ? _min1 : _min2; })struct
envdev_s{
char devname[16]; /* Device name */
ulong devoff; /* Device offset */
ulongenv_size; /* environment size */
ulongerase_size; /* device erase size */
ulongenv_sectors; /* number of environment sectors */
uint8_tmtd_type; /* type of the MTD device */
};
--->8---
Quoted 1 line
An device name can only have 16 char by this declaration ;)
good lord, you're right, that explains why the last character of the
device file was getting mysteriously dropped. :-( so as a quick hack, i just did a "mknod" (i suspect a symlink would have worked just as well) to invent a shorter name, "/dev/mmcboot1", and got (predictably):
# fw_printenv Cannot get MTD information: Invalid argument #
which leads me into stefano's response which i just saw.
rday
Signature · 7 lines
========================================================================
Robert P. J. Day Ottawa, Ontario, CANADA
http://crashcourse.ca
Twitter: http://twitter.com/rpjday
LinkedIn: http://ca.linkedin.com/in/rpjday
========================================================================Hi Robert,
Quoted 2 lines · Robert P. J. Day
i'm sure there's a simple answer to this
There is
Quoted 5 lines
-- i built u-boot for my
beaglebone black using the "am335x_boneblack" config, which supports saving env info to the eMMC HW partition boot1. but now that it's there, is there a way i can manipulate that info withfw_printenvandfw_setenv?
Check in code - fw_printenv / fw_setenv are supposed to work with a MTD device, and the MMC is not. There are some additional checks and handling of NOR and NAND devices is done differently. But there is no code for MMC.
However, managing MMC is easier: no need of erasing flash, simply write into the device computing the CRC. You could add the required functions to rwad / write a buffer from MMC to fw_printenv (and posting here the patch, thanks !).
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
Quoted 14 lines · Stefano Babic
Hi Robert,
Quoted 2 lines · Robert P. J. Day
i'm sure there's a simple answer to this
There is
Quoted 5 lines
-- i built u-boot for my
beaglebone black using the "am335x_boneblack" config, which supports saving env info to the eMMC HW partition boot1. but now that it's there, is there a way i can manipulate that info withfw_printenvandfw_setenv?
Quoted 4 lines
Check in code -
fw_printenv/fw_setenvare supposed to work with a MTD device, and the MMC is not. There are some additional checks and handling of NOR and NAND devices is done differently. But there is no code for MMC.
yup, i can see that. the tools i was using were an earlier version
selected by my OE build, where the code in fw_env.c was:
static int flash_read (int fd)
{
struct mtd_info_user mtdinfo;
int rc;
rc = ioctl (fd, MEMGETINFO, &mtdinfo);
if (rc < 0) {
perror ("Cannot get MTD information"); <-- where it was failing
return -1;
}
if (mtdinfo.type != MTD_NORFLASH &&
mtdinfo.type != MTD_NANDFLASH &&
mtdinfo.type != MTD_DATAFLASH) {
fprintf (stderr, "Unsupported flash type %u\n", mtdinfo.type);
return -1;
}
... snip ...i can see, in the current repo, that's been refined to distinguish between block and character device files:
static int flash_read (int fd)
{
struct mtd_info_user mtdinfo;
struct stat st;
int rc;
rc = fstat(fd, &st);
if (rc < 0) {
fprintf(stderr, "Cannot stat the file %s\n",
DEVNAME(dev_current));
return -1;
}
if (S_ISCHR(st.st_mode)) {
rc = ioctl(fd, MEMGETINFO, &mtdinfo);
if (rc < 0) {
fprintf(stderr, "Cannot get MTD information for %s\n",
DEVNAME(dev_current));
return -1;
}
if (mtdinfo.type != MTD_NORFLASH &&
mtdinfo.type != MTD_NANDFLASH &&
mtdinfo.type != MTD_DATAFLASH &&
mtdinfo.type != MTD_UBIVOLUME) {
fprintf (stderr, "Unsupported flash type %u on %s\n",
mtdinfo.type, DEVNAME(dev_current));
return -1;
}
} else {
memset(&mtdinfo, 0, sizeof(mtdinfo));
mtdinfo.type = MTD_ABSENT;
}
... snip ...which, as you point out, still doesn't solve the problem.
Quoted 4 lines
However, managing MMC is easier: no need of erasing flash, simply write into the device computing the CRC. You could add the required functions to rwad / write a buffer from MMC to
fw_printenv(and posting here the patch, thanks !).
as i read it (and i could be totally wrong here), all that needs to
be added is a way to specify to the fw_* tools that a given (block) partition has nothing to do with flash, and that it should be treated as pure data, bypassing any flash-related processing as you say.
i'm assuming that this would require deciding how to specify this in/etc/fw_env.config so the tools understand what's happening. thoughts on that? the line will look like:
/dev/mmcblk1boot1 ... and what goes here? ...
to identify this as a non-MTD partition?
and i guess that 16-character filename limit needs to be adjusted as
well, yes?
rday
Signature · 7 lines
========================================================================
Robert P. J. Day Ottawa, Ontario, CANADA
http://crashcourse.ca
Twitter: http://twitter.com/rpjday
LinkedIn: http://ca.linkedin.com/in/rpjday
========================================================================Quoted 5 lines · Robert P. J. Day
i'm sure there's a simple answer to this -- i built u-boot for my
beaglebone black using the "am335x_boneblack" config, which supports saving env info to the eMMC HW partition boot1. but now that it's there, is there a way i can manipulate that info withfw_printenvandfw_setenv?
I have put this in OpenWrt:
https://dev.openwrt.org/browser/trunk/package/boot/uboot-envtools/patches/110-add-support-for-MTD_ABSENT.patch
https://dev.openwrt.org/browser/trunk/package/boot/uboot-envtools/patches/115-writing-environment-for-mtd-devices.patch
With those two you will be able to use fw_{printenv,setenv} on MMC devices.
Luka
Quoted 7 lines · Luka Perkov
Quoted 5 lines · Robert P. J. Day
i'm sure there's a simple answer to this -- i built u-boot for my
beaglebone black using the "am335x_boneblack" config, which supports saving env info to the eMMC HW partition boot1. but now that it's there, is there a way i can manipulate that info withfw_printenvandfw_setenv?
Quoted 7 lines
I have put this in OpenWrt:
https://dev.openwrt.org/browser/trunk/package/boot/uboot-envtools/patches/110-add-support-for-MTD_ABSENT.patch
https://dev.openwrt.org/browser/trunk/package/boot/uboot-envtools/patches/115-writing-environment-for-mtd-devices.patchWith those two you will be able to use fw_{printenv,setenv} on MMC devices.
and how would you specify the partition in the /etc/fw_env.config
file?
rday
Signature · 7 lines
========================================================================
Robert P. J. Day Ottawa, Ontario, CANADA
http://crashcourse.ca
Twitter: http://twitter.com/rpjday
LinkedIn: http://ca.linkedin.com/in/rpjday
========================================================================Quoted 7 lines · Luka Perkov
Quoted 5 lines · Robert P. J. Day
i'm sure there's a simple answer to this -- i built u-boot for my
beaglebone black using the "am335x_boneblack" config, which supports saving env info to the eMMC HW partition boot1. but now that it's there, is there a way i can manipulate that info withfw_printenvandfw_setenv?
Quoted 7 lines
I have put this in OpenWrt:
https://dev.openwrt.org/browser/trunk/package/boot/uboot-envtools/patches/110-add-support-for-MTD_ABSENT.patch
https://dev.openwrt.org/browser/trunk/package/boot/uboot-envtools/patches/115-writing-environment-for-mtd-devices.patchWith those two you will be able to use fw_{printenv,setenv} on MMC devices.
i'll get a chance to test the above this weekend, but i just want to
make absolutely sure we're talking about the same thing. are you saying that with the above patches, the u-boot-tools will be able to manipulate an eMMC HW partition just as easily as a regular MTD partition? and, if so, what is the format of the entry one would add to /etc/fw_env.config to refer to that eMMC HW partition (in this case, boot1)?
thanks.
rday
Signature · 7 lines
========================================================================
Robert P. J. Day Ottawa, Ontario, CANADA
http://crashcourse.ca
Twitter: http://twitter.com/rpjday
LinkedIn: http://ca.linkedin.com/in/rpjday
========================================================================Quoted 14 lines · Robert P. J. Day
Quoted 12 lines · Luka Perkov
Quoted 5 lines · Robert P. J. Day
i'm sure there's a simple answer to this -- i built u-boot for my
beaglebone black using the "am335x_boneblack" config, which supports saving env info to the eMMC HW partition boot1. but now that it's there, is there a way i can manipulate that info withfw_printenvandfw_setenv?I have put this in OpenWrt:
https://dev.openwrt.org/browser/trunk/package/boot/uboot-envtools/patches/110-add-support-for-MTD_ABSENT.patch
https://dev.openwrt.org/browser/trunk/package/boot/uboot-envtools/patches/115-writing-environment-for-mtd-devices.patch
Quoted 8 lines
Quoted 2 lines
With those two you will be able to use fw_{printenv,setenv} on MMC devices.
i'll get a chance to test the above this weekend, but i just want to
make absolutely sure we're talking about the same thing. are you saying that with the above patches, the u-boot-tools will be able to manipulate an eMMC HW partition just as easily as a regular MTD partition?
Yes.
Quoted 3 lines
and, if so, what is the format of the entry one would add to
/etc/fw_env.configto refer to that eMMC HW partition (in this case, boot1)?
I have done this for imx6 wandboard in OpenWrt:
https://dev.openwrt.org/browser/trunk/package/boot/uboot-envtools/files/imx6
So example config would look like:
/dev/mmcblk0 0x60000 0x2000 0x2000
Luka
Quoted 30 lines · Luka Perkov
Quoted 14 lines · Robert P. J. Day
Quoted 12 lines · Luka Perkov
Quoted 5 lines · Robert P. J. Day
i'm sure there's a simple answer to this -- i built u-boot for my
beaglebone black using the "am335x_boneblack" config, which supports saving env info to the eMMC HW partition boot1. but now that it's there, is there a way i can manipulate that info withfw_printenvandfw_setenv?I have put this in OpenWrt:
https://dev.openwrt.org/browser/trunk/package/boot/uboot-envtools/patches/110-add-support-for-MTD_ABSENT.patch
https://dev.openwrt.org/browser/trunk/package/boot/uboot-envtools/patches/115-writing-environment-for-mtd-devices.patchQuoted 8 lines
Quoted 2 lines
With those two you will be able to use fw_{printenv,setenv} on MMC devices.
i'll get a chance to test the above this weekend, but i just want to
make absolutely sure we're talking about the same thing. are you saying that with the above patches, the u-boot-tools will be able to manipulate an eMMC HW partition just as easily as a regular MTD partition?Yes.
Quoted 3 lines
and, if so, what is the format of the entry one would add to
/etc/fw_env.configto refer to that eMMC HW partition (in this case, boot1)?
Quoted 7 lines
I have done this for imx6 wandboard in OpenWrt:
https://dev.openwrt.org/browser/trunk/package/boot/uboot-envtools/files/imx6
So example config would look like:
/dev/mmcblk00x600000x20000x2000
ah, there's the misunderstanding. i thought we were discussing how
to be able to refer *directly* to the eMMC partition "boot1", as in /dev/mmcblk1boot1. it looks like what you're describing would refer instead simply to /dev/mmcblk1, correct?
rday
Signature · 7 lines
========================================================================
Robert P. J. Day Ottawa, Ontario, CANADA
http://crashcourse.ca
Twitter: http://twitter.com/rpjday
LinkedIn: http://ca.linkedin.com/in/rpjday
========================================================================Quoted 7 lines · Robert P. J. Day
Quoted 1 line · Luka Perkov
/dev/mmcblk00x600000x20000x2000ah, there's the misunderstanding. i thought we were discussing how
to be able to refer *directly* to the eMMC partition "boot1", as in/dev/mmcblk1boot1. it looks like what you're describing would refer instead simply to/dev/mmcblk1, correct?
Even though the config is actually refering to /dev/mmcblk1 in fact it's writing/reading to /dev/mmcblk1p1 (or /dev/mmcblk1boot1) in your case. But you need to configure it properly for your MMC device.
Luka
Quoted 9 lines · Luka Perkov
Quoted 7 lines · Robert P. J. Day
Quoted 1 line · Luka Perkov
/dev/mmcblk00x600000x20000x2000ah, there's the misunderstanding. i thought we were discussing
how to be able to refer *directly* to the eMMC partition "boot1", as in/dev/mmcblk1boot1. it looks like what you're describing would refer instead simply to/dev/mmcblk1, correct?
Quoted 4 lines
Even though the config is actually refering to
/dev/mmcblk1in fact it's writing/reading to/dev/mmcblk1p1(or/dev/mmcblk1boot1) in your case. But you need to configure it properly for your MMC device.
right, i can see that and that clarifies things for me. my
*original* question was whether there was a way to set up /etc/fw_env.config to refer to the eMMC partition /dev/mmcblk1boot1 *directly*, treating it as a regular block partition and bypassing all the MTD-related processing. (perhaps stefano can weigh in and say whether that's how he understood what i was asking.)
if you instead refer to /dev/mmcblk1, as i understand it, you're
just back to the standard MTD-based access, yes?
anyway, sorry if i didn't explain myself clearly the first time.
rday
Signature · 7 lines
========================================================================
Robert P. J. Day Ottawa, Ontario, CANADA
http://crashcourse.ca
Twitter: http://twitter.com/rpjday
LinkedIn: http://ca.linkedin.com/in/rpjday
========================================================================Hi,
Quoted 9 lines
right, i can see that and that clarifies things for me. my
*original* question was whether there was a way to set up/etc/fw_env.configto refer to the eMMC partition/dev/mmcblk1boot1*directly*, treating it as a regular block partition and bypassing all the MTD-related processing. (perhaps stefano can weigh in and say whether that's how he understood what i was asking.)if you instead refer to
/dev/mmcblk1, as i understand it, you're
just back to the standard MTD-based access, yes?
the /dev/mmcblk... devices are block devices and do not provide the MTD API of the kernel. I guess this is the cause for the error message you've seen. You could try strace to verify.
And this is the problem why the patches Luka mentioned are required:
they make fw_{printenv,setenv} aware of opening such block devices by-passing the MTD-specific stuff, that means simply open the file, write/read the data and close the file descriptor. Without these patches these tools assume that the file descriptor opened are MTD-based.
You can pass what ever you want via your config, so your file could look like:/dev/mmcblk1boot1 0x0 0x4000
Since the partition is somewhere placed on the eMMC device, you can also refer to the same location using /dev/mmcblk1. In the latter case you have to calculate the offset correctly to not overwrite other data (e.g. on other partitions). Using /dev/mmcblk1boot1 as "entry point" the kernel should reject write requests which go beyond the partition size.
BR, Michael
Quoted 23 lines · Robert P. J. Day
Quoted 9 lines · Luka Perkov
Quoted 7 lines · Robert P. J. Day
Quoted 1 line · Luka Perkov
/dev/mmcblk00x600000x20000x2000ah, there's the misunderstanding. i thought we were discussing
how to be able to refer *directly* to the eMMC partition "boot1", as in/dev/mmcblk1boot1. it looks like what you're describing would refer instead simply to/dev/mmcblk1, correct?Quoted 4 lines
Even though the config is actually refering to
/dev/mmcblk1in fact it's writing/reading to/dev/mmcblk1p1(or/dev/mmcblk1boot1) in your case. But you need to configure it properly for your MMC device.right, i can see that and that clarifies things for me. my
*original* question was whether there was a way to set up/etc/fw_env.configto refer to the eMMC partition/dev/mmcblk1boot1*directly*, treating it as a regular block partition and bypassing all the MTD-related processing. (perhaps stefano can weigh in and say whether that's how he understood what i was asking.)
Quoted 4 lines
if you instead refer to
/dev/mmcblk1, as i understand it, you're
just back to the standard MTD-based access, yes?anyway, sorry if i didn't explain myself clearly the first time.
AFAIK there is no fw_{printenv,setenv} support for MMC. Except if you use the patches I pointed out. Somebody please correct me if I'm wrong.
Luka
Hi Luka,
Quoted 2 lines · Luka Perkov
AFAIK there is no fw_{printenv,setenv} support for MMC. Except if you use the patches I pointed out. Somebody please correct me if I'm wrong.
Because you have already done the work, do you plan to push official patches to the ML ? It is a pity if they will not be integrated in mainline.
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================