Discussion about development tools and environments, such as STLink, OpenOCD, arm-gcc, Eclipse, Qt Creator and Visual Studio.
no avatar
User

kyawkhaing

Posts

21

Joined

Fri Nov 28, 2014 1:48 am

Instructions to input TauLabs flight firmware to eclipse

by kyawkhaing » Sun Jan 04, 2015 8:07 pm

Happy New Year to all.

1)Install Ubuntu 10.04.4 (32) bit version on virtualbox.
[node: I try to run with Ubuntu 10.04.4 (64) bit , but when I try to build gcs "make gcs",
I got this error ( /home/kyawkhaing/code/TauLabs/ground/gcs/src/plugins/rawhid/hidapi/hidapi_linux.c:1117: undefined reference to `clock_gettime' collect2: ld returned 1 exit status ).
That why I recommended to use Ubuntu 10.04.4 (32) bit.
>>>>>>Important: when you create virtual machine on virtualbox , recommend to set hard disk size to 50GB and dynamic allocation because after finished your installation it will take up
16 GB.<<<<<]

After installed Ubuntu , you need to follow this instructions "http://askubuntu.com/questions/451805/screen-resolution-problem-with-ubuntu-14-04-and-virtualbox"
to get right resolution on the VM.

2)follow the instructions from the Development-Linux-setup
https://github.com/TauLabs/TauLabs/wiki ... inux-setup
>>>>>>Important: when you install Qt sdk using this command "make qt_sdk_install" , you need to wait around 2 or 3 hours according to your internet speed,
after finished download , you will see following message look like

*** NOTE NOTE NOTE ***
*
* In the GUI, please use exactly this path as the installation path:
* /home/kyawkhaing/code/TauLabs/tools/Qt5.3.2
*
*** NOTE NOTE NOTE ***
and don't forget to put given installation path (for my case /home/kyawkhaing/code/TauLabs/tools/Qt5.3.2) to qt sdk installation folder.

3)how to build gcs?
3.1) using the terminal very easy , go to taulabs home director and type "make gcs".
3.2) using qtcreator , launch QtCreator from TauLabs/tools/Qt5.3.2/Tools/QtCreator/bin/qtcreator and you need to open the project
>>File>>Open File or Project>>
and select ground.pro under /TauLabs/ground/ directory. Then you need to change build directory "for my case TauLabs/build/ground" by choosing "projects" icon from the
left menu bar.
[note: even though you open ground.pro project,you can't see project explore,you need to click "Edit" menu on the left menu bar and click "Hide sidebar" near the
bottom left corner, you can see "Hide sidebar" button left side of search box.After you click this button you can see project explore.Now you are ready to build
gcs by clicking green arrow menu on the left menu bar.



4)Import TauLabs flight to the eclipse

4.1)In the git download folder , under the TauLabs\flight\Project\Eclipse folder , you can find eclipseLinuxWsp.zip ,
unzip using "unzip eclipseLinuxWsp.zip -d eclipseLinuxWsp".In the eclipseLinuxWsp folder you can't see anything because all are hidden file.
You need to check Show Hidden Files under the view menu.Then you can see 1 folder name ".metadata" and 2 files are ".cproject" and ".project".
Then you put folder name ".metadata" under TauLabs and file name ".cproject" and ".project" to TauLabs\flight folder.

4.2)I download and install "eclipse-cpp-luna-SR1-RC3-linux-gtk.tar.gz". After unzip, you launch eclipse but no need to care about workspace right now.

4.3)Just go to menu Help>>Install New Software. , then you select "Luna - http://download.eclipse.org/releases/luna" in the "Work withd" combox on top
of the dialog box, then wait for a while, you can see items showing up in the third box from top.Amange the items
select "Mobile and Device Development" by tick check box on the right.Then click next,next,accept term and condition and Finish.

4.4)Just follow the same steps like (4.3) and instead of "Luna - http://download.eclipse.org/releases/luna" , you need to put this
"http://embsysregview.sourceforge.net/update" in the "Work withd" combox , and Then click next,next,accept term and condition and Finish.

4.5)set up embsysregview for degug.
Choose Window->Show View->Other... from the Menu and Debug->EmbSysRegisters from the view selection window.
Then you should tell the View what chip you are using, by
selecting Window->Preferences from the menu and C/C++->Debug->EmbSysRegview from the preferences window
or by clicking on the wrench icon in the upper left corner of the view.
after you select "EmbSys Register view" , on the right panel you need to select Architecture,Vendor,Chip,Board.In my case
Architecture: cortex-m4 , Vendor: STMicro , Chip: stm32f40x , Board: STM32F4DISCOVERY.

4.6)create folder eclipseWorkspace under TauLabs/tools and close eclipse and open , when you open eclipse , it will ask you to select the workspace ,
you select "eclipseWorkspace" folder you have created just now (for my case "/home/kyawkhaing/code/TauLabs/tools/eclipseWorkspace")
Then you click c/c++ perspective on the right top of the eclipse and you can see "Project Explore" on the left panel of the eclipse.
In the Project Explore right click and select "import" on the popup menu and select "Existing Projects into Workspace" then select "TauLabs" folder(root folder of the TauLabs git clone) and
just next next and finish.After that you can see two project under Project Explore, androidgcs and flight.My guid only cater for flight project.



4.7)Select flight project,on the tool bar,4th button count start from debug button to right, beside 4th button (green button with red luggage image) you can see down arrow button,

eclipse_extermal_tools_configuration.png
eclipse_extermal_tools_configuration.png (252.66 KiB) Viewed 2743 times


click this button (you can reference from "eclipse_extermal_tools_configuration.png" image),you can see 1 Build FW,2 Clean,3 Build FW , 4 Build BL,5 Start Debug Deamon,6 Upload BL,7 Upload FW.
In the menu you select External Tools Configurations,right of the External Tools Configurations dialogbox , you can see all menu that you see on the previous menu.You need to select , change "Working Directory" and apply one by one from Build BL until Upload FW.
Right now "Working Directory" value is showing ${workspace_loc:} , so you need to change by click "Browse File System.." and select "TauLabs" folder.
Detail of each configuration for my case,

eclipse_extermal_tools_configuration_2.png
eclipse_extermal_tools_configuration_2.png (493.77 KiB) Viewed 2743 times


Build BL
select "main" Tag
Location:${system_path:make}
Working Directory:/home/kyawkhaing/code/TauLabs
Arguments:bl_${string_prompt:Project_name:flying_f4}
>>>>>>click Apply button.
Build FW
select "main" Tag
Location:${system_path:make}
Working Directory:/home/kyawkhaing/code/TauLabs
Arguments:${string_prompt:Project_name:fw_flyingf4}
>>>>>>click Apply button.
Build FW(to use with BL)
select "main" Tag
Location:${system_path:make}
Working Directory:/home/kyawkhaing/code/TauLabs
Arguments:${string_prompt:Project_name:fw_flyingf4} USE_BOOTLOADER=YES
>>>>>>click Apply button.
Clean
select "main" Tag
Location:${system_path:make}
Working Directory:/home/kyawkhaing/code/TauLabs
Arguments:${string_prompt:Project_name:fw_flyingf4}_clean
>>>>>>click Apply button.
Start Debug Deamon
select "main" Tag
Location:/home/kyawkhaing/code/TauLabs/tools/openocd/bin/openocd
Working Directory:/home/kyawkhaing/code/TauLabs/flight
Arguments:-f Project/OpenOCD/stlink-v2.cfg -f Project/OpenOCD/stm32f4xx.stlink.cfg -c init
>>>>>>click Apply button.
Upload BL
select "main" Tag
Location:${system_path:make}
Working Directory:/home/kyawkhaing/code/TauLabs
Arguments:bl_${string_prompt:Project_name:flyingf4}_program
>>>>>>click Apply button.
Upload FW
select "main" Tag
Location:${system_path:make}
Working Directory:/home/kyawkhaing/code/TauLabs
Arguments:${string_prompt:Project_name:fw_flyingf4}_program
>>>>>>click Apply button.
4.8)on the tools menu, beside debug button you can see down arrow button ,when you click this button , one popup menu appear ,
select "Debug Configurations..." , after that Debug Configurations dialog box appear,select "Start Debugging" from left panel.
After that in the right panel

4.9.1)select "Main" tag and change the file location of the "C/C++ Application" , for my case
"/home/kyawkhaing/code/TauLabs/build/fw_flyingf4/fw_flyingf4.elf" , before debug you need to run "Build FW" from (4.7).
After finished firmware build you go and find the .elf file under the "/home/kyawkhaing/code/TauLabs/build/fw_flyingf4" folder because I build fw_flyingf4 ,
that why I can see "fw_flyingf4" folder under "build" folder.If you build fw_flyingf3 , you need to find under "/home/kyawkhaing/code/TauLabs/build/fw_flyingf3"
>>>>>>click Apply button.
4.9.2)dialog box's centre bottom , you can see "Select other..." , when you click this link , "Select Preferred Launcher" dialog box appear,
in my pc , "GDB(DSF)Hardware Debugging Launcher" is selected default.So I select "Legacy GDB Hardware Debugging Launcher" ,before that I need to tick "User configuration specific settin" otherwise
you can't select "Legacy GDB Hardware Debugging Launcher".
>>>>>>click ok button.

Debug_Configuration_Select_Preferred_Launcher.png
Debug_Configuration_Select_Preferred_Launcher.png (430.55 KiB) Viewed 2743 times



4.9.3)select Debugger tag and change GDB Command: to
for my case "/home/kyawkhaing/code/TauLabs/tools/gcc-arm-none-eabi-4_8-2013q4/bin/arm-none-eabi-gdb".If you have already done no(2), you have this "gcc-arm-none-eabi-4_8-2013q4"
folder under the "tools" folder.
4.9.4)select Startup tag, then draw right scroll to bottom and you can see "Run Commands" text box,you change value to
in my case "/home/kyawkhaing/code/TauLabs/flight/Project/gdb/InterruptsInEclipse".
>>>>>>click Apply button.

5)How to connect stm32f4 Discovery board to virtual box Ubuntu , for pc this is very easy step but for virtual box a little bit tricky.
5.1)run this command for usb driver for ubuntu.
sudo apt-get install build-essential \
virtualbox virtualbox-dkms \
virtualbox-guest-dkms \
virtualbox-guest-utils \
virtualbox-guest-x11 \
virtualbox-qt
5.2)Download "http://dlc-cdn.sun.com/virtualbox/4.3.14/Oracle_VM_VirtualBox_Extension_Pack-4.3.14-95030.vbox-extpack" and install Virtualbox extension pack (to enable USB 2.0).
5.3)if VirtualBox doesn't have Devices menu
you follow instructions under this link "http://askubuntu.com/questions/90318/virtualbox-doesnt-have-devices-menu" or
"http://askubuntu.com/questions/22743/how-do-i-install-guest-additions-in-a-virtualbox-vm/22745#22745". and reboot virtual box.
and then you need to Right (Ctrl + L) then you can see device menu right bottom of the virtual box.


General advice for connecting any USB device to a Windows guest(credit to https://forums.virtualbox.org/viewtopic.php?f=6&t=55483)
-------------------------------------------------------------

The steps I use to connect any USB device to a VM are as follows.
(Note: if it's a USB3 device then it will only be supported on Windows hosts in a USB2 port - other hosts won't support it at all).

Enable the "USB Controller" and "USB 2.0 (EHCI) Controller" options in the VM settings. If these were previously disabled then I like to boot up the VM at this point so that the guest OS can auto-detect the USB controller and install drivers for it. I then shut the guest down again. At this point the guest has only seen the controller - no actual USB devices were connected. This step ensures that when I later get the "New hardware found" dialog then I will not get confused over what hardware has been found.

In the VM settings USB | filters panel, add a filter to match the USB dongle. A blank filter will match anything, which is good if the device appears as a composite, i.e. presents as a number of different devices all connected at once. However the danger of a blank filter is the potential to grab the wrong device, e.g. you do not want to grab the hosts USB keyboard and assign it to the guest! (the host must have a keyboard, so it can't just be rudely grabbed and assigned to the guest: the host must own the keyboard and sends keystrokes to the guest as needed). If you have a problem with the wrong device being grabbed then you'll need to add information to the filter so that it matches the dongle only. In the case of my Huawei dongle I created a filter in which only the vendor ID field (Huawei) was filled in. This prevents most problems provided I continue to only use one Huawei device on my PC.

Now with the USB device unplugged, start up the VM. Wait until the guest OS is finished booting up (e.g. you reach the desktop in a Windows guest, and disk activity has stopped), then plug the USB device into a host port. On Windows hosts a "New hardware found" dialog box will appear. Don't let this fool you: this dialog is not the guest detecting your USB device, this prompt actually comes from VirtualBox on your host, and it's asking if it can install the USB filter driver, i.e. the driver that intercepts USB messages from this device and redirects them to the VM. You need to allow this to happen, so click "Not at this time" to the internet search question, then "Install the software automatically" to the driver location choice.
WARNING: on some hosts the protection level will be set so high that attempts to install the USB filter driver are automatically blocked without even prompting you. You'll never get USB working on such a host; you must have the host configured to at least prompt you when asked to install a device driver.

Once the host filter driver has been installed, I like to unplug the USB device and plug it back in again. Now the guest should grab the device smoothly and you should be ready to rock 'n roll.
The procedure outlined above works best with generic USB mass storage devices, because the Windows guest (XP and later) has native support for these and hence doesn't need you to install any further drivers. I suggest that you practice these steps with a USB thumb drive, and get the procedure down pat before you tackle devices that need additional drivers, such as the Huawei E3131.



6) How to debug , first of all you need to run "Start Debug Deamon" from (4.7) if everything is correct you can see following message under the console,
------------------Message ----------------------------------------------
Open On-Chip Debugger 0.7.0-dev-00128-gcf1418e-dirty (2015-01-03-00:05)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.sourceforge.net/doc/doxygen/bugs.html
adapter speed: 1000 kHz
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : clock speed 1000 kHz
Info : STLINK v2 JTAG v23 API v2 SWIM v0 VID 0x0483 PID 0x3748
Info : Target voltage: 2.865149
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
-------------------------------------------------------------------------
>>>>>>If you didn't see this message , os can't detect controller board.<<<<<
If you see this message , you run "Start Debugging" from (4.8).When you run this , you will see new message box which is asking about to switch debug perspective , just say yes.
After that you will reach to debug perspective view , first of all you need to click "resume"(F8) on the tools bar , otherwise you can continue debug.Then you click "instruction stepping mode" icon.
Icon look like " i-> " on the tools menu.

I forget one thing, ubuntu not allow to access usb from application , so that we need to put "45-taulabs-permissions.rules" file to this "/etc/udev/rules.d" folder.If you can't copy file to this destination , you login as super by typing "sudo -s" and try again.

45-taulabs-permissions.rules(file content)
---------------------------------------- Start ------------------------------------------------------------------------------
#
# OpenPilot
#

# OpenPilot Flight Control board
SUBSYSTEM=="usb", ATTRS{idVendor}=="20a0", ATTRS{idProduct}=="4117", MODE="0664", GROUP="plugdev"
# OpenPilot OP board
SUBSYSTEM=="usb", ATTRS{idVendor}=="20a0", ATTRS{idProduct}=="415a", MODE="0664", GROUP="plugdev"
# OpenPilot CopterControl flight control board
SUBSYSTEM=="usb", ATTRS{idVendor}=="20a0", ATTRS{idProduct}=="415b", MODE="0664", GROUP="plugdev"
# OpenPilot Pipx radio modem board
SUBSYSTEM=="usb", ATTRS{idVendor}=="20a0", ATTRS{idProduct}=="415c", MODE="0664", GROUP="plugdev"
# OpenPilot CopterControl3D flight control board
SUBSYSTEM=="usb", ATTRS{idVendor}=="20a0", ATTRS{idProduct}=="415d", MODE="0664", GROUP="plugdev"
# OpenPilot Revolution flight control board
SUBSYSTEM=="usb", ATTRS{idVendor}=="20a0", ATTRS{idProduct}=="415e", MODE="0664", GROUP="plugdev"
# OpenPilot osd
SUBSYSTEM=="usb", ATTRS{idVendor}=="20a0", ATTRS{idProduct}=="4194", MODE="0664", GROUP="plugdev"
# OpenPilot spare
SUBSYSTEM=="usb", ATTRS{idVendor}=="20a0", ATTRS{idProduct}=="4195", MODE="0664", GROUP="plugdev"

#
# Quantec Networks GmbH
#

# Quantec Networks GmbH - quanton flight control rev. 1
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fda", ATTRS{idProduct}=="0100", MODE="0664", GROUP="plugdev"

#
# Tau Labs
#

# TauLabs Freedom flight controller board
SUBSYSTEM=="usb", ATTRS{idVendor}=="20a0", ATTRS{idProduct}=="41d0", MODE="0664", GROUP="plugdev"
# TauLabs Sparky flight controller board
SUBSYSTEM=="usb", ATTRS{idVendor}=="20a0", ATTRS{idProduct}=="41d0", MODE="0664", GROUP="plugdev"

#
# ST Micro
#

# DFU (Internal bootloader for STM32 MCUs)
SUBSYSTEM=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="df11", MODE="0664", GROUP="plugdev"

#
# JTAG adapters
#

# FTDI FT2232C Dual USB-UART/FIFO IC
SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", MODE="0664", GROUP="plugdev"
# Olimex Ltd. OpenOCD JTAG TINY
SUBSYSTEM=="usb", ATTRS{idVendor}=="15ba", ATTRS{idProduct}=="0004", MODE="0664", GROUP="plugdev"
# STLINK/V2
SUBSYSTEM=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", MODE="0664", GROUP="plugdev"

------------------------------------------- The End ----------------------------------------------------------------------------------------------------------------




Good Luck.

Best regards,
Kyaw Khaing
User avatar
User

jhitesma

Posts

132

Joined

Tue Sep 30, 2014 8:14 am

Location

Yuma, AZ - USA

Re: Instructions to input TauLabs flight firmware to eclips

by jhitesma » Mon Jan 05, 2015 4:48 am

Thanks for sharing! I stopped messing with the VM and just started using my native Linux notebook for development - but I've only been doing it from command line because I've never been able to figure out how to setup a project in Eclipse.

I haven't touched my fork in a few months and really need to catch it up as I want to try the MW rate mode code and probably the oneshot soon as well. Looks like I need to set aside some time to get Eclipse going first as I'd love to have a full IDE instead of continuing with command line only.

Who is online

Users browsing this forum: No registered users and 1 guest

Powered by phpBB ® | phpBB3 Style by KomiDesign
cron