Getting Started with nanoFramework – Flash the CLR (Part 2)


I’m assuming that you have built the CLR and are now ready with nanoBooter and nanoCLR files to be flashed to the MCU (see part 1 of this blog series).

If you are not too keen on building the CLR, you can download pre-built images for officially supported boardsWhatever be the case, you should have the following files with you (either via a build process or you downloaded from the Github):

  1. nanoBooter.hex
  2. nanoCLR.hex

I’m listing down only the hex file formats (as I will use only those ones).

What will you need

To flash the images on the MCU, you will need the following:

  1. An appropriate board that matches the image you built or downloaded. I have successfully used STM32 NUCLEO board with STM32F401RE MCU
  2. A USB-A to mini B cable. STM32 boards work with mini-USB ports. This is how mini-B port looks like
  3. Download and install the ST-Link software utility from here. I will explain more later.

Note on flashing code

Any MCU will provide some way for you to burn your code files in the MCU flash. In STM32 (or any other advanced MCU), there are many ways to do this and the more you read, the more confusing it becomes. For beginners, the STM32 NUCLEO boards simplifies this process a lot. The NUCLEO board comes with an additional hardware built-in which simplifies the process of code flashing for you. Look at the picture below:


The top part, shown with a red rectangle, contains a USB micro B socket. It also contains all the hardware required to flash your code in the main MCU. The main MCU is present in the bottom part denoted by the blue rectangle. With this, you do not need to buy a separate hardware for flashing (a common occurrence). Once you install the ST-Link utility, it installs the right drivers and gives you an interface to flash your files to the MCU.

Note: You can flash the code even without the special ST-Link hardware (under red rectangle), but that is a topic for another day.

Flash the code

You need to flash two things to the MCU – first, the nanoBooter.hex and then, the nanoCLR.hex. After you flash the nanoBooter.hex, you should see the on-board green LED blinking slowly. After you flash nanoCLR.hex, the LED blink should stop. That is how you verify if the flashing process was fine (at the time of this writing).

After you install the ST-Link utility, connect the Nucleo board with your PC and open the ST-Link utility (see below):


If all goes well, when you click on the “Connect” button, you should see the MCU details (again, I’m using STM32F401RE).

Now, follow the steps below:

  1. Click on “Full chip erase” (reset it completely)
  2. Click on “Program and Verify”.This will open an “File Dialog”. Select the nanoBooter.hex file. In the dialog that opens after that, ensure you have selected “Reset after programming” checkbox. Click “Start”. If the flashing is successful, you should see the following message in the ST Link utility console:

Flash memory erased.
[nanoBooter.hex] opened successfully.
Address Ranges [0x08000000 0x08004E3E] [0x08004E40 0x080053F4]
Memory programmed in 1s and 235ms.

Notice carefully, the green LED on the board should be blinking at about 1 Hz. 

The next step is to flash the nanoCLR. Again, click on “Program and Verify”. Select nanoCLR.hex. When the dialog box opens after you select the file, once again ensure you have selected “Reset after programming”. Click “Start”. If the flashing is successful, you should see the following message in the ST Link utility console:

[nanoCLR.hex] opened successfully.
Address Ranges [0x08008000 0x080081E4] [0x080081F0 0x080359F6] [0x080359F8 0x0803D19C]
Memory programmed in 7s and 15ms.

Notice carefully, the green LED on the board should no longer be blinking.

To confirm if the files were flashed correctly, click on the toolbar button labeled  “Print via SWO viewer”. The dialog box it opens, change the frequency to the one used by your board (I used STM32F401RE Nucleo board. The system clock is 84MHz). Click on “Start”. You should see the following log (if you do not see, then press the reset button once):


nanoCLR (Build

nanoCLR running @ ST_NUCLEO64_F401RE_NF built with ChibiOS v18.2.0

Created EE.
Started Hardware.
Create TS.
Loading Deployment Assemblies.

Total: (0 RAM – 0 ROM – 0 METADATA)

AssemblyRef = 0 bytes ( 0 elements)
TypeRef = 0 bytes ( 0 elements)
FieldRef = 0 bytes ( 0 elements)
MethodRef = 0 bytes ( 0 elements)
TypeDef = 0 bytes ( 0 elements)
FieldDef = 0 bytes ( 0 elements)
MethodDef = 0 bytes ( 0 elements)
StaticFields = 0 bytes ( 0 elements)

DebuggingInfo = 0 bytes

Attributes = 0 bytes ( 0 elements)
TypeSpec = 0 bytes ( 0 elements)
Resources Files = 0 bytes ( 0 elements)
Resources = 0 bytes ( 0 elements)
Resources Data = 0 bytes
Strings = 0 bytes
Signatures = 0 bytes
ByteCode = 0 bytes

Error: a2000000
Waiting for debug commands…

That’s it. You are now ready to open Visual Studio and begin coding !




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s