| You are not Logged In! |
Difference between revisions of "Public:Building and Debugging Code"
imported>Amalia |
imported>Amalia |
||
| Line 1: | Line 1: | ||
| − | + | __NOTOC__ | |
==Getting Started== | ==Getting Started== | ||
| Line 19: | Line 19: | ||
##Close everything else that is open. You will be very sad if there are build error in other projects that make yours fail. | ##Close everything else that is open. You will be very sad if there are build error in other projects that make yours fail. | ||
#Set all build configurations (mbed, common, <project_name>) to whatever microcontroller is being used (probably LPC1549). | #Set all build configurations (mbed, common, <project_name>) to whatever microcontroller is being used (probably LPC1549). | ||
| + | * *Right click on each project > ''Build Configurations'' > ''Set Active'' > ''<correct>'' | ||
+ | + | ||
[[File:68|upright 1.0]] #Make sure the linker script location for your project is set correctly (on your project). | [[File:68|upright 1.0]] #Make sure the linker script location for your project is set correctly (on your project). | ||
| − | ##Right click on | + | ##Right click on <project_name> (NOT mbed or common) > ''Properties'' > ''C/C++ Build'' > ''Settings'' |
| − | ##In "Tool Settings" go to MCU C++ Linker > Managed Linker Script | + | ##In "Tool Settings" go to ''MCU C++ Linker'' > ''Managed Linker Script'' |
##Make sure that you have: | ##Make sure that you have: | ||
###Script name: -+LPC1549.ld+- | ###Script name: -+LPC1549.ld+- | ||
| Line 33: | Line 34: | ||
[[File:69|upright 1.0]] + | [[File:69|upright 1.0]] + | ||
| − | #Make sure the compiler language settings are set to the right thing (on mbed, common, and | + | #Make sure the compiler language settings are set to the right thing (on mbed, common, and <project_name>) |
| − | ##Right click on | + | ##Right click on each project > ''Properties'' > ''C/C++ Build Settings'' > ''Settings'' |
##In "Tool Settings" go to MCU C++ Compiler > Dialect | ##In "Tool Settings" go to MCU C++ Compiler > Dialect | ||
##Language standard settings should be: | ##Language standard settings should be: | ||
| Line 50: | Line 51: | ||
The way we flash code and debug is the same. Flashing code is just starting a debug session and then ending it right away. The steps to do so are: | The way we flash code and debug is the same. Flashing code is just starting a debug session and then ending it right away. The steps to do so are: | ||
| − | + | #'''With MCUXpresso closed''' set up the [https://github.com/devanlai/DAP42 custom DAP42 debugger] ''(if you're using the large, inefficient LPC-Link2 then you don't have to follow this step)'' | |
| − | '' | + | * *''If you're using the small ones (pic coming soon) that say "DL, DC" on them, that's the DAP42'' |
| + | ##Navigate to -+[your hard drive root directory/nxp/MCUXpressoIDE_xx.x.x_xxx/ide/bin/Scripts/probetable.csv+- | ||
| + | ##Open that file in Notepad or Notepad++ ('''NOT EXCEL''') | ||
| + | ##Add this line to the bottom: -+0x1209, 0xDA42, 64, 1, 0, 0, 0, "", 0x0000, -1+- (and a new line after it) | ||
| + | #Open MCUXpresso and build your project | ||
#Create the debug configuration (you'll only do this once per project) | #Create the debug configuration (you'll only do this once per project) | ||
| − | ##Select your project (NOT mbed or common, but '''your''' project) and open "Debug Configurations" | + | ##Select your project (NOT mbed or common, but '''your''' project) and open "Debug Configurations" (down arrow next to one of the bug icons) |
[[File:73|upright 1.0]] ##Double click on C/C++ (NXP Semiconductors) MCU Application to create a build configuration | [[File:73|upright 1.0]] ##Double click on C/C++ (NXP Semiconductors) MCU Application to create a build configuration | ||
| − | ##Name | + | ##Leave Project Name as default |
| − | + | ##Under "C/C++ Application", click ''Browse...'' and navigate to the project's folder inside the repository. The file will be located in that folder (in the repo) at -+LPC1549\projectname.axf+- | |
[[File:74|upright 1.0]] #Try hitting debug (the bug icon in the toolbar) | [[File:74|upright 1.0]] #Try hitting debug (the bug icon in the toolbar) | ||
##If all goes well you'll see this dialog: | ##If all goes well you'll see this dialog: | ||
| − | [[File:75|upright 1.0]] #You are now debugging. The debugger works just like | + | [[File:75|upright 1.0]] #You are now debugging. The debugger works just like it does in Eclipse which is basically gdb. ''Except'', if you try to use more than 4 breakpoints, it will crash and complain "resource not available." |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
==Common Problems== | ==Common Problems== | ||
Revision as of 13:02, 27 October 2018
Getting Started
- Have the code downloaded locally from Github. See: ((Github Setup))
- Have MCUXpresso installed and ready to go. See: ((MCUXpresso))
Building
- At this point you should have all of the proper projects imported (if the projects don't seem to be imported, try that again).
- Open the required projects (and close all others)
- The ONLY things you should have open are:
- mbed
- common
- <project_name>
- Close everything else that is open. You will be very sad if there are build error in other projects that make yours fail.
- The ONLY things you should have open are:
- Set all build configurations (mbed, common, <project_name>) to whatever microcontroller is being used (probably LPC1549).
- *Right click on each project > Build Configurations > Set Active > <correct>
+
File:68 #Make sure the linker script location for your project is set correctly (on your project).
- Right click on <project_name> (NOT mbed or common) > Properties > C/C++ Build > Settings
- In "Tool Settings" go to MCU C++ Linker > Managed Linker Script
- Make sure that you have:
- Script name: -+LPC1549.ld+-
- Script path: -+..\..\mbed\libraries\mbed\targets\cmsis\TARGET_NXP\TARGET_LPC15XX\TOOLCHAIN_GCC_CR+-
- (If you can't change these uncheck "Manage Linker Script")
+
File:69 +
- Make sure the compiler language settings are set to the right thing (on mbed, common, and <project_name>)
- Right click on each project > Properties > C/C++ Build Settings > Settings
- In "Tool Settings" go to MCU C++ Compiler > Dialect
- Language standard settings should be:
- For common: -+ISO C++11 (-std=c++11)+-
- For mbed: -+ISO C++11 (-std=c++0x)+-
+
File:70 #Build the project (ctrl+b). This will take a while (1-4 mins), especially when doing a full build for the first time. Future, incremental builds, should be faster as you won't need to recompile mbed (the OS) each time.
- If everything went well, then you now have a compiled binary file that you need to program/debug the microcontroller.
Flashing/Debugging
The way we flash code and debug is the same. Flashing code is just starting a debug session and then ending it right away. The steps to do so are:
- With MCUXpresso closed set up the custom DAP42 debugger (if you're using the large, inefficient LPC-Link2 then you don't have to follow this step)
- *If you're using the small ones (pic coming soon) that say "DL, DC" on them, that's the DAP42
- Navigate to -+[your hard drive root directory/nxp/MCUXpressoIDE_xx.x.x_xxx/ide/bin/Scripts/probetable.csv+-
- Open that file in Notepad or Notepad++ (NOT EXCEL)
- Add this line to the bottom: -+0x1209, 0xDA42, 64, 1, 0, 0, 0, "", 0x0000, -1+- (and a new line after it)
- Open MCUXpresso and build your project
- Create the debug configuration (you'll only do this once per project)
- Select your project (NOT mbed or common, but your project) and open "Debug Configurations" (down arrow next to one of the bug icons)
File:73 ##Double click on C/C++ (NXP Semiconductors) MCU Application to create a build configuration
- Leave Project Name as default
- Under "C/C++ Application", click Browse... and navigate to the project's folder inside the repository. The file will be located in that folder (in the repo) at -+LPC1549\projectname.axf+-
File:74 #Try hitting debug (the bug icon in the toolbar)
- If all goes well you'll see this dialog:
File:75 #You are now debugging. The debugger works just like it does in Eclipse which is basically gdb. Except, if you try to use more than 4 breakpoints, it will crash and complain "resource not available."
Common Problems
Shadows template parm 'int N' and some other build errors that complain about types
You probably didn't set the compiler language correctly. Double check step 5 in Building.
Uncommon Problems
If you have a Lenovo non-ThinkPad device, or maybe something else weird running Windows 10, you might run into the debuggers not working even if you've set up everything correctly. We've only had one team member with this problem so far but happened to them on 2 devices so it's worth mentioning in here. The error text when trying to debug was a popup saying "Socket exception: connection reset" or something similar, and the details would be a whole list of things including Java code locations. This problem is not with the drivers, surprisingly, but with MCUXpresso. Or at least, the fix was to install MCUXpresso 10.0.0 instead of the version just before 10.2. It may work with another version as well but hasn't been tested yet. Also make sure to restart your computer after attempting any changes to MCUXpresso versions and (if you want) driver installs. Another thing that may have helped is forcing Windows to install a nice driver for it using Zadig, a tool which you can run without installation.
Linux Mint (and likely other versions) do not properly configure the permissions (and sometimes device type) of the DAP42 probe. The easiest way to solve this is by adding
||ATTRS{idVendor}=="1209", ATTRS{idProduct}=="da42", ENV{ID_MM_DEVICE_IGNORE}="1", MODE="0666"||
to a udev rule (e.g. I recommend adding it to the file "/etc/udev/rules.d/12-dap42.rules"). REBOOT AFTER ADDING THIS FILE. This issue can be seen as a debugging error with the following message:
||"Server OK but no connection" to probe 1 core 0 (after 3 attempts) - Ee(36)||
Future
- Support program via CAN
Credit
This was made using the original LPCXpresso guide from Derek Chou (of Calsol and ISC) here: https://docs.google.com/document/d/1UbqKGVPCTO-VmLjGza0Km96y2tYtIO1zAWrmcexgvYg/