I have a project that uses i2c I have updated my local sources to the 3.4firmware revisions that are available for download But it still refuses to work, Where the same code works fine from the WebIDE. Honestly I am rather stumped at this point. Any help at all would be appreciated.
Try make clean all
?
I have between all updates and attempts still no dice.
Edit: just did it again and still not working
Do you have the build log?
Yes I do
I will make a note of the telnet library I use there now, Mostly because the warnings there are related to it.
Heya @Geekbozu,
If its the case that your code is working on the build IDE, but not when you compile locally, then it sounds like we just need to get those environments into sync. Can you check what version of the arm-none-eabi-gcc toolchain you’re using? Can you also move your branch to use the build server branch compile-server2
?
Thanks,
David
HI @Geekbozu could you please zip up and share your source files so that I may troubleshoot these compiler errors more effectively? I’ve just built and tested a DS1307 RTC I2C sample application I’ve used for testing I2C with Spark 0.3.4 firmware and also the latest master
firmware and both are compiling and working as expected.
Also, if you add the following two lines of code to your project in the web IDE, you can mimic the local build more closely:
#pragma SPARK_NO_PREPROCESSOR
#include "application.h"
@Geekbozu I found this code on your github repo and thought it might be similar to what you are starting with:
I modified the button
example slightly… but only because it looked sketchy (no pun because of .ino) just because I didn’t want to see any errors the first time I compiled it. It compiles fine via Spark CLI and locally with latest master
.
#pragma SPARK_NO_PREPROCESSOR
#include "application.h"
#include "Adafruit_MCP23017.h"
// Basic pin reading and pullup test for the MCP23017 I/O expander
// public domain!
// Connect pin #12 of the expander to Analog 5 for Arduino and D1 for Spark Core (i2c clock)
// Connect pin #13 of the expander to Analog 4 for Arduino and D0 for Spark Core (i2c data)
// Connect pins #15, 16 and 17 of the expander to ground (address selection)
// Connect pin #9 of the expander to 5V (power)
// Connect pin #10 of the expander to ground (common ground)
// Connect pin #18 through a ~10kohm resistor to 5V (reset pin, active low)
// Input #0 is on pin 21 so connect a button or switch from there to ground
Adafruit_MCP23017 mcp;
void setup() {
mcp.begin(); // use default address 0
mcp.pinMode(0, INPUT);
mcp.pullUp(0, HIGH); // turn on a 100K pullup internally
pinMode(D7, OUTPUT); // use the D7 LED as debugging
}
void loop() {
// The LED will 'echo' the button
digitalWrite(D7, mcp.digitalRead(0));
}
I don’t have a MCP23017 or I’d try this out and see what I get. Let me know if this simple example works for you… and then let’s try your larger project with the telnet stuff.
Haha good find @BDub, The only change I made to that repo was pull readRegister out of private And My code is more or less that example with the telnet-lib library tacked on it(minor edits to that as well because it was broken locally and on the webide), I will have my code up momentarily have to edit out some access token stuff in my make file. I did test the webide with the suggestions above and it still works fine, But is still broken locally
Code is located here
Tried your example No dice.
Interesting that my example by itself doesn’t work. So here’s how you set that up just so we are on the same page.
Create a folder called mcp_button
here:
../firmware/applications/mcp_button/
Inside that folder put these three files:
Adafruit_MCP23017.cpp
Adafruit_MCP23017.h
button.ino
Switch to the ../firmware/build/
directory and compile and program via DFU with this command:
make APP=mcp_button program-dfu
@Geekbozu I just tried compiling your code locally and it compiled the same without errors, with and without your included makefile
. I just put the code in a directory here: ../firmware/applications/sparkmarquee/
and compiled from ../firmware/build/
with make APP=sparkmarquee clean all
When you say no dice
with my button example, do you mean it won’t compile or it’s giving you results of 0xff (255 decimal) over I2C?
The same as in with the same out log or as in it compiles happily, The issue is that i2c is broken not that it would not compile.
By no dice I meant its giving me 0xFF over i2c
Ok let’s try to boil this down to super simple examples to find the issue… so with the MCP23017 button example I posted above do you just get 0xff returned from the mcp.digitalRead(0)
call no matter the state of the 0 input (HIGH/LOW)?
As I said I don’t have an MCP23017, but do have a DS1307. By chance do you have one of those?
Hmm… also, you are using pull up resistors on your I2C_CLK and I2C_DATA lines right?
Sadly I do not
I Am using pull up resistors on my clock and data lines. Made that mistake the first time i played with i2c. (the code would also not work in the web ide if that was the case. Which it does) as for testing the button example it seems to not return anything useable it might be returning 255 but I am writing code to check now.
I made a minor edit to control the rgb led and it seems to not ever the led either? It is the first thing in setup so im at a loss.
ok, diving deeper into simplicity sounds like it might be the right next step:
#pragma SPARK_NO_PREPROCESSOR
#include "application.h"
void setup() {
pinMode(D7, OUTPUT);
}
void loop() {
digitalWrite(D7, !digitalRead(D7));
delay(500);
}
does it blink?
No it doesnt… So now im wondering what actually is broken…
Ok cool, we’re on the trail of fixing things…
So this might be a good start, go into each of your libraries and do the follow commands:
core-firmware (aka firmware)
git checkout master
git pull
core-communication-lib
git checkout master
git pull
core-common-lib
git checkout master
git pull
You could also clone these all from scratch in a new folder to be absolutely sure you have a good copy of master
Then cd
into the firmware/build/
directory and run make clean all
and you should end up with the following build size (which is the tinker app):
Invoking: ARM GNU Print Size
arm-none-eabi-size --format=berkeley core-firmware.elf
text data bss dec hex filename
78908 1224 11860 91992 16758 core-firmware.elf
So I did the above, And my sizes do not match up
arm-none-eabi-size --format=berkeley core-firmware.elf
text data bss dec hex filename
78776 1228 11864 91868 166dc core-firmware.elf
I just decided to clone fresh and try again and I got:
arm-none-eabi-size --format=berkeley core-firmware.elf
text data bss dec hex filename
78812 1224 11860 91896 166f8 core-firmware.elf
So I must have made a couple changes somewhere that I should have git stash'd
You are compiling on Windows with a different output than I’ve seen when I was compiling on Windows previously. Now I’m compiling on Mac with the following version:
>arm-none-eabi-gcc --version
arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 4.8.3 20131129 (release) [ARM/embedded-4_8-branch revision 205641]
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
What do you get when you type that in?
arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 4.8.4 20140725 (release) [ARM/embedded-4_8-branch revision 213147]
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Latest version available, Also going to say thanks in advanced. I just completely ran out of ideas on what is wrong. >.<