Try   HackMD

Part 1: Firmware Update & Running Code (PyCom Boards)

tags: TA Stuff ESP32 PyCom ESP32

In this tutorial, we walk you through the hardware configuration, so you are up and running for your journey in IoT. If you own a PyCom Development Board (Like; FiPy, GPy, LoPy) you should follow this tutorial.
You will:

  • Download and Install PyCom Firmware Updat Application
  • Update the PyCom board with the latest firmware
  • Try a small code to confirm if everything is set properly

We'll continuously update this walkthrough. Is there anything missing or unclear, or have you experienced some issue? Please add a comment. You do this by highlighting the text and then you can write a comment on the highlighted part. You need to log in/create an account on HackMD first.

We follow PyCom documentation to update the firmware and you always need to check the links for the latest updates and instructions.

0. Prerequisites

You have watched this brief walkthrough, at least to the firmware update part: Session 2 Setup Atom Pymakr

  • You should be finished with the IDE installation tutorial before continuing this :)
  • Have your PyCom board (FiPy, GPy, or LoPy)
  • USB Cable (Make sure the USB cable is capable of data transferring. If you get the bundle with cable it will support)

Depending on your operating system follow one of the following sections.

Windows

Mac

Linux

Windows OS

You should not interrupt the firmware update process because it could damage your baord, meaning:

  • Make sure that your laptop is connected to power and/or fully charged.
  • Do not disconnect the USB cable during firmware update process.
  • Do not press the buttons on board or expansion board during firmware update.
  • Do not cancel the firmware update process.

Follow these steps:

  • Step 1: Connect your PyCom Expansion board to your computer with a USB cable.
  • Step 2: Download the Firmware Update from this link.
  • Step 3: Install the downlaoded file and open it.
  • Step 4: Follow these steps to upgrade firmware:
    • Press Continue and then Continue again
    • In port section, select the COM port to your PyCom Expansion board (Could be find in Windows Device Manager)
    • In type section, select the development and press continue
    • It should automatically detect your baord type, then select Erase during update and CONFIG partion & NVS Partition, and finally press continue.
    • It takes some time and finally you can press one Done. Below you can see some screenshots of processes:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →



Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →



Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

You are now ready for the next step to run code on your development IDE. Follow the steps below:

  • Step 1: Open Atom, Disconnect and Reconnect your board. It should automatically recognized be Atom, if not you can use Connect Device to access REPL.
    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →


  • Step 2: Try print("Hello from PyCom") on REPL and see if it successfully shows the message.
    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →
  • Step 3: We are ready to make our first project now. Create a folder on your computer like; ( First Project ).
  • Step 4: In Atom click on Add Folder from the left panel then open created folder.
  • Step 5: Right-click on your project folder from the left panel and choose New File to create a new file, in the opened box enter main.py and press enter.

All projects must have main.py which is the start point for code execution.

  • Step 6: Copy the following lines in main.py and save it.
import pycom # Import pycom to control LED import time # Import time to create delays # We disable LED heartbeat to control it manually pycom.heartbeat(False) # Your board run this section over and over while True: #colors in hexadecimal (0xRRGGBB) pycom.rgbled(0xFF0000) # Red time.sleep(1) pycom.rgbled(0x00FF00) # Green time.sleep(1) pycom.rgbled(0x0000FF) # Blue time.sleep(1)

  • Step 7: Now upload the file to your board from the upload project button:

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →


  • Step 8: The LED on your board starts to blink different color and the REPL is not accessible anymore because of your loop. To stop blinking press Ctrl+c in the REPL section.

You are now successfully finished Part 1 of four parts tutorial, It is a good idea to read more about MicroPython Tutorials and Examples from Pycom (here) and try different code to learn more.
Good Luck!

Mac OS

You should not interrupt the firmware update process because it could damage your baord, meaning:

  • Make sure that your laptop is connected to power and/or fully charged.
  • Do not disconnect the USB cable during firmware update process.
  • Do not press the buttons on board or expansion board during firmware update.
  • Do not cancel the firmware update process.

Follow these steps:

  • Step 1: Connect your PyCom Expansion board to your computer with a USB cable.
  • Step 2: Download the Firmware Update from this link.
  • Step 3: Install the downlaoded file and open it.
    • When starting the firmware update program for the first time, you might encounter the following message
      Image Not Showing Possible Reasons
      • The image file may be corrupted
      • The server hosting the image is unavailable
      • The image path is incorrect
      • The image format is not supported
      Learn More →

      Navigate to Applications and right-click on Pycom Firmware Update and select open
      Image Not Showing Possible Reasons
      • The image file may be corrupted
      • The server hosting the image is unavailable
      • The image path is incorrect
      • The image format is not supported
      Learn More →
  • Step 4: Follow these steps to upgrade firmware:
    • Press Continue and then Continue again
    • In port section, select the /dev/cu.usbserial0001 port to your PyCom Expansion board (Could be found by running ls /dev/cu.* in the terminal)
    • In type section, select the development (NOT PYBYTES) and press continue
    • It should automatically detect your baord type, then select Erase during update and and CONFIG partion & NVS Partition, also select FatFS instead of LittleFS, finally press continue.
    • It takes some time and finally you can press one Done. Below you can see some screenshots of processes:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →



Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →



Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

You are now ready for the next step to run code on your development IDE. Follow the steps below:

  • Step 1: Open Atom, Disconnect and Reconnect your board. It should automatically recognized be Atom, if not you can use Connect Device to access REPL.
    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →


  • Step 2: Try print("Hello from PyCom") on REPL and see if it successfully shows the message.
    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →
  • Step 3: We are ready to make our first project now. Create a folder on your computer like; ( First Project ).
  • Step 4: In Atom click on Add Folder from the left panel then open created folder.
  • Step 5: Right-click on your project folder from the left panel and choose New File to create a new file, in the opened box enter main.py and press enter.

All projects must have main.py which is the start point for code execution.

  • Step 6: Copy the following lines in main.py and save it.
import pycom # Import pycom to control LED import time # Import time to create delays # We disable LED heartbeat to control it manually pycom.heartbeat(False) # Your board run this section over and over while True: #colors in hexadecimal (0xRRGGBB) pycom.rgbled(0xFF0000) # Red time.sleep(1) pycom.rgbled(0x00FF00) # Green time.sleep(1) pycom.rgbled(0x0000FF) # Blue time.sleep(1)

  • Step 7: Now upload the file to your board from the upload project button:



  • Step 8: The LED on your board starts to blink different color and the REPL is not accessible anymore because of your loop. To stop blinking press Ctrl+c in the REPL section.

You are now successfully finished Part 1 of four parts tutorial, It is a good idea to read more about MicroPython Tutorials and Examples from Pycom (here) and try different code to learn more.
Good Luck!

Linux OS (Ubuntu 22.04)

You should not interrupt the firmware update process because it could damage your baord, meaning:

  • Make sure that your laptop is connected to power and/or fully charged.
  • Do not disconnect the USB cable during firmware update process.
  • Do not press the buttons on board or expansion board during firmware update.
  • Do not cancel the firmware update process.

Follow these steps:

  • Step 0: You may required to install python-serial package. You can run following pip commonds in the Terminal. (may also reuqire dialog, see this)
sudo apt -y install python3 sudo apt -y install python3-pip pip install pyserial
  • Step 1: Connect your PyCom Expansion board to your computer with a USB cable.
  • Step 2: Download the PyCom Firmware Update Tool from this link. For the Ubuntu 22.04 (x86-64) user, choose this.
  • Step 3: Install the downlaoded file by using right click the install package and choosing Open With Other Application. Select Software Install and click Select. Then click Install and finish install.

  • Step 4: Follow these steps to upgrade firmware:
    • Open Terminal and execute the following lines to remove access conflict in your Ubuntu and to give access to your connected board:
sudo systemctl stop brltty-udev.service sudo systemctl mask brltty-udev.service sudo systemctl stop brltty.service sudo systemctl disable brltty.service sudo usermod -a -G dialout [Your username] sudo chmod a+rw /dev/ttyACM0
    • Open PyCom Firmware Update Tool.
    • Press Continue and then Continue again
    • In port section, select the /dev/ttyACM0 port to your PyCom Expansion board
    • In type section, select the development (NOT PYBYTES) and press continue
    • It should automatically detect your baord type, then select Erase during update and CONFIG partion & NVS Partition finally press continue.
    • It takes some time and finally you can press one Done. Below you can see some screenshots of processes:







Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

You are now ready for the next step to run code on your development IDE. Follow the steps below:

  • Step 1: Open Atom, Disconnect and Reconnect your board. It should automatically recognized be Atom (/dev/ttyACM0 (Pycom)), if not you can use Connect Device to access REPL.



  • Step 2: Try print("Hello from PyCom") on REPL and see if it successfully shows the message.

  • Step 3: We are ready to make our first project now. Create a folder on your computer like; ( First Project ).

  • Step 4: In Atom click on Add Folder from the left panel then open created folder.
  • Step 5: Right-click on your project folder from the left panel and choose New File to create a new file, in the opened box enter main.py and press enter.

All projects must have main.py which is the start point for code execution.

  • Step 6: Copy the following lines in main.py and save it.
import pycom # Import pycom to control LED import time # Import time to create delays # We disable LED heartbeat to control it manually pycom.heartbeat(False) # Your board run this section over and over while True: #colors in hexadecimal (0xRRGGBB) pycom.rgbled(0xFF0000) # Red time.sleep(1) pycom.rgbled(0x00FF00) # Green time.sleep(1) pycom.rgbled(0x0000FF) # Blue time.sleep(1)

  • Step 7: Now upload the file to your board from the upload project button:



  • Step 8: The LED on your board starts to blink different color and the REPL is not accessible anymore because of your loop. To stop blinking press Ctrl+c in the REPL section.

Everytime you disconnect/connect your PyCom board in Ubuntu you must run the following commands:

sudo usermod -a -G dialout [Your username] sudo chmod a+rw /dev/ttyACM0

You are now successfully finished Part 1 of four parts tutorial, It is a good idea to read more about MicroPython Tutorials and Examples from Pycom (here) and try different code to learn more.
Good Luck!