OTB Blink Failing to Upload to Maixduino

Hi

Try to upload the sample blink to the Maixduino and get the following error, looks like kflash requires a firmware parameter and its not being supplied. Any ideas

The exact same program and com port works with ArudinoIDE.

Version: 1.57.0 (user setup)
Commit: b4c1bd0a9b03c749ea011b06c6d2676c8091a70c
Date: 2021-06-09T17:18:42.354Z (3 days ago)
Electron: 12.0.9
Chrome: 89.0.4389.128
Node.js: 14.16.0
V8: 8.9.255.25-electron.0
OS: Windows_NT x64 10.0.19043
Building in release mode
Compiling .pio\build\sipeed-maixduino\src\Blink.cpp.o
Linking .pio\build\sipeed-maixduino\firmware.elf
Building .pio\build\sipeed-maixduino\firmware.bin
Checking size .pio\build\sipeed-maixduino\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.5% (used 32424 bytes from 6291456 bytes)
Flash: [          ]   0.4% (used 68255 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: COM5
Uploading .pio\build\sipeed-maixduino\firmware.bin
usage: kflash.py [-h] [-p PORT] [-f FLASH] [-b BAUDRATE] [-l BOOTLOADER]
                 [-k KEY] [-v] [--verbose] [-t] [-n] [-s] [-B BOARD] [-S SLOW]
                 firmware
kflash.py: error: the following arguments are required: firmware
*** [upload] Error 2

Thanks
Marcus

Can you share

  1. The platformio.ini
  2. The src\main.cpp code
  3. The absolute location of the project folder
  4. The output of the project task “Advanced → Verbose Upload” with regards to what happens after Uploading .pio\build\sipeed-maixduino\firmware.bin is printed (it should print the complete kflash.py invocation)

Sure, thanks for helping with this, I do actually just use kflash.py directly now and upload the firmware.bin from the terminal, I run the pyenv activate script 1st, as I like to keep my python and pip off my path.

1. platformio.ini

[env:sipeed-maixduino]
platform = kendryte210
framework = arduino
board = sipeed-maixduino
board_build.mcu = K210
monitor_speed = 115200
upload_port = COM5
board_build.f_cpu = 400000000L
board_upload.slow = no
upload_protocol = kflash

2. The code is the blink sample, with a bit of serial in there

src/Blink.cpp

/*
 * Blink
 * Turns on an LED on for one second,
 * then off for one second, repeatedly.
 */

#include <Arduino.h>

void setup()
{
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(9600);
}

void loop()
{
  // turn the LED on (HIGH is the voltage level)
  digitalWrite(LED_BUILTIN, HIGH);
  // wait for a second
  delay(500);
  // turn the LED off by making the voltage LOW
  digitalWrite(LED_BUILTIN, LOW);
   // wait for 3 seconds
  delay(3000);
  Serial.println("hello Maixduino");
}

3. Location of project folder is here

P:\Documents\PlatformIO\Projects\210327-223050-arduino-blink

4. The output from verbose upload

"c:\users\marcu\.platformio\penv\scripts\python.exe" "C:\Users\marcu\.platformio\packages\tool-kflash-kendryte210\kflash.py" -p COM5 -b 1500000 
-B maixduino -S .pio\build\sipeed-maixduino\firmware.bin
usage: kflash.py [-h] [-p PORT] [-f FLASH] [-b BAUDRATE] [-l BOOTLOADER]
                 [-k KEY] [-v] [--verbose] [-t] [-n] [-s] [-B BOARD] [-S SLOW]
                 firmware
kflash.py: error: the following arguments are required: firmware
*** [upload] Error 2
========================================================== [FAILED] Took 1.42 seconds ==========================================================The terminal process "C:\Users\marcu\.platformio\penv\Scripts\platformio.exe 'run', '--verbose', '--target', 'upload', '--environment', 'sipeed-maixduino'" terminated with exit code: 1.

The full command line that works when I manually run it for the kflash,
P:\Documents\PlatformIO\Projects\210327-223050-arduino-blink.pio\build\sipeed-maixduino

after running the pyenv activate script, and changing directory to the firmware bin folder
C:\Users\marcu.platformio\penv\Scripts\activate

python X:\Firmware\Maixduino\kflashgui\kflash_gui\kflash_py\kflash.py -p COM5 -b 115200 -B sipeed-maixduino -S SLOW firmware.bin

That is really interesting. There’s a linebreak there that shouldn’t be there?

Does the error stay the same when you just use

[env:sipeed-maixduino]
platform = kendryte210
framework = arduino
board = sipeed-maixduino

as the platformio.ini?

Does it help when add and change this

to

board_upload.slow = True

?
(might be related to Default the value of upload.slow to avoid build error by mikljohansson ¡ Pull Request #39 ¡ sipeed/platform-kendryte210 ¡ GitHub)

No, I get this error and stack trace instead

Building in release mode
KeyError: “Invalid board option ‘upload.slow’”:
File “C:\Users\marcu.platformio\penv\Lib\site-packages\platformio\builder\main.py”, line 177:
env.SConscript(“$BUILD_SCRIPT”)
File “C:\Users\marcu.platformio\packages\tool-scons\scons-local-4.1.0\SCons\Script\SConscript.py”, line 591:
return _SConscript(self.fs, *files, **subst_kw)
File “C:\Users\marcu.platformio\packages\tool-scons\scons-local-4.1.0\SCons\Script\SConscript.py”, line 280:
exec(compile(scriptdata, scriptname, ‘exec’), call_stack[-1].globals)
File “C:\Users\marcu.platformio\platforms\kendryte210\builder\main.py”, line 108:
“-S” if board.get(“upload.slow”) else “”
File “c:\users\marcu.platformio\penv\lib\site-packages\platformio\platform\board.py”, line 59:
raise KeyError(“Invalid board option ‘%s’” % path)
========================================================== [FAILED] Took 0.77 seconds ==========================================================The terminal process “C:\Users\marcu.platformio\penv\Scripts\platformio.exe ‘run’, ‘–target’, ‘upload’, ‘–environment’, ‘sipeed-maixduino’” terminated with exit code: 1.

No I get the same error when I change the slow to True, this is the same error using just the 4 lines in the ini file, and then with all the lines in the ini.

Hm I can’t reproduce that behavior.

When I only use this platformio.ini

[env:sipeed-maixduino]
platform = kendryte210
framework = arduino
board = sipeed-maixduino

and do a verbose upload, I get

CURRENT: upload_protocol = kflash
MethodWrapper(["upload"], [".pio\build\sipeed-maixduino\firmware.bin"])
Auto-detected: COM33
"c:\users\max\appdata\local\programs\python\python38\python.exe" "C:\Users\Max\.platformio\packages\tool-kflash-kendryte210\kflash.py" -p COM33 -b 1500000 -B maixduino .pio\build\sipeed-maixduino\firmware.bin
[INFO] COM Port Selected Manually:  COM33 
[INFO] Default baudrate is 115200 , later it may be changed to the value you set.
[INFO] Trying to Enter the ISP Mode...

so, no error message about the firmware file not being found and no error message.

I think what happens here is that somehow you got the bleeding-edge git version of the platform.

The latest stable version 1.2.4 does not even have the -S flag

whereas the master branch has, along with the bug that no default value is supplied for it (as referenced by the above PR)

Can you please do the following: Open a CLI and execute

pio upgrade --dev
pio platform uninstall kendryte210
pio platform install kendryte210

and then re-upload the project.

@maxgerhardt - Yes you were right, the latest version of the master branch has the problem, but the stable release is working !
Thanks a lot for your help, I really appreciate the time you put in to help me.

1 Like