embedded

Linux cross-compilation for ARM architecture

你说的曾经没有我的故事 提交于 2019-11-27 05:07:38
问题 I am interested in cross-compiling a Linux kernel for an ARM target on a x86 host. Are there some good practices you recommend? Which is the best cross-compile suite in your opinion? Have you settled up a custom cross-compile environment? If yes, what advices do you have? Is it a good idea? 回答1: There are two approaches I've used for ARM/Linux tools. The easiest is to download a pre-built tool chain directly. Pro : It just works and you can get on with the interesting part of your project Con

@ sign in C variable declaration

[亡魂溺海] 提交于 2019-11-27 04:32:32
问题 I found this header file for PIC microcontrollers by the name of pic1250.h and I'm unable to get the hang of some syntax used in it. The source for the file is: /* * Header file for the Microchip * PIC 12c508 chip * PIC 12c509 chip * Baseline Microcontrollers */ static volatile unsigned char RTCC @ 0x01; static volatile unsigned char TMR0 @ 0x01; static volatile unsigned char PCL @ 0x02; static volatile unsigned char STATUS @ 0x03; static unsigned char FSR @ 0x04; static volatile unsigned

What is a jump table?

对着背影说爱祢 提交于 2019-11-27 03:48:58
Can someone explain the mechanics of a jump table and why is would be needed in embedded systems? A jump table can be either an array of pointers to functions or an array of machine code jump instructions. If you have a relatively static set of functions (such as system calls or virtual functions for a class) then you can create this table once and call the functions using a simple index into the array. This would mean retrieving the pointer and calling a function or jumping to the machine code depending on the type of table used. The benefits of doing this in embedded programming are: Indexes

Static allocation of opaque data types

亡梦爱人 提交于 2019-11-27 03:15:54
Very often malloc() is absolutely not allowed when programming for embedded systems. Most of the time I'm pretty able to deal with this, but one thing irritates me: it keeps me from using so called 'opaque types' to enable data hiding. Normally I'd do something like this: // In file module.h typedef struct handle_t handle_t; handle_t *create_handle(); void operation_on_handle(handle_t *handle, int an_argument); void another_operation_on_handle(handle_t *handle, char etcetera); void close_handle(handle_t *handle); // In file module.c struct handle_t { int foo; void *something; int another

Is there any alternative to using % (modulus) in C/C++?

拥有回忆 提交于 2019-11-27 03:03:47
I read somewhere once that the modulus operator is inefficient on small embedded devices like 8 bit micro-controllers that do not have integer division instruction. Perhaps someone can confirm this but I thought the difference is 5-10 time slower than with an integer division operation. Is there another way to do this other than keeping a counter variable and manually overflowing to 0 at the mod point? const int FIZZ = 6; for(int x = 0; x < MAXCOUNT; x++) { if(!(x % FIZZ)) print("Fizz\n"); // slow on some systems } vs: The way I am currently doing it: const int FIZZ = 6; int fizzcount = 1; for

Understanding the Location Counter of GNU Linker Scripts

雨燕双飞 提交于 2019-11-27 00:47:11
问题 I'm working on a university project where I'm writing software for an Atmel SAM7S256 microcontroller from the ground up. This is more in depth than other MCUs I've worked with before, as a knowledge of linker scripts and assembly language is necessary this time around. I've been really scrutinizing example projects for the SAM7S chips in order to fully understand how to start a SAM7/ARM project from scratch. A notable example is Miro Samek's "Building Bare-Metal ARM Systems with GNU" tutorial

recursive folder scanning in c++

爱⌒轻易说出口 提交于 2019-11-27 00:31:35
问题 I want to scan a directory tree and list all files and folders inside each directory. I created a program that downloads images from a webcamera and saves them locally. This program creates a filetree based on the time the picture is downloaded. I now want to scan these folders and upload the images to a webserver but I´m not sure how I can scan the directories to find the images. If anyone could post some sample code it would be very helpful. edit : I´m running this on an embedded linux

How does an assembly instruction turn into voltage changes on the CPU?

谁说胖子不能爱 提交于 2019-11-26 23:56:54
问题 I've been working in C and CPython for the past 3 - 5 years. Consider that my base of knowledge here. If I were to use an assembly instruction such as MOV AL, 61h to a processor that supported it, what exactly is inside the processor that interprets this code and dispatches it as voltage signals? How would such a simple instruction likely be carried out? Assembly even feels like a high level language when I try to think of the multitude of steps contained in MOV AL, 61h or even XOR EAX, EBX .

How can I unit test Arduino code?

爷,独闯天下 提交于 2019-11-26 23:45:32
问题 I'd like to be able to unit test my Arduino code. Ideally, I would be able to run any tests without having to upload the code to the Arduino. What tools or libraries can help me with this? There is an Arduino emulator in development which could be useful, but it doesn't yet seem to be ready for use. AVR Studio from Atmel contains a chip simulator which could be useful, but I can't see how I would use it in conjunction with the Arduino IDE. 回答1: Don't Run Unit Tests on the Arduino Device or

When is CRC more appropriate to use than MD5/SHA1?

℡╲_俬逩灬. 提交于 2019-11-26 23:28:28
When is it appropriate to use CRC for error detection versus more modern hashing functions such as MD5 or SHA1? Is the former easier to implement on embedded hardware? CRC works fine for detecting random errors in data that might occur, for example, from network interference, line noise, distortion, etc. CRC is computationally much less complex than MD5 or SHA1. Using a hash function like MD5 is probably overkill for random error detection. However, using CRC for any kind of security check would be much less secure than a more complex hashing function such as MD5. And yes, CRC is much easier