Author Topic: New Service Pack SP8 with USB support  (Read 36736 times)

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
New Service Pack SP8 with USB support
« on: September 15, 2008, 02:37:36 AM »
Hi All

It is with great pleasure that I announce that the M5223X SP8 is available on the service pack side:
http://www.utasker.com/software/softwareV1.3.html

This service pack adds USB device support for use with the M5221X and M5222X families - see an overview of the devices in the following thread:
http://www.utasker.com/forum/index.php?topic=256.0

In addition to the new USB support, there are various more subtle improvement such as HTTP POST for both parameters and files - the previous SP didn't support posting parameters. The parameter system has been separated from the file system in order to improve its flexibility. It is advisable to check through the release notes to see what may be important for yourself.

As usual, there is a reference config.h file (config_ref_m5223X_sp8.h) which was used for release testing and contains all latest defines as reference. It can be renamed to config.h to reproduce the release state.

There is one change which affects compatibility so it's worth mentioning here:
_CLEARBITS macro has been changed to use positive logic rather than negative logic.
Eg. _CLEARBITS(TC, PORT_TC_BIT2); clears PORT_TC_BIT2 in port TC - previously this was written as _CLEARBITS(TC, ~PORT_TC_BIT2); All driver files using this form have been adjusted, but it will be necessary to modify its use in any of your own existing application files.


USB device operation is essentially very simple: you put messages to be sent in buffers so that they can be picked up by the host and you receive data in buffers. But to put it all together requires a lot of study, programming, testing and optimising - it is only after reading a few books about it, experimenting and then re-reading the books again that it slowly all starts to fit into place. I wrote an introduction to the theme some time ago, but didn't feel ready to follow it up until I had the feeling of really getting to grips with it all:
http://www.utasker.com/forum/index.php?topic=176.0

But now I do feel that the state of the SP really has the potential to form the base of powerful and efficient projects and it is thus time to put it into action!

To get the ball rolling, here is a very quick step-by-step of how the new package can be test-driven. It concentrates on communication (although the embedded side actually doesn't really need to know much at all about the USB model being used) since I found this the most practical way to get something working without having to take a course on Windows Driver programming... it is also very practical for using older PC programs based on serial COM since these usually require no modification at all - they just can work rather faster and seem more 'modern'.

The following allows the M52211EVB, M52223EVB or M52221DEMO to be used (the M52210DEMO can also be used, but doesn't allow firmware upload via USB since it doesn't have adequate FLASH memory).

Simulator (just checking configuration and enumeration for the moment):
1. Install SP8
2. Rename config_ref_m5223X_sp8.h in the application directory to config.h
3. Delete the file resource.h in the application directory (there is a new version in \winsim and deleting the old one will avoid it causing errors).
4. In config.h activate the processor type and the board type (eg. _M5222X and M52223EVB).
5. Rebuild all and start the simulator
6. In the (new) menu USB, command "enumeration". This will play a typical enumeration sequence through the code (it allows the operation of the driver to also be studied) and if successful the USB sign lights up red.
7. When the menu point "Disconnect" is activated it will perform a USB suspend. All transmitted USB data will be logged to a file called "USB_Endpoint_00.txt" Only endpoint 0 is used during enumeration, otherwise there is a file for each endpoint.
8. It is possible to exercise the USB interface (and others) by playing 'sim-files' through the simulator - in the Menu "Port Sim" - but this subject can be discussed later - for the moment this should do and we can move on to the target...

With the chosen board ready:
1. Open the CodeWarrior projects in \Applications\uTaskerV1.3\CodeWarrior_M5223X\uTaskerV1.3 and \Applications\uTaskerBoot\CodeWarrior_M5223X. Use CW7.1 for this since older versions don't support the M5221X and M5222X (at least not properly). Open two incarnations of CW7.1, one with each of the projects (boot loader and V1.3).
2. Chose the targets M52211_BM_ROM (uTaskerV1.3) and M52211EVB (boot loader) -this is suitable for all of the mentioned boards.
3. Compile both projects.
4. In the boot loader project select the Flash programmer setting to suit your processor and delete the entire FLASH. Then load the boot loader project to the board.
5. In the uTaskerV1.3 project select also the same Flash programmer setting but don't erase the FLASH - just program the project to the board. Now the boot loader and application are loaded.
6. Allow the board to start - it should blink an LED at 2.5Hz rate. Connect the USB cable to your Windows PC, which should cause it to enumerate and start looking for a driver. It will probably not find the driver by itself so, when it asks, tell it to look in the directory \Applications\uTaskerV1.3\USB. You will have to give Windows permission to install the driver (which actually means copy the file that it has found to a directory where it keep all such files) and then it should be ready to use.
7. In the device manager you should see that the board is visible as a COM port (with name "uTasker driven device") - the COM port number that it receives depends on the PC but can be changed by opening up the characteristics of the COM entry seen and changing it in the extended options.
8. Open a terminal emulator on this port (I recommend TeraTermPro (freeware available at various locations on the Internet) - although it only supports COM1..COM4) and hit the enter key. You should get the uTasker serial menu as response and you can then perform commands as known from the original project via UART or TELNET.
9. Connect a second terminal emulator on UART1 of the demo board. When the USB menu is not being used, the UART can access it. When the UART is not using it, the USB can access it. (note that this has default 19'200baud but changes to the setting of the USB connection when this is attached to a terminal emulator!!).
10. Go to the UART menu (from either serial or USB connection) and enter "usb-serial". Now the board operates as a USB/RS232 adapter.  You can perform bidirectional file transfers to test its performance. Changing the setting of the USB connected terminal emulator also changes the boards UART settings.
11. Disconnect the USB cable, close the terminal emulator connected to the virtual USB COM ports and connect the USB cable again. The board will immediately enumerate again.
12. Start the terminal emulator on the USB virtual COM port and go to the USB menu again. This time enter "usb-load".
This will result in:
Please start download:
#


Don't type anything else in for the moment!
13. Go to the CW program for the uTasketV1.3 project and make a small change (eg. change the version number in application.h from 1.3.008 to 1.3.009):
#define SOFTWARE_VERSION                    "V1.3.009"
Then recompile.
14. In the target directory \Applications\uTaskerV1.3\CodeWarrior_M5223X\uTaskerV1.3\bin execute the bat file BM-Convert.bat (double click on it) to create a down-loadable target called "H_Upload.bin".
15. In the terminal emulator send this file to the USB port. Using TeraTerm you can use File | Send File.. but make sure that the option "binary" is set!!! The binary file will be sent and the target will reboot. After rebooting the new program will be loaded and executed.
Note that the USB connection will enumerate again and it is necessary to restart TeraTerm so that it will work again with the interface (in fact TeraTerm has to be closed before enumerating...).The new version number is displayed when the menu is entered so this allows the success of the upload to be verified.


This should give a quick first impression. Later you will find that the embedded user code to do this is very simple indeed. The application interface is more or less interchangeable with a standard UART interface!

Good luck with your first tests. There is a lot to be explained but a users' manual is in progress. Comments very welcome...

Best regards

Mark

Patch list:
1. See below in this thread for when using SPI FLASH
2. See the following if using DMA timer support and compiling with GCC: http://www.utasker.com/forum/index.php?topic=387.msg1560#msg1560
3. When running the RTC from the main crystal oscillator, and using PLL (not 32kHz crystal as possible with some devices) there is a frequency correction here: http://www.utasker.com/forum/index.php?topic=550.0
« Last Edit: March 25, 2009, 02:32:18 PM by mark »

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
Re: New Service Pack SP8 with USB support
« Reply #1 on: September 16, 2008, 03:37:01 PM »
Hi All

Here is an important note on using Vendor and Product IDs in the uTasker project for the Freescale devices with USB.

Freescale has kindly provided the project with an 'official' product ID for demonstration and development use. These are
VENDOR ID        0x15a2                         - Freescale's Vendor ID
PRODUCT ID      0x0044                         - uTasker development project for Coldfire


This means that these values can be used for all development work using the uTasker together with Freescale devices.

As you probably know, a product needs its own VID/PID before it can be taken into operation. A VID can be purchased from http://www.usb.org and the options available are the following (quote from usb.og):

Quote
Options for obtaining vendor ID numbers are as follows:

Option 1: Join the USB-IF
If your company chooses to become a member of the USB-IF, the annual fee for membership is US$4000.  A few of the benefits of membership are: only members are eligible to participate in free USB-IF sponsored quarterly Compliance Workshops, participate in USB Device Working Groups, a waived logo administration fee  when joining the new USB-IF logo program and have their company and product information included on the usb.org web site.

Option 2:  Become a non-member USB-IF Logo Licensee
If your company executes the USB-IF Trademark License Agreement in conjunction with the assignment of your company’s vendor ID number, the fee is US$2000 (your company must execute and return the USB-IF Trademark License Agreement along with a vendor ID number application to the address below.) Please keep in mind that becoming a USB-IF Logo Licensee alone does not entitle your company to USB-IF membership benefits, however this option allows your company to be assigned a USB Vendor ID Number and enjoy the benefit of a waived USB-If Logo License Fee.

Option 3:  Purchase a Vendor ID Number without signing the USB-IF Logo License Agreement
The fee is a one time administrative fee of US$2000 for the Vendor ID Number alone.  If your company chooses to execute the USB-IF Trademark License Agreement at a later time, the USB-IF Logo License Fee of US$2000 will apply.


For your first USB product, the fact that a VID must be purchased can often pose problems due to the cost involved and also the administrative tasks of understanding the details and getting such a purchase authorised by project responsibles who possibly didn't realise what is involved....

Developing using the allocated Freescale PID allows you to freely develop with these parts.

After the development phase, Freescale is working on a scheme allowing you to register your own product PID for your project using their silicon - the details are not yet ready and this announcement is presently tentative (awaiting official confirmation) but this will allow you to obtain a free PID (under the Freescale VID) for use in initial products up to a certain quantity (in the region of 10'000). Therefore the use of Freescale devices should remove all initial constraints and allow developers to jump into their real work, knowing that these details are solved.

As detailed above, the VID/PID allows you to then sell your product. It doesn't allow you to use the USB logo. Whether you need to use the USB logo is another question and this can always be solved at a later stage when your product has made you so much money that you can afford to become a USB-IF member and polish up the product with a logo and a signed driver...;-)

I would like to thank Freescale for all their help (especially Gerry) and of course for their great chips!

To add the VID/PID to the demo please do the following:
1. In usb_application.c change the values as follows:
    #define USB_VENDOR_ID                   0x15a2                       // Freescale vendor ID
    #define USB_PRODUCT_ID                  0x0044                       // uTasker Freescale development product ID


2. Copy the new .inf file http://www.uTasker.com/software/V1.3/uTaskerFreescaleVirtualCOM.inf to the USB directory.
When you next connect the device it will install the driver (point it to the USB directory so that it finds the new file) and then the board/interface will be displayed as “uTasker driven Freescale device (COM1)” in the Window's device manager.

Good luck!

Regards

Mark
« Last Edit: December 14, 2008, 04:11:30 PM by mark »

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Re: New Service Pack SP8 with USB support
« Reply #2 on: September 16, 2008, 06:19:50 PM »
Hi Mark,
 Thanks for your help today, much appreciated  :)

I have copied the SP8 files over my current SP6. When I compile it it comes up with error that it cant find the following:

Error   : the file 'spi_flash_m5223x_sst25.h' cannot be opened
M5223X.c line 225               #include "spi_flash_m5223x_sst25.h"                          // {61} 
Error   : the file 'spi_flash_m5223x_sst25.h' cannot be opened
M5223X.c line 583           #include "spi_flash_m5223x_sst25.h"                              // {61} 
Error   : the file 'spi_flash_m5223x_sst25.h' cannot be opened
M5223X.c line 2195           #include "spi_flash_m5223x_sst25.h"                              // {61} 

I can see the files in the M5223X folder, and the path points to this , as well as other locations.

I also noticed the following is defined:
        #define SPI_FLASH_ST                                             // use ST FLASH rather than ATMEL
I couldnt find anything for atmel.

Neil

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
Re: New Service Pack SP8 with USB support
« Reply #3 on: September 16, 2008, 07:20:20 PM »
Hi Neil

This is my mistake. Since the SST driver has not been completed, the file was not added to the SP. Please comment out the include to
"spi_flash_m5223x_sst25.h"

To use the ATMEL chips ensure that
#define SPI_FLASH_SST25 and
#define SPI_FLASH_ST
are not active in config.h - then it will default to the ATMEL type.

Regards

Mark

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Re: New Service Pack SP8 with USB support
« Reply #4 on: September 16, 2008, 07:37:00 PM »
Hi Mark,
  Thanks for the reply.

I done the above, and now get the message:

Error   : function has no prototype
spi_flash_m5223x_atmel.h line 43       ucSPI_FLASH_Type[0] = fnCheckAT45dbxxx();                            // flag whether the SPI FLASH device is connected 

Error   : identifier 'fnCheckAT45dbxxx(...)' redeclared
was declared as: '__regabi int (...)'
now declared as: '__regabi unsigned char ()'
spi_flash_m5223x_atmel.h line 346   { 


Neil

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
Re: New Service Pack SP8 with USB support
« Reply #5 on: September 16, 2008, 08:12:07 PM »
Hi Neil

I think that you have made an editing mistake:

In M5223X.c - line 222

        #define _SPI_DEFINES
            #include "spi_flash_m5223x_atmel.h"                          // {39}
            #include "spi_flash_m5223x_stmicro.h"                        // {40}
            #include "spi_flash_m5223x_sst25.h"                          // {61}
        #undef _SPI_DEFINES


It seems as though you have removed the define _SPI_DEFINES or possibly the spi_flash_m52223x_atmel.h include. Removing any of these will result in that error.

The block (after commenting out the sst header) should look like this:

        #define _SPI_DEFINES
            #include "spi_flash_m5223x_atmel.h"                          // {39}
            #include "spi_flash_m5223x_stmicro.h"                        // {40}
          //#include "spi_flash_m5223x_sst25.h"                          // {61} - removed since the SST driver is not ready yet
        #undef _SPI_DEFINES


Regards

Mark




Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Re: New Service Pack SP8 with USB support
« Reply #6 on: September 16, 2008, 08:39:05 PM »
Hi mark,
  You are right, my typo error.. Its been a long day..  :D

Thanks
Neil

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Re: New Service Pack SP8 with USB support
« Reply #7 on: September 24, 2008, 12:26:16 PM »
Hi mark,
  With SP8 I am trying the ethernet module again, and noticed that Full Duplex led is not on. When I run my old application (prior to sp8) it comes on (the 100MB is on ok). I am using the same NETWORK_PARAMETERS on both projects.


static const NETWORK_PARAMETERS network_default = {
    (LAN_100M | FULL_DUPLEX | RX_FLOW_CONTROL),                 
    {0x00, 0xcf, 0x52, 0x23, 0x00, 0x00},                               
    { 192, 168, 0, 3 },                                                  // ucOurIP - our default IP address
    { 255, 255, 255, 0 },                                                // ucNetMask - Our default network mask
    { 192, 168, 0, 1 },                                                  // ucDefGW - Our default gateway
    { 192, 168, 0, 1 },                                                  // ucDNS_server - Our default DNS server
};

Neil

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
Re: New Service Pack SP8 with USB support
« Reply #8 on: September 24, 2008, 02:21:52 PM »
Hi Neil

In sp8 the setting for
    #define LAN_REPORT_ACTIVITY                                          // transmissions/receptions and errors are reported to chosen task (for link LED control, etc)
(in hw_app_m5223x.h) is active. This means that the LD port pins are controlled by software rather than the PHY directly. This allows the LED blinking times to be controlled in NetworkIndicator.c. (The PHY sometimes flashes them so fast that they are not easily visible).
The duplex LED is not controlled in this mode - just the speed and the rx/tx LEDs - and that is why it is not lighting.

If you deactivate LAN_REPORT_ACTIVITY, it will remove the fnNetworkIndicator() task and program control of all LEDs back to the PHY.

Regards

Mark

Offline ewan

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: New Service Pack SP8 with USB support
« Reply #9 on: October 23, 2008, 09:18:45 PM »
TeraTermPro can handle many serial ports. You have to modify the following in "TERATERM.INI".

; Max serial port number
MaxComPort=4


Just change 4 to 20 or whatever. Works great.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
Re: New Service Pack SP8 with USB support
« Reply #10 on: October 23, 2008, 09:39:38 PM »
Hi Ewan

I never knew that...!! Great!!

I tried and it seemed to limit at 16 (COM1..COM16) and setting more didn't increase it (on my Vista Laptop), but this means that the program is even more practical than I thought..

Regards

Mark

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
Re: New Service Pack SP8 with USB support
« Reply #11 on: January 07, 2009, 06:25:34 PM »
Hi All

Please note that a USB demo pack has been added for the M522XX to show SP8 USB CDC support.

The following is an example of how to run the demo on an M52223EVB - 256k FLASH / 32k SRAM 80MHz:

- Download the following demo pack: http://www.uTasker.com/Demos/M522XX/M5222X_USB_DEMO_M52223EVB.zip
- Load the file uTaskerV1.3_USB_DEMO_M52223EVB.s19 to your M52223EVB using the FLASH utility in CW (or other methods)
- Follow the demo document http://www.utasker.com/docs/uTasker/uTaskerV1.3_USB_Demo.PDF (the USB .INF file is also included in the demo pack: uTaskerFreescaleVirtualCOM.inf) [Note that the serial connection used is the UART0 interface, operating in DMA mode for transmission. Connect to the RS232 connector with a straight 9-pin connector]
- When testing software uploads via USB simply use the files H_Upload_M52223EVB_V1.3.0.9.bin and H_Upload_M52223EVB_V1.3.0.10.bin. These simply have different version numbers which are displayed and so confirm upload success.


To run the demo on an M52221DEMO 128k FLASH / 16k SRAM 80MHz:

- Download the following demo pack: http://www.uTasker.com/Demos/M522XX/M5222X_USB_DEMO_M52221DEMO.zip
- Load the file uTaskerV1.3_USB_DEMO_M52221DEMO.s19 to your M52221DEMO using the FLASH utility in CW (or other methods)
- Follow the demo document http://www.utasker.com/docs/uTasker/uTaskerV1.3_USB_Demo.PDF (the USB .INF file is also included in the demo pack: uTaskerFreescaleVirtualCOM.inf) [Note that the serial connection used is the COM interface, operating in DMA mode for transmission. Connect to the RS232 connector with a straight 9-pin connector]
- When testing software uploads via USB simply use the files 0_Upload_M52221DEMO_V1.3.9.bin and 0_Upload_M52221DEMO_V1.3.10.bin. These simply have different version numbers which are displayed and so confirm upload success.


To run the demo on an M52211EVB 128k FLASH / 16k SRAM 80MHz:

- Download the following demo pack: http://www.uTasker.com/Demos/M522XX/M5222X_USB_DEMO_M52211EBV.zip
- Load the file uTaskerV1.3_USB_DEMO_M52211EVB.s19 to your M52211EVB using the FLASH utility in CW (or other methods)
- Follow the demo document http://www.utasker.com/docs/uTasker/uTaskerV1.3_USB_Demo.PDF (the USB .INF file is also included in the demo pack: uTaskerFreescaleVirtualCOM.inf) [Note that the serial connection used is the UART1 interface, operating in DMA mode for transmission. Connect to the RS232 connector with a straight 9-pin connector]
- When testing software uploads via USB simply use the files 0_Upload_M52211EVB_V1.3.9.bin and 0_Upload_M52211EVB_V1.3.10.bin. These simply have different version numbers which are displayed and so confirm upload success.


Regards

Mark

« Last Edit: January 07, 2009, 10:20:20 PM by mark »