Currently I'm reading the book 'Fast and Effective Embedded Systems Design - Applying the ARM mbed - 2nd Edition'
. The device that is used throughout the book is the LPC1768
and the recommended IDE is 'Mbed Studio'
. So the first thing I did was order an LPC1768. I had to be patient: long production/delivery times. Last week I received the LPC1768 and thought let's go for it and program the 'Hello World'-equivalent: blinky. A very small program. Source code can be found here
When I had set the target device and tried to compile blinky, I ran into the following error message:
After Googling for a while I did not find a clear solutions to this issue. I did see lots of people struggling with this too. So I thought, let's figure out what causes the error. Well obvious the error is giving something away: the compiler thinks I want the FPU (Floating Point Unit) enabled but the device doesn't have an FPU. When I looked at the first line of code, I saw a squiggly line below the included header file. 'mbed.h' When hovering above the squiggly lines, a tooltip shows the exact same error message. With + you can jump to the header file. I followed the path down from 'main.cpp' all the way down to 'core_cm3.h' Until there were no more squiggly lines for include files.
|--> #include "mbed.h"
|----> #include "netsocket/nsapi.h"
|------> #include "netsocket/UDPSocket.h"
|--------> #include "netsocket/InternetSocket.h"
|----------> #include "mbed_atomic.h"
|------------> #include "cmsis.h"
|--------------> #include "LPC17xx.h"
|----------------> #include "core_cm3.h"
So why is FPU enabled? The __ARMCC_VERSION is 6160001, which is larger than 6010050 and __ARM_FP is 6. This combination results in true for showing the error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)". The ARMCC version seems to be the compiler version (6.16...) One solution would be degrading to version below 6.01... Not really a proper solution. So that leaves the option to make __ARM_FP undefined. So where is this flag defined? Again you can + to the file where it is defined: 'macros-armclang.cfg' Unfortunately this is a system wide settings file for clang and not a project specific setting. But for the sake of testing whether this is the root cause. Let's just comment it out.
After a 'Clean rebuild' the error is gone. When you copy the generated bin file to the flash usb 'mbed' and press the reset button on the LPC1786, the led is blinking as expected.
I'm still looking for a better solution, but at least I can now build the exercises from the book.