Saturday, July 30, 2011

volatile variable

One of lesser known but important concept, which people usually encounter during the interviews is, what is a Volatile variable? I was asked this question directly or indirectly at many interviews. Initially I kind of knew what it meant but didn't know in details. But then I decided to dig in details and figured out how exactly it compiler make changes for a volatile variable.


First some resources from the web,

The colin walls blog (http://blogs.mentor.com/colinwalls/blog/2009/08/31/volatile/),

There is one feature of C/C++, that is often not well understood, but is a godsend to embedded programmers: the keyword volatile …

When you declare a variable/object volatile, you are telling the compiler not to optimize access to the data. When your code writes a value to the variable, it should be written straight away and not saved in a register for use later. Likewise, when the code reads the value, it should not use a copy that was obtained earlier.

Broadly speaking, it must be assumed that a volatile variable can change at any time, independently of the current code. This implies two uses: variables that are shared between execution threads [between tasks in an RTOS or between the mainline code and an interrupt service routine]; I/O device registers.

Although volatile is a useful language facility, it is not without difficulties. Firstly, some research has shown that many compilers do not implement the keyword correctly in all circumstances. So care and attention to generated code is required. There are also the usual troubles with C syntax; consider these:

volatile int* pi1 = 0; // pointer to volatile int
int* volatile pi2 = 0; // volatile pointer to int
volatile int* volatile pi3 = 0; // volatile pointer to volatile int
Plenty of room for errors there! [The same syntactic issues arise with const.]

However, just declaring a variable volatile is not enough if you are sharing it between execution threads [even if there are texts that suggest that this is the case]. To illustrate the problem, consider this code:

volatile x = 1;
...
x++;
Syntactically this is fine, but what about the generated code? If the CPU instruction set allows a memory location to be incremented directly with a single, non-interruptible instruction, there is no problem [so long as the compiler uses those instructions!]. But many devices would require the data to be read, incremented and written back. This is all fine according to the language definition, but what if an interrupt occurs during this sequence of instructions?

You need to protect access to it so that the memory location always contains a valid value. You could do this by disabling and re-enabling interrupts or, with an RTOS, maybe a semaphore would be the answer.


I had to re-read this multiple times to understand what exactly it means. So when we define a variable volatile,

-> We are telling compiler to do always read that variable from memory, it should not do any optimization like storing in a register or optimize the code assuming it being a deadcode.

-> volatile is not storage specifier, i.e. it doesn't specify where the variable would be stored.

-> volatile can not control the way the caching is done in the system. Caching is controlled by the way we define in the pages in page table during linking stage.

Monday, May 30, 2011

Reverse Engineering Firmware

Stumbled upon this excellent detailed article on Reverse engineering firmware for Linksys WAG120N,

http://www.devttys0.com/2011/05/reverse-engineering-firmware-linksys-wag120n/

This article describes in detail how to use linux tools such as hexdump, strings, binwalk to reverse engineer the firmware. A very nice read.

Sunday, May 1, 2011

Embedded Systems: UCSC Silicon Valley extension



I came across this nice certificate course on Embedded Systems at UCSC, the course structure seems to cover all aspects of embedded system design and especially tuned for working professionals. 

The comprehensive program at UCSC Extension will equip you with the hands-on experience and practical know-how to fully master embedded design. Instruction is geared to working professionals in a wide variety of fields, including:
  • Hardware design--system architecture, board design, FPGA, and SoC
  • Software development--real-time embedded programming, Linux-based systems
  • Digital signal processing--DSP and DV--and image processing
  • Mobile device design and programming
  • Interface protocols and design techniques

Friday, April 29, 2011

Embedded Systems: Capstone Project course at Carnegie Mellon


One of the interesting project based course on Embedded Systems at Carnegie Mellon. The idea is that during the course of the entire class, student in a team of four generally, develops a working prototype of a system. Checkout the various cool videos of the courses demos at Youtube channel, http://www.youtube.com/user/EmbeddedSystemsCMU

Monday, February 14, 2011

Greetings from Bay Area

I have completed my MS from Carnegie Mellon and started with new job as Firmware Engineer in the Bay area. I plan to update this blog in coming days with lots of new content. Stay tuned.

Sunday, July 12, 2009

Embedded Systems at Microsoft Research

I was looking for what kind of work is being done in the areas of Embedded Systems at Microsoft, and I found one group specifically working in the areas of Embedded Systems and Reconfigurable computing.

Research overview at Embedded Systems group at MSR;

Overview

Our work in Embedded Systems covers both the system software and the hardware platform issues.

System software is long lived and hard to develop.

  • How can we make computers and consumer electronic devices less helpless and needy of detailed instruction?
  • How can we build predictable systems out of a mix of real-time and non-real-time entities?
  • How can we trust the computers and how can they trust us? But keep our privacy, lifestyle, safety, and convenience?
  • What are the programming paradigms that simplify the programmer's tasks without undue overheads?
  • How can we verify that software behaves as expected and adapts to a changing environment?
  • How do we structure software for resource-constrained environments, while maximizing portability, reuse, and sharing?

Embedded hardware is diverse and forever changing.

  • How can we realize more stable platforms without raising costs and complexity?
  • What can we do to increase ease-of-use, especially for verification, debugging and performance tuning?
  • How can we shorten the development and testing time for new systems?
  • How can we best use reconfigurable hardware to execute software more efficiently?
  • What are the best ways to exploit the functionality and the efficiency of reconfigurable computing?
Link: http://research.microsoft.com/en-us/groups/embeddedsystems/

Wednesday, July 8, 2009

Education in Embedded Systems – 2

MSc and MAS (Master of Advanced studies) in Embedded Systems courses are offered at ALaRI (Advanced learning and research institute), Switzerland.

This is another place in Europe which offers specific education in Embedded Systems (the first one being TU Delft, read here for more info). It offers virtually every courses on Embedded Systems and there are many courses which I found only at ALaRI. And good part is that best professor and experts in the area comes and teaches you that subject. In this post I would cover on MSc course at ALaRI.

Course Overview:
Duration: 2 years (120 EC)
Approximate cost for one year: Tuition 8000 CHF (around 5300 Euro) and Living expenses 7000 CHF (around 4600 Euro)

Master project takes up 35% of 2years and remaining time is spent in Courses, seminars and other lab assignments.

Courses offered:
The following list contains only selected few courses offered, for list of all courses visit ALaRI homepage.

1. Architectures by M.G. Sami Politecnico di Milano, Italy
2.
Software Compilers by S. Crespi Reghizzi Politecnico di Milano, Italy
3.
Transforms Theory by A. Danani SUPSI Lugano, Switzerland
4.
RTOS and Scheduling by L. Thiele ETH Zurich, Switzerland and M. Platzner University of Paderborn, Germany
5.
Specification Languages by R. Lauwereins IMEC, Leuven, Belgium and M. Engel's FMTC, Belgium
6.
Digital Signal Processing by M. Moonen IMEC, Leuven, Belgium
7. Embedded processor design and implementation by R. Leupers, Aachen University of Technology
8.
VLIW Architectures by P. Faraboschi HP Labs Cambridge, USA
9. Microelectronics by C. Piguet CSEM, Neuchatel, Switzerland
10. Performance Evaluation by G. Serazzi Politecnico di Milano, Italy

Personally I like the course content very much and would like to cover many topics from it during my masters. If you are interested in higher studies in Embedded Systems, then ALaRI should be in your list of colleges to apply. Also you don't need GRE or TOEFL for application and there is no application fee !

Links:
1. ALaRI home page: http://alari.ch/
Browse through above page, very informative.

2. Student experience at ALaRI. Edulix thread: http://www.edulix.com/forum/showthread.php?tid=69510
You would require registration on Edulix before reading.

Training done at Conexant Systems

After completing my engineering from NIT, Trichy I joined as Software Engineer at Conexant Systems , Hyderabad Aug 2007. I was very happy about getting through Conexant as I knew the job would be challenging and provide me with plenty of new learnings.

About fifty odd freshers joined in Software domain at Conexant and there was proper training planned for us (they must have put a lot thought in design of the training content). It gave us very good idea on Embedded Systems, virtually covering all the topics in the area. I would say I was lucky to go through this excellent training, which provided me great platform to start off with my professional career.

It covered following aspects,

1. Effective Programming using C:
Topics covered: Basic programming; data structures such as arrays, linked list, graphs and trees; algorithms for sorting, searching and some graph algortithms; and a lab on all topics covered in theory.

Essentially it was similar to Data structures and Algorithm course done during engineering, but it was nice to revise again.

2. Embedded Systems Programming:
Topics covered: Intro to Embedded systems; Basics of RTOS; Software tools such as debugger, linker, compiler; Object file formats and how to make sense of it; OS Internals and drivers; Designing a Real time system, design modules and a Case study.

This was the best training session, as you would see it covers all the important topic in Embedded System programming. Many things learned from this training which are still useful.

3. ARM Architecture:
Topics covered: Intro to RISC, overview of ARM architecture, Thumb instruction set, Interrupts in ARM, Caches and memory mapping etc.

This was another very good training, Embedded engineer must know about ARM architecture as it is most widely used in industry. I liked the concepts of Thumb instruction set and instruction decoding in ARM.

4. Linux Kernel Internals:
Topics covered: All the chapters from book Linux Kernel Development by Robert Love

I had good idea of Linux kernel before joining Conexant, but this session cleared all the doubts and gave a good overview of writing a device driver for Linux. Must buy / read book by Robert love.

5. Socket Programming:
Topics covered: This session gave overall idea about networking and how one can write socket in C.

6. Introduction to Testing:
Topics covered: This session gave idea about how testing fits into large picture, why testing is very important, and made sure that engineer does not neglects testing and considers them as important as development.

There were some sessions by HR on topics Assertive communication and team building exercise. Some good videos were shown for Assertive communication techniques such as fogging, broken record, Negative inquiry etc. Communication is as important as technical skills in industry (which many times people tend to neglect), and one has to improve upon it constantly.

Thursday, July 2, 2009

Excellent web resourses on Embedded Systems

While browsing over the year, I found following very useful resources on Embedded systems. Following is the first list of them, would carry upon this in subsequent future posts. If you also come across any other resources, post it on comments.

1. Artist group, which is EU Network of excellence on Embedded Systems design
Home page: http://www.artist-embedded.org/artist/-Home-Page-.html
Browse through the above link, you would find many journals, articles and can understand the way research in Embedded Systems is moving forward.

Especially I found this collection videos and slides, of their Summer school held at France in 2008 very useful.
http://www.artist-embedded.org/artist/Videos-of-the-Presentations.html

2. ACM Transaction on Embedded Systems, special issue on education in this domain
http://portal.acm.org/toc.cfm?id=1086519&idx=J840&type=issue&coll=portal&dl=ACM&part=transaction&WantType=Transactions&title=TECS&CFID=53496696&CFTOKEN=70868022

The papers on education at Berkely or Carnegie Mellon are very informative. It would build your perspective on what kind of skills are necessary and how the education in this area can help.

3. Dedicated Systems Encyclopedia
http://www.realtime-info.be/Encyc/

4. Linden H McClure, Professor at University of Colorado Boulder
http://ecee.colorado.edu/~mcclurel/

Professor home pages are always a great resource for any students, you can find out more about course they are taking, links to slides, published papers etc. Especially I found Prof. Linen's home page very useful, it contains various data sheets, links to course slides and other very useful info related to Embedded Systems.

5. Digital Electronics blog
http://digitalelectronics.blogspot.com/

It is a TECHlog on VLSI, Chip Design, Industry News, Opinions, Reviews & much more...
If you are interested in VLSI or Chip design then you would find many resources on the above blog, check out your self.

Thats all for now, many more ideas to write a post upon, would update soon.

Wednesday, July 1, 2009

Top 20 Semicondutor companies

Knowing about major players in the market is always a good things, it helps to understand how industry is moving, which are the growth areas and then people can decide upon which domain they want to specialize. Following table from ICInsight summarizes trends in Semiconductor space for year 2008.




Some analysis:

1. Wireless is still hot with Broadcomm and Qualcomm showing highest growth for the year, Thanks in part to declining TI's share.

2. Intel still remains at top by a huge margin, also it wasn't affected much by slowing consumer demand in PC segment.

3. All DRAM suppliers suffered huge decline, Hynix of South Korea topping charts with 33% decline.

Link: 53-Point Growth-Rate Delta Within 2008 Top 20 Supplier Ranking http://www.icinsights.com/news/bulletins/bulletins2009/bulletin20090302.html

Tuesday, June 30, 2009

Thoughts on System Architecture

System:

A system is defined as a set of different elements so connected or related as to perform unique function not performable by the elements alone

Architecture:

The term ‘architecture’ is widely understood and used for what it is – a top down description of the structure of the system

- System Architecture definition by Eb Rechtin

System Architect is one of the crucial jobs in embedded industry and to reach there one should have various skills required apart from solid domain level skills. The essay (link below) by Dr. Koopman covers in detail the core competency required to become System Architect, they are as follows

  1. Must have an appreciation for the full breadth of complexity in the lifecycle of a system.

This would require years of experience working in various domains within a system and only then one can appreciate inherent complexities.

  1. Must have experience/knowledge of the strengths and weaknesses of various architectural approaches as well as ways to combine them.

This could be learned by knowing various approaches and should know when one can be used in particular system.

  1. Must have the ability to cope with significant amounts of complexity while creating or modifying architecture.

This is also very difficult skill to learn, would require working knowledge of various tools and to help deal with complexity.

  1. Must be able to articulate the essence of particular system architecture to others.

System Architect role is a of a leader, and excellent communication skills are expected from him. He should sell his vision and idea to the team, customers and all the stakeholders.

  1. Must be able to deal with systems that are evolved/composed rather than designed from scratch.

This is important as many of the systems or products are getting evolved, no one is designing everything from scratch.

  1. Must have good “taste” to create a “clean” architecture that scales well and ages gracefully in the face of unforeseeable changes.

Sometime the need comes to design entire thing from scratch, and here he has to play a crucial role.

Link:
1. Essay by Dr. Philip Koopman http://www.ece.cmu.edu/~koopman/system_architecture/00_04_system_architecture.pdf

Monday, June 29, 2009

Education in Embedded Systems - 1


MSc in Embedded Systems at Delft University of Technology (or TU – Delft)

TU – Delft is one of the college which offers MSc in Embedded Systems. The course is jointly offered by three Dutch universities; TU Delft, TU Eindhoven and TU Twente, and it’s called as 3TU program. I liked the course structure and it’s designed with a lot of thought into why there should be a separate course on Embedded Systems at first place.

The main reason for having a separate course on Embedded Systems is that in ES field an engineer is required to posses system level skills in a wide range of disciplines such as computer science, electrical engineering, real –time computing, system architecture, control engineering, signal processing, security and privacy, computer networking, mathematics, hardware, sensors and actuators. Thus to create these multidisciplinary skills it requires fundamental change in education and ES course emerged.

Course Overview:
Duration: 2 Years (120 EC)
Approximate cost for one year: Tuition Fees: € 8600 and Living expenses: € 7750

Few stages in the course,
1. Homologation
This phase is prerequisite phase, here a student from Electrical background can take CS courses and vice versa.

2. Compulsory courses
Total of 30 EC (European Credits defined through European Credits Transfer System ECTS) been allotted to 6 core courses.
a. System Validation (formal methods, model checking)
b. Software testing and Quality Engineering (testing in large Embedded Systems)
c. Real time systems
d. Performance Analysis (performance modeling of computation and communication)
e. Embedded Systems
f. Embedded Computer Architecture (contemporary embedded processor, microcontrollers)

I think the design of the course is such that it covers mainly all important areas of ES. The courses on System Validation and Testing are very important as Testing and Validation consumes around half of the resources in development life cycle.

3. Specialization
There are various tracks in which student can specialize, which are
a. Embedded Software
b. Embedded Computer Architecture
c. Embedded Circuits and Systems
d. Embedded Networking

4. MSc Thesis
And finally there is MSc thesis which is of 40 EC, which can be done either in industry or in academia.

3TU Program:
As the MSc program is jointly offered by three universities, a student joining either of the college automatically gets admitted to other two universities. The core structure of course remains same at each university but the research focus is different at each of them.

For example, Delft has more focus on Embedded Software and System level engineering rather than component level engineering which is usually done in Computer Engineering courses.

Personal Comments:
1. The course content is excellent, hard to find similar course any where in the world (believe me). From industry perspective it covers all the required subjects would help to develop a System level skills.
2. For research work, the computer engineering dept at Delft offers many projects especially in the areas of Reconfigurable computing. Also one can look at Embedded Systems Lab (ESL) at TU / e.
3. Delft is one of biggest and oldest engineering schools around and a member of prestigious IDEA group. As it’s the advantageous with all big schools, here at Delft too student can look forward to work with Aerospace dept on new satellite project (similar to Delfi) or Software engineering dept to work on Static code analyzers. Thus for a student interested in Core engineering, this is the place I would say.

Finally If any one is interested in Embedded Systems and wants to pursue higher studies in this area then this is one college not to miss applying for. Fortunately I knew about this course and I applied and received an admit too. For more information go through the links below.

Links:
1. Official site of ES dept:
http://www.tudelft.nl/live/pagina.jsp?id=11b86a67-fc3e-4daa-81e9-a1cbbda52847〈=en
2. Delft curriculum on Embedded Systems:
http://www.st.ewi.tudelft.nl/~gross/Publications/Gross_2006_WESE.pdf
3. TU Delft- Detailed Costs for M. Sc. 2009-2011:
http://spreadsheets.google.com/pub?key=pwxvvhp3oPpVQj1pMlcJxLg&gid=1
4. 3TU Course site:
http://www.3tu.nl/en/education/embedded_systems/
5. IDEA league site:
http://www.idealeague.org/