| Author | Topic: Programming Quickstart (Read 4,990 times) |
senatorpenguin New Member
 member is offline
Joined: Oct 2010 Gender: Male  Posts: 15 Karma: 2 |  | Programming Quickstart « Thread Started on Oct 24, 2010, 5:07pm » | |
[EDIT: I've gotten motors, the screen, and some other stuff working using GCC, look at http://ti-evalbot.proboards.com/index.cg....splay&thread=26 for a better guide]
I'm by no means an expert in anything ARM or Stellaris related, but I've gotten past the first few hurdles beyond simply running the preloaded uC/OS programs.
The IDE I've had the most success with is IAR Embedded Workbench for ARM (Kickstart edition, has a 32kb code limitation). http://supp.iar.com/Download/SW/?item=EWARM-KS32
The next things you'll need are drivers for the ICDI interface to program the board, which are found in the IAR installation folder at C:\Program Files\IAR Systems\Embedded Workbench 5.4 Kickstart\arm\drivers\LuminaryFTDI
There are two sets of example code that are useful in starting to program the evalbot. The first and easiest is the uC/OS III code examples that came with the book that costs more than triple the discounted bot. Fortunately, you can download them from Micrium with a bugmenot.com login: http://micrium.com/page/downloads/os-iii_files To save you a bit of searching, once you've extracted their examples, the IAR workspace file is in Micrium\Software\EvalBoards\TI\LM3S9B92-EVALBOT\IAR One folder level up from that is a collection of datasheets for parts on board the Evalbot.
Without any configuration, the 4 example programs can be compiled and downloaded to the board from IAR. The code is quite confusing, mainly because uC/OS is an entire operating system, and each example is a full application written for uCOS. You can however, learn a bit about how to interface with some of the peripherals by reading through some of the more helpful functions. "app.c" contains the main method, along with most of the initialization procedures. The files in the BSP folder have most of the peripheral code.
The second set of invaluable examples are shipped with the IAR Workbench, helpfully located in C:\Program Files\IAR Systems\Embedded Workbench 5.4 Kickstart\arm\examples\TexasInstruments\Stellaris\boards\ek-lm3s9b92 These are examples for a very similar development board, however most of the IO pins are wired differently. To adapt these examples, you have to cross reference the code with the schematic here: http://focus.ti.com/lit/ml/spmr001/spmr001.pdf
For example, in the "blinky" example, which just blinks an LED on and off repeatedly, the main method contains:
Code: // // Enable the GPIO port that is used for the on-board LED. // SYSCTL_RCGC2_R = SYSCTL_RCGC2_GPIOD;
// // Do a dummy read to insert a few cycles after enabling the peripheral. // ulLoop = SYSCTL_RCGC2_R;
// // Enable the GPIO pin for the LED (PD0). Set the direction as output, and // enable the GPIO pin for digital function. // GPIO_PORTD_DIR_R |= 1; GPIO_PORTD_DEN_R |= 1;
|
|
However, checking the schematic PDF shows that PD0 is connected to a motor driver, not an LED. A little searching shows that LED1 is connected to PF4. by replacing all references to GPIO port D with port F, and writing to the registers in bit 4 rather than bit 0, this is rewritten as
Code: // // Enable the GPIO port that is used for the on-board LED. // SYSCTL_RCGC2_R = SYSCTL_RCGC2_GPIOF;
// // Do a dummy read to insert a few cycles after enabling the peripheral. // ulLoop = SYSCTL_RCGC2_R;
// // Enable the GPIO pin for the LED (PF4). Set the direction as output, and // enable the GPIO pin for digital function. // GPIO_PORTF_DIR_R |= 1<<4; GPIO_PORTF_DEN_R |= 1<<4;
|
|
You have to do this a couple more times in the rest of the code, but that is the general procedure.
Most of the examples use the UART0 (which is connected to the ICDI interface) to communicate with the computer. These are on pins A0/1 on the Evalbot and in the examples, so the code needs no alterations. Just use PuTTY to open up the ICDI COM port at 115200 baud, and watch the Hello World!s fly by.
As for the other peripherals, here are a few notes and observations of mine that might help: 1. If you are trying to get either the USB host or device to work, make sure you enable the 5V power supply (PA6 is high) EVEN IF YOU ARE USING THE EVALBOT AS A USB DEVICE. There is a glitch in the B1 revision of the LM3S9B92, which needs to read 5V on the USB0VBUS pin regardless of whether it makes sense to do so. Also, make sure you set PB0 (the switch on the USB multiplexer) high for device mode, low for host mode.
2. I don't know if you can implement the ethernet libraries without going over the 32kB limit. Maybe.
3. TI made a mistake, the screen controller isn't a SSD1300 (No I2C interface, and its way obsolete). It might be a SSD0300, and the following datasheet seems to more accurately describe the OLED controller. bsp_display.c from the micrium examples helps the most in implementing this. http://www.eecs.umich.edu/~prabal/teachi....ision%201.4.pdf
4. If you are trying to run the example where the evalbot appears as a usb-serial device, you will need the "Stellaris Embedded USB Drivers" from http://www.luminarymicro.com/products/software_updates.html
| |
|
kemp New Member
 member is offline
Joined: Oct 2010 Gender: Male  Posts: 24 Karma: 0 |  | Re: Programming Quickstart « Reply #1 on Oct 24, 2010, 5:20pm » | |
Good work senatorpenguin, lots of useful hints.
| |
|
necromant New Member
 member is offline
![[avatar] [avatar]](http://necromant.ath.cx/ava.jpg)
![[homepage] [homepage]](http://images.proboards.com/new/buttons/www_sm.png) Joined: Oct 2010 Gender: Male  Posts: 29 Location: Moscow, Russia Karma: 0 |  | Re: Programming Quickstart « Reply #2 on Oct 25, 2010, 2:25am » | |
Thanks for the tip. But looks like I'll have to trash that IAR as soon as I get the bot and compile gcc, but that should be straightforward and simple. The thing that worries me more is: Is there anything about the LuminaryFTDI stuff to flash the firmware? I mean, is there a ready-to-use utility for linux? Or Should I order a good supply of coffee already?
|
AVR, ARM, MIPS & linux. |
|
jackthevendicator New Member
 member is offline
Joined: Oct 2010 Gender: Male  Posts: 13 Karma: 0 | |
kemp New Member
 member is offline
Joined: Oct 2010 Gender: Male  Posts: 24 Karma: 0 |  | Re: Programming Quickstart « Reply #4 on Oct 25, 2010, 10:43am » | |
SafeRTOS is overkill for anything we will do. IIRC it's aimed at Hard Real-time and it's certified for use in critical systems that can't fail or people die.
| |
|
jackthevendicator New Member
 member is offline
Joined: Oct 2010 Gender: Male  Posts: 13 Karma: 0 |  | Re: Programming Quickstart « Reply #5 on Oct 25, 2010, 1:16pm » | |
Oct 25, 2010, 10:43am, kemp wrote:| SafeRTOS is overkill for anything we will do. IIRC it's aimed at Hard Real-time and it's certified for use in critical systems that can't fail or people die. |
|
Of course... probably it does its best in medical/aeronautic applications.
Anyway, other useful stuff: http://www.luminarymicro.com/products/eki-lm3s9b92.html
| |
|
senatorpenguin New Member
 member is offline
Joined: Oct 2010 Gender: Male  Posts: 15 Karma: 2 |  | Re: Programming Quickstart « Reply #6 on Oct 25, 2010, 1:58pm » | |
I haven't looked into GCC much yet, but the IAR toolchain comes with a very full-featured bootloader (works over USB, UART, and Ethernet) as well as drivers for all the peripherals (+working USB drivers), and a smattering of third-party libraries like FATfs, jpeg, zip.
As far as I can tell, the LuminaryFTDI is just a driver for the slightly customized FTDI chip in the ICDI interface. It's a FT2232 dual USB-serial converter, with connections to UART0 and the JTAG interface. The most important puzzle piece for flashing the board would seem to be the actual protocol for downloading the program to the board. IAR uses JTAG to download programs (no bootloader). If you use their bl, they have provided code for two windows programmers(sflash for UART, eflash for ethernet) at arm\examples\TexasInstruments\Stellaris\tools With enough coffee, porting them to linux shouldn't be too horrible.
| |
|
jackthevendicator New Member
 member is offline
Joined: Oct 2010 Gender: Male  Posts: 13 Karma: 0 |  | Re: Programming Quickstart « Reply #7 on Oct 25, 2010, 4:10pm » | |
Oct 25, 2010, 1:58pm, senatorpenguin wrote: As far as I can tell, the LuminaryFTDI is just a driver for the slightly customized FTDI chip in the ICDI interface. It's a FT2232 dual USB-serial converter, with connections to UART0 and the JTAG interface. The most important puzzle piece for flashing the board would seem to be the actual protocol for downloading the program to the board. IAR uses JTAG to download programs (no bootloader). If you use their bl, they have provided code for two windows programmers(sflash for UART, eflash for ethernet) at arm\examples\TexasInstruments\Stellaris\tools With enough coffee, porting them to linux shouldn't be too horrible.
|
|
urjtag has plenty of support for ft2232 cables... having the schematics, it should be very easy to write a interface configuration file.
| |
|
senatorpenguin New Member
 member is offline
Joined: Oct 2010 Gender: Male  Posts: 15 Karma: 2 |  | Re: Programming Quickstart « Reply #8 on Oct 25, 2010, 6:10pm » | |
Just checked, the code for sflash has termios support for serial communication built in, it should compile on *nix systems without too much pain at all.
| |
|
necromant New Member
 member is offline
![[avatar] [avatar]](http://necromant.ath.cx/ava.jpg)
![[homepage] [homepage]](http://images.proboards.com/new/buttons/www_sm.png) Joined: Oct 2010 Gender: Male  Posts: 29 Location: Moscow, Russia Karma: 0 |  | Re: Programming Quickstart « Reply #9 on Oct 26, 2010, 7:42am » | |
That's good, because my guess was ftdi bit-bang mode and some closed source util. Damn, ti is definetely not in a hurry to ship my evalbot
|
AVR, ARM, MIPS & linux. |
|
jackthevendicator New Member
 member is offline
Joined: Oct 2010 Gender: Male  Posts: 13 Karma: 0 |  | Re: Programming Quickstart « Reply #10 on Oct 26, 2010, 10:19am » | |
Oct 25, 2010, 6:10pm, senatorpenguin wrote:| Just checked, the code for sflash has termios support for serial communication built in, it should compile on *nix systems without too much pain at all. |
|
sflash compiles as is:
Code:francesco@Gemstone:~/Programmi/IAR/sflash$ gcc -o sflash packet_handler.c uart_handler.c sflash.c francesco@Gemstone:~/Programmi/IAR/sflash$ ./sflash -h
Usage: sflash filename -p [program address] -r [execution address] -c [tty] -d -l [Boot Loader filename] -b [baud rate] -s [data size]
-p [program address]: if address is not specified it is assumed to be 0x00000000 if there is no 0x prefix is added then the address is assumed to be in decimal -r [execution address]: if address is not specified then no run command will be sent. -c [tty]: This is the name of the TTY device to use. -l [Boot Loader filename]: This specifies a boot loader binary that will be loaded to the device before downloading the application specified by the filename parameter. -b [baud rate]: Specifies the baud rate in decimal. -d Disable Auto-Baud support -s [data size]: Specifies the number of data bytes to be sent in each data packet. Must be a multiple of 4 between 4 and 252 (inclusive).
Example: Download test.bin using COM 1 to address 0x800 and run at 0x820 sflash test.bin -p 0x800 -r 0x820 -c 1 |
|
eflash must be ported from winsock to linux sockets, but runs on wine:
Code:francesco@Gemstone:~/.wine/drive_c/Programmi/IAR Systems/Embedded Workbench 5.4/arm/examples/TexasInstruments/Stellaris/tools/bin$ wine eflash.exe EFLASH Ethernet Boot Loader Download Utility (Version: 4652)
Copyright (C) 2009 Luminary Micro, Inc. All rights reserved.
usage: eflash [options] file
Download a file to a remote device, using the Ethernet Boot Loader. The file should be a binary image, and the IP and MAC address of the target device must be specified. Example: eflash -i 169.254.19.63 --mac=00.1a.b6.00.12.04 enet_lwip.bin
Required options: -i addr, --ip=addr IP address of remote device to program, in dotted-decimal notation (e.g. 169.254.19.63) -m addr, --mac=addr MAC address of remote device to program, specified as a series of hexadecimal numbers delimited with '-', ':', or '.'. (e.g. 00.1a.b6.00.12.04) file binary file to be downloaded to the remote device. (e.g. enet_lwip.bin)
Output control: --quiet, --silent suppress all normal output --verbose display additional status information --debug display additional diagnostic information
Miscellaneous: --version display program version information, then exit --help display this help text, then exit
Support Information: Report any bugs to <support@luminarymicro.com>
|
|
IAR runs on wine too:
![[image] [image]](http://img200.imageshack.us/img200/2671/iarwine.th.jpg)
Uploaded with ImageShack.us
| |
|
necromant New Member
 member is offline
![[avatar] [avatar]](http://necromant.ath.cx/ava.jpg)
![[homepage] [homepage]](http://images.proboards.com/new/buttons/www_sm.png) Joined: Oct 2010 Gender: Male  Posts: 29 Location: Moscow, Russia Karma: 0 |  | Re: Programming Quickstart « Reply #11 on Oct 28, 2010, 3:31am » | |
Wine doesn't work without an X server, so no way for remote debug, and I'm kind of hooked to my remote debug rig. VNC & other stuff really suck on a gprs connection, while ssh + sshfs look quite bearable. BTW, Last time I looked at IAR in wine it crashed all over the place.
|
AVR, ARM, MIPS & linux. |
|
artvandelay New Member
 member is offline
Joined: Jan 2011 Gender: Male  Posts: 8 Karma: 0 |  | Re: Programming Quickstart « Reply #12 on Jan 22, 2011, 6:46pm » | |
senatorpenguin, thanks for the info! I set up the gcc ARM toolchain (Code Sourcery) and OpenOCD last night on OS X, and just got the blinky project modified, flashed over and running on my evalbot. Very cool!
Now to start poking around the StellarisWare code and figure out how to access the screen, motor drivers, etc....
| |
|
mando New Member
 member is offline
Joined: Oct 2010 Posts: 4 Karma: 0 |  | Re: Programming Quickstart « Reply #13 on Jan 23, 2011, 11:18pm » | |
Thanks a lot senatorpenguin! So far, I've gotten up to the point of checking out the code examples and whatnot, but I'm not positive where to go from here. I realize that I'm supposed to edit/write code, then download to the bot? (I apologize, I'm completely unfamiliar with embedded systems)
| |
| |
|