Dangerous Prototypes

Other projects => Open Bench Logic Sniffer => Topic started by: dogsbody on January 09, 2011, 01:35:33 am

Title: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: dogsbody on January 09, 2011, 01:35:33 am
[-- Edit Jan 9th - Added source code], [-- Edit Jan 10th - Added github repository], [-- Edit Feb 6th - Added support for programming PIC firmware], [ -- Edit Feb 8th - Added flexibility for PIC firmware variations & now detects if OLS already in bootloader mode when starting.], [ -- Edit Feb 9th - Removed complaint about 8 byte difference in 2.6 firmware.  Fixed stupid build problem with 2.01], [ -- Edit Mar 14th - Fixed Logic Sniffer detection for Windows Vista & 7.]
[ -- Edit May 14th, 2012 - Updated Flash ROM Table.]

Hi,
Since I've been busy on fpga tweaking I decided to make myself a
polished Windows GUI OLS loader. 

I've attached screen images & a ZIP with the EXE.   Supports HEX,
MCS (same as HEX), BIN (binary), -and- Xilinx native BIT files.

It can update either the FPGA ROM file, or the PIC firmware.  Simply pick the
image file, and olswinloader handles the rest.  No knobs, or extra checkbox
required!

Source is available below and on Github:  https://github.com/ied/olswinloader (https://github.com/ied/olswinloader)

Enjoy! 
-- IED
Title: Re: New Windows OLS FPGA image loader...
Post by: ian on January 09, 2011, 09:28:57 am
Very nice! I really like the auto port detect, it is such a pain to go to the device manager every time to see what port is being used. Ill use this app for sure.

There are a couple new rom additions for the v1.04 boards that are not in svn yet, ill try to get them committed or post the data here.

Ols-loader was made by robots from pirate-loader made by pppd. There is no stated license, but i think we can ( and do) consider it gpl.
Title: Re: New Windows OLS FPGA image loader...
Post by: robots on January 09, 2011, 10:52:55 am
Let's make it GPL :-) I should probably patch the source to include the GPL statement and other stuff. (one day i will)
Title: Re: New Windows OLS FPGA image loader...
Post by: dogsbody on January 10, 2011, 03:39:39 am
[quote author="ian"]
There are a couple new rom additions for the v1.04 boards...[/quote]

No problem.   If it's ok, a short post here would probably be easier.   I made some changes to the original code, to return error codes instead printing error messages.

Also, I've attached source now (in first message).   It includes a revised ols_loader that uses the new plumbing if your interested. 

Cheers!
-- IED
Title: Re: New Windows OLS FPGA image loader...
Post by: ian on January 10, 2011, 08:20:02 am
Code: [Select]
const struct pump_flash_t PUMP_Flash[] = {
{
"x1fx24x00x00",
264, // size of page
2048, // number of pages
"ATMEL AT45DB041D"
},
{
"x1fx23x00x00",
264, // size of page
1024, // number of pages
"ATMEL AT45DB021D"
},
    {
"xefx30x13x00",
256, // size of page
1024, // number of pages
"WINBOND W25X40"
},
    {
"xefx30x12x00",
256, // size of page
1024, // number of pages
"WINBOND W25X20"
},
};

Thanks for the update. Here's the ROM struct.
Title: Re: New Windows OLS FPGA image loader...
Post by: dogsbody on January 10, 2011, 08:33:51 am
[quote author="ian"]
Thanks for the update. Here's the ROM struct.
[/quote]

Got it.  Easy update.   Quick question...  Since the "WINBOND W25x40" is a 4MBit device , shouldn't it have 2048 pages?  
-- IED
Title: Re: New Windows OLS FPGA image loader...
Post by: ian on January 10, 2011, 08:37:02 am
Probably :) The OLS only uses the first 2MBIT and I don;t think the app does anything with that value (beside range check?), so it shouldn't cause issues, but I updated it in the source anyways.
Title: Re: New Windows OLS FPGA image loader...
Post by: dogsbody on January 10, 2011, 09:31:31 am
The loader is now updated with the latest flash rom support.  :)
-- IED
Title: Re: New Windows OLS FPGA image loader...
Post by: robots on January 10, 2011, 09:45:46 am
You should make it part of some Source tracking system, like git, svn .... It gets really annoying managing the source in forum :-)
I personally suggest git (github, gitorious, unless you have your own).
Title: Re: New Windows OLS FPGA image loader...
Post by: dogsbody on January 10, 2011, 10:47:38 am
We'll that was fun...  Never created a public repository before.   First time for everything I guess.  
Anyway, here you go:

https://github.com/ied/olswinloader (https://github.com/ied/olswinloader)

-- IED
Title: Re: New Windows OLS FPGA image loader...
Post by: robots on January 10, 2011, 10:52:47 am
You will appreciate it when it comes to patches :-)
Title: Re: New Windows OLS FPGA image loader...
Post by: dogsbody on February 06, 2011, 01:05:17 pm
I've updated my Windows GUI OLS loader to support programming PIC firmware.  There are no extra knobs or buttons needed. 

Just select an image file, and the loader knows where to put it.  Small files for the PIC, big files for the FPGA.

Cudos to robots for discovering the trick to fast PIC updates.  See first post (http://http://dangerousprototypes.com/forum/viewtopic.php?f=23&t=1636) for images & source code.

Enjoy!
-- IED
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: ian on February 08, 2011, 09:24:37 am
This utility is ridiculously handy! I LOVE it!

I added a copy to the list of update utilities.
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: dogsbody on February 08, 2011, 10:42:30 am
Glad you like it!

Unfortunately I just found it didn't like the new 2.6 PIC firmware.  Doh.    The firmware was 8 bytes too small, and the loader too hyper-sensitive.  So I've added a little flexibility there.  Now it complains, but will continue.

Also, the image loader now detects a Logic Sniffer in HID mode from the start.  Just in case the Logic Sniffer hiccuped, or doesn't have valid firmware, etc...

I apologize to anyone snafu-ed by this.  If you short the PGC/PGD pins & hit the reset button, you'll kick the OLS into bootloader mode.  Remove the short & the 2.01 loader will see & update it then. 
-- IED
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: ian on February 08, 2011, 10:44:44 am
Careful, those last 8 bytes are the config words, we need to protect that page because the firmware ships without them, and there are both 20mhz and 16mhz crystal OLSes.
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: dogsbody on February 08, 2011, 10:51:14 am
I know.  It won't erase, write (or even verify) the first 2K, or last 1K byte.  Lotsa margin.

All previous firmwares I tried were 16K exactly, so I sorta assumed it would always be that way...
-- IED
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: ian on February 08, 2011, 10:53:50 am
Got ya, thank you. I exported this one without the config bits, maybe I forgot a time or two previously (that's not great...but I guess we know the apps are all protecting the bootloader well).
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: dogsbody on February 08, 2011, 11:07:16 am
Yup.  Only time I've ever walloped the config bits is with my PICKit.  16Mhz image on a first-run 20Mhz board (with no bootloader) didn't work so well.  This was back when I was first getting my head around everything.

Though I'm not so sure fw_update protects anything.  It thinks the program area size is 0x6000.  Maybe the bootloader is doing the protecting?

I only put in the check in the first place, because I figured if a firmware -was- corrupted, it'd be highly... inconvenient. :-)

[s:]Anyway 2.01 should be plenty robust now.[/s:]
-- IED
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: ian on February 08, 2011, 11:16:28 am
There isn't currently any bootloader based protection. I'll add address evaluation to the bootloader. I'm much more comfortable on the uC than desktop programming, I barely got fw_update to compile and put in a few minor mods against the 18f2550 version (though I can compile robot's version in mingw ok).
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: dogsbody on February 08, 2011, 11:35:50 pm
[quote author="ian"]I'll add address evaluation to the bootloader.[/quote]
Definitely a good idea.

btw, belated thanks for the posting in "OLS files and utilities (http://http://dangerousprototypes.com/forum/viewtopic.php?f=23&t=1780#p17489)"!  Can you edit it have the 2.01 release?    I'd like to avoid burning anyone who tries updating to 2.6 firmware... :-(

Thanks!
-- IED
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: ian on February 09, 2011, 08:17:34 am
Updated.
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: kandos on February 09, 2011, 11:26:31 am
[quote author="dogsbody"][quote author="ian"]I'll add address evaluation to the bootloader.[/quote]
Definitely a good idea.

btw, belated thanks for the posting in "OLS files and utilities (http://http://dangerousprototypes.com/forum/viewtopic.php?f=23&t=1780#p17489)"!  Can you edit it have the 2.01 release?    I'd like to avoid burning anyone who tries updating to 2.6 firmware... :-(

Thanks!
-- IED[/quote]

Unfortunately i got burnt yesterday before i saw this (oh well that will teach me for jumping in to quickly) and  i did see the warning in the winloader dialog box but went ahead anyway as i do have a pickit2 and thought it wouldn't be much of a problem to reflash the bootloader if i had to .

I had upgraded to meta4 core and then  went to upgrade pic to v2.6 and it crashed and appeared to break the bootloader so  i got out my pickit2 soldered a header on the board and flashed this bootloader OLSv1-DUMP-FW21BL2-16MHz and that appeared to work as now OLS is working again.

There is still a problem however, i now can no longer update the pic with any version of fw_update or either version of ols_winloader.With fw_update it tells me device not found and ols_winloader v2.01 states that the file i am trying to burn is 8 bytes too small and if i proceed anyway i get error reading file failed file to large for fpga flash rom.V2.0 just says error writing pic firmware. Windows is seeing it as a comm port with vid 04d8 & pid fc92  .It is also  possible to  flash any  version of the firmware using pickit2 and they work.
 
 Ian mentioned
"Careful, those last 8 bytes are the config words, we need to protect that page because the firmware ships without them, and there are both 20mhz and 16mhz crystal OLSes."
Could this be the problem , i really am not sure because i thought that the config bytes are set in the code i.e in the hex file i burnt.

My board is marked v1.01 with 16mhz crystal.

Any ideas how to solve this
Thanks
Nick
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: dogsbody on February 09, 2011, 12:14:47 pm
2.0 would erase the firmware, and balk on the latest firmware 8-byte difference.  Real helpful that (my bug, not the firmware).  v2.01 should have fixed it, and my local copy worked fine.  However...  I just downloaded the image on the site to double-check and it doesn't match my local copy.  What the heck?!  Somehow a non-final image got in there.  Argh!!

I've uploaded 2.02, which -is- correct.  Also stops complaining about the 8 byte difference now.

fyi, the bootloader & config bits were never touched.  Just a question of getting firmware downloaded.  The 2.0/2.01 releases would work fine with earlier firmware.  fw_update should have worked also.

Nick, use your PICKIT to install the bootloader -only-.  If you install firmware using PICKIT, you won't have a bootloader anymore.  Once the bootloader is installed,  plug the Logic Sniffer into your PC.    Short the PGC/PGD pins & hit the reset button.  Will appear as a HID device.  If it doesn't appear, verify the bootloader matches the oscillator on your board.  There are 16Mhz & 20Mhz versions.

Now either fw_update or olswinloader will see it, and be able load firmware.  I've thoroughly tested 2.02.  With & without firmware it'll work.  Even aborted in the middle of an update, and it'll recover.  Worst you'll need to do is short the PGC/PGD pins.

Ian & everyone, I'm so very sorry about this headache... 
-- IED
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: kandos on February 09, 2011, 12:46:18 pm
Thanks dogsbody for the quick reply just tried it and everything now works fine.I really do not know what happened originally but i should have realised that burning just the firmware with the pickit2 would erase the bootloader,my only excuse is it was a long hot day at work and the A/C had broken down so i think my brain was a bit cooked.Anyway thanks again for your help and contribution to the site.
Nick
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: dogsbody on February 09, 2011, 12:47:45 pm
Cooked brains.  A perfect explanation for my 2.01 fiasco!  Cheers! :-)
-- IED
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: jack.gassett on February 09, 2011, 06:45:56 pm
Awesome, I'll include this in the Windows installer once we are ready to move beyond the test release to a full release.

Jack.
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: ian on February 21, 2011, 02:05:18 pm
I split the winbond read discussion to here:
viewtopic.php?f=23&t=1901&p=18273#p18273 (http://dangerousprototypes.com/forum/viewtopic.php?f=23&t=1901&p=18273#p18273)
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: Rubu on March 02, 2011, 09:25:46 pm
This makes updating so easy and fast, great!
Found one minor 'bug' though, in the screenshot, it shows the OLS as "COMx (Logic Sniffer CDC-232)"
But for me it says "COMx (Port_#0001.Hub_#0005)".
So instead of displaying the bus reported device description (Logic Sniffer CDC-232, It does send that through just fine) it displays the location information.
Not really a problem as updating went fine, but if I would've had more COMports connected it would've been a hassle.
Other than that, great work (on the verilog core, too)!
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: dogsbody on March 02, 2011, 09:33:55 pm
Doh.  What OS version are you running?  (ie: XP, Vista, Win7, etc...)

The description comes from Windows, but I may need a better USB database parser.  Thanks for the report!
-- IED
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: Rubu on March 02, 2011, 10:12:21 pm
Sorry, just realized I forgot to post what windows version too! I'm on Win7 64Bit.
Gave it a quick check on WinXP and that worked fine.
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: dogsbody on March 14, 2011, 10:43:39 am
Here is a version that properly detects/describes the Logic Sniffer on Windows XP, Vista & Win7.  Turned out to be really quite annoying to fix.

The registry entry for the Logic Sniffer had a description line stating "Logic Sniffer".  However, none of the setupapi functions would return that.  Only "Communications Port" or the location info.  XP was fine.  Not Vista or Win7.  Nice improvement there Microsoft.  Ug. 

So now ols_winloader plies the depths of the USB database, and grabs the product description direct.

Cheers!
-- IED
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: octal on May 06, 2011, 02:35:38 pm
Would it not be easier if we switch from using CDC to HID?
With HID you can easily detect the device under any OS (at least the APIs are well documented everywhere under any version of Winxxx)!
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: dogsbody on May 06, 2011, 08:41:17 pm
A HID based search for the OLS in the USB database is exactly what I do now.  It works fine, but takes a lot of setup for the API call's, and is noticeably slower.

I could have cheated & hardcoded the strings, but I was feeling extremely annoyed with Microsoft, and d*mn determined to find a way to get that description.  :-)
-- IED
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: honken on May 06, 2011, 09:48:40 pm
Not having looked at your detection sw, what's wrong with searching for vid/pid? It is supposed to be unique for the ols.

Then again,  I have only used pyUSB for host software, which is great by the way.

I beleave your trouble lies in that cdc-acm is used as an abstraction layer. It is supposed to hide all usb details from user (software). It lays the responsibilty on the user (human) to correctly choose the right com port

I have an dfu bootloader in the works. All generic sw written but bug ridden. Needs some cpu specific flash write functions as well as code guarding and general rootkitness implemented.

Dfu works by adding an extra interface on the device for handeling the fw updates.

It has been a painfully slow development. At least three month and some 300 lines of code without any tries to even compile asI know it wouldn't work. But if there is intrest to follow I could branch the stack in cvs and add the dfu part.

[EDIT] Just realized this post is probably in the wrong topic. Desregard and reread with another state of mind. It is friday knight, shrimps (marine not logic) and white wine (drink not os abstraction)...
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: octal on May 06, 2011, 10:02:21 pm
[quote author="dogsbody"]A HID based search for the OLS in the USB database is exactly what I do now.  It works fine, but takes a lot of setup for the API call's, and is noticeably slower.

[/quote]

Why looking for HID device in registry or db?
If you know your VID/PID, you can "find" your device directly, with a single function call. Why do you want to look at it in registry?
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: dogsbody on May 06, 2011, 10:11:55 pm
I'm not looking in the registry.  I'm enumerating the USB device tree.  Also HID was poor choice of words on my part.  HID is a type of USB device & a mode of the OLS can operate in, different from the COM port.

The VID/PID of the OLS is what is used to search the USB database.  Enumerating root nodes, then any discovered hubs & endpoints, repeatedly enumerating those for more devices, etc...  until finding an OLS. 

I'm unaware of any single function call able to return the true USB description (& not some helpfully Windowized text), that works on XP/Vista & 7.  Then again, this was my first foray into USB hell.
-- IED
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: octal on May 06, 2011, 10:45:46 pm
[quote author="dogsbody"]HID is a type of USB device & a mode of the OLS can operate in, different from the COM port.
-- IED[/quote]
This is what I said, if we change the communication mode from CDC (virtual com port) to HID (Human Interface Device like key or mouse), we can do it quite easily.
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: dogsbody on May 07, 2011, 04:16:30 am
Ok... sorry.  Just being a little slow.  Haven't thought about this thing for a couple months. 

There are a few issues... 

First, it's hard to get away from the COM port.  The command to switch into bootloader mode is issued over the COM port.  So you have to enumerate the serial ports anyway. 

Next, you must query the hardware-id to verify the correct VID/PID.  Don't want to issue anything to a non-OLS. 

Next, issue the bootloader switch command, which causes the OLS to disconnect & reconnect into HID mode.  So Windows goes be-doop, do-beep whenever starting your tool.  Possibly multiple times if you have multiple OLS's hooked up.   

Next, if I remember correctly, the OLS has a different VID/PID in bootloader mode with a different description.  So you won't get the "CDC-232 Logic Sniffer" description anyway.  Doh.

Lastly, if the user exits your tool you need to restore the serial port mode (another disconnect/reconnect).  Otherwise the user would have to hit the reset button.  Doesn't strike me as user friendly.   

One last thought...  does the PIC bootloader even support updating the fpga flash chip?  Thought it was only for updating firmware.
-- IED
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: octal on May 07, 2011, 10:48:22 am
Hi Dogsbody,
we can simply use the PICKit2 Pins on the OLD and add a jumper on them, then when user resets the PIC it goes in bootloader mode. After all, bootloader mode is not for use 50 times per day, it will be used only once each firmware release. I think a special command to make OLS switching to bootloader mode is useless.
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: dogsbody on May 07, 2011, 11:45:13 am
When working on new FPGA images, I easily reflash my OLS a dozen+ times/day.  Having to fool around with jumpers in addition to the reset button would be a real hassle.  Avoiding bootloader mode whenever possible is probably a lot faster also.

I specifically wrote ols_winloader to make -my- life easier during fpga development.  If other people find it useful, that's a bonus.  :-)

My current method for obtaining the OLS product description is a pain, but it works, so I'm not inclined to tempt fate.

However, if you come up with a cleaner/faster method of fpga image programming I'll definitely be interested.

Cheers!
-- IED
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: ian on May 07, 2011, 11:49:43 am
Quote
One last thought... does the PIC bootloader even support updating the fpga flash chip? Thought it was only for updating firmware.

You're right, the bootloader is quite small (fits in the first few pages of flash) and it only does the firmware upgrades. If the bootloader did the flash updates too, we couldn't add support for new ROM chips without a bootloader update.

The command to jump to bootloader helps people who don't have the ICSP header, it also makes an all-in-one upgrade app possible.

I really like this app, I use it for a lot of FPGA development :) Firmware stuff though, is usually done directly with a debugger.
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: baxev2005 on January 15, 2012, 08:53:12 pm
Excelent tool. I was afaraid to upgrade, seemed too complicated to me, until I tried your tool. Everything went ok, PIC & FPGA firmware were upgraded without a sinlge problem. Use Win XP. Many many thanks
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: firehopper on May 14, 2012, 07:33:30 pm
this program is nice but does not support the newest flash chips found on some of the newer OLS boards gotten from linksprite.

windbond w25x80

ef 40 14 00
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: dogsbody on May 14, 2012, 09:02:32 pm
Thanks for the heads up!

It's weird... I updated olswinloader (to v2.04) with the latest table nearly a year ago (May 19th, 2011).  Could have sworn I uploaded it to the forum, but it was still showing 2.03.    v2.04 definitely has the "ef 40 14 00" sequence at least.

I've also got a little support page for it here:  http://mygizmos.org/ols/olswinloader.html (http://mygizmos.org/ols/olswinloader.html).

Hope this helps!
-- IED
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: firehopper on May 14, 2012, 11:06:54 pm
yes it did :) thanks I found my way to there somehow and got it downloaded, works good now :) thanks :)
Title: Re: New Windows OLS FPGA (& PIC firmware!) image loader...
Post by: timotet on March 11, 2014, 10:39:07 pm
Hi,

Last night I went to update my OLS and have seemed to make it inoperable.
I used the winloader v2.04 to do the updating, which is a breeze to use. Awesome work on that one.
I downloaded the latest update from the gadget factory, which is ols-0308.
When using the winloader I selected the pic firmware v3.0 and winloader reported success on that upload.
The problem is when I try to update the fpga to logic_sniffer_3.07-Demon-Core.mcs,
winloader makes it to about 90% then errors and says it fails to enable run mode.

Now when using the latest client software OLS v0.9.7 to detect the OLS it says detection failed and returns null!
So is my OLS done? I hope not I really like it.
Any info on this would be much appreciated.
Thanks

Edit: After messing around with the winloader a little more I discovered that the firmware for the fpga is loading fine.
For some reason the alarm was being generated when winloader tried to switch the OLS into run mode.
I disabled the check box for that in the advanced settings dialog in winloader and the fpga updated 100%.

The client software still returns null but the OLS seems to be capturing like it should. Awesome.