Schugy

  • *
  • 12
LP16.09+r735 and spracing_f3 with CP2102
« on: October 12, 2018, 10:54:38 am »
After 8 CC3Ds (F1) I tried a simple F3 as an upgrade. My choices are limited because I need my FCs to be fully assembled. It was an easy task to install the boot loader. Unfortunately noone updated the instructions in months for the F3 with a CP2102 chip.
I could install INAV without a problem but currently I don't want to use it.
My next try was stm32flash.
Quote
sudo stm32flash -w bl_spracingf3.hex /dev/ttyUSB0
stm32flash 0.5

http://stm32flash.sourceforge.net/

Using Parser : Intel HEX
Interface serial_posix: 57600 8E1
Version      : 0x31
Option 1     : 0x00
Option 2     : 0x00
Device ID    : 0x0422 (STM32F302xB(C)/F303xB(C)/F358xx)
- RAM        : 40KiB  (5120b reserved by bootloader)
- Flash      : 256KiB (size first sector: 2x2048)
- Option RAM : 16b
- System RAM : 8KiB
Write to memory
Erasing memory
Wrote address 0x08004000 (100.00%) Done.
Can I flash fw_spracingf3.opfw with stm32flash? What's the start address (something behind 0x08004000) or page offset?
Thank you for your help.

Re: LP16.09+r735 and spracing_f3 with CP2102
« Reply #1 on: October 12, 2018, 05:43:37 pm »
No, but it is simpler than that.  Once you have the bootloader, you use the GCS, but since you don't have firmware on it yet, you must use the manual method.  Unplug all FC power (usb and battery).  Go to Firmware page and press Rescue, THEN  plug in FC.  Then you can Upgrade, Upgrade & Erase, Open/Flash, Erase...

Make sure you do something that eventually includes Erase after flashing the firmware.

Schugy

  • *
  • 12
Re: LP16.09+r735 and spracing_f3 with CP2102
« Reply #2 on: October 13, 2018, 01:49:43 am »
Thank you for your help. I have the fading LED after flashing the boot loader. But when I plug the FC into the USB port with or without the bl-button pressed then nothing happens within the 20 seconds. That's why I'm looking for a command line tool for my KingKong F3 that actually works with LP firmware.
Quote
usb 1-1.1: new full-speed USB device number 16 using ehci-pci
usb 1-1.1: New USB device found, idVendor=10c4, idProduct=ea60
usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1.1: Product: CP2102 USB to UART Bridge Controller
usb 1-1.1: Manufacturer: Silicon Labs
usb 1-1.1: SerialNumber: 0001
cp210x 1-1.1:1.0: cp210x converter detected
usb 1-1.1: cp210x converter now attached to ttyUSB
Quote
2018-10-12 @ 22:33:19 -- Running - OS: Linux, Chrome: 68.0.3440.106, Configurator: 2.0.0
2018-10-12 @ 22:35:05 -- Loaded release information from GitHub.
2018-10-12 @ 22:43:00 -- Serial port successfully opened with ID: 2
2018-10-12 @ 22:43:00 -- MultiWii API version received - 2.2.0
2018-10-12 @ 22:43:00 -- Flight controller info, identifier: INAV, version: 2.0.0
2018-10-12 @ 22:43:00 -- Running firmware released on: Aug 19 2018 21:15:55
2018-10-12 @ 22:43:00 -- Board: SRF3, version: 0
2018-10-12 @ 22:43:00 -- Unique device ID received - 0x40002f5633571720333131

Re: LP16.09+r735 and spracing_f3 with CP2102
« Reply #3 on: October 13, 2018, 04:18:51 am »
Did you try it exactly this way?
Unplug all FC power (usb and battery).  Go to Firmware page and press Rescue, THEN  plug in FC (into USB).  Then you can Upgrade, Upgrade & Erase, Open/Flash, Erase...

Fading LED is good.  It means exactly that you have a working bootloader, but not normal firmware.

Schugy

  • *
  • 12
Re: LP16.09+r735 and spracing_f3 with CP2102
« Reply #4 on: October 14, 2018, 01:33:08 pm »
Yes, exactly this way. But when I connect the FC to my USB port(s) the 17 remaining seconds elapse and nothing happens. Tried that "rescue" and "open" method with a CC3D_F1 and it worked. INAV needed
Quote
sudo chmod user:group /dev/ttyUSB0
and I tried it with LP-GCS too. Nothing seems to work. I´d still like to skip this rescue procedure and use stm32flash to see if the GCS works with a properly flashed KK_F3.
INAV on the F3 seems (not configured to flyable state) to cure the Walkera RX-SBUS + CC3D intermittent SBUS input problem and I hope LP works too.
I have heard that F4 isn´t compatible either so I´m stuck with F3.

f5soh

  • *****
  • 4465
    • LibrePilot
Re: LP16.09+r735 and spracing_f3 with CP2102
« Reply #5 on: October 14, 2018, 02:19:27 pm »
You should give a try using the Uploader tool :

Code: [Select]
make fw_spracingf3
make uploader
./build/uploader_release/UploadTool -p ./build/firmware/fw_spracingf3/fw_spracingf3.opfw -v -t /dev/ttyUSB0

Or specify the serial port, close to the Rescue button in firmware tab (untested)

Re: LP16.09+r735 and spracing_f3 with CP2102
« Reply #6 on: October 14, 2018, 05:19:05 pm »
Hmmm.  Programming note for less familiar programmers:  I recall there is a place in the GCS code where each new FC needs to be added.  I also vaguely recall that @mr_w made a comment about F3 code being incomplete in GCS.  That would explain this issue.  And the discussed OpUploadTool or STM32Flash would be the way to get over this hurdle.

From what I recall, the trick to using stm32flash is building the ef_whatever.bin or hex (entire flash - contains bl and firmware) and using that with stm32flash.

SInce this has USB, you could also try dfu-util (replace the whatevers):
dfu-util -d 0483:df11 -c 1 -i 0 -a 0 -D build/firmware/ef_whatever/ef_whatever.bin -s 0x08000000
The "-d 0483:df11" is the USB device.  This number is the OpenPilot device ID.  You will probably need to use lsusb to find the correct USB ID for this non-OpenPilot board.
https://forum.librepilot.org/index.php?topic=2920.msg20233;topicseen#msg20233

Searching the forum for dfu-util or stm32flash or opuploadtool etc. gives a wealth of information.  :)

If you get it flashed with any of these and get it working, let us know in this thread.  Thanks.
« Last Edit: October 14, 2018, 05:23:06 pm by TheOtherCliff »

f5soh

  • *****
  • 4465
    • LibrePilot
Re: LP16.09+r735 and spracing_f3 with CP2102
« Reply #7 on: October 14, 2018, 05:23:58 pm »
dfu-util should not work for spracingF3.

Re: LP16.09+r735 and spracing_f3 with CP2102
« Reply #8 on: October 14, 2018, 11:49:37 pm »
I thought it would since it has USB.  Is the CP2102 or the evo (that mr_w talked about) the difference why dfu-util won't work?

From the mr_w post I linked to in previous msg:

Re: Re: TinyPilot F3?
« Reply #4 on: 2017-01-13, 17:12:24 »
Best thing is to get dfu-util and then use it to flash .bin file to "Internal Flash" section.

For initial flash of the bootloader (and rest of it), do make ef_spracingf3evo

And by the way, the USB ID (for use with dfu-util if it works) was identified in one of the previous posts.
Quote
usb 1-1.1: New USB device found, idVendor=10c4, idProduct=ea60

Schugy

  • *
  • 12
Re: LP16.09+r735 and spracing_f3 with CP2102
« Reply #9 on: October 15, 2018, 09:01:01 pm »
Tried dfu-util
Quote
dfu-util -d 10c4:ea60 -c 1 -i 0 -a 0 -D fw_spracingf3.opfw -s 0x08000000
dfu-util 0.8
dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
dfu-util: No DFU capable USB device available
Also converted the fw_spracing.opfw-file to .hex
Quote
arm-none-eabi-objcopy -I binary -O ihex --set-start 0x8000000 fw_spracingf3.opfw fw_spracingf3.hex
and tried INAV but got the following error:
Quote
stm32 communication failed, wrong response, expected: 121 (0x79) received: 31 (0x1f)
This USB-UART bridge thingy can't be easily circumvented.


f5soh

  • *****
  • 4465
    • LibrePilot
Re: LP16.09+r735 and spracing_f3 with CP2102
« Reply #10 on: October 15, 2018, 09:36:12 pm »
Quote
Also converted the fw_spracing.opfw-file to .hex
You cannot convert .opfw to hex, only from .bin to .hex, like file attached.

Can you try using the UploadTool, following the steps described in previous post ?

Schugy

  • *
  • 12
Re: LP16.09+r735 and spracing_f3 with CP2102
« Reply #11 on: October 16, 2018, 03:28:01 pm »
Tried to compile the upload tool but something is missing. I installed build-essential and libqt4-dev packages (Kubuntu 16.04.3/18.04.01 live systems).
You cannot convert .opfw to hex, only from .bin to .hex, like file attached.
Compared the 2 files and there are differences only at the very end of the file. Might still be enough to confuse the FC.

Re: LP16.09+r735 and spracing_f3 with CP2102
« Reply #12 on: October 16, 2018, 06:24:14 pm »
I presume you mean that the bin and opfw are similar.

I know that the opfw format is basically a repackaging of the bin file.  I had assumed that there was some other stuff (e.g. a header) that would make it more incompatible.

Both opfw and hex formats know more than just the firmware.  For instance they know where to write the firmware.  The bin format doesn't know that.

It seems you can use CleanFlight to program any hex file into any FC that CleanFlight knows about.  You may want to try that if OpUploadTool won't build or work for you.

Attached find:
OpUploadTool = upload tool I built for LP 16.09 (dirty is not a problem for you) on my Mint 17.2 (based on Ubuntu) system.
UploadToolnext = upload tool I built for LP next r735 on my Mint 17.2 (based on Ubuntu) system.
« Last Edit: October 16, 2018, 07:34:38 pm by TheOtherCliff »

f5soh

  • *****
  • 4465
    • LibrePilot
Re: LP16.09+r735 and spracing_f3 with CP2102
« Reply #13 on: October 16, 2018, 06:38:43 pm »
Quote
I installed build-essential and libqt4-dev packages
You need qt5 instead of qt4, something like that needed with apt-get :
Code: [Select]
apt-get install qt5-default qttools5-dev-tools
Take a look at Wiki page

Schugy

  • *
  • 12
Re: LP16.09+r735 and spracing_f3 with CP2102
« Reply #14 on: October 16, 2018, 08:18:25 pm »
Installed qt5-dev-packages but I guess make still uses the wrong path.
The UploadToolNext times out at erase. CleanFlight shows the same error as inav with ef_spracingf3.hex. Now my F3 has Cleanflight on it. That worked.