Picking ARM or x86 to boot from - linux

I currently have a raspberry pi, and am using my sd card to boot into linux for on-the-go access. However, the sd card boots into an ubuntu x86 version, not ARM. I saw the tutorial on how to flash the sd card for a raspberry pi, but I was curious if there is a way to pick which OS with specific architecture to boot off of. Is there a way to choose whichever system you would like to boot from?

Your SD card currently allow you to boot on ubuntu x86. You just want to add the ability to boot on your RPi. This totally depends on the ability of the RPi. I can't find complete documentation on RPi processor (this is why I don't like RPi (and Broadcom)), but, according to some online documentation, the RPi boots on FAT32. Your PC is probably also able to boot on a FAT32-formated SD card.
So, if your SD card format fits RPi requirements, you may put your bootable ubuntu x86 and a RPi bootloader on the same SD card partition. RPi is baremetal ARM, so you may put anything you want in your bootloader, including looking for your kernel on FAT32 on SD card with any name you want. It is therefore possible to add your ARM bootloader, your ARM kernel, and an ARM ramfs on your SD card without interfering with the x86 related files. You may then add a partition on your SD card to put your ARM binaries (some will use the same name as the x86, such as bash or startx, and should not be put on the same location than x86 ones, to avoid conflicts), and share data partitions between x86 and ARM OS.

Related

porting and run the linux kernel on beaglebone black development board

i have already compile the linux kernel with arm compiler for beaglebone black.comile the uboot. and also filesystem debian. Now i want to run my compiled linux kernel on beaglebone. how can i do it?which image file has to be port? and how? using sd card or using usb to serial ttl connector? please help me descriptively.thank you
This excellent page created by Robert C. Nelson, who also maintains the official images for Beagleboard, covers it in great descriptive detail, #exactsteps even.

How to work on kernel with an embedded device?

Right now, I'm compiling with printk's, copy the resulting kernel to a USB stick, mounting the USB stick on the device, mounting the partition that contains the kernel, copying the new kernel from the USB stick to the partition, rebooting, then inspecting the trace by capturing the dmesg output to a file.
On workstation:
make my-kernel
cp new_kernel /path/to/usb/stick
On embedded device:
mount /dev/sda1/ /mnt
mount kernelpartition /tmp/kernel
cp /mnt/new_kernel /tmp/kernel
sync
umount /tmp/kernel
umount /dev/sda1
reboot
dmesg > mytrace
less mytrace
Is it supposed to this painful to develop? I don't understand how any meaningful amount of non-trivial kernel code is ever developed.
The best workflow is going to depend on the capabilities of the device you are working with. Often they will have a bootloader with options to boot from a network or serial port.
I'm doing some embedded development also, and here's what I came up with. The device I am working with has some built in flash which by default it boots from, but also has a USB port and an SD Card slot. It has a fairly primitive bootloader.
On the USB port I have connected a wifi dongle. I make sure that I compile the kernels with the needed modules to get the USB dongle up and running.
I have built a minimal kernel and root filesystem which I have flashed onto the device. This kernel has the option CONFIG_KEXEC enabled. The root filesystem has kexec tools. I build the system using buildroot.
When this system starts, it attempts to mount the SDCARD and checks to see if it can find a kernel in the root directory. If it can, then it uses kexec to boot this second kernel. This is done using a custom init script that I have written.
If you don't have an SD Card slot on your device, you could probably do something similar with a USB memory stick.
With this setup, I can just use sftp to transfer a new kernel image onto the sdcard, and kexec to boot it. It saves me the hassle of reflashing the device each time I change the kernel.

How can we use Linux from a small storage pen drive? Does it work on micro-controllers also?

I generally hear that LINUX OS can be downloaded on flash, pen drive (floppy disk?) etc. How we can do that?
I have RHEL 5.4 source code - so how can download it into pen drive and how much space is required?
What other functionality I can add apart from the OS - so that when I boot from that storage device I can make use of them?
Can we download Linux OS into micro-controllers also?
I generally hear that LINUX OS can be downloaded on flash, pen drive (floppy disk?) etc. How > we can do that?
If you can't get it to work on your own, you can buy a ready made Linux on a USB drive from
a site like http://www.osdisc.com or http://www.cheapbytes.com
Not all PCs, especially older PCs, can boot from the USB Drive. Even some newer PCs are beginning to ship with security features that can interfere with booting code. When it does work, you have to find out the proper way to boot the USB drive. You might have only a few seconds during reboot to enter the right key, or it will boot Windows (if Windows is installed). The key to get to the BIOS Boot Menu might be delete or escape or F10 or some other key (varies with PC motherboard manufacturer). A message on the screen that flashes by rather quickly might mention keys you can press. Boot to a specific device or changing boot order can also often be found in the BIOS setup.
There is a linux utility called unetbootin that will create a USB drive that will boot linux. It does not create a USB boot drive from a source code distribution, but rather from an ISO file representing a live CD or the live CD itself.
Since large USB drives (e.g. 32GB) are relatively inexpensive, if you want to compare systems or have multiple systems there is a way to have multiple linux and other operating systems on one USB drive and be able to choose which to boot into. See, for instance, http://www.pendrivelinux.com/ which has a wide variety of procedures for making a bootable USB using either windows or Linux to set up the USB and booting a variety of systems.
I have RHEL 5.4 source code - so how can download it into pen drive
and how much space is required?
RHEL 5.4 is a bit old. You need the Live CD, if there was one.
The ISO file can take up 600+MB. You want space left over to use the system. 2GB for the pen drive is OK. Sometimes you can get by with less.
What other functionality I can add apart from the OS - so that when I
boot from that storage device I can make use of them?
Upon boot the operating system will often recognize sound cards, other usb devices, the hard drives, etc. You need to know how to use these things within Linux, and how to enable them if they are not configured. Some Linux distributions have a place to put packages that are to be autoinstalled when a USB pen drive based system initializes. In this way you can "install" software from the distribution archives that are not included on the standard live system, even if you don't have internet access.
Can we download Linux OS into micro-controllers also?
People run it on raspberry pi and such, but the versions of Linux on non-PC hardware that has low memory are often quite tiny compared to a desktop version. They can be tiny enough to be challenging to work with or expand.

Implementing i2c from Linux Userspace

Sorry for the long description of my problem :-)
I have been handed a task to perform simple reads and writes to/from an I2C device on our new PC based board design. The board will be built using Portwell's Qseven mini PC which uses an Intel Tunnel Creek (ATOM) processor (essentially an x86 processor) and an EG20T IOH chip.
The I2C slave device is a TI AIC3254 audio codec. OS is Ubuntu 10.04 LTS 32 bit.
uname -a
Linux Torchwood 2.6.32-41-generic #88-Ubuntu SMP Thu Mar 29 13:08:43 UTC 2012 i686 GNU/Linux
The PC portion of this device will be essentially a general purpose PC.
The PC/OS needs to load the codec (registers) via I2C at system init. After that the codec will be controlled by an Atmel processor which will be a second master on the I2C bus (remaining silent until init is complete). The ATOM will have no additional direct interaction with the AIC3254.
All that I need to do, as far as I know, is to copy the codec's "program" to it over the I2C bus then read it back (poor man's load check).
It seems the logical approach is to use a userspace program to talk to the AIC3254 rather than try to create a device driver. However, after I modprobe i2c-dev; depmod -a no I2C bus appears in /dev and i2cdetect from i2c_tools finds no buses (devices?).
What I need is some understanding of Linux I2C access coding. Complete noob here.
Do I need a device driver after all? I don't need any fancy interface for general programs too use, just one simple read/write to bus/page/register. Perhaps a simple char mode driver? I've read something that suggests such things exist.
Do I need to put a *new_device* and *delete_device* file in /sys/bus/i2c/devices/i2c-0/?
Even with i2c-dev.ko installed no i2c-x "file" appears in /sys/bus/i2c/devices/ What am I missing here?
Can I assume or find out if this kernel knows about EG20T IOH chips? Or are these chips generic enough that i2c-dev can deal with them?
Will I need i2c-core.ko? It isn't found on the Ubuntu image. What do I need to apt-get to have it if I need it?
Do I have any use for the i2c-algo_???.ko's?
Sorry to be such a noob. Thanks for any help.
I think you need to add i2c support in your board support file when you build the kernel for the target. We use an Atmel based board to do i2c, and during kernel init, it calls i2c_register_board_info() to register the i2c devices. Then you can access them using i2c-tools, and userspace apps. Note we are using 3.2.6 kernel, but similar calls are likely needed for 2.6 kernels

How to compile and install a Linux kernel into an ARM kit

I have an ARM kit beside me and a Linux kernel source code patched with Xenomai on my machine. I understand I can send data to the kit through an USB cable and a (windows-based, of course) software, but I'm stumped as to exactly what I should be sending that would make the kit run Linux.
(clarifications from comments: It is an Atmel AT91SAM9260-EK kit. It uses SAM-BA and SAM-PROG for the loading and unloading of data through either a serial or USB cable.)
I'd start with the ATM91SAM9 Linux software package from Atmel and follow the instructions.
Linky:
http://www.atmel.com/dyn/products/tools_card.asp?tool_id=4335
Otherwise, you need to get GCC setup with an ARM back end on a Linux box, build a Linux binary and then figure out how to load it on the devt board.
You might want to check out some cross compiler like OpenEmbedded which will help you compile the kernel for the ARM architecture.
i would suggest jtag and openOCD, then you just use the JTAG to place your filesystem and kernal image in the flash memory, in a place wear our bootloader can find it. you might have to change your bootloader.
another option is you might start up your micro, then insert a bootloading program into the RAM of the program then change the program counter to point at it.
that bootloading program can init the UART/USB then you have a host side program that transers the files. this method is very complicated and generally only good if you don't want to spend 100$ on a jtag (hint, buy a jtag they are useful)

Resources