"Clean" firmware project

I’m trying to create a “clean” firmware project without connecting to the cloud or to the wifi:)
I would like for starters to make something like this(except for the lcd):

I didn’t want to loose some core features so I’ve edited the core-firmware project.
Unfortunately all my eforts ran into problems (simple led flashing project doesn’t work).
I’m quite new to this.
Can anyone point me in the right direction how to start?:slight_smile:

  1. what’s your development environment? Netbeans etc…

  2. where did you add your own code?

  3. you also need to disable wlan and spark connection on startup in order to do so

Thank’s for your reply:)
I’m working on ubuntu 13.04
Netbeans 7.4
Everything that was needed is installed, compilation of the core-firmware project works fine.

int main(void)
	DEBUG("Hello from Spark!");

	/* Main loop */
	while (1)
		static uint8_t SPARK_WIRING_APPLICATION = 0;


// Define the pins we're going to call pinMode on
int led = D0;  // You'll need to wire an LED to this one to see it blink.
int led2 = D7; // This one is the built-in tiny one to the right of the USB jack

// This routine runs only once upon reset
void setup() {
  // Initialize D0 + D7 pin as output
  // It's important you do this here, inside the setup() function rather than outside it or in the loop function.
  pinMode(led, OUTPUT);
  pinMode(led2, OUTPUT);

// This routine gets called repeatedly, like once every 5-15 milliseconds.
// Spark firmware interleaves background CPU activity associated with WiFi + Cloud activity with your code. 
// Make sure none of your code delays or blocks for too long (like more than 5 seconds), or weird things can happen.
void loop() {
  digitalWrite(led, HIGH);   // Turn ON the LED pins
  digitalWrite(led2, HIGH);
  delay(10000);               // Wait for 1000mS = 1 second
  digitalWrite(led, LOW);    // Turn OFF the LED pins
  digitalWrite(led2, LOW); 
  delay(2000);               // Wait for 1 second in off mode


	ldr	r3, = _ebss
	cmp	r2, r3
	bcc	FillZerobss
/* Call the clock system intitialization function. */
	bl  SystemInit
/* Call the application's entry point. */
	bl	main
	bx	lr    
.size	Reset_Handler, .-Reset_Handler

How am I doing so far?:stuck_out_tongue_winking_eye:

Abador, what you’ve done is essentially remove ALL the Spark features that we call the core firmware. I still don’t know what you mean by: [quote=“Abador, post:1, topic:3728”]
HiI’m trying to create a “clean” firmware project without connecting to the cloud or to the wifi
but then you say:

To do WiFi scanning like in the video, you need the WiFi features of the core firmware. There is a way to control the WiFi or Spark Cloud connections in your code without having to edit the firmware files. I see two scenarios here:

  1. You expect to write you own firmware to control the CC3000 and associated resources
  2. You just want to turn off some things in the core firmware as mentioned above.

A third scenario is you customize NutX or FreeRTOS real-time operating systems to run on the Core along with your own CC3000 drivers. Can you elaborate more on what your goal is for your “clean” firmware project?

The first step is to run the scetch with the blinking leds.
I couldn’t make it working so I’ve removed the things that thought could interfere.

The second step is to include all the libs (wifi driver etc) and prepare the scanner.
At this point I don’t know if I will be using the spark cloud or anything else that the core does automatically, but it would be nice to be able to turn it on without many changes.

The other solution I’ve thought of is to make a bare project without using any of the core-firmware files just the libs. The problem is I’m quite new at this so I don’t know how to start:)

Abador, I have to admit that I am confused with what you are trying to do. So here is what I DO understand:

  1. You want to blink the onboard LED without the wifi or cloud connection which you refer to as “clean”. More specifically, you don’t want the code associated with wifi & cloud to be there.
  2. You eventually want to implement a WiFi scanner with only the necessary libraries.

Can I ask what is your purpose for doing it this way? Reduced code size perhaps?

Abador, part of the reason people buy the Spark Core is that is manages the WiFi and cloud connection in the background. You can disable one or both of those features to achieve what you are looking for. So your approach is not something that anyone is doing or possibly interested in doing. Good luck!

First of all I will explain why I’ve chosen this board:

  • small size
  • stable on 3,7 volts
  • low power consumption
    As far as I can see the hardware has everything I need.
    On the other side there’s the firmware.
    It has everything most people need to work, but if I understand correctly if the sketch works too long it may interfere with the background services. The other problem is that even if I program the core using the offitial firmware I’m not sure how it will end up draining the battery. Firstly I have to write an app that makes a minimal power drain(that includes deciding when to connect to wifi and send data but without a working internet connection) and test it for a few weeks.
    I know I might be naive but I think all I need is a nudge in the right direction to learn how to do it and make it work, because if it doesn’t work I’m doing it wrong:) Oh well if you don’t try you don’t learn:)

Abador, I’m glad you chose the Spark for the reasons you did. However, you are working under false assumptions:[quote=“Abador, post:7, topic:3728”]
but if I understand correctly if the sketch works too long it may interfere with the background services

This issue was resolved some time ago by modifying the delay() function, which is used often, to allow background processing during the delay. If your loop() simply processes so much that it does not return control to the background task in less than 10 seconds then you just need to sprinkle some SPARK_WLAN_Loop() calls in there to keep the background happy.

I just finished a program where I wanted sampling to take place in my loop() with wifi and cloud connection disabled. Then, every minute, I enable the wifi and cloud connection, publish some data and then disable wifi and cloud again. I measured about 37ma draw on the 5V USB line during data collection and about 310ma during publishing, which lasts just a few seconds at most. I also supply power to a couple of peripherals so I am measuring everything, not just the core. Perhaps this approach could work for you.

Another similar method is the sleep mode using Spark.sleep(), though like my code, it only disables the CC3000 and does not turn it off. Which brings up an interesting question that I will take up with the Spark Team - can there be a “deep” WiFi.off() function which shuts down the CC3000 completely? :smile:

That would be great;)

Thank’s for the tips, I’ll check them out:)