Mai 172015
 

Read here for an interesting thread over reboot.pro.

One issue is the BCD is that it is normally linked to one hard drive since it contains (hard coded) the disk id.
The boot manager will assume winload.exe sits on a specific disk/partition.
Meaning you cannot re use it on another system : you have to generate it for each drive using bcdedit command line.
In some cases like automating, cloning, preping, etc, it can be a stopper.

One alternative is to use the « boot » keyword.
You can then re use this bcd from one disk to the other with one constraint thus : you need to have one unique partition (whereas the windows setup will usually creates 2 partition : a hidden/boot one and a system one).
The boot manager will then assume winload.exe sits on the boot partition.
See below the code to create such a « boot » bcd.


@echo off
:_start

::_____________________________________________________________

setlocal
set LABEL=Windows
set BCDEDIT=bcdedit.exe
set BCDSTORE=%~dp0BCD

cls
Echo Creating store...
%BCDEDIT% /createstore %BCDSTORE%
echo.
echo.

Echo Creating bootmgr entry...
%BCDEDIT% /store %BCDSTORE% /create {bootmgr}
%BCDEDIT% /store %BCDSTORE% /set {bootmgr} description "Boot Manager"
%BCDEDIT% /store %BCDSTORE% /set {bootmgr} device boot
%BCDEDIT% /store %BCDSTORE% /set {bootmgr} timeout 20
echo.
echo.

Echo Adding Windows entry...
for /f "tokens=2 delims={}" %%g in ('%BCDEDIT% /store %BCDSTORE% /create /d %LABEL% /application osloader') do set guid={%%g}
echo guid=%guid%
%BCDEDIT% /store %BCDSTORE% /set %guid% device boot
%BCDEDIT% /store %BCDSTORE% /set %guid% path \Windows\system32\winload.exe
%BCDEDIT% /store %BCDSTORE% /set %guid% osdevice boot
%BCDEDIT% /store %BCDSTORE% /set %guid% systemroot \Windows
%BCDEDIT% /store %BCDSTORE% /displayorder %guid% /addlast
%BCDEDIT% /store %BCDSTORE% /default %guid%
echo.
echo.
endlocal
pause
:_end

One last alternative is to use the less documented « locate » keyword.
The boot manager will actually search for a specific file/folder and chain winload.exe from the partition containing that file/folder.
Get the batch to generate this BCD here.
It should give you a bcd looking like the below.


bcdedit /store c:\temp\bcd.dat
identificateur {bootmgr}
device locate=unknown
description Boot Manager
custom:23000003 {default}
custom:24000001 {default}
custom:25000004 20
identificateur {default}
device locate=\\Windows\\system32\\winload.exe
path \\Windows\\system32\\winload.exe
description Windows
custom:21000001 locate=\\Windows
custom:22000002 \\Windows

 Posted by at 19 h 09 min
Mar 222015
 

In a previous article, I had tried to move a XNA+Vb.Net game developped on Windows to Ubuntu.
I had limited success (I was only able to install monodevelop + monogame for C#).

This time I restarted from scratch :
-install ubuntu 14.04

-sudo apt-get install gnome-sharp2 mono-xsp4 (not sure about this line)
-sudo apt-get install libglade2.0-cil-dev (not sure about this line)
-sudo apt-get install monodoc-base
-sudo apt-get install monodevelop mono-vbnc

At this point, monodevelop (4.x) works and I can write vb.net programs.

-sudo apt-get install libmonogame-cil-dev monodevelop-monogame

At this point I can write c# monogame programs (a new template for monogame c# appears).

I then imported a vb.net monogame program and it works 🙂
I had to copy paste the monogame dll in the game folder thus.

monogame

 Posted by at 17 h 57 min
Mar 082015
 

In the previous article, I started to look for a way to build an infrared receiver based on an Arduino.
So far no luck…

So I decided to take another approach : plug my infrared TSOP component directly tot he Raspberry GPIO.
See the wiring below.

IRwiring2

Here below the steps required to settled a remote (any will do) with my receiver :

1-Add the following to config.txt dtoverlay=lirc-rpi

2-stop lirc daemon to be able to record codes in step 3 killall lircd

3-record your remote control codes with : irrecord /storage/.config/lircd.conf
tip here : your enter button should be key_ok and your back button should be key_exit in last openelec version (5.x)

4-check that your system detects your buttons press : irw
if yes, then you are good to go : Reboot and enjoy !

 Posted by at 13 h 57 min
Mar 032015
 

These days it is pretty easy to setup a Home Theater PC using a cheap computer (raspberry being my preferred choice).

Still, the remote control is many times the weak point.
It is easy to buy or refurbish an infrared remote transmitter, it is less easy/cheap to find an infrared receiver.
Thus, you can find some cheap telco+receiver like these :
amazon
ebay

I then thought it would be fun/interesting to use an arduino for this.

Quickly googling, I found 2 ways to achieve this :
-turn my arduino into a HID device (probably the cleanest way but more complex) thru the use of the v-usb firmware
-have the arduino send (over serial) the expected datas to LIRC (less complex but more prone to errors)

Lets do some mad googling and collect some interesting pointers

-setup LIRC and a FDTI232 adapter : here
-the arduino IRRemote lib as you will need to decode the incoming signals : here
-some arduino code which seems to turn the arduino into a lirc receiver : here
-another possible interesting thread : here
-a similar project with interesting links especially around irman protocol : here
-similar project using IRMAN protocol : here
-related, on attiny85 : here

-v-usb track : here

Mar 022015
 

A very simple GUI for the mkisofs command line utility (from cdrtools) to create a bootable iso.

-Choose your source folder
-Choose your bootsector
-Choose you target iso file

Supports EFI as well.

The zip file contains grub4dos (0.4.6) and isolinux (6.0.3) bootloaders with example menus.

Download/discuss it here

Fév 282015
 

This is the last article about my water impulse counter project.
3 previous articles can be found here .

The last issue I encountered was about electro magnetic disturbances (probably my gaz heater nearby).
I initially planned to detect FALLING impulses (high to low, low meaning the reed switch is closed).
But about 4 times per hour, i detected a falling impulse, and this even the water circuit closed !

I therefore decided to review my code in the interrupt function now based on a CHANGE event (no more FALLING).


void IntChange() {
if (digitalRead(SWITCHPIN)==LOW) {
start=millis();
change=false;
} else {
if (start>0) {
pulse=millis()-start;
start=0;
change=true;
} else {
start=0;
change=false;
}//if (start>0)
} //if (digitalRead(SWITCHPIN)==LOW) {
}

And this proves to work perfectly now 🙂
See graph below.

The whole code can be found here.
it includes a web server (for my domotic box to query), a sd card reader (to store the counter value between power off), an interrupt handler.

Fév 212015
 

In previous article, my water pulse was settled in my garage.

Lets now design a wiring schema based on Arduino.
The idea is to use interrupts on the Arduino : it will be HIGH (i.e near 5V) always except and it will be LOW when the reed switch will be closed.
We then want to detect either when it is LOW, or FALLING, or CHANGE.
For now I’ll go for FALLING as this one is the easiest to implement.

rising-edgefalling-edge

 

We would then use something like the below :


//in the setup
attachInterrupt(1, CallBack, FALLING);

void CallBack(){
//the below check will software debounce our switch
if (millis()-last_water>500) {
last_water=millis();
water=water+1;
}
}

Next article will be about the code (a web server, logging to SD card, monitoring impulses …).

Fév 172015
 

For some years now I have monitoring and logging my energy consumption with an OWL 160.
Datas are then collected in a domotic box (a raspberry + jeedom)

Next step is now to do the same with water.
I have tried several solutions but came to the following conclusions :
-my counter needs to be located inside my house (as operating outside is not practical)
-i need to use a reliable solution like impulse

Therefore I bought the below product based on a reed switch : it will trigger an impulse for each liter.

Jan 302015
 

In some specific situations, you may want to backup only one partition but still wish to boot it as a disk image.
Lets see below how to turn a partition image into a disk image.

Before we start, have a a look at the below disk layout to have a better understanding of items such as MBR, BS, Disk and Partition.

1.Create a 1 MBytes (2048*512=1MB) header file (under virtualdisk, create raw disk image)
Note : instead of 2048 sectors, you can go for 63 or 128 or whatever « sectors before » may suit you – just report that number in the following steps.

2.Append this header to your partition image using the dos command line copy /b header.img+part.img disk.img

3.Adapt MBR type=07 (for ntfs), boot=80, chs start & end=1023*254*63, sectors before=2048, sectors=bootsector.totalsec+1
(You need to untick « hide advanced menu » under tools menu to enable advanced screens in CloneDisk).

4.Inject boot code (nt6) (this will also fix the mbr magic byte AA55).

5.Adapt bootSector hiddensec=2048 so that it matches MBR sectors before field

You are now ready to boot this image as it has all it requires to boot :
-a disk boot record
-a partition table
-a boot sector
-a consistent BPB (bios parameter block)

 Posted by at 19 h 05 min