You are not Logged In!

Difference between revisions of "Public:Building and Debugging Code"

From Illini Solar Car Wiki
Jump to navigation Jump to search
imported>Jonathan
imported>Jonathan

Revision as of 13:45, 9 February 2019


Getting Started

  • Have the code downloaded locally from Github. See: ((Github Setup))
  • Have MCUXpresso installed and ready to go. See: ((MCUXpresso))

Building

File:67

  1. At this point you should have all of the proper projects imported (if the projects don't seem to be imported, try that again).
  2. Open the required projects (and close all others)
    1. The ONLY things you should have open are:
      1. mbed
      2. common
      3. <project_name>
    2. Close everything else that is open. You will be very sad if there are build error in other projects that make yours fail.
  3. 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 +

  1. Make sure the linker script location for your project is set correctly (on your project).
    1. Right click on <project_name> (NOT mbed or common) > Properties > C/C++ Build > Settings
    2. In "Tool Settings" go to MCU C++ Linker > Managed Linker Script
    3. Make sure that you have:
      1. Script name: -+LPC1549.ld+-
      2. Script path: -+..\..\mbed\libraries\mbed\targets\cmsis\TARGET_NXP\TARGET_LPC15XX\TOOLCHAIN_GCC_CR+-
      3. (If you can't change these uncheck "Manage Linker Script")

File:69

  1. Make sure the compiler language settings are set to the right thing (on mbed, common, and <project_name>)
    1. Right click on each project > Properties > C/C++ Build Settings > Settings
    2. In "Tool Settings" go to MCU C++ Compiler > Dialect
    3. Language standard settings should be:
      1. For common: -+ISO C++11 (-std=c++11)+-
      2. For mbed: -+ISO C++11 (-std=c++0x)+-

File:70 +

  1. 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.
  2. If everything went well, then you now have a compiled binary file that you need to program/debug the microcontroller.

File:71

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:

Setting up your projects & MCUXpresso settings

  1. 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
    1. Navigate to
  • **Windows: -+[your hard drive root directory/nxp/MCUXpressoIDE_xx.x.x_xxx/ide/bin/Scripts/probetable.csv+-
  • **Mac: Applications then -+MCUXpressoIDE_xx.x.x_xxx/ide/bin/Scripts/probetable.csv+-
    1. Open that file in Notepad or Notepad++ (NOT EXCEL)
    2. Add this line to the bottom: -+0x1209, 0xDA42, 64, 1, 0, 0, 0, "", 0x0000, -1+- (and a new line after it)
  1. Open MCUXpresso and build your project
  2. Create the debug configuration (you'll only do this once per project)
    1. Right click on your project (NOT mbed or common, but your project) > Debug As > Debug Configurations... (or triangle next to green bug)

File:73 ++

    1. Double click on C/C++ (NXP Semiconductors) MCU Application to create a build configuration
    2. Leave Project Name as default
    3. 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 ++

  1. Try clicking Debug (the bug icon in the toolbar)
    1. If all goes well you'll see this dialog:

File:75 ++

  1. 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."
  2. Before disconnecting the debugger from board, click the "Terminate Debug Session" button (red square) or "Terminate All Debug Sessions" (red square overlapping another red square)
  3. We recommended physically disconnecting the debugger from the board after you're done debugging/flashing because otherwise some things don't behave as expected (...ask the CompE's)

Debugging after going through setup for a project

  1. Build your project without errors (if there are errors it won't write the -+<project_name>.axf+- file)
  2. Click on the bug icon: the green one, but the purple one will probably also work so don't worry too much)
  3. That's it. It should load the configuration, find the debugger, upload the code, and start the session without any further input from you
  4. Before disconnecting the debugger from board, click the "Terminate Debug Session" button (red square) or "Terminate All Debug Sessions" (red square overlapping another red square)
  5. We recommended physically disconnecting the debugger from the board after you're done debugging/flashing because otherwise some things don't behave as expected (...ask the CompE's)

Common Problems

File:72

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. The error text when trying to debug was a popup saying -+Socket exception: connection reset+- or something similar, and the details were a whole list of things including Java code locations. This problem is probably not with the drivers. The easiest fix was to install MCUXpresso 10.1.0 instead of 10.1.1. It may work with other earlier versions as well but hasn't been tested yet. Also make sure to restart your computer after attempting any changes to MCUXpresso versions and driver installs.

Linux Mint (and likely other versions) do not properly configure the permissions (and sometimes device type) of the DAP42 probe.

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)+-

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.

Future

  • Support program via CAN

 

Credit

This was made using the original LPCXpresso guide from Derek Chou (of Calsol and ISC) here: Google Docs Link