Projects/IntegratedRadarReceiver/IntegratedRadarReceiver/ucLinux

Receiver Software

An extensive software set is necessary to allow the remote control of the tuner via Ethernet or USB serial. This includes an NIOS2 targeted GCC tool chain, an appropriately configured uClinux distribution, a tuner control library with appropriate register mapping, a command line tuner control tool for testing, a tuner control service for status generation and state monitoring, a tuner remote control cgi program, and a python class for remote interface to the tuner from other applications.

Much of the needed information on linux and the tool chain is derived from the [WWW] nios2 community wiki and the [WWW] uClinux and gcc tool chain prepared by hippo as part of that project.

Toolchain

It is necessary to have a working GCC cross compiler and library set for the nios2 processor. A distribution of uClinux patched for the nios2 processor is also required. The version of software used for the receiver is uClinux-dist-20060803 along with the patch uClinux-dist-20060803-nios2-02.diff. The nios2 gcc tool chain configuration was as follows

Configured with: /root/buildroot/toolchain_build_nios2/gcc-3.4.6/configure --prefix=/opt/nios2 --build=i386-pc-linux-gnu --host=i386-pc-linux-gnu --target=nios2-linux-uclibc --enable-languages=c --enable-shared --disable-__cxa_atexit --enable-target-optspace --with-gnu-ld --disable-nls --enable-threads --disable-multilib --enable-cxx-flags=-static
Thread model: posix
gcc version 3.4.6

Newer versions of the software chain and tools may work but have not been tested at this time. Note we do not follow the Wiki instructions of upgrading to the latest Altera tool chain as we found too many incompatibilities and issues with the latest tools (Quartus/Nios 7.2). These issues may get shaken out in newer releases but we didn't have time to mess with fixing them ourselves.

nios2 gcc

The cross compiler tar files should be unarchived in an appropriate directory. They are designed to run on an appropriate intel linux platform (e.g. RHEL4 or 5). The path for the tool binaries must be set appropriately. For example with the tools located in cronus:/data/isis/firefly/nios2 :


cronus:/data/isis/firefly/uClinux-dist > export PATH=/data/isis/firefly/nios2/bin/:$PATH
cronus:/data/isis/firefly/uClinux-dist > nios2-linux-gcc --version
nios2-linux-gcc (GCC) 3.4.6
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

ucLinux for the nios2

The [WWW] uClinux distribution is used to provide support for the NIOS2 processor which doesn't provide an MMU. Download and untar the correct distribution. The distribution must be patched using the matching nios2 patch to function correctly :

  1. cd uClinux-dist

  2. zcat uClinux-dist-20060803-nios2-02.diff.gz | patch -p0

Now it is necessary to configure and build the distribution using the cross-compiler. Generic instructions can be found on the [WWW] nios2 wiki. First configure the build process to use the correct NIOS2 PTF file generated by the Quartus 2 software :

  1. make vendor_hwselect SYSPTF=../isis_nios0.ptf

  2. make menuconfig

  3. Vendor Product selection

                      --- Select the Vendor you wish to target  
                      (Altera) Vendor
                      --- Select the Product you wish to target
                      (nios2nommu) Altera Products 
  4. Kernel/Library/Defaults selection

                       (linux-2.6.x) Kernel Version
                       (None) Libc Version
                       [ ] Default all settings (lose changes)
                       [*] Customize Kernel Settings (NEW)
                       [*] Customize Vendor/User Settings
                       [ ] Update Default Vendor Settings
  5. Exit out and save the custom kernel settings. You will then enter the kernel customization.

  6. Now customize the kernel settings Make sure the following are set (in the appropriate menus)

    [*] System V IPC 
    [*] POSIX Message Queues 
    (../romfs ../vendors/Altera/nios2nommu/romfs_list) Initramfs source 
    [*] Optimize for size (Look out for broken compilers!)
    [*] Configure standard kernel features (for small systems)
    CPU (NIOS2)  --->
    Platform (Microtronix Cyclone board support)  --->
    Nios II Hardware Multiply Support (Enable mul instruction) 
    [*] Support of DMA controller with Avalon interface
    [*] Allow allocating large blocks (> 1MB) of memory
    [*] Preemptible Kernel
    [*] Kernel support for flat binaries 
    [*]   Enable ZFLAT support
    [*] Generic netlink family 
    [*] Packet socket
    [*] Unix domain sockets
    [*] TCP/IP networking
    [*] Network device support 
    [*] Universal TUN/TAP device driver support
    [*] PHY Device support and infrastructure 
    [*] Ethernet (10 or 100Mbit) 
    [*]   Generic Media Independent Interface device support
    [*] Davicom DM9000 10_100 Ethernet chip support
    [*] Nios serial support
    [*]   Support for console on Nios UART
    [*] Altera JTAG UART support 
    [ ]   Support for console on Altera JTAG UART
  7. Next user software must be selected and configured.

    [*] login
    [*] agetty
    [*] passwd
    [*] Build libSSL
    [*] boa
    [*] dhcpcd-new (2.0/2.4)
    [*] inetd
    [*] ntpdate
    [*] ssh
    [*] scp
    [*] telnetd
    [*]   telnetd does not use openpty()
    [*] generic cgi
    

    and Busybox should be configured

    [*] ifconfig
    [*] ifconfig: status reporting
    [*] ifconfig: enable hw option
    [*] BusyBox 
    [*] cp 
    [*] date
    [*] mount
    [*] mount: loop devices
    [*] netstat
    [*] ping
    [*] ping: fancy
    [*] rm
    [*] route
    [*] telnet
    [*] vi
    [*] Build BusyBox as a static binary (no shared libs)
    
  8. It can be necessary to modify the files in vendors/Altera/nios2nommu/ and/or the files in romfs to obtain the correct configurations.

  9. make

The first make step above may need to be repeated if it fails the first time. This should result in an initial kernel in images/zImage

Next add any user software into the romfs/bin directory and then do another make to get the image with it built in :

  1. make

The zImage can then be loaded into the hardware using the instructions in the Firmware section. Repeat the build process as software is changed or updated.

Login to uCLinux

On boot the tuner will ask for a login and password. In general only the root account is enabled and a password may or may not be set depending on the configuration. It is possible to create other accounts if necessary but this must be done in the configuration provided during the build of the Linux zImage.

Networking

The network can be setup to use a static IP address or dhcp on boot. This is done in the rc startup file located in the vendors/altera/nios2nommu' directory.

  1. For dhcp use

    ifconfig lo 127.0.0.1
    route add -net 127.0.0.0 netmask 255.0.0.0 lo
    ifconfig eth0 hw ether 00:07:ED:00:00:XX
    ifconfig eth0 up
    dhcpcd&
    inetd&
    boa&
    
  2. For static IP use

    ifconfig lo 127.0.0.1
    route add -net 127.0.0.0 netmask 255.0.0.0 lo
    ifconfig eth0 hw ether 00:07:ED:00:00:XX
    ifconfig eth0 xxx.xxx.xxx.xxx # substitute IP address here
    route add default gw xxx.xxx.xxx.xxx # subsitute gateway address here
    inetd&
    boa&
    

where XX is the hex tuner number so that all the ethernet MAC addresses are unique.

Serial USB notes

The USB serial converter is connected to the FPGA on UART1 of the NIOS2 processor and is recognized by ucLinux as /dev/ttyS1. A second serial port is provide via pins for use in the case the USB isn't functioning. The USB serial converter is recognized by Linux and Windows as a serial device. Linux maps the port as /dev/ttyUSB0 unless that is in use in which case it ends up as /dev/ttyUSBx where x is the first available integer. Windows has the nasty habit of confusing the serial device with the USB Blaster and so you can't use both the board USB serial and the USB Blaster at the same time. Serial connection is made at 57600 BPS with 8N1 and no hardware flow control. Typically a program such as minicom or hyperterminal can be used to connect via a USB cable. In order for this to work serial console support under linux must be enabled or software used which outputs information on the serial device.

Linux configuration notes

  1. We have not yet had time to get sshd working on the platform. It is in theory possible.

  2. We currently use telnet to access the tuner and if used on an open network it is important to firewall the tuner to the outside world. We recommend using only closed networks for the moment.

  3. Password control isn't currently setup but this shouldn't be too hard.

  4. Transfering data to and from the tuner can be done using scp. Wget currently crashes things for reasons which aren't understood. We have had wget work before so this is a mystery.

  5. The boot up configuration needs to have the rc file modified to target a particular network environment. The tuner control service is currently activated by default.

JTAG console versus stand alone operation

The JTAG console is used during debugging and is convenient for early firmware and software development. To have an independently operating device it is necessary to configure Linux to use the serial console which connects to USB via the FTD translator chip.

  1. For Serial console operation configure the kernel

    [*] Nios serial support
    [*]   Support for console on Nios UART
    [*] Altera JTAG UART support 
    [ ]   Support for console on Altera JTAG UART
  2. For JTAG console operation configure the kernel

    [*] Nios serial support
    [ ]   Support for console on Nios UART
    [*] Altera JTAG UART support 
    [*]   Support for console on Altera JTAG UART
  3. Serial console support also requires that agetty program must be built in the user software configuration.

  4. Serial console support requires the software configuration

    [*] init 
    [ ]   enable console shell 
  5. JTAG console support requires the software configuration

    [*] init 
    [*]   enable console shell 
  6. Serial console support requires that the inittab file in vendors/Altera/nios2nommu contain the line

    # activate serial port console
    ttyS1:vt100:/bin/agetty 57600 ttyS1

When using the JTAG UART it is necessary to connect using the JTAG terminal to boot the device.

last edited 2011-04-12 17:37:59 by FrankLind