Program Development Tools Programming Editors Many good editors for programming exist. Two are available most anywhere. -vi, emacs vi (pronounced “vee.

Slides:



Advertisements
Similar presentations
CS 497C – Introduction to UNIX Lecture 8: The vi/vim Editor Chin-Chih Chang
Advertisements

A Guide to Unix Using Linux Fourth Edition
Editing with vi Or more fun than you thought you’d have without a mouse Prof. Chris GauthierDickey.
Program Development Tools IDE vs point tools Two tool flavors exist for developing embedded software: -IDEs: (Integrated Development Environments) i.e.,
CIS 240 Introduction to UNIX Instructor: Sue Sampson.
VIM: The basics Tang Wai-Chung, Matthew (MaFai) 29/12/2006.
ECE 353 WinAVR and C Debugging Tutorial By Adam Bailin ECE 353 Fall ‘06.
Vi Editor TA for ITIS3100: Xu Fei
Chapter 5 Editing Text Files
1 Using Editors Editors let you create and edit ASCII files UNIX normally includes two editors: vi and Emacs Vi and Emacs are screen editors: they display.
CS 497C – Introduction to UNIX Lecture 9: The vi/vim Editor Chin-Chih Chang
Starting Vi Opening an existing file vi filename Creating a new file vi filename In your workshop directory, create a new file called mysong vi mysong.
CSCI 330 T HE UNIX S YSTEM Editing files. E DITOR C ONCEPTS Editing a file is to modify the content of a file Text editor: Enter and modify text in a.
Using Linux Text Editors. Use Non-Graphical Linux Text Editors Graphical Text Editor.
1 Unix Editors (ee, ed, ex, vi, vim) and Compilers (g77, gcc) Speaker: Li-Wen Chen Date:
Chapter 3 Mastering Editors
Chapter 3: The UNIX Editors ASCII and vi Editors.
Chapter Three The UNIX Editors. 2 Lesson A The vi Editor.
The UNIX development environment CS 400/600 – Data Structures.
T HE VI EDITOR. vi has 2 modes: command mode (initial or "default" mode) insert mode [Esc] is used to switch to command mode. In general, vi commands:
리눅스 : Lecture 5 UNIX 유틸리티 : text editor, compilation (make), …
Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 5.1 © Copyright IBM Corporation 2008 Unit 7 Editing.
Software I: Utilities and Internals Lecture 2 – The vi Text Editor * Modified from Dr. Robert Siegfried original presentation.
Introduction to Vim Robbie CSCI2100 Data Structures Tutorial 3.
Intro. To Unix commands For those who’ve never used Unix before Quick tutorial to let you move around your Unix Accounts No discussion of inner workings.
Chapter8 The vi Editor. Introduction to vi u Modes of Operation u The Work Buffer  During the editing session, vi make all changes in the buffer  Advantage.
UNIX Intro vi  vi is the standard UNIX text editor v Contents 1.Why use vi ? 2. vi Basics 3.Moving Around 4.Inserting Text.
Text editors Why should I use an editor ? It is very important to able to use at least one text mode editor a text mode editor is so useful on remote machines.
Unix Editors. u Editors in Unix come in two general flavours: –modal editors have "modes" v generally input mode and command mode –input mode allows entry.
Tony Kombol.  Why text edit?  Many programs and features require configuration ▪ Configuration is kept in files ▪ Usually in the /etc directory  Changes.
Unix Session IV.
Text Editing February 2 nd, 2004 Class Meeting 3.
Chapter Three Text Editing1 System Programming Text Editing.
VI EDITOR University of Mississippi. Vi Editor What is Vi ? ▫Vi is a screen based editor. ▫The screen of your terminal will act as a window into the file.
Chapter 9 Using Text Editors. vi Editor visual Editor, ASCII text editor, no formatting capabilities almost as powerful as MS Word, has 26 clipboards.
1 © 2012 John Urrutia. All rights reserved. Chapter 6 The vi Editor.
Introduction to Unix (CA263) File Editing By Tariq Ibn Aziz.
Lesson 4-Mastering the Visual Editor. Overview Introducing the visual editor. Working in an existing file with vi. Understanding the visual editor. Navigating.
Chapter Three The UNIX Editors.
Linux Class #03. File Access Permissions Types of users in Linux: Local User (u) Group User (g) Other User (o) Each User can have 3 types of permissions:
Isecur1ty training center Presented by : Eng. Mohammad Khreesha.
Program Development Tools GNU make (much of this material is adapted from “GNU Make” by Richard Stallman) The make utility automatically determines which.
THE vi EDITOR. Introduction There are three editors available in almost all versions of Unix: ed, ex and vi. The ed program is the original editor that.
Text editing and more basic commands CS 2204 Class meeting 3 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
Agenda Using vi Editor Starting vi Session Command / Input Modes Entering Text Editing Text Saving Edited File Aborting Editing Session.
Vi editor Pronounced: `vee eye‘’. Agenda Describe the background of vi Editor Use vi editor to: create text files edit text files Our Goal is to create.
Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008 Chapter 6: The vi Editor – Last Look 1 of 55 Copyright ©2008 by Pearson Education, Inc. Upper Saddle.
LINUX System : Lecture 5 text editor, compilation (make), … Bong-Soo Sohn Assistant Professor School of Computer Science and Engineering Chung-Ang University.
Makefiles Manolis Koubarakis Data Structures and Programming Techniques 1.
Basic VI Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
Program Development Tools Diamonds in the Rough “Programming today is the opposite of diamond mining. In diamond mining, you dig up a lot of dirt to find.
Purdue Linux Users Group Presents Linux 201: Session 1 Everything you ever wanted to do in VIM Thor Smith.
CS:414 introduction to Unix and Linux
Chapter 3: Mastering Editors Chapter 3 Mastering Editors (Emacs)
Assembly Language with GCC
Vim basics Vi IMproved.
Guide To UNIX Using Linux Third Edition
Vi Editor.
Unix Fundamentals - Part iii vi Editor
Vim.
Vi Introduction Tony Kombol.
Linux 104 Training Module File Editing.
Lecture 3 More on editors: emacs and vi COP 3344 Introduction to UNIX.
IT244 - Introduction to Linux / Unix Instructor: Bo Sheng
Text Editors Vim (Chapter 6) Emacs (Chapter 7)
Chapter 2 Basic vi Editor.
The Emacs Editor Read: Forouzan, Appendix C
CSCI The UNIX System Editing files
In the last class… The vi basics command, input and ex mode
Presentation transcript:

Program Development Tools Programming Editors Many good editors for programming exist. Two are available most anywhere. -vi, emacs vi (pronounced “vee eye”) -Being able to use vi ensures that you will always have an editor available -vi is available on all unix systems, other editors are not. -no need to remove your fingers from the typing area of the keyboard -vi stays out of your way: no menus and short commands -you really only need to know about a dozen commands -Once those are mastered (30min), add to your repertoire -global replacement -split files vertically and horizontally copy and paste between multiple open files -”make program” and never leave the editor -vi help sites (Joy an Horton) - (fun way to waste time)

Program Development Tools Vi commands To begin editing a file: vi opens vi vi file_name opens vi on file_name To close vi: :q quit (it will query you if changes were made) :q! quit without save :x save and exit zz save and exit Writing a file: :w write out current file :w new_name write out current file as new_name :wq write file and quit (like “x” or “ zz) Read in a file: :r file_name Read in file_name into current one after the cursor

Program Development Tools Vi commands – Modes (input, command) Input Mode: Insert text: i insert text just prior to cursor Append text: a append text just after cursor Open line: o open a new line below the current one O open a new line above the current one Replace: r replace the character under cursor R replace continuously Exit input mode:

Program Development Tools Vi commands – Modes (input, command) Command mode: In command mode we do everything else moving around in the file -search and replace -yank (copy) and put (paste) -delete -split screens Command mode entered from input mode by You enter vi in the command mode.

Program Development Tools Vi commands – Modes (input, command) Moving around in the file: h move one character left l move one character right k move one line up j move one line down u move up one page d move down one page w move forward 1 word b move back 1 word $ move to end of line H move to line 1, column 1 G move to last line, column 1 :n go to line n

Program Development Tools Vi commands – Modes (input, command) Yank/paste, delete: yy yank current line p paste a line 8yy yank next 8 lines (a subsequent paste will paste all 8 lines) x delete character cw change word dw delete word dd delete current line (line goes in paste buffer) J join next to line to current u undo (multi-level repeat). repeat last command

Program Development Tools Vi commands – Modes (input, command) Search and Replace: /pattern search for pattern (forwards) ?pattern search for pattern (backwards) n repeat last search :%s/old/new/g replace every occurrence of old with new in entire file

Program Development Tools Vi commands – Modes (input, command) Multiple screens: :sp new_file open split screen with new_file displayed :vsp new_file open vertically split screen with new_file displayed ww move between screens wn split existing window wv split existing window vertically

Program Development Tools avr-gcc -One of the GCC cross compilers -Free, Open source, world class optimizing compiler -Runs on Linux, Solaris, Mac, PC -Available for almost any target uC/uP, -See AVR Freaks site for avr-gcc help ( uisp - Universal In System Programmer -Allows programming of AVRs through the parallel port avrdude - Another in System Programmer -Allows programming of AVRs through the parallel port or USB avr-objcopy -copies and translates object files avr-objdump -diplays information from object files

Program Development Tools: avr-gcc/avr-objcopy/uisp mycode.c uisp -dprog=stk200 -dpart=atmega128 -dlpt=/dev/parport0 –-erase –upload if=mycode.hex mycode.o mycode.el f mega128 avr-gcc -g -c -Wall -O2 -mmcu=atmega128 -o mycode.o mycode.c avr-objcopy -j.text -j.data -O -ihex mycode.elf mycode.hex mycode.h ex

Program Development Tools make To automate and simplify the process of making an executable image for the microcontroller we use the make utility make is the puppetmaster of your build environment. It... -checks file dependencies and compiles only the files that require it -executes other commands to generate other files (EEPROM images) -is very general purpose, it works with any language and other tools -lets us make one Makefile that can be used with many other programs In more complex programming environments, make is an excellent way to manage the creation of an executable from 10's or 100's of files.

Program Development Tools Makefiles make reads a file called “Makefile” or “makefile” that describes the dependencies and actions to take to generate the executable image. The syntax of a makefile rule is as follows: target-list: dependency-list command-list sr.o : sr.c avr-gcc -g -c -Wall -O2 -mmcu=atmega128 -o sr.o sr.c This rule tells make that: - sr.o is dependent on sr.c -if sr.c changes, sr.o must be recreated by running the avr-gcc command

Program Development Tools - make #a simple make file for sr.c PRG = sr all: $(PRG).elf sr.o : sr.c avr-gcc -g -c -Wall -O2 -mmcu=atmega128 -o sr.o sr.c sr.elf : sr.o avr-gcc -g -Wall -O2 -mmcu=atmega128 -Wl,-Map,$(PRG).map -o sr.elf sr.o sr.hex : sr.elf avr-objcopy -j.text -j.data -O ihex sr.elf sr.hex program : $(PRG).hex uisp -dprog=stk200 -dpart=atmega128 -dlpt=/dev/parport0 --erase -- upload\ if=sr.hex lst : $(PRG).lst sr.lst : sr.elf avr-objdump -h -S sr.elf > sr.lst clean : rm -rf *.o *.elf *.hex *.lst *.map a phony target dependancy with no command

Program Development Tools - make PRG = sr OBJ = $(PRG).o MCU_TARGET = atmega128 OPTIMIZE = -O0 # options are 1, 2, 3, s OBJCOPY = avr-objcopy OBJDUMP = avr-objdump CC = avr-gcc override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) override LDFLAGS = -Wl,-Map,$(PRG).map #The automatic variables make recognizes: # file name of target, i.e., left hand side of : # $< name of first prerequisite # $? name of all the prerequisites that are newer than the target # $^, $+ Names of all the prerequisites # all: $(PRG).elf lst text eeprom ####################################################################### # The dependency for 'all" is the program.elf and three other rules. # The target "all" is known as a "phony target" as it is not a file # but a name used to have "make" do something for you. #######################################################################

Program Development Tools - make $(PRG).elf: $(OBJ) $(CC) $(CFLAGS) $(LDFLAGS) -o $^ ########################################################### # Make understands that to make an.obj you compile a.c # Thus we only need to say we want a.elf from an.obj # is make shorthand for left hand side of ":" # $^ is make shorthand for right hand side of ":" ########################################################### clean: rm -rf *.o $(PRG).elf *.lst *.map ########################################################## # The target "clean" is another phony target that cleans # up all the extra files we make at each compile. ########################################################## program: $(PRG).hex uisp -dprog=stk200 -dpart=atmega128 -dlpt=/dev/parport0 \ –erase --upload if=$(PRG).hex ########################################################## # Target "program" depends on the.hex file which it # downloads to the target board using the parallel port. ##########################################################

Program Development Tools - make lst: $(PRG).lst %.lst: %.elf $(OBJDUMP) -h -S $ ############################################################ # The target "lst" is another phony target. Its depends # on the.lst (list) file. The list file shows the # assembly language output of the compiler intermixed # with the C code so it is easier to debug and follow. # avr-objdump ($OBJDUMP) is the avr binutil tool we us to # get information from the.elf file. # # $< is shorthand for source file for the single dependency ############################################################

Program Development Tools - make ############################################################ # Following are rules for building the.text rom images # This is the stuff that will be put in flash. ############################################################ text: hex bin srec hex: $(PRG).hex bin: $(PRG).bin srec: $(PRG).srec %.hex: %.elf $(OBJCOPY) -j.text -j.data -O ihex $< ########################################################## # Take any.elf file and build the.hex file from it using # avr-objcopy. avr-objcopy is used to extract the downloadable # portion of the.elf file to build the flash image. ########################################################## %.srec: %.elf $(OBJCOPY) -j.text -j.data -O srec $< #Make the Motorola S-record file %.hex: %.elf $(OBJCOPY) -j.text -j.data -O binary $< #Make a binary imagae also

Program Development Tools - make ########################################################## # Following are rules for building the.eeprom images # This is the stuff that will be put in EEPROM. ########################################################## eeprom: ehex ebin esrec ehex: $(PRG)_eeprom.hex ebin: $(PRG)_eeprom.bin esrec: $(PRG)_eeprom.srec %_eeprom.hex: %.elf $(OBJCOPY) -j.eeprom --change-section-lma.eeprom=0 -O ihex $< ################################################################# #This builds the EEPROM image from the.elf file for downloading. ################################################################# %_eeprom.srec: %.elf $(OBJCOPY) -j.eeprom --change-section-lma.eeprom=0 -O srec $< ################################################################ #This builds the S-record image from the.elf file if necessary. ################################################################ %_eeprom.bin: %.elf $(OBJCOPY) -j.eeprom --change-section-lma.eeprom=0 -O binary $< ############################################################ #This builds a binary image from the.elf file if necessary. ############################################################