Remove message “Waiting for network configuration…” on ubuntu

On ubuntu, if your system boots without network in failsafe mode, it will wait a long time for network to be available. In many case, this won’t help much…

Moreover, if you’re trying to do things like kernel compiling and for some reason you can’t see the boot log (including this “Waiting for network configuration” message), you’ll have the impression of being stuck with a bad kernel, but in fact it is just waiting 120 seconds…

Just edit the file sudo vi /etc/init/failsafe.conf and remove all “sleep” instructions. The message will be displayed but it won’t wait any time.

To repair you network problems, you might want to check this post and this post.

HDParm

HDParm is a tool to manage your drives. The first section show you how to get informations about your drives, the second tells you how to make them sleep when they aren’t used (and so make power economy). If you’ve got a home server like me with the system on a SSD, with only your big files on the hard drives(s), you’ll want to do this.

 

Get disk informations

You’ve got to use “sudo” to gain super user privilege. Your disk are in the /dev/ folder, named sd* where “*” is a letter. To see the list of disk, one can type use “ls /dev/sd[a-z]“:
debserver % ls /dev/sd[a-z]
/dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sde

 

To display informations about one disk, you can use “sudo hdparm -i”

 

debserver % sudo hdparm -i /dev/sda
/dev/sda:

Model=WDC WD20EFRX-68EUZN0, FwRev=80.00A80, SerialNo=WD-WCC4M1067803
Config={ HardSect NotMFM HdSw>15uSec SpinMotCtl Fixed DTR>5Mbs FmtGapReq }
RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=0
BuffType=unknown, BuffSize=unknown, MaxMultSect=16, MultSect=16
CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=3907029168
IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
PIO modes: pio0 pio3 pio4
DMA modes: mdma0 mdma1 mdma2
UDMA modes: udma0 udma1 udma2 udma3 udma4 udma5 *udma6
AdvancedPM=no WriteCache=enabled
Drive conforms to: Unspecified: ATA/ATAPI-1,2,3,4,5,6,7

* signifies the current active mode

 

Make a drive sleep after some time

From the manual (man hdparm on the command line):

-S Set the standby (spindown) timeout for the drive. This value is used by the drive to determine how long to wait (with no disk activity) before turning off the spindle motor to save power. Under such circumstances, the drive may take as long as 30 seconds to respond to a subsequent disk access, though most drives are much quicker. The encoding of the timeout value is somewhat peculiar. A value of zero means "timeouts are disabled": the device will not automatically enter standby mode. Values from 1 to 240 specify multiples of 5 seconds, yielding timeouts from 5 seconds to 20 minutes. Values from 241 to 251 specify from 1 to 11 units of 30 minutes, yielding timeouts from 30 minutes to 5.5 hours. A value of 252 signifies a timeout of 21 minutes. A value of 253 sets a vendor-defined timeout period between 8 and 12 hours, and the value 254 is reserved. 255 is interpreted as 21 minutes plus 15 seconds. Note that some older drives may have very different interpretations of these values.

 

So “sudo hdparm -I /dev/sdb | grep level” will show the current spindown value, for Example:

debserver % sudo hdparm -I /dev/sdb | grep level
Advanced power management level: 254

Example:

sudo hdparm -S 25 /dev/sdb = spindown after 25*5 seconds.

sudo hdparm -S 245 /dev/sdb = spindown after (245-240)*30 minutes.

 

If you want to check the state to see if it works :

sudo watch -n 1 "hdparm -C /dev/sdb && hdparm -C /dev/sdc && hdparm -C /dev/sdd && hdparm -C /dev/sde"

 

You can use /etc/hdparm.conf to make it permanent:
/dev/sdb {
spindown_time = 60
}

 

 

Huawei Honor 3 root + gapps + multilang

From chinese to international version (with root, multilang and gapps)

Just a little tuto about how I managed to re-flash the ROM of the Huawei Honor 3 bought in China with an international ROM from needrom.com. As you may know, all chinese smartphones may include an English version, but never the Google Play store, Gmail, … And of course, are not rooted.

(On windows)

  1. Put your phone in USB debugging mode (see below if you don’t know how)
  2. Go to http://www.needrom.com/mobile/huawei-honor-3/ (disable adblock if you have it)
  3. Download the first file, not the updates. The others are original, un-rooter version without gapps and so on.
  4. Run the .cmd file. (Without the chinese characters it’s called 3__HN3-U01_.cmd). It’s in chinese, but you just have to type “enter”.
  5. After 2 or 3 minutes it will reboot in recovery mode.
  6. Choose “Wipe data/factory reset”, and choose “yes – delete all data”. This step is very important. If you don’t do that, you’ll mix the two roms… Choose also “wipe cache”.
  7. Choose “reboot now”.

Change language

 

 

 

 

 

Go in settings. It’s the icon on the main screen with a gear :

20140211_155545

Click on the language menu. It’s the one with an icon of letter”A” :

20140211_155615

Click on the first item and choose your preferred language :

20140211_155648

 

 

 

 

 

 

Enable USB debugging

Like for the language, go in settings and choose “about phone” :

20140211_155706

 

Type 7 times on the “build number menu”. I know it’s weard but it’s the way to do it !

20140211_155718

Now, click on the new menu that appeared “developer options”

20140211_155732

And finally, check usb debugging :

20140211_155745

 

Troubleshooting

  • Error at startup : your phone can tell you twice that a process has stop. It won’t come a third time, so just ignore that. You screen may be black a little too, just lock your phone, unlock in message modes and it won’t happen again.
  • Get rid of the Huawei “home” : you cannot really remove it, but you can install “Apex launcher” or “Nova launcher” which arethe normal google home but slightly enhanced. After installing press the home button, choose the apex or nova launcher and type “always”. For them to work properly, you should install google search from the playstore too.
  • If nothing happen after running the .cmd file, maybe you have a driver problem. Install the software of your phone (HiSuite for the Huawei Honor 3.
  • I woudn’t advise doing system updates. If it’s working, don’t try… If you want to try other roms like the ones of needrom.com, remember always to do a full wipe ! If the installer don’t reboot you in recovery, whhen the system has rebooted, go in the windows command line (type “cmd” in the windows search prompt), go to the folder where your rom installer is and type “adb reboot recovery” to reboot in recovery. I tried a lot of rom on this website and this was the best at time of writing… The only one removing the chinese apps and dooing everything I said is this one. And the changelog between the 113 and 119 version doesn’t seem that important…

Ugly things : Autologin of console at startup

→ Ugly but okay in a development virtual machine…

Add “– – autologin root” at the end of /etc/init/tty1.conf

It will auto-log you as root for the first console. For the others, do the same with /etc/init/tty[1-5].conf

You can autolog as “student” by replacing root by student. It’s a little safer … but still ugly.

How to debug at boot time

If all you get is a black screen when booting, boot in recovery mode to see a little more information :

recovery

When you are in the grub menu, choose the “recovery” version

If there is none or if it’s still black type “e” in the grub menu over the kernel entry you want. Find the line starting by linux, and add “ro single recovery” at the end.
Type F10 to boot.

recovery2

Grub normally have a “Previous versions” menu to allow you to boot with the ubuntu default kernel…

 

In fact if you get a black screen when booting, chances is that you’re missing some modules. But you can get more:

  • Add a serial device to your virtualbox, select “file” mode, with e.g. /tmp/vbox-jerry
  • run tail -f /tmp/vbox-jerry on your machine to watch that log file,
  • before booting, press e to edit the config and add at the tail of the command line ” console=ttyS0,57600″
  • this will work only for boot time, when syslogd will start, the log will go to /var/log/syslog
  • You can use the /etc/default/grub file like for the screen size (see slides of info0940) to make it permanent

A network problem during boot may stall you for 120 seconds, with or without a black screen ! So wait a little !

Grignoux Cinema

This post is in French as it concerns only people from my area

Grignoux Cinema Grignoux Cinema


Je suis l’auteur de l’application “Grignoux Cinéma” qui permet de voir les horaires des cinémas grignoux à Liège (Churchill, Parc et Sauvenière) sur les terminaux Android. J’ai déposé le code sur Github, et rend donc open source cette application (licence GPL). N’hésitez pas à contribuer, je manque un peu de temps… J’aimerais rajouter certains fonctions comme la recherche par cinéma, une légende, etc…

Lien github

Lien Google Play Store

VM and Kernel compiling troubleshooting

Start’up Troubleshooting

 

  • Log in as “student” with the password mentioned in the auditorium and the slides.
  • If your virtual machine does not boot, you can check the boot log with a right-click on the virtual machine entry in VirtualBox.
    The kernel installed on ubuntu server *requires* PAE/NX extension to be enabled in your virtual box. This can be tuned in Settings>System>Processor for your virtual machine.
  • Ubuntu remembers which “network card” you have installed, so that interface IDs (i.e. eth0, eth1…) is consistent when you reboot. This may cause you to lose network connectivity when you copy your .vdi from one machine to another. If that happens (boot stalls on networking setup) reset the content of your /etc/udev/rules.d/*persistent-net.rules file.

Building Kernel Troubleshooting

  • The config file you’ve been given should provide all the options for a i386 build of the reference kernel sources. If you’re prompted with [Y/n/m] questions in “make oldconfig” step, you’re very likely to be trying to compile an amd64 kernel itself, which won’t work on the reference virtual machine. It is mandatory to compile the kernel in i386, see Shell, Linux and Kernel slides for more informations.
  • “CONFIG_DEBUG_SECTION_MISMATCH errors” essentially occurs when you’re including unsafe drivers in your kernel. Unless you’re experiencing this during “make bzImage”, you can safely ignore this.
  • quota exceeded while building may occur on ms8xx, with various error messages. use quota -v -s to check how much more space you can eat on the shared filesystem (/home). kdirstat $HOME can assist you in finding files that take too much room. You have 500Mo allowed, clearly not enough to build the kernel in your home directory. Beware, the compiler suite installed on ms8xx makes use of a “compiler cache”, in the (hidden) $HOME/.ccache directory. You’d more likely want to use some location in /tmp for that purpose. If that’s the case, create a personal sub-folder and export CCACHE_DIR=/tmp/OS$USER/ccache before you start compiling the kernel. Alternatively, you may prefer to restrict the size .ccache can grow. Check out the manpage for details.
  • permission denied during make install might occur. Part of the ‘install’ process is designed by your distribution maintainers for upgrading the distribution itself. This usually happens after vmlinuz and friends have been copied to $INSTALL_PATH, so most of the times, you do not need to bother.

Booting Kernel Troubleshooting

  • “init: failed to create pty…” errors on boot? may occur with your custom-built kernel. It’s annoying, but it’s not just you: it’s a bug not yet fixed in the distributed image. Retrieve the update definitions with sudo aptitude update and then selectively upgrade the buggy package (upstart): sudo aptitude upgrade upstart.
    the screen is completely black with your new kernel ? don’t panic (yet). Chances are that you’re missing some modules. The kernel has started, but cannot access some hardware (including fancy graphic modes). Try out the “recovery mode” for the corresponding kernel, then dig kern.log for an explanation. Use “insert CTRL+ALT+DEL” on your vbox’s “Machine” menu to return to the boot.
  • booting takes ages. Most likely, you’re stuck at network configuration. That may take several minutes when no network card is found (cf. Startup) or when modules for the network card cannot be located.

Read and write PIC EEPROM

More a little post-it than a post, I wanted to put somewhere the commands :

Using the eeprom is as simple as these two commands :

[code lang=”c”]EEPROM_READ(addr)
EEPROM_WRITE(addr,value)
[/code]

A little example (reading from the USART a value and putting it in the EEPROM address 0x00)

[code]
while (!DataRdyUSART());
char data = ReadUSART();
EEPROM_WRITE(0x00,data);
[/code]

Note that theses header are defined in the standard xc8 header which will include (or , …) or High Tech C headers if you come from the past :

[code lang=”c”]
// MACROS for EEPROM Access
/* macro versions of EEPROM read and write */

/* NOTE WELL:
EEPROM_READ() is NOT safe to use immediately after any
write to EEPROM, as it does NOT wait for WR to clear. This is by
design, to allow minimal code size if a sequence of reads is
desired. To guarantee uncorrupted writes insert
while(WR)continue;
before calling EEPROM_READ().
*/

#if _EEPROMSIZE > 0 && defined(_PLIB)
#define EEPROM_READ(addr) Read_b_eep(addr)
#define eeprom_read(addr) Read_b_eep(addr)
#else
#define EEPROM_READ(addr) 0 // Added only for code portability
#define eeprom_read(addr) 0
#endif

#if _EEPROMSIZE > 0 && defined(_PLIB)
#define EEPROM_WRITE(addr, value) (Busy_eep(), Write_b_eep(addr,value))
#define eeprom_write(addr, value) (Busy_eep(), Write_b_eep(addr,value))
#else
#define EEPROM_WRITE(addr, value) // Added only for code portability
#define eeprom_write(addr, value)
#endif
[/code]

Detecting if another user is connected on UNIX systems

How to detect if another user is connected to your machine or your server? You can use the command “users” to check yourself is someone is connected. But to do it automatically, you’ll have to use some pipe :

[code lang=”bash”]expr length “`users | sed -e “s/\($USER\|\[ \]*\)//ig”`”[/code]

The first thing executed by the shell will be the thing under french apostrophe ( ` ). Theses are for evaluation a command, and replace it by what it outputs (normally print on the screen). The command users print the list of connected users into a pipe, to sed which evaluate its command as a regular expression (-e parameter). The command is “s” for substitute, and the rest tells him to find “$USER” (replaced by the currently connected user, you) and spaces and replace them by … nothing. So this part will be an empty string if there is no other users connected than “$USER” and something not empty if there is.

The “expr length” return the length of a string. So this commands print 0 if there is no other user connected, and >0 if there is some !

In a shell script to do something if yes or no…
[code lang=”bash”]#!/bin/sh
usersstripped=`users | sed -e “s/\(tom\|\[ \]*\)//ig”`
connected=`expr length “$usersstripped”`
if [ “$connected” -eq “0” ] ; then
echo “No other user is connected”
else
echo “Other user connected !”
fi[/code]

It is essentially the same command but done in two times, as in a shell script this command would not be evaluated correctly.

And if you want to put that in a cron to eg. send you a mail, you just have to type “crontab -e” and put a line like :

[code]* * * * * /home/tom/connected[/code]

To launch it every minutes. But if you do that you’d better do something like detecting a connection…