- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I made a program with the help of uart bootloader host application.
i want to add security key feature.
I inherit the security key feature from the USB bootloader host project.
https://www.cypress.com/documentation/application-notes/an73503-psoc-usb-hid-bootloader
The software runs fine without Security key.
But when i enable security key feature in software, by checking a checkbox.
I got this Exception.
i tried a lot of different options but didn't work at all.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I was able to recreate the issue you are facing. This error usually occurs when you access unmanaged code like BootLoader_Utils.dll in this case in a manner that's not expected like wrong parameters etc.
I programmed the UART Bootloader project and checked if everything works using the Bootloader Host tool. Does it work for you?
Once I verified everything was fine, I then ran your application. When I click "Load" without security being enabled, I get the following error message. Not sure if you made any modifications to the UART Bootloader PSoC Creator.
I then enabled "Security" and was able to see the issue you are facing. The stack trace is as shown below:
" at UART_PROGRAMER.Bootload_Utils.CyBtldr_Program(String file, Byte[] securityKey, CyBtldr_CommunicationsData& comm, CyBtldr_ProgressUpdate update)\r\n at UART_PROGRAMER.Form1.BG_Work_DoWork(Object sender, DoWorkEventArgs e) in C:\\Users\\ddka\\Documents\\TechnicalSupport\\CDC\\2020\\Q1\\Thread52977\\UART_PROGRAMER\\UART_PROGRAMER\\Form1.cs:line 298\r\n at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)\r\n at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)\r\n at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)\r\n at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)\r\n at System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.DoAsyncCall()\r\n at System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.ThreadPoolCallBack(Object o)\r\n at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)\r\n at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)\r\n at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)\r\n at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()\r\n at System.Threading.ThreadPoolWorkQueue.Dispatch()\r\n at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()"
From the error, I think it might have something to do with calling DLL APIs from the Background Worker. There was a similar issue reported on the Microsoft Forum. Not sure if this is the root of the problem but probably where you can start debugging from.
Might, be helpful to check what the best way to invoke a DLL call from within a background worker would be. Also, since programming shouldn't be interrupted, if there might be another thread running, you can use a mutex lock or a critical section for that part of code.
I'll keep debugging and keep you posted on the developments.
Hope this helps!
Regards,
Dheeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I was able to recreate the issue you are facing. This error usually occurs when you access unmanaged code like BootLoader_Utils.dll in this case in a manner that's not expected like wrong parameters etc.
I programmed the UART Bootloader project and checked if everything works using the Bootloader Host tool. Does it work for you?
Once I verified everything was fine, I then ran your application. When I click "Load" without security being enabled, I get the following error message. Not sure if you made any modifications to the UART Bootloader PSoC Creator.
I then enabled "Security" and was able to see the issue you are facing. The stack trace is as shown below:
" at UART_PROGRAMER.Bootload_Utils.CyBtldr_Program(String file, Byte[] securityKey, CyBtldr_CommunicationsData& comm, CyBtldr_ProgressUpdate update)\r\n at UART_PROGRAMER.Form1.BG_Work_DoWork(Object sender, DoWorkEventArgs e) in C:\\Users\\ddka\\Documents\\TechnicalSupport\\CDC\\2020\\Q1\\Thread52977\\UART_PROGRAMER\\UART_PROGRAMER\\Form1.cs:line 298\r\n at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)\r\n at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)\r\n at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)\r\n at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)\r\n at System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.DoAsyncCall()\r\n at System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.ThreadPoolCallBack(Object o)\r\n at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)\r\n at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)\r\n at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)\r\n at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()\r\n at System.Threading.ThreadPoolWorkQueue.Dispatch()\r\n at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()"
From the error, I think it might have something to do with calling DLL APIs from the Background Worker. There was a similar issue reported on the Microsoft Forum. Not sure if this is the root of the problem but probably where you can start debugging from.
Might, be helpful to check what the best way to invoke a DLL call from within a background worker would be. Also, since programming shouldn't be interrupted, if there might be another thread running, you can use a mutex lock or a critical section for that part of code.
I'll keep debugging and keep you posted on the developments.
Hope this helps!
Regards,
Dheeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello DheerajK_81
Did you try to debug the software.
if you find any thing it will be helpful.
Thanks and Regards
Paras.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Paras,
Like I mentioned in the previous interaction please try running Bootloader Host tool from Cypress and checking if everything works. That will make it clear there is no error from the PSoC side.
Once it does, implement the suggestions I mentioned, it should solve your issue:
Might, be helpful to check what the best way to invoke a DLL call from within a background worker would be. Also, since programming shouldn't be interrupted, if there might be another thread running, you can use a mutex lock or a critical section for that part of code.
Following links can be helpful:
Make thread-safe calls to controls - Windows Forms | Microsoft Docs
Regards,
Dheeraj