Advice on RTOS for AVR? - avr

I need a very tiny RTOS for AVR similar to mRTOS which just has two files (mrtos.h and mrtos.c).
Can anyone please provide any advice?

You should check out FreeRTOS for AVR or search for some board specific ones on github.

For something really small, take a look at the Arduino scheduler:
http://arduino.cc/en/Reference/Scheduler
Pretty simple to adapt to almost anything with a c/c++ compiler. Note, this only gives you pretty basic cooperative multitasking. If you need OS services like semaphores, mutexes, mailboxes, etc. . . you'd need to look for something less lightweight.

Related

C++ running on PIC32 (MIPS32)

Unfortunately, my C app for PIC32 needs OO too much and I can't continue doing it in C.
Do you know any MIPS32 C++ compiler for PIC32?
Thanks
Microchip's XC32 tool chain now supports C++ since version 1.10
You might contact Comeau Computing; thier C++ compiler generates C code as an intermediate language so that it can then utilise a platform's existing native C compiler where only a C compiler is available, and therefore porting to new platforms is relatively quick and simple.
For various reasons the intermediate generation and compiler adaptation is not accessible to end users so you will still need Comeau to generate a PIC32/C32 port, but it probably won't take long and hopefully they would amortise the cost over sales to other users.
However if you use Commeau or any other C++ to C translator, you will suffer from the inability to use source-level debugging, and that is likley to be the killer to any attempt to use C++ sucessfully without native debugger support.
Although it is not always pretty, your best bet is probably to learn how to implement OO designs in C. Here's a whole book on the subject: http://www.planetpdf.com/codecuts/pdfs/ooc.pdf
According to this fairly recent thread on the microchip forums it looks like C++ support for PIC32 isn't available anywhere yet and isn't a high priority with Microchip. The wisdom of the respondents in that thread appears to be: don't hold your breath.
I'm a MPLAB user myself building small programs so I just take what Microchip gives me. I've never gotten to the point where I thought I needed C++, longed for yes, but never needed. As a next step you can either consider moving to another platform with C++ support or take another look at your design and ask why you need C++ that badly. Some features can be simulated in C with varying amounts of pain and suffering.
You might keep an eye on the proper GCC MIPS port. They have all the pieces, but I don't know if anyone's made C++ work with PIC32 in particular. I know it did work on sgimips.

What is the smallest, simplest CPU that GCC can compile for?

In terms of instruction set and simplicity of emulation. I would like to implement a virtual CPU and figured why not emulate an existing one, so to be able to compile C code to it.
Moxie is a great target because it was designed specifically to be an ideal target for GCC. I am the author and would be happy to answer any questions. green at moxielogic dot com
GCC supports Moxie (originally ggx), a little architecture invented by Anthony Green for experimentation.
You, too, can follow the steps he took to invent your own small simple CPU and port GCC to it.
ZPU (an FPGA targeted 32bit processor) is very small.
Possibly the AVR ATTiny45 or similar AVR chip.
This probably isn't an uncommon question; I'd hope that most CPU/machine simulation toolkits would include a simple example implementation, but some don't.
I haven't worked with it, but Knuth's MMIX architecture (wikipedia) looks interesting. Like Moxie, it was created to "illustrate machine-level aspects of programming" and is simpler than real machines. It's supported by GCC and there appear to be multiple existing simulators that could be used as a reference in your efforts.
Maybe something from the Ti MSP430 series.
MIPS I (one of the targets of GCC) is a surprisingly easy-to-emulate 32-bit platform. Here is an short and simple emulator which can load and run a statically linked Linux MIPS I executable: https://github.com/pts/pts-mips-emulator

Step-by-step execution for Intel AT&T assembler?

I'm writing a compiler that converts source code (written in a small imperative programming language) to Intel AT&T 32-bit assembler.
I tend to spend a lot of time debugging, because of nasty offset-mistakes etc. in the generated code, and I would like to know if anyone knows of a tool to "walk through" the generated assembler code step-by-step, visualizing what's on the stack etc.
I use Ubuntu Linux as my development platform, and I'm comfortable with the terminal -- a GUI-program would be nice though. Does it exist? Or is there a good reason it doesn't (maybe the problem isn't so straightforward..?)
If you have good ideas for approaching debugging tasks in assembly code, I'll be glad to hear from you!
I like EDB (Evan's Debugger) on Linux. It has a nice, easy-to-use, QT4-based GUI. Its developer's goal is to make it similar to OllyDbg. And it's being actively maintained:
EDB on FreshMeat
I'm pretty sure it's installable through Synaptic on Ubuntu as well. Enjoy!
Is the end result of the compile process something that you can actually execute, and therefore examine in a debugger? If so the Data Display Debugger (ddd) might be useful.
My experience with debuggers such as Olly and EDB is quite sparse, so I wasn't able to solve my problem with those. I ended up
scattering calls around to a Debug function in the source code, nailing down bad register values
letting the compiler output HTML-formatted code with useful metadata for different iterations in the liveness analysis etc.

GBA ROM Programming Language

Does anyone know what language ROMs (such as GBA ROMs) are coded in? I'd also like to know if there would be a simplistic way to decompile these ROMs.
GBA games can be programmed in any language, as long as it compiles to ARM assembly.
They're usually written in C++.
If you're interested in writing your homebrew games, see here.
I think you've misunderstood what ROMs are. They're not the actual executables (or what they would be on the original platform), rather they are image files that contains the executables. They can be written in many different languages.
See this wiki page for more info:
http://en.wikipedia.org/wiki/ROM_image

How to learn advanced C debugger usage?

How to learn advanced debugging techniques?
I am a C/Unix programmer, and as such rely on a good C debugger. I know Sun^WOracle mdb on Solaris, GNU gdb on Linux. I feel comfortable setting breakpoints, examining memory structures and such.
Yet, I know that those tools are way more powerful than that. Macros, custom walkers and I don't know what else. The learning curve on the other hand is very steep, as those tools sometimes seem to be arcane magic.
Any good texts? Practice problems? Other tips?
The GDB Pocket Reference is worth it's weight in diamonds, rubies, or something way lighter than gold. I use it all the time.
The online docs are also useful, but I actually like having a book on my desk.
Depends on the platform http://advancedwindowsdebugging.com/ is great but I assume from the gdb you aren't on windows

Resources