Would like to access all USBDM functionality from Java app

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Would like to access all USBDM functionality from Java app

691 Views
DaveA
Contributor III

Recently I went through the process of building the USBDM software from source.  (That was another long question-and-answer session to get it all worked out.) The main purpose of that exercise was to create the UsbdmJniWrapper.dll file. I had thought that this would provide access via a Java app to all of the USBDM functionality.  However this does not seem to be the case.  To be fair, the documentation does state "It allows java code to access basic functions.", and this can be taken to mean that beyond 'basic', there is no support.  The sample Java program lists only these native methods:

   private static native int init();

   private static native int exit();

   private static native int findDevices(int[] deviceCount);

   private static native int releaseDevices();

   private static native int openBDM(int deviceNum);

   private static native int closeBDM();

   private static native int getBDMDescription(char[] description);

   private static native int getBDMSerialNumber(char[] serialNumber);

   private static native int getBDMFirwareVersion(BdmInformation bdmInfo);

   private static native String getErrorString( int errorNum);

   private static native int getUsbdmPath(char[] serialNumber);

I'm not sure about that last one, as it is not listed in the header file for the C code that generates this DLL.

The point is though that I'd like to be able to actually access the target MCU via USBDM to do things like read/write registers/memory locations, etc. The only hint that this might be possible is the loading of library code in the sample Java program:

   static {

      System.loadLibrary("libusb-1.0");

      System.loadLibrary("usbdm.4");

      System.loadLibrary("UsbdmJniWrapper");

   }

Maybe I'm missing something, but does anyone know if there is a way to access all of the USBDM calls from Java with the currently provided code?  Or am I going to have to write C code to expand the 'UsbdmJniWrapper' library?

Tags (1)
0 Kudos
4 Replies

445 Views
pgo
Senior Contributor V

Hi David,

The Interface is very minimal.  It only provides the functionality necessary for the Codewarrior and Eclipse plugins.

I have uploaded a file to Sourceforge that contains a more complete implementation.   It also includes a (trivial) java application using the interface.

It is missing the Linux DLL at the moment.

Let me know if there is anything missing that you require.

bye

445 Views
DaveA
Contributor III

Alright, I've been working to use this new Java interface for the USBDM.  I have some questions:

1) On the S12X MCU series, the Condition Code register has an additional High byte, which is not present on the Standard HCS12 MCU series. Is there any special handling required to read/write this high order byte, or is it made to be transparent, and included with the current CCR routines?

Usbdm.readReg(Usbdm.Reg.HCS12_RegCCR);

Usbdm.writeReg(Usbdm.Reg.HCS12_RegCCR, CCR);

2) Maybe I'm missing the obvious, but are there calls to: a) clear all the target MCU Flash, b) clear just the EEPROM, and/or c) clear a specified PPAGE of Flash?

Thanks!

Dave

0 Kudos

445 Views
pgo
Senior Contributor V

Hi David,

I'm sorry but the USBDM functionality provided in the USBDM interface is very low level.  It does not include programming.

The programming utilities incorporate the programming algorithms but there is no API available.

On the HCS12 the CCR is not actually readable as a register.  The 'saved value' is read/written using the READ_BD and WRITE_BD functions.  These are mapped to the USBDM_Read/WriteDReg() interface so can be read in that fashion.

Reading the CCR using ReadReg is provided as a convenience.  It does not support the second byte because there is no easy way to determine if it exists (the USBDM interface doesn't know what device it's talking to).

USBDM_ReadReg(HCS12_RegCCR, regValue) <=>USBDM_ReadDReg(HCS12_DRegCCR, regValue)

Try USBDM_ReadDReg(HCS12_DRegCCR+1, regValue)

bye

0 Kudos

445 Views
DaveA
Contributor III

Thanks.  I saw the new file and am going through it.  I'll reply further once I've had an opportunity to go through it and play with it some.

0 Kudos