embedded

Understanding the Location Counter of GNU Linker Scripts

时光总嘲笑我的痴心妄想 提交于 2019-11-28 05:04:59
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 found here (where the code in this question is from). I've also spent a lot of time reading the linker

Macros to set and clear bits

回眸只為那壹抹淺笑 提交于 2019-11-28 04:54:47
问题 Im trying to write a few simple macros to simplify the task of setting and clearing bits which should be a simple task however I cant seem to get them to work correctly. #define SET_BIT(p,n) ((p) |= (1 << (n))) #define CLR_BIT(p,n) ((p) &= (~(1) << (n))) 回答1: Try #define CLR_BIT(p,n) ((p) &= ~((1) << (n))) However for various reasons of general macro evil I would advise not using a macro. Use an inline function and pass by reference, something like this: static inline void set_bit(long *x,

recursive folder scanning in c++

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 04:35:24
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 system and don´t want to use boost ephemient See man ftw for a simple "file tree walk". I also used fnmatch

Why do we need a bootloader in an embedded device?

巧了我就是萌 提交于 2019-11-28 04:11:40
I'm working with ELinux kernel on ARM cortex-A8. I know how the bootloader works and what job it's doing. But i've got a question - why do we need bootloader, why was the bootloader born ? Why we can't directly load the kernel into RAM from flash memory without bootloader? If we load it what will happen? In fact, processor will not support it, but why are we following the procedure? A boot loader is a computer program that loads the main operating system or runtime environment for the computer after completion of the self-tests. ^ From Wikipedia Article So basically bootloader is doing just

Making large constants in C source more readable?

别说谁变了你拦得住时间么 提交于 2019-11-28 03:38:18
问题 I'm working on some code for a microprocessor. It has a few large, critical constants. #define F_CPU 16000000UL In this case, this is the CPU frequency. In Hertz. As it is, it's rather hard to tell if that's 1,600,000, 160,000,000 or 16,000,000 without manually tabbing a cursor across the digits. If I put commas in the number #define F_CPU 16,000,000UL , it truncates the constant. I've worked with a few esoteric languages that have a specific digit-separator character, intended to make large

Test Automation with Embedded Hardware

旧时模样 提交于 2019-11-28 03:35:58
Has anyone had success automating testing directly on embedded hardware? Specifically, I am thinking of automating a battery of unit tests for hardware layer modules. We need to have greater confidence in our hardware layer code. A lot of our projects use interrupt driven timers, ADCs, serial io, serial SPI devices (flash memory) etc.. Is this even worth the effort? We typically target: Processor: 8 or 16 bit microcontrollers (some DSP stuff) Language: C (sometimes c++). Sure. In the automotive industry we use $100,000 custom built testers for each new product to verify the hardware and

Linux cross-compilation for ARM architecture

随声附和 提交于 2019-11-28 03:24:27
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? 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 : You are stuck with whichever version of gcc/binutils/libc they picked If the later matters to you, check

Fastest way to scan for bit pattern in a stream of bits

佐手、 提交于 2019-11-28 03:20:29
I need to scan for a 16 bit word in a bit stream. It is not guaranteed to be aligned on byte or word boundaries . What is the fastest way of achieving this? There are various brute force methods; using tables and/or shifts but are there any "bit twiddling shortcuts" that can cut down the number of calculations by giving yes/no/maybe contains the flag results for each byte or word as it arrives? C code, intrinsics, x86 machine code would all be interesting. Toad I think precalc all shifted values of the word and put them in 16 ints so you got an array like this unsigned short pattern = 1234;

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

若如初见. 提交于 2019-11-28 03:06:27
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 . EDIT: I read a few comments asking why I put this as embedded when the x86-family is not common in

How can I unit test Arduino code?

冷暖自知 提交于 2019-11-28 02:34:27
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. Don't Run Unit Tests on the Arduino Device or Emulator The case against microcontroller Device/Emulator/Sim-based tests There's a lot of discussion about