yhfudev / u8glib-backup

Universal Graphics Library for 8 Bit Embedded Systems
Other
0 stars 0 forks source link

Set the library for 32bit flash memory access #203

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I am using mega 128 with 10 fonts (size 35160B), overall program size is 78114B.
When I remove few fonts, library is working. But I need to work it with 
complete fonts. With all 10 fonts library shows only few fonts and boot time 
after reset is too long (about 4 sec, running on 8MHz).

So, my question is, how to expand address space for flash memory? I tried 
change in u8g.h:

typedef uint32_t PROGMEM u8g_pgm_uint8_t;
typedef uint32_t u8g_fntpgm_uint8_t;
#define u8g_pgm_read(adr) pgm_read_byte_far(adr)
typedef uint32_t u8g_pgm_uint8_t;
typedef uint32_t u8g_fntpgm_uint8_t;

with no luck, AVR Studio shows error (with these modifications) "size of array 
'u8g_font_fub20' is too large". 

Please help me how to correctly expand address space for this library.

Original issue reported on code.google.com by radim.l...@gmail.com on 27 Sep 2013 at 12:54

GoogleCodeExporter commented 9 years ago
I only have an Arduino Mega available for those kind of tests. Best starting 
point would be to have an Arduino .ino file avilable, which demonstrates the 
problem.

From your examples above, i think only
#define u8g_pgm_read(adr) pgm_read_byte_far(adr)
is usefull

Original comment by olikr...@gmail.com on 27 Sep 2013 at 2:08

GoogleCodeExporter commented 9 years ago
Why .ino file? What is in there? I believe it is irrelevant, because it is same 
architecture, and problem is probably in the library code (authors didn't 
expected so big program code).

Yes, #define u8g_pgm_read(adr) pgm_read_byte_far(adr) is for 32bit flash memory 
access, but still the same result. I was looking for "adr" definition, but 
found nothing...

Original comment by radim.l...@gmail.com on 27 Sep 2013 at 2:49

GoogleCodeExporter commented 9 years ago
Well, I finally discover the problem. The pgmspace is able to allocate only 
32kB of flash (because it uses 16 bit signed integer).
I tried to put in code empty array, experimenting with size of it, and 
threshold flash allocated size (all fonts + empty array) is 32kB.

Original comment by radim.l...@gmail.com on 27 Sep 2013 at 6:25

GoogleCodeExporter commented 9 years ago
.ino is the Arduino .c file

I did some googleing and reading...
The problem seems to be, that pointers are limited to 16 bit. However for areas 
beyond 64K we would need 24 or 32 bit pointers.

http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=34344&start=0&
postdays=0&postorder=asc&highlight= 

What i understood is this: If your constant data (fonts and other progmem data) 
do not exceed 32K then everything is fine. That means you can use the rest of 
the flash area for normal procedures.

Original comment by olikr...@gmail.com on 27 Sep 2013 at 6:53

GoogleCodeExporter commented 9 years ago
closing this issue, this will require to much of change to the lib.

Original comment by olikr...@gmail.com on 3 Oct 2013 at 6:40