README.txt 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. README.txt
  2. ==========
  3. This is the README file for the port of NuttX to the Freescale Freedom KL25Z
  4. board. This board has the MKL25Z128 chip with a built-in SDA debugger.
  5. Contents
  6. ========
  7. - Development Environment
  8. - GNU Toolchain Options
  9. - NuttX Buildroot Toolchain
  10. - LEDs
  11. - Serial Console
  12. - mbed
  13. - Freedom KL25Z-specific Configuration Options
  14. - Configurations
  15. Development Environment
  16. =======================
  17. Either Linux or Cygwin under Windows can be used for the development environment.
  18. The source has been built only using the GNU toolchain (see below). Other
  19. toolchains will likely cause problems.
  20. GNU Toolchain Options
  21. =====================
  22. As of this writing, all testing has been performed using the NuttX buildroot
  23. toolchain described below. I have also verified the build using the
  24. CodeSourcery GCC toolchain for windows. Most any contemporary EABI GCC
  25. toolchain should work will a little tinkering.
  26. NuttX Buildroot Toolchain
  27. =========================
  28. A GNU GCC-based toolchain is assumed. The PATH environment variable should
  29. be modified to point to the correct path to the Cortex-M0 GCC toolchain (if
  30. different from the default in your PATH variable).
  31. If you have no Cortex-M0 toolchain, one can be downloaded from the NuttX
  32. Bitbucket download site (https://bitbucket.org/nuttx/buildroot/downloads/).
  33. This GNU toolchain builds and executes in the Linux or Cygwin environment.
  34. 1. You must have already configured Nuttx in <some-dir>/nuttx.
  35. cd tools
  36. ./configure.sh freedom-kl25z/<sub-dir>
  37. 2. Download the latest buildroot package into <some-dir>
  38. 3. unpack the buildroot tarball. The resulting directory may
  39. have versioning information on it like buildroot-x.y.z. If so,
  40. rename <some-dir>/buildroot-x.y.z to <some-dir>/buildroot.
  41. 4. cd <some-dir>/buildroot
  42. 5. cp configs/cortexm0-eabi-defconfig-4.6.3 .config
  43. 6. make oldconfig
  44. 7. make
  45. 8. Make sure that the PATH variable includes the path to the newly built
  46. binaries.
  47. See the file configs/README.txt in the buildroot source tree. That has more
  48. details PLUS some special instructions that you will need to follow if you are
  49. building a Cortex-M0 toolchain for Cygwin under Windows.
  50. LEDs
  51. ====
  52. The Freedom KL25Z has a single RGB LED driven by the KL25Z as follows:
  53. ------------- --------
  54. RGB LED KL25Z128
  55. ------------- --------
  56. Red Cathode PTB18
  57. Green Cathode PTB19
  58. Blue Cathode PTD1
  59. NOTE: PTD1 is also connected to the I/O header on J2 pin 10 (also known as D13).
  60. If CONFIG_ARCH_LEDs is defined, then NuttX will control the LED on board the
  61. Freedom KL25Z. The following definitions describe how NuttX controls the LEDs:
  62. SYMBOL Meaning LED state
  63. Initially all LED is OFF
  64. ------------------- ----------------------- --------------------------
  65. LED_STARTED NuttX has been started R=OFF G=OFF B=OFF
  66. LED_HEAPALLOCATE Heap has been allocated (no change)
  67. LED_IRQSENABLED Interrupts enabled (no change)
  68. LED_STACKCREATED Idle stack created R=OFF G=OFF B=ON
  69. LED_INIRQ In an interrupt (no change)
  70. LED_SIGNAL In a signal handler (no change)
  71. LED_ASSERTION An assertion failed (no change)
  72. LED_PANIC The system has crashed R=FLASHING G=OFF B=OFF
  73. LED_IDLE K25Z1XX is in sleep mode (Optional, not used)
  74. Serial Console
  75. ==============
  76. As with most NuttX configurations, the Freedom KL25Z configurations
  77. depend on having a serial console to interact with the software. The
  78. Freedom KL25Z, however, has no on-board RS-232 drivers so will be
  79. necessary to connect the Freedom KL25Z UART pins to an external
  80. RS-232 driver board or TTL-to-Serial USB adaptor.
  81. By default UART0 is used as the serial console on this boards. The UART0
  82. is configured to work with the OpenSDA USB CDC/ACM port:
  83. ------ ------------------------------- -----------------------------
  84. PIN PIN FUNCTIONS BOARD SIGNALS
  85. ------ ------------------------------- -----------------------------
  86. Pin 27 PTA1/TSI0_CH2/UART0_RX/FTM2_CH0 UART1_RX_TGTMCU and D0 (PTA1)
  87. Pin 28 PTA2/TSI0_CH3/UART0_TX/FTM2_CH1 UART1_TX_TGTMCU and D1 (PTA2)
  88. But the UART0 Tx/Rx signals are also available on J1:
  89. ---------------- ---------
  90. UART0 SIGNAL J1 pin
  91. ---------------- ---------
  92. UART0_RX (PTA1) J1, pin 2
  93. UART0_TX (PTA2) J1, pin 4
  94. Ground is available on J2 pin 14. 3.3V is available on J3 and J4.
  95. mbed
  96. ====
  97. The Freedom KL25Z includes a built-in SDA debugger. An alternative
  98. to the SDA bootloader is this boot loader from mbed:
  99. http://mbed.org/handbook/mbed-FRDM-KL25Z-Getting-Started
  100. http://mbed.org/handbook/Firmware-FRDM-KL25Z
  101. Using the mbed loader:
  102. 1. Connect the KL25Z to the host PC using the USB connector labeled
  103. SDA.
  104. 2. A new file system will appear called MBED; open it with Windows
  105. Explorer (assuming that you are using Windows).
  106. 3. Drag and drop nuttx.bin into the MBED window. This will load the
  107. nuttx.bin binary into the KL25Z. The MBED window will close
  108. then re-open and the KL25Z will be running the new code.
  109. Using the Freescale SDA debugger is essentially the same. That
  110. debugger will also accept .hex file.
  111. Freedom KL25Z-specific Configuration Options
  112. ============================================
  113. CONFIG_ARCH - Identifies the arch/ subdirectory. This should
  114. be set to:
  115. CONFIG_ARCH=arm
  116. CONFIG_ARCH_family - For use in C code:
  117. CONFIG_ARCH_ARM=y
  118. CONFIG_ARCH_architecture - For use in C code:
  119. CONFIG_ARCH_CORTEXM0=y
  120. CONFIG_ARCH_CHIP - Identifies the arch/*/chip subdirectory
  121. CONFIG_ARCH_CHIP=kl
  122. CONFIG_ARCH_CHIP_name - For use in C code to identify the exact
  123. chip:
  124. CONFIG_ARCH_CHIP_MKL25Z128=y
  125. CONFIG_ARCH_BOARD - Identifies the configs subdirectory and
  126. hence, the board that supports the particular chip or SoC.
  127. CONFIG_ARCH_BOARD=freedom-kl25z (for the Freescale FRDM-KL25Z development board)
  128. CONFIG_ARCH_BOARD_name - For use in C code
  129. CONFIG_ARCH_BOARD_FREEDOM_K25Z128=y
  130. CONFIG_ARCH_LOOPSPERMSEC - Must be calibrated for correct operation
  131. of delay loops
  132. CONFIG_ENDIAN_BIG - define if big endian (default is little
  133. endian)
  134. CONFIG_RAM_SIZE - Describes the installed DRAM (SRAM in this case):
  135. CONFIG_RAM_SIZE=16384 (16Kb)
  136. CONFIG_RAM_START - The start address of installed DRAM
  137. CONFIG_RAM_START=0x20000000
  138. CONFIG_ARCH_LEDS - Use LEDs to show state. Unique to boards that
  139. have LEDs
  140. CONFIG_ARCH_INTERRUPTSTACK - This architecture supports an interrupt
  141. stack. If defined, this symbol is the size of the interrupt
  142. stack in bytes. If not defined, the user task stacks will be
  143. used during interrupt handling.
  144. CONFIG_ARCH_STACKDUMP - Do stack dumps after assertions
  145. CONFIG_ARCH_LEDS - Use LEDs to show state. Unique to board architecture.
  146. CONFIG_ARCH_CALIBRATION - Enables some build in instrumentation that
  147. cause a 100 second delay during boot-up. This 100 second delay
  148. serves no purpose other than it allows you to calibratre
  149. CONFIG_ARCH_LOOPSPERMSEC. You simply use a stop watch to measure
  150. the 100 second delay then adjust CONFIG_ARCH_LOOPSPERMSEC until
  151. the delay actually is 100 seconds.
  152. Individual subsystems can be enabled as follows. These settings are for
  153. all of the K25Z100/120 line and may not be available for the MKL25Z128
  154. in particular:
  155. AHB
  156. ---
  157. CONFIG_KL_PDMA Peripheral DMA
  158. CONFIG_KL_FMC Flash memory
  159. CONFIG_KL_EBI External bus interface
  160. APB1
  161. ----
  162. CONFIG_KL_WDT Watchdog timer
  163. CONFIG_KL_RTC Real time clock (RTC)
  164. CONFIG_KL_TMR0 Timer0
  165. CONFIG_KL_TMR1 Timer1
  166. CONFIG_KL_I2C0 I2C interface
  167. CONFIG_KL_SPI0 SPI0 master/slave
  168. CONFIG_KL_SPI1 SPI1 master/slave
  169. CONFIG_KL_PWM0 PWM0
  170. CONFIG_KL_PWM1 PWM1
  171. CONFIG_KL_PWM2 PWM2
  172. CONFIG_KL_PWM3 PWM3
  173. CONFIG_KL_UART0 UART0
  174. CONFIG_KL_USBD USB 2.0 FS device controller
  175. CONFIG_KL_ACMP Analog comparator
  176. CONFIG_KL_ADC Analog-digital-converter (ADC)
  177. APB2
  178. ---
  179. CONFIG_KL_PS2 PS/2 interface
  180. CONFIG_KL_TIMR2 Timer2
  181. CONFIG_KL_TIMR3 Timer3
  182. CONFIG_KL_I2C1 I2C1 interface
  183. CONFIG_KL_SPI2 SPI2 master/slave
  184. CONFIG_KL_SPI3 SPI3 master/slave
  185. CONFIG_KL_PWM4 PWM4
  186. CONFIG_KL_PWM5 PWM5
  187. CONFIG_KL_PWM6 PWM6
  188. CONFIG_KL_PWM7 PWM7
  189. CONFIG_KL_UART1 UART1
  190. CONFIG_KL_UART2 UART2
  191. CONFIG_KL_I2S I2S interface
  192. K25Z1XX specific device driver settings
  193. CONFIG_UARTn_SERIAL_CONSOLE - Selects the UARTn (n=0,1,2) for the
  194. console and ttys0.
  195. CONFIG_UARTn_RXBUFSIZE - Characters are buffered as received.
  196. This specific the size of the receive buffer for UARTn.
  197. CONFIG_UARTn_TXBUFSIZE - Characters are buffered before
  198. being sent. This specific the size of the transmit buffer
  199. for UARTn.
  200. CONFIG_UARTn_BAUD - The configure BAUD of UARTn,
  201. CONFIG_UARTn_BITS - The number of bits. Must be 5, 6, 7, or 8.
  202. CONFIG_UARTn_PARTIY - 0=no parity, 1=odd parity, 2=even parity
  203. CONFIG_UARTn_2STOP - Two stop bits
  204. Configurations
  205. ==============
  206. Each FREEDOM-KL25Z configuration is maintained in a sub-directory and
  207. can be selected as follow:
  208. cd tools
  209. ./configure.sh freedom-kl25z/<subdir>
  210. cd -
  211. If this is a Windows native build, then configure.bat should be used
  212. instead of configure.sh:
  213. configure.bat freedom-kl25z\<subdir>
  214. Where <subdir> is one of the following:
  215. nsh:
  216. ---
  217. Configures the NuttShell (nsh) located at apps/examples/nsh. The
  218. Configuration enables the serial interface on UART0. Support for
  219. builtin applications is disabled.
  220. NOTES:
  221. 1. This configuration uses the mconf-based configuration tool. To
  222. change this configuration using that tool, you should:
  223. a. Build and install the kconfig-mconf tool. See nuttx/README.txt
  224. see additional README.txt files in the NuttX tools repository.
  225. b. Execute 'make menuconfig' in nuttx/ in order to start the
  226. reconfiguration process.
  227. 2. By default, this configuration uses the CodeSourcery toolchain
  228. for Windows and builds under Cygwin (or probably MSYS). That
  229. can easily be reconfigured, of course.
  230. CONFIG_HOST_WINDOWS=y : Builds under Windows
  231. CONFIG_WINDOWS_CYGWIN=y : Using Cygwin
  232. CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y : CodeSourcery for Windows
  233. 3. Serial Console. A serial console is necessary to interrupt with
  234. NSH. The serial console is configured on UART0 which is available
  235. on J1:
  236. ---------------- ---------
  237. UART0 SIGNAL J1 pin
  238. ---------------- ---------
  239. UART0_RX (PTA1) J1, pin 2
  240. UART0_TX (PTA2) J1, pin 4
  241. Ground is available on J2 pin 14. 3.3V is available on J3 and J4.
  242. It is possible to configure NSH to use a USB serial console instead
  243. of an RS-232 serial console. However, that configuration has not
  244. been impelmented as of this writing.
  245. 4. Memory Usage. The size command gives us the static memory usage.
  246. This is what I get:
  247. $ size nuttx
  248. text data bss dec hex filename
  249. 35037 106 1092 36235 8d8b nuttx
  250. And we can get the runtime memory usage from the NSH free command:
  251. NuttShell (NSH) NuttX-6.25
  252. nsh> free
  253. total used free largest
  254. Mem: 14160 3944 10216 10216
  255. nsh>
  256. Summary:
  257. - This slightly tuned NSH example uses 34.2KB of FLASH leaving 93.8KB
  258. of FLASH (72%) free from additional application development.
  259. I did not do all of the arithmetic, but it appears to me that of this
  260. 34+KB of FLASH usage, probably 20-30% of the FLASH is used by libgcc!
  261. libgcc has gotten very fat!
  262. - Static SRAM usage is about 1.2KB (<4%).
  263. - At run time, 10.0KB of SRAM (62%) is still available for additional
  264. applications. Most of the memory used at runtime is allocated I/O
  265. buffers and the stack for the NSH main thread (1.5KB).
  266. There is probably enough free memroy to support 3 or 4 application
  267. threads in addition to NSH.
  268. 5. This configurations has support for NSH built-in applications. However,
  269. in the default configuration no built-in applications are enabled.
  270. 6. This configuration has been used to verify the TI CC3000 wireless
  271. networking module. In order to enable this module, you would need to
  272. make the following changes to the default configuration files:
  273. System Type -> Kinetis peripheral support
  274. CONFIG_KL_SPI0=y : Enable SPI
  275. CONFIG_KL_SPI1=y
  276. Drivers -> SPI
  277. CONFIG_SPI=y : Enable SPI
  278. CONFIG_SPI_EXCHANGE=y
  279. Drivers -> Wireless
  280. CONFIG_DRIVERS_WIRELESS=y : Enable wireless support
  281. CONFIG_WL_CC3000=y : Build the CC3000 driver
  282. Applications -> Examples
  283. CONFIG_EXAMPLES_CC3000BASIC=y : CC3000 test example
  284. Applications -> NSH Library
  285. CONFIG_NSH_ARCHINIT=y : Build in CC3000 initialization logic