Uploading to MAiX BiT failing in PlatformIO

I can’t upload a program to MAiX BiT using PlatformIO. I’ve tried this on both Win10 with PIO in VS Code, and on Ubuntu Linux with PIO in Atom, and I get the same failure. In both cases, the kflash script fails with the following trace:

Traceback (most recent call last):
  File "C:\Users\markp\.platformio\packages\tool-kflash-kendryte210\kflash.py", line 13, in <module>
    import argparse
  File "C:\Users\markp\.platformio\python37\lib\argparse.py", line 87, in <module>
    import re as _re
  File "C:\Users\markp\.platformio\python37\lib\re.py", line 143, in <module>
    class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
*** [upload] Error 1

It seems like a problem with the enum package in Python, but it’s a mystery. I have the latest Python loaded (3.7.4). This is painful, as this used to work some weeks ago. Anyone have any idea how to fix this?

Thanks!
M.

maybe you can rename dir [enum] to [enum_xxx] in ~\.platformio\packages\tool-kflash-kendryte210
I think this directory may have caused the conflict

2 Likes

It works!
Thanks

This solved my problem exactly. Thank you for the post.

@itsxm The renaming of the enum directory helped for me as well, the AttributeErrorwas resolved after that, thank you!

But uploading a firmware from PlatformIO to the MAIX BiT still doesn’t work after that. This is what I’m seeing at then end when I try to upload the kendryte-freertos-sdk hello sample:

Building in release mode
Checking size .pio\build\sipeed-maix-bit\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==        ]  19.1% (used 1204687 bytes from 6291456 bytes)
Flash: [          ]   1.9% (used 311991 bytes from 16777216 bytes)
Configuring upload protocol...
AVAILABLE: iot-bus-jtag, jlink, kflash, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, sipeed-rv-debugger, tumpa
CURRENT: upload_protocol = kflash
Looking for upload port...
Use manually specified: COM7
Uploading .pio\build\sipeed-maix-bit\firmware.bin
[INFO] COM Port Selected Manually:  COM7 
[INFO] Default baudrate is 115200 , later it may be changed to the value you set.
[INFO] Trying to Enter the ISP Mode... 
...............
Greeting fail, check serial port ([ERROR] No vaild Kendryte K210 found in Auto Detect, Check Your Connection or Specify One by`-p COM3`  )
*** [upload] Error 1

When I use the standalone kflash tool then I can successfully upload the firmware.bin file that was created by the PlatformIO build, over the same COM port COM7.

What might be the problem here?

hi @stm
i think maybe you can add the follows to platformio.ini

[env:sipeed-maix-bit-mic]
platform = kendryte210
framework = arduino
board = sipeed-maix-bit
monitor_speed = 115200
upload_port = COM12 ;[YOUR COM PORT]
board_upload.burn_tool = bit-mic
board_upload.speed = 1500000

this is my upload log

Configuring upload protocol…
AVAILABLE: iot-bus-jtag, jlink, kflash, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, sipeed-rv-debugger, tumpa
CURRENT: upload_protocol = kflash
Looking for upload port…
Use manually specified: COM12
Uploading .pio\build\sipeed-maix-bit-mic\firmware.bin
[INFO] COM Port Selected Manually: COM12
[INFO] Default baudrate is 115200 , later it may be changed to the value you set.
[INFO] Trying to Enter the ISP Mode…
._
[INFO] Automatically detected goE/kd233
[INFO] Greeting Message Detected, Start Downloading ISP
[INFO] CH340 mode
Downloading ISP: |---------------------------------------------| 1.5%
Downloading ISP: |=--------------------------------------------| 3.1%
Downloading ISP: |==-------------------------------------------| 4.6%
Downloading ISP: |==-------------------------------------------| 6.2%
Downloading ISP: |===------------------------------------------| 7.7%
Downloading ISP: |====-----------------------------------------| 9.2%
Downloading ISP: |====-----------------------------------------| 10.8%
Downloading ISP: |=====----------------------------------------| 12.3%
Downloading ISP: |======---------------------------------------| 13.8%
Downloading ISP: |======---------------------------------------| 15.4% 9kiB/s
Downloading ISP: |=======--------------------------------------| 16.9% 9kiB/s
Downloading ISP: |========-------------------------------------| 18.5% 9kiB/s
Downloading ISP: |=========------------------------------------| 20.0% 10kiB/s
Downloading ISP: |=========------------------------------------| 21.5% 10kiB/s
Downloading ISP: |==========-----------------------------------| 23.1% 10kiB/s
Downloading ISP: |===========----------------------------------| 24.6% 9kiB/s
Downloading ISP: |===========----------------------------------| 26.2% 10kiB/s
Downloading ISP: |============---------------------------------| 27.7% 10kiB/s
Downloading ISP: |=============--------------------------------| 29.2% 10kiB/s
Downloading ISP: |=============--------------------------------| 30.8% 10kiB/s
Downloading ISP: |==============-------------------------------| 32.3% 10kiB/s
Downloading ISP: |===============------------------------------| 33.8% 10kiB/s
Downloading ISP: |===============------------------------------| 35.4% 10kiB/s
Downloading ISP: |================-----------------------------| 36.9% 9kiB/s
Downloading ISP: |=================----------------------------| 38.5% 9kiB/s
Downloading ISP: |==================---------------------------| 40.0% 9kiB/s
Downloading ISP: |==================---------------------------| 41.5% 9kiB/s
Downloading ISP: |===================--------------------------| 43.1% 9kiB/s
Downloading ISP: |====================-------------------------| 44.6% 9kiB/s
Downloading ISP: |====================-------------------------| 46.2% 9kiB/s
Downloading ISP: |=====================------------------------| 47.7% 9kiB/s
Downloading ISP: |======================-----------------------| 49.2% 9kiB/s
Downloading ISP: |======================-----------------------| 50.8% 9kiB/s
Downloading ISP: |=======================----------------------| 52.3% 9kiB/s
Downloading ISP: |========================---------------------| 53.8% 9kiB/s
Downloading ISP: |========================---------------------| 55.4% 9kiB/s
Downloading ISP: |=========================--------------------| 56.9% 9kiB/s
Downloading ISP: |==========================-------------------| 58.5% 9kiB/s
Downloading ISP: |===========================------------------| 60.0% 9kiB/s
Downloading ISP: |===========================------------------| 61.5% 9kiB/s
Downloading ISP: |============================-----------------| 63.1% 9kiB/s
Downloading ISP: |=============================----------------| 64.6% 9kiB/s
Downloading ISP: |=============================----------------| 66.2% 9kiB/s
Downloading ISP: |==============================---------------| 67.7% 9kiB/s
Downloading ISP: |===============================--------------| 69.2% 9kiB/s
Downloading ISP: |===============================--------------| 70.8% 9kiB/s
Downloading ISP: |================================-------------| 72.3% 9kiB/s
Downloading ISP: |=================================------------| 73.8% 9kiB/s
Downloading ISP: |=================================------------| 75.4% 9kiB/s
Downloading ISP: |==================================-----------| 76.9% 9kiB/s
Downloading ISP: |===================================----------| 78.5% 9kiB/s
Downloading ISP: |====================================---------| 80.0% 9kiB/s
Downloading ISP: |====================================---------| 81.5% 9kiB/s
Downloading ISP: |=====================================--------| 83.1% 9kiB/s
Downloading ISP: |======================================-------| 84.6% 9kiB/s
Downloading ISP: |======================================-------| 86.2% 9kiB/s
Downloading ISP: |=======================================------| 87.7% 9kiB/s
Downloading ISP: |========================================-----| 89.2% 9kiB/s
Downloading ISP: |========================================-----| 90.8% 9kiB/s
Downloading ISP: |=========================================----| 92.3% 9kiB/s
Downloading ISP: |==========================================—| 93.8% 9kiB/s
Downloading ISP: |==========================================—| 95.4% 9kiB/s
Downloading ISP: |===========================================–| 96.9% 9kiB/s
Downloading ISP: |============================================-| 98.5% 9kiB/s
Downloading ISP: |=============================================| 100.0% 9kiB/s
?[32m?[1m[INFO]?[0m Booting From 0x80000000 ?[0m
[INFO] Wait For 0.1 second for ISP to Boot
[INFO] Boot to Flashmode Successfully
?[32m?[1m[INFO]?[0m Selected Baudrate: 1500000 ?[0m
[INFO] Baudrate changed, greeting with ISP again …
[INFO] Boot to Flashmode Successfully
[INFO] Selected Flash: On-Board
[INFO] Initialization flash Successfully
Programming BIN: |======================-----------------------| 50.0% 51kiB/s
Programming BIN: |=============================================| 100.0% 50kiB/s
[INFO] Rebooting…
========================================================================= [SUCCESS] Took 13.80 seconds =========================================================================

the project is platformio’s example [arduino-blink]

@itsxm thank you very much, the board_upload.burn_tool and board_upload.speed options indeed make the upload work!

I was not able to find the board_upload option and its suboptions in the PlatformIO documentation. Could you share where you got this information from?

hi @stm
about platformio, you can visit this blog http://blog.sipeed.com/p/622.html
about the suboptions of board_upload, i find them in ~\.platformio\platforms\kendryte210\boards\sipeed-maix-bit-mic.json

{
“build”: {
“extra_flags”: “”,
“f_cpu”: “400000000L”,
“mcu”: “K210”,
“hwids”: [
“0x0403”,
“0x6010”
],
“variant”: “sipeed_maix_bit”,
“board_def”: “BOARD_SIPEED_MAIX_BIT”
},
“frameworks”: [
“kendryte-standalone-sdk”,
“kendryte-freertos-sdk”,
“arduino”
],
“name”: “Sipeed MAIX BiT with Mic”,
“upload”: {
“maximum_ram_size”: 6291456,
“maximum_size”: 16777216,
“burn_tool”: “bit_mic”,
“require_upload_port”: true,
“speed”: 1500000
},
“url”: “https://www.sipeed.com/”,
“vendor”: “Sipeed”
}

there has several files in this dir, I looked at the differences.

@itsxm Thank you, that is useful information.