Sunday, August 05, 2012

Using WinAVR with Notepad++

Now that you've chosen to drop Arduino and write in pure AVR-GCC for your next project, there are more IDE options to suit your needs. From the nice Programmer's Notepad, included in the WinAVR installation, to the official supercharged AVRStudio. And the list is endless...

For the last couple of years, my personal preference for an advanced text editor, is, by far, the excellent Notepad++. I am a big fan of its customizable color themes and syntax highlighting, lots of editing options (like clickable links) and plugin support. Notepad++ is of course completely free and open source.


It was a tempting task to integrate Notepad++ with the WinAVR framework, exactly as done with Programmer's Notepad. So, let's get started, it will take a couple of minutes :

  • After installing WinAVR and Notepad++ (either in executable or portable form), choose your favorite color theme in Notepad++ from Settings → Style Configurator (I prefer Obsidian). You can also check these nice Raster Fonts by Cylog.org.
  • In Style Configurator, go to the C++ language set, and in TYPE WORD add some user defined keywords such as : uint8_t, uint16_t, uint32_t, int8_t, int16_t, int32_t that are AVR-GCC specific (if you find anything else, please leave a comment !).
  • Go to Plugins → Plugin Manager → Show Plugin Manager and install NppExec and, optionally, Explorer (really helpful to open files). Restart Notepad++.
  • Go to Plugins NppExec Execute (or just F6) and add these three new scripts, saving them as 'WinAVR Clean', 'WinAVR Compile' and 'WinAVR Program' respectively :

  • Now that the scripts are set, select Plugins → NppExec → Show Console Dialog and dock it on the right of your workspace.
  • The customization part is next. Go to Plugins → NppExec → Advanced Options and check "Place to the Macros Submenu", followed by adding the three scripts using "Add/Modify". When you restart Notepad++, these three new commands will be placed inside the "Macro" menu.

  • And a final touch : in order to highlight the words 'error' and 'warning' in the console output window just go to Plugins → NppExec → Console Filters and put *error:* and *warning:* in the highlight mask list : 

Done !!!
You are now ready to enjoy your new Notepad++ based WinAVR environment !



UPDATE : Even more console filters ! Check :


12 comments:

  1. How you obtain a WinAVR up to date, with the today's AVR-GCC, to use the latest Mega and tiny parts?
    Thank you

    ReplyDelete
  2. here : http://sourceforge.net/projects/winavr/files/WinAVR/

    download and install, preferably to C:\WinAVR

    ReplyDelete
  3. Anonymous, you can grab MHV AVR Tools, which provides a current AVR toolchain for Windows, Linux & OSX: http://www.makehackvoid.com/project/mhvavrtools

    It includes GCC 4.7.1 which has a whole lot of cool including link time optimisation and named enumerations.

    ReplyDelete
  4. Nice tut, thanx!
    Can you set up command to run Make File program/GUI?
    I tried but I failed to set up NppExec to run wish84.exe with mfile.tcl param. (ex: C:\WinAVR\bin\wish84.exe and parameter C:\WinAVR\mfile\mfile.tcl)
    I managed to set up PN to work, but not Npp.

    PS. Sorry for my bad English

    ReplyDelete
  5. How change color style console? I am changing Settings → Style Configurator but console style not changing

    ReplyDelete
    Replies
    1. You can change the console colors from Plugins -> NppExec -> Advanced Options. Section [Console] options TextColorNormal and BackgroungColor.

      Delete
  6. Hello!

    I've done changes in NPP as described, but how can I tell WinAVR to use NPP as a default editor? - does not work for me.


    Is this thing a software version related item (AVR studio, WinAVR, NPP) to get them all combined?

    ReplyDelete
  7. Olá amigo, eu fiz as alterações e ficou muito bom. Muito obrigado por divulgar.

    ReplyDelete
  8. Thanks a lot VPAPanik for your tutorial! I really recommend using Notepad++ as a generic editor for all programming projects on Windows, and your tutorial makes it easier for newcomers to experience it :-)

    If I could add anything to it, I would stress out the fact that it is very important to have your PATH System Variable set up correctly, so that the tools "make" and "avr-gcc" will be reachable once you compile your program.

    In my case, I used the following:

    - "make.exe": found here: http://gnuwin32.sourceforge.net/packages/make.htm
    Update your PATH system variable to add the directory where you installed the GNU Win32 tools, e.g. C:\Program Files (x86)\GnuWin32\bin
    The file "make.exe" should be there. To test that this operation worked, execute cmd.exe and just type "make" (of course without the ""). If it see the message "make: *** No targets...", the operation succeeded and you can now call "make" from the console in Notepad++.

    - avr-gcc: this is the compiler used for all AVR programs. In general, this compiler is different for 8-bit Atmel MCUs and for 32-bit Atmel MCUs (look it up for your MCU). All simple projects usually embed 8-bit microcontrollers such as the ATmega328 like on the Arduinos, so you should be good to go.
    Same thing here: to let your environment know where to find "avr-gcc", you can refer to vpapanik's comment above, download WinAVR and find the file "avr-gcc.exe". Then, you add the directory to the PATH system variable and click OK. When opening a NEW command line window (cmd.exe), type "avr-gcc" to verify that the system knows where to find avr-gcc.

    If you see a message such as "avr-gcc: fatal error...", it means that it could find avr-gcc and you are now ready to compile with Notepad++! :-)

    ReplyDelete
  9. I hope this data remains on the interwebs FOREVER! Thank you!

    ReplyDelete
  10. How did you get those two windows on the left side if your notepad++ screen?

    ReplyDelete