Adapting to coldfire v2

Help
yuhyuh
2010-10-08
2012-07-03
  • yuhyuh

    yuhyuh - 2010-10-08

    Hi,

    Ive been looking for a plugin of this kind to use for reading the internal
    memory registers on a Coldfire v2 processor (MCF5282 board).

    The problem is as I understand, that the Coldfire is big-endian while this
    plugin is designed for little-endian systems.

    Im not very experienced in embedded systems nor eclipse plugin design, so my
    question is whether it would be possible to adapt your plugin to support a
    big-endian processor? if so, could you give some advice on where the changes
    would need to be made in the code?

    Thanks!

    yuh

     
  • Raven Claw

    Raven Claw - 2010-10-08

    i only tested the convertbig2little method...the rest is untested...

    it converts the read data and also converts before writing back

    if you can confirm that this is working, i will add an optional attribute
    where bigendianess can be specified.

    -Robert

    Index: src/org/eclipse/cdt/embsysregview/views/EmbSysRegView.java
    ===================================================================
    --- src/org/eclipse/cdt/embsysregview/views/EmbSysRegView.java  (revision 7)
    +++ src/org/eclipse/cdt/embsysregview/views/EmbSysRegView.java  (working copy)
    @@ -61,6 +61,7 @@
     import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
     import org.eclipse.cdt.debug.mi.core.command.MIDataWriteMemory;
     import org.eclipse.cdt.debug.mi.core.output.MIInfo;
    +import org.eclipse.cdt.embsysregview.views.Utils;
    
     /**
      * Generates a View, displaying Registers for an Embedded Device
    @@ -466,7 +467,8 @@
        {
            CommandFactory factory = miSession.getCommandFactory();
    
    -           String value = "0x" + Long.toHexString(lvalue);
    +           
    +           String value = "0x" + Long.toHexString(Utils.convertbig2little(lvalue));
                String address = Long.toString(laddress);
                MIDataWriteMemory mw = factory.createMIDataWriteMemory(0,
                    address, MIFormat.HEXADECIMAL, 4, value);
    Index: src/org/eclipse/cdt/embsysregview/views/TreeRegister.java
    ===================================================================
    --- src/org/eclipse/cdt/embsysregview/views/TreeRegister.java   (revision 7)
    +++ src/org/eclipse/cdt/embsysregview/views/TreeRegister.java   (working copy)
    @@ -24,6 +24,7 @@
     import org.eclipse.cdt.debug.mi.core.MISession;
     import org.eclipse.cdt.debug.mi.core.MIException;
     import org.eclipse.cdt.debug.mi.core.output.MIMemory;
    +import org.eclipse.cdt.embsysregview.views.Utils;
    
     public class TreeRegister extends TreeParent{
        private long old_value;
    @@ -121,7 +122,7 @@
                               if (info != null) {
                                  MIMemory[] memories = info.getMemories();
                                  long[] val = memories[0].getData();
    -                             value = val[0];
    +                             value = Utils.convertbig2little(val[0]);
                               }
                            } catch (MIException e) {
                                //throw new MI2CDIException(e);
    Index: src/org/eclipse/cdt/embsysregview/views/Utils.java
    ===================================================================
    --- src/org/eclipse/cdt/embsysregview/views/Utils.java  (revision 0)
    +++ src/org/eclipse/cdt/embsysregview/views/Utils.java  (revision 0)
    @@ -0,0 +1,24 @@
    +package org.eclipse.cdt.embsysregview.views;
    +
    +public class Utils {
    +   /**
    +    * Converts from big endian to little endian and the other way round
    +    * 
    +    * @param value 32 bit big endian value
    +    * @return 32 bit little endian value
    +    * 
    +    * In:  0xAABBCCDD
    +    * Out: 0xDDCCBBAA
    +    * 
    +    */
    +   public static long convertbig2little(long value) {
    +       long a,b,c,d;
    +       
    +       a=value>>24;
    +       b=(value & (~0xFF00FFFFL))>>8;
    +       c=(value & (~0xFFFF00FFL))<<8;
    +       d=(value & (~0xFFFFFF00L))<<24;
    +
    +       return( a | b | c | d );
    +   }
    +}
    
     
  • Raven Claw

    Raven Claw - 2010-10-12

    I accidentialy published a version with this patch in place.

    If you want to test it with your processor, grab the released Version 0.1.5

    -Robert

     
  • yuhyuh

    yuhyuh - 2010-10-12

    Hi and thanks for the help!

    Ive had some time to play around with it now, but im not sure its working
    correctly. I didnt notice you had included it in the 0.1.5 though, so I might
    have double did the conversions some times (I'll grab a fresh version
    tomorrow)

    Example:

    Adress 0x10000220 should have the value 0x0000801B, but the converted output i
    get is 0x00001B80. If i disable the conversion in TreeRegister i get
    0x801B0000 as output.

    Since this particular register is 16-bit long i could solve it by removing
    half the bits (to get 0x801B), but still...

    should be relatively easy to fix this though, I'll look into it tomorrow.

    Thanks again!

     
  • yuhyuh

    yuhyuh - 2010-10-14

    Sorry, my mistake. It was actually supposed to be 0x801B0000 (with bits 0-15
    reserved).

    So, I've been testing a lot of registers and it seems to work correctly, but
    as mentioned in the post above, only if I just convert the bits in setRegister
    in EmbSysRegView. Converting in updateValue in TreeRegister aswell seems to
    "double-do" the conversion.

    One more thing, the description text for fields doesnt seem to appear. Could
    be useful for describing the function of each bit.

     
  • Raven Claw

    Raven Claw - 2010-10-14

    Hi, I dont understand the double conversion thing. I guessed that when i have
    a variable with 0xAABBCCDD and i write it to an register it has to be stored
    as 0xDDCCBBAA. And if the register has the value 0xDDCCBBAA I should convert
    it to 0xAABBCCDD for displaying and manipulating in the view. Am I wrong with
    this assumption ?

    On bit fields there is no single line description (attribute). But there is an
    Element, that allows multiline descriptions. You need to hover for 200ms over
    the descrption row (and column) to get the description in a tool tip popup.

    The "normal" single line description field is used for interpretations of the
    current bit-field value. I only did one example on this in the lm3s8962.xml
    ... on the eval board is a led connected to one pin of an gpio port...and when
    you look in the view in the description field...you can see there if the led
    is on or off ...

    This is more helpfull for example a timer configuration field or something
    else where it shows you the current setting.

    <field board_id="LM3S8962_EVAL" name="LED1" description="" bitoffset="0" bitlength="1">
        <interpretation key="0" text="Led 1 off"/>
        <interpretation key="1" text="Led 1 on"/>
    </field>
    

    -Robert

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks