Oh, seems like it is from the 16-bit pointer limitation
http://lists.nongnu.org/archive/html/avr-gcc-list/2008-07/msg00050.html

avr-libc's puts_P uses pgm_read_byte(), which gives no warning and is not
documented in the stdio portion of the manual. Maybe we can use
pgm_read_byte_far()? That would make the functions work on a larger range
of devices, with a small(?) performance penalty.

On Tue, Aug 16, 2016 at 2:56 PM, Tavish Naruka <tavishnar...@gmail.com>
wrote:

> Hi
>
> I'm linking a program as a bootloader with --section-start, everything is
> working fine, except that stdio functions with _P do not work as expected,
> once I link the same program with --section-start=0x00, it works just fine.
> I am not sure but it seems to me that only 16-bit addresses are working
> since only registers r24 and r25 are being used for the function calls.
> Here is the difference in the generated assembly:
>
> Function call is puts_P(NOT_PRESSED_STR).
>
> Linked at 0x00-:
>
> 000000e4 <NOT_PRESSED_STR>:
>   e4:   4e 6f 74 20 50 72 65 73 73 65 64 0a 00              Not Pressed..
>
>
>  1d6:   00 00           nop
>  1d8:   84 ee           ldi     r24, 0xE4       ; 228
>  1da:   90 e0           ldi     r25, 0x00       ; 0
>  1dc:   0e 94 f2 00     call    0x1e4   ; 0x1e4 <puts_P>
>
>
>  Linked at 0x1E000-:
>
>  0001e0e4 <NOT_PRESSED_STR>:
>    1e0e4:       4e 6f 74 20 50 72 65 73 73 65 64 0a 00              Not
> Pressed..
>
>    1e1d6:       00 00           nop
>    1e1d8:       84 ee           ldi     r24, 0xE4       ; 228
>    1e1da:       90 ee           ldi     r25, 0xE0       ; 224
>    1e1dc:       0e 94 f2 f0     call    0x1e1e4 ; 0x1e1e4 <puts_P>
>
> I haven't been able to find a workaround yet, so I'll use strings in
> initialized data section for now.
>
> --
> Regards
> Tavish Naruka
>



-- 
Regards
Tavish Naruka
_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
https://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Reply via email to