LibrePilot Forum

Development => GCS General => Topic started by: karla on January 12, 2017, 09:43:05 am

Title: Problems set up Build environment on OS X
Post by: karla on January 12, 2017, 09:43:05 am
Hi,
I am trying to set up the build environment on my mac using the wiki
https://librepilot.atlassian.net/wiki/display/LPDOC/Mac+-+Building+and+Packaging (https://librepilot.atlassian.net/wiki/display/LPDOC/Mac+-+Building+and+Packaging)

All is fine all the way down to the point "Dev Tools Installation".
Install development libraries and tools, these will be downloaded and automatically installed using root Makefile:
make all_sdk_install


I am using Terminal, the cursor is at directory code/librepilot and the I just send the command:
make all_sdk_install
(my user do have admin access)

First  there is a warning
[0] Warning: Could not create lock file '/Volumes/qt-opensource-mac-x64-clang-5.6.2/qt-opensource-mac-x64-clang-5.6.2.app/Contents/MacOS/lockmyApp1234865.lock': Read-only file system

and then later after lots of files are being installed, the whole command fails.
"disk2" unmounted.
"disk2" ejected.
 CLEAN       tools/osg-3.5.3-clang_64-qt-5.6.2
 VERIFY      downloads/osg-3.5.3-clang_64-qt-5.6.2.tar.gz
 EXTRACT     tools/osg-3.5.3-clang_64-qt-5.6.2
tar: Error opening archive: Failed to open 'downloads/osg-3.5.3-clang_64-qt-5.6.2.tar.gz'
make: *** [osg_install] Error 1
sh-3.2# make all_sdk_install


I probably do some wrong or missing command?
Here is the whole log

Karls-MacBook-Air-2:~ karl$ cd /Users/karl/Documents/karl/private/projects/helicopter/
Karls-MacBook-Air-2:helicopter karl$ cd code/librepilot
Karls-MacBook-Air-2:librepilot karl$ sudo su
Password:
sh-3.2# make all_sdk_install
 NOTE        Use 'make all_sdk_distclean' to remove installation files
 NOTE        Use 'make all_sdk_version' to check toolchain versions
 NOTE        Add 'V=1' to make command line to diagnose make problems
 NOTE        Add 'BATCH=1' to make command line to disable progress reporting during downloads
 INSTALL     gcc-arm-none-eabi
 CLEAN       tools/qt-5.6.2
 VERIFY      downloads/qt-opensource-mac-x64-clang-5.6.2.dmg
expected   CRC32 $5CE0F37C
/dev/disk2             GUID_partition_scheme             
/dev/disk2s1           EFI                               
/dev/disk2s2           Apple_HFS                         /Volumes/qt-opensource-mac-x64-clang-5.6.2
 EXTRACT     qt-opensource-mac-x64-clang-5.6.2.dmg to tools/qt-5.6.2
  • Warning: Could not create lock file '/Volumes/qt-opensource-mac-x64-clang-5.6.2/qt-opensource-mac-x64-clang-5.6.2.app/Contents/MacOS/lockmyApp1234865.lock': Read-only file system

"disk2" unmounted.
"disk2" ejected.
 CLEAN       tools/osg-3.5.3-clang_64-qt-5.6.2
 VERIFY      downloads/osg-3.5.3-clang_64-qt-5.6.2.tar.gz
 EXTRACT     tools/osg-3.5.3-clang_64-qt-5.6.2
tar: Error opening archive: Failed to open 'downloads/osg-3.5.3-clang_64-qt-5.6.2.tar.gz'
make: *** [osg_install] Error 1
sh-3.2# make all_sdk_install
Title: Re: Problems set up Build environment on OS X
Post by: filnet on January 12, 2017, 09:50:02 am
The recent upgrade to Qt 5.6.2 broke the osx build.

You can wait for the fix or locally revert https://bitbucket.org/librepilot/librepilot/commits/f54185948e33535e69a981d455bfa7c83195ea00.
Title: Re: Problems set up Build environment on OS X
Post by: karla on January 12, 2017, 10:22:43 am
Thanks filnet.

Good you can understand what happened :)
I am afraid I need some very clear and basic instructions to be able to do this.

If I wait for 'the fix' are we talking days, weeks or months?
Will that fix make changes to the Libre code? In that case, will I need to repeat the steps in the Wiki:
 
cd ~/code/librepilot
Now you can checkout code from remote Git server:
git checkout next
git pull

Title: Re: Problems set up Build environment on OS X
Post by: TheOtherCliff on January 12, 2017, 07:11:24 pm
'next' is the current development version.  It shouldn't be broken, but right now it is...

If you use:
16.09
instead of:
next
you will be building the release version instead of the development version.

'16.09' is the well tested release version, but it won't have some nice stuff in 'next' that is going to be added in the next release.  I think that would at least be a good way to test your building.

-------------------------------------------------------------

To continue to play with 'next' you could just try:
git revert f54185948e33535e69a981d455bfa7c83195ea00
then:
make all_clean
and start over with your makes
Title: Re: Problems set up Build environment on OS X
Post by: f5soh on January 12, 2017, 07:20:50 pm
For testing you can simply edit the  make/tools.mk file and set the QT_VERSION to 5.6.1 again.

This will revert to previous Qt version and check if the issue is related to this change.
If success you can still run next but using 5.6.1

You should also do a 'git pull' before editing the qt version and retrieve latest changes related the 'Jerry save' issue.
Title: Re: Problems set up Build environment on OS X
Post by: karla on January 12, 2017, 10:59:21 pm
Cool. thanks.
I think I understand some at least.
Since my purpose is not to change any code at the moment just get the code to the OPUploaderTool.exe and make an executable to upgrade my OP GPSv9 units, I will try the option of using 16.09 instead of next.

So I will back up in the instructions and do the commands:
git checkout 16.09
git pull

Then redo the
make all_sdk_install

Right? Will try
Title: Re: Problems set up Build environment on OS X
Post by: TheOtherCliff on January 13, 2017, 04:11:08 am
If you are using the directory you already have, you should 'make all_clean' before doing the build.
Title: Re: Problems set up Build environment on OS X
Post by: karla on January 13, 2017, 07:26:46 am
hm.. okay.
Seems to have worked better.
but i ran into some new problems.

I had a lot of warnings issued (over 50) during the make all_sdk_install command
like these ones
../qtools/qglobal.h:99:6: warning: "This version of Mac OS X is unsupported" [-W#warnings]
I am on MacOS Sierra 10.12.1 hope that is okay OS?

I tried run
make uploader fw_gpsplatinum
It complains
Project ERROR: Xcode not set up properly. You may need to confirm the license agreement by running /usr/bin/xcodebuild.

Running
/usr/bin/xcodebuild
complains
xcodebuild: error: The directory ~/code/librepilot does not contain an Xcode project.

I did check out the project first at the repository (16.09) and saved it locally in a dir called librepilot.
I was hoping Xcode could recognize it as a project? I used Xcode interface to checkout the 16.09 version.
What to set up first, a local project using Xcode then check out the code, or check out code first then try make a Xcode project?
Title: Re: Problems set up Build environment on OS X
Post by: TheOtherCliff on January 13, 2017, 07:44:03 am
At this point I have to say "Sorry, I'm not a Mac guy."  :(

If it were me, I would buy an external hard drive, use CloneZilla to back up your Mac, then make the Mac dual boot the latest Linux-Mint-Mate.  You will be able to boot either Linux or MacOS.

Everybody needs to back up, and it's crazy to not back up before something as drastic as making your main computer dual boot.
Title: Re: Problems set up Build environment on OS X
Post by: filnet on January 13, 2017, 08:55:08 am
Note that Qt 5.6 does not support macOs 10.12 (http://doc.qt.io/qt-5.6/supported-platforms.html).
Not sure how it will affect building GCS though...

Anyways : http://stackoverflow.com/questions/33728905/qt-creator-project-error-xcode-not-set-up-properly-you-may-need-to-confirm-t
Title: Re: Problems set up Build environment on OS X
Post by: karla on January 13, 2017, 09:59:59 am
Thanks all for advise.
Seems finally I got a successful build of the executable OPUploadTool :)
What made it work was to first create a project with Xcode and then checkout the code under a dir of that project. I think  :P
Anyways I attached it here for anyone else who like to try upgrade your OP GPSv9 while the Microsoft OPUploadTool.exe is broken.
I will try it myself after getting a well deserved beer  ;D
Title: Re: Problems set up Build environment on OS X
Post by: karla on January 14, 2017, 06:03:47 am
Story continues. Running the OPUploadTool today.

First i gave the wrong port name and then it complained it could not open serial port.
Then i gave the right port name that the GCS list under connections, this time it thinks for a while, then just exits without any further remark.
So Sync did not succeed but the device was found.
How do I know the speed is 9600? You cant specify combridge speed under hardware anymore like in the Wiki right?
https://librepilot.atlassian.net/wiki/display/LPDOC/Setup+a+bluetooth+for+telemetry (https://librepilot.atlassian.net/wiki/display/LPDOC/Setup+a+bluetooth+for+telemetry)

Karls-MacBook-Air-2:librepilot karl$ ./build/uploader_release/OPUploadTool -p ./build/firmware/fw_gpsplatinum/fw_gpsplatinum.opfw -t tty.usbmodem14

OpenPilot serial firmware uploader tool.
Connect the board
[==================================================] 100%     
Connect the board NOW
QSerialPort::SerialPortError(DeviceNotFoundError)
Could not open serial port

Karls-MacBook-Air-2:librepilot karl$ ./build/uploader_release/OPUploadTool -p ./build/firmware/fw_gpsplatinum/fw_gpsplatinum.opfw -t tty.usbmodem1421

OpenPilot serial firmware uploader tool.
Connect the board
[==================================================] 100%     
Connect the board NOW
Karls-MacBook-Air-2:librepilot karl$

Title: Re: Problems set up Build environment on OS X
Post by: TheOtherCliff on January 14, 2017, 06:52:10 am
The tricks are (I think):
- plug the FTDI (USB to serial adapter) in to the computer without the GPS being connected to the FTDI.
- determine what the port name is
- make sure you have write access to the port
- using sudo may be too slow (entering password)
- it's serial, so GPS Tx,Rx crosses and connects to FTDI Rx,Tx
- type the command line
- get the GPS (MCU+GPS port) ready to plug in to the FTDI
- plug the GPS in to the FTDI and immediately press Enter

It's been a while since I did this.  You may need to short SBL pads on GPS to get this to work?
Title: Re: Problems set up Build environment on OS X
Post by: karla on January 14, 2017, 07:59:19 am
The tricks are (I think):
- plug the FTDI (USB to serial adapter) in to the computer without the GPS being connected to the FTDI.
I am using the cambridge option with a Revo board. (i dont think a FTDI works on a Mac? I have one though)

- determine what the port name is
Clearly tty.usbmodem1421

- make sure you have write access to the port
This user have admin control to whole Mac

- using sudo may be too slow (entering password)
- it's serial, so GPS Tx,Rx crosses and connects to FTDI Rx,Tx
Yes, confirmed the crossing is correct.

- type the command line
- get the GPS (MCU+GPS port) ready to plug in to the FTDI
- plug the GPS in to the FTDI and immediately press Enter
Same result :(

It's been a while since I did this.  You may need to short SBL pads on GPS to get this to work?
That should be if using option A, not the OPUploadTool according the instruction file?

Do you think we can rule out there is something wrong with the OPUploadTool I build locally?
If that little app is okay then my building environment is okay at least.
How to check that?
Title: Re: Problems set up Build environment on OS X
Post by: TheOtherCliff on January 14, 2017, 08:19:49 am
I would guess that if it built successfully, that it should work (other than we know the Windows version has a bug).
Title: Re: Problems set up Build environment on OS X
Post by: hwh on January 14, 2017, 09:10:13 am
I was never able to get the OPUploadTool to upload firmware.  I just tried four or five times again and never got it to work.

I always recommend using a STLinkV2 to flash things.  No jumpers, no critical timing, it just works.  A genuine one is less than $25 and the clones on eBay less than $5.  It works to read and write the firmware on most F1, F3, and F4 based boards.  The cc3d, revo, and GPSv9 all have the same debug (SWD) connector on them.  Several other boards also use the same connector.  The ones that don't just need another adapter cable made.

I've used them on linux and windows only but the texane utilities supposedly can be compiled on OS-X.
Title: Re: Problems set up Build environment on OS X
Post by: f5soh on January 14, 2017, 11:38:44 am
Maybe there is others issues around.
With OPUploaderTool there is no need to short pads.

Here is a screenshot where the GPSv9 is flashed from a custom LiveCD:

(https://forum.librepilot.org/index.php?action=dlattach;topic=2903.0;attach=5014)


Title: Re: Problems set up Build environment on OS X
Post by: karla on January 14, 2017, 02:21:57 pm
Here is a screenshot where the GPSv9 is flashed from a custom LiveCD:

Do you mean having a CD version of Linux than can boot up my Mac will make it run on Linux instead of OSX, then I can use the Linux version of the OPUploaderTool to flash the GPSv9?

If so, i still need to get hold of the OPUploaderTool executable for Linux right?
Title: Re: Problems set up Build environment on OS X
Post by: f5soh on January 14, 2017, 06:13:52 pm
I made a i386 custom LiveCD with LP16.09, OPUploaderTool and firmware file on it.
Screenshot above describe the steps.

You can give a try using a PC if you have one at home.
Here is the iso file:
https://drive.google.com/drive/folders/0B5d_9OcqQj8BY1N1OXdqdGxGejA

http://www.linuxliveusb.com allow making a USB stick from Windows if you do not want to burn a DVD.


Title: Re: Problems set up Build environment on OS X
Post by: TheOtherCliff on January 14, 2017, 06:38:13 pm
You beat me to it.  I was in the middle of writing instructions to just download a live CD and install dependencies.
Title: Re: Problems set up Build environment on OS X
Post by: TheOtherCliff on January 14, 2017, 07:30:15 pm
FTDI USB to serial converter on eBay for $1.82 shipped.  Order one for later if not for now.  :)
http://www.ebay.com/itm/FTDI-Adapter-FT232RL-USB-zu-TTL-Serial-fur-3-3V-und-5V-fur-Arduino-PRO-Mini-/172456631436
The cheap one (USD $0.78) at this link would probably work too.  I just ordered one to play with.
http://www.ebay.com/itm/FTDI-FT232RL-USB-to-TTL-Serial-Converter-Adapter-Module-5V-3-3V-For-Arduino-New-/272501584059

Instructions to flash the GPS under Linux
I tested this myself just now (with my own built uploader and firmware)
-----------------------------------------------------------------------------------------------
set FTDI jumper to 5v or use the 5v pin when wiring a connector on the USB to serial adapter
  (the GPS needs 5v to run)
unplug the GPS from the FTDI (USB to serial converter)
plug the FTDI into the PC USB port
type this to make sure your device is called ttyUSB0
  ls -lrt /dev
I find ttyUSB0 third from the bottom for my FTDI brand USB to serial converter.  If using an OP FC set up as ComBridge instead of an FTDI, the device name will probably be ttyACM0.  In addition to being set up as ComBridge, an OP FC might need to have the correct baud rate set.  Use the GCS for that.  Do I recall that you need to leave the GCS running to use an FC as a ComBridge?

Once you are in a directory that has both uploader and the firmware you type this (but don't press Enter yet):
./OPUploaderTool -t /dev/ttyUSB0 -p fw_gpsplatinum.opfw

Get ready to plug the GPS "GPS+MCU" port into the FTDI
Press Enter and quickly plug the GPS into the FTDI

Within a few seconds, it should produce a progress bar, if not, ^C and try again.
Title: Re: Problems set up Build environment on OS X
Post by: hwh on January 14, 2017, 07:50:54 pm
...In addition to being set up as ComBridge, an OP FC might need to have the correct baud rate set.  Use the GCS for that....

You'd have to use an old version of GCS, that was deleted.  It automatically sets whatever baud rate the program opening the port sets.  If it doesn't set it then the system default is used.  The stty command will tell you what speed.

Have you tried combridge?  I remember someone saying it didn't work for the GPS update.
Title: Re: Problems set up Build environment on OS X
Post by: TheOtherCliff on January 14, 2017, 09:33:08 pm
Good to hear that ComBridge obeys the program for baud rate now.
I used ComBridge a long time ago (before GPS auto-everything) to connect GPS to u-center for configuration.  That is the last time I tried ComBridge.

I just used a Nano (a new K.Finisterre Nano) as a ComBridge and it starts but times out after flashing a few (5-22) percent.  I configured MainPort as a Combridge, stopped the GCS and unplugged everything, plugged in flight power to the Nano, plugged USB into the Nano, waited a few seconds for fast flashing and gyros to init, plugged GPS into the Nano and hit return on the following command line (which contains paths to files since they were not in my current directory).

./build/uploader_release/OPUploadTool -t /dev/ttyACM0 -p build/firmware/fw_gpsplatinum/fw_gpsplatinum.opfw

I tried several different things, INS13, 50hz output banks, disable USB HID, 6v power.
Title: Re: Problems set up Build environment on OS X
Post by: TheOtherCliff on January 14, 2017, 09:47:10 pm
I just did it with an authentic Sparky2 and it worked fine and completed.
Title: Re: Problems set up Build environment on OS X
Post by: karla on January 15, 2017, 02:55:32 am
Great this morning to find so much activity going on here!

I have been using ComBridge all along here.
Cliff, after you mentioned the GCS has to be kept running (I tried have GCS connected with usb to the board), then I got much further:

Karls-MacBook-Air-2:librepilot karl$ ./build/uploader_release/OPUploadTool -i -p ./build/firmware/fw_gpsplatinum/fw_gpsplatinum.opfw -t tty.usbmodem1421
OpenPilot serial firmware uploader tool.
Connect the board NOW
SYNC Succeded
Uploading...
Erasing, please wait...
Uploading firmware
Uploading firmware[===================>                              ]  39%     ____timeout
____timeout
Starting uploading description
Uploading firmware[=========================>                        ]  50%     ____timeout
Upload failed with code:1
Karls-MacBook-Air-2:librepilot karl$


But since you also seem to experience a lot of timeouts when using the ComBridge connection, I will abandon this.
The best I got was 63% uploaded but most of the cases its between 3-15%.

So I am downloading f5soh Linux bootable file with LP16.09 to make a USB and run on my PC from a USB memory with a  FTDI connector to my OP GPSv9. I have two different FTDIs and they have worked well for configuring my Bluetooth devices via the PC.

Thanks a lot all!
Title: Re: Problems set up Build environment on OS X
Post by: TheOtherCliff on January 15, 2017, 05:54:02 am
I had timeouts in Linux as well, so it isn't a MacOS issue.

I had good luck with a Sparky2 acting as ComBridge, but not with a Nano as ComBridge.  I suggest that you try different kinds of controllers or even several of the same kind as a last effort.
Title: Re: Problems set up Build environment on OS X
Post by: karla on January 15, 2017, 06:31:38 am
Okay.
I have already tried 2 Nano, 2 Revo and 3 OPGPSv9 boards in all combinations I can think of.
Can the FTDI USB to serial converters not be used with Mac?
Title: Re: Problems set up Build environment on OS X
Post by: TheOtherCliff on January 15, 2017, 06:38:31 am
I am guessing that either the high CPU power of the Sparky2 gets by a CPU priority issue, or the good quality components of the authentic Sparky2 helped.

I don't own a Mac, but I would bet large money that a standard FTDI would work on a Mac.

Are your Revo boards authentic?  I could try authentic Revo here for a test.

Title: Re: Problems set up Build environment on OS X
Post by: karla on January 15, 2017, 06:50:04 am
I dont know what an authentic Revo is :) all are from China. But no known problems with them. The two Nano are authentic.
If I plug in this FTDI to the USB port of the Mac I dont know how to figure out what Port name it has.
I suppose you give some command using Terminal... I tried the one you used for Linux but I cant find any new port after entering the USB.
Title: Re: Problems set up Build environment on OS X
Post by: karla on January 15, 2017, 09:53:15 am
Meanwhile I am trying to download f5soh ISO file but I am in China and it did not work all day, Google drive and anyting Google is blocked and VPN is soso. However I will be in Hong Kong tomorrow and likely get it fast.
Title: Re: Problems set up Build environment on OS X
Post by: TheOtherCliff on January 15, 2017, 03:31:51 pm
The "ls -lrt" command means list directory long (verbose) with reverse time order so the most recent show last.

Note that for Linux and MacOS we use the forward slash / to separate directory branches, but Microsoft uses the back slash \ to do this.

You could try
  ls -l /dev > before
plug in the FTDI
  ls -l /dev > after
then do this to compare the two files
  diff before after
Title: Re: Problems set up Build environment on OS X
Post by: f5soh on January 15, 2017, 03:41:20 pm
Here i simply use the 'dmesg' command (dmesg - print or control the kernel ring buffer) just after plugin the FTDI.

Code: [Select]
[143411.080560] usb 3-2: new full-speed USB device number 82 using xhci_hcd
[143411.250175] usb 3-2: New USB device found, idVendor=10c4, idProduct=ea60
[143411.250177] usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[143411.250178] usb 3-2: Product: CP2102 USB to UART Bridge Controller
[143411.250179] usb 3-2: Manufacturer: Silicon Labs
[143411.250180] usb 3-2: SerialNumber: 0001
[143411.252965] cp210x 3-2:1.0: cp210x converter detected
[143411.253446] usb 3-2: cp210x converter now attached to ttyUSB0
[laurent@new-host LibrePilot]

Anyways the /dev/ttyUSB0 should work first time without check, except if you plug multiples devices. (FTDI i mean)
Title: Re: Problems set up Build environment on OS X (SOLVED)
Post by: karla on January 16, 2017, 08:09:08 am
Fantastic - Uploading Succeeded!

Code: [Select]
Karls-MacBook-Air-2:librepilot karl$ ./build/uploader_release/OPUploadTool -i -p ./build/firmware/fw_gpsplatinum/fw_gpsplatinum.opfw -t tty.usbserial-AL00C2RJ
OpenPilot serial firmware uploader tool.
Connect the board NOW
SYNC Succeded
Uploading...
Erasing, please wait...
Uploading firmware
Uploading firmware[==================================================] 100%     Firmware Uploading succeeded
Starting uploading description
Uploading firmware[==================================================] 100%     Uploading Succeded!
Karls-MacBook-Air-2:librepilot karl$

Using my second FTDI unit resolved it.
The first one, I have used many times configuring Bluetooth boards with the little OP config executable for Windows. So I assumed it would work on Mac as well. I just have to accept that the Mac do not recognize it or list it at all, using the ‘ls -l /dev’ or ‘dmesg’ commands. But using the other FTDI unit with some 6 pins (only 4 used), then it listed the somewhat unexpected name ‘tty.usbserial-AL00C2RJ’. But it did work. First try.
Now all my GPSv9 are upgraded :))

Thanks sooo much!

Looking back on this, the Problems to set up the Build environment on OSX was solved early, the solution was really to set up a Xcode project first then download the LP code. Then when installing dev tools I had to back down from Next to LP 16.09 that uses a more familiar version Qt 5.6.1 (not 5.6.2), then okay.
Also okay to do my first build, the OPUploaderTool.
Then when actually using the little executable to upgrade the GPSv9, a ComBridge with Revo did not work (a bit better though after having the GCS running) neither with the first FTDI unit but finally with another one. I really do not know the difference between them. Both work but in different environments.


p.s. I will still try to make use of that Linux + OP16.09 ISO file so kindly posted here.

Finally really nice to hear someone have fixed the ‘Jerry save’ bug in the Heli set up!
That should reduce a lot of the confusion for newcomers.