USBDM On Linux Does NOT Require CW

From DIY contraptions to sophisticated FreeEMS-specific designs! Plus general hardware development!
User avatar
MrOnion
QFP80 - Contributor
Posts: 45
Joined: Tue Jul 06, 2010 1:03 pm
Location: Espoo, Finland

Re: USBDM On Linux Does NOT Require CW

Post by MrOnion »

Installed the USBDM without CW, but using my own quick hack script (viewtopic.php?p=30882#p30882). Didn't know at the time Fred had already did this ;). There is a small difference though. I used the 4.10.3 version and there is no "Utilities" folder anymore, but instead it is "bin" now. Also "Device_data" is "DeviceData" and along with FlashImages they are now installed into /usr/local/share/usbdm instead of ~/.usbdm.

Got my BDM this week and I'm trying it out today. Tested USBDMs HCS12_FlashProgrammer first on winxp (32bit) and seems to work ok. On ubuntu (12.10 32bit) there is a problem. After the install with this "no cw" script the program starts, but gives an error:

Code: Select all

* Error loading devices
Failed to load device database
Reason: DeviceXmlParser::parseSecurity() - illegal size in securityInfo = 16
Current device = Shared data
It does not stop the application, but only affects the device database. The application detects my USB device correctly (in sudo), but the device pulldownmenu says "invalid database". So, the devicedata is either corrupt or there is a problem with the XML parser...

The DeviceData folder and files are ok. Used both binary and source dist ones and they are ok. No difference between them. Compiled a new programmer from source, but still the same problem. Checked the parseSecurity method and hardcoded the value to 16 to test things out. Worked, but now gives a similar error concerning check address or some shit...

Turns out the string value from xml to unsigned long conversion in causing this. Looked into the parser code and there are two strToULong methods separated by a preprocessor #if 0. Switched to the other one and it's way too broken to use...

What the method does is only the conversion:

Code: Select all

unsigned long value_t = strtoul(start, &end_t, 0);
This works as expected but the method is returning false because of errno.h. strtoul will turn errno into ERANGE if the value is out of range. In this case this does not happen, but someone is turning the errno != 0. There is a ERANGE check anyway after the conversion:

Code: Select all

if ((ULONG_MAX == value_t) && ERANGE == errno) { // too large
  printf("strToULong() - Number too large\n");
  return false;
}
Usually you reset the errno to zero before your call and this is done here, but it is commented out for some reason? If I release the comment on:

Code: Select all

// errno = 0;


It works. Everything is ok now. Devicedata is parsed ok, etc... Just wondering if anyone else if experiencing this? Why is this left in this kind of condition without people noticing? Weird... or is it just me?
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: USBDM On Linux Does NOT Require CW

Post by Fred »

Awesome debugging effort! :-) I might have just tried the older version given that others had and had had it work ;-)

Cool that you're up and running and thanks for sharing your headaches here for others to learn from. Perhaps point the author at this?

It'd be good if there was a bloatware-free install script available out of the box. It'd be straight forward for them to prompt you with a "got cw?" and proceed accordingly, or even just detect, not fail and install without it if not present and then warn the user.

Fred.
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: USBDM On Linux Does NOT Require CW

Post by Fred »

FYI, our Australian genius thinks it's a good idea to withdraw releases! WTF. He also thinks it's a good idea to force window size to be fixed, and then make it not big enough to actually use! Furthermore, it won't work on my debian mac mini at all, only on my eee. Thus to actually use my BDM I have to plug my monitor into my EEE. JESUS. Free software... where's the warranty? :-)

Because of the release withdraws, I'm caching old ones for you, check SF first, though, please...

http://stuff.fredcooke.com/USBDM_Linux_V4.9.tar.gz < 4.9.3 i think?
http://stuff.fredcooke.com/USBDM_Linux_V4.9.4b.tar.gz < works on EEE WITH a monitor plugged in...
http://stuff.fredcooke.com/USBDM_Linux_V4.10.3.tar.gz < unknown, beware...
http://stuff.fredcooke.com/USBDM_Linux_V4.10.4.tar.gz < johntramp is trying this one nowish?

sourceforge.net/projects/usbdm/files above links not clickable, on purpose...

Fred.
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
User avatar
DeuceEFI
LQFP144 - On Top Of The Game
Posts: 578
Joined: Thu Feb 25, 2010 3:57 am
Location: Gosport, IN USA
Contact:

Re: USBDM On Linux Does NOT Require CW

Post by DeuceEFI »

For those of you who have USBDM 4.9.3 or 4.9.4 and are unable to program the serial monitor due to the "Detect Chip" function not identifying your newer Freescale processor, here is the fix:

The older Freescale XDP512 processors have a "chip ID" of of "C410" or "C411"
but the newer processors have a "chip ID" of "C412" so the HCS12_FlashProgrammer doesn't know how to access the memory on the processor.

To correct this problem you will need to edit 2 files in the .usbdm/Device_data folder which can be found in your home folder. These two files list all the chip IDs and what processor they belong to so that the USBDM programmer knows how to access all of the memory locations.

These 2 files are:
.usbdm/Device_data/hcs12_devices.xml
.usbdm/Device_data/hcs12_devicesX.xml

Open each one with your favorite text editor and search for "XDP" then scroll down until you see:

<sdid value="0xC410" />
<sdid value="0xC411" />


then add a new line below the "0xC411" line that reads:

<sdid value="0xC412" />

so it should now look like this:

<sdid value="0xC410" />
<sdid value="0xC411" />
<sdid value="0xC412" />


then save the file and exit your text editor.

Make this change to the second file and save your change.

Now you are able to program the newer S912XDP512 (112 pin and 144 pin version) processors directly from Linux, still not having to use CW.

Enjoy :-)
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: USBDM On Linux Does NOT Require CW

Post by Fred »

Thanks Andy!
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
pishta
LQFP112 - Up with the play
Posts: 147
Joined: Wed Aug 28, 2013 6:07 am

Re: USBDM On Linux Does NOT Require CW

Post by pishta »

"...Fuck codewarrior, may its 2.7gig download of nasty encrypted binary installer crap rot in hell :-)..."

Tell us how you really feel... :lol2:

still putting around with the assembly. MAX chip was backordered and the MOSFETS called out are now under a different RoHS part number so its a little tedious tracking them down. Ill still dedicate a laptop to Linux so I can follow your command line references.
User avatar
DeuceEFI
LQFP144 - On Top Of The Game
Posts: 578
Joined: Thu Feb 25, 2010 3:57 am
Location: Gosport, IN USA
Contact:

Re: USBDM On Linux Does NOT Require CW

Post by DeuceEFI »

For those of you who have USBDM 4.9.3 or 4.9.4 for Windows and are unable to program the serial monitor due to the "Detect Chip" function not identifying your newer Freescale processor, here is the fix:

The older Freescale XDP512 processors have a "chip ID" of of "C410" or "C411"
but the newer processors have a "chip ID" of "C412" so the HCS12 Programmer doesn't know how to access the memory on the processor.

To correct this problem you will need to edit 2 files:

For 32bit Windows:
The files are in the C:/Program Files/pgo/USBDM 4.9.3/Device_data folder. These two files list all the chip IDs and what processor they belong to so that the USBDM programmer knows how to access all of the memory locations.

These 2 files are:
  • C:/Program Files/pgo/USBDM 4.9.3/Device_data/hcs12_devices.xml
  • C:/Program Files/pgo/USBDM 4.9.3/Device_data/hcs12_devicesX.xml
For 64bit Windows:
The files are in the C:/Program Files (x86)/pgo/USBDM 4.9.3/Device_data folder. These two files list all the chip IDs and what processor they belong to so that the USBDM programmer knows how to access all of the memory locations.

These 2 files are:
  • C:/Program Files (x86)/pgo/USBDM 4.9.3/Device_data/hcs12_devices.xml
  • C:/Program Files (x86)/pgo/USBDM 4.9.3/Device_data/hcs12_devicesX.xml
Open each one with your favorite text editor and search for "XDP" then scroll down until you see:

<sdid value="0xC410" />
<sdid value="0xC411" />


then add a new line below the "0xC411" line that reads:

<sdid value="0xC412" />

so it should now look like this:

<sdid value="0xC410" />
<sdid value="0xC411" />
<sdid value="0xC412" />


then save the file and exit your text editor.

Make this change to the second file and save your change.

Now you are able to program the newer S912XDP512 (112 pin and 144 pin version) processors directly from 32bit and 64bit Windows, still not having to use CW.

Enjoy 8-)
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: USBDM On Linux Does NOT Require CW

Post by Fred »

Latest debs still have these issues FWIW. Not able to get mine to talk, but not confident it's plugged in correctly, either. Did manage to use the new tool to upgrade firmware.

Writing the above made me realise something, so I typed --help and then read through and you need to run it like this: UsbdmFlashProgrammer -target:HCS12
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
Post Reply