Introduction to driver programming [closed] - c

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
Driver programming is one of those things that I wanted to at least have an idea about for quite some time, but whenever I had some time to spare at my hands and sat down for research, I almost exclusively found very special questions about the matter or very broad introductions.
Now I do understand that it is not a trivial topic, but I personally learn best from sitting down and doing stuff. Therefore, I hope that you can give me a few pointers where to start. So, for the sake of a hands-on approach, consider the following scenario: I have a Raspberry Pi at my hands and want to utilize the GPIO pins as a serial port. (I'd love to hear other suggestions if you believe this is to complex for a starter's project. It's really more for the sake of doing it, the result is secondary). So the Pi runs Debian wheezy, and that's where I start from.
Given this, what do I need (software-wise) to get started? Specifically I am asking for the following:
Which compiler do I use?
Apart from the compiler and a text editor, do I need more tools?
Is there a some kind of scheme that I could copy to get started?
Do you maybe know of a great introduction that I just haven't had the luck to come across? I found that recorded lectures can be extremely helpful, and I would absolutely be willing to sit through a full course if that gets me started.
Do you know of a project simple enough for a beginner to learn from it by reading the sources on e.g. github?
And finally, am I totally on the wrong track? I might well be; I have been programming for quite some time, but usually in the high abstraction levels that languages with runtimes provide. I do have some experience regarding C++ programming and pointers aren't black magic to me, but I am not on very familiar ground here.
Also, if a blatant lack of understanding of drivers speaks out of this post, please point it out to me.

I never wrote a full fledged driver for a specific hardware, but I've gone through some basics in driver programming.
If you're into linux, before getting into driver programming you need to know what are drivers..? types of drivers..? how are drivers inserted as modules in kernel..? Here is the link. There is a basic abstract how to insert a driver or how to remove a driver from kernel and lot more.
There are video tutorials in youtube.
After you get enough stuff here, go through the LDD Book(Very nice book for beginners) as suggested by Joe.
Here's some more..
character driver example.
you may also wanted to know about kernel compilation, which is an intresting and important topic before starting driver programming, understand static and dyanamic(loadable) drivers.

You're in Linux, so what you have already installed (or available to install) should be enough to build with - a modern C compiler and make system, along with a decent editor. You even get a debugger capable of debugging both user and kernel space code - gdb & kgdb. Depending on what hardware you're tinkering with you may need something to look at what it's doing.
As for an introduction to drivers, there's two aspects you're asking about here. 1) O/S specific driver models, for Linux - start here: Linux Device Drivers and if that makes no sense to you, you know you need to go back a step and get some more basics down! 2) General aspects of h/w and terminology. I'm not sure of a good general resource here.
One final thing, C++ is not C, which is also not assembler which is also not machine code. At the level of battling hardware into life, you start having to know about the dirty secrets below the abstractions you normally use. There's plenty of information around about this sort of stuff but that's sort of the problem, there is a LOT to know. You could try Ulrich Dreppers article about memory, What Every Programmer Should Know About Memory, or you could look into what goes on with pre-emption and multi-tasking. Or you could look at datasheets for the hardware you're looking to control. There's plenty out there.
You've asked an incredibly general question, I'm surprised it's not been closed, however come back here when you've got stuff going and you have some specific questions to ask!

Related

How to convert an Arduino sketch into a C file in Code::blocks? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
How to convert an Arduino sketch into a C file in Code::blocks?
I don't know why this industry (Embedded Systems) is so poor in documentation. Everybody told me that in this field there are a lot of documentation to read... fine... I know for datasheets, but for some little code conversion (Arduino sketch to C in Code::blocks) I can't find even 1 example to see how it works...
Although this might be more of a comment I'd like to use an answer hoping that my "comment" answers your question.
don't know why this industry (Embedded Systems) is so poor in
documentation.
That is not true. Documentation of hard and software for embedded systems is very well documeneted. The manuals for Atmel AVR MCUs that power most of the Arduino models is excellent.
Converting Arduino sketches to Code::Blocks is a very special project. It is not surprising that you won't find a complete working tutorial on it.
Rather learn how to use Code::Blocks, how Arduino works and how to program AVRs from scratch. You'll find a ton of tutorials/resources on that. Then you combine that knowledge to your project. (that's a good approach to pretty much any problem you'll face in life. break it down)
There is also a vibrant and very kind community. All you need to do is show that you actually did some own work and you'll be overwhelmed with support.
Arduino is aimed at people with zero to little programming experience. Their takes away most hard work and thinking. You don't have to read 400 page manuals and manipulate registers on bitlevel to get a LED to blink or a motor to turn. You just call a few functions and that's it.
It uses some simplified C++ dialect and a lot of libraries and convenience stuff behind the curtain to allow that.
You don't have to worry about programmers, flashing firmware, setting up project files, writing make files and whatnot.
If you want to do the same without the Arduino IDE I highly recommend that you get yourself a book on AVR programming in C++ and if you don't know C++ to at least a medium level another one on C++. Somehow frankensteining Arduino sketches into a normal IDE doesn't appear to promissing in the long run.
You can make more out of your time.
You can't just convert a arduino sketch into codeblocks. The problem is that the arduino ide does all sorts of things behind our backs which makes it easier for a novice to begin programming a microcontroller.
The easiest way would be to start a new avr project in codeblocks and follow a tutorial on how to program a generic avr microcontroller using codeblocks. This might involve getting a ISP programmer or figuring out how to program using the arduino bootloader over serial.
You can start converting your arduino project to codeblocks after you've wholly understood the basic programming method using codeblocks. This is going to involve you writing your own definitions for digital_write and pinMode.
Your assertions about poor documentation is plain wrong. AVR is really well documented. You should try to read their documentation instead of Arduino's since that is targeted at novices or hobbyist who just want it to work. They hide much of the more fine tuned information.

Is C++ and Linear Algebra a must when trying to learn and understand core graphics? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Currently learning IOS App development using a the big nerd ios programming book and I was on a chapter of the book that focuses heavily on CoreGraphics. I found it hard to grasp so I went through the chapter multiple times and it became slightly easier but I still wasn't 100% confident with it so decided to find a nice core graphics tutorial.
I found myself doing the ray wenderlich core graphics tutorial, it's quite good but I still noticed there where somethings I didn't quite get. Often found myself asking questions like "why did I just do that?", "how am I suppose to know what floating point number to put there?".
Anyway I woke up at 5am and have been reading various posts and webites for the last 2 and half hours. I stumbled across a post that stated:
The basics of graphics programming is necessary
C++ is a must
Linear Algebra is a must
Firm knowledge of coordinate system transformation is a must
How true is the above?
I mean I remember in the past when learning ruby/rails I ended up needing to pick up various other things in order to be able to build complete websites. On my journey to learn IOS App development I'm starting to see the same thing happen.
I've stopped at chapter 6 of this big nerd book to focus on core graphics and now I'm not even half way through the core graphics tutorial I'm following and may need to stop and do a tutorial on linear algebra amongst other things.
I'd like to do what's really necessary. Stackoverflow is my go to place in these types of situations. I'd like to know from some of the experienced IOS App developers, what do you recommend in this situation?
Is there a set guide you recommend I follow?
I promised myself I was going to learn IOS Dev properly with no short cuts as understand things thoroughly has made the experience quite enjoyable.
I came across a linear algebra video course on khanacademy. But I'd really only like to put time into what's necessary. I work full time, currently trying to make the transition from networking into the web development industry so I can naturally put time into it rather than having to sacrifice evenings and weekends.
My aim is to be able to build a fully fledged app. E.g. Like twitter, facebook, tagged. I won't be doing any fancy graphics just the kind you'd see on the sites I mentioned.
Your advice will be greatly appreciated thanks.
The basics of graphics programming is necessary
Technically true, but Core Graphics is a great way to learn (at least 2D) graphics programming.
C++ is a must
False.
Linear Algebra is a must
It's involved, but you can ignore the man behind the curtain 90+% of the time.
The only time I can remember the matrix nature of affine transformations becoming important was the time I answered a question about infinite rotation—and even then, another answerer provided a solution that didn't rely on matrix knowledge.
Apple's own documentation says:
“You can use either set of functions [making matrixes directly from numbers vs. geometric transformations] without understanding anything about matrix math. However if you want to understand what Quartz does when you call one of the transform functions, read ‘The Math Behind the Matrices.’”
I would only add that if you do read “The Math Behind the Matrices” and it's lost on you, don't worry about it—just try it again in a month. At some point, you'll read that chapter and it'll make sense.
Geometry and trigonometry are much more important as a Core Graphics user than linear algebra. And the trig you need to know is pretty straightforward.
Firm knowledge of coordinate system transformation is a must
Again, true, but Core Graphics is a great way to learn it.
Is there a set guide you recommend I follow?
The Core Graphics Programming Guide.
If any part of it stumps you, open Xcode and start doing it. Pound on it 'til it works. Make sliders to adjust parameters (e.g., any of scale, translate, rotation angle, and skew) and fields to display them and see how the input affects the output. Experiment with blend modes.
Definitely experiment with blend modes.
And if you ever get completely stuck, you can always come back to SO and ask a question about it.

Starter kit for Embedded linux programming [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I want to begin learning embedded linux development (i'm not beginner in C nor in Linux) and i choose this book :
http://www.amazon.com/Embedded-Linux-Primer-Practical-Real-World/dp/0137017839
If you have a better choice let me know please.
I want to buy some hardware to do some practice, any suggestions?
Thanks for your help.
#Greg - not a duplicate. Clearly this post is looking for advice on embedded linux, not general embedded.
#funnyCoder - What sorts of things are you wanting to do? Beagleboard is nice but might not fit your needs. Are you looking for:
Battery powered
Video display
USB host capability
Running a full desktop environment
Removable storage
Expansion ability
Ethernet
Wireless (Bluetooth or 802.11 or Zigbee)
Buttons, switches, LEDs
Touch screen interface
Audio
Also, processor speed and RAM have a big influence on what you will be able to do. There are low-end systems and very high-end systems and lots in between. Give us some requirements and we can direct you a little better. Or maybe someone has a link to a comparison guide.
A good book I'd recommend is the O'Riley book Building Embedded Linux Systems, but the one you've got is pretty good too.
Linux programming is linux programming, even kernel level, so the question is what Luke asked. What is it that you really want to do? The computer you typed this question on may suffice for much of what you are interested in or none of it. Depends.
If you go beagleboard avoid the old one go for the xM, it is usable where the other just costs more money to make it usable. The raspberry pi should be out any time now but it is an unknown quanity. I didnt like the plug computer but did like the open-rd board, liked it much better than my beagleboard. I have one of the chinese clones of the beagleboard which I liked much better (because it was usable out of the box) the xM has bridged that gap though. embeddedarm.com has a number of boards. The hawkboard is fine as well, they have had that picture up about pcb design flaw forever but my boards so far are fine.
Oh the open-rd board has sata built in you can plug a laptop hard drive right into the board, all of the others use slow usb or flash based solutions (the open-rd might be a usb to sata though). there is a tegra2 based one out there with various flavors that did that usb to sata, pretty lame. The big problem with these arm based one is they use slow mass storage and you cant really take advantage of the instruction set or other things like that, they are also crippled with the amount of ram.
There is always qemu, its free and you can try different processors. I would make sure you put ARM on the list of things you want to try/learn but might be worth trying others as well, mips, ppc, etc.

Recommended books for building a shell/BBS Server [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I am working on a independent project for school, and I need a bit of guidance on possible resources. Basically, I am trying to build a Unix-style shell (possibly porting later to Windows) in C or C++. I will add shell commands in a modular fashion, adding functionality as I go. The final step will be to ad a "connect" command which will allow a user to connect to a telnet BBS that I have designed. The BBS will also only have basic, skeletal functionality. E.G., I am probably going to have news blurbs, maybe a basic application and a basic door game.
I don't really need help with the programming (at least, not yet), but I have been having trouble finding good resources to help me out. What I am looking for is a good book on shell programming (not writing scripts, but actually programming a shell from scratch, and its various interactions with the underlying system), and a good book on adding telnet functionality- what I mean by this is that I want to use my computer as a server, and allow a few other users to connect in order to test that my system works. I am currently reading the Sans "Teach Yourself TCP/IP in 24 hours" which has proved reasonably useful for someone with a good understanding of CS, algorithms, data structures, etc. I just need something a little more specific.
Just a little background- I am a second year Computer Science student at Purdue, and I am doing this independent study in order to tie together many of the concepts I have learned thus far. If anyone could point me toward some truly excellent resources, it would be very much appreciated.
Please let me know if you need more detail or clarification in order to point me toward the appropriate resource. Note that I am willing to buy any book available if it proves to be a valuable resource. Also, I did try a search for these resources on SO, but most questions seemed to be too specific (generally about issues that someone is having with their implementation of a shell, etc.); I would also prefer personal recommendations from experienced programmers in the field.
Thanks in advance.
-S
PS- To clarify "BBS" for younger programmers- this is what existed before the Internet. Old school, dial-up, text based bulletin board systems on a 2400 baud modem. I obviously can't recreate that exactly, but my hope was to synthesize the experience using telnet or SSH. See http://www.telnetbbsguide.com/ for more information on a telnet BBS. I need to be able to write my own software, though, that merely has a fraction of the functionality of a real BBS. But, I am not sure what I need to be searching for to learn more about this- should I be looking at server books, networking books, or something else entirely?
PPS- More clarification. Most of the books I have been seeing on BBS's are books about how to setup, run, and maintain a BBS as a sysop, using pre-existing software. What I need to do is write the software myself. I will likely use telnet, as it appears to be easier to use that SSH (at least, to program- please correct me if I am wrong about this). I friend of mine recommended that I get a book on patterns, and also a copy of "The Pragmatic Programmer". Please let me know if he is pointing me in the right direction for what I want to build. Also, just as a side note, I do have a pretty decent (if basic) knowledge of programming, algorithms, and data structures- but absolutely no knowledge of networking or servers and I am not really sure how much I actually need to know in order to start development on this project. Well, I know a little bit about networking, just not from a programmer's perspective. Thank you all again.
There is a book about programming unix shells! written by none other than Axel Tobias-Schreiner, illustrious author of ooc.pdf, The "Object-Oriented C" PDF (Google it, but don't forget his name!).
It's called "Using C with Curses, Lex and Yacc: Building a Window Shell for Unix System V", Prentice Hall, 1990; and it really should be considered Part 3 of the saga begun in K&R "The C Programming Language", and continued in the second half of K&P "The UNIX Programming Environment".
The shell the book describes is a rogue-style "window system" that works inside the terminal (using curses), it includes a text-file viewer, and a command-language interpreter that runs commands inside of these "windows". The command language uses lex and yacc to implement the lexer/parser. So the book serves as an introduction to doing such things, a large literate program in C, and goldmine of snippets for using curses, complicated options processing, and implementing a programming language using the much-touted standard unix tools.
I've never seen a book about programming of shells, although I'd be happy to find out that such a thing exists.
But really, isn't programming a shell basically a list of features that you'll implement AND the order of evaluation of how interpret the users input? You can see a good write-up on order of evaluation in 'Classic Shell Programming', Robbins and Beebe AND in 'C Shell Field Guide' (the Andersons) and possibly others.
Of course, you would learn a lot by digging in on the available source codes for shells, bash, z shell, ksh.
Sorry, I don't have any ideas about the BBS server part of your question. As you found the SAMS book helpful, I'd recommend looking at the W. Richard Stevens' Network Programming Series of books, which is 99% Unix network programming and maybe not what you want.
(Finally, consider changing out your recommendation tag for bash or zsh, as many regular contributors at S.O. check for new questions by searching on 'their' tags. The people that can answer your question better may not be reading it)
I hope this helps.

Best way to get started with programming other things than your computer? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
What is the best way to get started with programming things outside of your computer?
I don't mean mainstream things like cell phones with APIs.
Please assume working knowledge of C/C++
I vote for the Nintendo DS:
Nice hardware : 2 CPUs, 2 screens, touchscreen, mic, speakers, wireless, 2D and 3D acceleration
No OS to speak of
Freedom to talk to the bare metal without restriction
Well-documented
Very active dev community
Enthusiastic audience for anything cool you create
Cheap (shockingly so if you go for 1st-gen units)
All-in-all it's really excellent fun to play with.
To get started:
Get a DS
Get a SLOT1 flash-cart (I've got a DS-X, but there are plenty of others)
Get devkitpro
Go here for help or advice
Brian, you might find the Arduino interesting. It is inexpensive and pretty popular. I started playing around with micro controller boards and such a few years back and that lead to an interest in robots. Kind of interesting, at least to me.
If one is interested in a .NET-flavored development environment, there is an analog to the arduino call netduino that is worth a look.
Embedded programming is fun.
You can start with things like the Basic stamp or PIC, or since you know c/c++ you can use a real microcrontroller like an Atmel AVR. look at the Butterfly or Arduino kit
The Arduino has an amazing community of projects and info behind it.
It's not a microcontroller, but the Lego Minstorm is a good place to start learning the ins and outs of embedded programming.
I recently heard about the BUG which calls itself "open source hardware development". Is this the sort of thing you're looking for?
Buy yourself an HP 10C Calculator, and then program all those "programming 101" math algorithms using its insanely small but practical calculator language. Reminds me of assembler, but it's not.
I'd strongly recommend to find an open-source project next to one of your leisure occupations.
First, open-source because the support is mostly very friendly, then open-source because other contributors will have at least one comparable hobby, and then favorite pastime occupation so you can see a need for tools etc.
Two projects I have been playing around with very successfully:
Music: Rockbox, a firmware replacement for many mp3-players and portable media players.
Photography: CHDK, a firmware addition to numerous Canon compact still cameras.
Give SparkFun a shot. For me, servos are what I love to hack around with.
You can try with BeagleBoard, though its kind of mainstream, nonetheless very impressive performance to speak off at just 149$.
I'd look into stuff like (unofficial) GBA development or the like, sure there are "Libraries" but you can go digging and just stick bits into specific addresses and make stuff happen. You can't get more "No API" then raw memory-mapped hardware access.
Maybe start with small microcontroller projects.
This may be helpful: http://www.kmitl.ac.th/~kswichit%20/
What sort of things do you want to program?
Sounds like you might be interested in MAKE magazine, and some of their compilations, such as Making Things Talk. With a little bit of experience with basic electronics, you can follow their recipes to do all sorts of odd and interesting things. When you get more comfortable, you can start modding their designs.
Good luck, :)
I have personal experience and would recommend using these products to program PICs:
Programming board
GCBasic (Open Source Basic)
The PICs are cheap ($2 bucks or so) and the board will cost you around $120.
Recently, I have been impressed with TIs wireless USB chips/programmers. You can get 2 chips and a programmer for $50 bucks. It also comes with a free C compiler. By default it comes with a sample remote temperature program.
TI wireless target board
I think it's fun to hack old iPods. You can get a fourth generation iPod (or any of a number of supported devices), run Rockbox on it, then get the source and help hack on it.
I would also recommend AVR (8-bit) and Butterfly or DB101 kit. The main advantage is that there is a GCC compiler available and that you can program them through the Serial Port, without the need of a tool. Inexpensive programming and debugging tools are also available. There is a very strong AVR community in AVRFreaks
Another alternative is ARM7 and ARM9 microcontrollers (32bit). If you are interested in using an OS (ucLinux/FreeRTOS for ARM7, Linux for ARM9), you should go that way. There is of course a free GCC compiler. You can buy kits and tools at Olimex
If you would like to create a cool gadget using a microcontroller as a learning experience, you can look at the starter kits from Rabbit (website). They have a variety of low-cost kits with 8-bit microcontrollers to get started with a particular technology.
There are a lot of programmable robots around. In fact, even some of the Roombas (automated vacuums) can be programmed. This is particularly good if you want to teach kids how to program.
If you have a Nintendo Wii, you can crack it using Twilight Princess. You don't even have to buy it. I just rented it for a couple days. Go to WiiBrew.org and check out some of the projects that are available there. Most if not all are open source, and should give you a good starting point. Lots of ports of existing stuff, along with some original programs written specifically for the Wii. You would of course do the programming on your computer, and transfer the compiled binaries to the Wii. I haven't looked into how hard it is to get a development environment set up and having it build for the Wii, but if you email they project maintainers from wiibrew.org, they may be able to set you up.
[EDIT]
Just browsing around, I found DevkitPro, which seems to be the toolkit of choice for developing on many different console and handheld systems, including the Wii.
To ease yourself into embedded programming, you may want to try using XNA for either the Xbox or the Zune. You won't be doing memory management, but you'll get used to the constrained hardware if you do it on the Zune. Admittedly, it's using C#; but you could always do the programming itself using CIL.

Resources