date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,428,913,881,000
Will it be legal if I use the DuckDuckGo search engine without Creating a DuckDuckGo Email Protection account? Or Can I use the DuckDuckGo search engine without Creating a DuckDuckGo Email Protection account? Thank you
ERROR: type should be string, got "\nhttps://duckduckgo.com/ is a completely free of charge search engine. What's more, there is absolutely no obligation or reason to register. Just go to the web site and search without the need of registration or anything related.\n"
Can I use the DuckDuckGo search engine without Creating a DuckDuckGo Email Protection account? [closed]
1,312,470,873,000
Possible Duplicate: “No such file or directory” lies on Optware installed binaries I'm trying to add ebtables to a little router box. I went and got a binary compiled for the correct architecture, and put it on the box in /sbin/. When I do /sbin/ebtables, the shell says /bin/sh: /sbin/ebtables: not found, but I can do ls -l /sbin/ebtables and it shows up perfectly: -rwxr-xr-x 1 admin admin 4808 Aug 4 10:36 /sbin/ebtables Any ideas about what's going on here?
It could be a missing dependency. Notably you'll get that type of message if the runtime linker ("program interpreter") set in the ELF header does not exist on your system. To check for that, run: readelf -l your_executable|grep "program interpreter" If what it gives you does not exist on your system, or has missing dependencies (check with ldd), you'll get that strange error message. Demo: $ gcc -o test t.c $ readelf -l test|grep "program interpreter" [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2] $ ./test hello! $ gcc -Wl,--dynamic-linker -Wl,/i/dont/exist.so -o test t.c $ readelf -l test|grep "program interpreter" [Requesting program interpreter: /i/dont/exist.so] $ ./test bash: ./test: No such file or directory
Why does sh say "not found" when it's definitely there? [duplicate]
1,312,470,873,000
Recently we had a rather unpleasant situation with our customer - Raspberry Pi based "kiosk" used to display remote sensing data (nothing more fancy than a kiosk mode browser displaying a self-updating webpage from the data-collection server) failed to boot due to filesystem corruption. Ext4, Manual fsck required, the system will be a part of tomorrow's important presentation, service required immediately. Of course we can't require the customer to shut down the system nicely when switching it off for the night; the system must simply withstand such mistreatment. I'd like to avoid such situations in the future, and I'd like to move the OS to a filesystem that would prevent this. There's a bunch of filesystems intended for MTD devices, where getting them to run on SD card (a standard block device) requires some serious hoop-jumping. There are also some other filesystems (journalling etc) that boast good resistance against corruption. I still need to see some reasonable comparison of their pros and cons. Which filesystem available in Linux would provide best resistance against corruption on unexpected power failures and not require jumping through impossible hoops like yaffs2 in order to install to SD. Wear-balancing is a plus, but not a requirement - SD cards usually have their own mechanisms, if less than perfect, though the system should be "gentle for flash" (systems like NTFS can murder an SD card within a month).
The best resistance against corruption on a single SD card would be offered by BTRFS in RAID1 mode with automatic scrub run every predefined period of time. The benefits: retaining ability to RW to the filesystem modern, fully featured filesystem with very useful options for an RPi, like transparent compression and snapshots designed with flash memory in mind (among other things) Here is how to do it: I run my RaspberryPi on ArchARM linux and my card is in the SD reader, so modify those instructions accordingly for other distros and /dev interfaces. Here is an example partition layout: /dev/mmcblk0p1: fat32 boot partition /dev/mmcblk0p2: to be used as btrfs partition /dev/mmcblk0p3: to be used as btrfs partition (mirrored with the above) /dev/mmcblk0p4 (optional): swap To get btrfs into RAID1, you create the filesystem like so: mkfs.btrfs -m raid1 -d raid1 /dev/mmcblk0p2 /dev/mmcblk0p3 Then you rsync -aAXv to it your previously backed up system. To get it to boot from BTRFS in raid1, you need to modify initramfs. Therefore, you need to do the following while you still have your system running on your old filesystem. Raspberry does not normally use mkinitcpio so you must install it. Then, you need to add “btrfs” to MODULES array in mkinitcpio.conf and recreate initramfs with mkinitcpio -g /boot/initrd -k YOUR_KERNEL_VERSION To know what to type instead of YOUR_KERNEL_VERSION, run ls /lib/modules If you update the kernel, you MUST recreate initramfs BEFORE you reboot. Then, you need to modify RPi’s boot files. In cmdline.txt, you need to have root=/dev/mmcblk0p2 initrd=0x01f00000 rootfstype=btrfs and in config.txt, you need to add initramfs initrd 0x01f00000 Once you’ve done all that and successfully booted into your btrfs RAID1 system, the only thing left is to set up periodic scrub (every 3-7 days) either with systemd timer (preferred), or cron (dcron) like so: btrfs scrub start / It will run on your filesystem comparing checksums of all the files and fixing them (replacing with the correct copy) if it finds any corruption. The combination of BTRFS RAID1, single medium and Raspberry Pi make this pretty arcane stuff. It took some time and work to put all the pieces together, but here it is.
Corruption-proof SD card filesystem for embedded Linux?
1,312,470,873,000
I am looking for a way to mount a ZIP archive as a filesystem so that I can transparently access files within the archive. I only need read access -- the ZIP will not be modified. RAM consumption is important since this is for a (resource constrained) embedded system. What are the available options?
fuse-zip is an option and claims to be faster than the competition. # fuse-zip -r archivetest.zip /mnt archivemount is another: # archivemount -o readonly archivetest.zip /mnt Both will probably need to open the whole archive, therefore won't be particularly quick. Have you considered extracting the ZIP to a HDD or USB-stick beforehand and simply mounting that read-only? There are also other libraries like fuse-archive and ratarmount which supposedly are more performant under certain situations and provide additional features.
Mount zip file as a read-only filesystem
1,312,470,873,000
I want to check, from the linux command line, if a given cleartext password is the same of a crypted password on a /etc/shadow (I need this to authenticate web users. I'm running an embedded linux.) I have access to the /etc/shadow file itself.
You can easily extract the encrypted password with awk. You then need to extract the prefix $algorithm$salt$ (assuming that this system isn't using the traditional DES, which is strongly deprecated because it can be brute-forced these days). correct=$(</etc/shadow awk -v user=bob -F : 'user == $1 {print $2}') prefix=${correct%"${correct#\$*\$*\$}"} For password checking, the underlying C function is crypt, but there's no standard shell command to access it. On the command line, you can use a Perl one-liner to invoke crypt on the password. supplied=$(echo "$password" | perl -e '$_ = <STDIN>; chomp; print crypt($_, $ARGV[0])' "$prefix") if [ "$supplied" = "$correct" ]; then … Since this can't be done in pure shell tools, if you have Perl available, you might as well do it all in Perl. (Or Python, Ruby, … whatever you have available that can call the crypt function.) Warning, untested code. #!/usr/bin/env perl use warnings; use strict; my @pwent = getpwnam($ARGV[0]); if (!@pwent) {die "Invalid username: $ARGV[0]\n";} my $supplied = <STDIN>; chomp($supplied); if (crypt($supplied, $pwent[1]) eq $pwent[1]) { exit(0); } else { print STDERR "Invalid password for $ARGV[0]\n"; exit(1); } On an embedded system without Perl, I'd use a small, dedicated C program. Warning, typed directly into the browser, I haven't even tried to compile. This is meant to illustrate the necessary steps, not as a robust implementation! /* Usage: echo password | check_password username */ #include <stdio.h> #include <stdlib.h> #include <pwd.h> #include <shadow.h> #include <sys/types.h> #include <unistd.h> int main(int argc, char *argv[]) { char password[100]; struct spwd shadow_entry; char *p, *correct, *supplied, *salt; if (argc < 2) return 2; /* Read the password from stdin */ p = fgets(password, sizeof(password), stdin); if (p == NULL) return 2; *p = 0; /* Read the correct hash from the shadow entry */ shadow_entry = getspnam(username); if (shadow_entry == NULL) return 1; correct = shadow_entry->sp_pwdp; /* Extract the salt. Remember to free the memory. */ salt = strdup(correct); if (salt == NULL) return 2; p = strchr(salt + 1, '$'); if (p == NULL) return 2; p = strchr(p + 1, '$'); if (p == NULL) return 2; p[1] = 0; /*Encrypt the supplied password with the salt and compare the results*/ supplied = crypt(password, salt); if (supplied == NULL) return 2; return !!strcmp(supplied, correct); } A different approach is to use an existing program such as su or login. In fact, if you can, it would be ideal to arrange for the web application to perform whatever it needs via su -c somecommand username. The difficulty here is to feed the password to su; this requires a terminal. The usual tool to emulate a terminal is expect, but it's a big dependency for an embedded system. Also, while su is in BusyBox, it's often omitted because many of its uses require the BusyBox binary to be setuid root. Still, if you can do it, this is the most robust approach from a security point of view.
How to check password with Linux?
1,312,470,873,000
Buildroot is generating images for an embedded device where they should run. This is working very well. In those images, the rootfs is included. Due to some research, I'd like to look into that generated file (e.g. different compression modes set by the Buildroot were applied and now shall be checked if they were correctly done), but I can't find something useful in the Net. As far as I know, the difference between a uImage and zImage is just a small header, so u-boot is able to read that binary file. But I can open neither uImage nor the zImage. Can anyone give me a hint of how to decompress those (u/z)Images on the host?
mkimage -l uImage Will dump the information in the header. tail -c+65 < uImage > out Will get the content. tail -c+65 < uImage | gunzip > out will get it uncompressed if it was gzip-compressed. If that was an initramfs, you can do cpio -t < out or pax < out to list the content. If it's a ramdisk image, you can try and mount it with: mount -ro loop out /mnt file out could tell you more about what it is.
How to extract files from uImage?
1,312,470,873,000
When booting a kernel in an embedded device, you need to supply a device tree to the Linux kernel, while booting a kernel on a regular x86 pc doesn't require a device tree -- why? As I understand, on an x86 pc the kernel "probes" for hardware (correct me if I'm wrong), so why can't the kernel probe for hardware in and embedded system?
Peripherals are connected to the main processor via a bus. Some bus protocols support enumeration (also called discovery), i.e. the main processor can ask “what devices are connected to this bus?” and the devices reply with some information about their type, manufacturer, model and configuration in a standardized format. With that information, the operating system can report the list of available devices and decide which device driver to use for each of them. Some bus protocols don't support enumeration, and then the main processor has no way to find out what devices are connected other than guessing. All modern PC buses support enumeration, in particular PCI (the original as well as its extensions and successors such as AGP and PCIe), over which most internal peripherals are connected, USB (all versions), over which most external peripherals are connected, as well as Firewire, SCSI, all modern versions of ATA/SATA, etc. Modern monitor connections also support discovery of the connected monitor (HDMI, DisplayPort, DVI, VGA with EDID). So on a PC, the operating system can discover the connected peripherals by enumerating the PCI bus, and enumerating the USB bus when it finds a USB controller on the PCI bus, etc. Note that the OS has to assume the existence of the PCI bus and the way to probe it; this is standardized on the PC architecture (“PC architecture” doesn't just mean an x86 processor: to be a (modern) PC, a computer also has to have a PCI bus and has to boot in a certain way). Many embedded systems use less fancy buses that don't support enumeration. This was true on PC up to the mid-1990s, before PCI overtook ISA. Most ARM systems, in particular, have buses that don't support enumeration. This is also the case with some embedded x86 systems that don't follow the PC architecture. Without enumeration, the operating system has to be told what devices are present and how to access them. The device tree is a standard format to represent this information. The main reason PC buses support discovery is that they're designed to allow a modular architecture where devices can be added and removed, e.g. adding an extension card into a PC or connecting a cable on an external port. Embedded systems typically have a fixed set of devices¹, and an operating system that's pre-loaded by the manufacturer and doesn't get replaced, so enumeration is not necessary. ¹ If there's an external bus such as USB, USB peripherals are auto-discovered, they wouldn't be mentioned in the device tree.
Why do embedded systems need device tree while pcs don't?
1,312,470,873,000
I am using an embedded Arm with a Debian build. How does one list the compiled devices from the device tree? I want to see if a device is already supported. For those reading this, the "Device Tree" is a specification/standard for adding devices to an (embedded) Linux kernel.
The device tree is exposed as a hierarchy of directories and files in /proc. You can cat the files, eg: find /proc/device-tree/ -type f -exec head {} + | less Beware, most file content ends with a null char, and some may contain other non-printing characters.
How to list the kernel Device Tree [duplicate]
1,312,470,873,000
One of functionalities I miss the most from "small embedded" in Embedded Linux is the interrupts. A signal appears on a specific pin, or other interrupt source is triggered and whatever was done inside the CPU gets interrupted, and my function of interrupt handler is launched. In Linux everything is buffered, if something happens the system just goes about its own course and when (at last) given thread is brought to foreground, its wait-state expecting the external source ends, and its handler starts. The closest thing I know are the signals, which can trigger a handler interrupting normal flow of the thread, but still, the handler will not pick up the signal until the kernel brings the thread into foreground, which may be many milliseconds after the signal happened - and triggering the signals isn't as robust either; I need an app or a kernel module to send a signal, I can't just trivially attach it to a GPIO pin. How could I achieve a functionality similar to hardware interrupts within Linux userspace software - have a specific function launched or specific thread brought to foreground immediately after an externally sourced condition is triggered, without waiting for the process queue to bring my thread to foreground? If you feel this question is too broad, let's narrow it to a specific example: a Raspberry Pi board receives a signal on one of its GPIO pins (not necessarily arbitrary; if only some pins can do that, that's okay.) I want my userspace application to react to this event within least time possible, be it bringing it out of wait state, launching a handler function or any equivalent mechanism, but above all not waiting for the task queue to cycle through all pending processes before the handler is brought to foreground, but trigger it ASAP. (and specifically, when there is no signal, not leaving the system locked forever with the handler process occupying 100% CPU time polling the input and never yielding to the OS.) Is there such a mechanism?
If I understand your question this articled sounds like what you're looking for. The article is titled: Device drivers in user space. excerpt UIO drivers Linux provides a standard UIO (User I/O) framework for developing user-space-based device drivers. The UIO framework defines a small kernel-space component that performs two key tasks: a. Indicate device memory regions to user space. b. Register for device interrupts and provide interrupt indication to user space. The kernel-space UIO component then exposes the device via a set of sysfs entries like /dev/uioXX. The user-space component searches for these entries, reads the device address ranges and maps them to user space memory. The user-space component can perform all device-management tasks including I/O from the device. For interrupts however, it needs to perform a blocking read() on the device entry, which results in the kernel component putting the user-space application to sleep and waking it up once an interrupt is received. I've never done this before so I can not offer you much more guidance than this, but thought it might be helpful towards your quest.
Can I achieve functionality similar to interrupts in Linux userspace?
1,312,470,873,000
I have an embedded Linux ARM system that is showing significantly less throughput than expected on both Ethernet and USB. I suspect the memory may be contributing. Is there a way to observe the memory bandwidth that is consumed while running a throughput test on the Ethernet or USB?
There is a memory bandwidth benchmark available in open source. It works for Intel & ARM under Linux or Windows Mobile CE. It will give you raw performance for your memory as well as system performance with memory. But it won't give you a real-time bandwidth, so I don't know if it's a good answer to your question. There's also a memtop tool out there, but it's more about usage than bandwidth. Perf tool can be handy in order to detect page fault.
How can I observe memory bandwidth?
1,312,470,873,000
The rootfs is a squashfs image and my bootloader is loading it into some address in SDRAM. What parameters do I need to pass to the kernel so It can mount the rootfs from there? Squashfs support is built-in and it already works with root=/dev/mtdblock2 rootfstype=squashfs for booting from the flash. EDIT: This is a MIPS based embedded device, using a custom bootloader. Normally, the bootloader extracts the compressed kernel from the flash into the SDRAM, and then kernel mounts /dev/mtdblock2 as the rootfs. I am trying to improve the bootloader so it can download an image to its RAM and boot without writing to the flash. I cannot figure out how to make Linux mount a filesystem image in the RAM as the rootfs.
I would use an initramfs. (http://www.kernel.org/doc/Documentation/filesystems/ramfs-rootfs-initramfs.txt) Many Linux distributions use an initramfs (not to be confused with an initrd, they are different) during the boot process, mostly to be able to start userspace programs very early in the boot process. However, you can use it for whatever you want. The benefit of an initramfs over an initrd is that an initramfs uses a tmpfs filesystem while an initrd uses a ram block device. The key difference here is that for an initrd, you must preallocate all the space for the filesystem, even if you're not going to use all that space. So if you don't use the filesystem space, you waste ram, which on an embedded device, is often a scarce resource. Tmpfs is a filesystem which runs out of ram, but only uses as much ram as is currently in use on the filesystem. So if you delete a file from a tmpfs, that ram is immediately freed up. Now normally an initramfs is temporary, only used to run some programs extremely early in the boot process. After those programs run, control is turned over to the real filesystem running on a physical disk. However, you do not have to do that. There is nothing stopping you from running out of the initramfs indefinitely.
How do I have Linux boot with a rootfs in RAM?
1,312,470,873,000
It's a question about user space applications, but hear me out! Three "applications", so to speak, are required to boot a functional distribution of Linux: Bootloader - For embedded typically that's U-Boot, although not a hard requirement. Kernel - That's pretty straightforward. Root Filesystem - Can't boot to a shell without it. Contains the filesystem the kernel boots to, and where init is called form. My question is in regard to #3. If someone wanted to build an extremely minimal rootfs (for this question let's say no GUI, shell only), what files/programs are required to boot to a shell?
That entirely depends on what services you want to have on your device. Programs You can make Linux boot directly into a shell. It isn't very useful in production — who'd just want to have a shell sitting there — but it's useful as an intervention mechanism when you have an interactive bootloader: pass init=/bin/sh to the kernel command line. All Linux systems (and all unix systems) have a Bourne/POSIX-style shell in /bin/sh. You'll need a set of shell utilities. BusyBox is a very common choice; it contains a shell and common utilities for file and text manipulation (cp, grep, …), networking setup (ping, ifconfig, …), process manipulation (ps, nice, …), and various other system tools (fdisk, mount, syslogd, …). BusyBox is extremely configurable: you can select which tools you want and even individual features at compile time, to get the right size/functionality compromise for your application. Apart from sh, the bare minimum that you can't really do anything without is mount, umount and halt, but it would be atypical to not have also cat, cp, mv, rm, mkdir, rmdir, ps, sync and a few more. BusyBox installs as a single binary called busybox, with a symbolic link for each utility. The first process on a normal unix system is called init. Its job is to start other services. BusyBox contains an init system. In addition to the init binary (usually located in /sbin), you'll need its configuration files (usually called /etc/inittab — some modern init replacement do away with that file but you won't find them on a small embedded system) that indicate what services to start and when. For BusyBox, /etc/inittab is optional; if it's missing, you get a root shell on the console and the script /etc/init.d/rcS (default location) is executed at boot time. That's all you need, beyond of course the programs that make your device do something useful. For example, on my home router running an OpenWrt variant, the only programs are BusyBox, nvram (to read and change settings in NVRAM), and networking utilities. Unless all your executables are statically linked, you will need the dynamic loader (ld.so, which may be called by different names depending on the choice of libc and on the processor architectures) and all the dynamic libraries (/lib/lib*.so, perhaps some of these in /usr/lib) required by these executables. Directory structure The Filesystem Hierarchy Standard describes the common directory structure of Linux systems. It is geared towards desktop and server installations: a lot of it can be omitted on an embedded system. Here is a typical minimum. /bin: executable programs (some may be in /usr/bin instead). /dev: device nodes (see below) /etc: configuration files /lib: shared libraries, including the dynamic loader (unless all executables are statically linked) /proc: mount point for the proc filesystem /sbin: executable programs. The distinction with /bin is that /sbin is for programs that are only useful to the system administrator, but this distinction isn't meaningful on embedded devices. You can make /sbin a symbolic link to /bin. /mnt: handy to have on read-only root filesystems as a scratch mount point during maintenance /sys: mount point for the sysfs filesystem /tmp: location for temporary files (often a tmpfs mount) /usr: contains subdirectories bin, lib and sbin. /usr exists for extra files that are not on the root filesystem. If you don't have that, you can make /usr a symbolic link to the root directory. Device files Here are some typical entries in a minimal /dev: console full (writing to it always reports “no space left on device”) log (a socket that programs use to send log entries), if you have a syslogd daemon (such as BusyBox's) reading from it null (acts like a file that's always empty) ptmx and a pts directory, if you want to use pseudo-terminals (i.e. any terminal other than the console) — e.g. if the device is networked and you want to telnet or ssh in random (returns random bytes, risks blocking) tty (always designates the program's terminal) urandom (returns random bytes, never blocks but may be non-random on a freshly-booted device) zero (contains an infinite sequence of null bytes) Beyond that you'll need entries for your hardware (except network interfaces, these don't get entries in /dev): serial ports, storage, etc. For embedded devices, you would normally create the device entries directly on the root filesystem. High-end systems have a script called MAKEDEV to create /dev entries, but on an embedded system the script is often not bundled into the image. If some hardware can be hotplugged (e.g. if the device has a USB host port), then /dev should be managed by udev (you may still have a minimal set on the root filesystem). Boot-time actions Beyond the root filesystem, you need to mount a few more for normal operation: procfs on /proc (pretty much indispensible) sysfs on /sys (pretty much indispensible) tmpfs filesystem on /tmp (to allow programs to create temporary files that will be in RAM, rather than on the root filesystem which may be in flash or read-only) tmpfs, devfs or devtmpfs on /dev if dynamic (see udev in “Device files” above) devpts on /dev/pts if you want to use [pseudo-terminals (see the remark about pts above) You can make an /etc/fstab file and call mount -a, or run mount manually. Start a syslog daemon (as well as klogd for kernel logs, if the syslogd program doesn't take care of it), if you have any place to write logs to. After this, the device is ready to start application-specific services. How to make a root filesystem This is a long and diverse story, so all I'll do here is give a few pointers. The root filesystem may be kept in RAM (loaded from a (usually compressed) image in ROM or flash), or on a disk-based filesystem (stored in ROM or flash), or loaded from the network (often over TFTP) if applicable. If the root filesystem is in RAM, make it the initramfs — a RAM filesystem whose content is created at boot time. Many frameworks exist for assembling root images for embedded systems. There are a few pointers in the BusyBox FAQ. Buildroot is a popular one, allowing you to build a whole root image with a setup similar to the Linux kernel and BusyBox. OpenEmbedded is another such framework. Wikipedia has an (incomplete) list of popular embedded Linux distributions. An example of embedded Linux you may have near you is the OpenWrt family of operating systems for network appliances (popular on tinkerers' home routers). If you want to learn by experience, you can try Linux from Scratch, but it's geared towards desktop systems for hobbyists rather than towards embedded devices. A note on Linux vs Linux kernel The only behavior that's baked into the Linux kernel is that the first program that's launched at boot time. (I won't get into initrd and initramfs subtleties here.) This program, traditionally called init, has process ID 1 and has certain privileges (immunity to KILL signals) and responsibilities (reaping orphans). You can run a system with a Linux kernel and start whatever you want as the first process, but then what you have is an operating system based on the Linux kernel, and not what is normally called “Linux” — Linux, in the common sense of the term, is a Unix-like operating system whose kernel is the Linux kernel. For example, Android is an operating system which is not Unix-like but based on the Linux kernel.
What are the minimum root filesystem applications that are required to fully boot linux?
1,312,470,873,000
I have been tasked with running Linux as an operating system on an embedded device. The target has an x86 processor and has 8 GB CompactFlash device for storage. I have managed to use buildroot to create the kernel image and cross compilation tools. I have partitioned the CF device into a small FAT partition where the kernel image resides as well as syslinux boot configuration and an ext3 file system where I have decompressed the root file system generated by buildroot to. The system boots successfully using syslinux by setting the root directory to the CF ext3 partition where my buildroot file system is located. My question is centred around the need for robustness in the face of immediate (and frequent) power loss as it is crucial for the device to boot successfully after power outages. I have read that mounting the root file system as read only is a way of ensuring data integrity. Is this a sensible way for me to proceed? I have also read about the possibility of loading the root file system into RAM to achieve the same thing but as yet do not know how to do so. Is there a preferred way of achieving this goal and if so what is the best way for me to proceed?
New answer (2015-03-22) (Note: This answer is simpler than previous, but not more secure. My first answer is stronger because you could keep files read-only by fs mount options before permission flags. So forcing to write a files without permission to write won't work at all.) Yes, under Debian, there is a package: fsprotect (homepage). It use aufs (by default, but could use another unionfs tool) to permit live session changes but in RAM by default, so everything is forgotten at reboot. You could install them by running simply: apt-get install fsprotect Once done, from online doc: After that: Edit /boot/grub/menu.lst or /etc/default/grub2 or /etc/lilo.conf and add "fsprotect=1G" to kernel parameters. Modify 1G as needed. Apply changes (i.e. run update-grub) Edit /etc/default/fsprotect if you want to protect filesystems other than /. reboot You may also want to password protect the grub bootloader or forbid any changes to it. From there, if some file is protected against changes, for sample by chmod ugo-w myfile if you use for sample vi myfile and try to write on it with command :w!, this will work and your myfile became changed. You may reboot in order to retrieve unmodified myfile. That's not even possible with my following first solution: Old (first) answer: Yes, it is a strong solution, but powerfull! Making r/o useable You have to mount some directories in rw, like /var, /etc and maybe /home. This could by done using aufs or unionfs. I like this another way, using /dev/shm and mount --bind: cp -a /var /dev/shm/ mount --bind /dev/shm/var /var You could before, move all directories who have not to change in normal operation in a static-var, than create symlinks in /var: mkdir /static-var mkdir /static-var/cache mkdir /static-var/lib mv /var/lib/dpkg /static-var/lib/dpkg ln -s /static-var/lib/dpkg /var/lib/dpkg mv /var/cache/apt /static-var/cache/apt ln -s /static-var/cache/apt /var/cache/apt ... # an so on So when remounting in ro, copying /var in /dev/shm won't take too much space as most files are moved to /static-var and only symlinks are to be copied in ram. The better way to do this finely is to make a full power-cycle, one day of full work and finely run a command like: find / -type f -o -type f -mtime -1 So you will see which files needs to be located on read-write partition. Logging As in this host no writeable static memory exist, in order to store history and other logs, you have to config a remote syslog server. echo >/etc/syslog.conf '*.* @mySyslogServer.localdomain' In this way, if your system break for any reason, everything before is logged. Upgrading When running whith some mount --bind in use, for doing such an upgrade while system is in use (whithout the need of running init 1, for reducing down-time), the simplier way is to re-build a clean root, able to do the upgrade: After remounting '/' in read-write mode: mount -o remount,rw / for mpnt in /{,proc,sys,dev{,/pts}};do mount --bind $mnpt /$mnt$mpnt; done chroot /mnt apt-get update && apt-get dist-upgrade exit umount /mnt/{dev{/pts,},proc,sys,} sync mount -o remount,ro / And now: shutdown -r now
Is using a read only root file system a good idea for embedded setup?
1,312,470,873,000
I'm working on an embedded Linux project where I will be developing a program that will run automatically on bootup and interact with the user via a character display and some sort of button array. If we go with a simple GPIO button array, I can easily write program that will look for keypresses on those GPIO lines. However, one of our thoughts was to use a USB number pad device instead for user input. My understanding is that those devices will present themselves to the OS as a USB keyboard. If go down this path, is there a way for my program to look for input on this USB keyboard from within Linux, keeping in mind that there is no virtual terminal or VGA display. When a USB keyboard is plugged in, is there an entity in '/dev' that appears that I can open a file descriptor for?
Devices most likely get a file in /dev/input/ named eventN where N is the various devices like mouse, keyboard, jack, power-buttons etc. ls -l /dev/input/by-{path,id}/ should give you a hint. Also look at: cat /proc/bus/input/devices Where Sysfs value is path under /sys. You can test by e.g. cat /dev/input/event2 # if 2 is kbd. To implement use ioctl and check devices + monitor. EDIT 2: OK. I'm expanding on this answer based on the assumption /dev/input/eventN is used. One way could be: At startup loop all event files found in /dev/input/. Use ioctl() to request event bits: ioctl(fd, EVIOCGBIT(0, sizeof(evbit)), &evbit); then check if EV_KEY-bit is set. IFF set then check for keys: ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybit)), &keybit); E.g. if number-keys are interesting, then check if bits for KEY_0 - KEY9 and KEY_KP0 to KEY_KP9. IFF keys found then start monitoring event file in thread. Back to 1. This way you should get to monitor all devices that meet the wanted criteria. You can't only check for EV_KEY as e.g. power-button will have this bit set, but it obviously won't have KEY_A etc. set. Have seen false positives for exotic keys, but for normal keys this should suffice. There is no direct harm in monitoring e.g. event file for power button or a jack, but you those won't emit events in question (aka. bad code). More in detail below. EDIT 1: In regards to "Explain that last statement …". Going over in stackoverflow land here … but: A quick and dirty sample in C. You'll have to implement various code to check that you actually get correct device, translate event type, code and value. Typically key-down, key-up, key-repeat, key-code, etc. Haven't time, (and is too much here), to add the rest. Check out linux/input.h, programs like dumpkeys, kernel code etc. for mapping codes. E.g. dumpkeys -l Anyhow: Run as e.g.: # ./testprog /dev/input/event2 Code: #include <stdio.h> #include <string.h> /* strerror() */ #include <errno.h> /* errno */ #include <fcntl.h> /* open() */ #include <unistd.h> /* close() */ #include <sys/ioctl.h> /* ioctl() */ #include <linux/input.h> /* EVIOCGVERSION ++ */ #define EV_BUF_SIZE 16 int main(int argc, char *argv[]) { int fd, sz; unsigned i; /* A few examples of information to gather */ unsigned version; unsigned short id[4]; /* or use struct input_id */ char name[256] = "N/A"; struct input_event ev[EV_BUF_SIZE]; /* Read up to N events ata time */ if (argc < 2) { fprintf(stderr, "Usage: %s /dev/input/eventN\n" "Where X = input device number\n", argv[0] ); return EINVAL; } if ((fd = open(argv[1], O_RDONLY)) < 0) { fprintf(stderr, "ERR %d:\n" "Unable to open `%s'\n" "%s\n", errno, argv[1], strerror(errno) ); } /* Error check here as well. */ ioctl(fd, EVIOCGVERSION, &version); ioctl(fd, EVIOCGID, id); ioctl(fd, EVIOCGNAME(sizeof(name)), name); fprintf(stderr, "Name : %s\n" "Version : %d.%d.%d\n" "ID : Bus=%04x Vendor=%04x Product=%04x Version=%04x\n" "----------\n" , name, version >> 16, (version >> 8) & 0xff, version & 0xff, id[ID_BUS], id[ID_VENDOR], id[ID_PRODUCT], id[ID_VERSION] ); /* Loop. Read event file and parse result. */ for (;;) { sz = read(fd, ev, sizeof(struct input_event) * EV_BUF_SIZE); if (sz < (int) sizeof(struct input_event)) { fprintf(stderr, "ERR %d:\n" "Reading of `%s' failed\n" "%s\n", errno, argv[1], strerror(errno) ); goto fine; } /* Implement code to translate type, code and value */ for (i = 0; i < sz / sizeof(struct input_event); ++i) { fprintf(stderr, "%ld.%06ld: " "type=%02x " "code=%02x " "value=%02x\n", ev[i].time.tv_sec, ev[i].time.tv_usec, ev[i].type, ev[i].code, ev[i].value ); } } fine: close(fd); return errno; } EDIT 2 (continued): Note that if you look at /proc/bus/input/devices you have a letter at start of each line. Here B means bit-map. That is for example: B: PROP=0 B: EV=120013 B: KEY=20000 200 20 0 0 0 0 500f 2100002 3803078 f900d401 feffffdf ffefffff ffffffff fffffffe B: MSC=10 B: LED=7 Each of those bits correspond to a property of the device. Which by bit-map means, 1 indicate a property is present, as defined in linux/input.h. : B: PROP=0 => 0000 0000 B: EV=120013 => 0001 0010 0000 0000 0001 0011 (Event types sup. in this device.) | | | || | | | |+-- EV_SYN (0x00) | | | +--- EV_KEY (0x01) | | +------- EV_MSC (0x04) | +----------------------- EV_LED (0x11) +--------------------------- EV_REP (0x14) B: KEY=20... => OK, I'm not writing out this one as it is a bit huge. B: MSC=10 => 0001 0000 | +------- MSC_SCAN B: LED=7 => 0000 0111 , indicates what LED's are present ||| ||+-- LED_NUML |+--- LED_CAPSL +---- LED_SCROLL Have a look at /drivers/input/input.{h,c} in the kernel source tree. A lot of good code there. (E.g. the devices properties are produced by this function.) Each of these property maps can be attained by ioctl. For example, if you want to check what LED properties are available say: ioctl(fd, EVIOCGBIT(EV_LED, sizeof(ledbit)), &ledbit); Look at definition of struct input_dev in input.h for how ledbit are defined. To check status for LED's say: ioctl(fd, EVIOCGLED(sizeof(ledbit)), &ledbit); If bit 1 in ledbit are 1 then num-lock are lit. If bit 2 is 1 then caps lock is lit etc. input.h has the various defines. Notes when it comes to event monitoring: Pseudo-code for monitoring could be something in the direction of: WHILE TRUE READ input_event IF event->type == EV_SYN THEN IF event->code == SYN_DROPPED THEN Discard all events including next EV_SYN ELSE This marks EOF current event. FI ELSE IF event->type == EV_KEY THEN SWITCH ev->value CASE 0: Key Release (act accordingly) CASE 1: Key Press (act accordingly) CASE 2: Key Autorepeat (act accordingly) END SWITCH FI END WHILE Some related documents: Documentation/input/input.txt, esp. note section 5. Documentation/input/event-codes.txt, description of various events etc. Take note to what is mentioned under e.g. EV_SYN about SYN_DROPPED Documentation/input ... read up on the rest if you want.
Is it possible for a daemon (i.e. background) process to look for key-presses from a USB keyboard?
1,312,470,873,000
This question is fairly lengthy, so I'll ask the questions at the top and then go through my method of coming to the questions: Did (Busybox based) rm not execute because there wasn't enough contiguous RAM? If so, is there a lightweight method of defragging the DMA - without resorting to a system restart? If not, what caused it? How can I prevent it from happening in the future? After our test system had been running fairly intensively over the last few days - I telnet'd into the system and checked the test results. When I came to delete some data, the system returned the command line (as if the command had executed correctly). When I came to check the directory for another set of results, I saw the file still existed (using ls). After this, I noticed more and more of my shell commands wern't performing as expected. I'll start off with an output from dmesg after rm failed to execute correctly: Allocation of length 61440 from process 6821 (rm) failed DMA per-cpu: CPU 0: hi: 0, btch: 1 usd: 0 Active_anon:0 active_file:1 inactive_anon:0 inactive_file:0 unevictable:6 dirty:0 writeback:0 unstable:0 free:821 slab:353 mapped:0 pagetables:0 bounce:0 DMA free:3284kB min:360kB low:448kB high:540kB active_anon:0kB inactive_anon:0kB active_file:4kB inactive_file:0kB unevictable:24kB present:8128kB pages_scanned:0 all_unreclaimable? no lowmem_reserve[]: 0 0 0 DMA: 31*4kB 47*8kB 42*16kB 64*32kB 1*64kB 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 3284kB 14 total pagecache pages Unable to allocate RAM for process data, errno 12 Initially, I thought I was unable to run the program in the largest portion of contiguous memory. Meaning the DMA was too fragmented and I would have to find a way of getting the system to defragment the memory. Then I did a quick math/sanity check and realised that the program should have been able to run in the sole 64kB contiguous memory slot. Rm was requesting 61440 bytes (60kB). I did a good old "manual defrag" and rebooted the system. When I rebooted the sytem I output /proc/buddyinfo: Node 0, zone DMA 2 8 3 12 0 1 0 1 0 1 0 Which I suspect map to: 2 x 4 kB 8 x 8 kB 3 x 16 kB 12 x 32 kB 1 x 128 kB 1 x 512 kB But if one sums the above list of values, it doesn't match up with the output of /proc/meminfo: MemTotal: 6580 kB MemFree: 3164 kB Buffers: 0 kB Cached: 728 kB SwapCached: 0 kB Active: 176 kB Inactive: 524 kB Active(anon): 0 kB Inactive(anon): 0 kB Active(file): 176 kB Inactive(file): 524 kB` Unevictable: 0 kB Mlocked: 0 kB MmapCopy: 844 kB SwapTotal: 0 kB SwapFree: 0 kB Dirty: 0 kB Writeback: 0 kB AnonPages: 0 kB Mapped: 0 kB Slab: 1268 kB SReclaimable: 196 kB SUnreclaim: 1072 kB PageTables: 0 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 3288 kB Committed_AS: 0 kB VmallocTotal: 0 kB VmallocUsed: 0 kB VmallocChunk: 0 kB To recap, my questions are: Did rm not execute because there wasn't enough contiguous RAM? If so, is there a lightweight method of defragging the DMA - without resorting to a system restart? If not, what caused it? How can I prevent it from happening in the future? I am using Lantronix's XPort Pro (8MB, Linux OS) running uClinux version 2.6.30. The shell in use is hush.
It's taken a bit of time, but I thought I'd hold off answering until I had answers to all 3 of my sub-questions. Before I start though, I will mention that the correct term when it comes to "de-fragmenting" working memory is referred to "compacting" working memory. 1. Did rm not execute because there wasn't enough contiguous RAM? I was correct in my conclusion - rm didn't execute because there was insufficient contiguous RAM. The system had been acquiring RAM and fragmenting it, thus making it unreclaimable. 2. If so, is there a lightweight method of defragging the DMA - without resorting to a system restart? Turns out there is no way of compacting the memory, short of restarting the embedded system. In the case of a MMU-less system, prevention is the name of the game. Part of me ponders if its possible to hack the linux kernel to emulate the MMU in software. I figure if it were possible, someone would have done it already. I can't imagine its an entirely new concept ;) 3. How can I prevent it from happening in the future? For this project, I was using cron to manually initiate the program each time it was required. A much better way to do this is to call the program on start up, and then force the program to sleep until it is required. This way, the memory doesn't need to be allocated on each use. Thus reducing fragmentation. On the first iteration of the project, we relied on my shell script calls to perform critical functions (such as rm). We didn't see the need in re-inventing the wheel if we didn't need to. However, I would recommend avoiding the shell where possible for an MMU-less system - (Question, what happens if you execute ls -la /path/to/directory/ | grep file-i-seek?) (Answer: it starts a new subprocess) If you need to implement some of the core shell script functionality in your C program, I recommend checking out the source code used in BusyBox. Chances are you'll be using C in your embedded system..
Defragging RAM / OOM failure
1,312,470,873,000
I'm dealing with an embedded device running Linux. The manufacturers of this device have it set up so that it loads the root filesystem as readonly. From /etc/mtab: rootfs / rootfs rw 0 0 /dev/root / squashfs ro,relatime 0 0 This means that I'm unable to modify any files within /etc, such as to add a new user. I've tried remounting the root directory: mount -o remount,rw -t squashfs /dev/root / but I just get an error mount: cannot remount block device /dev/root read-write, is write-protected I looked up this error and people were saying to use blockdev. The system doesn't have blockdev installed, so I cross compiled it and copied it across. Then I ran blockdev --setrw rootfs but again I got an error: blockdev: cannot open rootfs: No such file or directory Is it possible to make /etc writeable if it's not already? I have root access to the system, but I'm not able to access the filesystem 'offline', all changes have to be done via Bash commands.
squashfs is a read-only compressed file system. It has no provision to make modification to it once it's been created. So you couldn't write to it even if the underlying block device could be made writeable. You'd need to create a new squashfs image of the whole filesystem with your modifications and burn it to the storage device where that file system is stored, which would be problematic to do from the live system. Another option is to mount a different file system on /etc. It could be via a union mount if supported by the kernel, which merges two file systems together typically with one file system recording only the changes to a base read-only file system. Check for support for AUFS_FS or OVERLAY_FS in the kernel config. For instance to union-mount a directory in /tmp (hopefully writeable though possibly on tmpfs in memory (so not persistent across a reboot) in your case if the system has no permanent writeable storage) mkdir -p /tmp/etc/work /tmp/etc/upper mount -t overlay \ -o lowerdir=/etc,upperdir=/tmp/etc/upper,workdir=/tmp/etc/work \ overlay /etc Then /etc will be writeable and modifications you make to it will actually be stored in /tmp/etc/upper. Alternatively, if it's only a few file you want to modify, you could bind-mount them (yes you can mount on any file, not only directories) from a version stored in a writable file systems: cp /etc/passwd /tmp mount --bind /tmp/passwd /etc/passwd Then /etc/passwd would be writeable. Of course you can also do that for the whole of /etc instead. (cp -a /etc /tmp && mount --bind /tmp/etc /etc).
Make readonly /etc writeable
1,312,470,873,000
I'm trying to identify an embedded Linux distribution. Here are the commands I have typed so far: $ uname -a Linux LIN-SRV-EMB01 3.10.105 #25556 SMP Sat Aug 28 02:14:22 CST 2021 x86_64 GNU/Linux synology_bromolow_rs3412rpxs $ lsb_release -sh: lsb_release: command not found $ ls /usr/lib/os-release ls: cannot access /usr/lib/os-release: No such file or directory $ cat /proc/version Linux version 3.10.105 (root@build1) (gcc version 4.9.3 20150311 (prerelease) (crosstool-NG 1.20.0) ) #25556 SMP Sat Aug 28 02:14:22 CST 2021 $ cat /proc/cmdline root=/dev/md0 netif_seq=2130 ahci=0 SataPortMap=34443 DiskIdxMap=03060e0a00 SataLedSpecial=1 ihd_num=0 netif_num=4 syno_hw_version=RS3412rpxs macs=001132109b1e,001132109b1f,001132109b20,001132109b21 sn=LDKKN90098 $ dmesg | grep "Linux version" [ 0.000000] Linux version 3.10.105 (root@build1) (gcc version 4.9.3 20150311 (prerelease) (crosstool-NG 1.20.0) ) #25556 SMP Sat Aug 28 02:14:22 CST 2021 [ 342.396803] Loading modules backported from Linux version v3.18.1-0-g39ca484 $ python -m platform Linux-3.10.105-x86_64-with-glibc2.2.5 $ which python2 && python2 -c "import platform;print platform.linux_distribution()[0]" /bin/python2 $ which python3 && python3 -c "import distro;print(distro.name())" $ more /etc/issue /etc/*release /etc/*version /boot/config* more: stat of /etc/issue failed: No such file or directory more: stat of /etc/*release failed: No such file or directory more: stat of /etc/*version failed: No such file or directory more: stat of /boot/config* failed: No such file or directory $ zcat /proc/config.gz /usr/src/linux/config.gz | more gzip: /proc/config.gz: No such file or directory gzip: /usr/src/linux/config.gz: No such file or directory $ which dpkg apt apt-get rpm urpmi yum dnf zypper /bin/dpkg $ df -h / Filesystem Size Used Avail Use% Mounted on /dev/md0 2.3G 1.1G 1.1G 50% / $ sudo parted /dev/md0 print Password: Model: Linux Software RAID Array (md) Disk /dev/md0: 2550MB Sector size (logical/physical): 512B/512B Partition Table: loop Disk Flags: Number Start End Size File system Flags 1 0.00B 2550MB 2550MB ext4 $ sudo mdadm -Q /dev/md0 /dev/md0: 2.37GiB raid1 10 devices, 0 spares. Use mdadm --detail for more detail. $ which lsblk lscsci lshw lspci dmidecode /bin/lspci /sbin/dmidecode EDIT0: Tried two more commands : $ strings $(ps -p 1 -o cmd= | cut -d" " -f1) | egrep -i "ubuntu|debian|centos|redhat" -o | sort -u -sh: strings: command not found [remoteserver] $ ssh embedded-linux 'cat $(ps -p 1 -o cmd= | cut -d" " -f1)' | strings | egrep -i "ubuntu|debian|centos|redhat" -o | sort -u ubuntu EDIT1: Tried three more commands : $ which initctl && initctl --version /sbin/initctl initctl (upstart 1.13.2) Copyright (C) 2006-2014 Canonical Ltd., 2011 Scott James Remnant This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ which systemctl && systemctl --version $ cat /sys/class/dmi/id/product_name To be filled by O.E.M. $ EDIT2: Tried one more command (specific to Synology) : $ grep productversion /etc/VERSION productversion="6.2.4" EDIT3: Just in case one wants to identify the hardware : $ uname -u # Specific to Synology ? synology_bromolow_rs3412rpxs $ sudo dmidecode -t system | grep Product Product Name: To be filled by O.E.M. $ $ cat /sys/devices/virtual/dmi/id/product_name To be filled by O.E.M. $ EDIT4 : On another Synology, I get : $ uname -u synology_broadwell_rs3618xs I guess it's based on Ubuntu+upstart. EDIT5 : Distrib can be identified using this Observium script or this LibreNMS script. What other commands can I use to look a little deeper?
The uname -a output identifies this as a Synology device. Such devices run Synology DiskStation Manager. This is Linux-based, but it is not managed like a typical Linux system running a “traditional” Linux distribution. It has its own package manager, synopkg, for which third-party packages are made available by SynoCommunity. The DiskStation CLI guide describes a few administration tools available in DSM. If you’re interested in automating administrative tasks on such devices, you might find Synology’s Central Management System useful.
How can I identify an embedded Linux distribution?
1,312,470,873,000
How to know whether a particular patch is applied to the kernel? Especially RT-Preempt Patch.
In the case of preempt you can just use uname: uname -v #23 SMP PREEMPT RT Fri Oct 16 11:52:29 CET 2012 The string PREEMPT shows that you use a kernel version with the realtime patch. Some other patches might also changes the uname string. So it might also be a help. If this is not the case you can try to look at your .config. The file could be found in the /boot directory or (if enabled) by using cat /proc/config.gz. Maybe there is also a version in /usr/src/linux (or where you put the kernel sources). If you found the config file you can grep for specific settings and find out if a patch is used.
Checking linux Kernel for RT-Preempt Patch
1,312,470,873,000
I'm currently trying to make HSP bluetooth profile works on a custom board based on Atmel SAMA5D2. I'm using a custom Linux made from Buildroot-2017-08. I'm at the point where I try to configure pulseaudio. The pulseaudio package is the one from buildroot and I ticked "start as system daemon". When the system starts, pulseaudio seems to be running # ps aux | grep pulse 174 pulse usr/bin/pulseaudio --system --daemonize --disallow-exit --disallow-module-loading 197 root grep pulse However when I try to communicate with the daemon it fails # pacmd No PulseAudio daemon running, or not running as session daemon. # pacmd info No PulseAudio daemon running, or not running as session daemon. # pactl info Connection failure: Access denied I realized that the message change if I export the following environement variable # export PULSE_RUNTIME_PATH="/run/pulse" # pacmd info Daemon not responding. # pactl info Connection failure: Access denied Concerning rights to access this folder here they are # ls -la /run/pulse/ total 8 drwx------ 3 root root 120 Jan 2 05:09 . drwxr-xr-x 6 root root 240 Jan 2 05:09 .. drwxr-xr-x 3 pulse pulse 60 Jan 2 05:09 .config -rw------- 1 pulse pulse 16 Jan 2 05:09 .esd_auth srwxrwxrwx 1 pulse pulse 0 Jan 2 05:09 native -rw------- 1 pulse pulse 4 Jan 2 05:09 pid From this question Problems with pulseaudio - pavucontrol and pacmd not connecting to pulseaudio I tried to change rights about the directory but it didn't changed anything. # ls -la /run/pulse/ total 8 drwx------ 3 pulse pulse 120 Jan 2 05:09 . drwxr-xr-x 6 root root 240 Jan 2 05:09 .. drwxr-xr-x 3 pulse pulse 60 Jan 2 05:09 .config -rw------- 1 pulse pulse 16 Jan 2 05:09 .esd_auth srwxrwxrwx 1 pulse pulse 0 Jan 2 05:09 native -rw------- 1 pulse pulse 4 Jan 2 05:09 pid It seems that there are some problems when looking at logs but I can't say if this is a big deal or not. # cat /var/log/messages | grep pulse Jan 2 05:43:19 buildroot pulseaudio[174]: [pulseaudio] caps.c: Normally all extra capabilities would be dropped now, but that's impossible because PulseAudio was built without capabil. Jan 2 05:43:19 buildroot pulseaudio[174]: [pulseaudio] main.c: OK, so you are running PA in system mode. Please note that you most likely shouldn't be doing that. Jan 2 05:43:19 buildroot pulseaudio[174]: [pulseaudio] main.c: If you do it nonetheless then it's your own fault if things don't work as expected. Jan 2 05:43:19 buildroot pulseaudio[174]: [pulseaudio] main.c: Please read http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/WhatIsWrongWithSystemWide/ for an exp. Jan 2 05:43:19 buildroot pulseaudio[174]: [pulseaudio] module.c: module-detect is deprecated: Please use module-udev-detect instead of module-detect! Jan 2 05:43:19 buildroot pulseaudio[174]: [pulseaudio] alsa-util.c: Disabling timer-based scheduling because high-resolution timers are not available from the kernel. Jan 2 05:43:20 buildroot pulseaudio[174]: [pulseaudio] authkey.c: Failed to open cookie file '/var/run/pulse/.config/pulse/cookie': No such file or directory Jan 2 05:43:20 buildroot pulseaudio[174]: [pulseaudio] authkey.c: Failed to load authentication key '/var/run/pulse/.config/pulse/cookie': No such file or directory Jan 2 05:43:20 buildroot pulseaudio[174]: [pulseaudio] authkey.c: Failed to open cookie file '/var/run/pulse/.pulse-cookie': No such file or directory Jan 2 05:43:20 buildroot pulseaudio[174]: [pulseaudio] authkey.c: Failed to load authentication key '/var/run/pulse/.pulse-cookie': No such file or directory Also I have no choice to run pulseaudio as root because there is no other user on my target. EDIT : After restarting pulseaudio in verbose mode (-vvv) it seems that the problem comes from an invalid connection data # pactl info -vvv Connection failure: Access denied # cat /var/log/messages | grep pulse | tail -n 20 Jan 2 06:27:51 buildroot pulseaudio[250]: [pulseaudio] main.c: Daemon startup successful. Jan 2 06:27:51 buildroot pulseaudio[252]: [pulseaudio] main.c: Daemon startup complete. Jan 2 06:27:51 buildroot pulseaudio[252]: [pulseaudio] module.c: Unloading "module-detect" (index: #0). Jan 2 06:27:51 buildroot pulseaudio[252]: [pulseaudio] module.c: Unloaded "module-detect" (index: #0). Jan 2 06:27:56 buildroot pulseaudio[252]: [pulseaudio] module-suspend-on-idle.c: Sink alsa_output.0.analog-stereo idle for too long, suspending ... Jan 2 06:27:56 buildroot pulseaudio[252]: [pulseaudio] sink.c: Suspend cause of sink alsa_output.0.analog-stereo is 0x0004, suspending Jan 2 06:27:56 buildroot pulseaudio[252]: [alsa-sink-CLASSD PCM atmel-classd-hifi-0] alsa-sink.c: Device suspended... Jan 2 06:27:56 buildroot pulseaudio[252]: [pulseaudio] core.c: Hmm, no streams around, trying to vacuum. Jan 2 06:28:28 buildroot pulseaudio[252]: [pulseaudio] client.c: Created 0 "Native client (UNIX socket client)" Jan 2 06:28:28 buildroot pulseaudio[252]: [pulseaudio] protocol-native.c: Protocol version: remote 31, local 31 Jan 2 06:28:28 buildroot pulseaudio[252]: [pulseaudio] protocol-native.c: Got credentials: uid=0 gid=0 success=0 Jan 2 06:28:28 buildroot pulseaudio[252]: [pulseaudio] protocol-native.c: Denied access to client with invalid authentication data. Jan 2 06:28:28 buildroot pulseaudio[252]: [pulseaudio] client.c: Freed 0 "Native client (UNIX socket client)" Jan 2 06:28:28 buildroot pulseaudio[252]: [pulseaudio] protocol-native.c: Connection died. Jan 2 06:28:43 buildroot pulseaudio[252]: [pulseaudio] client.c: Created 1 "Native client (UNIX socket client)" Jan 2 06:28:43 buildroot pulseaudio[252]: [pulseaudio] protocol-native.c: Protocol version: remote 31, local 31 Jan 2 06:28:43 buildroot pulseaudio[252]: [pulseaudio] protocol-native.c: Got credentials: uid=0 gid=0 success=0 Jan 2 06:28:43 buildroot pulseaudio[252]: [pulseaudio] protocol-native.c: Denied access to client with invalid authentication data. Jan 2 06:28:43 buildroot pulseaudio[252]: [pulseaudio] client.c: Freed 1 "Native client (UNIX socket client)" Jan 2 06:28:43 buildroot pulseaudio[252]: [pulseaudio] protocol-native.c: Connection died. After adding root user to pulse group the problem persists. EDIT 2 : Changing the process access rights to allow pulse group's members to read/write and execute files seems to unlock a bit the situation as I can now communicate with the daemon but not act on it. # pactl info Server String: /run/pulse/native Library Protocol Version: 31 Server Protocol Version: 31 Is Local: yes Client Index: 1 Tile Size: 65496 User Name: pulse Host Name: buildroot Server Name: pulseaudio Server Version: 9.0 Default Sample Specification: s16le 2ch 44100Hz Default Channel Map: front-left,front-right Default Sink: alsa_output.platform-fc048000.classd.analog-stereo Default Source: alsa_output.platform-fc048000.classd.analog-stereo.monitor Cookie: 6ae9:b402 # pacmd info Daemon not responding.
Finally, seems that it was a profile issue. I just changed the umask line from umask 077 to umask 007 in /etc/init.d/S50pulseaudio so members of group pulse can access files. Content of /etc/init.d/S50pulseaudio: #!/bin/sh # # Starts pulseaudio. # start() { printf "Starting pulseaudio: " #umask 077 umask 007 /usr/bin/pulseaudio --system --daemonize --disallow-exit --disallow-module-loading -vvv echo "OK" } stop() { printf "Stopping pulseaudio: " killall pulseaudio echo "OK" } restart() { stop start } case "$1" in start) start ;; stop) stop ;; restart|reload) restart ;; *) echo "Usage: $0 {start|stop|restart}" exit 1 esac exit $? Regarding pacmd it's normal I can't access it as I'm running pulseaudio system-wide.
Pulseaudio daemon not running for pacmd
1,312,470,873,000
I need an extendable Linux distribution which I can easily reduce in size so much that it fits into a 64 mb CF card. In this stripped version it will run on a Via C7 and needed is Kernel, networking, a shell, basic perl and a ftp server. There are some distributions for embedded systems which can do this, however I have the requirement that it should be possible to to expand this set in the future, e.g. to a basic X setup or python instead of perl etc. Which distribution do you know which can do this? Can any one of the major distributions like Fedora, Debian, Ubuntu be stripped down so much? Edit: I looked at Embedded Debian which seems pretty close to what I need. Sadly, development seems to have stalled due to health problems of the main maintainer.
After quite some research I settled in the end for SliTaz. I can really recommend it, as I haven't found any distribution which is so flexible. There is a minimum system (well under 20 MB--choose from the Live CD flavors), basically giving you just a shell and ssh access. However, there is a huge package repository so you can extend to graphical interface or server daemons etc.
Which minimal but extendable Linux distribution to choose
1,312,470,873,000
I am running a small uClibc and busybox based embedded system on an x86 device. I am using an initramfs but I also mounting a custom ext3 directory on a compact flash device in IDE mode that I am using to store persistent measurement logging data created by a custom written c++ application. I chose the ext3 file system as it is recommended for safety against power loss when using CF drives in IDE mode in a couple of books I have read (Building Embedded Linux Systems by Karim Yaghmour and Embedded Linux Primer by Christopher Hallinan). This is particularly important and the data is critical. However, due to some of the comments in my previous question Confusion with how to restore corrupt ext3 files if power outage occurs during a file write it would appear that in fact this file system does not offer the guarantee of safety against data corruption due to power loss. So I would like to know if Is ext3 actually the best choice for this setup? Does power loss during a disc write operation only corrupt the portion of data I am appending to the file periodically or can it corrupt the entire file? Is data that is not being written at the point of power loss completely safe? In particular, is there any risk that my initramfs.cpio file can become corrupt also? Is there any method I can use in my application code to protect the data (i.e. creating an extra partition and writing my data to mirror images so that there are always 2 copies) - speed is not a real issue for my application so expensive copying operations are acceptable. I have seen and read the answers to this related question: Do journaling filesystems guarantee against corruption after a power failure?, but it doesn't quite cover some of the things that are confusing me. I realise that I am asking a lot of questions but it seems that despite reading a lot of material I have had a fundamental failure to understand the risks to my data in the event of power loss.
As with all things pertaining to security, there aren't any guarantees, but you also need to balance risk (and cost) against probability. From experience (and I've been running dozens of *nix boxen since the dark ages), I've never really had significant power-caused filesystem corruption. Some of these machines were even running on non-journalled filesystems (ufs and ext2 usually). Some of them were embedded, and a few were mobile phones like the Nokia N900 — so a good power supply wasn't at all guaranteed. It's not that filesystem corruption can't happen, it's just that the probability of it happening is low enough that it shouldn't worry you. Still, no reason not to hedge your bets. In answer to your literal questions: At least the first book you referenced was written before ext4 — when the author suggests using ext3, they're really saying ‘don't use unstable or non-journalled filesystems like ext2’). Try ext4, it's quite mature, and has some decent options for non-spinning disks which may extend the life expectancy of your flash device. Chances are it would lose you the last block or two, not the entire file. With a journalled filesystem, this will be about the only loss. There are failure scenarios where I could see random data sprayed across the file, but they seem about as likely as a micrometeorite smashing right through your embedded device. See 2. Nothing is 100.00% safe. If you have a second IDE channel, stick a second CF card in there and grab a backup of the filesystem periodically. There are a few ways to do this: rsync, cp dump, dd, even using the md(4) (software RAID) device (you add the second drive occasionally, let it sync, then remove it — if both devices are live all the time, they run the same risk of filesystem corruption). If you use LVM, you can even grab snapshots. For a data collection embedded device, I'd just use am ad hoc solution which mounts the second filesystem, copies over the data log, the immediately unmounts it. If you're worried about the device having a good boot image, stick a second copy of the boot manager and all necessary boot images on the second device and configure the computer to boot from either CF card. I wouldn't trust a second copy on the same device because storage devices fail more often than stable filesystems. Much more often, in my experience so far (at work, there was a bitter half-joke about the uncannily high chances of Friday afternoon disk failures. It was almost a weekly event for a while). Whether the disk is spinning or not, it can fail. So keep your eggs in two baskets if you can, and you'll protect your data better. If the data is particularly sensitive, I'd pay regular visits to the device, swap the backup CF for a fresh one and reboot, letting it fsck all its filesystems for good measure.
What filesystem offers best protection for securing data against corruption due to power loss?
1,312,470,873,000
I'm looking for a programmable Linux controller for home automation and general fun projects. Requirements: Controlling electric appliances - On/Off switches and dimmers (perhaps using relays) Receive analogue and digital data from sensors (switches, temperatures, etc.) USB connection Running Linux Advantages: Network connection / Web interface Python support Small display screen Keyboard and VGA support I used to have a lot of fun with a Handy Board, but it broke down a few months ago, and it lacks many vital features.
Is not so powerfull as a normal PC, but you should try arduino platform. You can buy a great and cheap unit here: http://www.libelium.com/ Google a little bit about arduino and you will find a lot of references and a big community
Linux Programmable Controller
1,312,470,873,000
I am building a disk image for an embedded system (to be placed on an 4GB SD card). I want the system to have two partitions. A 'Root'(200Mb), and a 'Data' partition(800Mb). I create an empty 1GB file with dd. Then I use parted to set up the partitions. I mount them each in a loop device then format them; ext2 for 'Root' ext4 for 'Data'. Add my root file system to the 'Root' partition and leave 'Data' empty. Here's where the problem is. I am now stuck with a 1GB image, with only 200MB of data on it. Shouldn't I, in theory, be able to truncate the image down to say.. 201MB and still have the file system mountable? Unfortunately I have not found this to be the case. I recall in the past having used a build environment from Freescale that used to create 30Mb images, that would have partitions for utilizing an entire 4GB sdcard. Unfortunately, at this time, I can not find how they were doing that. I have read the on-disk format for the ext file system, and if there is no data in anything past the first super block (except for backup super blocks, and unused block tables) I thought I could truncate there. Unfortunately, when I do this, the mounting system freaks out. I can then run FSCK, restore the super blocks, and block tables, and can mount it then no problem. I just don't think that should be necessary. Perhaps a different file system could work? Any ideas? thanks, edit changed partition to read file system. The partition is still there and deoesn't change, but the file system is getting destroyed after truncating the image. edit I have found the case to be that when I truncate the file to a size just larger than the first set of 'Data' partition superblock and inode/block tables, (Somewhere in the data-block range) the file system becomes umountable without doing a fsck to restore the rest of the super blocks and block/inode tables
Firstly, writing a sparse image to a disk will not result in anything but the whole of the size of that image file - holes and all - covering the disk. This is because handling of sparse files is a quality of the filesystem - and a raw device (such as the one to which you write the image) has no such thing yet. A sparse file can be stored safely and securely on a medium controlled by a filesystem which understands sparse files (such as an ext4 device) but as soon as you write it out it will envelop all that you intend it to. And so what you should do is either: Simply store it on an fs which understands sparse files until you are prepared to write it. Make it two layers deep... Which is to say, write out your main image to a file, create another parent image with an fs which understands sparse files, then copy your image to the parent image, and... When it comes time to write the image, first write your parent image, then write your main image. Here's how to do 2: Create a 1GB sparse file... dd bs=1kx1k seek=1k of=img </dev/null Write two ext4 partitions to its partition table: 1 200MB, 2 800MB... printf '%b\n\n\n\n' n '+200M\nn\n' 'w\n\c' | fdisk img Create two ext4 filesystems on a -Partitioned loop device and put a copy of the second on the first... sudo sh -c ' for p in "$(losetup --show -Pf img)p"* ### the for loop will iterate do mkfs.ext4 "$p" ### over fdisks two partitions mkdir -p ./mnt/"${p##*/}" ### and mkfs, then mount each mount "$p" ./mnt/"${p##*/}" ### on dirs created for them done; sync; cd ./mnt/*/ ### next we cp a sparse image cp --sparse=always "$p" ./part2 ### of part2 onto part1 dd bs=1kx1k count=175 </dev/zero >./zero_fill ### fill out part1 w/ zeroes sync; cd ..; ls -Rhls . ### sync, and list contents umount */; losetup -d "${p%p*}" ### last umount, destroy rm -rf loop*p[12]/ ' ### loop devs and mount dirs mke2fs 1.42.12 (29-Aug-2014) Discarding device blocks: done Creating filesystem with 204800 1k blocks and 51200 inodes Filesystem UUID: 2f8ae02f-4422-4456-9a8b-8056a40fab32 Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729 Allocating group tables: done Writing inode tables: done Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done mke2fs 1.42.12 (29-Aug-2014) Discarding device blocks: done Creating filesystem with 210688 4k blocks and 52752 inodes Filesystem UUID: fa14171c-f591-4067-a39a-e5d0dac1b806 Superblock backups stored on blocks: 32768, 98304, 163840 Allocating group tables: done Writing inode tables: done Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done 175+0 records in 175+0 records out 183500800 bytes (184 MB) copied, 0.365576 s, 502 MB/s ./: total 1.0K 1.0K drwxr-xr-x 3 root root 1.0K Jul 16 20:49 loop0p1 0 drwxr-xr-x 2 root root 40 Jul 16 20:42 loop0p2 ./loop0p1: total 176M 12K drwx------ 2 root root 12K Jul 16 20:49 lost+found 79K -rw-r----- 1 root root 823M Jul 16 20:49 part2 176M -rw-r--r-- 1 root root 175M Jul 16 20:49 zero_fill ./loop0p1/lost+found: total 0 ./loop0p2: total 0 Now that's a lot of output - mostly from mkfs.ext4 - but notice especially the ls bits at the bottom. ls -s will show the actual -size of a file on disk - and it is always displayed in the first column. Now we can basically reduce our image to only the first partition... fdisk -l img Disk img: 1 GiB, 1073741824 bytes, 2097152 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xc455ed35 Device Boot Start End Sectors Size Id Type img1 2048 411647 409600 200M 83 Linux img2 411648 2097151 1685504 823M 83 Linux There fdisk tells us there are 411647 +1 512 byte sectors in the first partition of img... dd seek=411648 of=img </dev/null That truncates the img file to only its first partition. See? ls -hls img 181M -rw-r--r-- 1 mikeserv mikeserv 201M Jul 16 21:37 img ...but we can still mount that partition... sudo mount "$(sudo losetup -Pf --show img)p"*1 ./mnt ...and here are its contents... ls -hls ./mnt total 176M 12K drwx------ 2 root root 12K Jul 16 21:34 lost+found 79K -rw-r----- 1 root root 823M Jul 16 21:34 part2 176M -rw-r--r-- 1 root root 175M Jul 16 21:34 zero_fill And we can append the stored image of the second partition to the first... sudo sh -c ' dd seek=411648 if=./mnt/part2 of=img umount ./mnt; losetup -D mount "$(losetup -Pf --show img)p"*2 ./mnt ls ./mnt; umount ./mnt; losetup -D' 1685504+0 records in 1685504+0 records out 862978048 bytes (863 MB) copied, 1.96805 s, 438 MB/s lost+found Now that has grown our img file: it's no longer sparse... ls -hls img 1004M -rw-r--r-- 1 mikeserv mikeserv 1.0G Jul 16 21:58 img ...but removing that is as simple the second time as it was the first, of course... dd seek=411648 of=img </dev/null ls -hls img 181M -rw-r--r-- 1 mikeserv mikeserv 201M Jul 16 22:01 img
How do I create small disk image with large partitions
1,312,470,873,000
Can the default permissions and ownership of /sys/class/gpio/ files be set, e.g. by configuring udev? The point would be to have a real gid for processes that can access GPIO pins on a board. Most "solutions" include suid wrappers, scripts with chown and trusted middleman binaries. Web searches turn up failed attempts to write udev rules. (related: Q1) (resources: avrfreaks, linux, udev)
The GPIO interface seems to be built for system (uid root) use only and doesn't have the features a /dev interface would for user processes. This includes creation permissions. In order to allow user processes (including daemons and other system services) access, the permissions need to be granted by a root process at some point. It could be an init script, a middleman, or a manual (sudo) command.
Set GPIO permissions cleanly
1,312,470,873,000
I failed to find the kernel binary in the standard location in /boot. I've also searched the whole file system for vmlinux or bzimage find / -iname vmlin* find / -iname bzimage However, this is an embedded device not a standard desktop. Is it possible that the kernel binary is located on a different storage location which isn't mounted. Example: / is mounted on the SD card and the kernel is written on flash? If not, what are the options for locating the kernel binary?
/boot is the standard location for the kernel in desktop/server distributions, but embedded systems vary greatly. Where the kernel is stored entirely depends on your bootloader, and it may not be a file as embedded bootloaders are often not capable of reading Linux filesystems. For example, with U-Boot (a popular embedded bootloader), you create an image with mkimage, which may then be written to a separate FAT partition or written in some other system-specific format. If the kernel image is on a FAT partition, that partition is often not mounted under Linux, since Linux never needs to access it (except during upgrades, but most embedded systems don't upgrade their kernel separately from the bootloader). The upshot is that you have to look for it. If you need help, you need to describe your system very precisely, and even then we may or may not be able to help depending on how popular your embedded system is. If you can't find it on your own, consider asking for support from the providers of the embedded system.
Location of the kernel binary (when not in /boot)?
1,312,470,873,000
I am working on an embedded device running on Linux. This device communicates with a server and sends data to it using a certificate and a private key. When we distribute the device, I am afraid that some evil people might steal that private key by hacking through the file system of the embedded device, and try to tamper with the data on our server. Even if I encrypt that private key, since the running program needs to decrypt the key, they could still find the decrypting key somewhere on the file system. Changing the permissions of the files would not be a solution as we must inherently distribute the device, and as such, anyone can have physical access to it. I would be glad to hear any suggestion to protect the private key without preventing the running program from using it. Thank you. Edit: We use Yocto running on Intel Edison.
If your hardware is not physically secure, nothing you do in software will give you physical security. Don't bother encrypting unless you have a separate, secure location for the key. Full disk encryption on a computer is useful when someone types in the (password to derive the) key at boot time. Full disk encryption can also be done if the key is on a separate, physically protected storage area such as a TPM or smartcard. As far as I can tell, the Intel Edison has no such separate storage area. Furthermore, an Edison board can be booted from an SD card or USB stick, so anyone who has physical access to a USB port can extract all the data from the eMMC. It seems that USB boot relies on U-Boot, so it's possible that replacing the official U-Boot image by a custom one that disables USB would force booting from the OS on eMMC. I don't actually know whether that's a possibility, I just don't have enough information to refute it. Even with a custom bootloader, the board can be reflashed through the USB connection. This overwrites part of the eMMC, but not the whole thing, at least if the flash is interrupted. No matter where you try to put the key on the eMMC, a careful attacker could avoid overwriting it. If your server needs to trust the data from the device, the feature you're looking for is called “secure boot” (or “trusted boot” or “verified boot” or a few other names, terminology isn't standardized). With Intel processors, this is achieved through a TPM (but embedded boards rarely have a TPM). With ARM processors, this is achieved through TrustZone plus some manufacturer-dependent tools. Neither technology is proof against an adversary who can spend a large sum of money, but breaking them requires at the very least a soldering iron, not just a USB stick.
Encrypt files (private key, etc.) in an embedded system
1,312,470,873,000
The system clock is maintained by the kernel, whereas the hardware clock is maintained by the Real Time Clock (RTC). Do both clock run at same frequency? Are both independent of each other? What happens when Real time clock fails? Does it affect the system clock? Can anyone let me know the difference between both the clocks.
both clock run at same frequency? Usually there are two clocks inside a computer/device/system. One is powered from a battery (usually a CR2032, could be the main battery or even a supercap in an embedded system) and runs from an dedicated chip. The other one is driven by the CPU clock source (with its own quartz crystal). One usually runs from a 32.768kHz crystal. The other one from a CPU crystal Mhz or GHz range. There is a lot of variation as there are a lot of CPU models. both are independent of each other? Yes, most of the time. But one could adjust the other (on embedded linux you typically have the hwclock command with options -r or -w). The CPU clock is set by the chip clock on boot (the CPU has no idea of what time it is when booting). For a system in a network, the CPU clock might find better time value from the network via the NTP (Network Time Protocol) and then adjust or correct the value inside the clock chip. what happens when Real time clock fails does it affect system clock? Yes, sure, if the battery runs out, for example, the computer boots up with a completely out of wack idea of real time But, nowadays, most of the systems have some network connectivity and update their concept of real time pretty soon after boot via the NTP protocol. can anyone let me know the difference between both the clocks. As said above, one clock source is a chip, the other is the CPU. Note that I have avoided calling the chip clock the RTC clock as there are internal values on the CPU also called RTC. But yes that is the common name for it. Related: Real-Time -Clock Kernel reference Red-Hat reference
System Clock vs. Hardware Clock (RTC) in embedded systems
1,312,470,873,000
In answer to My process was killed but I cannot understand the kernel notice, I was pointed to some documentation on the Secure Attention Key (SAK) on Linux. I have a embedded system generated using buildroot which uses busybox and the busybox init system. I am unable to find either rc.local or rc.sysinit on my system anywhere. I have looked online but I cannot find any documentation (other than the link above) that tells how I can identify what the SAK is for my system. Can anyone tell me how I can get this information and also if I can turn the SAK off? As my system is embedded and isolated from the internet I am not overly concerned with security breaches or hack attempts. The SAK seems to pop up out of nowhere and kills my main embedded application which is totally unacceptable so if I can turn this off it would be better for my needs (even if this means I have to reconfigure and build my kernel)
According to this mailing list post SAK is «break», k. So you could be receiving it over the serial port. The kernel sysrq documentation agrees. That kernel document also gives a solution: disable sysrq by echo 0 >/proc/sys/kernel/sysrq. Or, alternatively, only enable the ones you'd like. You can also configure SAK using setserial, according to the setserial man page. Busybox init probably runs the /etc/init.d/rcS shell script. It also runs other things out of /etc/inittab. I suggest looking at that shell script see where you should plop scripts to set these things.
How can I find the Secure Attention Key (SAK) on my system and can I disable it?
1,312,470,873,000
I have compiled and installed the 2.6 kernel on an ARM board. I am using the ARM mini2440 board. I would like to know if there is already a way to access the General Purpose I/O port pins? Or will I have to do ioctl() and access them directly from the memory?
Use the sysfs control files in /sys/class/gpio. The following links will hopefully be useful to helping you get started: http://www.avrfreaks.net/wiki/index.php/Documentation:Linux/GPIO Have seen reports of this article on the Beagle Board also working with the mini2440: http://blog.makezine.com/archive/2009/02/blinking_leds_with_the_beagle_board.html In your Linux kernel documentation, look at Documentation/gpio.txt too.
Linux kernel 2.6 on ARM
1,316,828,411,000
Is there a command like vi > out vi | out That I could use to cause a watchdog reset of my embedded linux device?
If you have a watchdog on your system and a driver that uses /dev/watchdog, all you have to do is kill the process that is feeding it; if there is no such process, then you can touch /dev/watchdog once to turn it on, and if you don't touch it again, it will reset. You also might be interested in resetting the device using the "magic sysrq" way. If you have a kernel with the CONFIG_MAGIC_SYSRQ feature compiled in, then you can echo 1 > /proc/sys/kernel/sysrq to enable it, then echo b > /proc/sysrq-trigger to reboot. When you do this, it reboots immediately, without unmounting or or syncing filesystems.
How do I cause a watchdog reset of my embedded Linux device
1,316,828,411,000
I've been messing around with my NAS which runs on Linux. I have root access, but there is no compiler. I seem to remember something about being able to compile on another system, but I'm not certain. root@LSB1:~# uname -a Linux LSB1 2.6.22.18-88f6281 #50 Tue Dec 22 18:06:23 JST 2009 armv5tejl unknown
Cross-compiling may be the solution for you It allows you to compile executables for one architecture on a system of a different architecture. Here's an introduction
How do I install GCC on a system with no compiler?
1,316,828,411,000
I have an embedded system setup built using buildroot and using initramfs. It runs on compact flash device where I have created separate ext3 partitions to mount /etc/ and /var directories as well as custom directory to store data. I am not entirely certain if this is a good idea or not, but I need access to sytem log output and also need to be able to modify files in /etc as they require a static IP address to be configured here. Once the /etc/network/interfaces file has been edited to set the IP, I have no further need to manually edit anything in /etc so I was wondering if making this mount as read only when the devices are out in the field is a good idea or whether it is possible that other applications on my system need to write to any files in /etc ? I run a fairly minimal system, really just dropbear and busybox are running (as well as my custom controller application that controls the devices). I have looked around on various forums and sites and this idea does not seem too controversial, but my knowledge is fairly limited. I realise I could just try mounting it as read only, but it seems possible that things could break silently so is it a bad idea??
A read-only /etc is increasingly common on embedded devices. A rarely-changing /etc is also increasingly common on desktop and server installations, with files like /etc/mtab and /etc/resolv.conf located on another filesystem and symbolically linked in /etc (so that files in /etc need to be modified when installing software or when the computer's configuration changes, but not when mounting a USB drive or connecting in a laptop to a different network). The emerging standard is to have a tmpfs filesystem mounted on /run and symbolic links in /etc like /etc/mtab -> /run/mtab /etc/resolv.conf -> /etc/resolvconf/run/resolv.conf Existing or embedded systems may have the tmpfs mounted on a different location such as /dev/shm or /lib/init/rw or /var/run. The problem with making /etc read-only is that this locks the set of files that you'll ever be able to modify. A different approach that avoids this problem is to make the root filesystem an initramfs. This is an archive that's stored next to the kernel image and loaded by the bootloader. It is unpacked into RAM and becomes the root of the root of the filesystem. If you're going to let the initramfs stick around, it shouldn't be too big (because it's using up precious RAM), but a BusyBox binary plus some configuration files may be an acceptable use of RAM. Another approach is to have a read-only root filesystem plus a union mount of a read-write filesystem.
Is making /etc directory read only a bad idea?
1,316,828,411,000
I have a small custom embedded Linux distribution (created with OpenEmbedded), which boots with GRUB 1.99. The aim is to have it start up fast. Currently it says: GRUB loading. for ~2+ seconds (this is probably unavoidable). Then: Welcome to GRUB! under it for a fraction of a second when it has finished loading. (There is no menu or menu timeout.) It clears the screen, then: Booting 'Disk' for ~8 seconds. This delay seems like it should be avoidable. I'd very much like to know how to make it not delay here. Then it continues on to: Decompressing Linux... Parsing ELF... done. Booting the kernel. And then lots of fast scrolling text as the kernel boots. The kernel image file is 1.8MB, and the disk image file is 16MB. The grub.cfg file looks like: set default="0" set timeout=0 menuentry "Disk" { set root=(hd0,1) linux /boot/Disk.kernel parport=0x378,7,3 ramdisk_size=16384 root=/dev/ram rw initrd /boot/Disk.ext2 } In another boot disk I have (on a Compact Flash card), I have exactly the same kernel, and a different disk image file, which 20MB. The config file is also identical, except that ramdisk_size=20480. This one has an extremely long delay of 69 seconds at that same point. Why is it so much longer? Thankfully, I don't need to use that boot disk often. But it would be nice to fix that one too, since presumably the delay is caused by the same thing. How do I fix this delay? What is it doing? How does one go about debugging a bootloader? Is it worth looking into a lighter weight bootloader like SYSLINUX instead? Will deleting some of the unused GRUB 2 modules improve it? (How does one find which modules are unused?) Summary All of the following have the exact same Linux 3.2 kernel: Flash disk A on computer X: 16MB image, GRUB 1.99, boot delay is ~8s; disk A's read speed is 20MB/s. Flash disk B on computer X: 20MB image, GRUB 1.99, boot delay is 69s; disk B's read speed is 20MB/s. Flash disk C on computer Y: 16MB image, GRUB 0.97, boot delay is.. extremely quick; disk C's read speed is 16MB/s. Note that computer Y is similar to computer X, but a bit slower. (The monitor is not even fast enough to show any GRUB screens at all. From the point of the BIOS screen disappearing to the Linux kernel loading screen first appearing, it shows 4.76s of blank screen - but the Linux kernel has already been loading for at least 1.5s by that time, so it's more like 3.2s at a maximum for GRUB to do its thing. This includes GRUB itself loading and BIOS deciding which drive to boot from, etc.) Unfortunately GRUB 0.97 like that instance is not able to be repeatably built like that, so it doesn't seem like a feasible option (although it would be nice). How do I make GRUB 2 fast??
I didn't find the cause of the slow booting with GRUB 2. I ended up using EXTLINUX instead, which is compact and fast, and better-suited if you don't need all the fancy GRUB 2 things. http://www.syslinux.org/wiki/index.php/EXTLINUX
Why is GRUB 2 booting so slowly?
1,316,828,411,000
After reading this question, I was a little confused; it sounds like some daemon reacting by rebooting a system. Is that right? Is it a common occurrence in embedded *nixes?
Having a watchdog on an embedded system will dramatically improve the availability of the device. Instead of waiting for the user to see that the device is frozen or broken, it will reset if the software fails to update at some interval. Some examples: Linux System http://linux.die.net/man/8/watchdog VxWorks (RTOS) http://fixunix.com/vxworks/48664-about-vxworks-watchdog.html QNX Watchdog http://www.qnx.com/solutions/industries/netcom/ha.html The device is designed in such a way that its state is saved somewhere periodically(like Juniper routers that run FreeBSD, Android phones, and dvrs that run linux). So even if it is rebooted it should re-enter a working configuration.
What is a "watchdog reset"?
1,316,828,411,000
Anyone know what happens when UBI uses up all its reserved PEBs that are reserved for bad block management? For example say I have a UBI volume that has 14 PEBs reserved # ubinfo -d 1 ubi1 Volumes count: 1 Logical eraseblock size: 126976 bytes, 124.0 KiB Total amount of logical eraseblocks: 1466 (186146816 bytes, 177.5 MiB) Amount of available logical eraseblocks: 787 (99930112 bytes, 95.3 MiB) Maximum count of volumes 128 Count of bad physical eraseblocks: 0 Count of reserved physical eraseblocks: 14 Current maximum erase counter value: 9 Minimum input/output unit size: 2048 bytes Character device major/minor: 249:0 Present volumes: 0 What happens when UBI finds bad block number 15? Does it not allow the volumes to be used?
I've tested it on armv5tel GNU/Linux 2.6.39+ by marking physical eraseblocks (PEB) as bad using the U-Boot command line: When the bad PEB count is higher than the amount of reserved PEBs, the volume will still be usable. As long as free blocks are available they are used to replace the bad ones. Problems will occur when all PEBs are used up and a new bad block is discovered.
UBI bad block management
1,316,828,411,000
I recently tried to install OpenBSD to my Soekris net4526, but the 64MB onboard storage is too small. Is there any way to make OpenBSD smaller, because even the smallest configuration (bsd and baseXX.tgz only) doesn't fit.I tried with OpenBSD 3.9. Can you give me some links?
The good news is it can be done, but you'll need to know what you're doing and you won't be able to ask for any help on the openbsd mailing lists. You'll need: a more powerful build machine then your soekris a list of things to delete which will be based on whatever compromises you're willing to make. (You haven't given any detail about what you're planning to use this machine for). I just downloaded the latest base.tgz snapshot. It's 148M in size. Here are some ideas about things you could look to remove from base: if you can live without Perl, removing it will save you 54.5M without perl, you may as well delete the pkg_* tools and /etc/signify/openbsd-*-pkg.pub files. You can also delete some other odds and ends like fw_update, libexec/security, etc. the terminfo database, 5.6M /usr/bin/spell, /usr/bin/deroff (only kept around because it's used by spell) and /usr/share/dict will save 3.5M prune the zoneinfo, 3M /etc/firmware will save 2.3M maybe you don't need /sbin/isakmpd which will save 1.8M /usr/share/man/ will save 1.3M (a select few man pages are installed in base not in the man set). without man pages, you may as well delete /usr/bin/man, /usr/bin/mandoc, /etc/examples/man.conf you can also probably delete libsqlite for 3M delete dig, host, nslookup for 1.4M /usr/share/misc will save 1.2M cvs will save 0.7M /usr/bin/file and /etc/magic will save 0.6M texinfo will save 0.5M /usr/mdec will save 0.3M /var/sysmerge/etc.tgz will save 0.2M At this point you'll be close. Maybe around 70M of usage, so you'll have to start deleting things you wouldn't use. For example, in /usr/sbin do you need pppd? Do you need httpd? You probbably don't need installboot, etc, etc. You will need to go through with a fine tooth comb based on your use case. One other thing you can experiment with is to compile your system with -Os instead of -O2. It might be worth checking if it saves space too. But note -Os is not a well tested gcc code-path on OpenBSD. It would not surprise me if you run into compiler bugs by doing this. So I think the point, is it can be done if you're willing to sink enough time into this as a project. Only you can decide if you want to create such a stripped down version of OpenBSD. And again, don't expect any help from the openbsd mailing lists. People will laugh at you if you ask for help with this project over there.
OpenBSD - Reduce the Base Install Size for Smaller Systems
1,316,828,411,000
I'm in a situation where I have a 10/100/1000-capable PHY cabled only to support 10/100. The default behaviour is to use the autonegociation to find the best mode. At the other end, using a gigabit capable router ends in a non-working interface. I guess autonegociation never converges. I've heard some people tried with a 100Mbps switch and it works fine. I'm able to get it working using ethtool but this is quite frustrating : ethtool -s eth1 duplex full speed 100 autoneg off What I'd like to do is to keep the autonegociation but withdraw 1000baseT/Full from the choices so that it ends up running seemlessly in 100Mbps. Any way to achieve that using ethtool or kernel options ? (didn't find a thing on my 2.6.32 kernel ...) (Let's just say some strange dude comes to me with a 10Mbps switch, I need this eth to work with this switch from another century)
The thing with autonegotiation is that if you turn it off from one end, the other side can detect the speed but not the duplex mode, which defaults to half. Then you get a duplex mismatch, which is almost the same as the link not working. So if you disable autonegotiation on one end, you practically have to disable it on the other end too. (Then there's the thing that autonegotiation doesn't actually test the cable, just what the endpoints can do. This can result in a gigabit link over a cable that only has two pairs, and cannot support 1000Base-T.) But ethtool seems capable of telling the driver what speed/duplex modes to advertise. ethtool -s eth1 advertise 0x0f would allow all 10/100 modes but not 1G. advertise N Sets the speed and duplex advertised by autonegotiation. The argument is a hexadecimal value using one or a combination of the following values: 0x001 10baseT Half 0x002 10baseT Full 0x004 100baseT Half 0x008 100baseT Full 0x010 1000baseT Half (not supported by IEEE standards) 0x020 1000baseT Full
Remove SOME advertised link modes with ethtool
1,316,828,411,000
I have used buildroot to successfully create a kernel, root file system and cross-compilers to enable me to write application code to run on an embedded device. Currently I have no need to write device drivers and currently have no idea how to go about it anyway but it is quite likely that in future I may need to do this. From my research I have come to understand that the kernel API can change between versions and that writing a device driver is specific to a kernel version unlike writing a user level application. Basically I would like to know: Is the above correct? What factors need consideration when deciding on a what kernel version to use? The reason I ask is that from all the literature that I have read on the subject (and the attendance at an embedded linux course) deals with version 2.6.x kernels. I am building by embedded system using a 3.6.11 kernel but I am wondering why the course and literature seems to deal with these older kernels. Are there beneficial aspects to using an older kernel, or are there drawbacks to using newer versions?
3.x is just continuation of 2.x - at one point Linus decided that the "x" part of the version is too big. Generally you probably want reasonably recent kernel, probably one marked as "longterm". A lot also depends on your application as well - while remote security holes in kernel are rather scarce, local problems are much more prevalent.
What considerations need to be made when choosing the version of kernel for an embedded device?
1,316,828,411,000
I've worked with a few embedded systems, but now I'd like to make my own piece of hardware and despite a pretty thorough knowledge of Linux, I have no idea how to get Linux up and running on new hardware. So I'm looking for resources on how to do some board bringup/support. Some more details: I'm wondering about the following kinds of things: How does Linux know the processor configuration - e.g. how the pins are configured, how much cache is there, is there an MMU present. How does Linux know about the board layout - e.g. which pins are the memory bus, where is the row select, column select, which pins are an i2c bus, and so on.
I worked on a system using uboot which had custom hardware and was ported to arm and powerpc. There were two things that needed to be set up. First there is a place in u-boot where you can add board support to set registers and create handler functions for accessing RAM or FLASH on your device. You then have to write similar support in the /arch part of the linux tree. I think keywords to google for are "board support"
Resources for very low-level (board bring-up)
1,316,828,411,000
In this question over at superuser several answers report SDHC card failures in Raspberry Pi single-board computers and other embedded devices over the course of periods varying from weeks to years. In comments to this answer to an unrelated question about the swappiness, there was speculation as to whether adjusting swappiness to favour file cache pages over anonymous pages would increase the longevity of SD cards in embedded systems that rely on SD cards as their primary storage medium. Intuitively it seems that adjusting swappinness should have some effect on writes to the SD cards, but it is difficult to tell it is difficult how much swapping contributes to the overall strain on the SD card endurance compared to other contributing factors, such as logging or temporary files. The question is: How much does adjusting the swappiness really affect the longevity of SD cards in such systems? Answers should be backed up by specific experiences or references. Please keep Good Subjective, Bad Subjective in mind.
The answer to this depends heavily on your use case. I no longer own a Raspberry Pi, but the one I used to have came with 512 MB of RAM. Conveniently, my NFS server has the same amount. In addition to NFS, this server (like all my others) has an m68k cross-compiler that sees regular use via distcc. It also has an always-on GNU screen session attached to the serial port of another server. Let's have a look at vmstat: $ vmstat | awk '{ printf "%4s %2s %2s\n", $3, $7, $8 }' | tail -n 2 swpd si so 0 0 0 In this case, no value of swappiness is better than any other, as the system never swaps. Small, embedded systems often don't even have swap space. From Memory Management Approach for Swapless Embedded Systems, a 2005 article in Linux Journal: The Linux kernel Out of Memory (OOM) killer is not usually invoked on desktop and server computers, because those environments contain sufficient resident memory and swap space, making the OOM condition a rare event. However, swapless embedded systems typically have little main memory and no swap space. In such systems, there is usually no need to allocate a big memory space; nevertheless, even relatively small allocations may eventually trigger the OOM killer. In systems that take this approach, the same holds: Since there is no swap space, swappiness can have no effect on the longevity of your storage. If you are using your Raspberry Pi more like a desktop system, perhaps running X and doing gene sequencing in Python for your biology homework (I've seen it done), then you might have something to worry about. Let's find out: Suppose you run low on memory and your swappiness is set very high, to almost exclusively page out program memory and retain file cache. Suppose also, for concreteness, that you have a class 8 SDHC card and that it has a (fairly low) 16-kilobyte block size. Then you can write 8 MB/s, or 512 blocks per second. Without wear-leveling, and assuming failure after 100,000 writes, this leaves you only 195 seconds, or just over three minutes, before failure. Of course, this is a worst-case scenario. With wear-leveling, the failure-time is closer to 100,000 writes times the number of unused blocks. Say you have 1 GB, or 65,536 blocks, available for wear-leveling. In this case, you get (roughly) 65,536 times this amount of time, or about 24 years of constant swapping. Since you probably won't be constantly swapping for 24 years, this won't likely be the cause of premature flash-demise. Something much more likely to be a problem is the logging of access times of files. Whenever a file is read, its access time is updated unless the filesystem is mounted with the noatime option. This requires one block to be written every time a file is read. Journaling filesystems like ext3 and ext4 write extra data to an on-medium journal upon each write. Some filesystems (e.g. ext2 or FFS) do not support journaling. Using these filesystems (or turning off journaling in others) definitely improves the longevity of flash media, but reduces data reliability in case of power loss or media-removal. I don't think that system logs will in general contribute much to the death of flash media, as the only files in my /var/log that have changed in the past month are btmp, wtmp, and lastlog.
How does swappiness affect the longevity of SDHC memory cards in embedded computers?
1,316,828,411,000
I have just learned of Gentoo's sys-devel/crossdev package. This is a package that is useful for creating a cross-compiling toolchain. Are there any other such packages out there on other distributions? I'm specifically interested in distro-maintained packages because I've tried a couple of others (buildroot, crosstool) and it seems that and any time the distribution touches gcc or binutils, it invariably breaks at least the building of the toolchain if not the building of the project itself.
On Debian, there are apt-cross and dpkg-cross from Emdebian, which let you set up cross-compilation for many architectures (you get cross-compilers and libraries). On Ubuntu, there's a crosschain for ARM, and a project to improve on this. You can also create toolchain using crosstool-ng which is not link to a distribution.
What distribution-maintained cross-compile toolchain packages exist?
1,316,828,411,000
I'm wondering if it's possible to make a Linux system appear like an USB peripheral. Like smartphones which can switch from master to slave depending on the device they are connected to, I would like to know if it's possible to have the same behavior with a Linux system. For example, I have an embedded Linux on a card with usb connectors, when I plug a usb key to this card, the usb key is detected as a slave device and mounted on the file system. Now if I connect my card to my computer I would like to have it recognized as usb slave device too. Do you think it's possible? I found a similar question asked but not answered Use a Linux directory as a USB-OTG device to an Android phone? I finaly chose to try to configure the system as MTP device instead of presenting it as mass storage for those reasons : Protect against concurrent file access Protect system against crash or corruption due to concurrent file access or bad mounting/unmounting Possibility to expose root file system without unmounting or stopping it Possibility to share multiple devices As I have some problems configuring it I oppened a new question here for those interested.
Yes, you can, but it is not easy. You need at least a little work with it. Working as an USB slave is supported in Linux since around the 2.4 or 2.6 times. You have to find a compatible chip, then a device having it, and then buying one, somewhere (typically, to rent it on the Internet). Specifically for USB gadgets, there is support for peripherial devices and also for block devices. Your Google search: Linux USB gadget . You may also have a little dig task in the kernel sources, this slave-side mode is likely not included in most distribution kernels, so you will have to recompile it. Here is an old, but still actual reference about this. Other may be useful answer. Extension by @Arkaik: A userspace MTP responder is available uMTP-Responder, it's easy to implement and relies on either gadgetfs or functionfs.
Configure Linux system as an OTG device
1,316,828,411,000
On an mtd partition with 39 erase blocks (= 4.9 MiB), I tried to format a ubifs. The resulting file system has free space of 2.2M uncompressed data when reserved blocks are reduced to the minimum possible 1 block (I know that's not good). This means that only 45% of the space is usable for data. The same area formatted with jffs2 allows me to write 4.6 MB of data which is 93% or more than double the size in a ubifs setup. The problem is that I can't use jffs2 because my OOB size of 64 bytes doesn't provide enough space for both BCH8 and JFFS2 OBB data, as described in a TI warning. I already read the FAQ chapters Why does my UBIFS volume have significantly lower capacity than my equivalent JFFS2 volume? and Why does df report too little free space? but I still can't believe that the overhead is so big. Is there anything I can do to increase the free space of my (writable) ubifs volume? Do I save space when I merge ubi0 and ubi1? (more than the reserved blocks?) This is my setup: $ mtdinfo -a mtd10 Name: NAND.userdata Type: nand Eraseblock size: 131072 bytes, 128.0 KiB Amount of eraseblocks: 39 (5111808 bytes, 4.9 MiB) Minimum input/output unit size: 2048 bytes Sub-page size: 512 bytes OOB size: 64 bytes Character device major/minor: 90:20 Bad blocks are allowed: true Device is writable: true $ ubinfo -a ubi1 Volumes count: 1 Logical eraseblock size: 129024 bytes, 126.0 KiB Total amount of logical eraseblocks: 39 (5031936 bytes, 4.8 MiB) Amount of available logical eraseblocks: 0 (0 bytes) Maximum count of volumes 128 Count of bad physical eraseblocks: 0 Count of reserved physical eraseblocks: 1 Current maximum erase counter value: 2 Minimum input/output unit size: 2048 bytes Character device major/minor: 249:0 Present volumes: 0 Volume ID: 0 (on ubi1) Type: dynamic Alignment: 1 Size: 34 LEBs (4386816 bytes, 4.2 MiB) State: OK Name: userdata Character device major/minor: 249:1 dmesg: [ 1.340937] nand: device found, Manufacturer ID: 0x2c, Chip ID: 0xf1 [ 1.347903] nand: Micron MT29F1G08ABADAH4 [ 1.352108] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 [ 1.359782] nand: using OMAP_ECC_BCH8_CODE_HW ECC scheme uname -a: Linux 4.1.18-g543c284-dirty #3 PREEMPT Mon Jun 27 17:02:46 CEST 2016 armv7l GNU/Linux Create & test ubifs: # flash_erase /dev/mtd10 0 0 Erasing 128 Kibyte @ 4c0000 -- 100 % complete # ubiformat /dev/mtd10 -s 512 -O 512 ubiformat: mtd10 (nand), size 5111808 bytes (4.9 MiB), 39 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes libscan: scanning eraseblock 38 -- 100 % complete ubiformat: 39 eraseblocks are supposedly empty ubiformat: formatting eraseblock 38 -- 100 % complete # ubiattach -d1 -m10 -b 1 UBI device number 1, total 39 LEBs (5031936 bytes, 4.8 MiB), available 34 LEBs (4386816 bytes, 4.2 MiB), LEB size 129024 bytes (126.0 KiB) # ubimkvol /dev/ubi1 -N userdata -m Set volume size to 4386816 Volume ID 0, size 34 LEBs (4386816 bytes, 4.2 MiB), LEB size 129024 bytes (126.0 KiB), dynamic, name "userdata", alignment 1 # mount -t ubifs ubi1:userdata /tmp/1 # df -h /tmp/1 Filesystem Size Used Avail Use% Mounted on - 2.1M 20K 2.0M 2% /tmp/1 # dd if=/dev/urandom of=/tmp/1/bigfile bs=4096 dd: error writing '/tmp/1/bigfile': No space left on device 550+0 records in 549+0 records out 2248704 bytes (2.2 MB) copied, 1.66865 s, 1.3 MB/s # ls -l /tmp/1/bigfile -rw-r--r-- 1 root root 2248704 Jan 1 00:07 /tmp/1/bigfile # sync # df -h /tmp/1 Filesystem Size Used Avail Use% Mounted on - 2.1M 2.1M 0 100% /tmp/1 Create & test jffs2: # mkdir /tmp/empty.d # mkfs.jffs2 -s 2048 -r /tmp/empty.d -o /tmp/empty.jffs2 # flash_erase /dev/mtd10 0 0 Erasing 128 Kibyte @ 4c0000 -- 100 % complete # nandwrite /dev/mtd10 /tmp/empty.jffs2 Writing data to block 0 at offset 0x0 # mount -t jffs2 /dev/mtdblock10 /tmp/1 # df -h /tmp/1 Filesystem Size Used Avail Use% Mounted on - 4.9M 384K 4.5M 8% /tmp/1 # dd if=/dev/urandom of=/tmp/1/bigfile bs=4096 dd: error writing '/tmp/1/bigfile': No space left on device 1129+0 records in 1128+0 records out 4620288 bytes (4.6 MB) copied, 4.54715 s, 1.0 MB/s # ls -l /tmp/1/bigfile -rw-r--r-- 1 root root 4620288 Jan 1 00:20 /tmp/1/bigfile # sync # df -h /tmp/1 Filesystem Size Used Avail Use% Mounted on - 4.9M 4.9M 0 100% /tmp/1 Update: I did some mass measurements which resulted in the following chart: So I can formulate my question more specific now: The "formula" seems to be usable_size_mb = (raw_size_mb - 2.3831) * 0.89423077 In different words: no matter what size my mtd has, there are always 2.38 MB lost, no matter how big our volume is. This is the size of 19 erase blocks. The rest is a filesystem overhead of 10.6% of user data which is a high value but not unexpected for ubifs. Btw. when doing the tests I got kernel warnings that at least 17 erase blocks are needed (=2.176 MB). But the smallest mtd which successfully ran through the test had 22 blocks (2.816 MB).
Why the numbers don't match up The "at least 17 erase blocks" warning counts blocks needed by the UBIFS filesystem itself. Of those 17 erase blocks, 14 are UBIFS overhead and 3 are usable filesystem space. The underlying UBI layer underneath also uses 5 erase blocks of overhead. Getting More Space There's no way to make a single UBI partition with a single UBIFS filesystem use less overhead. However, if you have more than one UBI partition on the same MTD device, I recommend merging them. Not only will it free up 5 erase blocks, but it will also get you improved wear leveling and bad block handling, because UBI will have more options for mapping physical erase blocks to logical erase blocks as needed. (Ignoring overhead, imagine two partitions of two blocks each, one of which is bad. Now one partition only has one block left, and it's impossible to do wear leveling. But if you merge the two, then you have three good blocks left to share between the two filesystems as needed.) To merge two adjacent UBI partitions: Update your MTD partition table, replacing the two partitions with one larger one. Run ubiformat on that one large partition. Run ubimkvol twice, providing appropriate partition names and and specifying the sizes manually with -s or -S. An accounting of UBI+UBIFS overhead First, the UBI layer takes 5 erase blocks of overhead: 2 for the volume table 1 reserved for the wear leveling algorithm 1 reserved for the "atomic LEB change" feature, which allows for reliable in-place updates of a logical erase block 1 (ideally more, as you mentioned) reserved for handling bad physical erase blocks. Next, the UBIFS layer has a minimum number of erase blocks for the filesystem metadata: 1 for the filesystem superblock, which identifies the volume as a valid UBIFS and stores the filesystem parameters 2 for the master node area (redundant copies), which are the roots of the tree used for filesystem lookups 2 or more for the log area (which counts towards usable space) 2 for the LEB properties tree, which tracks how each logical erase block is used 1 or more for the orphan area (for tracking deleted files, so they are cleaned up correctly after an unclean unmount) 8 reserved for filesystem metadata (garbage collection, deletions, buds, index) 1 or more for committed data not in the log (usable space). References For the UBI overhead, the linux-mtd site has a straightforward description. For the UBIFS overhead, I had to do a little more digging. The source code of mtd-utils counts up the absolute minimum number of erase blocks and mentions what each block is for. To make sense of it, the UBIFS whitepaper is useful.
Surprisingly big overhead when creating small ubifs volume
1,316,828,411,000
I am attempting to boot the freescale 1040RDB and am having some difficulty. I'm using a pre-built SDK from Freescale that has a linux VB image with the yocto installation along with all of the yocto layers and configurations pre installed. I've been able to successfully run bitbake and am now trying to deploy the images on the target. Of course, the documentation from Freescale is completely useless. So through trial and error I've found what I think are the kernel image, root filesystem and FDT. I'm loading them onto the target using TFTP and then trying to boot from memory. Below is a capture of the target's serial terminal. The error is on the last line. At this point I'm wondering if something is wrong with the .dtb file or maybe I need to do something to prepare it. I've hexdumped the .dtb file and compared it against a pre-installed device tree in the target's flash and believe them to be similar types of data. What does this error mean and what can I do to fix it? => tftp 0x01000000 uImage Using FM1@DTSEC4 device TFTP from server 192.168.2.236; our IP address is 192.168.2.18 Filename 'uImage'. Load address: 0x1000000 Loading: ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ###################### 1.3 MiB/s done Bytes transferred = 5103714 (4de062 hex) => tftp 0x02000000 rootfs.gz.u-boot Using FM1@DTSEC4 device TFTP from server 192.168.2.236; our IP address is 192.168.2.18 Filename 'rootfs.gz.u-boot'. Load address: 0x2000000 Loading: ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ############################################################## 1.4 MiB/s done Bytes transferred = 3310270 (3282be hex) => tftp 0x00c00000 uImage.dtb Using FM1@DTSEC4 device TFTP from server 192.168.2.236; our IP address is 192.168.2.18 Filename 'uImage.dtb'. Load address: 0xc00000 Loading: ####### 994.1 KiB/s done Bytes transferred = 35655 (8b47 hex) => bootm 0x01000000 0x02000000 0x00c00000 WARNING: adjusting available memory to 30000000 ## Booting kernel from Legacy Image at 01000000 ... Image Name: Linux-3.12.19-rt30-QorIQ-SDK-V1. Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 5103650 Bytes = 4.9 MiB Load Address: 00000000 Entry Point: 00000000 Verifying Checksum ... OK ## Loading init Ramdisk from Legacy Image at 02000000 ... Image Name: fsl-image-minimal-t1040rdb-64b-2 Image Type: PowerPC Linux RAMDisk Image (gzip compressed) Data Size: 3310206 Bytes = 3.2 MiB Load Address: 00000000 Entry Point: 00000000 Verifying Checksum ... OK ## Flattened Device Tree blob at 00c00000 Booting using the fdt blob at 0xc00000 Uncompressing Kernel Image ... OK Loading Ramdisk to 2fcd7000, end 2ffff27e ... OK ERROR: image is not a fdt - must RESET the board to recover.
This seems like the memory at which fdt is getting corrupted (usually due to overwrite) when kernel image starts to un-compress. Try loading fdt at a higher address e.g. 0xe00000.
ERROR: image is not a fdt - must RESET the board to recover
1,316,828,411,000
I am working on a embedded Linux with u-boot as bootloader and systemd init system. The tools are limited to standard busybox. While analyzing some problems, I figured out the root filesystem is read only which causes the problem. The reason is some of the services and programs depend on a writable root fs, causing malfunction. After researching for a while I found out the root filesystem is only readonly when there is a power failure. (The main unit triggers a power recycle when some error is encountered.) I suspect that when the root fs tries to write to some critical file or updating some service / process, then on power failure a error flag is set on the filesystem. On next boot fsck reads the flag and mounts/remounts the root as read only, or fsck forces to go into some recovery mode (I don't know if any recovery mode exists). Is my hypothesis correct? If so, then what is a fs flag that is set on the FS on error and how to I prevent the root to boot as RO? Note: The root filesystem is mounted with 'errors=continue'. So if fsck reads the superblock for remount option, it should ignore the error and remounts as RW. I tried to reproduce the case, turning off the power while running a dd command, but never been able to reproduce. Additional Question: Which udev/systemd magic mounts the root fs?
At boot, you are supposed to check your filesystems to see if the system was shut down properly or if it crashed, and perform the necessary recovery actions in the latter case. On modern journaled filesystems, this usually means a simple and quick journal recovery operation that can be done automatically. Root filesystem checking and mounting is normally done by initramfs/initrd, but on an embedded system you might or might not have it. If you are not using initramfs, then the traditional way would be to have the kernel always mount the root filesystem initially as read-only (with boot options root=/dev/<whatever> ro, and the start-up scripts would then first run fsck on it (assuming it's necessary for the filesystem type used) and then remount the root filesystem into read/write mode before doing anything else. If initramfs did not check the root filesystem (perhaps because it's not being used), then the standard systemd service name for running a filesystem check on the root filesystem is named systemd-fsck-root.service. I could not find out the name of the service responsible for remounting the root filesystem with systemd after it's been checked. If a boot-time root filesystem check needs to modify the root filesystem, it typically triggers another reboot afterwards, because the modification may have affected something the kernel has already read and is caching, and would now be inconsistent after a correction was made on the disk by fsck.
When can Linux boot with a Read-Only Root Filesystem
1,316,828,411,000
It seems that I have a lack of understanding how booting SD-Card images on devices like the Banana Pi work. The situation is as follows. I have a Banana Pi and a Banana Pro. Every device has an image of some distribution on a SD card plugged into the device (Banana Pro -> Arch Linux, Banana Pi -> Bananian). The images can be downloaded from here and here. This works fine. But since the Banana Pi / Pro has a SATA port, it would be nice if the root system could be booted from an attached Hard Drive. As can be read here this can be accomplished quite simple. But now comes the part I'm struggling with. Flashing an entire 4GB SD card (or even larger ones) with the distributions image and using just a 50MB partition seems a bit wasteful. So I tried to use a smaller SD card. I created a partiton with fdisk (50MB size) and used mkfs.vfat -F 16 /dev/sdXX to create the filesystem on the partiton. I made it FAT 16 because of the parted output while examining the image file. . After that I mounted the partion from the image to /tmp/boot with sudo mount -o loop,offset=1048576 ArchLinux_For_BananaPro_v1412.img /tmp/boot. The offset value is the Start value in the parted output. Copied the files (script.bin, uEnv.txt, uImage) to my SD card partition, changed the root path in uEnv.txt. Made a sync and dismounted the SD card. Everything seems fine. Even when comparing the boot partitons on a SD card flashed with the entire image and my SD card with only the boot partiton, they are identical (according to fdisk) But the Banana Pi / Pro won't boot with the SD card with just a boot partition providing the u-boot files. Has anyone a clue on that behaviour? UPDATE: Thanks to @BananaFreak I recognized my mistake. The bootloader was indeed missing but even after following that guide from lemaker the BananaPro does not boot. One weird thing on the lemaker wiki page is the first sentence stating: Note: these instructions are for a Linux computer, not the Banana Pro/Pi!!
I think you've missed bootloader. U-Boot has to be present on your SD. Take a look at how the SD layout should be for the Banana Pi / Pro: http://wiki.lemaker.org/BananaPro/Pi:Setting_up_the_bootable_SD_card#SD_Card_Layout
How to create boot SD card for Banana Pi manually
1,316,828,411,000
I am trying to develop an application to run on an embedded linux installation. It comes with an older version of libc than I have on my development maching. If I were to create a chroot environment on my development machine, copy the libraries from my embedded device in such a way that the chroot environment mirrors the device and then build the application, would it be safe to run on the device? My dev machine and the device are both x86 32 bit so I don't think I need to cross compile. Also should the application I write require linking to additional libraries (that are not present on the device) am I safe to build these libs on the dev machine in the chroot and then just copy them to the device for application deployment? From all the reading I have done on this subject it appears that the only way I can ensure that everything links together properly would be to actually build the application on the device but this is not an option as it is a minimal install and doesn't come with gcc installation.
This will generally work. I would just give it a try, but there are a few things you need to be aware of: When building, binaries need to be built for the CPU architecture and capabilities of your target. Given that they're both x86, this will help a lot, but you still need to be careful about using processor features like sse3, etc. If you build a binary that takes advantage of features that are absent on your target installation, it won't work. Your build system's kernel might exert some influence over the behaviour of your chrooted environment. You can't use a different kernel for a chroot vs the host system, so you may encounter discrepancies between the two. Apps generally ultimately communicate with the kernel via libc though, which provides a standard interface that can help prevent such problems. Your libc needs to be compatible with your kernel, to some degree. The libc from your embedded system might not be totally compatible with your kernel, depending on interface changes; however, if the libc predates your kernel, this is unlikely to be a problem (old kernel interfaces are more likely to stick around to support old binaries). Your host system's services will be visible to your embedded system. This is common to any chroot, as they share process tables, network interfaces, etc. For your 'additional libraries', you could use static linking to link those to your application. Then you can avoid deploying the libraries to the device. Your mileage may vary. You might consider using a virtual machine to do this instead. It won't necessarily remove all the concerns (like processor features/flags), but you can have an environment that matches your embedded system much more closely. That is, you can use the same kernel, run the same boot process, avoid contamination by the host's services... Be aware that if you set up a build toolchain inside your chroot, you might want to think about how you will copy the new files back to your embedded system; you probably do not want to copy the toolchain files (gcc, etc). Try setting it up and writing a test application, build some libraries or whatever, and see how well they work when moved to the embedded system.
Can I use a chroot on my dev machine to build an application to run on embedded linux installation?
1,316,828,411,000
From the link: http://en.wikipedia.org/wiki/Extended_display_identification_data The EDID is often stored in the monitor in a memory device called a serial PROM (programmable read-only memory) or EEPROM (electrically erasable PROM) and is accessible via the I²C bus at address 0x50.[1] The EDID PROM can often be read by the host PC even if the display itself is turned off. How can I read that information?
Answer to my own Question: [:)] i2cdetect -l : To enlist the existing i2c adapter echo Y | i2cdump $i 0x50 : Where i is the device id of each /dev/i2c-* The above command will print the Raw-EDID for the given I2C-Adapter. Now custom C ( or any ) programming language can be used to parse the information to give the neat description of the underlying device. [ Though I used the i2c-tools, still It will be far better to use the low-level assembly programming to read the EEPROM values. ]
Reading EDID from EEPROM
1,316,828,411,000
I have an Atmel SAM9X system running Angstrom. I am trying to make a recovery partition so when a user holds a button during boot up the recovery partition boots up. I have modified the bootstrap so when a button is held on boot up, an alternate linux kernel is loaded. What I want is the alternate kernel to load linux from the recovery boot partition not the normal main partition. Is this even possible? Or can I load the recovery partition without using two kernels? The reason I want this is so if the main bootable partition gets corrupted the recovery partition will copy itself to the main partition (similar to those Dell or HP windows machines with the recovery partition) and the main bootable partition will be restored. Edit: Giles suggestion did it. The bootstrap was setting the kernel command line argument, I just added root=/dev/mmcblk0p3 (boot from 3rd sd partition) to that and it booted from the desired partition!
The kernel contains a default root partition setting, determined at compile time (you can change it in the binary image with the rdev command). You can pass an argument on the kernel command line to override this default at boot time, e.g. root=/dev/mmcblk9p42 to boot from MMC device 9 partition 42 instead of the default. The command line is passed to the kernel by the bootloader, so you need to change your bootloader configuration. If there is an initrd or initramfs, it may override the root partition that was compiled in or passed by the bootloader.
Making a recovery partition in embedded Linux
1,316,828,411,000
Looking for an inexpensive embedded device that contains 2 Ethernet Ports, runs Linux (or some other type of Unix), and is under $50. My main concern is cost. It must be under $50 and have 2 Ethernet ports. It can be a bare circuit board, it doesn't need to be a complete device with cover and all.
http://soekris.com/ Not at the $50 level, but probably what you're looking for in general.
Low Cost, 2 Ethernet Ports & Runs Linux [closed]
1,316,828,411,000
I am working on Zynq Microzed board. It is booting perfectly with uramdisk.image.gz but I trying to boot it with initramfs.cpio. In this regard I have made following changes in header files of u-boot: zynq_common.h and zynq_common.h.save changes are as follows "ramdisk_image=uramdisk.image.gz\0" to "ramdisk_image=initramfs.cpio\0" in both the header files I am getting following log messages It is still looking for uramdisk.image.gz and giving an error Wrong Ramdisk Image Format Ramdisk image is corrupt or invalid I am unable sought out where I am getting wrong and how to resolve it.
I think you should convert it to u-boot file like this and give it a try: mkimage -n 'Ramdisk Image' -A arm -O linux -T ramdisk -C gzip -d initramfs.cpio.gz initramfs.uImage This might be a valid format for u-boot.
Booting using initramfs instead of uramdisk
1,316,828,411,000
We have beaglebone black based custom board with 256MB RAM and 4GB eMMC. Board runs Linux kernel 4.9 we are running into a situation where we create a file in tempfs and then after validation, we have to move it to the ext4 partition of eMMC. File nothing but a certificate in some situations, we have multiple certs in a directory so we have to move the whole directory from tempfs to the ext4 partition on eMMC. So one of the problems we are worried about is atomicity of mv(move) operation. As per rename system call Linux man page renaming file is an atomic operation. http://man7.org/linux/man-pages/man2/rename.2.html However we are not sure if rename operation involves moving files between two filesystems, atomicity is still available or not. So question is Is moving file from tmpfs to ext4 atomic? Obviously, one possible solution is to keep files in a different folder on the same partition (on same filesystem obviously ) and rename it using mv. For directory using below approach of renaming SRC_dir --> TMP_DEST_dir DEST_dir --> BAK_DEST_dir TMP_DEST_dir --> DEST_dir delete BAK_DEST_dir Any suggestion for alternatives ? EDIT After i got reply i tried following test code on the board, #include <stdio.h> #include <errno.h> int main() { int retcode = 0; system("touch /tmp/rename_test"); retcode = rename("/tmp/rename_test", "/home/fs_rename_test"); if ( retcode < 0) { printf("errno : %d\n",errno ); perror("Error occurred while renaming file"); return 1; } return 0; } Which returned following output. And confirmed that rename doesn't work cross file-system. errno : 18 Error occurred while renaming file: Invalid cross-device link
Is moving file from tmpfs to ext4 atomic? No. Renames as such only work within a filesystem. The manual page for rename(2) explicitly mentions the error that is returned if trying to rename across mount points: EXDEV oldpath and newpath are not on the same mounted filesystem. Moves across file systems need to be done as a combination of a copy and a delete. mv will do this for you if the rename() doesn't work, but it will not be atomic in that case. The simple way to work around that would indeed be to first copy the file to a temporary location on the same filesystem. In general, it's simplest to place the temporary file in the same directory as the final destination, since that's the only place that's guaranteed to be on the same filesystem. Of course that requires that any process working on the files there will have some logic to ignore the temporary based on its name. Roughly, something like this should work for one file: cp /src/filename /dst/filename.tmp && mv /dst/filename.tmp /dst/filename && rm /src/filename Note that the process you describe for a directory is essentially this: cp -r /src/dir /dst/dir.tmp && mv /dst/dir /dst/dir.bak && mv /dst/dir.tmp /dst/dir && rm -r /dst/dir.bak Which is not bad, but is not atomic. There's a moment of time between the two runs of mv (or calls to rename()), when /dst/dir does not exist. That could be worked around by accessing the directory through a symlink, since the link can be atomically replaced with a rename.
is there a way to atomically move file and directory from tempfs to ext4 partition on eMMC
1,470,727,670,000
I have put a vendor supplied embedded Linux installation (called X-Linux) onto a hardware device. I ran lsmod to see what modules are loaded and nothing at all is shown. Also there is no /proc/modules directory on the system. What does this mean? Does it mean that no drivers are loaded to communicate with the rest of the devices on the board (ethernet, serial etc?). I don't see how this can be as I have been able to configure the static IP of the board and am able to successfull ftpget files from my desktop development machine. I really am unsure about what is going on and about the stability of the system. Is this is a problem or is it expected behaviour?
This just means that the drivers are compiled directly into the kernel and that the kernel does not have module support. If you know exactly your target system and the purpose you don't necessarily need module support.
lsmod returns nothing on my embedded device
1,470,727,670,000
I'm trying to boot Linux from U-boot on an embedded ARM board using a filesystem on a remote machine served via NFS. It appears that the ethernet connection is not coming up correctly, which results in a failure to mount the NFS share. However, I know that the ethernet hardware works, because U-boot loads the kernel via TFTP. How can I debug this? I can try tweaking the kernel, but that means recompiling the kernel for every iteration, which is slow. Is there a way that I can make the kernel run without being able to mount an external filesystem?
You can compile a initrd image into kernel (General Setup -> Initial RAM filesystem and RAM disk (initramfs/initrd) support -> Initramfs source file(s)). You specify file in special format like (my init for x86): dir /bin 0755 0 0 file /bin/busybox /bin/busybox 0755 0 0 file /bin/lvm /sbin/lvm.static0755 0 0 dir /dev 0755 0 0 dir /dev/fb 0755 0 0 dir /dev/misc 0755 0 0 dir /dev/vc 0755 0 0 nod /dev/console 0600 0 0 c 5 1 nod /dev/null 0600 0 0 c 1 3 nod /dev/snapshot 0600 0 0 c 10 231 nod /dev/tty1 0600 0 0 c 4 0 dir /etc 0755 0 0 dir /etc/splash 0755 0 0 dir /etc/splash/natural_gentoo 0755 0 0 dir /etc/splash/natural_gentoo/images 0755 0 0 file /etc/splash/natural_gentoo/images/silent-1680x1050.jpg /etc/splash/natural_gentoo/images/silent-1680x1050.jpg 0644 0 0 file /etc/splash/natural_gentoo/images/verbose-1680x1050.jpg /etc/splash/natural_gentoo/images/verbose-1680x1050.jpg 0644 0 0 file /etc/splash/natural_gentoo/1680x1050.cfg /etc/splash/natural_gentoo/1680x1050.cfg 0644 0 0 slink /etc/splash/tuxonice /etc/splash/natural_gentoo 0755 0 0 file /etc/splash/luxisri.ttf /etc/splash/luxisri.ttf 0644 0 0 dir /lib64 0755 0 0 dir /lib64/splash 0755 0 0 dir /lib64/splash/proc 0755 0 0 dir /lib64/splash/sys 0755 0 0 dir /proc 0755 0 0 dir /mnt 0755 0 0 dir /root 0770 0 0 dir /sbin 0755 0 0 file /sbin/fbcondecor_helper /sbin/fbcondecor_helper 0755 0 0 slink /sbin/splash_helper /sbin/fbcondecor_helper 0755 0 0 file /sbin/tuxoniceui_fbsplash /sbin/tuxoniceui_fbsplash 0755 0 0 file /sbin/tuxoniceui_text /sbin/tuxoniceui_text 0755 0 0 dir /sys 0755 0 0 file /init /usr/src/init 0755 0 0 I haven't used it on ARM but it should work. /init is file you are can put startup commands. Rest are various files needed (like busybox etc.).
Debugging ethernet before NFS boot
1,470,727,670,000
When executing ps command in my Linux system i see some user processes twice (different PID...). I wonder if they are new processes or threads of the same process. I know some functions in standard C library that could create a new process such fork(). I wonder what concrete functions can make a process appear twice when i execute ps command because i am looking in the source code where the new process or thread is created.
Little bit confusing. fork is a system call which creates a new process by copying the parent process' image. After that if child process wants to be another program, it calls some of the exec family system calls, such as execl. If you for example want to run ls in shell, shell forks new child process which then calls execl("/bin/ls"). If you see two programs and their pid's are different, check their ppid's (parent id's). For example, if p1 is ppid of process whose pid is p2, it means that process whose id is p1 forked that process. But if first process' ppid is not same that the other process' pid, it means that the same command is executed twice. If pid and ppid are same, but tid's (thread id's) are different, it means that it's one process that has 2 threads. I think that making your own shell is a good start point.
Which system calls could create a new process?
1,470,727,670,000
I have compared this in different systems, but only get this behavior in an embedded system running Arago linux. I use the date command from BusyBox v.1.13.2 I executed this two commands "simultaneously": [root@host:~] date; date -u Fri Mar 18 12:56:49 CET 2016 Fri Mar 18 11:57:14 UTC 2016 The output of zdump is as expected (+3600 seconds; +1 hour): /etc/localtime Sun Mar 29 01:00:24 2015 UT = Sun Mar 29 01:59:59 2015 CET isdst=0 gmtoff=3600 /etc/localtime Sun Mar 29 01:00:25 2015 UT = Sun Mar 29 03:00:00 2015 CEST isdst=1 gmtoff=7200 /etc/localtime Sun Oct 25 01:00:24 2015 UT = Sun Oct 25 02:59:59 2015 CEST isdst=1 gmtoff=7200 /etc/localtime Sun Oct 25 01:00:25 2015 UT = Sun Oct 25 02:00:00 2015 CET isdst=0 gmtoff=3600 /etc/localtime Sun Mar 27 01:00:24 2016 UT = Sun Mar 27 01:59:59 2016 CET isdst=0 gmtoff=3600 /etc/localtime Sun Mar 27 01:00:25 2016 UT = Sun Mar 27 03:00:00 2016 CEST isdst=1 gmtoff=7200 /etc/localtime Sun Oct 30 01:00:24 2016 UT = Sun Oct 30 02:59:59 2016 CEST isdst=1 gmtoff=7200 /etc/localtime Sun Oct 30 01:00:25 2016 UT = Sun Oct 30 02:00:00 2016 CET isdst=0 gmtoff=3600 /etc/localtime Sun Mar 26 01:00:24 2017 UT = Sun Mar 26 01:59:59 2017 CET isdst=0 gmtoff=3600 /etc/localtime Sun Mar 26 01:00:25 2017 UT = Sun Mar 26 03:00:00 2017 CEST isdst=1 gmtoff=7200 Where does this offset of 25 seconds comes from?
By following the strace of the first command (date): open("/etc/localtime", O_RDONLY) It access the timezone file pointed by /etc/localtime which is /usr/share/zoneinfo/europe/Zurich in my case. So everything fine so far. The strace of the second command (date -u) gave me hints why it wasn't working properly: open("/usr/share/zoneinfo/UTC0", O_RDONLY) There wasn't such a file in the zoneinfo directory, so I had to copy UTC to UTC0 and now everything works as expected. date; date -u Fri Apr 26 09:52:44 CET 2016 Fri Apr 26 07:52:44 UTC 2016
UTC vs. localtime has an offset of about 25 seconds
1,470,727,670,000
On my Beaglebone Black I added a I2C real-time-clock to not being reliant on ntpd to maintain accurate timing. The outcome is that there are two special device files in /dev. These are /dev/rtc0 and /dev/rtc1 but there is also /dev/rtc which is a symlink to /dev/rtc0. /dev/rtc0 is the real-time-clock within the ARM SOC on the board, /dev/rtc1 is the I2C device. At the moment I'm using scripts that read and write the time manually to the I2C clock but I'd rather like the symlink /dev/rtc to point to /dev/rtc1. Hence the question, how can this be done? The Linux distro on my beaglebone black is Arch Linux which uses systemd for all the house keeping. When I delete the symlink and create a new one pointing to /dev/rtc1 not surprisingly it is reset after the next reboot and I didn't find any config files or systemd-units so far. Help is much appreciated.
That udev rule hint pointed me in the right direction. After a quick review of writing udev rules I did the following. udevadm info -a -p /sys/class/rtc/rtc1 The output (shortened) revealed some useful properties to define a udev rule. looking at device '/devices/platform/ocp/4802a000.i2c/i2c-1/1-0068/rtc/rtc1': KERNEL=="rtc1" SUBSYSTEM=="rtc" DRIVER=="" ATTR{date}=="2015-12-04" ATTR{hctosys}=="0" ATTR{max_user_freq}=="64" ATTR{name}=="ds1307" ATTR{since_epoch}=="1449230817" ATTR{time}=="12:06:57" ... So the rules file needs to reside in /etc/udev/rules.d/ with a naming scheme like 99-rtc1.rules. The files content is KERNEL=="rtc1", SUBSYSTEM=="rtc", DRIVER=="", ATTR{name}=="ds1307", SYMLINK="rtc", MODE="0666" To test the rule you can run udevadm test /sys/class/rtc/rtc1 and the important lines in the output are ... creating link '/dev/rtc' to '/dev/rtc1' atomically replace '/dev/rtc' ... The result in /dev is the desired configuration.
How can the link target of /dev/rtc be changed?
1,470,727,670,000
A program (which needs to read and write from and to the filesystem), has the extra feature of being able to communicate with an external sensor. Therefore it has the unique ability to know if a power loss is imminent. The warning I get is only a few (around 3 to 5) seconds - not enough to perform a full shut-down. A few precious seconds might be added, but it would increase hardware costs. As writing to a file does not guarantee that the OS will do the job now, even closing the file can, as far as I know, lead to the OS deciding it will do the closing later if no one else tries to access it, so how can I guarantee that all the writes I perform now will be saved. (After the warning is received, my program will write a few kilobytes to disk, but there might have been larger amounts of data written before the warning is received, which might or might not yet be finalized by the OS) No other corruption occurs because of an improper shut-down of the OS. Note: by design, the loss of power might be a regular occurrence. Also by design, no other "user applications" will run on the system (so we don't have to worry for example about a music player, a development environment, a spreadsheet editor and gimp all running and accessing the file system).
The main thing you need to do is issue a sync system call. There's a sync utility that does just that. When the sync system call returns, it guarantees that any filesystem write operation (on any mounted filesystem) that was issued before the sync is completed. It's up to your application design to ensure that if this happens in the middle of a sequence of write operations, the data is left in a usable state. However, if you have the luxury of a guaranteed warning period before power loss, you can be sloppier in your application design, as long as you guarantee timely response to the power loss notice (which is hard). With journaling filesystems such as ext4, if you sync and then turn off power, you won't get an fsck on reboot. However, if something causes a write after the sync, I think it's possible, but rare, that fsck could be needed. If you want to be absolutely sure, unmount all read-write filesystems before the power loss, or at least remount them as read-only. Normally, you can't do that if there are files open for writing. If your system runs Linux, you can use its magic sysrq feature (you'll need to make sure that it's enabled). This can be invoked programmatically by writing a character to /proc/sysrq-trigger: echo u >/proc/sysrq-trigger force-remounts all filesystems as read-only (this includes the effect of sync). You can also use this interface to reboot (b) or power off (o), if that's useful in your setup. If the power loss notice might be cancelled, you can call sync: that has no ill effect on anything but performance. A force-mount-read-only, on the other hand, is not recoverable in general, so do that only when you've committed to rebooting. For most setups that match your description, this is a reasonable reaction to a power loss notice: Send a custom signal (e.g. SIGUSR1 or SIGPWR) to affected process, instructing them to quickly commit or abort any ongoing transaction, if it can help make the recovery on the next boot easier. Wait for part of the delay before the expected power loss. Calibrate that to have enough for the remaining operations. Write a log message. echo u >/proc/sysrq-trigger
If my program detects that a power loss will occur in a few seconds, what can it do to avoid data corruption?
1,470,727,670,000
I have an embedded device with this SD card: [root@(none) ~]# busybox fdisk -l Disk /dev/mmcblk0: 3965 MB, 3965190144 bytes 4 heads, 16 sectors/track, 121008 cylinders Units = cylinders of 64 * 512 = 32768 bytes Device Boot Start End Blocks Id System /dev/mmcblk0p1 305 8497 262144+ 83 Linux /dev/mmcblk0p2 8497 16689 262144+ 83 Linux /dev/mmcblk0p3 16689 60352 1397247 b Win95 FAT32 and these partitions: [root@(none) ~]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/root 253871 140291 113580 55% / none 16384 4 16380 0% /tmp none 127016 4 127012 0% /dev none 16 4 12 25% /var/lib none 16 0 16 0% /var/log none 128 16 112 13% /var/run /dev/mmcblk0p3 1394520 118036 1276484 8% /mnt/onboard I have a u-boot kernel image file, uImage, of ~2 Mb. What happens exactly if I do the following? dd if=uImage of=/dev/mmcblk0 bs=512 seek=2048 Why am I asking this? This command is strange for me because: the copied image is smalled than target partition it seems that the image is extracted on /dev/mmcblk0p1, that is the root partition. It starts at 305, while dd skips 2048 blocks EDIT: see Anthon's answer there's not a boot partition uImage is extracted; on the contrary I expected it will be used by u-boot as-is Background: the device is a Kobo Glo, and the command is executed by update scripts to update the kernel.
I am guessing here, as I have no Kobo Glo (I wish my Bookeen HD was reprogrammable). You seem to have a 2Gb SD memory internally ( 60352 cylinders of 32K each) The dd does skip 2048 blocks of 512 (1048576), which is less than the 305 cylinder offset (9994240). In fact have to write more than 8Mb to reach the /dev/mmcblk0p1 partition that way. How the device boots depends on its firmware, but it is likely that there is some basic bootstrapping done via the first 1Mb on the SD memory, that in turn then calls the image written with dd. /dev/mmcblk0p1 is 256Mb ( (8497 - 305)*32768 ) and that seems to be mounted as / with maybe a backup of it on /dev/mmcblk0p2 or vv.
What does this dd command do exactly?
1,470,727,670,000
I am just starting out with embedded Android drivers, so any help would be great. I haven't found a lot of resources online. At the moment, I am working through a tutorial on porting a driver, and the instructions read: copy the platform data initialization files, “driver_sources/platform.c" and "driver_sources/platform.h" into “/arch/arm/” How do I know which machine directory I should choose? I am using the APQ8064 DragonBoard. I don't see an APQ8064 to choose, but maybe it is called something else? boot common configs include Kconfig Kconfig.debug Kconfig-nommu kernel lib mach-at91 mach-bcmring mach-clps711x mach-cns3xxx mach-davinci mach-dove mach-ebsa110 mach-ep93xx mach-exynos mach-footbridge mach-gemini mach-h720x mach-highbank mach-imx mach-integrator mach-iop13xx mach-iop32x mach-iop33x mach-ixp2000 mach-ixp23xx mach-ixp4xx mach-kirkwood mach-ks8695 mach-l7200 mach-lpc32xx mach-mmp mach-msm mach-mv78xx0 mach-mxs mach-netx mach-nomadik mach-omap1 mach-omap2 mach-orion5x mach-picoxcell mach-pnx4008 mach-prima2 mach-pxa mach-realview mach-rpc mach-s3c2410 mach-s3c2412 mach-s3c2440 mach-s3c24xx mach-s3c64xx mach-s5p64x0 mach-s5pc100 mach-s5pv210 mach-sa1100 mach-shark mach-shmobile mach-spear3xx mach-spear6xx mach-tegra mach-u300 mach-ux500 mach-versatile mach-vexpress mach-vt8500 mach-w90x900 mach-zynq Makefile mm net nwfpe oprofile perfmon plat-iop plat-mxc plat-nomadik plat-omap plat-orion plat-pxa plat-s3c24xx plat-s5p plat-samsung plat-spear plat-versatile tools vfp
According to elinux.org this should be mach-msm folder. It is a folder for Qualcomm SoCs.
Embedded Linux: Which machine directory to pick in /arch/arm?
1,470,727,670,000
I have a router that provides internet connection to a single client device via a wireless cellular data network. This network provides non-public IP addresses which gets natted. I would like to get a static IP address outside of the network that will route everything back to the device on the cell network. Because this is an embedded device, space is limited (about 500kB to work with here). Because the network is expensive, it has to not consume too much traffic. First I tried creating an IPIP tunnel using iproute2. From the server, I used the router's egress IP for the remote IP, not the private address the router received. I hoped that once the router communicated over the tunnel to the server, the server could communicate back. This was not the case. I tried dropbear SSH and found it won't do a generic tunnel, but I thought I could probably get around that using iptables. However, it seems that just having the ssh link open consumes about 150 bytes/sec. I also tried nc, but the communication is only one direction, so I can initiate a connection to the server, but can't get anything back. OpenSSH and OpenVPN are too big to fit on the device (both around 1MB). My next attempt will probably be to write a program that keeps a persistent socket open to the server, and to use iptables to route the traffic to that program. I wanted to see if there were any other ideas first. So, any ideas?
The only NAT that an IPIP tunnel might work with is one-to-one NAT, which is clearly not what you have in the cellular case. This "150 bytes/second for an open SSH connection" business is very strange and you should investigate. No such thing happens for me with OpenSSH -> OpenSSH sessions (there's the unavoidable keepalives, but you actually WANT those when you're behind a NAT) and there's no reason it should unless you're actually passing traffic. You are mistaken about netcat being unidirectional, a TCP session initiated with netcat works both ways. I would suggest getting a bidirectional stream up any way you can (probably netcat and a TCP listener on the server) and running PPP over that. You get all the usual disadvantages of running IP over TCP, but it's better than not having connectivity at all. Here's what works for me in a quick test - on the server: server:~$ sudo pppd noauth passive pty "nc -lp 9999" debug nodetach On the client: client:~$ sudo pppd noauth pty "nc server 9999" debug nodetach I think having dialup semantics also provides a useful model for the cases where your cell device will simply not be reachable. After you have the IP connection running, you can consider playing IPIP or 1:1 NAT.
Tunnel through a NAT
1,470,727,670,000
I am working on a Colibri module having Angstrom linux installed in it! The processor is ARM v7. I am having trouble updating the softwares installed in the system. Whenever I tried the command opkg update, I'd get a bunch of errors. Probably, it seems that the support from Angstrom project has been withdrawn as it gives 404 content not found error. The error message is: $ opkg update Downloading http://feeds.angstrom-distribution.org/feeds/v2014.06/ipk/eglibc/armv7ahf-vfp-neon/base/Packages.gz. wget: server returned error: HTTP/1.1 404 Not Found Downloading http://feeds.angstrom-distribution.org/feeds/v2014.06/ipk/eglibc/armv7ahf-vfp-neon/debug/Packages.gz. wget: server returned error: HTTP/1.1 404 Not Found Downloading http://feeds.angstrom-distribution.org/feeds/v2014.06/ipk/eglibc/armv7ahf-vfp-neon/gstreamer/Packages.gz. wget: server returned error: HTTP/1.1 404 Not Found Downloading http://feeds.angstrom-distribution.org/feeds/v2014.06/ipk/eglibc/all/Packages.gz. Inflating http://feeds.angstrom-distribution.org/feeds/v2014.06/ipk/eglibc/all/Packages.gz. Updated list of available packages in /var/lib/opkg/lists/no-arch. Downloading http://feeds.angstrom-distribution.org/feeds/v2014.06/ipk/eglibc/armv7ahf-vfp-neon/perl/Packages.gz. wget: server returned error: HTTP/1.1 404 Not Found Downloading http://feeds.angstrom-distribution.org/feeds/v2014.06/ipk/eglibc/armv7ahf-vfp-neon/python/Packages.gz. wget: server returned error: HTTP/1.1 404 Not Found Collected errors: * opkg_download: Failed to download http://feeds.angstrom-distribution.org/feeds/v2014.06/ipk/eglibc/armv7ahf-vfp-neon/base/Packages.gz, wget returned 1. * opkg_download: Failed to download http://feeds.angstrom-distribution.org/feeds/v2014.06/ipk/eglibc/armv7ahf-vfp-neon/debug/Packages.gz, wget returned 1. * opkg_download: Failed to download http://feeds.angstrom-distribution.org/feeds/v2014.06/ipk/eglibc/armv7ahf-vfp-neon/gstreamer/Packages.gz, wget returned 1. * opkg_download: Failed to download http://feeds.angstrom-distribution.org/feeds/v2014.06/ipk/eglibc/armv7ahf-vfp-neon/perl/Packages.gz, wget returned 1. * opkg_download: Failed to download http://feeds.angstrom-distribution.org/feeds/v2014.06/ipk/eglibc/armv7ahf-vfp-neon/python/Packages.gz, wget returned 1. 404 Not Found feeds.angstrom-distribution.org Also, I tried installing package gcc by using the command opkg install gcc, but the same result. Again, surprisingly, the error message is unbelievable... $ opkg install gcc Unknown package 'gcc'. Collected errors: * opkg_install_cmd: Cannot install package gcc. I have no idea as to how to resolve this error as it is completely surprising. Also, it is of immense importance as I have to complete it within 2 days of installing gcc and running C programs...
Sorry I just saw your question now, and I had to deal with the same issue on Apalis T30. Toradex is quite helpful if you ask them questions, but I found the solution myself in their release notes. Newer images of Toradex builds for Apalis and Colibri have an issue with the Angstrom package feeds. (V2.3 Beta1+ is my understanding). You will need to manually change some files in the /etc/opkg/*.conf to make it work. Search for armv7ahf-vfp-neon and replace them with armv7at2hf-vfp-neon. From Toradex's release notes file Colibri_T30_LinuxReleaseNotesV2.x.txt: The Angstrom-Distribution since switched to using ARM Thumb2 instruction set. To use their binary feeds e.g. using the opkg package manager please change in /etc/opkg/base-feed.conf et. al. armv7ahf-vfp-neon to armv7at2hf-vfp-neon. We consider switching in our next release. On Apalis T30 I had to change 5-6 .conf files to make it work.
Trouble with opkg package manager in Angstrom embedded linux on Colibri module ARM v7 processor
1,470,727,670,000
I want to run SSH on Qtopia (on my FriendlyARM). My own distribution is Ubuntu, so I cannot copy and paste the ssh binary file into the device. If I can copy and paste a binary file, where can I find it? If I must compile SSH, how is it possible in my ubuntu?
Your device has an ARM processor. Your PC has an x86 processor. ARM and x86 are different processor architectures with different instruction sets. An executable program compiled for x86 consists of x86 instructions that an ARM processor cannot execute, and vice versa. You need an ARM binary. Furthermore, you need an ARM binary that's compatible with the other software you have on your device. Specifically, you need either a statically linked binary (a binary that does not depend on anything else) or a binary linked with the right system libraries. Check which standard library you have. If you have a file called /lib/ld-uClibc.so, you have uClibc, a small library intended for embedded systems. If you have a file called /lib/ld-linux.so.2, you have GNU libc, the same library that you have on your Ubuntu PC (and any other non-embedded Linux). You have two choices of SSH clients and servers: OpenSSH and Dropbear. Dropbear is smaller, but has fewer features, in particular no SFTP. If the standard library is Glibc, you can grab a binary from Debian's ARM distribution. Get the armel client or server package. Extract the .deb file by running dpkg-deb -x openssh-….deb . Then copy the binary from ./usr/bin or ./usr/sbin to the device. If the standard library is uClibc, you'll need to grab a binary from a distribution based on uClibc. Dropbear is included in many embedded distribution. Openmoko, which shares some ancestry with Qtopia, includes Dropbear in its default installation. If you're going to want to install several programs, BuildRoot makes it very easy to obtain a cross-compiler and build common programs: you pretty much only need to follow the guide.
Adding ssh on embedded linux
1,470,727,670,000
I'm working on a Davinci DSP ARM embedded board. The board itself is the Texas Instruments 816X/389X EVM. I'm currently trying to get apache working on the board. The problem is that the SDK for the board is extremely basic and doesn't include 'make' or any update manager like RPM, yum, or apt-get. So I'm having a hard time getting it to work. I compiled apache on my host machine, which is connected through minicom to the target. I have G++ Sourcery installed, but don't have any experience with it. So, when I took the compiled files to the target, I ended up with the error: line 1: syntax error: word unexpected (expecting ")") I'm assuming that I did something wrong during the compile, but I'm not really sure because I'm normally a hardware designer and not a software guy.
When you are compiling something for another system, it needs to be cross-compiled to that architecture. Most likely your host is an x86. The TI is an ARM. The instruction set isn't the same. You need to setup a cross toolchain to compile apache with an ARM version of g++. TI should have included cross tools with the EVM so that's the best place to start looking. Otherwise, you can build your own toolchain (http://kegel.com/crosstool/).
Embedded board with apache
1,470,727,670,000
The following is contained in the vendor user manual for its embedded Linux distro on the hardward board they supply Developers can put their program onto X-Linux device via FTP or NFS. Before running it, use ldd command on development workstation to check dependency files. Also put relative files onto X-Linux to ensure program can run properly. Here is an example when we put “syslinux” onto X-Linux: [root@X-Linux]:/sbin # ldd syslinux linux-gate.so.1 => (0xb80a0000) libc.so.6 => /lib/libc.so.6 (0xb7f60000) /lib/ld-linux.so.2 (0xb80a1000) [root@X-Linux]:/sbin # From above messages, /lib/libc.so.6 and /lib/ld-linux.so.2 are needed by syslinux. Put those two files onto X-Linux to ensure syslinux can work properly. I will have to write software to run on this device and a lot of advice I have received on stack exchange points me in directions that contradict this advice (suggesting setting up specific embedded development environment, linking to older versions of libc, static linking etc). Is the above information given by the vendor a safe and reliable way to do things???
You can copy libraries to your embedded device provided that it's running the same operating system on the same processor architecture family. Your device has an x86 processor, which is the same family as 32-bit PCs. So if you have a 32-bit Linux system on your desktop machine, you can copy libraries and executables from your desktop machine to your device. On the other hand, I do not recommend doing things that way. You'll end up with a jumble of files of unknown origin, with no way to manage dependencies, upgrade, or uninstall software. From what I gather from a quick glance at the manual, X-Linux is a small Linux system that is not designed to be extensible. My recommendation is to instead install another Linux distribution alongside or instead of X-Linux. If the other distribution is alongside X-Linux, run programs from that distribution in a chroot (you'll still be constrained by the X-Linux kernel).
Is it safe to just copy shared libraries onto embedded Linux device?
1,470,727,670,000
My main question is how the open source community reverse engineers windows drivers (for say, video cards) to re-write them under linux. I'm an EE graduate, so I've taken courses in microprocessor design and such, assembly, C for embedded systems, and I've worked on embedded linux. But I feel like I'm missing something when trying to understand how drivers are written for linux without an API from the hardware manufacturer. What leads to my question is that on some new laptops, they come with dual video cards. Both an integrated one and a discrete one. There's driver software that allows switching between the 2 in windows, but as far as I know, there's no either open source or proprietary drivers. Obviously I'm not asking something stupid like "omg how do I write that msyelf". But it did make me realize that I've always wondered the process of getting hardware support on linux.
There are of course a lot of possibilities. For example if it is an USB device you could monitor the USB traffic between the device/compute on a system with driver support (analogous to tcpdump for network). For example for Windows there are several USB monitor tools available (IIRC usbsnoop for example). In the case of a USB scanner you could e.g. generate a trace with the default settings, then change one setting, generate another trace, compare them and figure out what changed and so on. Analogous to that you could trace stuff for SCSI, Firewire etc. devices. Then you could try to dis-assemble/debug a proprietary driver (for example with IDA pro). Or you could execute Windows in a virtual machine or emulator (e.g. qemu) and use breakpoints and inspect the hardware state before/after driver calls. Analogous to that you could observe to what registers or something like that a driver writes/reads.
Capturing OS/hardware communication / reverse engineering drivers
1,470,727,670,000
I am able to telnet into a router that's running a customized linux firmware. It was compiled using 'buildroot'. I was able to dig out some specs of the router. I intend to clone the router's firmware for further study. 'dd' is not available so I tried using cat to throw the entire contents of the flash drive (mtdblock0) to my pc using netcat: Router: cat /dev/mtdblock0 | nc ip port PC: nc -lp port > routerFirmware Then on my PC I used 'binwalk' to examine the downloaded file. The result is: DECIMAL HEXADECIMAL DESCRIPTION -------------------------------------------------------------------------------- 0 0x0 Squashfs filesystem, little endian, non-standard signature, version 4.0, compression:gzip, size: xxxxxxx bytes, xxx inodes, blocksize: xxxxxx bytes, created: xxxx-xx-xx xx:xx:xx Seems good so far. But '# unsquash routerFlash' results in: Can't find a SQUASHFS superblock on routerFlash The most probable reason I think is that 'cat' and 'nc' are not able to clone the entire flash as I intend. I am stuck here. Any help would be appreciated!
Turns out the 'cloning' step was not the problem. My router vendor had used non-standard 'magic number' to create the squashfs system. I was advised to give sasquatch a shot. Fortunately, sasquatch correctly read and understood the file compression and other details, which unsquash didn't report correctly. Result: I have a replica of my router firmware on my PC which I can study and analyze, just as I wanted. Looks good so far.
Clone a block device using 'cat'
1,470,727,670,000
I'm running an Linux Image (kernel 3.2.8) for beagleboard-xm on QEMU's 1.4.0 emulator Ubuntu distribution for 13.04. My image is created using Buildroot beagle_defconfig. I added some pkgs to be able to debug a little. QEMU call cmd: `$ sudo qemu-system-arm -M beaglexm -m 1024 -sd ./test.img -clock unix -serial stdio -device usb-mouse -device usb-kbd -serial pty -serial pty` [sudo] password for emperador: char device redirected to /dev/pts/3 (label serial1) char device redirected to /dev/pts/4 (label serial2) What I want to do is to have a communication between guest and host across serial the 4 differents ttyO present on the guest. QEMU offer facilities to redirect the trafic to some device in the host side. My problem goes like this: At the guest kernel boot Im able to see that my UART where enabled [ 2.682040] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled [ 2.777947] omap_uart.0: ttyO0 at MMIO 0x4806a000 (irq = 72) is a OMAP UART0 [ 2.794967] omap_uart.1: ttyO1 at MMIO 0x4806c000 (irq = 73) is a OMAP UART1 [ 2.814942] omap_uart.2: ttyO2 at MMIO 0x49020000 (irq = 74) is a OMAP UART2 [ 2.966825] console [ttyO2] enabled [ 2.984777] omap_uart.3: ttyO3 at MMIO 0x49042000 (irq = 80) is a OMAP UART3 In fact when I go see in to /proc/tty/driver and I do a cat on OMAP-SERIAL Im able to see this serinfo:1.0 driver revision: 0: uart:OMAP UART0 mmio:0x4806A000 irq:72 tx:0 rx:0 CTS|DSR|CD 1: uart:OMAP UART1 mmio:0x4806C000 irq:73 tx:0 rx:0 CTS|DSR|CD 2: uart:OMAP UART2 mmio:0x49020000 irq:74 tx:268 rx:37 RTS|CTS|DTR|DSR|CD 3: uart:OMAP UART3 mmio:0x49042000 irq:80 tx:0 rx:0 CTS|DSR|CD I know that ttyO2 is working because my console is been redirected to it. The thing is that doing a set serial on any of the ttyO I get the following message: [root@enu driver]# setserial -a /dev/ttyO0 /dev/ttyO0, Line 0, UART: undefined, Port: 0x0000, IRQ: 72 Baud_base: 3000000, close_delay: 50, divisor: 0 closing_wait: 3000 Flags: spd_normal The same goes with ttyO2. I tried to set some settings to any of the ttyO with setserial but I always get the same message: [root@enu ~]# setserial /dev/ttyO0 uart 8250 setserial: can't set serial info: Invalid argument [root@enu ~]# setserial /dev/ttyO0 port 0x4806a000 setserial: can't set serial info: Invalid argument While looking at guest /proc/tty/drives this is what we see /dev/tty /dev/tty 5 0 system:/dev/tty /dev/console /dev/console 5 1 system:console /dev/ptmx /dev/ptmx 5 2 system /dev/vc/0 /dev/vc/0 4 0 system:vtmaster sdio_uart /dev/ttySDIO 249 0-7 serial acm /dev/ttyACM 166 0-31 serial ttyprintk /dev/ttyprintk 5 3 console OMAP-SERIAL /dev/ttyO 253 0-3 serial serial /dev/ttyS 4 64-95 serial pty_slave /dev/pts 136 0-1048575 pty:slave pty_master /dev/ptm 128 0-1048575 pty:master unknown /dev/tty 4 1-63 console Basically I want to establish a serial communication between a guest and a host, but the serial ports on the guest side aren't well configured. /sys/class/tty show that tty drivers had been linked to a serial device. has I showed up before, only omap uarts have been initialized and attached to ttyO*. notice that the console is been redirected ttyO2 by kernel configs. but because I added -serial stdio, console is been redirected to the terminal that invoked QEMU. If I redirect the console using at first -serial pty instead of -serial stdio , I'm able to prompt the console in minicom by opening the pty created on the host side. Still nothing happen on the others pty created on the host side to communicate across other ports. On host side I open /dev/pts/3 and /dev/pts/4 with minicom or by doing cat on them On guest side: Whent I do echo "test" > /dev/ttyO0 or 1 or 3 nothing. but when I do it on ttyO2, "test" prompt on the console terminal (which is normal). now when using any of the ttyS: echo "test" > /dev/ttyS0 I get -bash: echo: write error: Input/output error I made some research about this error and what I found is that is could be many things. But one thing that I noticed was that no device beside serial has been assigned to ttyS. and looking at /proc/tty/driver/serial we see this : serinfo:1.0 driver revision: 0: uart:unknown port:00000000 irq:0 1: uart:unknown port:00000000 irq:0 2: uart:unknown port:00000000 irq:0 3: uart:unknown port:00000000 irq:0 also setserial -a /dev/ttyS0 confrim this: /dev/ttyS0, Line 0, UART: unknown, Port: 0x0000, IRQ: 0 Baud_base: 0, close_delay: 50, divisor: 0 closing_wait: 3000 Flags: spd_normal I managed to do serial communication with muliples ports usig grml image on a x86 architecture. So its seems the host side is fine. If anyone have ever made something like this work before on QEMU -M beaglexm or any other ARM architecture, I would gladly take any details on the VM used, QEMU's version and distribution as well as the kernel details and image configs used.
I found what my problem was, QEMU ins't mapping the serial chardev of any extra -serial pty. After doing the this Invoke command: sudo qemu-system-arm -M beaglexm -m 1024 -sd ./test.img -clonix -serial stdio -device usb-mouse -device usb-kbd -serial pty -serial pty -monitor pty char device redirected to /dev/pts/5 (label compat_monitor0) char device redirected to /dev/pts/7 (label serial1) char device redirected to /dev/pts/10 (label serial2) We can see that 2 extra serials where created with the label serial 1 and 2. But if I look at the tree info (qemu) info qtree dev: omap_uart, id "uart4" revision = 82 mmio_size = 4096 baudrate = 812500 chardev = uart4 irq 3 mmio 0000000049042000/0000000000001000 dev: omap_uart, id "uart3" revision = 82 mmio_size = 4096 baudrate = 812500 chardev = serial0 irq 3 mmio 0000000049020000/0000000000001000 dev: omap_uart, id "uart2" revision = 82 mmio_size = 4096 baudrate = 812500 chardev = uart2 irq 3 mmio 000000004806c000/0000000000001000 dev: omap_uart, id "uart1" revision = 82 mmio_size = 4096 baudrate = 812500 chardev = uart1 irq 3 mmio 000000004806a000/0000000000001000 We clearly see that just the label serial0 was attached to a uart (the one setted to be the console). The other labels (serial1 and serial2) are no where to be found. With the working image of grml that jofel was realy nice to tell me we see this: dev: i440FX-pcihost, id "" irq 0 bus: pci.0 type PCI dev: PIIX3, id "" addr = 01.0 romfile = <null> rombar = 1 multifunction = on command_serr_enable = on class ISA bridge, addr 00:01.0, pci id 8086:7000 (sub 1af4:1100) bus: isa.0 type ISA dev: isa-serial, id "" index = 2 iobase = 0x3e8 irq = 4 chardev = serial2 wakeup = 0 isa irq 4 dev: isa-serial, id "" index = 1 iobase = 0x2f8 irq = 3 chardev = serial1 wakeup = 0 isa irq 3 dev: isa-serial, id "" index = 0 iobase = 0x3f8 irq = 4 chardev = serial0 wakeup = 0 isa irq 4 all 3 serial lebels were attached to a chardev. Now I just have to ask a new question about how making QEMU to link those lables to my beagleboard uarts. Also I would like to add I think that setserial did not outputed any info about ttyO's because it doesn't support omap uarts. setserial ? shows what devices are supported. In the case of the ttyS's, I think its because the tty drivers are installed but there is no other type of uarts bisede omap uarts emulated for bealgeboard in QEMU. Thanks alot for everyone that took a look on this question and specialy jofel.
ttyO ports do not have the good port address on QEMU 1.4.0 running image for beagleboard-xm
1,470,727,670,000
We have custom hardware running 3.2 Angstrom on a SAM9G45 processor. Everything works fine. Recently we designed similar hardware that uses the SAM9G25 processor. We found the 2.6 kernel works fine on the SAM9G25, but we needed to port the 3.2 kernel to the platform to take advatage of some wireless drivers. We completed the port, but we have just discovered the time of day clock is not reliable. It runs fine for about 20 minutes - then the time (reported by "date") will jump ahead a few hours or days. The 2.6 kernel still works fine, so we think it's something we did not port correctly. We have looked over everything, but no luck so far. I'm not sure where to look next. Final Answer: Atmel supplies a patch for the 2.6 kernel, to the file tcb_clksrc.c. We missed that in our port to the 3.2 kernel. Thanks for the insight!
Try booting the system with the kernel-option clocksource=jiffies or nohpet. I have an open case about SLES11 SP2 (using Kernel 3.0) where I observe time-mismatches on VMs. The clocksource=jiffies made it worse in my case - but in yours it might help. Currently the support is focussing on the high-precision-event-timer (but I doubt that your embedded system has such a device).
How can I find the cause of clock drift on a custom embedded system?
1,470,727,670,000
I have a single board appliance that runs Debian 10 on a chunk of flash. UBIFS is used, and is split into two volumes: an ro roots, and an rw /var. I have found that under power cycling/reset conditions, that I can end up with 0 byte files. I keep my "settings" in /var/opt/myApp. Changing the mount option of /var to include sync seems to make those incidents go away. I know the usual advice is that async is preferred over sync, but it is usually caveated with "usually, but not always" with little explanation what the exceptions might be. The alternate solution, would be to modify any and all call sites where I write data to disk, to not only flush on file close, but sync as well (I do a lot of it with python). From a coding/completeness sake, mounting as sync seemed both less work, and avoided me missing adding the sync guards at places, iow it's universal. Additionally, I allow the appliance to save data to usb thumb drives. I think I should mount those sync too, to reduce loss when they are yanked out right after data is written to them. Is this a suitably exceptional configuration to justify using sync? Or should I use the alternate solution?
Here is my opinion: Sorry for verbosity in advance. When we are specifically talking about ubifs we should always either sync / similar options. ubifs supports write-back caching That means changes written on the files do not go to flash directly. They are stored on the page cache first and later written to flash. (Read more on write buffers for NAND flashes in UBIFS) This improves file system performance by reducing number of writes. Note that this is asynchronous behavior of fs. As you said in the question, when you mount UBIFS with -sync option, it will make the file system synchronous (changes are written to flash every time) however at the cost of performance drop. If you are working with asynchronous file systems like ubifs, then the onus of making sure that writes are written to flash is on application developers. Here is the what man page of write(2) says: $ man 2 write NOTES A successful return from write() does not make any guarantee that data has been committed to disk. In fact, on some buggy implementations, it does not even guarantee that space has successfully been reserved for the data. The only way to be sure is to call fsync(2) after you are done writing all your data. Using sync - synchronizes whole fs. Might not be optimal fsync - Mostly does the job fdatasync - Only data changes are flushed and not the metadata (permissions). More optimal than fsync maybe (not sure) Also read Good Read about fsync So at the end, your options: mount with 'sync' - with performance hit improve the application using above sync options. handle 0 byte files in applications creating temp files and renaming them later Last thought, might wanna switch to synchronous fs like jffs2 (not fully synchronous if using NAND flash though). I know this is not the answer to your question but eh, wrote so much might as well write this....
To sync or not to sync in an embedded environment?
1,470,727,670,000
I'm working on an embedded system and want to make it boot faster. I already stripped a lot of things. Now I don't know how to improve it further. Here is my systemd-analyze blame: 4.457s dev-mmcblk0p2.device 1.303s systemd-journald.service 913ms systemd-journal-flush.service 793ms systemd-sysctl.service 672ms systemd-udev-trigger.service 287ms systemd-udevd.service And here is the systemd-analyze time: Startup finished in 4.202s (kernel) + 5.179s (userspace) = 9.381s Does anyone know how to optimize dev-mmcblk0p2.device and/or systemd-journal*.service? For Information: mmcblk0p2 is an internal emmc where the rootfs is located.
I found out, that I had to modify the kernel commandline in U-boot. The commandline now Looks like this: # cat /proc/cmdline root=/dev/mmcblk0p2 rootfstype=ext4 rootwait console=ttymxc4,115200 quiet consoleblank=0 coherent_pool=32M
Systemd Boot Optimization dev-mmcblk0p2.device
1,470,727,670,000
For an embedded Linux system, if I have two or more network interfaces, how do I ensure that they always get the same interface names every boot In other words, I want, for example, eth0 to always map to one physical Ethernet port, eth1 to the next, etc. My Linux "distribution" is home-grown, and I use devtmpfs for populating /dev. I use busybox for init (and most everything else), along with custom init scripts for system startup and shutdown. I do not need hotplug facilities of mdev or udev -- I'm referring to "fixed" Ethernet ports.
This works for me with Linux 3.9.0 on an x86_64 architecture. #!/bin/sh # This assumes the interfaces come up with default names of eth*. # The interface names may not be correct at this point, however. # This is just a way to get the PCI addresses of all the active # interfaces. PCIADDRLIST= for dir in /sys/class/net/eth* ; do [ -e $dir/device ] && { PCIADDRLIST="`readlink -f $dir/device` ${PCIADDRLIST}" } done # Now assign the interface names from an ordered list that maps # to the PCI addresses of each interface. # IFNAMES could come from some config file. "dummy" is needed because of # my limited tr- and awk-fu. IFNAMES="eth0 eth1 eth2 dummy" for dir in `echo ${PCIADDRLIST} | tr " " "\n" | sort` ; do [ -e $dir/net/*/address ] && { MACADDR=`cat $dir/net/*/address` IFNAME=`echo $IFNAMES | awk '{print $1}'` IFNAMES=`echo $IFNAMES | awk '{ for (i=2; i<=NF; i++) printf "%s ", $i; }'` echo -n "$IFNAME " nameif $IFNAME mac=$MACADDR } done
How do you ensure physical network interfaces always get the same interface name across reboots on an embedded Linux system?
1,470,727,670,000
Looks like my MTD2,and MTD3 partitions are write protected. The OS is booting from SD card on a ARM Cortex A 9 processor. root@Xilinx-ZC702-2013_3:~# mount /dev/mmcblk0p1 /mnt/ root@Xilinx-ZC702-2013_3:~# root@Xilinx-ZC702-2013_3:~# cd /mnt/flash/ root@Xilinx-ZC702-2013_3:/mnt/flash# root@Xilinx-ZC702-2013_3:/mnt/flash# ls BOOT.BIN image.ub rootfs.jffs2 root@Xilinx-ZC702-2013_3:/mnt/flash# flashcp -v image.ub /dev/mtd2 While trying to open /dev/mtd2 for read/write access: Permission denied root@Xilinx-ZC702-2013_3:/mnt/flash# Even I tried this: root@Xilinx-ZC702-2013_3:/mnt/flash# flash_eraseall -j /dev/mtd2 flash_eraseall has been replaced by `flash_erase <mtddev> 0 0`; please use it flash_erase: error!: /dev/mtd2 error 13 (Permission denied) Here are additional info: root@Xilinx-ZC702-2013_3:/mnt/flash# mtdinfo Count of MTD devices: 4 Present MTD devices: mtd0, mtd1, mtd2, mtd3 Sysfs interface supported: yes root@Xilinx-ZC702-2013_3:~# cat /proc/mtd dev: size erasesize name mtd0: 00500000 00010000 "boot" mtd1: 00020000 00010000 "bootenv" mtd2: 001202c0 00010000 "image" mtd3: 00500000 00010000 "jffs2" Also: root@Xilinx-ZC702-2013_3:/mnt/flash# mtd_debug info /dev/mtd3 mtd.type = MTD_NORFLASH mtd.flags = MTD_BIT_WRITEABLE mtd.size = 5242880 (5M) mtd.erasesize = 65536 (64K) mtd.writesize = 1 mtd.oobsize = 0 regions = 0 root@Xilinx-ZC702-2013_3:/mnt/flash# mtd_debug info /dev/mtd2 mtd.type = MTD_NORFLASH mtd.flags = MTD_BIT_WRITEABLE mtd.size = 1180352 (1M) mtd.erasesize = 65536 (64K) mtd.writesize = 1 mtd.oobsize = 0 regions = 0 root@Xilinx-ZC702-2013_3:/mnt/flash# mtd_debug info /dev/mtd1 mtd.type = MTD_NORFLASH mtd.flags = MTD_CAP_NORFLASH mtd.size = 131072 (128K) mtd.erasesize = 65536 (64K) mtd.writesize = 1 mtd.oobsize = 0 regions = 0 root@Xilinx-ZC702-2013_3:/mnt/flash# mtd_debug info /dev/mtd0 mtd.type = MTD_NORFLASH mtd.flags = MTD_CAP_NORFLASH mtd.size = 5242880 (5M) mtd.erasesize = 65536 (64K) mtd.writesize = 1 mtd.oobsize = 0 regions = 0 root@Xilinx-ZC702-2013_3:/mnt/flash# How do I solve this issue? dmesg output I think something is wrong here: 4 ofpart partitions found on MTD device spi32766.0 Creating 4 MTD partitions on "spi32766.0": 0x000000000000-0x000000500000 : "boot" 0x000000500000-0x000000520000 : "bootenv" 0x000000520000-0x0000006402c0 : "image" mtd: partition "image" doesn't end on an erase block -- force read-only 0x0000006402c0-0x000000b402c0 : "jffs2" mtd: partition "jffs2" doesn't start on an erase block boundary -- force read-on ly full dmesg output is given here Booting Linux on physical CPU 0x0 Linux version 3.8.11 (root@xilinx) (gcc version 4.7.3 (Sourcery CodeBench Lite 2 013.05-40) ) #3 SMP PREEMPT Mon Apr 7 19:02:27 IST 2014 CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=18c5387d CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache Machine: Xilinx Zynq Platform, model: . Memory policy: ECC disabled, Data cache writealloc On node 0 totalpages: 262144 free_area_init_node: node 0, pgdat c0bed1c0, node_mem_map c0c0a000 Normal zone: 1520 pages used for memmap Normal zone: 0 pages reserved Normal zone: 193040 pages, LIFO batch:31 HighMem zone: 528 pages used for memmap HighMem zone: 67056 pages, LIFO batch:15 PERCPU: Embedded 7 pages/cpu @c1415000 s6592 r8192 d13888 u32768 pcpu-alloc: s6592 r8192 d13888 u32768 alloc=8*4096 pcpu-alloc: [0] 0 [0] 1 Built 1 zonelists in Zone order, mobility grouping on. Total pages: 260096 Kernel command line: console=ttyPS0,115200 PID hash table entries: 4096 (order: 2, 16384 bytes) Dentry cache hash table entries: 131072 (order: 7, 524288 bytes) Inode-cache hash table entries: 65536 (order: 6, 262144 bytes) __ex_table already sorted, skipping sort Memory: 1024MB = 1024MB total Memory: 1027124k/1027124k available, 21452k reserved, 270336K highmem Virtual kernel memory layout: vector : 0xffff0000 - 0xffff1000 ( 4 kB) fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB) vmalloc : 0xf0000000 - 0xff000000 ( 240 MB) lowmem : 0xc0000000 - 0xef800000 ( 760 MB) pkmap : 0xbfe00000 - 0xc0000000 ( 2 MB) modules : 0xbf000000 - 0xbfe00000 ( 14 MB) .text : 0xc0008000 - 0xc04effd4 (5024 kB) .init : 0xc04f0000 - 0xc0bbf9c0 (6975 kB) .data : 0xc0bc0000 - 0xc0bedee0 ( 184 kB) .bss : 0xc0bedee0 - 0xc0c09670 ( 110 kB) Preemptible hierarchical RCU implementation. NR_IRQS:16 nr_irqs:16 16 MIO pin 47 not assigned(00001220) xslcr mapped to f0002000 Zynq clock init sched_clock: 16 bits at 54kHz, resolution 18432ns, wraps every 1207ms ps7-ttc #0 at f0004000, irq=43 Console: colour dummy device 80x30 Calibrating delay loop... 1332.01 BogoMIPS (lpj=6660096) pid_max: default: 32768 minimum: 301 Mount-cache hash table entries: 512 CPU: Testing write buffer coherency: ok Setting up static identity map for 0x35eec0 - 0x35eef4 L310 cache controller enabled l2x0: 8 ways, CACHE_ID 0x000000c0, AUX_CTRL 0x72360000, Cache size: 524288 B CPU1: Booted secondary processor Brought up 2 CPUs SMP: Total of 2 processors activated (2664.03 BogoMIPS). devtmpfs: initialized NET: Registered protocol family 16 DMA: preallocated 256 KiB pool for atomic coherent allocations xgpiops e000a000.ps7-gpio: gpio at 0xe000a000 mapped to 0xf004e000 bio: create slab <bio-0> at 0 GPIO IRQ not connected XGpio: /amba@0/gpio@41200000: registered, base is 252 SCSI subsystem initialized usbcore: registered new interface driver usbfs usbcore: registered new interface driver hub usbcore: registered new device driver usb Switching to clocksource xttcps_clocksource NET: Registered protocol family 2 TCP established hash table entries: 8192 (order: 4, 65536 bytes) TCP bind hash table entries: 8192 (order: 4, 65536 bytes) TCP: Hash tables configured (established 8192 bind 8192) TCP: reno registered UDP hash table entries: 512 (order: 2, 16384 bytes) UDP-Lite hash table entries: 512 (order: 2, 16384 bytes) NET: Registered protocol family 1 RPC: Registered named UNIX socket transport module. RPC: Registered udp transport module. RPC: Registered tcp transport module. RPC: Registered tcp NFSv4.1 backchannel transport module. bounce pool size: 64 pages jffs2: version 2.2. (NAND) (SUMMARY) © 2001-2006 Red Hat, Inc. msgmni has been set to 1478 Block layer SCSI generic (bsg) driver version 0.4 loaded (major 253) io scheduler noop registered io scheduler deadline registered io scheduler cfq registered (default) e0001000.serial: ttyPS0 at MMIO 0xe0001000 (irq = 82) is a xuartps console [ttyPS0] enabled xdevcfg f8007000.ps7-dev-cfg: ioremap f8007000 to f00c8000 with size 100 st: Version 20101219, fixed bufsize 32768, s/g segs 256 osst :I: Tape driver with OnStream support version 0.99.4 osst :I: $Id: osst.c,v 1.73 2005/01/01 21:13:34 wriede Exp $ SCSI Media Changer driver v0.25 xqspips e000d000.ps7-qspi: master is unqueued, this is deprecated m25p80 spi32766.0: found n25q128, expected n25q128 m25p80 spi32766.0: n25q128 (16384 Kbytes) 4 ofpart partitions found on MTD device spi32766.0 Creating 4 MTD partitions on "spi32766.0": 0x000000000000-0x000000500000 : "boot" 0x000000500000-0x000000520000 : "bootenv" 0x000000520000-0x0000006402c0 : "image" mtd: partition "image" doesn't end on an erase block -- force read-only 0x0000006402c0-0x000000b402c0 : "jffs2" mtd: partition "jffs2" doesn't start on an erase block boundary -- force read-on ly xqspips e000d000.ps7-qspi: at 0xE000D000 mapped to 0xF00CA000, irq=51 libphy: XEMACPS mii bus: probed xemacps e000b000.ps7-ethernet: invalid address, use assigned xemacps e000b000.ps7-ethernet: MAC updated 96:ec:fa:13:9f:95 xemacps e000b000.ps7-ethernet: pdev->id -1, baseaddr 0xe000b000, irq 54 ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver ULPI transceiver vendor/product ID 0x0424/0x0007 Found SMSC USB3320 ULPI transceiver. ULPI integrity check: passed. xusbps-ehci xusbps-ehci.0: Xilinx PS USB EHCI Host Controller xusbps-ehci xusbps-ehci.0: new USB bus registered, assigned bus number 1 xusbps-ehci xusbps-ehci.0: irq 53, io mem 0x00000000 xusbps-ehci xusbps-ehci.0: USB 2.0 started, EHCI 1.00 usb usb1: New USB device found, idVendor=1d6b, idProduct=0002 usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1 usb usb1: Product: Xilinx PS USB EHCI Host Controller usb usb1: Manufacturer: Linux 3.8.11 ehci_hcd usb usb1: SerialNumber: xusbps-ehci.0 hub 1-0:1.0: USB hub found hub 1-0:1.0: 1 port detected Initializing USB Mass Storage driver... usbcore: registered new interface driver usb-storage USB Mass Storage support registered. i2c /dev entries driver xi2cps e0004000.ps7-i2c: 400 kHz mmio e0004000 irq 57 i2c i2c-0: Added multiplexed i2c bus 1 i2c i2c-0: Added multiplexed i2c bus 2 i2c i2c-0: Added multiplexed i2c bus 3 at24 3-0054: 1024 byte 24c08 EEPROM, writable, 1 bytes/write i2c i2c-0: Added multiplexed i2c bus 4 i2c i2c-0: Added multiplexed i2c bus 5 i2c i2c-0: Added multiplexed i2c bus 6 i2c i2c-0: Added multiplexed i2c bus 7 i2c i2c-0: Added multiplexed i2c bus 8 pca954x 0-0074: registered 8 multiplexed busses for I2C switch pca9548 xadcps f8007100.ps7-xadc: enabled: yes reference: external sdhci: Secure Digital Host Controller Interface driver sdhci: Copyright(c) Pierre Ossman sdhci-pltfm: SDHCI platform and OF driver helper mmc0: Invalid maximum block size, assuming 512 bytes mmc0: SDHCI controller on e0100000.ps7-sdio [e0100000.ps7-sdio] using ADMA usbcore: registered new interface driver usbhid usbhid: USB HID core driver TCP: cubic registered NET: Registered protocol family 10 sit: IPv6 over IPv4 tunneling driver NET: Registered protocol family 17 NET: Registered protocol family 40 VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4 Registering SWP/SWPB emulation handler Freeing init memory: 6972K mmc0: new high speed SDHC card at address 1234 mmcblk0: mmc0:1234 SA04G 3.67 GiB mmcblk0: p1
When you see weird kernel behavior, dmesg is a great first thing to check. In your case, it gave an important pointer: 4 ofpart partitions found on MTD device spi32766.0 Creating 4 MTD partitions on "spi32766.0": 0x000000000000-0x000000500000 : "boot" 0x000000500000-0x000000520000 : "bootenv" 0x000000520000-0x0000006402c0 : "image" mtd: partition "image" doesn't end on an erase block -- force read-only 0x0000006402c0-0x000000b402c0 : "jffs2" mtd: partition "jffs2" doesn't start on an erase block boundary -- force read-only Your /proc/mtd shows an erase block size of 64 KiB (0x10000). The size of the "image" partition (0x1202c0) is indeed not a multiple of the erase block size. The closest (though slightly smaller) is 0x120000 (1152 KiB); the next largest is 0x130000 (1216 KiB).
While trying to open /dev/mtd2 for read/write access: Permission denied
1,470,727,670,000
I'm not sure at which level I am having a problem. System is a LeopardBoard DM368 running TI's own SDK / LSP / BusyBox kernel, the core Linux kernel is 2.6.x so using serial_core.c driver model. By default the system has one UART enabled, UART0, mounted as /dev/ttyS0 which is also used/invoked via the bootargs console=ttyS0,115200n8 earlyprintk. We want to enable UART1 as /dev/ttyS1, so have gone through the low-level board initialisation code which sets up the pinmux, clocks, etc. On booting, the low-level init reports (via printk's I added in) that it's enabled the UART1, and the driver code reports happiness too: [ 0.547812] serial8250.0: ttyS0 at MMIO 0x1c20000 (irq = 40) is a 16550A [ 0.569849] serial8250.0: ttyS1 at MMIO 0x1d06000 (irq = 41) is a 16550A However, the port does not appear in /dev/ (as /dev/ttyS1), and there are discrepancies with its status (flow control bits) which I suspect may be causing it to hang / never transmit: cat /proc/tty/driver/serial serinfo:1.0 driver revision: 0: uart:16550A mmio:0x01C20000 irq:40 tx:97998 rx:0 CTS|DSR 1: uart:16550A mmio:0x01D06000 irq:41 tx:0 rx:0 DSR If I try to configure or modify it from the command line I get an error: >: stty -F /dev/ttyS1 stty: can't open '/dev/ttyS1': No such file or directory Bizarrely, if I change the bootargs to console=ttyS1,115200n8 earlyprintk the port works perfectly, and ttyS0 is still initialised correctly and works too: cat /proc/tty/driver/serial serinfo:1.0 driver revision: 0: uart:16550A mmio:0x01C20000 irq:40 tx:0 rx:0 CTS|DSR 1: uart:16550A mmio:0x01D06000 irq:41 tx:11563 rx:0 RTS|DTR|DSR Now, that would be fine, but our bootloader must use UART0 so it would be nice to keep all the console stuff on ttyS0 and have ttyS1 for our secondary comms. I inserted a couple of printk's into serial_core.c and it seems like uart_open() is never being called for ttyS1, I'm assuming it's something in the Linux init/startup sequence that needs modifying? Edited: because I had fooled myself by doing an echo >/dev/ttyS1 which had created a file called /dev/ttyS1, which clouded matters somewhat. I'm now 99% sure /dev/ttyS1 is never created.
mknod /dev/ttyS1 c 4 65 (if /dev is read-only use any writable directory mounted without the option nodev) If the node is created without errors you can check if your patch is working reading/writing to the node or with any terminal emulator. The problem is that the node isn't created? If you're using some auto-magic dynamic dev fs like devfs or udev probably there's some registration problem in the middle (but I think not as most of the code is the same to bring up the ttyS0 and I guess adding a serial port is like adding a configuration row in an array in some platform file). If you aren't using dev fs like that probably you have a MAKEDEV file somewhere in your build tree where to manually add a line for your new device to be created statically. I've seen also a system where the dev nodes were created by an init script.
ttyS1/uart1 initialised but not accessible through /dev/ttyS1
1,470,727,670,000
Reading from /proc/PID/stat a lot of information can be processed. I would like to see how many percentages has been used of CPU power by this process. There are a lot of variable around here (utime, stime, cutime, cstime, gtime, cgtime) but they are in jiffies. The problem with this that jiffy depends on speed of the current CPU. However IPS (Instructions Per Second) depends on inctructions set, and which program do we run but maybe this is more accurete. I would like to use this information in embedded systems where I could pick a CPU that just satisfies the features. In this way I don't have to spend a lot for a largly oversized system. Here is the contents of the stat file (as of 2.6.30-rc7): Field Content pid process id tcomm filename of the executable state state (R is running, S is sleeping, D is sleeping in an uninterruptible wait, Z is zombie, T is traced or stopped) ppid process id of the parent process pgrp pgrp of the process sid session id tty_nr tty the process uses tty_pgrp pgrp of the tty flags task flags min_flt number of minor faults cmin_flt number of minor faults with child's maj_flt number of major faults cmaj_flt number of major faults with child's utime user mode jiffies stime kernel mode jiffies cutime user mode jiffies with child's cstime kernel mode jiffies with child's priority priority level nice nice level num_threads number of threads it_real_value (obsolete, always 0) start_time time the process started after system boot vsize virtual memory size rss resident set memory size rsslim current limit in bytes on the rss start_code address above which program text can run end_code address below which program text can run start_stack address of the start of the stack esp current value of ESP eip current value of EIP pending bitmap of pending signals blocked bitmap of blocked signals sigign bitmap of ignored signals sigcatch bitmap of catched signals wchan address where process went to sleep 0 (place holder) 0 (place holder) exit_signal signal to send to parent thread on exit task_cpu which CPU the task is scheduled on rt_priority realtime priority policy scheduling policy (man sched_setscheduler) blkio_ticks time spent waiting for block IO gtime guest time of the task in jiffies cgtime guest time of the task children in jiffies
The jiffy does not depend on the CPU speed directly. It is a time period that is used to count different time intervals in the kernel. The length of the jiffy is selected at kernel compile time. More about this: man 7 time One of fundamental uses of jiffies is a process scheduling. One jiffy is a period of time the scheduler will allow a process to run without an attempt to reschedule and swap the process out to let another process to run. For slow processors it is fine to have 100 jiffies per second. But kernels for modern processors usually configured for much more jiffies per second.
What is the connection between jiffies and IPS? How to convert jiffies to IPS?
1,470,727,670,000
I would be interested in finding ways to reduce the boot time, specially in embedded-related environments. I've read somewhere of a method to avoid the kernel to load some drivers or modules but I'm completely lost and all the information I find on internet is quite complex and dense. Could anyone please suggest the general steps needed to achieve this? Maybe I'm wrong and this is nothing to do with the kernel.
The arch linux documentation Improving performance/Boot process may help you to learn how to improve the boot performance. Use systemd-analyze blame to check the timing for the enabled services, or systemd-analyze critical-chain to check the critical points then disable the unwanted services through systemctl disable service_name. or removing the un-necessary programs through apt.
Reduce Boot time
1,470,727,670,000
In the future I may be building a system with an embedded operating system. Given the commercial properties of this system, it will make sense to have all of the internals as closed source as possible. I have seen in the past many router manufacturers being forced to release source code due to them using a system under an open license. Is there a variation of Linux/Unix that does not have this requirement (e.g. no GNU or similar licensing)? From my limited understanding of Red Hat, don't they have a "commercial only" distro these days? I'd assume based on this that the source is not available then?
A Linux distribution consists of many pieces. All the pieces that are based on software licensed under the GNU GPL and other copyleft licenses must have the code source released. For example, if you ship something built on a Linux kernel, you must provide the Linux kernel source as well as any patch that you have made to the kernel source (however, for the Linux kernel, Linus Torvalds interprets the GPL as not requiring to provide source code for code that is only loaded as a module). You can ship the source code on a CD, or offer that people download it from your website, or any other reasonable method. You do not have to provide source code for non-GPL programs that are included in the same system. Most distributions (Red Hat, SuSE, Ubuntu, even Debian¹) provide some non-free software in binary form only. There are other Unix variants that not only do not require open licensing of any core component, but even forbid it. Of course, the flip side is that you'll have to pay to license them. They tend to be operating in the big server realm, not in the embedded realm: Solaris, AIX, HP-UX, SCO... Apple's iOS runs on what is sometimes termed high-end embedded system (MP3 players, mobile phones), but they are exclusively Apple's hardware, you won't be able to license the OS. There are also unix variants licensed under a BSD license. A BSD license allows you to do pretty much what you want with them, with only a provision that you acknowledge that there is some BSD-licensed software inside (the details of the acknowledgement requirement depend on the version of the license). There are several unix distributions where the whole core system is provided under a BSD license: FreeBSD, OpenBSD, NetBSD are the main ones. Note that some components have different licenses; in particular, the C compiler is GCC, which is under the GNU GPL (you would probably not be shipping the compiler however). For an embedded system, MINIX is more likely to be appropriate. It is published under a BSD license and designed for both teaching and embedded systems. A major advantage of Linux is that it has drivers for just about any system you can find. This is not the case with other unices. Even for MINIX, you're likely to have to write a bunch of drivers. In a commercial embedded system, the value is not in the operating system itself. The value is in integrating all the hardware and software component and making a usable and reliable product out of these disparate pieces. To insist on a free-software-free embedded system, in many cases, is not just reinventing the wheel but reinventing every single part of the vehicle. Concentrate on the part where you're adding value, and reuse what's tried and tested for the rest. Providing source code for GPLv2 components has negligible cost (the situation is a bit more complex for GPLv3, but we're getting widely off-topic). ¹ There is some dispute as to whether the non-free software that the Debian project provides for installation on Debian system are part of the Debian distribution or software that happens to be distributed by the Debian project and packaged for installation on Debian systems. It quacks like a duck, it walks like a duck, and I don't want to get dragged into the dispute as to whether it is a duck.
Is there a variation of Linux or Unix that does not require open licensing?
1,470,727,670,000
I recently dug out some prototyping equipment from the trash and I want out figure out what the heck it is. It has a port labelled 'Ethernet' and when I plug it into a router the lights flash like its trying to pull an ip but it does not. My router is running DD-Wrt and I have a netbook with Knoppix I can use on the router. How could I go about sniffing the communication and figure out what IP the device wants and how to communicate with it?
Perhaps the easiest way is to use your netbook - just because you don't have to filter out unrelated traffic later. You can use tcpdump to dump all traffic on your ethernet device. After starting up tcpdump you connect your equipment. After nothing flashes any more you disconnect it and you can look at the dump with wireshark. The dump should contain ARP/dhcp etc. related traffic that originates from the trashed equipment. For example as root: # ifconfig (to checkout which ethernet device to capture) # tcpdump -ieth0 -w my.dump -s0 Ctrl+C or Ctrl+\ after some time As normal user under X11: $ wireshark my.dump
Ethernet Sniffing Embeded Device
1,470,727,670,000
I would like to have a service which behaves differently on first run and on restart of service. Is this possible with systemd? (I use systemd in my embedded os). I tried with ExecReload and ExecStart, but ExecReload is run only when I use command "systemctl restart". On the other hand ExecStart is run after service Restart ( I have Restart=on-failure and RestartSec=5).
You could use systemctl set-environment to push some values into future runs of the service. For example, with a unit: [Unit] Description=testing [Service] Type=oneshot ExecStart=/my/command myarg1 ${MYDONE} ExecStart=/usr/bin/systemctl set-environment MYDONE=1 [Install] On the first systemctl start <unit> the last arg passed to /my/command will be '' and MYDONE will not be in the environment. On later starts, the last arg will be 1 and MYDONE=1 will be in the environment.
Systemd - how service can determine first run from restart run?
1,470,727,670,000
I have an embedded system built using buildroot. I have had a number of network issues, one of which is that my machine cannot see its gateway despite it being on the same subnet. I have tried using wireshark to analyse what is going on without success so as a last resort, I am considering trying to turn off support for IPv6 as I do not need it (my device doesn't need DNS or anything similar, simply needs to be able to communicate with other local machines on its subnet). I have read that I can turn off IPv6 by editing /etc/modprobe.conf but this file does not exist on my setup. Is there anything else I can do to disable IPv6 or is the only option to build the kernel from scratch without IPv6 support?
I agree with Ulrich, that this doesn't sound like an IPv6 problem. However, here's how to disable IPv6. In /etc/sysctl.conf set the following options: net.ipv6.conf.all.autoconf = 0 net.ipv6.conf.all.accept_ra = 0 net.ipv6.conf.all.disable_ipv6 = 1 If you don't have /etc/sysctl.conf just create it and add those lines, then reboot. Alternatively, each of these has an interface in /proc that you can flip (and/or create a script to do this at boot time). echo 0 > /proc/sys/net/ipv6/conf/all/autoconf echo 0 > /proc/sys/net/ipv6/conf/all/accept_ra echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
How can I disable IPv6 in custom built embedded setup
1,470,727,670,000
I have compiled an embedded Linux with Buildroot for i386. I didn't edited much, just defaults. Now I want to run it under qemu. But the only thing I see is this: I'm running qemu with these options: qemu-system-i386 -kernel vmlinux -hda rootfs.ext2 -m 256 Why this is happening? I have compiled like the example in the buildroot documentation.
Commands that just work To make absolutely sure that it will work, we can make Buildroot build QEMU for us, and use the exact QEMU CLI provided by Buildroot at: https://github.com/buildroot/buildroot/blob/2019.05/board/qemu/x86_64/readme.txt git clone https://github.com/buildroot/buildroot cd buildroot git checkout 2019.05 make qemu_x86_64_defconfig printf ' BR2_CCACHE=y BR2_PACKAGE_HOST_QEMU=y BR2_PACKAGE_HOST_QEMU_LINUX_USER_MODE=n BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE=y BR2_PACKAGE_HOST_QEMU_VDE2=y ' >> .config make olddefconfig time make BR2_JLEVEL="$(nproc)" HOST_QEMU_OPTS='--enable-sdl --with-sdlabi=2.0' ./output/host/bin/qemu-system-x86_64 \ -M pc \ -kernel output/images/bzImage \ -drive file=output/images/rootfs.ext2,if=virtio,format=raw \ -append "rootwait root=/dev/vda" \ -net nic,model=virtio \ -net user \ ; You are now left on a shell and you can login with username root (no password). Note however that the default Buildroot build does not have an interesting GUI like X11 by default, as that is not the most common use case for this project. I have covered that at: How to install X11 on my own Linux Buildroot system? But because Buildroot does not focus enough on the run part to my needs (more automation, more boot types, GDB step debug), I extended it with some extra scripts on this project: https://github.com/cirosantilli/linux-kernel-module-cheat Other ISAs mentioned at: https://cirosantilli.com/linux-kernel-module-cheat/#buildroot-hello-world Buildroot 2019.08 QEMU build failed because QEMU 3.1.1 release has a broken x86_64 build... QEMU 3.1.1 failed to build Tested in Ubuntu 19.04.
How to use qemu to run Buildroot Linux images?
1,485,283,266,000
I was asking myself if a certain dtb that works with linux kernel version 3.18 is compatible with a linux kernel version 4.9. I suppose not, because kernel code concerning the device tree likely changes over the time, but it somehow has to be compatible otherwise multiple dts/dtsi files have to change all the time. I used google to investigate this, but even in the official documentation I couldn't find a word about compatibility throughout different kernel versions.
The Device Tree is supposed to be a stable ABI so a device tree written for any version of the kernel should work with any following kernel version. However, for practical reasons, this is quite often not the case. You can have a look at the following presentation from Thomas, explaining why: http://free-electrons.com/pub/conferences/2015/elc/petazzoni-dt-as-stable-abi-fairy-tale/petazzoni-dt-as-stable-abi-fairy-tale.pdf Video: https://www.youtube.com/watch?v=rPRqIS9q6CY
Is a device tree blob tied to a specific linux kernel version?
1,485,283,266,000
I'm trying my hand at creating a very minimal custom Busybox/Linux distro, a task that is admittedly above my head, but I figured I'd give it a shot. My issue is that whenever I try to run a C program that is not Busybox or a Busybox utility, ash complains and tells me that the file is not found. I mounted the partition from my Arch system, installed GNU binutils and uClibc; no dice. I also wrote the simplest C program I could think of with no dependencies on any libraries: int main(int argc, char *argv[]) { return 0; } I compiled, ran on Arch, still gave me "file not found" on my Busybox system, although it is shown when I run ls. To address the obvious, yes, I ran it from the same directory as the program and typed ./ before the file name.
My guess is that you don't have the correct dynamic linker on the Busybox system. On your Arch system do this: ldd ./simplestprogram I imagine ldd will give you output similar to this: linux-vdso.so.1 => (0x00007fff9b34f000) libc.so.6 => /lib64/libc.so.6 (0x0000003b19e00000 /lib64/ld-linux-x86-64.so.2 (0x0000003b19a00000) That last line, /lib64/ld-linux-x86-64.so.2 is the dynamic linker. I bet that isn't present on your Busybox system. I compiled a "hello, world" program on my Arch laptop, used vim in binary mode to change /lib64/ld-linux-x86-64.so.2 to /lib65/ld-linux-x86-64.so.2, saved it, and tried to execute it. I got the same "file not found" message you got. You may not even have the libc.so file on your Busybox system. It's possible that just copying the libc.so and dynamic linker files from Arch to Busybox systems (preserving directories!) might work, but it might not. I'm just not sure. One thing to try: install musl on your Arch machine. Compile your simple program with musl-gcc -static -o simple simple.c, move that executable, which has no dynamically-linked anything, and try it on the Busybox system.
Minimal Busybox/Linux Installation - Won't Run C
1,485,283,266,000
I have been using the following command on my system to create the .cpio archive to create an initramfs for my embedded target device sudo find . | cpio -H newc -oc > ~/initramfs.cpio This has always worked for me without any problem. Yesterday I was generating a new archive and I received the following error: cpio: Archive format multiply defined: Operation not permitted cpio: ./etc/shadow: Function open failed: Permission denied cpio: ./usr/lib/ssh-keysign: Function open failed: Permission denied 64842 blocks I never received these errors in the past, the files mentions with failed opens have not been touched either so I cannot understand why this has started happening. I update my host system with Ubuntu package manager so it is possible that my cpio package has been updated too. I obviously have no faith in the initramfs generated here due to all of the errors which confuse me greatly. The only option I can think of is to try and find out if my cpio version has changed and if so remove and replace with the older version I had. Is there any way I can find out this information on my system (Ubuntu 12.04)? Or is there some other way I can get around this problem?
The first error is because you're passing both -H newc and -c. You have to make up your mind on the format of the archive you want to generate. The "Operation not permitted" is a bug in GNU cpio, it's passing wrong arguments to the function that outputs that error message and should exit there. The other errors are because you're not running that command as the superuser or more likely , you're not running it from the correct location. Only the superuser can read files like /etc/shadow as it contains sensitive information. You should also make sure that the archive you generate can only be read by the superuser. If it's an initramfs you're creating, chances are /etc/shadow has not business being there, unless that initramfs contains a full operating system.
What is the meaning of the errors from my cpio command?
1,485,283,266,000
I want to test the touch panels on embedded devices like iPhone, iPad and Kindle against following criteria: Do a gesture, like tap, swipe, pinch ( zoom in/out) 10000 times and validate that every time the gesture was indeed detected and was detected as a tap, swipe, pinch ( zoom in/out). Do a tap on the touch panel (screen) 10000 times and make sure that the coordinate of the touched location as reported by the software stack is indeed where you did the tap. Also I would like to get more ideas on what other touch testing can I do?
Jason Huggins gave a fantastic talk at PyCon 2012 that described, in great detail, a robot that could play "Angry Birds" on the phone: Worth watching the talk, it was very entertaining. Most importantly, the plans for the hardware and software of the core toolkit, BitBeam, are online in a github repo. I'm sure it would give you a great start.
How to test the touch screen on embedded devices like iPhone / iPad / Kindle? [closed]
1,485,283,266,000
I am currently developing inside an embedded Linux environment (kernel 3.10.0), and while goofing around in the procfs mount of the system I found that all processes present the following file in their /proc/[pid] folder: -rw-r--r-- 1 root root 0 Feb 22 09:10 make-it-fail Just for testing, I launched from the shell sleep 360 & and tried to read/write with cat and echo the make-if-fail file. These are the results: # stat /proc/[sleep_pid]/make-it-fail File: /proc/[sleep_pid]/make-it-fail Size: 0 Blocks: 0 IO Block: 1024 regular empty file [...] # cat /proc/[sleep_pid]/make-it-fail 0 # echo "1" > /proc/[sleep_pid]/make-it-fail # cat /proc/[sleep_pid]/make-it-fail 1 # stat /proc/[sleep_pid]/make-it-fail File: /proc/[sleep_pid]/make-it-fail Size: 0 Blocks: 0 IO Block: 1024 regular empty file [...] Odd things: Although stat claims that the file has size 0, I could read and write something there, and retrieve what I wrote. The process is alive and kicking, "surviving" the reads and writes of this file. I actually expected it to ... well, fail or exit. I understand that procfs is a pseudo-filesystem (therefore stat results might be not "real"/misleading) and that it interfaces with kernel structures, but I feel I am missing something here right now. So, what is the purpose and usage of this file? I cannot recall seeing it in other distros (e.g. it is not in the Ubuntu that I use for development)
I was investigating a little your questions, as I was becoming suspicious from reading this Injecting faults into the kernel that make-it-fail was a flag. Actually it is confirmed reading Injecting faults into the kernel: So there are a number of options which can be used to focus the faults on a particular part of the kernel. These include: task-filter: if this variable is set to a positive value, faults will only be injected when a specially-marked processes are running. To enable this marking, each process has a new flag (make-it-fail) in its /proc directory; setting that value to one will cause faults to be injected into that process. At the end of the day, make-it-fail is a boolean flag that marks whether a conditional injection operation to several processes will be done in the related PID. So just changing it's value to 1 as you have done will have no consequences. As for the variables/filenames themselves, the article also point outs the kernel has to be compiled with fault injection capability turned on; hence you not seeing them in other Linux machines normally. As for proc having the file system inconsistencies, proc is a virtual file system mapping file names to internal linux structures/variables; and it is natural a file having as size 0 bytes. From the TLDP Linux Filesystem Hierarchy: /proc The most distinctive thing about files in this directory is the fact that all of them have a file size of 0, with the exception of kcore, mtrr and self.
Meaning and usage of /proc/[pid]/make-if-fail
1,485,283,266,000
I have an interface for RS-232 communication. I need this interface for simple communication (no parity bit or flow control → TX, RX and ground) but now I have quite 4 pins unused (RTS, DTR, DCD/DSR, CTS) and wondered whether I could misuse these pins for some other signalling and for this I would need a way for reading out these pins. So how can I do that on my embedded Linux-based system? seterial reports that the interface is in 16550A UART mode and according to https://en.wikipedia.org/wiki/16550_UART: "Handshake lines for control of an external modem, controllable by software." Anything else you need to know?
RTS and DTR are output pins - which you can set. DCD and CTS are input pins and can only be read. The device is probably set for hardware handshaking by default. You can change this using tcsetattr (see CRTSCTS). Then you can use the TIOCMBIS ioctl to set RTS and DTR Good references are: Linux Serial HOWTO Linux Serial Programming HOWTO The above might be Linux centric. To be more POSIX then see Serial Programming Guide for POSIX Operating Systems I have lifted this example from the guide: #include <unistd.h> #include <termios.h> int fd; int status; ioctl(fd, TIOCMGET, &status); status &= ~TIOCM_DTR; ioctl(fd, TIOCMSET, status); On Stack Overflow you can find some opinions on how to set up the port properly.
How to readout unused serial pins (RTS, CTS, etc.)?
1,485,283,266,000
I work on embedded Linux devices that usually have hard wired Ethernet as well as cell modem connections. If I were to use MPTCP would it be possible to easily configure the system to use eth0 all the time if it's available, then fall back to ppp0 if eth0 is down? Also would such a handoff be transparent to the network application using the socket?
The plain protocol is specifically designed to do what you request. With MPTCP you can establish a connection to your peer tell the peer your available endpoints (like IP address of ppp0 and eth0) from this point all negotiated paths can be used, but you also can define one link as active and the others as fallback If one of your paths fails, MPTCP will enable you to transparently fail-over to another known path (your peer needs to be aware of this path, of course). If your prior failed path becomes available again, you can switch back. If you addresses change in between, you can tell your peer it happened, as long as one usable path stays available (since you'll need a channel to communicate the change). But you'll have to keep in mind that this only works if not only your client but also your remote peer needs to support MPTCP all intermediate routers/gateways on your path need to keep their hands off your MPTCP TCP-options (at least many plastic routers like "customer-class" ADSL routers etc. are known to strip TCP options they don't understand). In a perfect world, we'd all be using SCTP, *sigh*.
How configurable is MPTCP?
1,485,283,266,000
I need to run an NTP client on a very limited embedded device. ntpd is available but I do not see anything like rc.conf, or ntp.conf, or xntp.conf? Can someone advise on how to setup NTP? I ran ntpd, but the date and time haven't updated.
It looks like you have the Busybox version of ntpd. Here's a useful HOWTO: http://wiki.openwrt.org/doc/howto/ntp.client For example: ntpd -q -p ptbtime1.ptb.de
Setup ntp client with embedded device
1,485,283,266,000
I'm building an embedded system based on debian 7, and I'd like to make the most out of busybox that comes with debian. The problem is default busybox build in debian seems quite minimal, for example it does not even include passwd. On the other hand I don't want to build busybox from busybox.net sources for stability and update issues. So how can I build and install a bigger busybox from debian source package?
If you need a .deb customized on the fly mkdir /tmp/bb cd /tmp/bb apt-get source busybox sudo apt-get build-dep busybox cd busybox-1.20.0/ fakeroot debian/rules build make -C debian/build/deb/ menuconfig # enable passwd fakeroot debian/rules binary but probably the best would be to add a custom package inside debian/control and the relative config under debian/config/pkg/ (I'm not using Debian 7 but guess it is similar) edit You can use fakeroot debian/rules debian/build/deb/.built and fakeroot debian/rules binary-arch_busybox to build the deb target only
How to custom build debian's busybox?
1,485,283,266,000
I have a small embedded linux kernel and file system created via buildroot that is installed onto a compact flash drive running on an x86 board. I am using an initramfs (due to power loss concerns) but mounting a small number of directories on ext3 partitions on the CF drive for data that has to be persistent. However, recently I have been reading about swap partitions and their uses and as my current setup does not employ a swap partition at all. I am wondering if this is safe? I do not anticipate that the applications running on the device will be using a great deal of memory but is it better to create a swap partition regardless? I am very conscious of the limited writes that can be made to CF devices so if it is not vital then I would prefer not to use a swap partition. What would be the worst case scenario if I go ahead without a swap partition?
No, this is not a bad idea. Many devices that you may find around are running linux without swap partition. For example, there are many DLink router models with linux inside. The only possible issue is that it may run out of memory. However, with embedded solutions this should not happen if the system is properly designed (no memory leaks, e.t.c.) and user is not allowed to start any extra programs on his own.
Is it a bad idea to not have a swap partition on an embedded linux setup?
1,485,283,266,000
I am working on Freescale T2080 RDB. I got CentOS for PPC64 architecture from this link. I made a bootable SD card with the CentOS minimal ISO using the following command: dd bs=4M if=CentOS-7-AltArch-ppc64-Minimal-1611.iso of=/dev/sdc When I try to boot the freescale board using this SD card I get following message and error: ==> bootd Device: FSL_SDHC Manufacturer ID: 74 OEM: 4a60 Name: USDU1 Tran Speed: 50000000 Rd Block Len: 512 SD version 3.0 High Capacity: Yes Capacity: 15.1 GiB Bus Width: 4-bit Erase Group Size: 512 Bytes ** Invalid partition 2 ** Unknown command '/boot/uImage' - try 'help' ** Invalid partition 2 ** WARNING: adjusting available memory to 30000000 Wrong Image Format for bootm command ERROR: can't get kernel image! Where am I going wrong? The freescale board seems to be looking for uImage file in /boot directory but the CentOS structure in the SD card is different. Is CentOS PPC64 supported by Freescale T2080 RDB? EDIT: I also tried creating the bootable SD card using Rufus software but I am facing the same problem.
Following is the reply I got from CentOS mailing list: The CentOS 7 ppc64 and ppc64le variants are supposed to be installed on IBM Power (or compatible boxes, like Tyan or others, from the OpenPower consortium) Nothing would work "by default" from a CentOS side, but something could probably be done if you build a RootFS composed with the ppc64/ppc64le tree.
Is CentOS PPC64 supported by Freescale T2080 RDB?
1,485,283,266,000
I have a Debian embedded Linux system that uses an SD card as the RFS. What is a reliable way to determine how many bytes / hr are being written to the SD card?
A couple of ways: If you can get SMART data from an SD cart with smartctl, it may have a bytes written counter (no idea if this is possible). This will be the most accurate, as it will count all partitions and also not be lost over reboot. It may also be able to count any write-amplification caused by erase block size and/or wear-leveling. Depending on the filesystem you're using, there may be a write counter. For example, ext4 tracks lifetime writes, which you can see with dumpe2fs -h. The kernel keeps I/O counters. There are several programs to see them (they're in /sys and /proc, so you don't actually need special programs). For example iostat /dev/sda will show you how many kB have been written since boot, and the kB/sec also since boot. iostat can also show you current values (e.g., iostat /dev/sda 10 will show you values for every 10 seconds). The basic approach to turn a counter into a per-time measure is to take one reading and record it, then take another some time later, subtract, and divide. Example: At 0600 hours, 10 KB have been written. At 1000 hours, 50 KB have been written. 50kB - 10kB = 40kB; 40kB ÷ 4 hours = 10 kB/hour.
How to determine how many bytes / hr are being written to my SD card
1,485,283,266,000
I have some embedded Linux ARM chip with LCD display on frame-buffer. I connect to chip with serial console. I can access frame-buffer directly with low-level commands. However I need to draw some figures or even sprites. I am searching something. Can for example SDL run on frame-buffer without X, or there is similar graphical libraries? High performance video like speed is not needed, because probably animation will not be used, but GUI should be at least usable. Ncurses was useful for text interface, but I need some graphical interface.
DirectFB might be what you are looking for. If you needed higher level API, SDL should be able to use it as its backend.
What is the easiest way to draw graphics on Linux framebuffer?
1,485,283,266,000
I'm working on an embedded Linux (4.1.15) bash script wherein the bitrate of a CANbus may be one of several possibilities. When my module comes online it comes up at the first bitrate in the list, checks for traffic, and, if no traffic, cycles through each bitrate in like manner until traffic is detected. My initial approach was to do something like timeout -t 1 output=$(candump can0). If output is empty, then bitrate is incorrect. However, the timeout function doesn't seem to force a return from the command. My second approach was to try to do something with ip -details -statistics link show can0. While this does produce some meaningful information in a single, discrete command, it's not very useful without being able to reset the statistics. The command uname -rms yields this version info about the system: Linux 4.1.15 armv7l If anyone knows how to get either of these approaches to work, that'd be great, or if you know another way, I'm all ears. Bottom line is, I need to find a way to do this using bash script.
(My timeout command doesn't use -t, but there seem to be different versions). By putting the timeout part inside the $(), it should be able to signal the canbus command, and at least the assignment to output should always create the variable. output=$(timeout -t 1 candump can0)
Bash: Determining if CANbus Bitrate is Configured Properly
1,485,283,266,000
Working on a embedded Linux device built using yocto that is pulling a date via uart from another device with a satellite connection. By the time we have access to this date, we are well into a fully initialized multi-threaded application as well as various daemons running etc. From what I have read, using stime() or settimeofday() can result in breaking anything relying on timers. I'm guessing that something like std::this_thread::sleep_for() would be included in this? Is there a safe way to set the system time at this point or how do most embedded Linux devices that do not have internet access navigate this problem? Edit: We do have an RTC but the implementation of hwclock we are using does not allow us to directly write to it, at least through the hwclock api. Here is the --help: BusyBox v1.24.1 (2018-11-14 12:40:41 PST) multi-call binary. Usage: hwclock [-r|--show] [-s|--hctosys] [-w|--systohc] [-t|--systz] [-l|--localtime] [-u|--utc] [-f|--rtc FILE] And the link to the hwclock source.
My solution was to write directly to the rtc using ioctrl. Here's an implementation for anyone who comes across this: #include <linux/rtc.h> #include <stdio.h> #include <fcntl.h> #include <sys/ioctl.h> int main(void) { int fd; fd = open("/dev/rtc0",0); if (fd < 0) printf("Can't open rtc!"); struct rtc_time time; time.tm_sec = 12; time.tm_min = 12; time.tm_hour = 7; time.tm_mday = 12; time.tm_mon = 7; time.tm_year = 118; if (ioctl(fd, RTC_SET_TIME, &time) < 0 ) printf("Set rtc failed!"); return 0; }
Embedded Linux: setting the time without NTP
1,485,283,266,000
I have a small embedded system that I am working on that needs to be able to reduce its brightness for power saving reasons. The screen is connected by LVDS with separate Inverter Power Output connection providing the backlights power. The system is running Debian 3.2.68. I have tried several approaches to this such as xbacklight but the folder /sys/class/backlight is empty so it fails with No outputs have backlight property. Also when I search for any other folders containing "backlight" I go almost nothing back. $sudo find / -type d -iname \*backlight\* /lib/modules/3.2.0-4-686-pae/kernel/drivers/video/backlight /sys/class/backlight /usr/share/doc/xbacklight When I run xrandr with no parameters to detect displays I get the following. $xrandr xrandr: Failed to get size of gamma for output default Screen 0: minimum 1024 x 768, current 1024 x 768, maximum 1024 x768 default connected 1024x768+0+0 0mm x 0mm 1024x768 0.0* I have tried updating and rebuilding my kernel as well as trying different parameters for acpi_backlight= in my menu.lst file. Any ideas on what to try from here or other ways to reduce the brightness are greatly appreciated! Update 11/16: I have tried wiping the drive and starting over with a different distribution (Tiny Core Linux) with Xorg-7.7 in place of Xversa. The result is the same as with Debian where there is No outputs have backlight property for xbacklight. This leads me to think the issue is related to the board and its interaction with the monitor? The board is a Advantech MIO-5721 and the monitor is Mitsubishi Electric AA084XE01. They are connected by LVDS for the video and a Inverter Power Output for the backlights power. Update 11/19: Although my final solution needs to run on Linux (probably a small version of Debian), I have installed Windows 10 as it appears more compatible with the drivers on Advantech's website. It has NOT helped solve my problem but for that reason I have re-posted it on superuser. Update 11/23: I installed Windows 7 to test the drivers from Advantech again and I was able to adjust the brightness. Unfortunately the drivers appear to be Windows only. I am now in contact with Advantech regarding a Linux version of the drivers.
The issue was a missing driver. After being in contact with advantech they had drivers built for both 32 and 64 bit Ubuntu which were not on their website. The Ubuntu drivers (of the correct architecture) work on Debian enabling brightness control.
Trouble changing backlight brightness (/sys/class/backlight folder empty)
1,485,283,266,000
*tldr; I would like to generally understand how the world of linux / embedded linux works. What do I need to do to take the Linux mainline and compile/deploy it on a board with different processors and peripherals, from scratch. How I currently See It Working: Steps to get Linux running on arbitrary board: Get sources for uBoot (for embedded) or GRUB (desktop/x86 SOM) Modify uBoot or GRUB for specific system, write code to init specific chip and get required interfaces for memory and console up and running Modify uBoot/GRUB config.txt to configure code written above compile these and deploy to board, verify that bootloader console comes up and can interact with it Get kernel mainline sources "make config" to select drivers and modules that will be available (At this point these selections will change the source - wherever these settings are stored will no longer match a git clone from the mainline) (Track this .config file in source control for future reference) Get tools such as Busybox or desktop alternative? Install in source directories Get ucLibc or other libraries and install in source directories Compile kernel source using cross compiler toolchain for specific chip Create device tree files .dtb for board (both embedded/desktop? or desktop does not use?) This connects drivers to physical pins Use Uboot/GRUB and TFTP/serial console or memory card etc to load compiled kernel image. Boot up and verify shell access through serial/SSH etc depending on drivers and device tree config Modify uEnv.txt (embedded) or mysteryfile.txt (desktop) for board specific configurations? This is essentially a script that blocks or adds kernel startup steps? What is the desktop equivalent? apt-get desired packages and drivers write drivers and application code and test (manually loading drivers) Add device tree files to account for hardware and drivers implemented above (these are separate from the intial BSP one created) To include these in kernel image build the kernel and create the file structure with all of these sources and config file mods in the folder strcuture (additions/mods to Linux mainline) Could have a separate folder for Linux mainline and mods, copy mods directly overwritting/adding files to mainline in a third staging folder. This will allow all additions and non-mainline mods to be source controlled separate. If you can get a base system that you can SSH into, and at this point you have drivers for all the common components (Video, USB, mouse etc) then you can pretty much do anything at this point (install X11 server, LXDE, networking etc)? Which drivers need to be handled by the bootloader/bios and which ones are purely in the kernel domain? There are Kconfig files for configuring the kernel build. This makes sense and the kernel module development docs that I have seen seem to describe this well. There are also files like uEnv.txt and config.txt that handle the run time configuration and which devices should be loaded. There are also device tree blobs which also determine which devices should be loaded? How do the magic strings in these files tie into the kernel, are these modifications done to the mainline for a specific board? Something has to read these to determine if HDMI should be enabled or not, and this can't be the exact same code as what is on the desktop version of Linux. Once drivers are in the mainline are they still developed independently from the mainline? For example I have been using a couple of drivers but there are notes they are now included in the mainline, does this mean that it is no longer possible to download directly on its own? The steps I have followed downloaded the headers for my board, the source and then compiled it and installed it. If it is in the mainline do I need to pull it from there now instead? Background and Specific Thoughts I am an EE and have experience with Microcontrollers and Windows development, but do not have much Linux experience. The framing of my question is "If I started off with this arbitrary (with linux compiler available) processor, and these peripherals how do I (and what are my options) for building a linux release" Bootloader: I have been able to find RPI2 and BBB (Beaglebone Black) specific documentation and how-to's but when you get into more advanced topics like the bootloader there are only a few crumbs to vaguely describe what is going on. For example the RPI2 has a 3 stage bootloader (of which from reading it does not sound like it is totally uBoot based) and the BBB has a more "traditional" uBoot based bootloader. Now the new BBx15 has jumpers where you can select where you want to boot from. The desktop systems use GRUB (IIRC) and embedded systems typically use uBoot. I have read that the RPI uses the GPU during boot and reads the first stage bootloader off of a separate ROM. And that is all the information available. If you wanted to spin your own version of the board (for discussions sake, this is not really practical) then in addition to uBoot what is going on? Doesn't uBoot for the BBx15 have extra modifications to allow for the jumper boot selection? Does Linux know anything about the staging of booting or is it oblivious to this once it is running? The BBB uses uBoot to load the image off the eMMC into RAM, the RPI2 uses the 3 stage bootloader. I am guessing that the BBB uses the ARM processor to do this but the RPI2 uses the GPU. I thought on power up that the ARM processor starts executing, what would they have to modify to stage these load procedure? Does the GPU hold the ARM in reset until it has completed its ROM code? Since the GPU is part of the boot procedure does that mean the code it executes is taken out of the uBoot code, that other systems without this GPU would have to then run in the uBoot code? This whole procedure implies to me that if you modify the second or third stage bootloader that you could run Linux entirely off the GPU alone (if the kernel was compiled with the GPU toolchain)? Is the third stage bootloader and config.txt actually just uBoot? Regarding the headers for the board in use. Are these just the headers from the mainline with the drivers that have been overlayed included or is there something more to this. The "headers" are just the mainline headers if that is what you have started running with? For embedded microcontroller development I am used to having a HAL layer. The HAL has function stubs where you setup the peripherals and then point the drivers to those resources. The board support package typically have these HAL stubs already coded for the board in question. I am sure there has to be some parallels here to Linux development but I can't quite see where these divisions are. There are packages such as Buildroot and Yocto. Are these just the Linux mainline with an interface to automate selecting the ARM processor and drivers to include?
From my small experience with router hardware I played with, I can say that this is a dumb small hardware picked up just to do one thing. At hardware level, it's simple: U-Boot there is not only bootloader, but a BIOS in PC terms. So it's not only a bootloader, but also it initializes all hardware. At start, CPU executes it directly (from FLASH for example), and it decides what to do next, but usually it relocates itself into memory. Then it does what it needs to: reads configuration from flash piece then loads image at specified address and transfers control there. Nothing special, but it's important to know. U-Boot (embedded on router hardware) does not access root filesystem at all. Instead, there is a dedicated space for whole kernel image (usually compressed). So, at least on routers - there is no /boot/vmlinuz file. RPI indeed uses it's own, proprietary boot sequence. They have closed source binaries which user puts on SD flash. The first stage init code is hardcoded into CPU or somewhere there on board. And they start ARM core after GPU, and whole code is done for GPU. More about that maybe you're already found, but if not: https://raspberrypi.stackexchange.com/questions/10489/how-does-raspberry-pi-boot So, because I did some fun with routers and had rebuilt them into my small servers completely from source code, I can list my own building sequence: Obtain and build u-boot for platform Build Linux kernel Build userspace (kernel and userspace usually divided, even on flash) Flash that u-boot into flash on programmer Solder flash on to board Connect to board via UART Boot it, verify u-boot inits all hardware well tftp kernel, write to flash inside board tftp rootfs, write to flash inside board reset, verify all works ok fine-tune rootfs: set permissions, preload default config via tftp dump whole image, flash it on many devices Linux kernel then can, or cannot, support your board. Please verify that. You will not able to just take the latest kernel and build it, for example, for your router. The same with RPi: they have their own kernel tree. That happens often in embedded world, only few (and usually generic) platforms are supported by Linux kernel directly. Be prepared for that. As for userspace, you can select whatever you need, balance your needs between what you need and how many space is left. Usually in embedded, you either compress anything, or strip unneeded things, or both. I hope this will shed some light on. If you have further questions - welcome to comments! :-)
Linux/Embedded Linux - Understanding the Kernel and additional BSP specific components [closed]
1,485,283,266,000
I'm using a DTS file for a Duovero Parlor board. To this board I've added some SPI devices. My first (a display) works perfectly so I have that entry correct at least. I want to add an entry to support the SPI connected NXP SC16IS752 UART controller. (There's been a patches on lkml recently I want to try). This is my entry: clocks { clk14m: oscillator { #clock-cells = <0>; compatible = "fixed-clock"; clock-frequency = <14745600>; }; }; &mcspi4 { sc16is752: sc16is752@0 { compatible = "nxp,sc16is752"; reg = <0>; spi-max-frequency = <4000000>; clocks = <&clk14m>; interrupt-parent = <&gpio4>; interrupt = <15 IRQ_TYPE_EDGE_FALLING>; gpio-controller; #gpio-cells = <2>; }; }; It looks vaguely right. The SPI bus is 4MHz, mode 0. Interrupt is GPIO 111 which is <&GPIO 4 15>. My problem is specifying the clock. It's a standalone crystal oscillator connected directly to the chip. So is that clocks but right? Because the clock is standalone I've no idea where to place it so "clocks" sound right but I'm totally guessing. When I compile the dts it fails with a syntax error though so something is wrong somewhere. I'm not sure if the #gpio-cells is correct either. Does that mean the gpio numbering will start at 200 and go up?
The issue with your clocks, is that clocks declared outside the TI clock domains are not parsed and set up correctly in 3.17. This issue is resolved in kernel version 4.0.5. The required changes occurred in the function omap_clk_init at the end of /arch/arm/mach-omap2/io.c, there is an extra call there to of_clk_init(NULL) which doesn't exist in 3.17. Some relevant discussion here, http://patchwork.ozlabs.org/patch/375753/
Clocks entry in SPI device tree entry
1,485,283,266,000
I am running SuSE-based embedded system with a touchscreen. The embedded application is a graphics application which uses OpenGL over X Window for graphics. We have a user-space touchscreen driver that reads the touch events and calls our callbacks. These callbacks simply forward the x,y events to the application. We are refactoring the design and thinking to read touch input events through X11. Can anyone tell me how to enable touchscreen for X11? How do I know if my touchscreen is supported by X11? If not, how to do it?
First and foremost, your touchscreen needs a kernel device driver. It may be compiled into the kernel or as a module. The loaded driver will generally create an event in /dev/input/. This event is used by X. You can test touch input event with evtest: evtest /dev/input/event# Additionally, the device should be listed by xinput: xinput xinput can also be used to list and set device properties: xinput --list-props 8 xinput --set-int-prop 8 "Device Enabled" 8 0 Such settings can also be persisted in xorg.conf. For more information, see http://linux.die.net/man/1/xinput. Depending on the nature of the device driver, it may be necessary to register device info such as a device ID with the driver to activate the device.
How to setup touch screen for X11