bugAVR C Runtime Library - Bugs: bug #25120, pgm_read_*_far() functions cause...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #25120: pgm_read_*_far() functions cause incorrect usage of the Z pointer for RAM access in ATxmega series

Submitter:  Luke Morrison <lfmorrison>
Submitted:  Thu 18 Dec 2008 03:35:25 PM UTC
   
 
Category:  Header Severity:  5 - Blocker
Priority:  9 - Immediate Item Group:  Header files
Status:  Fixed Assigned to:  arcanum
Percent Complete:  100% Open/Closed:  Closed
Release:  Any Fixed Release:  1.6.6

Thu 18 Dec 2008 03:35:25 PM UTC, original submission:  

The pgm_read_*_far() functions manipulate the RAMPZ register but do not restore it when they are finished.

This behavior is usually safe for any part with 64 KiB or less of data memory address space, because the RAMPZ register is only ever used in relation to the ELPM instruction.  Saving and restoring the RAMPZ register would normally be an unnecessary waste of cycles and Flash in such circumstances.

However, with the ATxmega series of devices, the RAMPZ register is also used every time any indirect data memory access happens through the Z pointer via the normal LD and ST instructions.  As soon as one of the pgm_read_*_far() functions is invoked, the RAMPZ register will be left in a modified state, rendering any subsequent compiler-generated indirect access of data memory through the Z pointer invalid.  This also makes pgm_read_*_far() interrupt-unsafe on such devices.

Possible fixes include:
1) Modify the pgm_read_*_far() functions to save and restore the RAMPZ register if the functions are used in a device which also uses RAMPZ as part of its normal indirect data access.
2) Modify GCC so that it never uses the Z pointer to indirectly access data memory on a device which also uses RAMPZ as part of its normal indirect data access.
3) Modify GCC to set the RAMPZ register appropriately (initially this might mean simply zeroing it) every time it begins accessing data memory through the Z pointer on a device which uses also RAMPZ as part of its normal indirect data access.

Luke Morrison <lfmorrison>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by arcanum (Updated the item)
  • -email is unavailable- added by lfmorrison (Submitted the item)
  •  

    Follow 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2009-03-01 arcanum StatusNone Fixed
        Percent Complete70% 100%
        Open/ClosedOpen Closed
        Fixed ReleaseNone 1.6.6
    2009-03-01 arcanum Percent Complete30% 70%
    2009-02-28 arcanum Severity3 - Normal 5 - Blocker
    2009-02-27 arcanum Priority5 - Normal 9 - Immediate
        Percent Complete0% 30%
        Assigned toNone arcanum

    Back to the top

    Powered by Savane 3.14-d582.
    Corresponding source code