Difference between revisions of "CutiPy-Installing MicroPython Firmware"

From wiki.emacinc.com
Jump to: navigation, search
 
(33 intermediate revisions by 3 users not shown)
Line 1: Line 1:
  
===THIS PAGE IS CURRENTLY UNDER CONSTRUCTION===
+
This tutorial will walk you through installing/updating MicroPython on your CutiPy device. Instuctions are given for both Windows and Linux users.
 
=== Necessary equipment ===
 
=== Necessary equipment ===
  
Line 8: Line 8:
 
* A pair of needle nose pliers for wire jumper re-positioning  
 
* A pair of needle nose pliers for wire jumper re-positioning  
 
* A personal computer (Windows or Linux)
 
* A personal computer (Windows or Linux)
* EMAC's latest MicroPython firmware release
+
* [http://git.emacinc.com/micropython-public/micropython/-/releases EMAC's latest MicroPython firmware release]
 
</cl>
 
</cl>
  
 +
{{:Templateimpl:using | initials=BS | title=Installing Firmware | desc=Entering Bootloader Mode Cutipy. | project=OE 5.0 }}
  
 +
<cl>
 +
1. With the USB disconnected and power removed, carefully use a pair of needle nose pliers to shift jumper JB2 upwards from FLS to to RXM (The BT0 and RXM pins will now be linked). The device is now in bootloader mode.
 +
 +
{{note|If a version of Micropython is already installed on your device, '''>>>pyb.bootloader()''' can be inputted into the REPL console, to put the board into bootloader mode ''without'' having to move the jumper.
 +
}}
 +
 +
* Connect your CutiPy to your PC using the Micro-USB cable.
 +
</cl>
 
{{:Templateimpl:using | initials=BS | title=Windows Users | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}  
 
{{:Templateimpl:using | initials=BS | title=Windows Users | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}  
  
 
<cl>
 
<cl>
1. With the USB disconnected and power removed, carefully use a pair of needle nose pliers to shift jumper JB2 upwards from FLS to to RXM (The BT0 and RXM pins will now be linked).
+
3. Download and install [https://zadig.akeo.ie  Zadig]
  
* Connect your CutiPy to your PC using the Micro-USB cable.
+
* Open Zadig  and select '''STM32 BOOTLOADER''' and '''WinUSB'''
  
* Download and install [https://zadig.akeo.ie  Zadig]
+
[[File:Zadig.png]]
  
* Open Zadig and install WinUSB by selecting the following options given in the image below
+
{{note|The '''STM32 BOOTLOADER''' option is only available when the microUSB is connected and the device is in bootloader mode.
 +
}}
  
* Select ''''Replace Driver''''  
+
* Click '''Replace Driver'''  
  
 
{{note|Upon clicking “Replace Driver” the app may read “Not Responding” for a short duration and then recover. This is normal.
 
{{note|Upon clicking “Replace Driver” the app may read “Not Responding” for a short duration and then recover. This is normal.
Line 39: Line 49:
 
* From the Command Prompt navigate to the dfu-util directory. If necessary switch drives by entering ''''drive_name:'''. For example to switch to the C drive enter
 
* From the Command Prompt navigate to the dfu-util directory. If necessary switch drives by entering ''''drive_name:'''. For example to switch to the C drive enter
 
'''c:'''. Use '''dir''' to list sub-directories and use '''cd directory_name''' to navigate to a subdirectory.  
 
'''c:'''. Use '''dir''' to list sub-directories and use '''cd directory_name''' to navigate to a subdirectory.  
 +
 +
{{clo}}
 +
Microsof Windows [Version 6.1.7601] <br />
 +
Copyright (c)  2009 Microsoft Corporation. All rights reserved.
 +
 +
O:\>C:
 +
 +
C:\Users>cd MyUser
 +
 +
C:\Users\MyUser>cd Desktop
 +
 +
C:\Users\MyUser\Desktop>cd dfu-util-0.9-win64
 +
 +
C:\Users\MyUser\Desktop\dfu-util-0.9-win64>
 +
 +
 +
 +
{{clos}}
 +
  
 
* Once in the dfu-util directory enter '''dfu-util -l'''. Something similar to the following should be displayed:
 
* Once in the dfu-util directory enter '''dfu-util -l'''. Something similar to the following should be displayed:
  
* From this directory install the firmware to the device by entering the following into the Command Prompt:
+
{{clo}}
 +
C:\Users\MyUser\Desktop\dfu-util-0.9-win64>dfu-util -l<br />
 +
 
 +
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc. <br />
 +
Copyright 2010-2016 Tormod Volden and Stefan Schmidt<br />
 +
This program is Free Softwasre and has ABSOLUTELY NO WARRANTY<br />
 +
Please report bugs to http: // sourceforge.net / p / dfu-util / tickets /<br />
 +
 
 +
Found DFU: [0483:df11] ver 2200, dvenum=7, cfg =1, intf=0, path="2-1.3", alt=3, n <br />
 +
ame="@Device Feature/0xFFFF0000/01*004 e", serial="336445653437"<br />
 +
Found DFU: [0483:df11] ver 2200, dvenum=7, cfg =1, intf=0, path="2-1.3", alt=2, n <br />
 +
ame ="@OTP Memory /0x1FFF7900/01*412 e, 01*016 e", serial="336445653437" <br />
 +
Found DFU: [0483:df11] ver 2200, dvenum=7, cfg =1, intf=0, path="2-1.3", alt=1, n <br />
 +
ame="@Option Bytes/0xFFFF0000/01*016 e", serial="336445653437" <br />
 +
Found DFU: [0483:df11] ver 2200, dvenum=7, cfg =1, intf=0, path="2-1.3", alt=0, n <br />
 +
ame="@Internal Flash /0x08000000/04*016Kg, 01*064Kg, 07*128Kg", serial="336445653 <br />
 +
437" <br />
 +
 
 +
C:\Users\MyUser\Desktop\dfu-util-0.9-win64>
 +
 
 +
{{clos}}
 +
 
 +
* From this directory install the firmware to the device by entering the following into the Command Prompt, where '''firmware.dfu''' is just the name of the firmware dfu file:
 +
 
 +
{{clo}}
 +
 
 +
C:\Users\MyUser\Desktop\dfu-util-0.9-win64>dfu-util --alt 0 -D firmware.dfu
 +
 
 +
{{clos}}
 +
{{note|If the firmware dfu file is saved anywhere other than the dfu-util folder, the full path location will need to be entered. E.g. '''dfu-util --alt 0 -D ...\firmware.dfu''', where "..." should be filled in with the directory path.
 +
}}
  
 
Something similar to the following should be displayed.  
 
Something similar to the following should be displayed.  
 +
 +
{{clo}}
 +
C:\Users\MyUser\Desktop\dfu-util-0.9-win64>duf-util --alt 0 -D firmware.dfu
 +
 +
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc. <br />
 +
Copyright 2010-2016 Tormod Volden and Stefan Schmidt        <br />
 +
This program is Free Softwasre and has ABSOLUTELY NO WARRANTY  <br />
 +
Please report bugs to http: // sourceforge.net / p / dfu-util / tickets /  <br />
 +
 +
Match vendor ID from file: 0483  <br />
 +
Match product ID from file: df11 <br />
 +
Opening DFU capable USB device...<br />
 +
ID 0483:df11<br />
 +
Run-time device DFU version 011a<br />
 +
Claiming USB DFU Interface...<br />
 +
Setting Alternate Setting #0 ...<br />
 +
Determining device status: state = dfuERROR, satus = 10<br />
 +
dfuERROR, clearing status<br />
 +
Determining device status: state = dfuIDLE, status = 0<br />
 +
dfuIDLE, continuing <br />
 +
DFU mode device DFU version 011a<br />
 +
Device returned tranfer size 2048<br />
 +
DfuSe interface name: "Internal Flash "<br />
 +
file contains 1 DFU images<br />
 +
parsing DFU image 1<br />
 +
image for alternate setting 0, <2 elements, total size = 386288><br />
 +
parsing element1, address = 0x08000000, size =15000<br />
 +
Download    [=========================] 100%      15000 bytes<br />
 +
Download done.<br />
 +
pasing element 2, address = 0x8020000, size =371272<br />
 +
Download    [=========================] 100%    371272 bytes<br />
 +
Download done.<br />
 +
done parsing DfuSe file<br />
 +
 +
C:\Users\MyUser\Desktop\dfu-util-0.9-win64><br />
 +
     
 +
{{clos}}
  
  
 
The firmware is now installed.
 
The firmware is now installed.
  
* Safely eject and disconnect the USB, shift the JB2 pin jumper back to the original location (BT0 and FLS should now be joined). Now reconnnect the MicroUSB cable.
 
  
Installation is now complete complete.
+
* Safely eject and disconnect the USB (Remove power), shift the JB2 pin jumper back to the original location (BT0 and FLS should now be joined). Now reconnnect the MicroUSB cable.
 +
 
 +
Installation is now complete.
  
 
</cl>
 
</cl>
 +
 +
 +
{{:Templateimpl:using | initials=BS | title=Linux Users | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}
 +
 +
 +
3. Follow the EMAC DFU instructions given [http://git.emacinc.com/micropython-public/micropython-doc/blob/master/Micropython_firmware_installation.md#dfu-usb-instructions-linux here]
 +
* Safely eject and disconnect the USB (Remove power), shift the JB2 pin jumper back to the original location (BT0 and FLS should now be joined). Now reconnnect the MicroUSB cable.
 +
 +
Installation is now complete.
 +
 +
{{:Templateimpl:using | initials=BS | title=After Firmware Installation | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}
 +
 +
After installing the firmware you can open a MicroPython REPL(read evaluate print loop) console (covered [http://wiki.emacinc.com/wiki/Cutipy_Getting_Started here ]), and verify the firmware version by entering the following into the REPL console
  
 
{{clo}}
 
{{clo}}
If desired, please enter a name for this project, otherwise press Enter to use the default: hello_emac <br />
+
>>> import os <br />
 +
>>> os.uname()<br />
 +
{{clos}}
  
-- Creating new project directory... <br />
+
Output should look similar to the following:
-- Creating new source file... <br />
 
-- Building custom CMakeLists.txt file... <br />
 
-- Done. <br />
 
  
Do you want to create a build directory for this project? (y/n) y <br />
+
{{clo}}
 +
(sysname='pyboard', nodename='pyboard', rlease='0.0.1', version='394ae277 as IOT-F40<br />
 +
7C-XXXRX on 2019-06-07', machine = 'EMAC-CutiPy with STM32F407')<br />
 +
>>>
 +
{{clos}}
  
-- Creating build directory... <br />
+
After installing the firmware perform a factory reset. This clears the file system, and adds/replaces boot.py and main.py
  
Do you want to run cmake for this project? (y/n) y <br />
+
{{note|The factory reset will delete all files present on the board. For this reason we recommend backing up your files if you have made any changes.
 +
}}
  
-- Using system compiler <br />
 
-- The C compiler identification is GNU 4.8.2 <br />
 
-- The CXX compiler identification is GNU 4.8.2 <br />
 
-- Check for working C compiler: /usr/bin/cc <br />
 
-- Check for working C compiler: /usr/bin/cc -- works <br />
 
-- Detecting C compiler ABI info <br />
 
-- Detecting C compiler ABI info - done <br />
 
-- Check for working CXX compiler: /usr/bin/c++ <br />
 
-- Check for working CXX compiler: /usr/bin/c++ -- works <br />
 
-- Detecting CXX compiler ABI info <br />
 
-- Detecting CXX compiler ABI info - done <br />
 
-- Configuring done <br />
 
-- Generating done <br />
 
-- Build files have been written to: /home/developer/projects/hello_emac/hello_emac-build <br />
 
  
Do you want to compile this project? (y/n) y
+
Perform a factory reset as follows (Note these instructions are a slight modification of the PyBoard factory reset instruction given [https://docs.micropython.org/en/latest/pyboard/tutorial/reset.html#factory-reset-the-filesystem here]):
  
Scanning dependencies of target hello_emac <br />
+
<cl>
[100%] Building C object CMakeFiles/hello_emac.dir/hello.c.o <br />
+
1. Connect your CutiPy to your PC using the MicroUSB cable.
Linking C executable hello_emac <br />
+
* Hold down PB1.
[100%] Built target hello_emac <br />
+
* While still holding down PB1, press and release the reset button PB5.
{{clos}}
+
* The LD2 and LD3 will then flash, cycling through various lighting combinations corresponding to different options. Both lit corresponds to the factory reset option.
 +
* Keep holding down PB1, when both LEDs are lit, release PB1 to select the factory reset option.
 +
* Both LEDs should quickly flash 4 times, a third LED (LD1) will turn on.
 +
* The file system is now being reset.
 +
* After the file system is reset, all LEDs will turn off and the device will enter safe mode.
 +
* Press and release the reset button, PB5 to boot normally.
  
 +
</cl>
  
 +
{{:Templateimpl:using | initials=BS | title=References | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}
 +
https://github.com/micropython/micropython/wiki/Pyboard-Firmware-Update<br />
 +
https://docs.micropython.org/en/latest/pyboard/tutorial/reset.html#factory-reset-the-filesystem
  
 +
{{:Templateimpl:using | initials=BS | title=Pages with Related Content| desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}
 +
[http://git.emacinc.com/micropython-public/micropython-doc CutiPy Micropython Documentation]
  
{{:Templateimpl:using | initials=BS | title=Linux Users | desc=Basic tutorial for using the EMAC OE SDK. | project=OE 5.0 }}
+
[[ Micropython | Micropython ]]
  
 +
[[ Cutipy_Test | Cutipy Test Software ]]
  
Follow the EMAC DFU instructions given [http://git.emacinc.com/micropython-public/micropython-doc/blob/master/Micropython_firmware_installation.md#dfu-usb-instructions-linux here]
+
[[ Cutipy-MicroPython Bluetooth LE demo | Cutipy-MicroPython Bluetooth LE demo ]]

Latest revision as of 17:24, 12 April 2021

This tutorial will walk you through installing/updating MicroPython on your CutiPy device. Instuctions are given for both Windows and Linux users.

Necessary equipment

  1. CutiPy

  2. 1 Micro-USB cable

  3. A pair of needle nose pliers for wire jumper re-positioning

  4. A personal computer (Windows or Linux)

  5. EMAC's latest MicroPython firmware release

Installing Firmware

  1. With the USB disconnected and power removed, carefully use a pair of needle nose pliers to shift jumper JB2 upwards from FLS to to RXM (The BT0 and RXM pins will now be linked). The device is now in bootloader mode.



    NOTE
    If a version of Micropython is already installed on your device, >>>pyb.bootloader() can be inputted into the REPL console, to put the board into bootloader mode without having to move the jumper.


  2. Connect your CutiPy to your PC using the Micro-USB cable.

Windows Users

3. Download and install Zadig

  • Open Zadig and select STM32 BOOTLOADER and WinUSB

    Zadig.png



    NOTE
    The STM32 BOOTLOADER option is only available when the microUSB is connected and the device is in bootloader mode.


  • Click Replace Driver



    NOTE
    Upon clicking “Replace Driver” the app may read “Not Responding” for a short duration and then recover. This is normal.


  • After successfully installing the WinUSB driver, download the latest dfu-util application zip file here.

  • Extract the zip file.

  • For convenience, save the CutiPy firmware dfu file to the dfu-util folder.

  • Open the Windows Command Prompt by searching and selecting "Command Prompt" from the Windows start menu.

  • From the Command Prompt navigate to the dfu-util directory. If necessary switch drives by entering 'drive_name:. For example to switch to the C drive enter c:. Use dir to list sub-directories and use cd directory_name to navigate to a subdirectory.

    Microsof Windows [Version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation. All rights reserved.

    O:\>C:

    C:\Users>cd MyUser

    C:\Users\MyUser>cd Desktop

    C:\Users\MyUser\Desktop>cd dfu-util-0.9-win64

    C:\Users\MyUser\Desktop\dfu-util-0.9-win64>



  • Once in the dfu-util directory enter dfu-util -l. Something similar to the following should be displayed:

    C:\Users\MyUser\Desktop\dfu-util-0.9-win64>dfu-util -l

    Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
    Copyright 2010-2016 Tormod Volden and Stefan Schmidt
    This program is Free Softwasre and has ABSOLUTELY NO WARRANTY
    Please report bugs to http: // sourceforge.net / p / dfu-util / tickets /

    Found DFU: [0483:df11] ver 2200, dvenum=7, cfg =1, intf=0, path="2-1.3", alt=3, n
    ame="@Device Feature/0xFFFF0000/01*004 e", serial="336445653437"
    Found DFU: [0483:df11] ver 2200, dvenum=7, cfg =1, intf=0, path="2-1.3", alt=2, n
    ame ="@OTP Memory /0x1FFF7900/01*412 e, 01*016 e", serial="336445653437"
    Found DFU: [0483:df11] ver 2200, dvenum=7, cfg =1, intf=0, path="2-1.3", alt=1, n
    ame="@Option Bytes/0xFFFF0000/01*016 e", serial="336445653437"
    Found DFU: [0483:df11] ver 2200, dvenum=7, cfg =1, intf=0, path="2-1.3", alt=0, n
    ame="@Internal Flash /0x08000000/04*016Kg, 01*064Kg, 07*128Kg", serial="336445653
    437"

    C:\Users\MyUser\Desktop\dfu-util-0.9-win64>

  • From this directory install the firmware to the device by entering the following into the Command Prompt, where firmware.dfu is just the name of the firmware dfu file:

    C:\Users\MyUser\Desktop\dfu-util-0.9-win64>dfu-util --alt 0 -D firmware.dfu



    NOTE
    If the firmware dfu file is saved anywhere other than the dfu-util folder, the full path location will need to be entered. E.g. dfu-util --alt 0 -D ...\firmware.dfu, where "..." should be filled in with the directory path.


    Something similar to the following should be displayed.

    C:\Users\MyUser\Desktop\dfu-util-0.9-win64>duf-util --alt 0 -D firmware.dfu

    Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
    Copyright 2010-2016 Tormod Volden and Stefan Schmidt
    This program is Free Softwasre and has ABSOLUTELY NO WARRANTY
    Please report bugs to http: // sourceforge.net / p / dfu-util / tickets /

    Match vendor ID from file: 0483
    Match product ID from file: df11
    Opening DFU capable USB device...
    ID 0483:df11
    Run-time device DFU version 011a
    Claiming USB DFU Interface...
    Setting Alternate Setting #0 ...
    Determining device status: state = dfuERROR, satus = 10
    dfuERROR, clearing status
    Determining device status: state = dfuIDLE, status = 0
    dfuIDLE, continuing
    DFU mode device DFU version 011a
    Device returned tranfer size 2048
    DfuSe interface name: "Internal Flash "
    file contains 1 DFU images
    parsing DFU image 1
    image for alternate setting 0, <2 elements, total size = 386288>
    parsing element1, address = 0x08000000, size =15000
    Download [=========================] 100% 15000 bytes
    Download done.
    pasing element 2, address = 0x8020000, size =371272
    Download [=========================] 100% 371272 bytes
    Download done.
    done parsing DfuSe file

    C:\Users\MyUser\Desktop\dfu-util-0.9-win64>


    The firmware is now installed.


  • Safely eject and disconnect the USB (Remove power), shift the JB2 pin jumper back to the original location (BT0 and FLS should now be joined). Now reconnnect the MicroUSB cable.

    Installation is now complete.



Linux Users

3. Follow the EMAC DFU instructions given here

  • Safely eject and disconnect the USB (Remove power), shift the JB2 pin jumper back to the original location (BT0 and FLS should now be joined). Now reconnnect the MicroUSB cable.

Installation is now complete.

After Firmware Installation

After installing the firmware you can open a MicroPython REPL(read evaluate print loop) console (covered here ), and verify the firmware version by entering the following into the REPL console

>>> import os
>>> os.uname()

Output should look similar to the following:

(sysname='pyboard', nodename='pyboard', rlease='0.0.1', version='394ae277 as IOT-F40
7C-XXXRX on 2019-06-07', machine = 'EMAC-CutiPy with STM32F407')
>>>

After installing the firmware perform a factory reset. This clears the file system, and adds/replaces boot.py and main.py



NOTE
The factory reset will delete all files present on the board. For this reason we recommend backing up your files if you have made any changes.


Perform a factory reset as follows (Note these instructions are a slight modification of the PyBoard factory reset instruction given here):


  1. Connect your CutiPy to your PC using the MicroUSB cable.

  2. Hold down PB1.

  3. While still holding down PB1, press and release the reset button PB5.

  4. The LD2 and LD3 will then flash, cycling through various lighting combinations corresponding to different options. Both lit corresponds to the factory reset option.

  5. Keep holding down PB1, when both LEDs are lit, release PB1 to select the factory reset option.

  6. Both LEDs should quickly flash 4 times, a third LED (LD1) will turn on.

  7. The file system is now being reset.

  8. After the file system is reset, all LEDs will turn off and the device will enter safe mode.

  9. Press and release the reset button, PB5 to boot normally.


References

https://github.com/micropython/micropython/wiki/Pyboard-Firmware-Update
https://docs.micropython.org/en/latest/pyboard/tutorial/reset.html#factory-reset-the-filesystem

Pages with Related Content

CutiPy Micropython Documentation

Micropython

Cutipy Test Software

Cutipy-MicroPython Bluetooth LE demo