Microcontroller IDE like simulink [closed] - c

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I have a query that, is there any simulation software available (like simulink in matlab) for micro controllers.
I have tested my system on simulink and generated a c code for it.Now I want to verify the code by running it on a micro controller simulator which also have such scopes etc(so i can easily verify my embedded code).

Xcos is a simulink analogous in Scilab very helpful for most who can't afford a matlab license. The Arduino library will help you making whatever project you want.
You can download it free here https://www.scilab.org/

Now I want to verify the code by running it on a micro controller simulator which also have such scopes et (so i can easily verify my embedded code)
You might consider a static program analysis approach. Tools like Frama-C or Coverity or Clang analyzer come to mind. But they are difficult to learn or use. If your code is compilable by some recent GCC-based cross-compiler, consider also developing your GCC plugin.
For some microcontrollers, you might find software emulators for them (e.g. sourceforge lists several of them). Qemu could be a possibility (but again, there is a learning curve).
See also this report....
Take into account your time (including learning efforts). You might decide that buying an arduino (or a RaspBerryPi) is cheaper than learning to use emulators for it. For example GCC is free software, but you'll need months of efforts to dive into its source code (many millions lines of code). Scilab is also free software. So is GHDL.
If you have access to the entire documentation of your micro-controller (including cycle times of every machine instruction), writing the emulator is also a possibility. Again, budget months of efforts. JIT compilation libraries such as libgccjit or libjit could be interesting to use for that. Or higher-level languages (e.g. SBCL).
Be also aware of Rice's theorem, C compilers like CompCert, and processor architectures like RISC-V or simulator frameworks like UniSIM
Notice that automatically assisted verification of C code reduce program bugs, but not software design bugs. You basically move bugs from programs to their specifications (as described by the V-model of software development). There is No Silver Bullet

Related

How would I go about incrementing an integer in C when the user opens a program? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I'm currently writing a text-based adventure game and I have a lifetime counter. I wanted to know if it would be possible to increment the lifetime counter upon starting the game without using a file?
I am using Windows 10 x64.
This is operating system specific, since while the C11 draft standard n1570 does mention files (in section §7.21) it does not mention other ways of persisting data.
You might consider using some database, e.g. the sqlite library or PostGreSQL or MongoDB. It might be overkill.
You could consider keeping persistent data (like suggested in this draft report, or coded in C++ in the RefPerSys software) in some textual format such as JSON. Concepts and terminology from garbage collection could be relevant (e.g. Cheney's algorithm). Read at least the old Uniprocessor Garbage Collection Techniques paper for terminology.
You might be interested by web services, using libcurl and/or libonion and/or Wt. Before that, read documentation related to HTTP. You might consider using JSONRPC or SWIG.
On Linux you might consider using shared memory or other ways of interprocess communication with several cooperating processes, see shm_overview(7), sem_overview(7), fifo(7), unix(7), poll(2) and other syscalls(2) (and atexit(3)). Read then Advanced Linux Programming
On Windows you need to read the documentation of the WinAPI.
You could be interested by the POSIX standard and by cross-platform libraries like GTK or libSDL. Both are often used in game software.
Notice that SBCL has some persistence machinery (see also this). You might take inspiration from its save-lisp-and-die primitive. You could also write parts of your game in Ocaml and take advantage of Ocaml's Marshal module. You could embed Python (or GNU guile, or Lua) in your game software and use its persistence features. Even if you don't code in SBCL or Ocaml, you could take inspiration from their runtime C code.
I'm currently writing a text-based adventure game and I have a lifetime counter.
Then look also (for inspiration) inside the source code of existing games on github.

What is LLVM and why is it so popular all of a sudden? [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 3 years ago.
Improve this question
In recent months, I have been seeing mentions of "LLVM" all over the place. I've looked it up, but the description of a "modern compiler infrastructure" doesn't really tell me anything. I can't find much about it, other than some mention of a c compiler that comes along with it (which doesn't seem to be any different from any other C compiler out there.)
Is there some difference between this LLVM thing and any other compiler, say, GCC? Or is it an over-hyped replacement benefiting from being newer than the competition?
There is some academic literature on the matter, I recommend the AOSA book chapter on it, written by the principal author (Chris Lattner).
LLVM is a collection of libraries built to support compiler development and related tasks. Each library supports a particular component in a typical compiler pipeline (lexing, parsing, optimizations of a particular type, machine code generation for a particular architecture, etc.). What makes it so popular is that its modular design allows its functionality to be adapted and reused very easily. This is handy when you're developing a compiler for an existing language to target a new hardware architecture (you only have to write the hardware specific components, all the lexing, parsing, machine independent optimization, etc. are handled for you), or developing a compiler for a new language (all the back end stuff is handled for you), or when you're doing something compiler adjacent (like analyzing source code, embedding a language in a larger application, etc.).
In order to support this, LLVM employs a pretty sophisticated internal representation (called the LLVM IR, creatively enough) that is basically assembly language for a theoretical hardware architecture designed to make targeting it with a compiler very easy. Most of the LLVM libraries take the IR in, operate on it, and output the modified IR, supporting the project's aim of modularity. This is in contrast to GCC, which (historically, I haven't checked recently) has a less complete IR and thus the separate phases of compilation are very tightly coupled because they have to share a lot of information.
Clang is the flagship compiler built on the LLVM framework.

linux kernel step by step [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 6 years ago.
Improve this question
i know c language.my goal is to read linux kernel.so what languages should i learn(write books too) before start reading kernel and is there any book to help reading linux kernel
This book is a little outdated, but Understanding The Linux Kernel is an amazing reference. It will also give you a crash course in i386 features that make a lot of the kernel facilities possible (such as the MMU and how interrupts work. With operating systems, it's sometimes hard to understand where the hardware ends and the OS begins), and reference a lot of the critical source directly.
Also, look into the LWN Kernel article index for more up-to-date references.
One good way to start is come up with a really simple feature that you'd like to add to the kernel and start hacking away at it. (Something I did in college was count how many times each process got preempted and export that value via the /proc file system. Taught me a lot about scheduling, /proc, the process structure, and many other facilities). Also a recommendation, do this in a VM unless you plan to reboot every fifteen minutes.
For ad hoc questions, searching Google works, or asking questions on IRC. (Respectfully, of course.)
The Linux kernel is over 11.5 million lines long! It takes years to be a good programmer and you have to be one if you want to hack the Linux kernel. Taking your age and experience into account, you will most probably fail if you make that your first C project. I recommend getting your hands wet on some other cool stuffs using C. For Example, port the codes in the GreyHat Python book (debuggers, hooking, fuzzing and e.t.c) to C and add interesting features to them. If you are really into OS development, I recommend reading good books on Assembly and writing your own little real time OS. I've seen a real time OS written by a 13 year old kid so it's possible. Good luck!
Not so long ago there was a Linux kernel workshop at Hackerspace Brussels. You can take a look at the links on the event page https://hackerspace.be/LinuxKernelWorkshop
I raised this question myself years ago. I've then got stuck into lines of Linux kernel source code to figure out how it works. Till now my understanding on Linux kernel is still a mix. I think the best way to understand a program is write it by yourself. To build an OS, I think this is the minimum:
computer hardware & architecture
assembler & compiler
assembly
C language
There are lots of books out there that could help you read Linux kernel piece by piece. You still have a lot of time to rewrite it yourself.

LInux vs BSD for kernel development [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 11 years ago.
Improve this question
I recently updated my rusty C skills, and I've been trying to find a project to try them out on, so I picked kernel development (after all, C is a systems language). So, I was wondering which would be easier to start out with, Linux or one of the BSDs? Linux has a larger userbase (so I would probably have more support), but it also has a humongous codebase (9 million lines last time I checked), would the BSDs be easier to start out with because they combine the userbase and kernel into one large codebase? Also, is it best to just start reading the kernel source code? And, are they trying to implement new features aside from SMP and new drivers?
Unfortunately, I can only speak of Linux kernel hacking for myself. Currently I'm in an internship where I am working on a kernel, and I never did this before. But I was able to learn a lot of stuff in a quite short time, due to several reasons (again, I want to point out that I don't know how much of this is covered withint he BSD community):
Tutorials. The Linux Community is quite big and therefore you will find a lot of beginners information on kernel hacking. I feel like the standard to begin with was this guide. If you read it you will see, that even kernel hacking starts with hello world ;)
Linux Cross Reference. A great tool. It covers the complete Vanilla source code and shows you where each function/struct/define/whatever was defined and implemented, so no long searching for some stuff
The modular build of linux (I assume the same goes for BSD) Clearly you won't be able to look through 9 mio lines of code. But you can start easy with a little loadable kernel module and then go deeper. Maybe look at other modules first, hack them, and finally dig into the directly compiled stuff
The sheer community size. Not only kernel mailing lists, but also a huge number of forums or Q&A sites like this one where you can be sure to get help if you don't know what to do ;)
Just my 2 cents ;)
I am using and developing for Linux for many years, but am lacking any real experience with BSD to recommend either way.
You sound lacking experience for kernel hacking. Just reading kernel source might be insightful, but won't really teach you much. There is a lot going on in Linux kernel besides drivers. For example, latest 2.6.38 was focused on desktop responsiveness. DRM stack is ever changing and could use more man power.
I'd suggest start easy, small fixes for beta drivers, etc.

What alternatives to Hans Boehm GC are out there for small devices? [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
I'd like to use a virtual machine like NekoVM into a small device but to build it, it requires Boehm GC, however there is no port of that GC to that small device so I was wondering if there is any alternative to it, something that could be done exclusively with C code?
I'd say your best option would be to port the GC to your platform, for which there are instructions (libgc porting instructions).
Additionally, it should be possible to swap out the GC implementation (NekoVM FAQ), see vm/alloc.c file.
EDIT:
Hopefully useful additional links: (untested)
Smieciuch Garbage Collector
libgcroots (based on libgc 7, abstracts architecture dependant bits)
Squirrel programming language
Perhaps you'd be better off with Lua, which has a very small but powerful virtual machine, has its own garbage collector built in, and runs on any platform that supports ANSI Standard C. With just a little effort you can even build Lua on a machine that lacks standard input and standard output. I have seen Lua running on an embedded device that was a small LCD touch screen with an embedded CPU stuck on the back. Neko is good work, but I think you'll find Lua every bit as satisfying.
I could suggest TinyGC (tinygc.sf.net) - an independent lightweight implementation of the BoehmGC targeting small devices. It is fully API-compatible (even more, binary compatible) with BoehmGC v7+ but only a small subset of the API is implemented (but sufficient for Java/GCJ-like memory management) and there is no automatic threads and static data roots registration. The latter, however, may require some efforts to make NekoVM work with it (i.e., call GC_register_my_thread() and GC_add_roots()).

Resources