Chat about current Lua tools and IDEs

User avatar
By hamishcunningham
#6853 Hi folks. NodeMCU is great -- thanks!

I've spent a while figuring out how to rebuild and flash the firmware on Ubuntu 14.04 using the esp-open-sdk toolchain.

I've got it to work but the method is a bit involved and doesn't seem to be documented anywhere very obvious. Does anyone know
if there is a better way, or if it would be good to patch the relevant scripts (e.g. app/gen_misc.sh) and do a pull request? Some detail
of the method below; I've also raised this issue: https://github.com/nodemcu/nodemcu-firmware/issues/86

First I install the toolchain from https://github.com/pfalcon/esp-open-sdk (I used the instructions from
http://nathan.chantrell.net/20141230/wi ... e-esp8266/).
Then I clone nodemcu-firmware, cd there and "make". After the initial "make" I do

Code: Select all    cd app; gen_misc.sh


This creates some .bin files, but the gen_misc.sh call invokes gen_appbin.py,
which then calls genflashbinv6 -- which isn't available except as a binary for
Windows.

So we get part way there, but not all the .bin files are generated. So then I
use the method from https://github.com/esp8266/esp8266-wiki/wiki/Building to
finish off:

Code: Select all    cd .output/eagle/debug/image
    esptool-ck/esptool -eo eagle.app.v6.out -bo eagle.app.v6.flash.bin -bs .text -bs .data -bs .rodata -bc -ec
    xtensa-lx106-elf-objcopy --only-section .irom0.text -O binary eagle.app.v6.out eagle.app.v6.irom0text.bin
    cp eagle.app.v6.flash.bin ../../../../../bin/
    cp eagle.app.v6.irom0text.bin ../../../../../bin/


And this gives me the full set of files that I can then flash to the chip like this:

Code: Select all    esptool.py --port /dev/ttyAMA0 write_flash 0x00000 eagle.app.v6.flash.bin 0x10000 eagle.app.v6.irom0text.bin 0x7c000 esp_init_data_default.bin 0x7e000 blank.bin

This works :-) (though it was quite hard to figure out!).

So perhaps gen_appbin.py should just omit the genflashbinv6 call on linux, and
gen_misc.sh do the above instead? Or perhaps there's a better way to take the
results of the initial build and make them flashable?

Cheers,
Hamish
User avatar
By sej7278
#6863 here's how i do it on debian sid with ~/esp-open-sdk/xtensa-lx106-elf/bin and /usr/local/bin/genflashbinv6 in my $PATH:

Code: Select allmake
cd app/
./gen_misc.sh
../tools/gen_flashbin.py ../bin/eagle.app.v6.flash.bin ../bin/eagle.app.v6.irom0text.bin
mv eagle.app.flash.bin ../bin/
cd ../bin/
cp ../pre_build/0.9.2/4M-flash/blank.bin .
cp ../pre_build/0.9.2/4M-flash/esp_init_data_default.bin .

esptool.py --port /dev/ttyUSB0 write_flash \
    0x00000 eagle.app.v6.flash.bin \
    0x10000 eagle.app.v6.irom0text.bin \
    0x7c000 esp_init_data_default.bin \
    0x7e000 blank.bin


this seems to work just using esptool.py's new elf2image support, but i'm not sure its correct, it built/flashed/ran nodemcu 0.9.5 b20150108 fine:

Code: Select allmake
cd app/.output/eagle/debug/image
esptool.py elf2image eagle.app.v6.out
esptool.py write_flash 0x00000 eagle.app.v6.out-0x00000.bin 0x10000 eagle.app.v6.out-0x10000.bin


but also there's now a flash.sh script that does something different again: https://github.com/nodemcu/nodemcu-firm ... p/flash.sh