Saturday, July 6, 2013

EmguCV and Getting the Right Libraries in the Right Places!

Some quick hints for now, and hopefully I'll fill this in more later : )

If you see the exception "The type initializer for 'Emgu.CV.CvInvoke' threw an exception." then you need to dig deeper to figure out what actually happened.  View details of the exception and drill down into the InnerException until you get to the bottom.  You'll probably find one of these...

Exception: Probable Cause
"An attempt was made to load a program with an incorrect format." : You are compiling for 32-bit but the OpenCV library you are using was compiled for 64-bit.  Or the other way around.

"Unable to load DLL 'opencv_core240': The specified module could not be found" : The core240 DLL is not in the same folder as your executable...or if you do have it there then you might need to install (or reinstall) The Microsoft Visual C++ 2010 redistributable package of the latest Service Pack (SP1 is current as of this writing).  x86: http://www.microsoft.com/en-us/download/details.aspx?id=8328  x64: http://www.microsoft.com/en-us/download/details.aspx?id=13523

Still having trouble loading the core240?  Use the great Dependency Walker tool from http://www.dependencywalker.com/ to open the core240 DLL and see what other DLLs might be missing!

Wednesday, January 9, 2013

CooCox and GCC-ARM 4.7 (2012q4)

Real quick update for those of you struggling to make GCC ARM 4.7.3 work with CooCox.

First of all, make sure that you when to the Project menu and selected the new toolchain path (e.g. ...\4.7 2012q4\arm-none-eabi\bin) AND set the linker to the new libm.a file in the new toolchain path (e.g. ...\4.7 2012q4\arm-none-eabi\lib\armv7e-m\fpu\libm.a  for the Hardware FPU library option)


If you properly configure the new libraries and you are getting a compiler error saying "[cc] arm-none-eabi-gcc: error: unrecognized command line option '-Wl'"
Download this file: org.coocox.builder.ui_1.0.0.201212141638.jar
and put it on your CoIDE plugins folder, e.g. C:\CooCox\CoIDE\plugins, overwriting the one that is there.

If you have other problems, and you're trying to use printf(), then you and I are in the same boat, so hold on for the solution.  For now get rid of printf() and try to be more creative about getting data out of the uC.

Thanks to these guys for the help on this one.

S



An Adventure in CooCox and Cortex M4 (STM32F4)

From the outset I think this is going to be a multipart blog of my journey though a new IDE and processor.  As before, this series will serve partially as my notebook of how to do it again and your more-or-less guide to how to do it the right way, including visibility of some pitfalls which might try to grab you.

Project Goals

A little intro to what I am trying to achieve.  I've come up with a brilliant idea for a product that until recently could only be done on a PC or single board computer (SBC) at great cost and inconvenience...at least when you come from a microcontroller and consumer product background like me.  I recently discovered the ARM Cortex M4 with integrated floating point unit (FPU) and realized that something like this running at 168MHz is exceeding the performance of my old Intel 486DX and possibly even my first Pentium MMX.  I decided it was time to go for it and created my shopping list:

  • Cortex M4
  • Development board with Ethernet connectivity
  • JTAG hardware
  • IDE and compiler that wouldn't limit my solution size
  • Schematic capture and board layout software suitable for a distributed development team
  • Be as cheap as possible since we don't have a customer yet!

My preferred flavor of ARM is the ST Microelectronics family so I started with the STM32F4 and chose the Olimex STM32-E407 development board. Olimex, based out of the eastern European country of Bulgaria, has great products, at great prices, with valuable support, and cheap shipping to the US.  Olimex also has great FTDI-based JTAG options, like the ARM-USB-TINY-H, that are very inexpensive and yet very powerful.  In the past I've used the TINY with IAR and Eclipse via the OpenOCD GDB Server so I was prepared for the manual process of starting the server and messing around with config files...but I was in for a treat.

Now enter the IDE choice.  I was going to use IAR Embedded Workbench for ARM because it is always easy to get started and the support is great.  In the past I've gotten away with the 32KB Kickstart version because my STM32F103 projects were never really that crazy, even with USB.  I started estimating my solution size and I knew 32KB wouldn't cut it, so I checked the prices on the full versions of IAR and immediately started thinking Eclipse again : )  Started Googling for new things that I may have missed in the past year and I found CooCox.org which is a free commercial (aka closed source) product based on Eclipse.  Now, you'll have to excuse me, but I don't really understand how free and commercial go together nor do I get how they close-sourced something based on Eclipse.  However, the product is amazing.  Incredible support for all the ARMs I care about, uses the ARM compiler, natively employs the Olimex JTAG, great community of developers, and actively being improved.  After a few months with it I actually prefer it over IAR thanks to the great text editor and debugger.  The only downside is that the Java-based engine is a bit slow to spool up the debugger in Windows (the only supported OS) on my aging MacBook Pro 2.4GHz Core2Duo.  Did I mention it is free and completely unlimited in code size?  Much more on all of this later.

Briefly on schematic and layout: I used to use OrCAD Capture and Layout.  Well, Layout was retired in 16.2 and I decided if I had to learn something new (like 16.3+ PCB Editor) then I better be smart about where I spend my time learning.  OrCAD isn't cheap, but its not expensive.  Until you have three engineers who want to share files and co-develop.  I'll save the EDA comparison for later, but for now go read about KiCAD at their website and on Wikipedia.  Perfect? No.  Free? Yes.  Cross platform? Mostly...stick to Windows or Linux.

Ok, that's the project intro. Time to delve into CooCox so I can save some of my thoughts and get back to work.