Brilliant. I followed the instructions and everything works. Thank you @seulater
As a newcomer to NetBeans and makefiles I was thrown for a while when I tried to compile my own code instead of just modifying application.cpp and despite apparent success the code on the core didn’t seem to change.
However all that was necessary was to edit build.mk in the src directory and replace application.cpp with my own program name. Blisteringly obvious to those of you who know what you are doing …
Brilliant. I followed the instructions and everything works. Thank you @seulater
I should have added that now that you mention it.
For those unaware. If you want to add your own files simply do this.
Navigate to the core-firmware folder, then src. in there you will find a file called “build.mk”. Double click on it to open it. In there you will notice the start of the following:
C++ source files included in this build.
CPPSRC += $(TARGET_SRC_PATH)/application.cpp
CPPSRC += $(TARGET_SRC_PATH)/main.cpp
CPPSRC += $(TARGET_SRC_PATH)/newlib_stubs.cpp
CPPSRC += $(TARGET_SRC_PATH)/spark_utilities.cpp
CPPSRC += $(TARGET_SRC_PATH)/spark_wiring.cpp
All you need to do from here is create your new file, we will call ours my_test.cpp
Put the my_test.cpp in the core-firmware/src folder and the my_test.h in the core-firmware/inc folder.
then edit the build.mk file by adding your new file to it. add a new line to the start of the “CPPSRC += …” lines and add this:
CPPSRC += $(TARGET_SRC_PATH)/my_test.cpp
save it and your done.
p.s. now I’ve got that working, can I access the USB port to see Serial.print() output to monitor and debug programs? @BDub has a workable solution using sparkcore.inf but what do I do now I have zadig installed instead? And of course Serial.read() would be a useful bonus. Thanks again.
you sure can.
to access the USB for serial do this.
Serial.begin(115200); // or other baud rate you desire Serial.println("Hello World");
To access the second serial pins labeled on the board as TX/RX you would do this:
Serial1.begin(115200); Serial1.println("Hello World");
The Zadig driver works as a CORE DFU driver and also as a USB SERIAL virtual COM driver
(EDIT: scratch that, you have to install both the Zadig and Spark_Core.inf drivers)
You may want to do this if you can’t open your port on the computer:
// Have serial monitor closed before you boot the Spark Core // After it connects to the cloud, serial.begin() is run and the serial driver is loaded Serial.begin(115200); // At this point you can open your serial monitor while(!Serial.available()); // press ENTER Serial.println("Hello World"); // Your program runs and talks over serial fine now
Your demo software works fine when I plug the Spark into another computer with the sparkcore.ing driver. On the computer with NetBeans, when the yellow LED is flashing the Spark shows up on the device Manager as a CORE DFU.
When running the program and breathing cyan it shows as Other Devices/SparkCore with WiFi and the properties tell me there is no driver. Have I installed the zadig driver wrongly or is there a step I’m missing to get it to run as a virtual COM driver too?
OK Serial communications sorted. I messed around with zadig but couldn’t get it to load a virtual COM port for me. However when I followed @BDub’s instructions for installing the sparkcore.inf driver it worked perfectly happily alongside the zadig installed USB driver.
The process was:
press mode and click reset get yellow flashing LED
run zadig and install USB driver for Spark Core
run BDub’s Serial software so that the spark is waiting for serial input (I dare say listening mode would work too but I’m quitting while I’m ahead) and follow his instructions - briefly
go to control panel/system/device manager and find Spark Core
right click, install driver (delete existing driver first in my case after messing with zadig)
The zadig driver is there when the yellow LED is flashing
The sparkcode.inf driver is there when the cyan LED is breathing
It is a mystery to me but it works so many thanks to Bdub and @seulater
Now if some wise soul can get the Serial communications going through the Netbeans Terminal window that would be awesome.
Hmm, all this time I thought I had deleted the spark_core.inf driver and the zadig was doing both core dfu and serial. I just checked, nope! Thanks for the correction
Just wanted to thank you very much for the video. It allowed me a guy pretty new to the micro processor world to actually learn how to flash the spark core and how to pull firmware from Git Hub.
The only thing that tripped me up the first time was that when pasting the path = info which I copied from someplace (Not your Youtube Description) that had added a “-” to part of the path description which broke the path description.
So when I tried to type Make into the command prompt it would not run because the path was not setup right due to the dash. I copied the path data directly from the Youtube video description and it solved the problem.
So if your looking to load new firmware on the Spark Core and have no idea how to do it then this video will allow you to get the job done. You’ll learn a few things in the process also.
Thanks for making and sharing the video, without it I don’t think I would have ever figured it out.
I have seen on several threads that people have issues with the Windows folder “Program Files (x86)” and the common cure is to install or copy things to different folders.
Where this does work, there is another even easier work around that keeps things in place and still saves us from having problems with the weird Windows naming.
You can just create a link to the “Program Files (x86)” folder that does not contain any disliked characters, setup your PATH refering to this link instead of “Program Files (x86)” and there you go.
Windows is still happy, anybody who might be looking for a program will find it where it is expected to live and you don’t have to have multiple instances of the same files or programs scatterd over several folders - apart from those two Windows ones.
Great vid! As I also said in the video response, youtube creates 1 problem:
path = C:\SparkCorePrograms\dfu;C:\SparkCorePro-grams\Git\bin;C:\SparkCorePrograms\GNU Tools ARM Embedded\4.8 2013q4\bin;C:\SparkCorePrograms\GnuWin32-\bin
The stripes added by youtube in the Git path (SparkCorePro - grams) and in the GnuWin32 - path are not visible when pasting in the windows settings but they do appear as a wierd E in the command prompt, and they make your path useless. After deleting those Es everything worked as it should Thanks a lot
I create a chocolately package for all the dependencies. sparkcore-build
One command line call and everything is installed. Should speed up the setup process and remove the mistakes around environment variables.
Wow is local building and flashing way faster!
Local compilation tip …
Several code snippets I have seen on this site use types like uint8_t or uint32_t. These are defined in the header file #include <stdint.h> and make it quite clear how long your int is supposed to be.
If you are using local compilation you will get the compillation error message " ‘uint32_t’ does not name a type" unless you make sure that in your code you #include “application.h” before your own includes or explicitly #include<stdint.h> yourself.
seulater… thank you… now for days I have been occupied with learning NetBeans. I have lots of things operating well, have been able to create separate projects, have projects with V3 SPARK FW and some with old versions to test backwards.
I have a new user question. application.cpp… I want to be able to create EACH project with a UNIQUE application name. I can not yet find how to assign names to this project file. Is this a “locked” parameter??? Can you point me to the method for defining a new name in NetBeans build/definition files???
Very nice tut!
I have a question.
How do i create new projects in NetBeans so it uses the needed firmware without editing it in all my existing projects?
If i copy an old project to create a new one with the same configurations,the files in both the old and the new gets updated when i edit in them… And how many of the files are actually getting uploaded to the Core? Is all the files from the src folder needed in all projects?
I feel dumb, but…
When I try to ‘Make’, I get an error: ‘make’ is not recognized as an internal or external command, operable program or batch file.
I’ve quadruple-checked the path, updated the path for ‘GNU Tools ARM Embedded\4.8 2014q1’ (from the previous … 4.82013q4).
I’m sure I’m missing something simple but cannot figure it out. Meanwhile I’m trying to install an embedded controller for a client that I built, but I need to compile the files locally so that I can fix them to work without the cloud.
Please help a poor old EE without much programming experience!
Oh SNAP. It was the dumb hyphen on the path setting from the YouTube page.
Hi, thanks for the excellent tutorial. I now exclusively use netbeans for spark dev becuase of this tutorial, it really has helped me out so thank you.
I have a few questions though. I’d like to create my projects in my own projects folder, I don’t really feel comfortable creating file inside core-firmware/src folder, isn’t this where the spark firmware lives and as such shouldn’t I put my file somewhere else then just link using a make file to the firmware libraries I need. For instance, being new to netbeans and spark core, it looks to me that whenever I create a project I’m pulling in everything from the spark core firmware, do I need to do this? Like, if I’m not using servos could I ommit that file from my projects make file?
I’m sorry to be ignorant but I really like the IDE and would like to be able to use it without feeling like I’m sort of stumbling round in the dark, I just need a little guidance on how to organize my projects from someone who knows. I would research it myself only I think what I need to know may be a little specific to the core firmware when used in netbeans.
Thanks again, Rick.
Wow @seulater thanks! I’ve tried other IDE’s and no go, but your great instructions on the video worked 1st time.
Can you tell me how to set up GDB in Netbeans so that I can debug via USB?
Particularly, what would the “Debug command” look like?
I’m sorry, maybe it is a silly issue but I am stuck here. Everything was being awesome until 10:40 to build repositories. When I type “make” does not happen anything, instead appears “make” is not a command. Tha path is ok, everything until here was perfect. Could you tell me what to do in this case, please. I would appreciate. Regards.
Hmm, if you’re compiling on windows and make isn’t working, make sure you’re in a command prompt that has the build tools in your path. Try looking for a “Bash command prompt” or a “git command prompt”, and make sure you’re in the “core-firmware/build” directory.
It’s possible you might have deleted your makefiles or something, so also try a
git status to see if you’ve modified / removed those files, and you can use git to bring them back safely.
I hope that helps!