himanshubdave1426459935 1 Posted August 1, 2013 Share Posted August 1, 2013 I have run and debgged all (expect one - where a WINDOWS client was needed) Labs for TivaC LaunchPad Workshop using command-line Sourcery CodeBench and OpenOcd, on Slackware Linux. The details can be given in this list if there is enough interest. Quote Link to post Share on other sites
bluehash 1,581 Posted August 2, 2013 Share Posted August 2, 2013 Of course. I'm sure many would benefit from it. Will it be a video or a writeup? Quote Link to post Share on other sites
himanshubdave1426459935 1 Posted August 4, 2013 Author Share Posted August 4, 2013 The TM4C123GXL LaunchPad Workshop only contains Labs, suitable to run on CCSv5, as described in TM4C123GXL_LaunchPad_Workshop_ Workbook.pdf . For Linux users, the problem is that, tho Yough CCSv5 is avialable for Linux, but the flash-programmer does not work reliably for Stellaris/TivaC LaunchPads. I found it much more comfortable to use Sourcery CodeBench Lite (i.e. the Command Line Interface version) along with arm-gdb and OpenOCD, to build, run and debug various examples and Lab's. You can use lmicdi in place of openocd, but it will only allow flash-writing, not full use of debuging via gdb. The purpose of this note is to give steps for using the Lab examples with Sourcery CLI CodeBench. Mainly, some of the Makefiles are to be adjusted as per locations of various directories. Of course, you will have to be comfortable to use gdb. Steps are in twp parts: Preparation and Use. Preparation: 1. Download and install TivaWare for LaunchPad in WINDOWS: EK-TM4C123GXL-CB-753. Actually we are going to use a few Makefiles only from this package, so if if you do not have WINDOWS, only copy the Makefiles mentioned below from your friend's machine. 2. Download TM4C123G_LaunchPad_Workshop from TI site and install it in WINDOWS. Again copy the whole directory from your friend's machine if you do not have WINDOWS. The package is not very large (a couple of MBytes) As an aside, many of the packages from TI in form of *.exe files are actually zipped directories and can be directly unzipped in Linux, unfortunately this one is not. 3. CodeSourcery Sourcery_CodeBench_Lite_for_ARM_EABI should have been Download'ed and installed. 4. OpenOCD should have been Download'ed and installed. 5. (preferable) download putty and install it, check that it works OK. Alternatives are minicom or screen. You will need this for some of the Lab's. Yo 6. If you did install TivaWare on WINDOWS, run make in it's top directory This will create the libraries (and examples). Alternatively, you can possibly do that after copying the whole directory to Linux. We are interested in the drivers, sensors and usb libraries. Remember that these libraries are for the ARM platform and not x86. You should check that fact by using file and/or ldd command. 7. copy the following from TM4CWare to TM4CWorkshop and put them in appropriate directories: makedefs -----> will be modified as described below. Makefile(example) ----- as given in blinky or bitband examples Makefile(toplevel) ----- from toplevel of TM4CWare standalone.ld The Makefile from example bitband shows how to add driver or other libraries in the linker-make portion of the Makefile 8. Put the following in your $HOME/.bashrc or $HOME/.bash_profile: ----------------------------- OCD and other lines in .bashrc ------------export OCD="openocd --file /usr/local/share/openocd/scripts/board/ek-tm4c123gxl.cfg" export DEBUG=1 <------ needed by gdbexport SCR="screen /dev/ttyACM0 115200" <------ if you are using screenexport TM4C="/home/hbd/TM4CWare/examples/boards/ek-tm4c123gxl/"---------------------------------------------------------------------------------------------------- Refer to spmu356.pdf for details of the Sourcey CodeBench usage. The modifications needed in the above Makefiles depends upon where you installed the TivaWare and Workshop directories. [iI] Use: As the first example, we take Lab2. 1. Copy Makefile(toplevel) to dir TM4CWorkshop, and modify the first few lines as follows:----------------------------------------------# A list of the directories containing the examples.#DIRS=lab2/project--------------------------------------------- This will build only the lab2 example when you run this top level makefile. 2. Copy the Makefile(lab2) to lab2/project directory Copy lab2.ld to lab2/project directory 3. Rename the two *.txt files in the project dir to *.c, we are not goinf to use the C source files in files dir, they may be kept as back-ups. 4. make in the top dir. this should create two files lab2.axf and lab2.bin in the dir : TM4C123G_LaunchPad_Workshop/lab2/project/gcc 5. Insert TivaC LaunchPad in a USB port. 6. sudo $OCD <----- sudo: to be able to access USB virtualized ICDI and serial ports This will connect openocd to the LaunchPad 7. open putty in another screen (serial 115300 None, 8,1,None /dev/ttyACM0) Actually not needed for Lab2, but later needed for other Lab's. 8. in directory TM4C123G_LaunchPad_Workshop/lab2/project/gcc start gdb by: (assuming that the Sourcery CodeBench is properly installed): arm-none-eabi-gdb lab2.axf then: (gdb) target remote :3333 (gdb) monitor reset halt (gdb) load --------> loads the lab2 code to the LaunchPad (gdb) monitor reset init (gdb) c ---------> the program of blinking RGB LED should start CTRL-C (gdb) li, b, s, n, p, etc. can be used and are tested to be working If you have gone this far, you can try more exciting things. For example, in Lab5 on ADC12, you are told to monitor some of the program variables. We can do that using our set-up as follows: Lab5: ADC12: To look at the values of ui32ADC0value, ui32TempAvg, ui32TempValueC, ui32TempValueF : After setting up for Lab5 as above, building the lab5.axf file, etc. proceed as follows: 1. sudo $OCD 2. arm-none-eabi-gdb lab5.axf (gdb) target remote :3333 (gdb) monitor reset halt (gdb) load (gdb) monitor reset init (gdb) b 34 <------ line: ADCIntClear(ADC0_BASE, 1) gdb responds: breakpoint 1 at 0x2e2 ..... (gdb) commands 1 > p ui32ADC0value > p ui32TempAvg > p ui32TempValueC > p ui32TempValueF > end (gdb) c Now every time round the loop, on the break at line no. 34, the values of these variables are printed Note that putting watch-points on these variables will not help, as the watch will be displayed only if the variable value changes. We could have used display command also but it will clutter the output if other break-points are active. I have listed the USB Bulk Example Client needed in Lab7 (for Linux) in the "Code" Forum, please have a look there. A final warning: if you try the Lab6- Hibernation Module, there is a little problem (the problem is logical in nature and is also there in WINDOWS CCSv5). After the Lab6 code is loaded in the LaunchPad, it goes into Hibernation after 4 seconds. You can not put any later program in the LaunchPad! This is because, openocd will terminate the connection to the LaunchPad within the 4 seconds time window available to you to program via gdb and you can not flash a new program. I proceed as follows to come out of this dilema: (Of course, you are lucky to be forewarned, make that delay something like 10 to 30 seconds instead of the original 4 seconds, enough time to switch the screens and flash the new program! ) 1. At this stage we just want to flash a new program in the LaunchPad and not interested in debugging it. 2. Use lm4tools package's lmicdi utility to connect to the LaunchPad. 3. Keep gdb ready with command (gdb) target remote :7777 in another screen, but do not press RET yet 4. keep SW2 on the LaunchPad pressed, press RET on the gdb screen and quickly type commands (gdb) monitor reset halt (gdb) load <------ loads your new program in the LaunchPad (gdb) monitor reset init Release SW2. Whew! (gdb) c If your new program starts working, you are done, otherwise repeat the steps 3 and 4 . We use lmicdi instead of openocd, as it seems to be better tolerant of momentory breaks in connection (which will result due to the processor going in Hibernation momentorily, even with SW2 pressed) I hope the above note is of some help. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.