I've always liked cheap smartphones ($ 50) because with little money I can have a powerful system with lots of sensors and things like that. So I wondered if it was possible to use the hardware without using the very limited android APIs, programming it at a low level then, of course with the root. In particular I wanted to see how the LTE module worked and experiment with this having full control, the Android API does not allow it to do much.
UPDATE: I'm using something called libhybris, a wrapper that permit the use of android driver blobs in Linux.
The first layer of software for the phone is the bootloader. It tells the processor what partition to load into memory for executing the kernel. This is the level that is usually blocked by manufacturers because of greedy corporate reasons that are beyond the scope of this site.
The second layer of the phone is the linux kernel. Rooting is the process of gaining root user access to this layer. Root is the main administrator user account that has permission to do anything to the device. Accessing this layer is what most people refer to rooting. A large portion of the kernel is written in C, with other parts in c++. What happens at this level is where all the magic is. For most phone this is where the code for the modem resides. Talking to this can usually be done via at commands of serial. Sensors are also programmed at this level and communicate via drivers. Root access is not normally needed to read sensor data, its just a case of permissions usually.
The next level is the android operating system, the java instance runs on top of that, which in turn executes the android operating system. This is the portion that most users will see and is primarily written in java. In reality you can run any kind of user interface at this level.
A very brief view of android apps.
The android api provides a way for java developers to write "apps" that communicate with the kernel and access different parts of the phone's hardware. These apps can also be written using c++. Only until recently has google integrated c++ into android studio, but the most common and still most effective method of doing so is using the QT framework.
It's a bit problematic.
Hardware manufacturers do that actually.
Take into account that Android is Linux much like other distributions.
The manufacturers develop hardware and then compile a version Android that sits on top of it. Each Android compilation is specifically tailored to the hardware and equipped with drivers that enable the main OS access to the different hardware capabilities.
For example, some tables will tweak the Android OS to not support cellular communication because they decided to cut costs and deliver the tablet without a cellular module.
From here you have 2 options:
To hack a specific hardware and understand how the OS communicates with the hardware.
Find hardware manufacturers that release some/all of their Android OS code. This is a much simpler way as you can both learn and extend the Android OS for that specific device.
An example of the 2nd way is Sony who has AOSP that allows low-level access to some of the Sony devices.
Also, there is always the Android NDK which gives you a more low-level access to Android but you are still constrained by the KIT API so I'm not sure it will help you.
I'm using something called libhybris, a wrapper that permit the use of android driver blobs in Linux.
Related
Is Way To Run Machine Code Instead Android OS In Android Devices ?
I Want Remove Android Os And Work With Cpu And Other Devices Directly .
What Compiler I Can Use ?
MASM is an x86 assembler, so it would not be suitable for most Android devices as the vast majority use ARM-based processors.
That said, Android phones are computers just like any other and can be programmed in assembly. The first thing you'll need to do is select a device running a well documented CPU and chipset.
Since you'll be removing Android and plan on programming in assembly you'll need to write your own routines for nearly everything. An understanding of the CPU, power management and some form of I/O (you can avoid having to write complex display code if you plan to interface with the phone through serial communication, for example).
Unfortunately, much of the information required for successfully writing your own OS for an Android device is unavailable so you'll need some hardware analysis tools to assist in reverse engineering some of this information. A logic analyzer may be useful in sniffing some of the protocols used between chips, although much of modern phones is done on a single SoC, so you'll need to experiment heavily and compile information from a wide variety of online sources.
Aside from that, it's smooth sailing. Programming an OS in assembly for Android is pretty much the same as programming an OS in assembly for any other computer and you'll find it to be rather familiar territory.
I need to make an architectural decision for developing (actually porting) my embedded solution.
I will try to present my case as clearly as possible, and any advice I can get will be appreciated.
Introduction
I have an embedded system, currently developed on ARM11 architecture and ArchLinux OS. It is implemented using all kinds of technologies available under Linux, including C, C++, Bash and Python.
At this time, I would like to port my solution to a tablet, so I am trying to make some decisions about the architecture, based on the requirements of my system.
Requirements
The system is modular, and it runs multiple processes and threads. It also communicates to remote servers and controls the hardware peripherals. These are the basic requirements, at the moment, I will update as discussion develops:
Primary:
Dedicated system (minimum amount of other applications running, even in the bg)
Multiple processes, ability to set priorities
Ability to assign a process to a single CPU Core (cpu affinity)
Inter-process communication mechanisms
Complete hardware control (WiFi, 3G, GSM, mic, speaker, display, ...)
Creating sockets, etc.
Other:
Ability to connect a microphone directly to a 3.5mm plug (TRRS connector)
Mainstream solution to ensure reliability
Future-proof: minimize the porting effort for new tablets and HW
My questions
What tablet and OS combination would meet these requirements?
How to approach the "dedicated solution" requirement?
How to approach the software development, what language and tools to use?
My investigation so far
My investigation so far has been concentrated on the OS choice. The main options seem to be Android and Ubuntu Touch. Here are my thoughts:
Android
Android wins in the mainstream category obviously, but...
I have no experience of Android development, but as far as I can tell, I can either develop a Java application that runs on top of Dalvik, or I can go native via Android NDK. Maybe I can even bypass the whole thing and go native side-by-side of Dalvik, and develop in Python? I guess then I will lose the access to the API for HW access. Not sure how I would access the HW then. But if I go with Java development, this is a sandbox solution, and I am not sure if I can have such a control over the processes, HW and CPU core affinity?
Ubuntu Touch
Developing on Ubuntu Touch would be more like Linux development I am used to, since it uses Qt. The issue here is that the applications are developed using the SDK that restricts me to HTML5 and QML, which I'm not sure can allow me the same control over the system I need. If I use Python and avoid the SDK, same issue arises - how do I control the HW? Of course, there is a way to do it like on a regular embedded system I guess, but I don't want to reinvent the wheel if I don't have to.
Also, it seems that Ubuntu Touch hasn't been ported to many devices yet, only a handful of them are supported.
Finally
I am not sure how well I have presented my case, but I will update the question as needed with further explanations and requirement details. Thank you for your patience, your time and any help you may offer.
I am in the same boat as you, we are developing embedded system on ARM CPU. Currently the system is written in Python on custom built linux distro from hardware vendor.
We have been looking at Android and Ubuntu Touch for a few months. So far we didn't get any decision yet. But here what we found out from our incomplete analysis:
Android is quite heavy system, that also brings JVM into the mix. So you HW and memory requirements will significantly increase.
Android likes to take over the entire system, so sometimes you might be fighting with Android.
Android has very good IPC mechanisms, not available on mainstream linux kernel, such as Binder. Of course you can port it to another system. But this would be considerable effort.
Android has very rich GUI interface, also with things like NDK view you are not confined into the JDK box.
Android doesn't use standard GNU C library, it uses something called BioniC which is a port of C library from BSD. Usually it is not a problem for most software, but if you are using some linux specific low level features, like working with serial ports you will need to tweak your code. See what I had to do to port Java RXTX library to android https://github.com/vladistan/gnu.io.android
You can find a lot of Android developers out there who will do basic GUI programming for you, while you are concentrating on your app specific stuff. Interfacing between GUI and low level things is quite easy using binder. And of course you can bring in whatever mecahnism you want via NDK.
We have considered Ubuntu Touch. But so far it doesn't seem to be mature enough.
I hope this is the right place to ask this.
I would like to work on an Android build with a completely custom OS. I was inspired by this project that ported Inferno to Android.
I would like to do this legally (obeying all terms of service and what-not) if possible, and I have no problem with disclosing my source code to a carrier.
Do any of you have experience with this? What are the considerations for getting a custom build to work with a carrier?
Since I am building on Android, I probably won't have to worry about cell/3g/4g hardware drivers, and I would like to buy a phone from the carrier anyway just to make sure it will be supportable.
I'm one of the creators of the Inferno project you mentioned. Anyway, making a completely custom OS for an Android phone will be difficult; a lot of the hardware will be undocumented or only drivable by Linux binary blobs. What we did (and what Boeing has also done recently for a commercial project) is strip away all the Java from an Android system, leaving a basic Linux upon which you can build your own custom interface. This lets you use all the hardware (since the drivers are in Linux), but everything that the end users see will be your stuff. There are a variety of ways to go from there. Inferno implements a virtual machine, so we can abstract the Linux stuff into our own Inferno-style world.
I don't think there should be any problems with the carriers. We started with a Cyanogenmod ROM and hacked on that; custom ROMs are just fine! I never had any problems, even when I was swapping my little pay-as-you-go SIM card among several phones running Gingerbread, ICS, and Inferno.
Head over to the AOSP source, and clone it. Strip out what you don't need in your branch and begin the kernel patching! You'll need to modify the kernel in portions to make it compatible (fairly) with the device you're on. The Android kernel is in fact a very close cousin of the Linux Kernel, and in Linux 3.3, they've begun merging the two. After this is done, write your interfacing mechanisms (be it a display, web interface, etc) and you can test it out on your platform.
I have a Symbian based phone with a ARM Cortex-A8 processor (SonyEricsson Vivaz) and was thinking on how hard would it be to try and port the Android OS for it. Obviously Android runs on a myriad of devices with different hardware so I imagine it shouldn't be too hard to adapt it to SE hardware. Could some one give me a clue where to start or if this is even undertakable...
How much information do you have about the hardware in the phone ? Are you starting completely from scratch ?
Porting Android is not simple task. First thing is to have Linux running (preferably 2.6.32 for more compatibility with the latest releases of AOSP.
If you can find a kernel that can run on your phone, that's one big step. After that, you want make sure that the peripherals you want to use also have the right drivers : touch interface, LCD display, SD card, audio, video. The ones that are probably most difficult will be wifi, radio (GSM) and power management module.
If you get that far, you don't have that much to go anymore, a few more changes in the kernel needed for Android, be able to compile Android correctly file system, hook up a few things like buttons and correctly interface with the drivers mentioned above...
But overall, definitely not an easy task (IMHO).
Android devices become incredible cheap (especially those with android v1.6). I'm considering to use one as a brain of autonomous robot. Unfortunately I didn't find any info on that.
I would like to connect two external USB-webcams and some DIY-selfmade USB ADC & output-ports converter to steer the wheels and read analog distance sensors. If I choose some cheap netbook than they usually already have 3 usb ports. But if I will be forced to use a tablet, then it requires also an usb hub.
Do android devices support usb-hubs?
Is there any API to grab still frames from external usb webcams (e.g. "vfa://0" & "vfa://1")
Is there any API to read from USB custom device? Let assume that it will simulate serial port for simplicity.
Do I get all of this in android 1.6 or any newer version?
As an update for your information: Based on answers I assume that android device will be too expensive in comparison to effort. I will go for cheap atom netbook with standard linux & arduinio USB device for controls & sensors. At cost of half kg (one pound) heavier device I will save months on learning & development.
You need an android device that either supports usb host mode out of the box (a few of the cheap tablets apparently do) or a phone that can do so with custom usb power wiring and perhaps a new kernel driver (as many phones can).
You will likely need root.
The api would be the normal linux USB stack, including just about any C-coded source-available device driver available for a desktop linux (excepting those that use bits of x86 binary windows drivers run in a compatibility wrapper).
You could interact with that either from the ndk using normal methods (device files, read/write/ioctl) or with careful driver design so things really look like files you can probably get at some of it from java or at the very least java with some thin ndk wrappers around device file operations.
Essentially, this isn't an "android" question, it's a question about the capabilities of a particular android device's hardware, how to get root on that device, and then it becomes a standard embedded linux question.
As far as I know you won't get any of this with the default Java API. Lots of this stuff can however be achieved if you build a custom kernel and add needed modules to it. Basically it all comes down to kernel hacking and won't be really Android related.
I'm very interested in stuff like that myself so keep me updated please.