Difference between revisions of "MINGW Development Package(MAC OS)"

From Embedded Systems Learning Academy
Jump to: navigation, search
(Open Eclipse and Create New Project)
(Required Package)
 
(28 intermediate revisions by the same user not shown)
Line 11: Line 11:
 
You might need to get and install the following package:
 
You might need to get and install the following package:
 
* Command Line Tools
 
* Command Line Tools
 +
* Python
 +
* Pyserial [v3.0.1]
 +
* Intelhex [v2.0]
 
<br/>
 
<br/>
  
Line 27: Line 30:
 
*  Right click on the lpc1758_freertos project
 
*  Right click on the lpc1758_freertos project
 
*  Choose '''Open Project'''
 
*  Choose '''Open Project'''
| [[File:open_project.png|left|frame|100px|Create New Eclipse C++ Project]]
+
| [[File:open_project.png|left|frame|100px|Open C++ Project]]
 
<BR/>
 
<BR/>
  
Line 58: Line 61:
 
| [[File:Build_code.png|left|frame|100px|Run your project]]
 
| [[File:Build_code.png|left|frame|100px|Run your project]]
  
 +
|}
 +
 +
== Program the Hex file into SJOne board ==
 +
 +
{|
 +
|
 +
'''1.'''  Find USB path
 +
<br/>
 +
* Open Terminal from your Mac
 +
* Type "ls /dev/ | grep usbserial*"
 +
| [[File:usb_path.png|left|frame|100px|Find USB path]]
 +
 +
|-
 +
|
 +
'''2.'''  Modify python script
 +
<br/>
 +
* Open the pyFlash-Hyperload.py
 +
* Find '''sDeviceFile''' and '''sHexFilePath'''
 +
* Replace these two path with your local device path and hex file path
 +
| [[File:python_script1.png|left|frame|100px|Modify python script]]
 +
<br/>
 +
 +
 +
|-
 +
|
 +
'''3.'''  Run External python tool from eclipse
 +
<br/>
 +
* Go to '''Run''' from the menu bar
 +
* Click '''External Tool''' -> '''python'''
 +
| [[File:run_python_tool.png|left|frame|100px|Start python tool from Eclipse]]
  
 
|-
 
|-
 
|
 
|
'''4.'''  Optional : Debug your program
+
'''4.'''  Program SJOne board
 
<br/>
 
<br/>
To perform debugging or run your code one line of code at a time, you can perform debugging.
+
*  Run the following command on the python external tool
*  Now, go to '''Run''' --> '''Debug'''
+
execfile("pyFlash-Hyperload.py")
*  Your program will now "pause" at the '''main()''' function.
+
| [[File:python_command.png|left|frame|100px|Program SJOne board]]
*  You can now use the '''Run''' menu to execute one line at a time.
 
*  Other hints :
 
*:  Double clicking on the code window sets a breakpoint.
 
*: You must press the red stop button to stop your program.
 
| [[File:mingw_debug_project.png|left|frame|100px|Debug your project]]
 
  
 
|}
 
|}

Latest revision as of 22:58, 27 December 2016

This tutorial shows you how to compile a C/C++ program in Mac OS using Eclipse. Remember that GNU is the linux-based compiler and hence if we want to use it for Mac OS, we have to have certain executable(s) to be running in Mac OS.

Development Package

You can get the same development package as the one we promote for ARM processors.


Required Package

You might need to get and install the following package:

  • Command Line Tools
  • Python
  • Pyserial [v3.0.1]
  • Intelhex [v2.0]


Open Eclipse and Create New Project

1. Open Eclipse.
   Always open the bash file
   since it sets up environment variables for you.

Open bash file in your development package directory

2. Open lpc1758_freertos Project

  • Right click on the lpc1758_freertos project
  • Choose Open Project
Open C++ Project


3. Write your source code
   Copy the simple source code on the right.

#include <stdio.h>

int main(void)
{
    /* Without this, printf() will not work */
    setvbuf(stdout, 0, _IONBF, 0);
    setvbuf(stdin,  0, _IONBF, 0);

    /* Write rest of your code here */
    printf("Hello World\n");
    return 0;
}

4. Run your program

  • Click on the the harmmer button and start building your code
  • build_with_dbc option will also generate the dbc file in _can_dbc directory
Run your project

Program the Hex file into SJOne board

1. Find USB path

  • Open Terminal from your Mac
  • Type "ls /dev/ | grep usbserial*"
Find USB path

2. Modify python script

  • Open the pyFlash-Hyperload.py
  • Find sDeviceFile and sHexFilePath
  • Replace these two path with your local device path and hex file path
Modify python script



3. Run External python tool from eclipse

  • Go to Run from the menu bar
  • Click External Tool -> python
Start python tool from Eclipse

4. Program SJOne board

  • Run the following command on the python external tool
  • execfile("pyFlash-Hyperload.py")
Program SJOne board