Writing image to SD card programmatically - cross-platform

I am trying to write a cross-platform (Linux, Mac OS and windows) tool/script which can write .img images to SD cards via an SD card reader connected to the computer. I tried searching a lot for tutorials/references on how this could be done using various languages but I was unable to find anything fruitful.
I want to gain a deeper understanding of the underlying process which happens when images are written to SD cards, and what factors make this process platform dependent. Some kind of guide/blog post of how such a program can be implemented in some language would be wonderful.
(dd command can be used on linux and mac os, but I'm exploring the possibility of writing a single uniform program which could do the job on all platforms)
I would like some guidance/references regarding this

From the perspective of an application program, an SD card is just a file. You can write data on the SD card with the same library functions and system calls you would normally use. On Unix-like operating systems, the files corresponding to devices are commonly placed in the folder /dev. For instance, to write the image sd.img on the first SD card on Linux, you could invoke the command dd like this:
dd if=sd.img of=/dev/mmcblk0
This copies the content of sd.img into the SD card. The process is similar but not exactly equal on other platforms.

Related

Is it possible to write a program on flash drive (pen drive) to perform a task on inserting flash drive into USB port?

I have a music playlist folder in my Flash drive (pen drive), music names are sorted in a fixed manner, I want to shuffle my music playlist by renaming the files. Generally I use Flash drive to play music in my car.
Is it practically possible to write a program for a flash drive? On inserting a flash drive into PC/car firmware; music files in the playlist folder must be shuffled every time.
Thank you.
I searched on web, I didn't find useful resources to accomplish the task.
It's only possible if either of the following are true:
The "computer" you're inserting it into supports running code. (Like an autoexec.bat on Windows). Obviously this depends entirely on what CPU/"OS" your car's audio player runs. Unlikely that there's any intentional support for executing code, but you might find an exploit that would let you run code on your car's audio-player microcontroller. The audio player probably doesn't really have an OS, it's probably just a lightweight custom system.
Your flash drive can run custom firmware that has a driver for FAT32 and modifies its own contents on powerup, before making itself visible to the host.
Flash drives do have a microcontroller internally to run the flash remapping / wear-leveling firmware. But usually there's no documented interface for uploading programs to it. And normally it doesn't know anything about filesystems, only block-level stuff, so anything you wanted to stuff into it would have to include a driver for FAT32.
I assume some people have reverse-engineered the programming / firmware-update interface on some flash drives.
You can probably also get USB devices that are designed to run custom programs like this as well as act as USB storage. If you really really want this (and your car doesn't have a "randomize" mode you can use instead), buying a USB-storage device that was designed to be programmable would probably be the easiest way to go. I assume such things exist but IDK.

Filo I/O operations from SD card in Xilinx Zynq ZCU102

I'm using a Xilinx Zynq UltraScale+ MPSoC ZCU102 Evaluation Kit. I want to run a C++ program in the Xilink SDK tool(running on a Windows machine) that can do Filo I/O operations on a binary file stored in the SD card in the Zync board. I have the command line tool(xsct) setup. My questions are as follows:
What are the commands that I have to execute in XSCT tool to mount the SD card?
Once the SD card is mounted, how can I query for the SD card drive(whether C:\ or D:\ drive)?
Edit: The following Xilinx thread suggests that no mounting procedure
is required. In this case, I'd like to know how the SD card drive can
be identified and the information about the files contained therein
can be displayed in the XCST terminal.
https://forums.xilinx.com/t5/Embedded-Development-Tools/Filo-I-O-operations-from-SD-card-in-Xilinx-Zynq-ZCU102/m-p/851582/highlight/false#M45325
Don't confuse two different systems.
In simple terms, SD card when inserted in MPSoC-board is accessible to the processor running on the MPSoC-board. The code running on that board will initialize it and access its contents.
XSCT is just a command line tool. It allows to perform the tasks using commands that are also possible using SDK GUI. Go through this link to understand what XSCK really is.
You can accomplish what you are saying by running PetaLinux on MPSoC and accessing the card using simple open,read,write,close functions by writing a C or C++ program that will run on PetaLinux.
A more difficult approach would be to make a bare-metal (standalone) program with SD-card driver and file-system code in it to access the SD-card

How to determine if an application is using the GPU

I'm looking for a way to determine how to know whether an application is using the GPU with Objective-C. I want to be able to determine if any applications currently running on the system have work going on on the GPU (ie: a reason why the latest MacBook Pros would switch to the discrete graphics over the Intel HD graphics).
I've tried getting the information by crossing the list of active windows with the list of windows that have their backing location stored in video memory using Quartz Window Services, but all that does is return the Dock application and I have other applications open that I know are using the GPU (Photoshop CS5, Interface Builder), that and the Dock doesn't require the 330m.
The source code of this utility gfxCardStatus might help....

How to find an embedded platform?

I am new to the locating hardware side of embedded programming and so after being completely overwhelmed with all the choices out there (pc104, custom boards, a zillion option for each board, volume discounts, devel kits, ahhh!!) I am asking here for some direction.
Basically, I must find a new motherboard and (most likely) re-implement the program logic. Rewriting this in C/C++/Java/C#/Pascal/BASIC is not a problem for me. so my real problem is finding the hardware. This motherboard will have several other devices attached to it. Here is a summary of what I need to do:
Required:
2 RS232 serial ports (one used all the time for primary UI, the second one not continuous)
1 modem (9600+ baud ok) [Modem will be in simultaneous use with only one of the serial port devices, so interrupt sharing with one serial port is OK, but not both]
Minimum permanent/long term storage: Whatever O/S requires + 1 MB (executable) + 512 KB (Data files)
RAM: Minimal, whatever the O/S requires plus maybe 1MB for executable.
Nice to have:
USB port(s)
Ethernet network port
Wireless network
Implementation languages (any O/S I will adapt to):
First choice Java/C# (Mono ok)
Second choice is C/Pascal
Third is BASIC
Ok, given all this, I am having a lot of trouble finding hardware that will support this that is low in cost. Every manufacturer site I visit has a lot of options, and it's difficult to see if their offering will even satisfy my must-have requirements (for example they sometimes list 3 "serial ports", but it appears that only one of the three is RS232, for example, and don't mention what the other two are). The #1 constraint is cost, #2 is size.
Can anyone help me with this? This little task has left me thinking I should have gone for EE and not CS :-).
EDIT: A bit of background: This is a system currently in production, but the original programmer passed away, and the current hardware manufacturer cannot find hardware to run the (currently) DOS system, so I need to reimplement this in a modern platform. I can only change the programming and the motherboard hardware.
I suggest buying a cheap Atom Mini-ITX board, some of which come with multi - 4+ RS232 ports.
But with Serial->USB converters, this isn't really an issue. Just get an Atom. And if you have code, port your software to Linux.
Here is a link to a Jetway Mini-Itx board, and a link to a 4 port RS232 expansion module for it. ~$170 total, some extra for memory, a disk, and a case and PSU. $250-$300 total.
Now here is an Intel Atom Board at $69 to which you could add flash storage instead of drives, and USB-serial converters for any data collection you need to do.
PC104 has a lot of value in maximizing the space used in 19" or 23" rackmount configurations - if you're not in that space, PC104 is a waste of your time and money, IMHO.
The BeagleBoard should have everything you need for $200 or so - it can run Linux so use whatever programming language you like.
A 'modern' system will run DOS so long as it is x86, I suggest that you look at an industrial PC board from a supplier such as Advantech, your existing system may well run unchanged if it adheres to PC/DOS/BIOS standards.
That said if your original system runs on DOS, the chances are that you do not need the horsepower of a modern x86 system, and can save money by using a microcontroller board using something fairly ubiquitous such as an ARM. Also if DOS was the OS, then you most likely do not need an OS at all, and could develop the system "bare-metal". The resources necessary just to support Linux are probably far greater than your existing application and OS together, and for little or no benefit unless you intend on extending the capability of the system considerably.
There are a number of resources available (free and commercial) for implementing a file system and USB on a bare-metal system or a system using a simple real-time kernel such as FreeRTOS or eCOS which have far smaller footprints than Linux.
The Windows embedded site ( http://www.microsoft.com/windowsembedded/en-us/default.mspx )
has a lot of resources and links to hardware partners, distributors and development kits. There's even a "Spark" incubation project ( http://www.microsoft.com/windowsembedded/en-us/community/spark/default.mspx )
What's also really nice about using windows ce is that it now supports Silverlight as a development environment.
I've used the jetway boards / daughter cards that Chris mentioned with success for various projects from embedded control, my home router, my HTPC front end.
You didn't mention what the actual application was but if you need something more industrial due to temperature or moisture constraints i've found http://www.logicsupply.com/ to be a good resource for mini-itx systems that can take a beating.
A tip for these board is that given your minimal storage requirements, don't use a hard drive. Use an IDE adapter for a compact flash card as the system storage or an SD card. No moving parts is usually a big plus in these applications. They also usually offer models with DC power input so you can use a laptop like or wall wart external supply which minimizes its final size.
This http://www.fit-pc.com/web/ is another option in the very small atom PC market, you'd likely need to use some USB converters to get to your desired connectivity.
The beagle board Paul mentioned is also a good choice, there are daughter cards for that as well that will add whatever ports you need and it has an on board SD card reader for whatever storage you need. This is also a substantially lower power option vs the atom systems.
There are a ton of single board computers that would fit your needs. When searching you'll normally find that they don't keep many interface connectors on the processor board itself but rather you need to look at the stackable daughter cards they offer which would provide whatever connections you need (RS-232, etc.). This is often why you see just "serial port" in the description as the final physical layer for the serial port will be defined on the daughter card.
There are a ton of arm based development boards you could also use, to many to list, these are similar to the beagle board. Googling for "System on module" is a good way to find many options. These again are usually a module with the processor/ram/flash on 1 card and then offer various carrier boards which the module plugs into which will provide the various forms of connectivity you need.
In terms of development, the atom boards will likely be the easiest if your more familiar with x86 development. ARM is strongly supported under linux though so there is little difficulty in getting these up and running.
Personally i would avoid windows for a headless design like your discussing, i rarely see a windows based embedded device that isn't just bad.
Take at look at one of the boards in the Arduino line, in particular the Arduino Mega. Very flexible boards at a low cost, and the Mega has enough I/O ports to do what you need it to do. There is no on-chip modem, but you can connect to something like a Phillips PCD3312C over the I2C connector or you can find an Arduino add-on board (called a "shield") to give you modem functionality (or Bluetooth, ethernet, etc etc). Also, these are very easy to connect to an external memory device (like a flash drive or an SD card) so you should have plenty of storage space.
For something more PC-like, look for an existing device that is powered by a VIA EPIA board. There are lot of devices out there that use these (set-top boxes, edge routers, network security devices etc) that you can buy and re-program. For example, I found a device that was supposed to be a network security device. It came with the EPIA board, RAM, a hard drive, and a power supply. All I had to do was format the hard drive, install Linux (Debian had all necessary drivers already included), and I had a complete mini-computer ready to go. It only cost me around $45 too (bought brand new, unopened on ebay).
Update: The particular device I found was an EdgeSecure i10 from Ingrian Networks.

A PDF reader - please guide - a step by step guidance - reference to guidance-

I have to make a hardware project using a microcontroller, memory, screens, etc.
Is it possible to make an independent PDF / documents reader, which is capable of running on battery power?
Please note I don't want to use any technology which needs licensing. It must be all freeware readers, etc., and programing language can be assembly, C, Flash or any.
I have submitted proposal of PDF reader project (independent hardware). Many say it's impossible. What should I do?
Reading and displaying a PDF document is quite a "high level operation".
You should start with a microcontroller starter kit, with an ARM9 processor or something similar. Then install a Linux operating system on it, include a standard display driver and run an X server. Then you should be able to find a Linux based PDF reader with X drivers.
To 2nd another comment here, I would say that you're not going to to do this with a microcontroller, you're going to need to get some more powerful ARM CPU like an ARM9, Cortex-A8 or similar with a decent amount of RAM.
You'll probably need something that's capable of running Linux if you want to start with pieces of software that won't require writing quite a large volume of software from scratch.
Note that for commercial devices that are out there, including the Kindle, run Linux, and aren't based on a micrcontroller.
You might be best off getting something like a BeagleBoard, attach a display to that, and start from there with an X-based PDF viewer.