Nut/OS on the AT91SAM9260 EK
This document describes, how to configure and build Nut/OS for the AT91SAM9260 Evaluation Kit on a Windows PC.
Requirements
In the first place we need the target board. As far as we know, Atmel's AT91SAM9260 evaluation kit is the only one currently available.
Software development can be done on a Windows or Linux system. However, at the time of this writing, only Windows had been fully tested for this CPU.
If you haven't installed Nut/OS yet, follow the instructions on this page:
Installing Nut/OS on Windows.
In case you still want to try Linux, read
Nut/OS Development on Debian.
This will be helpful, even if using other Linux/UNIX distributions
The SAM9260 MCU contains a bootloader (called SAM-BA) in internal ROM. Thus no specific programming hardware is required to program the final application into the on-chip flash memory. We used the SAM-BA v2.4 utility, which can be downloaded free of charge from Atmel's Website.
Nut/OS Configuration
Assuming that you successfully installed Nut/OS, start the Nut/OS Configurator now via the Windows Start Menu, if it is not yet running. On Linux, simply enter nutconf on the shell prompt.
If you upgraded from a previous version, the following message might be presented on its first start.
You may chose Yes and let the Configurator adapt the new installation path or select No and correct the path later.
The Configurator typically starts with a file selection dialog, from which you can choose a pre-configuration for a specific board. We use the one for the AT91SAM9260-EK.
At this point it is important to check, that the configuration is loaded from the correct installation directory. The default for Nut/OS 4.4.0 is
c:\ethernut-4.4.0\nut\conf\
After loading the selected configuration, a component tree and a log window appear in the Configurator's main window. Check the log window to make sure, that the repository and the configuration file had been loaded from the current installation directory. If not correct, you may reload the configuration later. For now, just continue.
Nut/OS is configured in two steps. First some Configurator settings need to be specified. These settings are stored in the Windows repository. To change these settings, select Edit -> Settings... from the main menu.
A tabbed dialog with four pages appears.
On the first page, titled Repository you can specify the path of the repository file. The repository is a set of scripts, which lists all Nut/OS modules and their optional settings. You do not need to know anything about it unless you want to implement new drivers etc.
Remember the log in the main window? If the wrong repository had been loaded, you can correct this here. Always use Unix like slashes to separate directory paths, not Windows like backslashes.
The settings on the second page specify the locations of the Nut/OS source code, header files, build directory and the final destination of the newly build libraries. It is recommended to stick with the defaults shown.
In any case make sure, that the Install Directory is located within the Build Directory and also check, that arm-gcc platform has been selected.
On the third page the build environment has to be specified. In contrary to the rule stated above, backslashes can be used here. It is very important, that the Nut/OS tools directory comes first, followed by the path to the YAGARTO compiler binaries.
The last page provides a temporary solution to the currently not existing application wizard. The Configurator will simply copy the Nut/OS samples to the directory specified on this page.
The programmer selection can be ignored. We will use the SAM-BA tool instead.
Click OK to confirm all settings and return to the main window.
Important:
If you changed any of the paths, specifically the one of the repository, you
should now re-load the configuration file by selecting File -> Open in
the main menu. This way the correct repository will be loaded.
Building Nut/OS
Before starting the build, make sure, that the correct linker script at91sam9260_ram and the correct MCU are selected.
Start the build by selecting Build -> Build Nut/OS in the main menu or click on the tree symbol in the toolbar.
In a first step the build directory will be prepared. Check the displayed paths again and click OK.
In a second step the Configurator will build the Nut/OS libraries. Click OK to start this build. It may take some time to finish.
Check the output in the log window. make install should terminate successfully.
Building A Sample Application
Nut/OS comes with a number of sample applications. A quite simple one is called events, which demonstrates how to implement mutual exclusion with Nut/OS event queues.
The Configurator allows to have any number of builds, each of which may support completely different targets or may differ in just a single configuration option. Each build may have one or more associated application directories. The easiest way to create such a directory is to let the Configurator create one.
Selecting Build -> Create Sample Directory from the main menu will instruct the Configurator to copy the sample applications into a new or existing application directory and associate it to the current build tree.
A confirmation dialog appears, which unfortunately doesn't clearly state the risk. If you already created this directory before and modified any of the samples, your changes will get lost. If unsure, click Abort and specify another application directory in the Configurator settings. Otherwise click OK.
Finally terminate the Configurator. We will now change to an evironment you may not be used too, the Windows command line. Don't worry, nothing really complicated going to happen.
Open a command line window, for example by executing cmd.exe from the Windows Start Menu.
Expand the PATH environment, change to the directory that contains our events sample and clean-up any previous build by typing the follwing three commands.
SET PATH=C:\ethernut-4.4.0\nut\tools\win32;C:\Programme\yagarto\bin;%PATH% cd C:\ethernut-4.4.0\nutapp-sam9260-gcc\events make clean
Now type
make installto build the application and link it to the associated Nut/OS build.
As a final result, two files will be created, which contain the binary code of our sample application. One is in Intel hex format (events.hex) while the second one is a pure binary image. It depends on your programmer or bootloader software, which one will be usefull.
NOTE: The last step may fail, because the directory nut\bin\arm9 doesn't exist. Creating this directory manually will fix this problem.
Running The Sample Application
Please refer to Atmel's Website for a complete documentation about how to upload a binary to the AT91SAM9260 target board. Make yourself familiar with the SAM-BA bootloader.
Connect the target board's DBGU port with the PC via a serial cable and the USB type B connector (J19) of the target board with the PC's USB port. Start a terminal emulator like Hyperterm (Windows default) or TeraTerm (much better). Serial port settings are 115200,8,n,1.
Start the SAM-BA utility, select the AT91SAM9260-EK board and click on USB connection.
The main window of the SAM-BA utility will appear. Select the SDRAM tab and run the script Enable SDRAM on EBI by pressing the Execute button. This will enable the SDRAM chips on the target board.
We will now load our application binary into the external SDRAM. Press the Browse button for Send File Name and navigate to our Nut/OS application sample directory.
Double click on the file events.bin. Back on the SAM-BA main window, click on Send File.
The binary image will be uploaded to the SDRAM on the target board.
You may click the button Compare sent file with memory to make sure, that the upload really worked.
In order to start the uploaded code, enter
go 0x20000000in the script window. The SAM-BA utility will terminate.
You should now see some output in the terminal emulator's output window.
Good luck,
Harald Kipp
Castrop-Rauxel, 5th of September 2006