* MTD with non-power-of-2 page size
@ 2015-08-12 11:21 Dave Kitchen
2015-08-12 12:13 ` Simon Aittamaa
2015-08-19 14:20 ` Sascha Hauer
0 siblings, 2 replies; 5+ messages in thread
From: Dave Kitchen @ 2015-08-12 11:21 UTC (permalink / raw)
To: barebox
I have just started to work with barebox on an Atmel at91sam9g45 processor.
The board has an Atmel AT45DB161 dataflash configured as 528-byte page size.
I find that eg saveenv command does not run as the page erase fails with
EINVAL. On tracing this is fired from the page size and offset
correction code [mtd/core,c mtd_erase_align()] which uses bit masking to
align the size and offset. Unfortunately bit-masking does not work with
non-power-of-2 pages. Has anyone else addressed this problem?
The 'trivial' exercise of replacing the bit masks by modulo [%] operator
does not succeed as the compiler I am using (gcc!) does not support
long-long divmod.
Regards
Dave Kitchen
InSync technology Ltd
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: MTD with non-power-of-2 page size
2015-08-12 11:21 MTD with non-power-of-2 page size Dave Kitchen
@ 2015-08-12 12:13 ` Simon Aittamaa
2015-08-19 14:20 ` Sascha Hauer
1 sibling, 0 replies; 5+ messages in thread
From: Simon Aittamaa @ 2015-08-12 12:13 UTC (permalink / raw)
To: Dave Kitchen; +Cc: barebox
On 12 August 2015 at 13:21, Dave Kitchen <dave.kitchen@insync.tv> wrote:
>
> I have just started to work with barebox on an Atmel at91sam9g45 processor.
> The board has an Atmel AT45DB161 dataflash configured as 528-byte page size.
> I find that eg saveenv command does not run as the page erase fails with
> EINVAL. On tracing this is fired from the page size and offset correction
> code [mtd/core,c mtd_erase_align()] which uses bit masking to align the size
> and offset. Unfortunately bit-masking does not work with non-power-of-2
> pages. Has anyone else addressed this problem?
>
Yes, it's a bit of an annoying problem...
The easy solution (if you can spare the space) is to increase the
partition size, e.g. 128*528 should work (which is what I'm currently
using) and any multiple thereof. I'm fairly certain that 64*528 (and
any multiple thereof) should also work, but it was a while since I
messed around with that so you'll have to test it yourself.
You can also reprogram the device to present pages that are
power-of-two, but you should be aware that you lose some space
(pages*16) and the process is not reversible (you've been warned!),
see the datasheet for more information.
Best,
Simon Aittamaa
> The 'trivial' exercise of replacing the bit masks by modulo [%] operator
> does not succeed as the compiler I am using (gcc!) does not support
> long-long divmod.
>
> Regards
> Dave Kitchen
> InSync technology Ltd
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: MTD with non-power-of-2 page size
2015-08-12 11:21 MTD with non-power-of-2 page size Dave Kitchen
2015-08-12 12:13 ` Simon Aittamaa
@ 2015-08-19 14:20 ` Sascha Hauer
2015-08-19 14:29 ` Dave Kitchen
1 sibling, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2015-08-19 14:20 UTC (permalink / raw)
To: Dave Kitchen; +Cc: barebox
Hi Dave,
On Wed, Aug 12, 2015 at 12:21:00PM +0100, Dave Kitchen wrote:
>
> I have just started to work with barebox on an Atmel at91sam9g45 processor.
> The board has an Atmel AT45DB161 dataflash configured as 528-byte page size.
> I find that eg saveenv command does not run as the page erase fails
> with EINVAL. On tracing this is fired from the page size and offset
> correction code [mtd/core,c mtd_erase_align()] which uses bit
> masking to align the size and offset. Unfortunately bit-masking does
> not work with non-power-of-2 pages. Has anyone else addressed this
> problem?
>
> The 'trivial' exercise of replacing the bit masks by modulo [%]
> operator does not succeed as the compiler I am using (gcc!) does not
> support long-long divmod.
You could use do_div here which returns the remainder. Also see the
mtd_div_by_eb() and mtd_mod_by_eb() functions which may be what you are
looking for.
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] 5+ messages in thread
* Re: MTD with non-power-of-2 page size
2015-08-19 14:20 ` Sascha Hauer
@ 2015-08-19 14:29 ` Dave Kitchen
2015-08-19 14:45 ` Sascha Hauer
0 siblings, 1 reply; 5+ messages in thread
From: Dave Kitchen @ 2015-08-19 14:29 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
Hi Sascha
Thank you for the hint. I now have running code with the non-power-of-2
page size.
Shall I try and generate/submit a patch for this? The code may be
marginally slower in the power-of-2 case than the original, but I defy
anyone to notice if they are using spi boot!
Regards
Dave
On 19/08/15 15:20, Sascha Hauer wrote:
> Hi Dave,
>
> On Wed, Aug 12, 2015 at 12:21:00PM +0100, Dave Kitchen wrote:
>>
>> I have just started to work with barebox on an Atmel at91sam9g45 processor.
>> The board has an Atmel AT45DB161 dataflash configured as 528-byte page size.
>> I find that eg saveenv command does not run as the page erase fails
>> with EINVAL. On tracing this is fired from the page size and offset
>> correction code [mtd/core,c mtd_erase_align()] which uses bit
>> masking to align the size and offset. Unfortunately bit-masking does
>> not work with non-power-of-2 pages. Has anyone else addressed this
>> problem?
>>
>> The 'trivial' exercise of replacing the bit masks by modulo [%]
>> operator does not succeed as the compiler I am using (gcc!) does not
>> support long-long divmod.
>
> You could use do_div here which returns the remainder. Also see the
> mtd_div_by_eb() and mtd_mod_by_eb() functions which may be what you are
> looking for.
>
> Sascha
>
--
Dave Kitchen
InSync technology Ltd
Tilbrook House
2-4 Grenehurst Way
Petersfield
GU31 4AZ
+44(0) 1730 235117
-fwd
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: MTD with non-power-of-2 page size
2015-08-19 14:29 ` Dave Kitchen
@ 2015-08-19 14:45 ` Sascha Hauer
0 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2015-08-19 14:45 UTC (permalink / raw)
To: Dave Kitchen; +Cc: barebox
On Wed, Aug 19, 2015 at 03:29:21PM +0100, Dave Kitchen wrote:
> Hi Sascha
>
> Thank you for the hint. I now have running code with the
> non-power-of-2 page size.
> Shall I try and generate/submit a patch for this?
Yes please.
> The code may be
> marginally slower in the power-of-2 case than the original, but I
> defy anyone to notice if they are using spi boot!
Well this code is not only executed for SPI Flashes but also NAND
flashes. Anyway, the speed penalty should be negligible.
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] 5+ messages in thread
end of thread, other threads:[~2015-08-19 14:45 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-12 11:21 MTD with non-power-of-2 page size Dave Kitchen
2015-08-12 12:13 ` Simon Aittamaa
2015-08-19 14:20 ` Sascha Hauer
2015-08-19 14:29 ` Dave Kitchen
2015-08-19 14:45 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox