| You are not Logged In! |
Public:Building and Debugging Code
Getting Started
- Have the code downloaded locally from Github. See: ((Github))
- Have MCUXpresso installed and ready to go. See: ((MCUXpresso))
Creating a new MCUXpresso Project
Generally there is one project per board. To do so:
- You should use the appropriate skeleton project for your chip as a starting point.
- For ISC made boards that should be the
mbed1549_skeleton(Argo) ormbed15xx_skeleton(Brizo) - For older boards from CalSol you may need the
mbed11c14_skeleton
- For ISC made boards that should be the
- In the project explorer right click on the appropriate skeleton and select "Copy"
- Right click in the Project Explorer and "Paste"
- At the "Copy Project" Dialog, name your project. Ensure this is unique, otherwise MCUXpresso won't let others import it (and we can't tell projects apart easily!)
- Uncheck "Use Default Location"
- Click "Browse" to chose the folder and place it appropriately within the correct repo
(for b-fw this needs to be the folder for the chip you are using)there are not folders for each chip anymore. - Create a new folder in the repo for the project. The name does not matter but it is generally best to make it the same as the project name
- Select the new folder and press "ok"
- Click "Browse" to chose the folder and place it appropriately within the correct repo
Done! You can now work on your new project!
Building
- At this point you should have all of the projects imported into your workspace
- 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
- *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: chipname.ld such as: -+LPC1549.ld+- (Argo-FW) or -+LPC15x8+- (B-FW)
- Argo FW Script path: -+..\..\mbed\libraries\mbed\targets\cmsis\TARGET_NXP\TARGET_LPC15XX\TOOLCHAIN_GCC_CR+-
- Breeze FW Script Path: -+"../../../mbed/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC15XX/TOOLCHAIN_GCC_CR"+-
- (If you can't change these uncheck "Manage Linker Script")
- 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 as you probably won't be changing it.
- If everything went well, then you now have a compiled binary file (.axf) that you need to program/debug the microcontroller.
(Haven't figured out how to move the pictures to places among lines like the old wiki page Yes, I just figured that out)
Flashing/Debugging
The way we flash code and debug is the same for simplicity. Flashing code will just be starting a debug session and then ending it right away. The steps to do so are:
Setting up your projects & MCUXpresso settings
- With MCUXpresso closed set up MCUXpresso to be able to see the 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 that that's the DAP42
- 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+-
- 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)
- Save and close the file
- Open MCUXpresso and build your project
- Create the debug configuration (you'll only do this once per project)
- Right click on your project (NOT mbed or common, but your project) > Debug As > Debug Configurations... (or triangle next to green bug)
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 -+LPC15xx\projectname.axf+-
File:74 ++
- Try clicking 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 probably crash and complain "resource not available."
- 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)
- Don't leave an unpowered DAP42 plugged into your board as it will pull the ISP/RESET pins which will prevent your board from running
Debugging after going through setup for a project
- Build your project without errors (if there are errors it won't write the -+<project_name>.axf+- file)
- Click on the bug icon: the green one, but the purple one will probably also work so don't worry too much)
- That's it. It should load the configuration, find the debugger, upload the code, and start the session without any further input from you
- 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)
Notes and 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.
- Did you get your code to upload, but now it's not letting you upload code? Make sure that you've ended any previous debugging sessions before trying to upload code again (you can either right click on an instance and terminate it or terminate all from the top menu in MCUXpresso). Sometimes, if you unplug debuggers with active debug sessions MCUXpresso may get very confused and not allow you to end active debug sessions. You will need to restart MCUXpresso (or sometimes your whole computer) to fix that.
- Are you getting an error saying cannot find -lcommon or similar? Make sure that the active build configuration for common and mbed for the same microcontroller as your project and that they have the correct dialect selected.
- Does it say cannot find -lcommon -lmbed close MCUExpresso, and delete .cproject and .project files in common and mbed then redo the setup process for these files.
- Is the Debugger crashing on upload, with red messages saying that GDB crashed and can't be relied on? Try opening the breakpoints tab and right click "delete all" to make sure there aren't random ones saved. Also setting too many breakpoints can crash the debugger too.
- Is your board hard-faulting on debug? Check the .cproject file and try reverting to an earlier version if things are really ugly. Don’t sink 6 hours into attempting to fix the versioning by committing more changes like we did.
- Is the debugger not working and the red LED on it is lit up? It’s probably stuck in some weird state. Unplugging it and plugging it back in will usually fix it.
- Is the debugger really really not letting you upload code, even though it appears to be okay? You may have accidentally disabled the SWD/JTAG pins on the microcontroller, blocking communications. Try holding down PGRM and RESET on your board to force it to go into the on-chip bootloader, which is always able to talk to the debugger.
- The debugger does not provide power to your board. Make sure it’s powered on…
- If you need to change the processor (LPC1549 vs LPC11C14), you can do so by right clicking the project and selecting C++ Build > MCU Settings
- *Note that because of the way that the mbed libraries map the interrupt vector table to let you dynamically set interrupt handlers, there are 512 bytes of RAM that are dedicated to the table
- *When you change the processor, you may need to adjust the RAM region to start offset by 512 bytes (0x10000200 instead of 0x10000000) and to be 512 bytes smaller (0x1E00 instead of 0x2000) for the LPC11Cx4. Otherwise the linker may attempt to place variables in the space reserved for the interrupt table and you may see variables getting corrupted.
- The LPCXpresso board is a combination of the LPC-LINK debugger (which you want to use to program your board) and a target board containing a microcontroller. To use the LPC-LINK to program your board, you need to desolder the traces between the two rows of nine pins in the middle of the LPCXpresso board.
- * For extra mechanical fun, you can also dice the board into two pieces, where the cut point is the line of traces that you desoldered.
- If all else fails, try restarting LPCXpresso / plugging in / unplugging the board + debugger board, etc. Actually, this is usually a good place to start.
Run into other issues not found here? Add to this list to help others!
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

