Friday, November 26, 2010

Nov.26,27 Dev Env reinstall

My Laptop's network adaptors stopped working. The reason is not clear - virus/trojan or deleting the files for a Virtual Machine manually - but get to do an install of development environment on a clean system. So...


updated Nov.18+26 Tutorial Dev Environment Summary with new information learned like:
  • Installing gnuarm added cygwin location correctly to the windows registry
  • c:\local\bin; had to be added manually to the window path for the eclipse compile to work correctly
  • Testing arm-elf-insight caused the firewall to ask for certain features to be blocked/unblocked.
    • Not blocking solved a previous problem where the gdb GUI did not work.
  • Added links for serial download. Wondering how this .bat file and source should be packaged for the tutorial.
  • At one point from make all in eclipse got the error ld error message "uses hardware FP, whereas forte uses software FP". Still not sure what combination caused this error message.
  • Installed gnuarm 4.1, cygwin 1.7, java 1.6.0_22  in C:\local, because wrongly thought there was a problem, C:\Program Files, has a blank in the name. Some older notes said Forte does not work with blank in file name. Still good having the tools in one place, since hope to create a zip with tools needed.


Thursday, November 18, 2010

Nov.18+26 Tutorial Dev Environment Summary

Links for setting up tools needed: 
  • Java SE6
  • Build Environment 
    • cygwin
    • add cygwin/bin location to the path 
    • installing gnuarm set the window registry entry needed for cygwin 1.7 for use with eclipse
  • Eclipse with C-Development Tools (CDT)
  • FORTE
  • 4DIAC-IDE 
Other
  • loop-back device 
    • install check: Device Manager => Network Adaptors => MS Loopback Device
    • needed for virtual network on 1 PC with 4diac/forte
Cross-compiling and debugging for ARM
  • GNUARM includes arm-elf-insight for debugging
    • used: binutils-2.17, gcc-4.1.1-c-c++, newlib-1.14.0, insight-6.5, setup.exe
    • install check: 
      • 1. echo $PATH Your install directory for /gnuarm/bin should be in the path.
      • 2. in a cygwin command window enter arm-elf-insight. The GNU GDB RedHat Source Window should appear.
        • arm-elf-insight GUI will not work if blocked by firewall
    • Cross-compiling in eclipse
      • use arm-elf-g++
    • Debugging with GNU GDB arm-elf-insight forte 
      • open a cygwin command window
      • cd to the directory with the forte executable
        • ex: cd /cygdrive/h/lms/bin/src/forte
      • enter arm-elf-insight forte
      • GUI Source Window opens
        • Run > Connect to Target: (for Segger JLINK)
          • Target: Remote TCP
          • Hostname: localhost
          • Port: 3333
        • View > Console
          • monitor reset
          • monitor halt
        • View > set breakpoints
          • max of 2 breakpoints for lms
          • max of 1 breakpoint when stepping through code
Flashing the LMS
    eCos, Samba, usb Drivers are needed for the following:

Nov.17 OpenOCD install tries

1. The drivers sometimes revert back to the first driver installed:
see previous Nov. blog entries for driver details
  • Ports(COM&LPT) ecosUsbSerial to libwin32usb/ecos usb driver
    • need a COM port for forte deployment FB download
  • Universial Serial usb controllers/atmel driver reverts to Lego device/firmware update mode
    • need  atmel driver to flash via sam-ba
2. openocd on my laptop
The correct way to install will be documented in a separate blog entry.
Try1: Just copy directory and usb.dll needed to my laptop. Not enough.
Try2: Find out what first praktikat used.
Found link to install .msi file that is no longer actual, but google found: 
Search in this website for OpenOCD Windows installer lead to a current list of installers 

Question:
What is a FTDI type chip which needs libusb?
libftdi is a library that talks to FTDI's FT232/245BM, FT2232C/D, and FT232/245R type chips, including the popular bitbang mode
Answer: See OpenOCD user's guide... FTDI type chip is used in some JTAG doggles, but not in the Segger JLINK.
If understand right then libusb doesn't have to be installed.
However for the Raven it is needed.

So it is not possible to use the version the first praktikat used.
openocd  -v says Alex used 0.3.0-in-development version.
A website with a list of openocd Windows installers says 0.3.1 has important fixes
so...
Try3: install openocd 0.3.1 using an .msi installer found online
Installed with no problem from zip.
All files needed are in the zip.

Wednesday, November 17, 2010

Nov. 17 Line Follower Algorithms / Beginners

Each week I meet with 2 friends, so they can learn about Lego Robot one of them recently bought.
Today we accidently found a simple algorithm that looks for the line and then follows it.
The line follower allows lots of algorithms.  First two friends downloaded, tried and looked at existing NXT-G programs. In the end they could somewhat follow the program, but could not make even minor changes successfully to the program. 
Today we started with basics. Motors block; Loop testing light sensor or looping forever;  If-then-else branch block.

[Picture of algorithm goes here]
The idea was:
Step 1: Go when see white, stop when see black. 
Loop while see white
Then stop
Step 2: Loop forever
If-then-else branch for light sensor:
IF white
THEN: forwards
ELSE: turn x degrees

We found when it found the line when x was around 45 degrees, the robot would follow the edge of the  line if it was on the correct edge for the direction it should go in. Since blue was seen as black, it lost the line at the blue box.

The Video shows the attempts starting with 90 degrees, then 45 degrees, then 25 degrees.

[VIDEO(S) COMING]

Monday, November 15, 2010

Nov.15 OpenOCD Flashing on AA PC

TODO
Get a version with export 4.0 working with FBs!
SEGWAY


1a. OpenOCD  is part of the gnuarm toolchain. 
OpenOCD does not have offical releases, but some stable releases are available. It was easiest to copy the OpenOCD in the on Alex's PC to my laptop and add it to the path. Unfortantely its not clear where this working version came from orginally.

1b.Support for mulitple versions of forte.bin at once.
Created a flash_forte_bin directory to copy forte.bin and forte to for use with openocd bat files.
New bat file:  cp_Oflash.bat
Now
C:\openocd\trunk3\testing\examples\SAM7S256Test\prj\sam7s256_flash_Q.cfg file is also hard coded to this directory.

2. CBC/Scheme

- plug in keyboard and display
--  result: CBC booted the same.
    It didn't seem to be aware of the keyboard or display automatically.
- kernel # for ubuntu10.4 is at least 2.6.32.9
-- if kernel is new enough the CBC Linux driver is included
--- (11/17 note: interesting the driver link is same those doggles needing usblib)
- Can't use CBCJVM - Racket has its on Racket machine bytecode

Botball has another language forum. Only Java seems to be doing anything.

Friday, November 12, 2010

Nov.13 How to update driver

1. Right click on the device and choose Update Driver
2. Again choose Update Driver and OK
3. Choose Browse my computer for driver software


4. Enter the directory with the .inf and .sys driver files
5. If driver is installed chose the second option and a list of installed drivers for the device will show-up.  Then you are ready to test in SAM-BA.


Nov.13 Can flash with Sam-BA from laptop!

 Again an already installed driver interfered. 
This time the (normal) LMS driver from Lego company.
So there will be separate blog entry for how to update a driver.

To install the driver and flash the lms using SAM-BA:
1. Plug in the lms in boot mode
2. The driver files directory with the  .inf and .sys files is found under:
 Program Files\ATMEL Corporation\AT91-ISP v1.13\sam-ba 2.9\drv
After installation this driver should show up in the device manager:
3. Open SAM-BA .
The first time the board at91sam7e256-ek must be choosen.
Then hoose the forte.bin to send to the lms to flash its memory.
 Unlock - yes  then afterward lock -no

Nov.12 eCos USB device

Refer back to the  Oct.13 Lego, ecos, Samba and usb Drivers

Two problems solved!
1. Two characters were exchanged in a new parameter in LMS_RMT_DEV.c
This caused usb to not be set-up correctly.
Symptom was the lms was not recognized as an eCos device

2. To install eCosUsbSerial driver
refer back to the  Oct.13 Lego, ecos, Samba and usb Drivers 

Origin of eCosUsbSerial.inf is probably from eCos itself. Specifically:
        packages/io/usb/serial/slave/current/host/windows: 
                                                           eCosUsbSerial.inf 
See:

The copy given us is in the directory \libusbdriver, but LIBUSB (sourceForge) is not needed.

On my laptop having installed the LIBUSB sourgeForge project confused matters. The usblib driver had to be replaced.

Nov.11 JTAG,openocd, arm-elf-insight revisted

Details so can change to use with forte not in 1 place or copy to a common place.

JTAG - the picture shows the connections best. Note the black line goes toward the outside.
openocd - FLASH.bat is hard coded to a specific directory with forte and forte.bin
uses
C:\openocd\trunk3\testing\examples\SAM7S256Test\prj\SAM7S256_flash.cfg  is also hardcoded to a specific directory.
Note: multiple openocd's installed so notice trunk3 is the version used!


arm-elf-insight from cygwin 
openocd.bat  must be running before arm-elf-forte is started.


In a cygwin window:
1. cd to directory with forte and forte.bin
2.  enter arm-elf-insight forte

     The gnu debugger opens
3. Connect to the device (run-->connect to device) using ethernet / localhost / 3333
4. Open console (view-->console) and enter:
  •      monitor reset
  •      monitor halt 
    • stop  button if want to restart this process later]
5. Set breakpoints  (view-->breakpoints)
- at most 2 breakpoints are allowed
- at most 1 breakpoint if you want to examine variables
6. Continue to start debugging




Sunday, November 7, 2010

Nov.5 forte.bin to get an eCos device

When/how is forte.bin is built, so the flashed Lego brick is recognized as an eCos device;  Not which driver is loaded, but that the PC knows a new device has been plugged in.

This is important because the usb download will not work if the Lego is known to the PC.

The following documents what is known so far.
0. Looked at the command to create the forte.bin in the 2 working versions and in current hg
- no difference that I could see (it was late)

1. Known as eCos device = works
Windows XP recognizes the Lego Brick as an eCos Device

* Summer lms version
* Forte Version of Dominik's from Oct. BUT
in lmsmain: 
  code to create lms device commented out
  added in his own main method

2. Unknown as an eCos device  = does not work
Windows XP does NOT recognize the Lego Brick as an eCos Device:
* hg forte out of the box with the same FBs as in Dominik's
* hg forte with lms device commented out
* hg forte with just code to blick led in the main
   (I hope device was commented out - but going on memory at the moment)
   [will check and update]
* my cleaned code version

3. Next tests = try and see if the flashed on Lego -forte.bin  goes from known to unknown or vice versa.
(Ran out of time Friday night.)

known to unknown
- Uncomment the code to create the device in the Dominik  version

unknown to known
- put the main, utilities and BT fb code in the current hg version

If neither test yields anything new... then start a code compare

4. Other info:
After flashing the Lego the device, take out the battery and put it back in.
After about 25-30 sec. the Lego will click. Then the PC will show the Lego as an eCos device or it never will know the Lego is plugged in.  The 25-30 sec. is slightly longer than the normal boot blinking in lmsmain. After this click the Lego is either known/never known, independent of the contents of lmsmain.

Thursday, November 4, 2010

Nov.4 HW / Ports

Dominik using Windows 7 - the same Lego 
Alex's PC the Device Manager shows:
JTAG LINK as Universal Serial Bus controllers --> J-Link driver 
  • in the middle between the list of USB2 Controllers and USB Composite Device
eCos Lego 
= flashed with forte.bin with eCos included 
  •  (com3, com4, com5)



Samba
  • Put the LMS in reset mode, then plug in USB to PC so:
    • the Atmel Samba device driver is used
    • the LMS is not recognized as eCos or Lego device 
      • if its device driver is loaded,  then it shows up as a COM device, which is wrong!
      • so it is recognized as a USB/ARM0 device ready to be flashed

     

    Nov.4 Touch Sensor as Button Applications

    E_CYCLE is better to use than E_DELAY in many cases:
    • E_CYCLE: Sends sample request at regular intervals, independent of other FBs
    • E_DELAY: Waits a specific length of time. A total sample cycle time can be influenced by the time variance in FB execution times.
    Simple example: Touch sensor as start application button 
    E_CYCLE + E_PERMIT
    E_SWITCH+E_DELAY

    Nov.4 IEC 61499 LMS "Segway" application

    Here is a IEC 61499 LMS "Segway" application ready to be tested.
    Test results will be posted here.

    Wednesday, November 3, 2010

    Nov.3 Clean lms 4diac Pallete

    Clean lms 4diac Pallete on AlexPC - not compiled/tested  AND needs PID1 FB before Segway

    Since there doesn't seem to be any copy of the LMS Sept. workspace where the System Manger works, need finish moving the working/finished LMS Function Blocks to their own clean local hg repository. clean = no extra code + use of static const

    4DIAC-IDE managed somehow to get the same FB type (PID1) in the same group. Since good copy was lost, just deleted both copies and started over.

    forte1103 lms pallete FBs with working code from summer:
    • OFF(was shutdown); 
      • added message sent via USB back to 4diac "LMS OFF"
    • LED; 
    • LT (was RD)
    • TOUCH; 
    • SOUND; 
    • M_PWR (was motor.basic)
    Clock skew problem on Alex's PC (slow clock) is annoying since build leaves a directory when it sees it. 
    Cause: Files copied from a computer with a normal clock time.
    Solution: Wait the 10 minutes the PC clock is behind and the problem goes away.


    cntlr.PID1 Basic FB 
    Kp=25,Ki=1,Kd=10 values taken from LMS NXTG "Segway" code 
    Since the FB has been lost due to 4DIAC several times a screen capture backup - PID1 is currently in the Nov lms directory. The FB should work, but is not polished.
    • Several "Segway" application versions. 
      • Refining how to get the desired value = first read
      • Should LT FB should do its initial read when INIT event is sent?
    • PID FB 
      • Does it need an event when OUT is out of reasonable range is QO= false enough?
      • or is a separate event needed?
    • M_PWR
      • Similiarly is STOP event needed when finished with motors?
    Created sample applications for:
    • Using touch sensor as start button 
      • T_SWITCH:    with E_DELAY and E_SWITCH 
      • T_SWITCH2:: with E_CYCLE and E_PERMIT
    Tutorial0 for Blinky restructured  in usb wiki

    ECC interface is a mixture:
    event & condition in structured text 
    so might need both &s and ANDs
    ex. REQ & ((-1000 <= OUT) AND (OUT<= 1000))

    Tuesday, November 2, 2010

    Nov.2 KISS CBC day

    Dave Miller gave a quick introduction toBotball CBC robot.
    Its UI is touch screen.   Download is similar to Lego NXT.
    We did the typical first time things. Move the motors and follow a line.
    The function to start the motors returns as soon as the motors are started.
    Later a separate function can be set to wait for the motor function to complete.

    BUT BC Botball has a very nice camera which works as a color light sensor.
    The range of light is chosen from a spectrem, not restricted to ranges or 3 colors. 
    Also you see a picture via the camera and can see what it is detecting.

    For Thursday its hoped I can get a Scheme language interface workng on CBC.