Bootloader_Utils 64-bit dll!!!!

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
ErNo_1148106
Level 4
Level 4
First solution authored 50 replies posted 25 replies posted

Hi All,

Is there a bootloader_utils.dll for 64-bit windows? I cant seem to find one anywhere... Is there an app note to create one? I have the dll for 32-bit windows and it works great but doesn't work for 64-bit machines. I get an error message:

See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box. ************** Exception Text ************** System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) at UARTBootloaderHost.Bootloader_Utils.CyBtldr_Program(String file, Byte[] securityKey, Byte appId, CyBtldr_CommunicationsData& comm, CyBtldr_ProgressUpdate update) at UARTBootloaderHost.Form1.Bootload_Click(Object sender, EventArgs e) in E:\Memory Key Backup files\Laser GRBL LX4 Bootloader Host\AN68272 VS GUI\AN68272\UART Bootloader Host GUI\UARTBootloaderHost_Source_Code\UARTBootloaderHost\Form1.cs:line 267 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) ************** Loaded Assemblies ************** mscorlib Assembly Version:

4.0.0.0

Win32 Version: 4.8.4180.0 built by: NET48REL1LAST_B CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll ---------------------------------------- UARTBootloaderHost Assembly Version:

1.0.0.0

Win32 Version:

1.0.0.0

CodeBase: file:///C:/Users/User/Documents/UARTBootloaderHost.exe ---------------------------------------- System.Windows.Forms Assembly Version:

4.0.0.0

Win32 Version: 4.8.4150.0 built by: NET48REL1LAST_C CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll ---------------------------------------- System Assembly Version:

4.0.0.0

Win32 Version: 4.8.4001.0 built by: NET48REL1LAST_C CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll ---------------------------------------- System.Drawing Assembly Version:

4.0.0.0

Win32 Version: 4.8.3752.0 built by: NET48REL1 CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll ---------------------------------------- System.Configuration Assembly Version:

4.0.0.0

Win32 Version: 4.8.4190.0 built by: NET48REL1LAST_B CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll ---------------------------------------- System.Core Assembly Version:

4.0.0.0

Win32 Version: 4.8.4180.0 built by: NET48REL1LAST_B CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll ---------------------------------------- System.Xml Assembly Version:

4.0.0.0

Win32 Version: 4.8.3752.0 built by: NET48REL1 CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll ---------------------------------------- LBIndustrialCtrls Assembly Version:

2.1.0.0

Win32 Version:

2.1.0.0

CodeBase: file:///C:/Users/User/Documents/LBIndustrialCtrls.DLL ---------------------------------------- ************** JIT Debugging ************** To enable just-in-time (JIT) debugging, the .config file for this application or computer (machine.config) must have the jitDebugging value set in the system.windows.forms section. The application must also be compiled with debugging enabled. For example: <configuration> <system.windows.forms jitDebugging="true" /> </configuration> When JIT debugging is enabled, any unhandled exception will be sent to the JIT debugger registered on the computer rather than be handled by this dialog box.

What steps do I need to do to create one and if I can't how do I change the code for it to work in a 64-bit OS.

All help is greatly appreciated and this is time sensitive as well!!!

Thanks,

Eric

0 Likes
6 Replies
KyTr_1955226
Level 6
Level 6
250 sign-ins 10 likes given 50 solutions authored

The process of building Bootloader_Utils.dll from the source included with your PSoC Creator installation is described as part of this AppNote:

https://www.cypress.com/documentation/application-notes/an73503-psoc-usb-hid-bootloader

However, I don't believe it is meant to be built for x64, only win32.  The problem you might be running into is attempting to use the 32-bit bootloader_utils.dll with an application targeted for x64.  Assuming you are using Visual Studio, try adjusting your build configuration to build your Bootloader Host application for "x86" (32-bit) rather than "x64" or "Any CPU".

x86 applications should have absolutely no trouble running in a 64-bit environment.

0 Likes

Hi KyTr,

Would .Net framework not being installed on the target computer cause this issue as well? I've tried several configurations as x86 debug and release with no luck. I guess I could try installing the .Net framework and see if that solves my problem.

Also is there a way of embedding the dlls directly into the c# project to avoid having to send dlls with the program? Is there a way to create a c++/cli wrapper for this dll? The ultimate cats meow would be able for me to add a reference and call the functions from within the c# application. If this is possible how do I do it? It would probably be a huge task I assume...

Thanks,

Eric

0 Likes

Not having .NET installed could absolutely be a problem, but it doesn't sound like the issue in this case.

System.BadImageFormatException: An attempt was made to load a program with an incorrect format

Is an error that likely points to a 32-bit/64-bit mismatch Could be a .NET version issue, after reading through more of this SO thread.

In the VS project properties, you can actually see what version of .NET is being targeted.  In my case, my custom PSoC UART Bootloader project is targeting .NET 4.  This shouldn't be an issue to run on any machine with Windows 10, since it comes with .NET 4 preinstalled, but machines on older versions of windows may need to manually install .NET 4 to run the application.

There are ways to embed a dll in an executable, but I can't say I've actually tried any of them.

bootload_utils.dll is actually already a C/C++ library, and all the source code for the library is included with your PSoC Creator installation if you want to build it yourself.  You can find the source files at C:\Program Files (x86)\Cypress\PSoC Creator\4.3\PSoC Creator\cybootloaderutils. (Section 5 of the AN73503 AppNote contains instructions on how to create the project and build the library)

It should be usable as-is in a C++ application if you want to go that route.  Using it in C# actually requires using InteropServices in order to call the unmanaged C++ functions of the library from the managed C# environment.

Check the example project at AN73503.  The project shows an example of using InteropServices to call the unmanaged bootload_utils.dll functions from the managed C# application, as well as writing delegates for OpenConnection()/CloseConnection()/WriteData()/ReadData()/etc.  It's meant for USB HID bootloaders, but the principle is the same as if you were using a UART since bootload_utils is agnostic of what communication interface is being used.

0 Likes

Hi KyTr,

I've skimmed through all of those application notes before and got what I needed from them. The DLL section didn't work for me because I have Visual Studio 2019. I had to figure that out by guessing (not really) at a lot of it. An update to the app note would be great :-). One of the users of my board has a Windows 10 64-bit OS and the bootloader works fine on his PC and on my development PC which is 64-bit so it has to be .NET framework or some other underlying issue I cannot pinpoint at the moment. I have to build some more processor modules to test the .NET theory. I shipped my test processor module to a customer today because of this crazy bootloader issue and no doubt made me look bad I am sure. Not a good way to launch a new product.

The other thing as mentioned earlier that bothers me to no end is the extra "stuff" (dll's) I have to include with the executable. I don't like it and it sets the stage for confusion as it already has in Australia with one customer. I'm selling my product internationally and the guy from Australia  already made a comment saying "this is a kludge, why so many files" so as you can see I need to find a better way. I really like the referenced dll idea or cli or whatever I need to do to make it a single executable file so I don't have to give the customer a "kludge" to upgrade the firmware.

Your help thus far has been great just looking for more ideas on how to grab all this crap and stuff it into one exe and work with 64 and 32 bit OS.

Thanks,

Eric

0 Likes
lock attach
Attachments are accessible only for community members.

I would hardly call the inclusion of a dll in a software package a "kludge", but I can understand only wanting to ship an exe and nothing else. There do appear to be a couple options for building libraries directly into the exe.  This page has a few, but again, I haven't actually tried any of them so can't speak to how friendly they are to work with.

When you say "The DLL section didn't work", do you mean you're having issues getting a working project?  I've attached my working VS2019 project if that's the case.  Do bear in mind that I've actually tweaked the bootload_utils source code in this project to fix a possible bug, so if you want the bone stock version, you will need to replace the source files (I think it's just cybtldr_api2.c that I modified) with the ones included with PSoC Creator.

0 Likes

Hi KyTr,

No the dll I created worked fine after I figured out how to do it. I have tried just about everything I can think of. I want to create the dll so I can add it as a reference under the References section of the Solution Explorer like in this picture:

Solution_Ref_C#.PNG

If I can't do that can I embed the C code and headers into C#? If so how do I do it? I think im running into a permissions issue too but can't say for sure.

Im not a Windows developer and it pains me to have to struggle with something I don't know much about and have to support this crap across many users.

Why can't Cypress make the dll in different flavors so its easier to integrate for the end user making the host tool? Why do they just give the C files? Its like here take this and good luck with it. The instructions to create the dll are for an earlier version of Visual Studio and thats why it didn't work for me in the beginning.

Im frustrated and don't have the time to work on something like this with a customer breathing down my neck. There's never enough time for anything and im tired. Sorry for the rant. I just want it to work and move on from this issue....

Thanks,

Eric

0 Likes