Skip to contentSkip to conversation

Update barebox on mmc without touching partition table

DISCUSSION Thomas Mayer 4 participants 6 messages Apr 8, 2011 – Apr 13, 2011

lore
Share & tools
lore
#0 lore raw

Hi,

to copy barebox to a mmc I use the command "dd if=barebox.bin of=/dev/sdb bs=512 seek=2 skip=2 && sync". So I don't touch the first 0x400 bytes with contains the partition table and everything is fine.

But I want to write a little script to update barebox itself via tftp. So I create a partition "/dev/self0" (0x00000 to 0x40000) and update barebox with "tftp barebox.bin /dev/self0". The problem is that barebox write the first 0x400 bytes too and overwrite the partition table .

Is there any way to "seek" and "skip" with barebox?

Regards,
Thomas

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#1 lore raw

Hi Thomas,

Quoted 7 lines · Thomas Mayer

Hi,

to copy barebox to a mmc I use the command "dd if=barebox.bin of=/dev/sdb bs=512 seek=2 skip=2 && sync". So I don't touch the first 0x400 bytes with contains the partition table and everything is fine.

Quoted 7 lines

But I want to write a little script to update barebox itself via tftp. So I create a partition "/dev/self0" (0x00000 to 0x40000) and update barebox with "tftp barebox.bin /dev/self0". The problem is that barebox write the first 0x400 bytes too and overwrite the partition table .

Is there any way to "seek" and "skip" with barebox?

Not directly. What you can do is this:

tftp barebox.bin
memcpy -s barebox.bin -d /dev/self0 512 0

Sascha

Signature · 9 lines
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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

Hi Sasha,

thanks for your help!

Am 08.04.2011 15:21, schrieb Sascha Hauer:

Quoted 16 lines

Hi Thomas,

Quoted 13 lines · Thomas Mayer

Hi,

to copy barebox to a mmc I use the command "dd if=barebox.bin of=/dev/sdb bs=512 seek=2 skip=2&& sync". So I don't touch the first 0x400 bytes with contains the partition table and everything is fine.

But I want to write a little script to update barebox itself via tftp. So I create a partition "/dev/self0" (0x00000 to 0x40000) and update barebox with "tftp barebox.bin /dev/self0". The problem is that barebox write the first 0x400 bytes too and overwrite the partition table .

Quoted 5 lines
Quoted 1 line

Is there any way to "seek" and "skip" with barebox?

Not directly. What you can do is this:

tftp barebox.bin
memcpy -s barebox.bin -d /dev/self0 512 0

It's working, but I have to use "1024" instead of "512". Also I have to change my partition init from "devfs_add_partition("disk0", 0x000000, 0x040000, PARTITION_FIXED, "self0");"
to
devfs_add_partition("disk0", 0x000400, 0x040000, PARTITION_FIXED, "self0");

Regards,
Thomas

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#3 lore raw
Quoted 14 lines · Thomas Mayer
Quoted 14 lines
Quoted 5 lines

to copy barebox to a mmc I use the command "dd if=barebox.bin of=/dev/sdb bs=512 seek=2 skip=2&& sync". So I don't touch the first 0x400 bytes with contains the partition table and everything is fine.

Quoted 7 lines

But I want to write a little script to update barebox itself via tftp. So I create a partition "/dev/self0" (0x00000 to 0x40000) and update barebox with "tftp barebox.bin /dev/self0". The problem is that barebox write the first 0x400 bytes too and overwrite the partition table .

Is there any way to "seek" and "skip" with barebox?

Not directly. What you can do is this:

Quoted 8 lines
Quoted 2 lines

tftp barebox.bin
memcpy -s barebox.bin -d /dev/self0 512 0

It's working, but I have to use "1024" instead of "512". Also I have to change my partition init from
"devfs_add_partition("disk0", 0x000000, 0x040000, PARTITION_FIXED, "self0");"
to
devfs_add_partition("disk0", 0x000400, 0x040000, PARTITION_FIXED, "self0");

what about using:

memcpy -s barebox.bin -d /dev/self0 1024 1024

Marc

Signature · 4 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#4 lore raw

Hi Marc,

Am 13.04.2011 11:51, schrieb Marc Kleine-Budde:

Quoted 23 lines · Thomas Mayer
Quoted 14 lines
Quoted 14 lines
Quoted 5 lines

to copy barebox to a mmc I use the command "dd if=barebox.bin
of=/dev/sdb bs=512 seek=2 skip=2&& sync". So I don't touch the
first 0x400 bytes with contains the partition table and everything is fine.

Quoted 7 lines

But I want to write a little script to update barebox itself via tftp. So I create a partition "/dev/self0" (0x00000 to 0x40000) and update barebox with "tftp barebox.bin /dev/self0". The problem is that barebox write the first 0x400 bytes too and overwrite the partition table .

Is there any way to "seek" and "skip" with barebox?

Not directly. What you can do is this:

Quoted 8 lines
Quoted 2 lines

tftp barebox.bin
memcpy -s barebox.bin -d /dev/self0 512 0

It's working, but I have to use "1024" instead of "512". Also I have to change my partition init from
"devfs_add_partition("disk0", 0x000000, 0x040000, PARTITION_FIXED, "self0");"
to
devfs_add_partition("disk0", 0x000400, 0x040000, PARTITION_FIXED, "self0");

Quoted 4 lines

what about using:

memcpy -s barebox.bin -d /dev/self0 1024 1024

works too, with partition from 0x00000 to 0x040000.

Regards,
Thomas

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#5 lore raw
Quoted 3 lines · Thomas Mayer
Quoted 2 lines

memcpy -s barebox.bin -d /dev/self0 1024 1024

works too, with partition from 0x00000 to 0x040000.

\o/

Signature · 4 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox