benagricola / tracker

Particle Electron GPS / GSM tracker based on fancy-asset-tracker demo and ULOC tracking example.
GNU General Public License v3.0
30 stars 24 forks source link

Difficulty building #1

Open dokterbob opened 8 years ago

dokterbob commented 8 years ago

Hey there,

Thank for this awesome package, you potentially saved me days of work IF I can get this stuff to build.

I have spent the last several hours trying to get this to run on my Electron but, using particle compile it fails to build. These are things I've tried:

  1. Building the directory as-is, which doesn't include the inc/ folder and hence results in the include files not being found.
  2. Creating a particle.include file listing main.cpp and includes which, somehow, results in the includes not being found as well: `main.cpp:12:30: fatal error: inc/Adafruit_GPS.h: No such file or directory

    include "inc/Adafruit_GPS.h"`

  3. Moving all the files in inc/ to the main directory. This time, includes seem to be taken along but I'm getting the following output:
~/Development $ particle compile electron tracker --saveTo firmware.bin && particle flash --serial firmware.bin 

Compiling code for electron

Including:
    /Users/drbob/Development/tracker/Adafruit_GPS.h
    /Users/drbob/Development/tracker/Adafruit_LIS3DH.h
    /Users/drbob/Development/tracker/Adafruit_Sensor.h
    /Users/drbob/Development/tracker/GPS_Math.h
    /Users/drbob/Development/tracker/cell_locate.h
    /Users/drbob/Development/tracker/cell_locate.cpp
    /Users/drbob/Development/tracker/Adafruit_LIS3DH.cpp
    /Users/drbob/Development/tracker/Adafruit_GPS.cpp
    /Users/drbob/Development/tracker/main.cpp
attempting to compile firmware 
pushing file: /Users/drbob/Development/tracker/Adafruit_GPS.h
pushing file: /Users/drbob/Development/tracker/Adafruit_LIS3DH.h
pushing file: /Users/drbob/Development/tracker/Adafruit_Sensor.h
pushing file: /Users/drbob/Development/tracker/GPS_Math.h
pushing file: /Users/drbob/Development/tracker/cell_locate.h
pushing file: /Users/drbob/Development/tracker/cell_locate.cpp
pushing file: /Users/drbob/Development/tracker/Adafruit_LIS3DH.cpp
pushing file: /Users/drbob/Development/tracker/Adafruit_GPS.cpp
pushing file: /Users/drbob/Development/tracker/main.cpp
Compile failed. Exiting.
Adafruit_GPS.cpp: In member function 'boolean Adafruit_GPS::LOCUS_StartLogger()':
Adafruit_GPS.cpp:320:34: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
   sendCommand(PMTK_LOCUS_STARTLOG);
                                  ^
Adafruit_GPS.cpp:322:47: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
   return waitForSentence(PMTK_LOCUS_LOGSTARTED);
                                               ^
Adafruit_GPS.cpp: In member function 'boolean Adafruit_GPS::LOCUS_ReadStatus()':
Adafruit_GPS.cpp:326:38: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
   sendCommand(PMTK_LOCUS_QUERY_STATUS);
                                      ^
Adafruit_GPS.cpp:328:35: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
   if (! waitForSentence("$PMTKLOG"))
                                   ^
Adafruit_GPS.cpp: In member function 'boolean Adafruit_GPS::standby()':
Adafruit_GPS.cpp:381:29: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     sendCommand(PMTK_STANDBY);
                             ^
Adafruit_GPS.cpp: In member function 'boolean Adafruit_GPS::wakeup()':
Adafruit_GPS.cpp:390:19: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     sendCommand("");  // send byte to wake it up
                   ^
Adafruit_GPS.cpp:391:38: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     return waitForSentence(PMTK_AWAKE);
                                      ^
In file included from Adafruit_LIS3DH.cpp:25:0:
Adafruit_LIS3DH.h: In constructor 'Adafruit_LIS3DH::Adafruit_LIS3DH()':
Adafruit_LIS3DH.h:140:29: warning: 'Adafruit_LIS3DH::_sck' will be initialized after [-Wreorder]
   int8_t _cs, _mosi, _miso, _sck;
                             ^
Adafruit_LIS3DH.h:136:11: warning:   'int32_t Adafruit_LIS3DH::_sensorID' [-Wreorder]
   int32_t _sensorID;
           ^
Adafruit_LIS3DH.cpp:34:1: warning:   when initialized here [-Wreorder]
 Adafruit_LIS3DH::Adafruit_LIS3DH()
 ^
In file included from Adafruit_LIS3DH.cpp:25:0:
Adafruit_LIS3DH.h: In constructor 'Adafruit_LIS3DH::Adafruit_LIS3DH(int8_t)':
Adafruit_LIS3DH.h:140:29: warning: 'Adafruit_LIS3DH::_sck' will be initialized after [-Wreorder]
   int8_t _cs, _mosi, _miso, _sck;
                             ^
Adafruit_LIS3DH.h:136:11: warning:   'int32_t Adafruit_LIS3DH::_sensorID' [-Wreorder]
   int32_t _sensorID;
           ^
Adafruit_LIS3DH.cpp:39:1: warning:   when initialized here [-Wreorder]
 Adafruit_LIS3DH::Adafruit_LIS3DH(int8_t cspin)
 ^
In file included from Adafruit_LIS3DH.cpp:25:0:
Adafruit_LIS3DH.h: In constructor 'Adafruit_LIS3DH::Adafruit_LIS3DH(int8_t, int8_t, int8_t, int8_t)':
Adafruit_LIS3DH.h:140:29: warning: 'Adafruit_LIS3DH::_sck' will be initialized after [-Wreorder]
   int8_t _cs, _mosi, _miso, _sck;
                             ^
Adafruit_LIS3DH.h:136:11: warning:   'int32_t Adafruit_LIS3DH::_sensorID' [-Wreorder]
   int32_t _sensorID;
           ^
Adafruit_LIS3DH.cpp:43:1: warning:   when initialized here [-Wreorder]
 Adafruit_LIS3DH::Adafruit_LIS3DH(int8_t cspin, int8_t mosipin, int8_t misopin, int8_t sckpin)
 ^
Adafruit_LIS3DH.cpp: In member function 'virtual bool Adafruit_LIS3DH::getEvent(sensors_event_t*)':
Adafruit_LIS3DH.cpp:304:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
main.cpp:1:0: warning: ignoring #pragma SPARK_NO_PREPROCESSOR  [-Wunknown-pragmas]
 #pragma SPARK_NO_PREPROCESSOR
 ^
main.cpp: In function 'void activateGPS()':
main.cpp:122:34: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     GPS.sendCommand("$PMTK101*32");
                                  ^
main.cpp:127:49: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_ALLDATA);
                                                 ^
main.cpp:132:36: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     GPS.sendCommand(PGCMD_NOANTENNA);
                                    ^
main.cpp: In function 'bool doSleep()':
main.cpp:176:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
main.cpp: In function 'int forceSleep(String)':
main.cpp:180:37: warning: format '%u' expects argument of type 'unsigned int*', but argument 3 has type 'unsigned int' [-Wformat=]
     sscanf(seconds, "%u", SLEEP_TIME);
                                     ^
main.cpp:180:37: warning: format '%u' expects argument of type 'unsigned int*', but argument 3 has type 'unsigned int' [-Wformat=]
main.cpp:183:46: error: no matching function for call to 'Timer::Timer(int, bool (&)(), bool)'
     Timer shutdown_timer(10000, doSleep, true);
                                              ^
main.cpp:183:46: note: candidates are:
In file included from ./inc/application.h:54:0,
                 from main.cpp:8:
../wiring/inc/spark_wiring_timer.h:34:5: note: Timer::Timer(unsigned int, Timer::timer_callback_fn)
     Timer(unsigned period, timer_callback_fn callback_) : handle(nullptr), callback(callback_) {
     ^
../wiring/inc/spark_wiring_timer.h:34:5: note:   candidate expects 2 arguments, 3 provided
../wiring/inc/spark_wiring_timer.h:32:5: note: Timer::Timer(unsigned int, void (*)())
     Timer(unsigned period, void (*callback)()) : Timer(period, timer_callback_fn(callback)) {}
     ^
../wiring/inc/spark_wiring_timer.h:32:5: note:   candidate expects 2 arguments, 3 provided
../wiring/inc/spark_wiring_timer.h:26:7: note: constexpr Timer::Timer(const Timer&)
 class Timer
       ^
../wiring/inc/spark_wiring_timer.h:26:7: note:   candidate expects 1 argument, 3 provided
main.cpp: In function 'void checkGPS()':
main.cpp:193:18: warning: unused variable 'c' [-Wunused-variable]
             char c = GPS.read();
                  ^
make[1]: *** [../build/target/user/platform-10main.o] Error 1
make: *** [user] Error 2

It seems particle compile builds against a different version of the firmware, somehow.

My main question is: how do you build this thing? And then my next question, how might I? ;)

Thanks for any help! Mathijs

benagricola commented 8 years ago

Hi @dokterbob - I've been building this locally using the 'develop' firmware rather than using the cloud build system.

I'll try and have a look at getting this to build online but for the moment, you'll want to follow the following set of instructions:

https://github.com/spark/firmware/blob/develop/docs/gettingstarted.md - you'll want to 'git checkout develop' in the firmware directory before attempting to build.

After that, check out the tracker repo into ./user/applications/tracker and run

PARTICLE_SERIAL_DEV=<your serial device> make clean all PARTICLE_DEVELOP=1 PLATFORM_ID=10 APP=tracker COMPILE_LTO=n DEBUG_BUILD=n -s program-dfu

Which should build and flash the electron with the new firmware (both parts) and the app itself.

dokterbob commented 8 years ago

Great, thanks. Will try. If it works I'm likely to send a pull req. with this stuff neatly documented.

Lastly, it seems that your editor is not setup to remove trailing whitespace. Could I tempt you to configure this, so that you won't ever have whitespace diffs in commits? :)

dokterbob commented 8 years ago

Ok, I've tried the instructions with commit c974657 of the develop branch, this results in the unit booting to safe mode. :(

What commit are you running from? Any other hints?

dokterbob commented 8 years ago

Ok, so I managed to get stuff to run. The (reconstructed, as-is untested) steps I performed were, roughly:

  1. git clone -b develop https://github.com/spark/firmware.git particle-firmware
  2. git clone https://github.com/benagricola/tracker.git particle-firmware/user/applications/tracker
  3. cd particle-firmware/modules
  4. make clean all PARTICLE_DEVELOP=1 PLATFORM_ID=10 APP=tracker COMPILE_LTO=n DEBUG_BUILD=n -s program-dfu

Now for some more testing, also of aforementioned instructions and a pull req. with build instructions can be expected.

benagricola commented 8 years ago

cd particle-firmware/modules

Sorry, forgot this bit in my instructions and it's sorta important :sweat_smile:

benagricola commented 8 years ago

@dokterbob can you please try the particle.include file added in 6ad1602?

Output from cloud build with that include file:

...@b-mbp ~/d/p/f/u/a/tracker> particle compile electron

Compiling code for electron

Including:
    /Users/.../dev/particle/firmware/user/applications/tracker/inc/Adafruit_GPS.cpp
    /Users/.../dev/particle/firmware/user/applications/tracker/inc/Adafruit_GPS.h
    /Users/.../dev/particle/firmware/user/applications/tracker/inc/Adafruit_LIS3DH.cpp
    /Users/.../dev/particle/firmware/user/applications/tracker/inc/Adafruit_LIS3DH.h
    /Users/.../dev/particle/firmware/user/applications/tracker/inc/Adafruit_Sensor.h
    /Users/.../dev/particle/firmware/user/applications/tracker/inc/GPS_Math.h
    /Users/.../dev/particle/firmware/user/applications/tracker/inc/cell_locate.cpp
    /Users/.../dev/particle/firmware/user/applications/tracker/inc/cell_locate.h
attempting to compile firmware
pushing file: /Users/.../dev/particle/firmware/user/applications/tracker/inc/Adafruit_GPS.cpp
pushing file: /Users/.../dev/particle/firmware/user/applications/tracker/inc/Adafruit_GPS.h
pushing file: /Users/.../dev/particle/firmware/user/applications/tracker/inc/Adafruit_LIS3DH.cpp
pushing file: /Users/.../dev/particle/firmware/user/applications/tracker/inc/Adafruit_LIS3DH.h
pushing file: /Users/.../dev/particle/firmware/user/applications/tracker/inc/Adafruit_Sensor.h
pushing file: /Users/.../dev/particle/firmware/user/applications/tracker/inc/GPS_Math.h
pushing file: /Users/.../dev/particle/firmware/user/applications/tracker/inc/cell_locate.cpp
pushing file: /Users/.../dev/particle/firmware/user/applications/tracker/inc/cell_locate.h
downloading binary from: /v1/binaries/56ef0e09477963a40b0fde88
saving to: electron_firmware_1458507269866.bin
Memory use:
   text    data     bss     dec     hex filename
   2796       8     436    3240     ca8 /spark/compile_service/shared/workspace/10_electron_15_1/firmware/cbc30c33372afa3be5979eda7d1bea726f2e268edad651d4783245fb0bb7/cbc30c33372afa3be5979eda7d1bea726f2e268edad651d4783245fb0bb7.elf

Compile succeeded.
Saved firmware to: /Users/.../dev/particle/firmware/user/applications/tracker/electron_firmware_1458507269866.bin
benagricola commented 8 years ago

Also: I use Vim - I've added a remove-trailing-whitespace-on-save function so we'll see how it goes, if it causes issues with editing other code (I write in lots of languages) I may have to disable but we'll see!

dokterbob commented 8 years ago

Hey Ben,

Thanks for the feedback. It’ll be about a week before I get time to dive into this again- so beware it’s gonna take a while.

M

benagricola commented 8 years ago

I'm on holiday from Tuesday until mid april so also won't be able to reply from now !

vielmetti commented 8 years ago

I'm willing to write up build instructions as I put together this code for myself and to contribute that back. Hopefully get a chance fairly soon.

DigiDr commented 8 years ago

Hi,

I'm a python programmer with little experience of the hardware side, and the particle firmware is completely new to me so please forgive the inexperience:

I've attempted to compile and flash by both methods described above.

1) - manually compilation and flash via "make clean all" works great: i also see the bad checksum described in bug report https://github.com/benagricola/tracker/issues/2, but am also getting accurate gps events.

2) "particle compile electron" gives me the .bin - fine. Flash via "particle flash --usb electron_firmware_xxxx.bin" - fine.

Breathing cyan light - but doesn't get motion/gps events, nor any red light on the gps unit itself.

cdolan92 commented 8 years ago

I'm also struggling to get this to install on my Particle Electron. Could totally be my error, but I've tried the above options (cloud, make clean all, particle compile electron...) and have not been successful.

Any tips are appreciated, this looks to be a great starting point for a project I'm working on.

DigiDr commented 8 years ago

Building manually works for me. I finally got the cloud build to work by altering the source files to remove the "inc/" from all #include lines in main.cpp (e.g. #include "inc/Adafruit_GPS.h" becomes #include "Adafruit_GPS.h", etc.) - since the particle.include file already takes care of this.

Hope this helps.

cdolan92 commented 8 years ago

I tried removing the "inc/" references as well, perhaps there is something else I am doing incorrectly?

My process was basically to:

  1. make a new app/project in the cloud code builder.
  2. Hit the + button and make files with the same name as those in the "inc/" directory. Copy the contents of those files as well.
  3. Adjust any include statements as you mentioned above.

Is there a way to "upload" the entire project directory or some other approach?

DigiDr commented 8 years ago

I'd download "particle dev" (https://www.particle.io/products/development-tools/particle-local-ide) and try importing the project in there. You can then "cloud compile" and either download the firmware file to flash locally, or have it flash through the cloud.

Please share any error messages and ill do my best to help.

cdolan92 commented 8 years ago

KuDeTa,

I did not know there was a desktop app - thanks for pointing me in that direction. Here are the steps I have taken:

  1. Download the tracker-master.zip from github.
  2. Unzip, drag directory into Atom IDE
  3. Compile for cloud (but do not flash)
  4. Error: inc/LIS3DH.h: No such file or directory (LIS3DH.ino:3:24)
    • The file reference in the LIS3DH.cpp that includes the LIS3DH.h file is prefaced with inc/. I tried removing it, which took this error away.
  5. New Errors, see attached image.

image

I'll keep chugging away at it, but if you've got any pointers I'm all ears!

cdolan92 commented 8 years ago

So compiling to the cloud ended up succeeding once I moved all the files out of the inc/ directory and into the main directory. I was able to Compile in the IDE (but not flash over the cloud). I popped over to the CLI and ran particle compile electron, which then gave me a .bin file that I could run particle flash --usb {.bin directory location}.

I believe I have the app installed, but its breathing white (no cellular connection). Working on why that might be now...

Edit - I put it into "listening" mode and got it to do a flash over cellular using the IDE. Seems to have successfully installed! Now trying to sort out what exactly constitutes enough movement for this to wake up and report a new location.