Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By mariuszb
#12598 BMP180 example:

In file i2c_bmp180.c should such a two change (in bold):


bool ICACHE_FLASH_ATTR BMP180_Init()
{

i2c_init(); // ----------------- should be added here

int16_t version = BMP180_readRegister16(BMP180_CHIP_ID_REG);
if ((version >> 8) != BMP180_CHIP_ID) {
#ifdef BMP180_DEBUG
char temp[80];
os_sprintf(temp, "BMP180: wanted chip id 0x%X, found chip id 0x%X\r\n",
BMP180_CHIP_ID, version);
ets_uart_printf(temp);
#endif
return 0;
}

if (!BMP180_readRegister16(BMP180_VERSION_REG))
return 0;

#ifdef BMP180_DEBUG
//os_printf("BMP180 read calibration data...\r\n");
ets_uart_printf("BMP180 read calibration data...\r\n");
#endif
ac1 = BMP180_readRegister16(0xAA);
ac2 = BMP180_readRegister16(0xAC);
ac3 = BMP180_readRegister16(0xAE);
ac4 = BMP180_readRegister16(0xB0);
ac5 = BMP180_readRegister16(0xB2);
ac6 = BMP180_readRegister16(0xB4);
b1 = BMP180_readRegister16(0xB6);
b2 = BMP180_readRegister16(0xB8);
mb = BMP180_readRegister16(0xBA);
mc = BMP180_readRegister16(0xBC);
md = BMP180_readRegister16(0xBE);

#ifdef BMP180_DEBUG
ets_uart_printf("BMP180_Calibration:\r\n");

char temp[80]; //80 bytes buffer is too small for this prints -----------, eg. use 128 bytes

os_sprintf(temp, "AC1: %ld, AC2: %ld, AC3: %ld, AC4: %ld, AC5: %ld, AC6: %ld, B1: %ld, B2: %ld, MB: %ld, MC: %ld, MD: %ld\r\n",
ac1, ac2, ac3, ac4, ac5, ac6, b1, b2, mb, mc, md);
ets_uart_printf(temp);
#endif
return true;
}
User avatar
By alon24
#12646 Hi,
I am using version 1.12 and its very very good, but I have a few issues with flashing, and I wonder if someone can help:
1.Lets take HelloWorld example (happens all the time with my code,, but this is simplest):

After running clean and rebuild i run flash:
Code: Select all08:02:41 **** Build of configuration Default for project hello_world ****
mingw32-make.exe -f C:/Espressif/examples/hello_world/Makefile flash
c:/Espressif/utils/esptool-ck.exe -cp COM2 -cd ck -ca 0x00000 -cf firmware/eagle.flash.bin -v
esptool v0.4.1-3-g9ab93f4 - (c) 2014 Ch. Klippel <ck@atelier-klippel.de>
opening bootloader
resetting board
trying to connect
trying to connect
Uploading 28960 bytes from firmware/eagle.flash.bin to flash at 0x00000000
.............................
starting app without reboot
closing bootloader
c:/Espressif/utils/esptool-ck.exe -cp COM2 -cd ck -cb 256000 -ca 0x40000 -cf firmware/eagle.irom0text.bin -v
esptool v0.4.1-3-g9ab93f4 - (c) 2014 Ch. Klippel <ck@atelier-klippel.de>
opening bootloader
resetting board
trying to connect
trying to connect
trying to connect
resetting board
trying to connect
trying to connect
trying to connect
resetting board
trying to connect
mingw32-make.exe: *** [flash] Error -1
trying to connect
trying to connect
warning: espcomm_sync failed
error: espcomm_open failed
C:/Espressif/examples/hello_world/Makefile:320: recipe for target 'flash' failed

08:02:52 Build Finished (took 11s.130ms)



If I try with flashonefile it all works:
Code: Select all08:04:35 **** Build of configuration Default for project hello_world ****
mingw32-make.exe -f C:/Espressif/examples/hello_world/Makefile flashonefile
c:/Espressif/xtensa-lx106-elf/bin/xtensa-lx106-elf-objcopy --only-section .text -O binary build/app.out eagle.app.v6.text.bin
c:/Espressif/xtensa-lx106-elf/bin/xtensa-lx106-elf-objcopy --only-section .data -O binary build/app.out eagle.app.v6.data.bin
c:/Espressif/xtensa-lx106-elf/bin/xtensa-lx106-elf-objcopy --only-section .rodata -O binary build/app.out eagle.app.v6.rodata.bin
c:/Espressif/xtensa-lx106-elf/bin/xtensa-lx106-elf-objcopy --only-section .irom0.text -O binary build/app.out eagle.app.v6.irom0text.bin
c:/Espressif/utils/gen_appbin_old.exe build/app.out v6
text start_addr 0x40100004
data start_addr 0x3ffe8000
rodata start_addr 0x3ffe89f0
ERROR: text seg len is 62f6 is NOT 4-byte aligned!! Need to pad
text size62f8
data size9f0
rodata size414
header size is 8 block header size 18 total size is 711d pad is 0x3 blocks 
chksum text d5
chksum data 6
chksum all c1
text load_addr 0x40100000 len 0x62f8
data load_addr 0x3ffe8000 len 0x9f0
rodata load_addr 0x3ffe89f0 len 0x414
40100004
3ffe8000
3ffe89f0
C:\Espressif\utils\genflashbinv6 eagle.app.v6.text.bin 40100004 eagle.app.v6.data.bin 3ffe8000 eagle.app.v6.rodata.bin 3ffe89f0
ren eagle.app.flash.bin eagle.app.v6.flash.bin
c:/Espressif/utils/gen_flashbin.exe eagle.app.v6.flash.bin eagle.app.v6.irom0text.bin 0x40000
rm -f eagle.app.v6.data.bin
rm -f eagle.app.v6.flash.bin
rm -f eagle.app.v6.irom0text.bin
rm -f eagle.app.v6.rodata.bin
rm -f eagle.app.v6.text.bin
rm -f eagle.app.sym
mv eagle.app.flash.bin firmware/
No boot needed.
Generate eagle.app.flash.bin successully in folder firmware.
eagle.app.flash.bin-------->0x00000
new
c:/Espressif/utils/esptool-ck.exe -cp COM2 -cd ck -cb 256000 -ca 0x00000 -cf firmware/eagle.app.flash.bin -v
esptool v0.4.1-3-g9ab93f4 - (c) 2014 Ch. Klippel <ck@atelier-klippel.de>
opening bootloader
resetting board
trying to connect
trying to connect
Uploading 406264 bytes from firmware/eagle.app.flash.bin to flash at 0x00000000
.............................................................................................................................................................................................................................................................................................................................................................................................................
starting app without reboot
closing bootloader

08:04:56 Build Finished (took 21s.689ms)


The device is reset and the prog starts to work.

2. How should I hook the device? right now gpio0 is connected to ground (no resistor, just to gnd), and I wonder if that is the correct form, for this wot work well?
As I understood it, its supposed to be that when I start flash, it would reset device to bootlader mode on its own, is that how it should work? am I doing something wrong here?
Thanks
User avatar
By alon24
#12647 Forgot to say - that was with esptoolmode new.

What is the difference with old and new?
This is with old:
Code: Select all08:10:06 **** Build of configuration Default for project hello_world ****
mingw32-make.exe -f C:/Espressif/examples/hello_world/Makefile flash
c:/Espressif/utils/esptool.exe -p COM2 -b 256000 write_flash 0x00000 firmware/eagle.flash.bin 0x40000 firmware/eagle.irom0text.bin
Entering bootloader...
Connecting...
Erasing flash...
head: 8 ;total: 8
erase size : 16384

Writing at 0x00000000... (3 %)
Writing at 0x00000400... (6 %)
Writing at 0x00000800... (10 %)
Writing at 0x00000c00... (13 %)
Writing at 0x00001000... (17 %)
Writing at 0x00001400... (20 %)
Writing at 0x00001800... (24 %)
Writing at 0x00001c00... (27 %)
Writing at 0x00002000... (31 %)
Writing at 0x00002400... (34 %)
Writing at 0x00002800... (37 %)
Writing at 0x00002c00... (41 %)
Writing at 0x00003000... (44 %)
Writing at 0x00003400... (48 %)
Writing at 0x00003800... (51 %)
Writing at 0x00003c00... (55 %)
Writing at 0x00004000... (58 %)
Writing at 0x00004400... (62 %)
Writing at 0x00004800... (65 %)
Writing at 0x00004c00... (68 %)
Writing at 0x00005000... (72 %)
Writing at 0x00005400... (75 %)
Writing at 0x00005800... (79 %)
Writing at 0x00005c00... (82 %)
Writing at 0x00006000... (86 %)
Writing at 0x00006400... (89 %)
Writing at 0x00006800... (93 %)
Writing at 0x00006c00... (96 %)
Writing at 0x00007000... (100 %)
Erasing flash...
head:  16 ;total: 36
erase size :  81920

Writing at 0x00040000... (0 %)
Writing at 0x00040400... (1 %)
Writing at 0x00040800... (2 %)
Writing at 0x00040c00... (2 %)
Writing at 0x00041000... (3 %)
Writing at 0x00041400... (4 %)
Writing at 0x00041800... (4 %)
Writing at 0x00041c00... (5 %)
Writing at 0x00042000... (6 %)
Writing at 0x00042400... (7 %)
Writing at 0x00042800... (7 %)
Writing at 0x00042c00... (8 %)
Writing at 0x00043000... (9 %)
Writing at 0x00043400... (9 %)
Writing at 0x00043800... (10 %)
Writing at 0x00043c00... (11 %)
Writing at 0x00044000... (12 %)
Writing at 0x00044400... (12 %)
Writing at 0x00044800... (13 %)
Writing at 0x00044c00... (14 %)
Writing at 0x00045000... (14 %)
Writing at 0x00045400... (15 %)
Writing at 0x00045800... (16 %)
Writing at 0x00045c00... (17 %)
Writing at 0x00046000... (17 %)
Writing at 0x00046400... (18 %)
Writing at 0x00046800... (19 %)
Writing at 0x00046c00... (19 %)
Writing at 0x00047000... (20 %)
Writing at 0x00047400... (21 %)
Writing at 0x00047800... (21 %)
Writing at 0x00047c00... (22 %)
Writing at 0x00048000... (23 %)
Writing at 0x00048400... (24 %)
Writing at 0x00048800... (24 %)
Writing at 0x00048c00... (25 %)
Writing at 0x00049000... (26 %)
Writing at 0x00049400... (26 %)
Writing at 0x00049800... (27 %)
Writing at 0x00049c00... (28 %)
Writing at 0x0004a000... (29 %)
Writing at 0x0004a400... (29 %)
Writing at 0x0004a800... (30 %)
Writing at 0x0004ac00... (31 %)
Writing at 0x0004b000... (31 %)
Writing at 0x0004b400... (32 %)
Writing at 0x0004b800... (33 %)
Writing at 0x0004bc00... (34 %)
Writing at 0x0004c000... (34 %)
Writing at 0x0004c400... (35 %)
Writing at 0x0004c800... (36 %)
Writing at 0x0004cc00... (36 %)
Writing at 0x0004d000... (37 %)
Writing at 0x0004d400... (38 %)
Writing at 0x0004d800... (39 %)
Writing at 0x0004dc00... (39 %)
Writing at 0x0004e000... (40 %)
Writing at 0x0004e400... (41 %)
Writing at 0x0004e800... (41 %)
Writing at 0x0004ec00... (42 %)
Writing at 0x0004f000... (43 %)
Writing at 0x0004f400... (43 %)
Writing at 0x0004f800... (44 %)
Writing at 0x0004fc00... (45 %)
Writing at 0x00050000... (46 %)
Writing at 0x00050400... (46 %)
Writing at 0x00050800... (47 %)
Writing at 0x00050c00... (48 %)
Writing at 0x00051000... (48 %)
Writing at 0x00051400... (49 %)
Writing at 0x00051800... (50 %)
Writing at 0x00051c00... (51 %)
Writing at 0x00052000... (51 %)
Writing at 0x00052400... (52 %)
Writing at 0x00052800... (53 %)
Writing at 0x00052c00... (53 %)
Writing at 0x00053000... (54 %)
Writing at 0x00053400... (55 %)
Writing at 0x00053800... (56 %)
Writing at 0x00053c00... (56 %)
Writing at 0x00054000... (57 %)
Writing at 0x00054400... (58 %)
Writing at 0x00054800... (58 %)
Writing at 0x00054c00... (59 %)
Writing at 0x00055000... (60 %)
Writing at 0x00055400... (60 %)
Writing at 0x00055800... (61 %)
Writing at 0x00055c00... (62 %)
Writing at 0x00056000... (63 %)
Writing at 0x00056400... (63 %)
Writing at 0x00056800... (64 %)
Writing at 0x00056c00... (65 %)
Writing at 0x00057000... (65 %)
Writing at 0x00057400... (66 %)
Writing at 0x00057800... (67 %)
Writing at 0x00057c00... (68 %)
Writing at 0x00058000... (68 %)
Writing at 0x00058400... (69 %)
Writing at 0x00058800... (70 %)
Writing at 0x00058c00... (70 %)
Writing at 0x00059000... (71 %)
Writing at 0x00059400... (72 %)
Writing at 0x00059800... (73 %)
Writing at 0x00059c00... (73 %)
Writing at 0x0005a000... (74 %)
Writing at 0x0005a400... (75 %)
Writing at 0x0005a800... (75 %)
Writing at 0x0005ac00... (76 %)
Writing at 0x0005b000... (77 %)
Writing at 0x0005b400... (78 %)
Writing at 0x0005b800... (78 %)
Writing at 0x0005bc00... (79 %)
Writing at 0x0005c000... (80 %)
Writing at 0x0005c400... (80 %)
Writing at 0x0005c800... (81 %)
Writing at 0x0005cc00... (82 %)
Writing at 0x0005d000... (82 %)
Writing at 0x0005d400... (83 %)
Writing at 0x0005d800... (84 %)
Writing at 0x0005dc00... (85 %)
Writing at 0x0005e000... (85 %)
Writing at 0x0005e400... (86 %)
Writing at 0x0005e800... (87 %)
Writing at 0x0005ec00... (87 %)
Writing at 0x0005f000... (88 %)
Writing at 0x0005f400... (89 %)
Writing at 0x0005f800... (90 %)
Writing at 0x0005fc00... (90 %)
Writing at 0x00060000... (91 %)
Writing at 0x00060400... (92 %)
Writing at 0x00060800... (92 %)
Writing at 0x00060c00... (93 %)
Writing at 0x00061000... (94 %)
Writing at 0x00061400... (95 %)
Writing at 0x00061800... (95 %)
Writing at 0x00061c00... (96 %)
Writing at 0x00062000... (97 %)
Writing at 0x00062400... (97 %)
Writing at 0x00062800... (98 %)
Writing at 0x00062c00... (99 %)
Writing at 0x00063000... (100 %)

Leaving...
c:/Espressif/utils/esptool.exe -p COM2 write_flash 0x7c000 c:/Espressif/ESP8266_SDK/bin/esp_init_data_default.bin 0x7e000 c:/Espressif/ESP8266_SDK/bin/blank.bin
Entering bootloader...
Connecting...
Traceback (most recent call last):
  File "esptool.py", line 559, in <module>
  File "esptool.py", line 154, in connect
Exception: Failed to connect
C:/Espressif/examples/hello_world/Makefile:323: recipe for target 'flash' failed
mingw32-make.exe: *** [flash] Error 255

08:10:22 Build Finished (took 16s.41ms)