arendst / Sonoff-MQTT-OTA

Provide ESP8266 based itead Sonoff with MQTT and OTA firmware - Now EOL
202 stars 47 forks source link

Trouble compiling..please help #1

Closed mgf909 closed 8 years ago

mgf909 commented 8 years ago

Hi Theo - i saw your post on my Scargills blog on this code..Thanks very much for sharing. I am trying to compile your code, but unfortuantly i am inexperienced in this area. ( im comfortable in Arduino/Visual Studio but not much with ESP8266! )

I hope you can help me to fix the issue I have in compiling your code.

I have as you instructed, installed the esp-8266 dev environment on my debian machine , and i was able to compile one of the examples which came with it successfully.

So i then tried to compile your code, but it fails with the error below. Any ideas on what the issue may be?

Do i need to put your code into a specific directory?

greg@hal:~/Sonoff-MQTT-OTA/sonoff$ make

Makefile:11: ../../Makefile.common: No such file or directory make: *\ No rule to make target '../../Makefile.common'. Stop.

arendst commented 8 years ago

I suggest you make a directory ./esp8266-dev/work/ and copy the sonoff directory into it. You then save the original ./esp8266-dev/Makefile.common and copy the one from me in ./esp8266-dev. That should at least compile the code.

mgf909 commented 8 years ago

Thats looking better...but still not correct: greg@hal:~/esp8266-dev$ ls apps dev esp-sdk examples Makefile.common Makefile.common_backup README.md tools work greg@hal:~/esp8266-dev$ cd ./work/sonoff/ greg@hal:~/esp8266-dev/work/sonoff$ ls eagle.app.v6.data.bin eagle.app.v6.irom0text.bin eagle.app.v6.rodata.bin eagle.app.v6.text.bin Makefile modules user greg@hal:~/esp8266-dev/work/sonoff$ make LD -T../../esp-sdk/ld/eagle.app.v6.new.1024.app1.ld .objs/app.out Usage: gen_appbin.py eagle.app.out boot_mode flash_mode flash_clk_div flash_size_map ../../esp-sdk/tools/gen_appbin.py .objs/app.out 2 0 0 2 1 mv: cannot stat ‘eagle.app.flash.bin’: No such file or directory ../../Makefile.common:206: recipe for target '.firmwares/user1.bin' failed make: *** [.firmwares/user1.bin] Error 1 greg@hal:~/esp8266-dev/work/sonoff$

mgf909 commented 8 years ago

Sorry about the formating above...not sure why its wrapping..

mgf909 commented 8 years ago

greg@hal:~/esp8266-dev$ ls apps dev esp-sdk examples Makefile.common Makefile.common_backup README.md tools work greg@hal:~/esp8266-dev$ cd ./work/sonoff/ greg@hal:~/esp8266-dev/work/sonoff$ ls eagle.app.v6.data.bin eagle.app.v6.irom0text.bin eagle.app.v6.rodata.bin eagle.app.v6.text.bin Makefile modules user greg@hal:~/esp8266-dev/work/sonoff$ make LD -T../../esp-sdk/ld/eagle.app.v6.new.1024.app1.ld .objs/app.out Usage: gen_appbin.py eagle.app.out boot_mode flash_mode flash_clk_div flash_size_map ../../esp-sdk/tools/gen_appbin.py .objs/app.out 2 0 0 2 1 mv: cannot stat ‘eagle.app.flash.bin’: No such file or directory ../../Makefile.common:206: recipe for target '.firmwares/user1.bin' failed make: *\ [.firmwares/user1.bin] Error 1 greg@hal:~/esp8266-dev/work/sonoff$

mgf909 commented 8 years ago

Ive done a clean...

greg@hal:~/esp8266-dev/work/sonoff$ make clean greg@hal:~/esp8266-dev/work/sonoff$ make CC -c modules/config.c -o .objs/config.o CC -c modules/ota.c -o .objs/ota.o CC -c modules/wifi.c -o .objs/wifi.o CC -c modules/rtc.c -o .objs/rtc.o CC -c ./user/user_main.c -o .objs/user_main.o CC -c ../../dev/driver/uart.c -o .objs/uart.o CC -c ../../dev/driver/gpio16.c -o .objs/gpio16.o CC -c ../../dev/driver/spi.c -o .objs/spi.o CC -c ../../dev/driver/key.c -o .objs/key.o CC -c ../../dev/driver/i2c_master.c -o .objs/i2c_master.o CC -c ../../dev/driver/mcp3221.c -o .objs/mcp3221.o CC -c ../../dev/utils/utils.c -o .objs/utils.o CC -c ../../apps/mqtt/mqtt.c -o .objs/mqtt.o CC -c ../../apps/mqtt/ringbuf.c -o .objs/ringbuf.o CC -c ../../apps/mqtt/mqtt_msg.c -o .objs/mqtt_msg.o CC -c ../../apps/mqtt/queue.c -o .objs/queue.o CC -c ../../apps/mqtt/proto.c -o .objs/proto.o LD -T../../esp-sdk/ld/eagle.app.v6.new.1024.app1.ld .objs/app.out Usage: gen_appbin.py eagle.app.out boot_mode flash_mode flash_clk_div flash_size_map ../../esp-sdk/tools/gen_appbin.py .objs/app.out 2 0 0 2 1 mv: cannot stat ‘eagle.app.flash.bin’: No such file or directory ../../Makefile.common:206: recipe for target '.firmwares/user1.bin' failed make: *\ [.firmwares/user1.bin] Error 1 greg@hal:~/esp8266-dev/work/sonoff$

arendst commented 8 years ago

Problem is caused by additional gen_appbin.py parameter introduced with SDK 1.5. I've updated the Makefile.common file with a SDK 1.4 flag. Please use the updated file and try again.

mgf909 commented 8 years ago

That works! Thanmk you so much for sharing your code and also to help me get up and going. I really appreciate it!.

mgf909 commented 8 years ago

Hi Theo me again...sorry - whilst i was able to compile it successfully, and flash it seemingly successfully, on my windows PC using esptool (esptool.py -p com9 write_flash 0x00000 d:\IOT\SonoffMQTT\user1.bin)

But the serial connection just gives a small amount of garbarge and stops. The led does not flash or respond to button presses and it does not connect to the wifi.

Can i compile the user1.bin and send it to you to see if it works on your device? ( i would obviously reset back the wifi/mqtt server settings in user_config.h to your specific settings) If this is OK then ill attach here.

arendst commented 8 years ago

You're esptool.py command line is incomplete. Please take a look in Makefile.common from line 239 what the correct options are. You'll need a boot_v1.4(b1).bin file at 0x00000, your compiled bin file at 0x80000 , esp_init_data_default.bin at 0xFC000 and blank.bin at 0xFE0000. The three files can be found in your esp8266-dev/esp-sdk/bin directory.

mgf909 commented 8 years ago

Thanks again...im learning a great deal from you. I have done as you kindly advise : D:\IOT\esptool\esptool>esptool.py -p com9 write_flash 0x00000 d:\iot\SonoffMQTT\boot_v1.4(b1).bin 0x80000 D:\IOT\SonoffMQTT\user1.bin 0xFC000 D:\IOT\SonoffMQTT\esp_init_data_default.bin 0xFE000 D:\IOT\SonoffMQTT\blank.bin Connecting... Erasing flash... Took 0.09s to erase flash block Wrote 3072 bytes at 0x00000000 in 0.3 seconds (73.4 kbit/s)... Erasing flash... Took 1.02s to erase flash block Wrote 310272 bytes at 0x00080000 in 59.9 seconds (41.4 kbit/s)... Erasing flash... Took 0.09s to erase flash block Wrote 1024 bytes at 0x000fc000 in 0.1 seconds (74.5 kbit/s)... Erasing flash... Took 0.10s to erase flash block Wrote 4096 bytes at 0x000fe000 in 0.4 seconds (79.0 kbit/s)...

Leaving...

but unfortunately same issue....some garbage at the serial connection.

I have also tried to do a "erase_flash" and also "verify_flash" - both of these were successful when i ran them.

Any other ideas? I really do appreciate your assistance.

arendst commented 8 years ago

Well you're running out of options. I suppose after the flash you remove the serial connection and connect AC to sonoff. This will reboot sonoff and allows you to press the button as documented in README.md. There is no need to keep serial connected as you can't control sonoff using it.

mgf909 commented 8 years ago

OK - ill try in the morning ( midnight here) . I was hoping to see basic "im conne3cted messages on the serial, but ill connect to AC and see if it comes to life.!

Thanks again...will advise.

arendst commented 8 years ago

As correction you'll need to change the address of your compiled bin file from 0x80000 to 0x01000 in your esptool.py command line. Executing make flash will reveal the correct syntax.

mgf909 commented 8 years ago

YAY!!!!

It has connected!!!

Thank you so so much! I have learnt a lot from this...but clearly still have a lot more to learn. Once again, i really appreciate your help ;-)