<commit_before>==Installation
There are a few things that you need to download and install before using MRI:
* Follow the instructions at [[https://github.com/adamgreen/gcc4mbed#quick-start]] to install the latest version of the GCC4MBED project which includes the MRI debug monitor.
* MRI doesn't work if the JTAG debug interface is actively being used on the device.  Any such JTAG usage will need to be disabled before you can use MRI.  What needs to be done will differ depending on your device:
* **mbed 1768:**  Download [[http://mbed.org/media/uploads/simon/mbedmicrocontroller_21164.if]].  Copy this file to your mbed device and then reset it.  This will update the firmware on the interface chip so that its JTAG usage can be disabled when MRI is used.
* **LPCXpresso 1769:**  Cut away the debugger portion of the device along the white line which separates the main LPC1769 device from the JTAG hardware.  You will now need to provide 3.3V of regulated power and a serial connection to UART0 on the LPC1769 portion of the board.
* **Other:**  Remove JTAG debugger connection when using MRI and connect your PC to a UART on the device.  Typically this will be done with something like a [[https://www.sparkfun.com/products/9717|FTDI to USB to serial cable]].


==Getting Started
This section provides steps to setup MRI the first time and use it to debug one of the samples included with the GCC4MBED project.

===Verify serial connection
You will first want to make sure that you can connect to your mbed device using the USB virtual serial port provided by the mbed interface chip.  Follow the steps [[http://mbed.org/handbook/SerialPC|documented here in the mbed handbook]] to get your PC talking to the mbed device.  Once you have this working, take note of the serial port identifier that worked for you (ie: COM3, /dev/ttyACM0, /dev/tty.usbmodem412, etc.)  You will soon need to provide this identifier to the GNU debugger, GDB.

===Build debugger enabled binaries
By default the GCC4MBED project builds binaries of a **Release** type which produces optimized code and doesn't include any debugging support.  This will need to be changed to a **Debug** build type to enable the MRI debugger in the binaries.  This can be done by following these steps:
* Run the BuildShellDebug script found in the root of the GCC4MBED project directory.  This script will start a shell which is configured to create debuggable binaries for your mbed.
* Run "cd samples" from the debug shell.
* Run "make clean all" from the debug shell.

//Using the BuildShell script will revert back to Release.//

===Deploy FileTest sample to your mbed
From within the debug shell, run "cd FileTest" to switch into the directory which contains the sample's sources and binaries.  Make sure that your mbed device is connected to your PC and that you can access its file system from your PC.  On OS X and Linux, you can probably now just run "make deploy" from the debug shell to have the FileTest.bin copied to your mbed device.  On Windows, you will need to issue something like "copy FileTest.bin e:\" to copy the binary to your mbed device but you will need to switch the "e:\" drive designation to match whatever is appropriate for your particular machine.<commit_msg>Nest list items in Getting Started doc.<commit_after>==Installation
There are a few things that you need to download and install before using MRI:
* Follow the instructions at [[https://github.com/adamgreen/gcc4mbed#quick-start]] to install the latest version of the GCC4MBED project which includes the MRI debug monitor.
* MRI doesn't work if the JTAG debug interface is actively being used on the device.  Any such JTAG usage will need to be disabled before you can use MRI.  What needs to be done will differ depending on your device:
** **mbed 1768:**  Download [[http://mbed.org/media/uploads/simon/mbedmicrocontroller_21164.if]].  Copy this file to your mbed device and then reset it.  This will update the firmware on the interface chip so that its JTAG usage can be disabled when MRI is used.
** **LPCXpresso 1769:**  Cut away the debugger portion of the device along the white line which separates the main LPC1769 device from the JTAG hardware.  You will now need to provide 3.3V of regulated power and a serial connection to UART0 on the LPC1769 portion of the board.
** **Other:**  Remove JTAG debugger connection when using MRI and connect your PC to a UART on the device.  Typically this will be done with something like a [[https://www.sparkfun.com/products/9717|FTDI to USB to serial cable]].


==Getting Started
This section provides steps to setup MRI the first time and use it to debug one of the samples included with the GCC4MBED project.

===Verify serial connection
You will first want to make sure that you can connect to your mbed device using the USB virtual serial port provided by the mbed interface chip.  Follow the steps [[http://mbed.org/handbook/SerialPC|documented here in the mbed handbook]] to get your PC talking to the mbed device.  Once you have this working, take note of the serial port identifier that worked for you (ie: COM3, /dev/ttyACM0, /dev/tty.usbmodem412, etc.)  You will soon need to provide this identifier to the GNU debugger, GDB.

===Build debugger enabled binaries
By default the GCC4MBED project builds binaries of a **Release** type which produces optimized code and doesn't include any debugging support.  This will need to be changed to a **Debug** build type to enable the MRI debugger in the binaries.  This can be done by following these steps:
* Run the BuildShellDebug script found in the root of the GCC4MBED project directory.  This script will start a shell which is configured to create debuggable binaries for your mbed.
* Run "cd samples" from the debug shell.
* Run "make clean all" from the debug shell.

//Using the BuildShell script will revert back to Release.//

===Deploy FileTest sample to your mbed
From within the debug shell, run "cd FileTest" to switch into the directory which contains the sample's sources and binaries.  Make sure that your mbed device is connected to your PC and that you can access its file system from your PC.  On OS X and Linux, you can probably now just run "make deploy" from the debug shell to have the FileTest.bin copied to your mbed device.  On Windows, you will need to issue something like "copy FileTest.bin e:\" to copy the binary to your mbed device but you will need to switch the "e:\" drive designation to match whatever is appropriate for your particular machine.
{'fraction_non_alphanumeric': 0.05136829231004433, 'fraction_numerical': 0.011619018498700505, 'mean_word_length': 4.292880258899676, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4018551', 'n_tokens_mistral': 1728, 'n_tokens_neox': 1623, 'n_words': 1041}