HABA-KNX-EXPLORER Software

From CALAO Systems Wiki
Jump to: navigation, search

How to use buildroot

How to build the binaries for the HABA-KNX-EXPLORER from buildroot

  • Download the 2013.05 buildroot release available here
  • Untar and uncompress the buildroot-2013.05.tar.bz2 package on your host (tar -xvjf buildroot-2013.05.tar.bz2)
  • Issue cd buildroot-2013.05
  • Download the calao patch available here
  • Apply the patch
  • Issue chmod +x board/calao/haba-knx-explorer/pre-build.sh to give execute permission to the pre-build script
  • Issue make calao_haba_knx_explorer_defconfig
  • Issue make 2>&1 | tee build.log to build the binaries for the HABA-KNX-EXPLORER
Note: By default the haba-knx-explorer is pre-installed with u-boot. 
In this case you should flash the uImage file at 0xa0000 in the nandflash memory.

In order to install the rootfs you can copy the rootfs.jffs2 file and the u-boot script to a USB memory key.

After plugging in the USB memory key to the HABA-KNX-EXPLORER, you can issue the commands below:

  • HABA-KNX-EXPLORER > usb reset
  • HABA-KNX-EXPLORER > fatload usb 0 0x21000000 haba-knx-explorer.img
  • HABA-KNX-EXPLORER > source 0x21000000

How to modify the barebox default config from buildroot

You can modify the default barebox settings by issuing the following command:
  • make barebox-menuconfig
From the menu you can add/remove features and then rebuild barebox by issuing the following command:
  • make
If you want to save your config file your can save by issuing the following command:
  • make savedefconfig

How to modify the linux kernel default config from buildroot

You can modify the default linux kernel settings by issuing the following command:
  • make linux-menuconfig
From the menu you can add/remove features and then re-build the linux kernel by issuing the following command:
  • make
If you want to save your config file your can save by issuing the following command:
  • make savedefconfig

How to install SAM-BA from buildroot

How to add your software application in buildroot

  • More info available at here

How to flash the HABA-KNX-EXPLORER with the SAM-BA utility

  • Download the custom calao sam-ba utility available here
  • Untar and uncompress the sam-ba package on your host.
  • Setup your hardware
  1. Plug a usb cable in the Type-B USB connector located on the front panel.
  2. Connect the other side to your host machine
  3. Supply the HABA-KNX-EXPLORER as shown below:

600px

NOTE: You have to erase the nand flash memory if you want to reflash your HABA-KNX-EXPLORER with SAM-BA. First you need to connect a usb cable on the type-B usb connector located on the front panel of your HABA-KNX-EXPLORER and your host.Then you need to open a terminal on your host (115200,n,8,1) by using the serial port corresponding to the usb device connection (/dev/ttyACM0).Eventually you have to erase the first block of the nand flash memory by issuing the following command: erase /dev/nand.at91bootstrap from the barebox command line.
  • Issue sam-ba from the command line to start SAM-BA.
Note: Depending on your linux distro you should have to issue the following command in order to create a symlink to
/dev/ttyACM0: ln -s /dev/ttyACM0 /dev/ttyUSB0 
  • From the window below choose the haba_knx_explorer board and click on the Connect button.
  • Once sam-ba is loaded you should see the following window
  • Click on the Script File menu and click on Execute
  • Choose the haba-knx-explorer.tcl script in the calao directory.
  • When the haba-knx-explorer.tcl starts, SAM-BA will ask you to browse your home directory in order to find the at91 bootstrap loader binary.
  • Browse your home directory in order to load the nandflash_haba_knx_explorer.bin file.
Note: By default the haba-knx-explorer.tcl script will load the binaries from ~/buildroot/output/images/ 
- Nand Flash Mapping Table
NAND Offset Size Reserved for
0x00000 128KB at91bootstrap loader (nandflash_haba_knx_explorer.bin)
0x20000 256KB bootloader (barebox.bin)
0xA0000 128KB Device tree blob
0xC0000 4MB Linux kernel image (default:zImage)
0x4C0000 120MB UBI rootfs (default:rootfs.ubifs)
  • After a while your board is re-flash
Note: You can edit the haba-knx-explorer.tcl script from the Script File menu in order to modify your default binaries directory.

How to use barebox

Introduction

Barebox (formerly known as u-boot-v2) is a bootloader that inherits the best of U-Boot and the Linux kernel: The size and look-and-feel of u-boot, with driver model and lots of design concepts from the kernel.

Start with barebox

Once your HABA-KNX-EXPLORER is re-flashed, you can plug in an ethernet cable on the RJ-45 connector and reset your board as shown below:

Then start a terminal program on your host (minicom for instance), setup your serial link with the following parameters: 115200,n,8,1.

In your terminal window you should see something similar to the information displayed below:

If you don't stop the auto countdown, you can notice barebox tries to boot from the network.

  • Issue a ctrl-c from your terminal to stop the network boot stage as it is not probably well configured.

How to install a UBI rootfs from barebox

Prepare the Flash before UBI rootfs install

The /dev/nand0.root partition can be attached to ubi using

  • ubiattach /dev/nand0.rootfs
NOTE: Before attaching the rootfs partition to ubi please erase it with erase /dev/nand0.rootfs

Create a volume on the UBI device

  • ubimkvol /dev/ubi0 root 0

Load a file from a tftp server

Setup a tftp server on your host and copy the UBI rootfs from ~/buildroot/output/images/ to your tftp directory.

Setup your network from barebox:

If you have a dhcp server available on your network you can see the network parameters by issuing the following command:

  • devinfo eth0

If you want to modify for example the serverip you have to issue the following command:

  • eth0.serverip=192.168.1.10

As your network setup is ok, you can load a file from barebox with the command below:

  • tftp zImage zImage

Issue ls and you should see your file in the / directory

Flash the UBI rootfs from barebox

The UBI volume can then be flashed with the command below:

  • tftp rootfs.ubifs /dev/ubi0.root

Save your network settings

From the barebox command line you can save your network settings by editing the config file in /env directory:

  • edit env/config
 env/config                <ctrl-d>: Save and quit <ctrl-c>: quit 
#!/bin/sh

# use 'dhcp' to do dhcp in barebox and in kernel
# use 'none' if you want to skip kernel ip autoconfiguration
ip=dhcp-barebox
dhcp_vendor_id=barebox-haba-knx-explorer

# or set your networking parameters here
#eth0.ipaddr=a.b.c.d
#eth0.netmask=a.b.c.d
#eth0.gateway=a.b.c.d
#eth0.serverip=a.b.c.d

# can be either 'nfs', 'tftp', 'nor' or 'nand'
kernel_loc=nand
# can be either 'net', 'nor', 'nand' or 'initrd'
rootfs_loc=nand
# can be either 'nfs', 'tftp', 'nor', 'nand' or empty
oftree_loc=none

Uncomment and setup your network parameters as below:

# or set your networking parameters here
eth0.ipaddr=192.168.1.100
eth0.netmask=255.255.255.0
eth0.gateway=192.168.1.10
eth0.serverip=192.168.1.10

Save your config file by issuing Ctrl-d

Now to save your config issue the following command :

  • saveenv

Modify the default boot sequence

By default barebox tries to boot from the network.Once you have flashed your kernel and your root filesystem in the Nand Flash memory you can boot from the NAND Flash.

Below the steps required to modify the default boot sequence (Boot from Nand Flash).

  • Stop the autoboot from your terminal

  • Edit the config file by issuing the following command edit env/config
 env/config                <ctrl-d>: Save and quit <ctrl-c>: quit 
#!/bin/sh
# use 'dhcp' to do dhcp in barebox and in kernel
# use 'none' if you want to skip kernel ip autoconfiguration
# ip=dhcp-barebox
dhcp_vendor_id=barebox-haba-knx-explorer

# or set your networking parameters here
#eth0.ipaddr=a.b.c.d
#eth0.netmask=a.b.c.d
#eth0.gateway=a.b.c.d
#eth0.serverip=a.b.c.d

# can be either 'nfs', 'tftp', 'nor' or 'nand'
kernel_loc=nfs
# can be either 'net', 'nor', 'nand' or 'initrd'
rootfs_loc=net
# can be either 'nfs', 'tftp', 'nor', 'nand' or empty
oftree_loc=none

# can be either 'jffs2' or 'ubifs'
rootfs_type=ubifs
  • replace ip by none & modify the kernel_loc, rootfs_loc by nand as shown below:
# use 'dhcp' to do dhcp in barebox and in kernel
# use 'none' if you want to skip kernel ip autoconfiguration
# ip=dhcp-barebox
ip=none
dhcp_vendor_id=barebox-haba-knx-explorer

# or set your networking parameters here
#eth0.ipaddr=a.b.c.d
#eth0.netmask=a.b.c.d
#eth0.gateway=a.b.c.d
#eth0.serverip=a.b.c.d

# can be either 'nfs', 'tftp', 'nor' or 'nand'
kernel_loc=nand
# can be either 'net', 'nor', 'nand' or 'initrd'
rootfs_loc=nand
# can be either 'nfs', 'tftp', 'nor', 'nand' or empty
oftree_loc=nand

# can be either 'jffs2' or 'ubifs'
rootfs_type=ubifs
rootfsimage=root.$rootfs_type

kernelimage=zImage
#kernelimage=uImage
#kernelimage=Image
#kernelimage=Image.lzo

Save your config file by issuing Ctrl-d

 Note:If you built a linux kernel with DT, you should specify where your DT blob is located with oftree_loc

Now to save your config issue the following command :

  • saveenv

Issue reset in order to check your default boot sequence

  • reset

How to use the dfu

DFU for Device Firmware upgrade can be used to download and upload barebox, linux kernel and the rootfs to the HABA-KNX-EXPLORER connected over USB.

Let's assume that you want to upgrade your kernel image from barebox.

  • Plug a usb cable on the Type B USB receptacle located on the front panel of your HABA-KNX-EXPLORER controller
  • Plug the other side in your host machine
  • Supply your HABA-KNX-EXPLORER controller

  • During the boot, press the user push button of the HABA-KNX-EXPLORER in order to start the DFU automatically.
Note: If you don't want to remove the case, you can also start the dfu from the barebox command line by issuing the command below:
dfu ${dfu_config} -P ${product_id} -V ${vendor_id}
  • Now from your host you can start dfu-util
Note: dfu-util can be installed on your host from buildroot.
dfu-util can be downloaded: here.
  • From your host open a terminal window and issue the following command:
  • $sudo dfu-util -l (if you have installed dfu-util from buildroot issue cd ~/buildroot/output/host/usr/bin/ and then sudo ./dfu-util -l)
  • You should see the upgradable partition list
barebox@Calao HABA-KNX-EXPLORER:/                                                                                                                
# dfu ${dfu_config} -P ${product_id} -V ${vendor_id}                                                                                     
dfu: register alt0(barebox) with device /dev/nand0.barebox.bb                                                                            
dfu: register alt1(kernel) with device /dev/nand0.kernel.bb                                                                              
dfu: register alt2(rootfs) with device /dev/nand0.rootfs.bb

Let's assume that you want to reflash your linux kernel

  • Issue the following command:

$sudo ./dfu-util -d 4321:1234 -a kernel -R -D ~/buildroot/output/images/zImage

$ sudo ./dfu-util -d 4321:1234 -a kernel -R -D ~/buildroot/output/images/zImage 
dfu-util 0.6

Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2012 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY

Filter on vendor = 0x4321 product = 0x1234
Opening DFU capable USB device... ID 4321:1234
Run-time device DFU version 0100
Claiming USB DFU Runtime Interface...
Determining device status: state = appIDLE, status = 0
Device really in Runtime Mode, send DFU detach request...
Resetting USB...
Opening DFU USB Device...
Found Runtime: [4321:1234] devnum=0, cfg=1, intf=0, alt=1, name="kernel"
Claiming USB DFU Interface...
Setting Alternate Setting #1 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 0100
Device returned transfer size 4096
No valid DFU suffix signature
Warning: File has no DFU suffix
bytes_per_hash=42475
Copying data from PC to DFU device
Starting download: [##################################################] finished!
state(2) = dfuIDLE, status(0) = No error condition is present
Done!
Resetting USB to switch back to runtime mode

Let's assume that you want to reflash your rootfs

  • Issue the following command:

$sudo ./dfu-util -d 4321:1234 -a rootfs -R -D ~/buildroot/output/images/rootfs.ubi

sudo ./dfu-util -d 4321:1234 -a rootfs -R -D ~/buildroot/output/images/rootfs.ubi
dfu-util 0.6

Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2012 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY

Filter on vendor = 0x4321 product = 0x1234
Opening DFU capable USB device... ID 4321:1234
Run-time device DFU version 0100
Claiming USB DFU Runtime Interface...
Determining device status: state = appIDLE, status = 0
Device really in Runtime Mode, send DFU detach request...
Resetting USB...
Opening DFU USB Device...
Found Runtime: [4321:1234] devnum=0, cfg=1, intf=0, alt=2, name="rootfs"
Claiming USB DFU Interface...
Setting Alternate Setting #2 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 0100
Device returned transfer size 4096
No valid DFU suffix signature
Warning: File has no DFU suffix
bytes_per_hash=62914
Copying data from PC to DFU device
Starting download: [##################################################] finished!
state(2) = dfuIDLE, status(0) = No error condition is present
Done!
Resetting USB to switch back to runtime mode
 Note: The rootfs.ubi is an image of the UBI rootfs and can be built from buildroot 

How to boot from nfs

When you are setting up your rootfs for your target, it can be interesting to use nfs.

Indeed when your ethernet is functional on your target you can easily mount a rootfs available on your host.

First setup an nfs server on your host. You will find a lot of interesting information about how to install an nfs server on your preferred linux distro documentation.

Below the Howto for Ubuntu:

  • How to setup an NFS server here.

From your freshly reflashed HABA-KNX-EXPLORER you should see the following trace:

# Clocks: CPU 399 MHz, master 133 MHz, main 12.000 MHz                            
atmel_nand: Use On Flash BBT                                                    
NAND device: Manufacturer ID: 0x2c, Chip ID: 0xaa (Micron NAND 256MiB 1,8V 8-bi)
Bad block table found at page 131008, version 0x01                              
Bad block table found at page 130944, version 0x01                              
nand_read_bbt: Bad block at 0x053a0000                                          
nand_read_bbt: Bad block at 0x053c0000                                          
nand_read_bbt: Bad block at 0x09840000                                          
nand_read_bbt: Bad block at 0x09860000                                          
nand_read_bbt: Bad block at 0x0a1e0000                                          
nand_read_bbt: Bad block at 0x0a200000                                          
nand_read_bbt: Bad block at 0x0b7a0000                                          
nand_read_bbt: Bad block at 0x0b7c0000                                          
nand_read_bbt: Bad block at 0x0c280000                                          
nand_read_bbt: Bad block at 0x0c2a0000                                          
nand_read_bbt: Bad block at 0x0d0c0000                                          
nand_read_bbt: Bad block at 0x0d0e0000                                          
at91_udc@at91_udc0: at91_udc version 3 May 2006                                 
Malloc space: 0x23b00000 -> 0x23efffff (size  4 MB)                             
Stack space : 0x23af8000 -> 0x23b00000 (size 32 kB)                             
envfs: wrong magic on /dev/env0                                                 
no valid environment found on /dev/env0. Using default environment              
running /env/bin/init...                                                        
No USB Device cable plugged, normal boot                                        
                                                                                
Hit any key to stop autoboot:  1                                                
barebox@Calao HABA-KNX-EXPLORER:/                                                   
# 

Edit the env/config file by issuing the command below:

  • edit env/config

Replace ip=dhcp by ip= and if you don't have a dhcp server available on your network, you can setup the following variables:

  • eth0.ipaddr
  • eth0.serverip
  • eth0.netmask
  • eth0.gateway
  • eth0.ethaddr
#!/bin/sh

# use 'dhcp' to do dhcp in barebox and in kernel
# use 'none' if you want to skip kernel ip autoconfiguration
#ip=dhcp-barebox
#dhcp_vendor_id=barebox-haba-explorer
ip=
nfsroot=/home/user/nfs

# or set your networking parameters here
eth0.ipaddr=192.168.1.100
#eth0.netmask=255.255.255.0
#eth0.gateway=192.168.1.10
eth0.serverip=192.168.1.10

# can be either 'nfs', 'tftp', 'nor' or 'nand'
kernel_loc=tftp
# can be either 'net', 'nor', 'nand' or 'initrd'
rootfs_loc=net
# can be either 'nfs', 'tftp', 'nor', 'nand' or empty
oftree_loc=none

# can be either 'jffs2' or 'ubifs'
rootfs_type=ubifs
rootfsimage=root.$rootfs_type

kernelimage=zImage
#kernelimage=uImage
#kernelimage=Image
#kernelimage=Image.lzo

nand_device=atmel_nand
nand_parts="128k(at91bootstrap),256k(barebox)ro,128k(bareboxenv),128k(bareboxenv2),128k(oftree),4M(kernel),120M(rootfs),-(data)"
rootfs_mtdblock_nand=6

autoboot_timeout=3


bootargs="console=ttyS0,115200"

# set a fancy prompt (if support is compiled in)
PS1="\e[1;32mbarebox@\e[1;31m\h:\w\e[0m\n# "
# 

As you can notice above in the config file, the kernel image will be downloaded from the tftp server installed on your host. If you have flashed a kernel in the nand flash memory you can replace kernel_loc=tftp by kernel_loc=nand to check if everything is ok.

You can now save your file with ctrl-d and saveenv and reset your board.

Note: You will have to setup your nfsroot variable in function of your nfs settings

You will find a lot of interesting information about how to install a tftp server on your preferred linux distro documentation.

Below the Howto for Ubuntu:

  • How to setup a tftp server here.

How to download a file from the serial port

If you want to download a file through the serial port you can issue the following command on your target:

  • loadb -f filename -c

From your host you can use for instance C-Kermit and issue the command below in order to send a file to your QIL-A9260:

~$ kermit
?SET SPEED has no effect without prior SET LINE
C-Kermit 8.0.211, 10 Apr 2004, for Linux
 Copyright (C) 1985, 2004,
  Trustees of Columbia University in the City of New York.
Type ? or HELP for help.
Linux Kermit> send filename
Note: You should configure kermit by editing the kermrc file located in /etc/kermit/

How to take control of the haba-knx-explorer

The user can access the haba-knx-explorer from a host by issuing the following command:

  • $ssh root@haba_ipaddress
Note: By default no password is required

How to install knxweb2

The user can easily install knxweb2 by executing the knxweb2-install.sh script available in the root/ directory.

  • First download the knxweb2 package from here and copy this package to the haba-knx rootfs.
or

Then execute the script from the haba-knx

  • # ./knxweb-install.sh

Then from a host computer you can start a web browser in order to configure your knx installation.

  • Just fill in the haba-knx ip address assigned by your dhcp server to the address bar of your browser

  • and start the configuration