Shop OBEX P1 Docs P2 Docs Learn Events
Got proploader and SimpleIDE working with ESP-01S wifi module — Parallax Forums

Got proploader and SimpleIDE working with ESP-01S wifi module

roglohrogloh Posts: 5,787
edited 2017-06-20 09:58 in Propeller 1
Hi all,
In the last couple of days I have been playing around with the small ESP-01S module in a Propeller project I have be working on and found a way to get it to work with proploader and SimpleIDE for wifi resets/downloads and for its very handy telnet terminal serving of the Propeller's debug serial port. Maybe someone already got this working before but I was unable to find it online when I first looked around, so I just tried to do it myself.

Normally it would be easier to just use a Parallax WX wifi module to do what I want but in my case the project's physical size is too small and the ESP-01S better suited the bill. The main problem was that this ESP-01 board only exposes GPIO0 and GPIO2 and the Parallax-ESP firmware normally only supports GPIOs12, 13, 15 for RESET of the prop which are not brought out onto any external IO pins on the ESP-01S so some tweaks were required to make it work.

I started with the Parallax-ESP firmware codebase from github and followed the instructions there to successfully get it to build with the ESP toolchain. In my case I used a Mac. See here:
https://github.com/parallaxinc/Parallax-ESP

Then I made these four changes (diffs from Parallax-ESP root level shown below) and rebuilt:
1) support the 1MB flash size module on the ESP-01S instead of 4MB by default in the Makefile.
2) Use boot image 1.6 (version 1.5 was not present in the ESP tools I had, so I just used 1.6 instead).
3) In the HTML web page, allow GPIO0 and GPIO2 to be passed in as reset pin options for the flash configuration.
4) Add a missing URL that SimpleIDE and PropLoader used to reset the propeller. I found this by some WireSharking on my Wifi network and seeing what was failing when the Prop was being reset and I was getting 404 File not found errors as the response. Once I fixed this the propeller could be reset by GPIO0 or GPIO2.

Note that there is a limitation with using these GPIOs for reset as both of these pins do output some transitions upon ESP-01 module startup that will reset the Propeller multiple times initially.

GPIO2 has some serial output at 74800bps showing boot information. In theory it can also be used as a debug UART output later on so probably best to not enable ESP DBG in the settings if you choose this. It might be possible to tweak things to stop the serial debug output on GPIO2 from bootup but I haven't looked into it in depth so I'm not sure.

GPIO0 outputs some 2MHz clock burst at ESP startup time. However after about 150ms both this and the other GPIO2 output cease and the system seems to be stable from then on. In my application this is not really an issue as I am working with a P1V that has some FPGA configuration reset delays anyway. Also one thing to consider if you have an external propeller reset button wired in parallel and GPIO0 is ever held low at ESP-01S power up time then you are likely to boot up in ESP8266 serial flashing mode, so be wary of this too. GPIO2 is probably safer.

The smaller ESP-01S flash size of 1MB would not allow a large amount of extra user web content to be added in compared to the larger capacity devices, but so far the base set of features is useful enough for my needs. I could always replace the flash chip on the ESP module one day if required.

If this information is useful to anyone else, enjoy.
Roger.
diff --git a/Makefile b/Makefile
index 4758abe..d7048c7 100644
--- a/Makefile
+++ b/Makefile
@@ -31,7 +31,7 @@ VERSION=$(GIT_VERSION) ($(shell date "+%Y-%m-%d %H:%M:%S")$(GIT_COMMIT_HASH_SUFF
 $(info VERSION $(VERSION))
 
 #SPI flash size, in K
-ESP_SPI_FLASH_SIZE_K=4096
+ESP_SPI_FLASH_SIZE_K=1024
 #Amount of the flash to use for the image(s)
 ESP_SPI_IMAGE_SIZE_K=1024
 #0: QIO, 1: QOUT, 2: DIO, 3: DOUT
diff --git a/Makefile.ota b/Makefile.ota
index b6b67e2..15ecdf8 100644
--- a/Makefile.ota
+++ b/Makefile.ota
@@ -84,7 +84,7 @@ $(FW_BASE): $(TARGET_BIN) libesphttpd/mkupgimg/mkupgimg
        $(Q) libesphttpd/mkupgimg/mkupgimg $(TARGET_BIN_USR1) $(TARGET_BIN_USR2) $(TAGNAME) $(TARGET_OTAFILE)
 
 flash: $(TARGET_OUT) $(FW_BASE)
-       $(Q) $(ESPTOOL) $(ESPTOOL_OPTS) write_flash $(ESPTOOL_FLASHDEF) 0x00000 "$(SDK_BASE)/bin/boot_v1.5.bin" 0x1000 $(TARGET_BIN_USR1)
+       $(Q) $(ESPTOOL) $(ESPTOOL_OPTS) write_flash $(ESPTOOL_FLASHDEF) 0x00000 "$(SDK_BASE)/bin/boot_v1.6.bin" 0x1000 $(TARGET_BIN_USR1)

 blankflash:
        $(Q) $(ESPTOOL) $(ESPTOOL_OPTS) write_flash $(ESPTOOL_FLASHDEF) $(BLANKPOS) $(SDK_BASE)/bin/blank.bin $(INITDATAPOS) $(SDK_BASE)/bin/esp_init_data_default.bin
diff --git a/html/settings.html b/html/settings.html
index b9dccf8..0df8cb4 100755
--- a/html/settings.html
+++ b/html/settings.html
@@ -40,6 +40,8 @@
             <td>Reset Pin:</td>
             <td>
               <select id="reset-pin">
+                <option value="0">PGM (GPIO0)</option>
+                <option value="2">DBG (GPIO2)</option>
                 <option value="12">DTR (GPIO12)</option>
                 <option value="13">CTS (GPIO13)</option>
                 <option value="15">RTS (GPIO15)</option>
diff --git a/parallax/user_main.c b/parallax/user_main.c
index 533e525..28563d2 100644
--- a/parallax/user_main.c
+++ b/parallax/user_main.c
@@ -175,6 +175,7 @@ HttpdBuiltInUrl builtInUrls[]={
     { "/propeller/load-file", cgiPropLoadFile, NULL },
     { "/propeller/reset", cgiPropReset, NULL },
     { "/wx/module-info", cgiPropModuleInfo, NULL },
+    { "/wx/propeller/reset", cgiPropReset, NULL },
     { "/wx/setting", cgiPropSetting, NULL },
     { "/wx/save-settings", cgiPropSaveSettings, NULL },
     { "/wx/restore-settings", cgiPropRestoreSettings, NULL },

Comments

  • roglohrogloh Posts: 5,787
    edited 2017-06-20 09:52
    Now if only PropellerIDE supported the use of proploader or Wifi access directly, I'd be set. Instead I need to manually send a binary from the command line tools if I want to play with Spin code in PropellerIDE instead of using C in SimpleIDE (which is still okay, its just a couple more manual steps). I did once intercept and hack the called bstc tools for getting the handy listfile generated and displayed in PropellerIDE so perhaps it can be done in a similar way if any command line calls for programming the propeller can be translated (haven't checked how it is done there but if/when I get a chance I might look into that too). I'm really not sure what is the ongoing plan for PropellerIDE anymore. Continued development on it seems to have stopped lately which is a shame.

    Update: While playing around with output binary files I encountered some strange PropellerIDE behavior. The binary file format it saves off from the memory map window has an extra 4 bytes prepended to it which makes it not compatible with proploader. However thankfully the binary that PropellerIDE generates on its own by its Build process itself is able to be read ok by the proploader tool and can be downloaded via Wifi to the prop. Not really sure what those extra magic 4 first bytes in the memory map generated file were meant to be for, values were (00 00 12 B4). Am using version 0.38.5.
  • It's odd that /wx/propeller/reset was missing. It's also odd that /propeller/reset was there. I should check to see if the GitHub repository is up to date.
  • I checked into this and the Parallax docs say that /propeller/reset is the correct URL for resetting the Propeller. I've fixed the code in the PropLoader repository to reflect that. Thanks for pointing this out!
  • roglohrogloh Posts: 5,787
    edited 2017-06-23 06:48
    No problem David. This code you've put together and integrated from other people is great, it is really useful.
    I am finding that programming propellers wirelessly (e.g. for robotics etc) is extremely handy and fast too.

    I also just managed (via a slight hack) to integrate the wireless programming into the PropellerIDE build button. I just added another line to my bstc script mod I had done earlier to download after compile if the compile is successful. It's a bit hardcoded with its IP right now but could be enhanced to use environment variables etc and to determine whether this step is done and what IP to use. Unfortunately the PropellerIDE download to RAM and EEPROM program buttons do not yet integrate with the wireless ESP device or get used in its terminal window / serial port selection like SimpleIDE does. If it did it would be very handy indeed but until that ever happens, I found what I have done suits me pretty well. Better than needing the extra manual step anyway. I just press F9 and the wifi download happens automagically. I love it.
    Cheers.
    Roger.
    #!/bin/bash
    
    # add the extra compiler options here
    EXTRAOPTS=-l
    
    # display the command being invoked
    echo $0 $EXTRAOPTS $@ 
    
    # detemine the name of the listing file 
    LISTFILE=`echo $1 | sed s/\.[a-zA-Z_0-9]*$/\.list/`
    
    # delete the old listing file in case of error so we don't get stale output
    rm -f $LISTFILE
    
    # call the real compiler
    $02 $EXTRAOPTS $@
    
    # display the listing file only if it was produced
    if [ -f $LISTFILE ] ; then cat $LISTFILE; else exit 1; fi
    
    # run Wifi download
    /Applications/SimpleIDE.app/Contents/MacOS/proploader -i 192.168.1.6 `echo $1 | sed s/\.[a-zA-Z_0-9]*$/\.binary/`
    

    Note: this script (for Mac) replaces the original bstc command and that should be named bstc2 and both stored in the same folder where bstc was originally. Windows and Linux users make be read from different folders and need other customizations so YMMV.
  • You're building the firmware on the Mac? I tried that early on and didn't have much luck. What did you have to do to make that work? Did you need to use one of the non-Apple package managers to install extra tools?
  • roglohrogloh Posts: 5,787
    edited 2017-06-25 13:34
    Yeah there was a little bit of mucking about with the ESP tools. I wish I still had it all in my history but it is too far back. I used homebrew and I do recall there was some extra stuff loaded there. I do know I needed this extra pip thing for python esptool for flashing the ESP-01S module. The other stuff I think I probably just followed the ESP open SDK tools instructions as repeated here... I actually did the virtual disk case sensitive thing too.

    ## MacOS:
    ```bash
    $ brew tap homebrew/dupes
    $ brew install binutils coreutils automake wget gawk libtool help2man gperf gnu-sed --with-default-names grep
    $ export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"
    ```

    In addition to the development tools MacOS needs a case-sensitive filesystem.
    You might need to create a virtual disk and build esp-open-sdk on it:
    ```bash
    $ sudo hdiutil create ~/Documents/case-sensitive.dmg -volname "case-sensitive" -size 10g -fs "Case-sensitive HFS+"
    $ sudo hdiutil mount ~/Documents/case-sensitive.dmg
    $ cd /Volumes/case-sensitive
    ```
Sign In or Register to comment.