2014年10月28日星期二

PSoC bootloaders ZZ

eewiki.net/display/microcontroller/PSoC+Bootloaders#PSoCBootloaders-HowBootloadersWork

Creating PSoC Bootloaders

Cypress makes it very simple to create bootloader programs.  This section will walk through the process of creating a bootloader application in PSoC Creator 3.0 for PSoC 3, 4, and 5LP devices.  PSoC Creator 3.0 can be downloaded for free here.
  1. Open PSoC Creator 3.0.
  2. Navigate to File -> New -> Project.
  3. Select Empty PSoC 3, 4, 5LP Design - whichever device family you are using.
  4. Type a descriptive name for your bootloader program in the "Name" field.  I usually indicate which device family I'm using, which serial port I'm using, and the fact that it's a bootloader.  i.e. PSoC4_UART_Bootloader
  5. Browse to whatever directory you wish to save the project in.
  6. Click the '+ Advanced' button.
  7. Select your specific device.
  8. Select "Bootloader" as the application type and click 'OK'.
  9. PSoC Creator should bring up the schematic view.  If not, double click "TopDesign.cysch" from the Project Explorer window.
  10. From the Component Catalog, drag the desired communication port for your bootloader into your design.  For example, if you would like a UART-based bootloader, click and drag the UART component into your design.
  11. Double-click on your component after it has been added to the design to configure it.  Name it whatever you would like and setup your desired communication settings.  For a UART, you will need to verify the baud rate, number of data bits, parity type, number of stop bits, and flow control setting.  You will also need to change the RX and TX buffer sizes to 64 bytes if using UART.  If using I2C, you'll need to use an I2C Slave component.  You'll need to verify the slave address and data rate.  You can use any serial com you would like, or create your own custom serial com.  However, that is out of the scope of this page.  Apply any changes and click 'OK'.
  12. From the Component Catalog, drag a Bootloader component into your design.
  13. Double-click on the Bootloader to configure it.  Name it whatever you'd like.  Your com port should be available in the Communication Component drop-down.  The Wait Time defines how long the bootloader will wait for the start signal from the Host before passing control to the application program.  Multi-application bootloader is out of the scope of this page.  Every other option can be set however you wish.  I usually leave default settings.  Apply any changes and click 'OK'.
  14. Open the .cydwr file for your project from the Project Explorer window.  Assign physical pins to your communication port.  Save and close the .cydwr file.
  15. Open the main.c file from the Project Explorer window.  Nothing needs to be changed in main.c for the bootloader to function properly.  You could light up an LED before starting the bootloader, if you wish, but for a simple bootloader program, main.c can be left alone.
  16. Save and build the project.  This will create bootloader .hex and .elf files and in the Debug folder of your project directory.  These files are necessary for your Bootloadable application.
    • For PSoC3 devices, they will be in your project directory under <project name>.cydsn -> DP8051 -> DP8051_Keil_9xx -> Debug. 
    • For PSoC4 devices, they will be in your project directory under <project name>.cydsn -> CortexM0 -> ARM_GCC_4xx -> Debug. 
    • For PSoC5 devices, they will be in your project directory under <project name>.cydsn -> CortexM3 -> ARM_GCC_4xx -> Debug.
  17. Program the bootloader to your device like you would normally program a PSoC device using Debug -> Program from within your bootloader project.  You can also use PSoC Programmer to program your device.
Congratulations!  If you completed all of these steps, you just created and flashed a bootloader to your PSoC device!  Give yourself a pat on the back...but not too hard.  We don't need anybody getting hurt.  We haven't even used our bootloader yet!  Now we need to create a Bootloadable application.

Creating PSoC Bootloadable Applications

Cypress makes it very simple to create a bootloadable application from scratch.  This section will walk through the process of creating a bootloadable application in PSoC Creator 3.0 for PSoC 3, 4, and 5LP devices.
  1. Open PSoC Creator 3.0.
  2. Navigate to File -> New -> Project.
  3. Select Empty PSoC 3, 4, 5LP Design - whichever device family your are using.
  4. Type a descriptive name for your bootloadable program in the "Name" field.  I usually type my application name preceded by which device family I'm using, which serial port I'm using, and the fact that it's bootloadable.  i.e. PSoC4_UART_Bootloadable_TempSensor.
  5. Browse to whatever directory you wish to save the project in.
  6. Click the '+ Advanced' button.
  7. Select your specific device.
  8. Select "Bootloadable" as the application type and click 'OK'.
  9. PSoC Creator should bring up the schematic view.  If not, double click "TopDesign.cysch" from the Project Explorer window.
  10. Click and drag a Bootloadable component into your schematic from the Component Catalog.  Double-click the Bootloadable to configure it.  The General tab can be left alone.  Under the Dependencies tab, you will need to map the project to the bootloader .hex and .elf files you previously created.
  11. At this point you should develop your program exactly as you would any other PSoC application.  Add any components you need for your design and develop firmware in main.c as you normally would.
  12. Save and build your bootloadable program.  Just like any normal PSoC project, building will create a program .hex file in the Debug folder of your project directory.  However, for a bootloadable project, a .cyadc file will also be generated.  This is the file needed by the Bootloader Host application that actually uploads the device firmware using your bootloader.
    • For PSoC3 devices, the .cyacd file will be in your project directory under <project name>.cydsn -> DP8051 -> DP8051_Keil_9xx -> Debug. 
    • For PSoC4 devices, the .cyacd file will be in your project directory under <project name>.cydsn -> CortexM0 -> ARM_GCC_4xx -> Debug. 
    • For PSoC5 devices, the .cyacd file will be in your project directory under <project name>.cydsn -> CortexM3 -> ARM_GCC_4xx -> Debug.
Cheers! If you completed all of these steps, you just created a bootloadable application that can be uploaded to your device using the bootloader that you already programmed to memory.  Now we need to upload the bootloadable program using Bootloader Host.

Using Bootloader Host

Bootloader Host is included by default in the PSoC Creator installation.  You can use this application to upload PSoC bootloadable programs to a PSoC device containing the mapped bootloader program.  This section will walk through the process of uploading a bootloadable application using Bootloader Host. 
Bootloader Host supports numerous serial communication protocols.  However, keep in mind, you will need to physically connect the target device to the PC somehow.  In many cases, the only connectivity options on a PC are USB or RS232.  You may need some sort of bridge device to actually connect your target to the PC.
USB / UART Bridges:
    • TTL-232R-3V3:  This is a USB to 3.3V TTL bridge cable from FTDI.  If your bootloader uses UART, this can be used to connect the UART of your target to the USB port of a PC.
    • CYUSBS232:  This kit contains a USB to RS232 bridge device that can be used to connect your target to the USB port of a PC if your bootloader uses UART.
USB / I2C Bridges:
    • CY8CKIT-002:  Miniprog3 can be used as a USB to I2C bridge if your bootloader uses I2C.
    • CY3240-I2USB:  This kit contains a USB to I2C bridge device that can be used to connect your target to the USB port of a PC if your bootloader uses I2C.
    • If using the PSoC4 Pioneer Kit, the on-board PSoC5LP device can be used as a USB to I2C bridge device (no external bridge device needed for bootloading).

2014年10月14日星期二

Books for Embedded System Developers ZZ

http://www.ganssle.com/bkreviews.htm

Here's links to various reviews of books useful to embedded system developers. They cover subjects from firmware development to hardware. First, one shameless plug - I've written a half dozen embedded books myself. More here.
Suggestion: Subscribe to my free newsletter which often has reviews of books about embedded systems.
Agile Estimating and Planning, Mike Cohn - Valuable for anyone building software.
Balancing Agility and Discipline, Barry Boehm and Richard Turner - Agile or more disciplined?
Bebop to the Boolean Boogie, Clive Maxfield - A fun and interesting digital design book.
Better Embedded System Software, Phil Koopman - An essential introduction to all areas of building embedded systems.
Building Parallel, Embedded, and Real-Time Applications with AdaJohn McCormick, Frank SInghoff and Jerome Hugues - One of the best books on using Ada effectively in building embedded systems.
CMMI Survival Guide, Suzanne Garcia and Richard Turner - One guide to CMMI.
Computer Approximations - The best book on approximations ever. Hart's classic book is a "must have"... if you can find it.
Debugging, David Agans- A well written, quick read packed with war stories. Every new grad should read this.
Digital Apollo, David Mindell - An exploration of the relationship between human and computers.
Embedded Ethernet and Internet Complete, Jan Axelson - A good "how to" description of building internet-aware applications.
Embedded Linux Primer, Christopher Hallinan - A Practical Real World Approach- A book about putting the OS into firmware.
Embedded Systems Building Blocks, Jean LaBrosse - If you believe in reuse, well, here's stuff to reuse! Also has his firmware standard.
Embedded Systems Design, Arnold Berger - A great intro to the embedded world, with a focus on tools. Also has good hints on selecting processors.
Embedded Systems Security, David and Mike Kleidermacher - Practical methods for safe and secure software systems development.
An Embedded Software Primer, David Simon - One of the best introductory books to embedded development around.
Embedded Systems Design using the Rabbit 3000 Microprocessor, Kamal Hyder and Bob Perrin. - Required reading for users of the R3000, and a pretty darn good introduction to the entire realm of embedded systems development as well.
Extreme Programming Explained, Kent Beck - XP is garnering waves of adherents. A very good intro to the ideas and practices.
Extreme Programming Refactored, Matt Stephens and Doug Rosenberg - An infuriating but enlightening expose of eXtreme Programming.
Feature-Driven Development, A Practical Guide to, Stephen Palmer and John Felsing - A development methodology that is much more suited to most embedded efforts. Highly recommended.
The GE Transistor Manual. Everything about transistors, in the 1960s at least. A fascinating and fun book for EE history buffs.
Guidelines for the Use of the C Language in Vehicle Based Software, by MISRA - This is a list of dos and don't dos for writing reliable C code. Not a book per se, but a hundred page list of rules.
Ham Radio for Dummies, by Ward Silver - A great introduction for the newbies to the fascinating world of ham radio.
Hands-on XBEE Lab Manual, Jonathan Titus - Experiments that teach you XBEE wireless communications.
High Integrity Software, John Barnes - A fascinating description of the SPARK programming language.
High Speed Digital Design, Howard Johnson and Martin Graham - The best book around about high-speed issues.
How Computers Do MathClive "Max" Maxfield and Alvin Brown - All about the essential workings of computers.
If I Only Changed the Software, Why is the Phone on Fire, Lisa Simone - A fast paced book, interweaving software and hardware.
Introduction to the Personal Software Process, Watts Humphrey - All about the Personal Software Process.
MATH Toolkit for Real-Time Programming, Jack Crenshaw - If you're building approximations, or trying to learn about fixed-point math, this is your bible.
MicroC/OS-II, The Real Time Kernel, Jean Labrosse - The best book on real time operating systems.
MSP430 Microcontroller Basics, John Davies - A great book for novices, as well as experienced developers.
uC/OS-III, The Real-Time KernelJean Labrosse - An entirely rewritten version of a classic.
Peer Reviews in SoftwareKarl Wiegers - The most readable book on code inspections.
PeoplewareDeMarco and Lister - Perhaps one of the most important books written about being more productive in a software environment.
Principles of Software Engineering Management, Tom Gilb - An interesting book that's essential to anyone planning to manage a software project.
Programming Embedded Systems in C and C++, Michael Barr - A very good intro book, with a focus on the 186 processor.
Real-Time Embedded Multithreading Using ThreadX and MIPS, Edward Lamie - A very organized book with lots of well written code that lends to an excellent presentation of the subject.
Real-Time UML Workshop for Embedded Systems, Bruce Powel Douglass - A precise and engaging, humorous at times book, yet clearly focused on getting complex ideas across.
Serial Port Complete, Jan Axelson - A very complete reference to serial communications.
Software Inspection, Tom Gilb and Dorothy Graham - THE book on code inspections.
Software Inspection - An Industry Best Practice, IEEE Collection - A good series of papers on software inspections.
Statistics in a Nutshell, Paul A Watters and Sarah Boslaugh - an ideal self study book, one of the best.
TCP/IP Lean, Jeremy Bentham - An intro to TCP/IP.
Test Driven Development, by Kent Beck - Kent Beck's view of building the system by producing tests first - Flawed but interesting.
Test Driven Development for Embedded C, James Grenning - hands down, the best book written on the subject.
The Art of Designing Embedded Systems, Jack Ganssle - How to go about building an embedded system, from process issues to tech ideas.
The Art of Programming Embedded Systems, Jack Ganssle - This book is now all but out of print.
The Definitive Guide to the ARM Cortex-M3, Joseph Yiu. A good intro to the very popular Cortex-M3.
The Digital I/O Handbook, Jon Titus and Tom O'Hanlan. A great introduction to a tough subject.
The Elements of Style, William Strunk and E. B. White - If your comments are lousy, so's your code. Here's a short classic about writing decent comments and prose.
The Embedded Systems Dictionary, by Jack Ganssle and Michael Barr - The only single-source of definitions of words used in our industry.
The Existential Pleasures of Engineering, Samuel Florman - If you enjoy the philosophy of engineering, you will like this book.
Understanding and UsingC Pointers, Richard Reese - A surprisingly worthwhile new book on using C pointers
USB Mass Storage, by Jan Axelson. The definitive guide to building memory systems using USB.
When Computers Were Human, David Alan Grier - Computers used to be flesh and blood.
Writing in Software Developmentby Al Stavely. How to create great docs with your code.