How I built a custom firmware for frozen bytecode

  • Pybytes Beta

    Some rough notes to hopefully save others hassle. I think these were all the steps, but if you find something not working let me know and I'll check my command history.

    My setup is I have a Linux Mint VM (Very similar to Ubuntu and Debian) and a Windows desktop with Cygwin installed that I used for flashing. Mint is apt-get dist-update up to date as of this posting.

    So here's what I could piece together from my command history:

    sudo su - # Yeah, I do everything as root. Sue me.
    apt-get install build-essential git
    cd /root
    vi .profile # Add the export above
    sudo su -
    git clone
    git clone
    cd pycom-esp-idf
    git submodule update --init # Don't recall why I did this sorry
    cd /root
    tar zxf xtensa-esp32-elf-linux64-1.22.0-61-gab8375a-5.2.0.tar.gz
    • Then I copied my custom code into /root/pycom-micropython-sigfox/esp32/frozen/

    • Ran the build commands, and actually I rolled them into to make re-running simpler.

    cd /root/pycom-micropython-sigfox/esp32
    make clean # May not be desired if doing active development?
    rm -rf frozen/__pycache__
    export IDF_PATH=~/pycom-esp-idf
    export BUILD_VERBOSE=true
    make BOARD=WIPY TARGET=boot
    make BOARD=WIPY TARGET=app
    cp build/WIPY/release/wipy.bin /home/betterauto/
    cp build/WIPY/release/bootloader/bootloader.bin /home/betterauto/
    cp build/WIPY/release/lib/partitions.bin /home/betterauto/
    chown betterauto /home/betterauto/*.bin
    • Copied the *bin files to my Windows desktop.
    • I already had the Pycom firmware updater installed and I used its My serial UART is plugged into COM18 in Windows, which in Cygwin is /dev/ttyS17. (Like good geeks, they start counting at zero.)
    • Grounded Pin 23
    • Here are the commands I used to flash. Found them here. It's probably possible to consolidate these into one command but I haven't tried it yet. I saw in some examples that they combined firmware files on the command line like 0x1000 Desktop/bootloader.bin 0x8000 Desktop/partitions.bin 0x10000 Desktop/wipy.bin. I also saw that some flags such as --flash_mode or --flash_freq may not be needed. I haven't experimented.
    /cygdrive/c/Program\ Files\ \(x86\)/Pycom/Pycom\ Firmware\ Update/Upgrader/bin/ --chip esp32 --port /dev/ttyS17 --baud 115200 --after no_reset write_flash --flash_mode dio --flash_freq 80m --flash_size detect 0x1000 Desktop/bootloader.bin
    /cygdrive/c/Program\ Files\ \(x86\)/Pycom/Pycom\ Firmware\ Update/Upgrader/bin/ --chip esp32 --port /dev/ttyS17 --baud 115200 --after no_reset write_flash --flash_mode dio --flash_freq 80m --flash_size detect 0x8000 Desktop/partitions.bin
    /cygdrive/c/Program\ Files\ \(x86\)/Pycom/Pycom\ Firmware\ Update/Upgrader/bin/ --chip esp32 --port /dev/ttyS17 --baud 115200 --after no_reset write_flash --flash_mode dio --flash_freq 80m --flash_size detect 0x10000 Desktop/wipy.bin
    • Pulled off the Pin 23 ground and reset the device, it came right up.
    rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
    ets Jun  8 2016 00:22:57
    rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
    configsip: 0, SPIWP:0xee
    mode:DIO, clock div:1
    ho 0 tail 12 room 4
    entry 0x4009fc9c
    MicroPython 3f93fc2 on 2017-10-09; WiPy with ESP32
    Type "help()" for more information.

  • @betterauto I found this redirection of USB to a VM often flaky. VMware works better than Virtualbox.

  • Pybytes Beta

    @robert-hh I could not, because my VM is on a different machine than the machine I use to flash. Though I could have plugged the UART into the machine with the VM and redirected the USB device to the VM, then it likely would have worked.

  • @betterauto You can simply type:
    make flash
    to upload the firmware via USB, if USB is usable, which is problematic in a VM.

Log in to reply

Pycom on Twitter

Looks like your connection to Pycom Forum was lost, please wait while we try to reconnect.