README.txt 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. README
  2. ^^^^^^
  3. This is the README file for the NuttX port to the Atmel AVR32DEV1 board.
  4. Contents
  5. ^^^^^^^^
  6. * GPIO Pin Configuration
  7. * Serial Connection
  8. * Toolchains
  9. * Development Environment
  10. * GNU Toolchains
  11. * IDEs
  12. - Makefile Build
  13. - Native Build
  14. * AVR32 Bootloader
  15. - Boot Sequence
  16. - Link Address
  17. - Entering the ISP
  18. - BatchISP
  19. * Reset
  20. * Make Tip
  21. * AVR32DEV1 Configuration Options
  22. * Configurations
  23. GPIO Pin Configuration
  24. ^^^^^^^^^^^^^^^^^^^^^^
  25. The only GPIO pin usage is for LEDs (2) and Buttons (2):
  26. PIN 13 PA7 LED1
  27. PIN 14 PA8 LED2
  28. PIN 24 PB2 KEY1
  29. PIN 25 PB3 KEY2
  30. (See configs/avr32dev1/src/avr32dev1.h). And also for
  31. crystals (4), JTAG (1), and USB (1):
  32. PIN 30 PA11 XIN32
  33. PIN 31 PA12 XOUT32
  34. PIN 35 PA15 EVTO (JTAG)
  35. PIN 39 PA18 X1IN
  36. PIN 40 PA19 X1OUT
  37. PIN 61 PA26 ID (USB)
  38. All GPIO pins are brought out through connectors J1 (PINS 33-64)
  39. and J2 (PINS 1-32).
  40. NOTE: There seems to be some difference in labeling for OSC0 and
  41. OSC1 between MCUZone.com and Atmel:
  42. Oscillator pinout
  43. -------------------------- --------------------
  44. QFP48 QFP64 Pad Oscillator AVR32DEV1
  45. PIN PIN PIN LABEL
  46. ----- ----- ---- --------- --------------------
  47. 30 39 PA18 XIN0 X1IN (12MHz)
  48. 41 PA28 XIN1 PA28 (no crystal)
  49. 22 30 PA11 XIN32 XIN32 (32KHz)
  50. 31 40 PA19 XOUT0 X1OUT (12Mhz)
  51. 42 PA29 XOUT1 PA29 (no crystal)
  52. 23 31 PA12 XOUT32 XOUT32 (32 Khz)
  53. ----- ----- ---- --------- --------------------
  54. NOTE 1: These crystal inputs/outputs are analog signals and my
  55. assumption is that they need no pin multiplexing setting to
  56. enable them for the external crystal function.
  57. NOTE 2: There is no support for OSC1.
  58. NOTE 3: There are solder pads for the 32KHz OSC32, but the
  59. crystal is not populated on my board. Therefore, the RTC will
  60. have to run from the (uncalibrated) RCOSC.
  61. Serial Connection
  62. ^^^^^^^^^^^^^^^^^
  63. USART1 is the default USART1 used in the configuration files to
  64. provide a serial console (of course, that can be easily changed
  65. by editting the configuration file). The AVR32DEV1 board has no
  66. RS-232 drivers or connectors on board. I use an off-board MAX232
  67. module that I got on eBay (search for MAX232 if you want to find
  68. one). I connect the MAX232 board as follows:
  69. In configs/avr32dev/include/board.h:
  70. #define PINMUX_USART1_RXD PINMUX_USART1_RXD_1
  71. #define PINMUX_USART1_TXD PINMUX_USART1_TXD_1
  72. In arch/avr/src/at32uc3/at32uc3b_pinmux.h:
  73. #define PINMUX_USART1_RXD_1 (GPIO_PERIPH | GPIO_FUNCD | GPIO_PORTA | 17)
  74. #define PINMUX_USART1_TXD_1 (GPIO_PERIPH | GPIO_FUNCA | GPIO_PORTA | 23)
  75. PA17 and PA23 are avaiable from the AVR32DEV1:
  76. FUNC GPIO PIN Header 16X2 (J1) MX232 Board
  77. ---- ----- ----- ---------------- ------------
  78. RXD PA17 PIN37 Pin 5 PIN4 RXD (5V TTL/CMOS)
  79. TXD PA23 PIN47 Pin 15 PIN3 TXD (5V TTL/CMOS)
  80. PIN2 GND
  81. PIN1 VCC (5V)
  82. Voltage on GPIO Pins with respect to Ground for TCK, RESET_N, PA03-PA08,
  83. PA11-PA12, PA18-PA19, PA28-PA31............................-0.3 to 3.6V
  84. Other Pins ............................................... -0.3 to 5.5V
  85. I get the 5V from another USB port (using the 5V power cable that normally
  86. provides the extra current needed by my USB IDE drive).
  87. Development Environment
  88. ^^^^^^^^^^^^^^^^^^^^^^^
  89. Linux, Mac OS X or Cygwin on Windows can be used for the development environment.
  90. The source has been built only using the GNU toolchain (see below). Other
  91. toolchains will likely cause problems. Testing was performed using the Cygwin
  92. environment.
  93. GNU Toolchains
  94. ^^^^^^^^^^^^^^
  95. Atmel Toolchain:
  96. The build logic in these directories assume that you are using the GNU
  97. toolchain with the Atmel patches. The patch file, pre-patched tool
  98. sources,and pre-built binaries are available from the Atmel website.
  99. CONFIG_AVR32_AVRTOOLSW=y # Use the windows version
  100. CONFIG_AVR32_AVRTOOLSL=y # Ue the Linux version
  101. NOTE: The NuttX builtroot cannot be used to build the AVR32 toolchain.
  102. This is because the Atmel patches that add support for the AVR32 are not
  103. included in the NuttX buildroot.
  104. WinAVR:
  105. Another option for use under Windows is WinAVR:
  106. http://sourceforge.net/projects/winavr/files/. WinAVR includes the
  107. AVR32 toolchain as well as the AVR toolchain and various support
  108. libraries and header files.
  109. AVR32 Toolchain Builder:
  110. A third option is to build the toolchain yourself. For OS X and Linux systems,
  111. this Makefile will build a complete gcc-4.4.3 toolchain:
  112. https://github.com/jsnyder/avr32-toolchain
  113. By default the toolchain installs into ${HOME}/avr-32-tools-<somedate> and
  114. the bin subdirectory must be added to your path before compiling.
  115. IDEs
  116. ^^^^
  117. NuttX is built using command-line make. It can be used with an IDE, but some
  118. effort will be required to create the project.
  119. Makefile Build
  120. --------------
  121. Under Eclipse, it is pretty easy to set up an "empty makefile project" and
  122. simply use the NuttX makefile to build the system. That is almost for free
  123. under Linux. Under Windows, you will need to set up the "Cygwin GCC" empty
  124. makefile project in order to work with Windows (Google for "Eclipse Cygwin" -
  125. there is a lot of help on the internet).
  126. Native Build
  127. ------------
  128. Here are a few tips before you start that effort:
  129. 1) Select the toolchain that you will be using in your .config file
  130. 2) Start the NuttX build at least one time from the Cygwin command line
  131. before trying to create your project. This is necessary to create
  132. certain auto-generated files and directories that will be needed.
  133. 3) Set up include pathes: You will need include/, arch/avr/src/at32uc3,
  134. arch/avr/src/common, arch/arm/src/avr, and sched/.
  135. 4) All assembly files need to have the definition option -D __ASSEMBLY__
  136. on the command line.
  137. Startup files will probably cause you some headaches. The NuttX startup file
  138. is arch/avr/src/avr3/up_nommuhead.S.
  139. AVR32 Bootloader
  140. ^^^^^^^^^^^^^^^^
  141. Boot Sequence
  142. -------------
  143. "An AVR UC3 part having the bootloader programmed resets as any other
  144. part at 80000000h. Bootloader execution begins here. The bootloader
  145. first performs the boot process to know whether it should start the
  146. USB DFU ISP or the application. If the tested conditions indicate
  147. that the USB DFU ISP should be started, then execution continues in
  148. the bootloader area, i.e. between 80000000h and 80002000h, else
  149. the bootloader launches the application at 80002000h."
  150. Link Address
  151. ------------
  152. The linker scripts (ld.script) assume that you are using the DFU
  153. bootloader. The bootloader resides at 0x8000:0000 and so the ld.script
  154. files link the application to execute after the bootloader at
  155. 0x8000:2000. To link so that NuttX boots directly without using the
  156. bootloader, change the flash definition from:
  157. flash (rxai!w) : ORIGIN = 0x80002000, LENGTH = 256K - 8K
  158. to:
  159. flash (rxai!w) : ORIGIN = 0x80000000, LENGTH = 256K
  160. Or to use the MSC bootloader:
  161. flash (rxai!w) : ORIGIN = 0x80008000, LENGTH = 256K - 32K
  162. Entering the ISP
  163. ----------------
  164. In order to use the USB port to download the FLASH(ISP), you need to
  165. use the S3(PA13) to make CPU return to boot status. In this mode, the
  166. on chip bootloader will run, making the ISP possible.
  167. BatchISP
  168. --------
  169. Unlike other Atmel parts, the AVR32 will not work with the FLIP GUI
  170. program. Instead, you must use the command-line loader call BatchISP.
  171. If need to download FLIP from the atmel.com website, install the USB
  172. driver in the FLIP usb directory. Then in the bin directory where
  173. you installed FLIP, you will also find batchisp.exe.
  174. NOTE: You will need to set the PATH environment variable to include the
  175. path to the BatchISP bin directory.
  176. Notes from "AVR32 UC3 USB DFU Bootloader" (doc7745.pdf)
  177. "To launch BatchISP, open a command prompt. Windows or Cygwin command
  178. prompt can be used provided that the bin folder of the FLIP installation
  179. directory is in the PATH (Windows’ or Cygwin’s) environment variable.
  180. When running BatchISP on AT32UC3xxxxx, the target part has to be specified
  181. with -device at32uc3xxxxx and the communication port with -hardware usb.
  182. Commands can then be placed after -operation. These commands are executed
  183. in order. BatchISP options can be placed in a text file invoked using
  184. -cmdfile rather than on the command line.
  185. "BatchISP works with an internal ISP buffer per target memory. These ISP
  186. buffers can be filled from several sources. All target operations (program,
  187. verify, read) are performed using these buffers."
  188. The following BatchISP command line will erase FLASH, write the nuttx binary
  189. into FLASH, and reset the AVR32. This command line is available in the
  190. script config/avr32dev1/tools/doisp.sh:
  191. batchisp -device at32uc3b0256 -hardware usb -operation erase f memory flash \
  192. blankcheck loadbuffer nuttx.elf program verify start reset 0
  193. "BatchISP main commands available on AT32UC3xxxxx are:
  194. - ASSERT { PASS | FAIL } changes the displayed results of the following
  195. operations according to the expected behavior.
  196. - ONFAIL { ASK | ABORT | RETRY | IGNORE } changes the interactive behavior
  197. of BatchISP in case of failure.
  198. - WAIT <Nsec> inserts a pause between two ISP operations.
  199. - ECHO <comment> displays a message.
  200. - ERASE F erases internal flash contents, except the bootloader.
  201. - MEMORY { FLASH | SECURITY | CONFIGURATION | BOOTLOADER | SIGNATURE | USER }
  202. selects a target memory on which to apply the following operations.
  203. - ADDRANGE <addrMin> <addrMax> selects in the current target memory an
  204. address range on which to apply the following operations.
  205. - BLANKCHECK checks that the selected address range is erased.
  206. - FILLBUFFER <data> fills the ISP buffer with a byte value.
  207. - LOADBUFFER { <in_elffile> | <in_hexfile> } loads the ISP buffer from an
  208. input file.
  209. - PROGRAM programs the selected address range with the ISP buffer.
  210. - VERIFY verifies that the selected address range has the same contents
  211. as the ISP buffer.
  212. - READ reads the selected address range to the ISP buffer.
  213. - SAVEBUFFER <out_hexfile> { HEX386 | HEX86 } saves the ISP buffer to an
  214. output file.
  215. - START { RESET | NORESET } 0 starts the execution of the programmed
  216. application with an optional hardware reset of the target.
  217. "The AT32UC3xxxxx memories made available by BatchISP are:
  218. - FLASH: This memory is the internal flash array of the target, including the
  219. bootloader protected area. E.g. on AT32UC3A0512 (512-kB internal flash),
  220. addresses from 0 to 0x7FFFF can be accessed in this memory.
  221. - SECURITY: This memory contains only one byte. The least significant bit
  222. of this byte reflects the value of the target Security bit which can only
  223. be set to 1. Once set, the only accepted commands will be ERASE and START.
  224. After an ERASE command, all commands are accepted until the end of the
  225. non-volatile ISP session, even if the Security bit is set.
  226. - CONFIGURATION: This memory contains one byte per target general-purpose
  227. fuse bit. The least significant bit of each byte reflects the value of
  228. the corresponding GP fuse bit.
  229. - BOOTLOADER: This memory contains three bytes concerning the ISP: the ISP
  230. version in BCD format without the major version number (always 1), the
  231. ISP ID0 and the ISP ID1.
  232. - SIGNATURE: This memory contains four bytes concerning the part: the product
  233. manufacturer ID, the product family ID, the product ID and the product
  234. revision.
  235. - USER: This memory is the internal flash User page of the target, with
  236. addresses from 0 to 0x1FF.
  237. "For further details about BatchISP commands, launch batchisp -h or see the
  238. help files installed with FLIP ..."
  239. Reset
  240. ^^^^^
  241. I don't trust the reset button -- if you reset and something weird happens,
  242. try a full power cycle.
  243. Make Tip
  244. ^^^^^^^^
  245. Because this build uses a native Windows toolchain and the native Windows
  246. tools do not understand Cygwin's symbolic links, the NuttX make system does
  247. something weird: It copies the configuration directories instead of linking
  248. to them (it could, perhaps, use the NTFS 'mklink' command, but it doesn't).
  249. A consequence of this is that you can easily get confused when you edit
  250. a file in one of the "linked" directories, re-build NuttX, and then not see your
  251. changes when you run the program. That is because build is still using the
  252. version of the file in the copied directory, not your modified file! To work
  253. around this annoying behavior, do the following when you re-build:
  254. make clean_context all <-- Remove and re-copy all of the directories, then make all
  255. doisp.sh <-- Load the code onto the board.
  256. AVR32DEV1 Configuration Options
  257. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  258. CONFIG_ARCH - Identifies the arch/ subdirectory. This should
  259. be set to:
  260. CONFIG_ARCH=avr
  261. CONFIG_ARCH_family - For use in C code:
  262. CONFIG_ARCH_AVR=y
  263. CONFIG_ARCH_architecture - For use in C code:
  264. CONFIG_ARCH_FAMILY_AVR32=y
  265. CONFIG_ARCH_CHIP - Identifies the arch/*/chip subdirectory
  266. CONFIG_ARCH_CHIP=at32uc3
  267. CONFIG_ARCH_CHIP_name - For use in C code to identify the exact
  268. chip:
  269. CONFIG_ARCH_CHIP_AT32UC3B0256
  270. CONFIG_ARCH_BOARD - Identifies the configs subdirectory and
  271. hence, the board that supports the particular chip or SoC.
  272. CONFIG_ARCH_BOARD=avr32dev1 (for the AV32DEV1 board)
  273. CONFIG_ARCH_BOARD_name - For use in C code
  274. CONFIG_ARCH_BOARD_AVR32DEV1
  275. CONFIG_ARCH_LOOPSPERMSEC - Must be calibrated for correct operation
  276. of delay loops
  277. CONFIG_ENDIAN_BIG - define if big endian (default is little
  278. endian)
  279. CONFIG_RAM_SIZE - Describes the installed DRAM (SRAM in this case):
  280. CONFIG_RAM_SIZE=0x00010000 (64Kb)
  281. CONFIG_RAM_START - The start address of installed DRAM
  282. CONFIG_RAM_START=0x20000000
  283. CONFIG_ARCH_LEDS - Use LEDs to show state. Unique to boards that
  284. have LEDs
  285. CONFIG_ARCH_INTERRUPTSTACK - This architecture supports an interrupt
  286. stack. If defined, this symbol is the size of the interrupt
  287. stack in bytes. If not defined, the user task stacks will be
  288. used during interrupt handling.
  289. CONFIG_ARCH_STACKDUMP - Do stack dumps after assertions
  290. CONFIG_ARCH_LEDS - Use LEDs to show state. Unique to board architecture.
  291. Individual subsystems can be enabled:
  292. CONFIG_AVR32_GPIOIRQ - GPIO interrupt support
  293. CONFIG_AVR32_GPIOIRQSETA - Set of GPIOs on PORTA that support interrupts
  294. CONFIG_AVR32_GPIOIRQSETB - Set of GPIOs on PORTB that support interrupts
  295. CONFIG_AVR32_USARTn - Enable support for USARTn
  296. CONFIG_AVR32_USARTn_RS232 - Configure USARTn as an RS232 interface.
  297. CONFIG_AVR32_USARTn_SPI - Configure USARTn as an SPI interface.
  298. CONFIG_AVR32_USARTn_RS485 - Configure USARTn as an RS485 interface.
  299. CONFIG_AVR32_USARTn_MAN - Configure USARTn as an Manchester interface.
  300. CONFIG_AVR32_USARTn_MODEM - Configure USARTn as an Modem interface.
  301. CONFIG_AVR32_USARTn_IRDA - Configure USARTn as an IRDA interface.
  302. CONFIG_AVR32_USARTn_ISO786 - Configure USARTn as an ISO786 interface.
  303. AT32UC3B0256 specific device driver settings
  304. CONFIG_USARTn_SERIAL_CONSOLE - selects the USARTn for the
  305. console and ttys0 (default is the USART0).
  306. CONFIG_USARTn_RXBUFSIZE - Characters are buffered as received.
  307. This specific the size of the receive buffer
  308. CONFIG_USARTn_TXBUFSIZE - Characters are buffered before
  309. being sent. This specific the size of the transmit buffer
  310. CONFIG_USARTn_BAUD - The configure BAUD of the USART. Must be
  311. CONFIG_USARTn_BITS - The number of bits. Must be either 7 or 8.
  312. CONFIG_USARTn_PARTIY - 0=no parity, 1=odd parity, 2=even parity
  313. CONFIG_USARTn_2STOP - Two stop bits
  314. Configurations
  315. ^^^^^^^^^^^^^^
  316. Common Configuration Notes
  317. --------------------------
  318. 1. Each Atmel AVR32DEV configuration is maintained in a sub-directory and
  319. can be selected as follow:
  320. tools/configure.sh avr32dev1/<subdir>
  321. Where <subdir> is one of the configuration sub-directories described in
  322. the following paragraph.
  323. (Use configure.bat instead of configure.sh in a native Windows environment).
  324. 2. These configurations use the mconf-based configuration tool. To
  325. change a configurations using that tool, you should:
  326. a. Build and install the kconfig-mconf tool. See nuttx/README.txt
  327. see additional README.txt files in the NuttX tools repository.
  328. b. Execute 'make menuconfig' in nuttx/ in order to start the
  329. reconfiguration process.
  330. 3. By default, all configurations assume the AVR toolchain under Cygwin
  331. with Windows. This is easily reconfigured:
  332. CONFIG_HOST_WINDOWS=y
  333. CONFIG_WINDOWS_CYGWIN=y
  334. CONFIG_AVR32_AVRTOOLSW=y
  335. Configuration Sub-Directories
  336. -----------------------------
  337. nsh:
  338. Configures the NuttShell (nsh) located at examples/nsh. The
  339. Configuration enables only the serial NSH interface.
  340. ostest:
  341. This configuration directory, performs a simple OS test using
  342. examples/ostest.
  343. NOTE: Round-robin scheduling is disabled in this test because
  344. the RR test in examples/ostest declares data structures that
  345. are too large for the poor little uc3 SRAM.