Go to Post Can't engineers be jesters? - danielkitchener [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 22-10-2006, 20:48
Shinigami2057 Shinigami2057 is offline
Slackware Is Your New God (Mentor)
AKA: Harry Bock
FRC #1350 (Rambots)
Team Role: Programmer
 
Join Date: Oct 2006
Rookie Year: 2006
Location: Johnston, RI
Posts: 106
Shinigami2057 is just really niceShinigami2057 is just really niceShinigami2057 is just really niceShinigami2057 is just really niceShinigami2057 is just really nice
IFI_Loader protocol?

Hi all, I have a few questions for the programmers from AdamBots or anyone else who knows anything about the IFI_Loader protocol, especially in regards to the ifipictools program. I'm sorry this post is so long, but

I am in the process of writing a portable program loader specifically for the FRC. I've written the Intel HEX file reader and I know how I'm going to go about working with input and output from the serial port, but I have really no idea what I'm sending to the FRC's program port. I was originally just going to extend ifipictools, since it has an open license, but upon looking at the code, I have absolutely no idea what's going on, as nothing in the code lends to figuring what exactly it DOES.


Basically, all I really get out of it (based on the variable names in the program, since there are no useful comments) is that to load the program, you have to:
1) Send version information to the PIC.
2) Send a "base read" command to the PIC.
3) Send two commands that erase whatever is currently in flash program memory.
4) "Splice" blocks of memory read from the HEX file into a command that tells the PIC to write that block to whatever address.
5) Close and reopen the connection to the controller
6) Send the reset command to the controller.
And in between reads and writes to /dev/sttywhatever you need to wait a few milliseconds to let the FRC write to the user PIC18 before sending more data.

Could anyone involved in the project please help me understand what exactly is going on in that code sequence? Did you get help from IFI or did you just try to pick apart the data going between the FRC and IFI_Loader by monitoring the serial port? Any help would be GREATLY appreciated.

All the work I'm doing on this project will be released under the GPL and will hopefully be cross-platform, so that any team can use our program loader, whether they're using Linux, Solaris, OSX, Windows, or whatever. Attached is the latest version of ifi-pictools and what I've got for the HEX reader right now, which is mostly useless by itself.

Harry
Attached Files
File Type: tgz ifi-pictools_0.4.97-1.tgz (13.1 KB, 30 views)
File Type: h ihex.h (1.3 KB, 31 views)
File Type: c ihex.c (3.2 KB, 39 views)
  #2   Spotlight this post!  
Unread 22-10-2006, 22:10
Noah Kleinberg Noah Kleinberg is offline
Registered User
FRC #0395 (2TrainRobotics)
Team Role: Driver
 
Join Date: Jan 2006
Rookie Year: 2006
Location: New York
Posts: 196
Noah Kleinberg is a splendid one to beholdNoah Kleinberg is a splendid one to beholdNoah Kleinberg is a splendid one to beholdNoah Kleinberg is a splendid one to beholdNoah Kleinberg is a splendid one to beholdNoah Kleinberg is a splendid one to behold
Send a message via AIM to Noah Kleinberg
Re: IFI_Loader protocol?

I'm not sure if you've seen this yet, but a while back someone made a program called IFI Loader Reloaded which I think does about what you're doing. The source code is included (here), and that should help you; you could also contact the guy who made it.

Good Luck.
  #3   Spotlight this post!  
Unread 23-10-2006, 00:56
Shinigami2057 Shinigami2057 is offline
Slackware Is Your New God (Mentor)
AKA: Harry Bock
FRC #1350 (Rambots)
Team Role: Programmer
 
Join Date: Oct 2006
Rookie Year: 2006
Location: Johnston, RI
Posts: 106
Shinigami2057 is just really niceShinigami2057 is just really niceShinigami2057 is just really niceShinigami2057 is just really niceShinigami2057 is just really nice
Re: IFI_Loader protocol?

Wow, thanks a million for the quick reply! The source code to that programmer is much easier to understand. I also found a reference to AN851, a white paper supplied by Microchip for a special bootloader and serial protocol, which is what IFI uses in their FRC (slightly modified, though). It would've been nice if IFI supplied that information on their website

Thanks so much again for the help, and especially to Phil Baltar and John Dong for their original work on this

I'll make sure to post more info when I've figured things out a little more and written the base code. I want to make this worthwhile for more than just our team in the end.
__________________
One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs.
  #4   Spotlight this post!  
Unread 23-10-2006, 20:47
sciguy125 sciguy125 is offline
Electrical Engineer
AKA: Phil Baltar
FRC #1351
Team Role: College Student
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Sunnyvale, CA
Posts: 519
sciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond repute
Send a message via AIM to sciguy125 Send a message via MSN to sciguy125 Send a message via Yahoo to sciguy125
Re: IFI_Loader protocol?

I'm glad to know that my program could help.
__________________

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GE/S/P a-- e y-- r-- s:++ d+ h! X+++
t++ C+ P+ L++ E W++ w M-- V? PS+ PE+
5- R-- tv+ b+ DI+++ D- G
------END GEEK CODE BLOCK------
  #5   Spotlight this post!  
Unread 24-10-2006, 16:02
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: IFI_Loader protocol?

You'll probably want to look at my Python port of IFI PICLoader, which I called "pycloader".

I tried to make the modules which handle reading of the HEX file (which is based on a spec from Intel) and interfacing with the controller as usable as possible.

The Intel Hex reader interface is more hackish than I'd like, but it works. It supports more record types than is actually used.

The PIC interface (what you're interested in) is a little more manageable, IMHO. I've tried really hard to make sure it's all documented and laid out nicely and...

The C version is not really readable. I first tried porting it by doing a line-by-line port and simplifying. I then grabbed PortMon from Sysinternals and just figured it out. The resultant protocol I documented (or tried to) on my website. (Also in CVS.)

Any suggestions would be appreciated.

And no, I don't understand the parameters to the ERASE command, yet.
  #6   Spotlight this post!  
Unread 26-10-2006, 17:10
chris31 chris31 is offline
Team 2021 Captain
AKA: Chris Davidson
FRC #2021 (FA Robotics)
Team Role: Mentor
 
Join Date: Nov 2005
Rookie Year: 2006
Location: Atlanta, GA/ Fredericksburg,VA
Posts: 949
chris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond repute
Send a message via AIM to chris31
Re: IFI_Loader protocol?

Astro, What license is all your code under? I would just have PMed you but there might be someone else interested in know so I posted.
  #7   Spotlight this post!  
Unread 26-10-2006, 17:15
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: IFI_Loader protocol?

Quote:
Originally Posted by chris31
Astro, What license is all your code under? I would just have PMed you but there might be someone else interested in know so I posted.
Just like the rest of the project, pyctools (pycloader et al) is under the GNU GPL.
  #8   Spotlight this post!  
Unread 26-10-2006, 18:16
chris31 chris31 is offline
Team 2021 Captain
AKA: Chris Davidson
FRC #2021 (FA Robotics)
Team Role: Mentor
 
Join Date: Nov 2005
Rookie Year: 2006
Location: Atlanta, GA/ Fredericksburg,VA
Posts: 949
chris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond repute
Send a message via AIM to chris31
Re: IFI_Loader protocol?

Quote:
Originally Posted by Astronouth7303
Just like the rest of the project, pyctools (pycloader et al) is under the GNU GPL.
I figured it was all GPL'd but since the sourceforge page didnt have a License selected I figured I would check.
  #9   Spotlight this post!  
Unread 29-10-2006, 14:54
Shinigami2057 Shinigami2057 is offline
Slackware Is Your New God (Mentor)
AKA: Harry Bock
FRC #1350 (Rambots)
Team Role: Programmer
 
Join Date: Oct 2006
Rookie Year: 2006
Location: Johnston, RI
Posts: 106
Shinigami2057 is just really niceShinigami2057 is just really niceShinigami2057 is just really niceShinigami2057 is just really niceShinigami2057 is just really nice
Re: IFI_Loader protocol?

Hey all, thanks for the help I've got just about everything implemented on the basic API level- serial I/O, transmitting and receiving command packets (including EEPROM read/writes and the repeat and replicate commands), and Intel HEX reading.

Soooo what I am probably going to do is use that code as a shared library (how does libfrcloader.so sound? ) and make a terminal-based loader first (to test) and if that goes over well, a GTK+ version. A shared or static library would be good if someone wants to write an ncurses or plain X version or something... I dunno.

Phil, you mentioned in your ifi-reloaded thread that you had the white paper for the IFI modifications to the AN851 bootloader. Do you still have it? I noticed in your code that you never actually use ifi_prep(), did that ever affect program loading? I think I've got at least part of what the weird packets being sent mean.
"erase1" = STX STX 0x09 0xE0 0x00 0x08 0x00 0x00 DLE 0x0F ETX
"erase2" = STX STX 0x09 0xE0 0x00 0x40 0x00 0x00 0xD7 ETX
Taking out the control characters, it looks like it could be this:
Command 0x09
Rows 0xE0
Address 0x000800 (and 0x004000)
Data 0x00
and then the usual checksum.

I think command 0x09 is basically just a mass row write to whatever byte data is (in this case, 0x00). Since one row is 8 blocks or 64 bytes, I guess it's writing E0 rows of 0x00 (0x3800 bytes) to 0x0800 (Which accounts for the range 0x0800 - 0x4000) and the same amount to 0x4000 (0x4000-0x7800). From the looks of it, it's just doing a bulk erase to the upper limit of a device's program memory (3FFF is the limit on the PIC18F442, 7FFF on the 18F8520, etc.) in parts since it can only write/erase 256 rows at one time. Seems kind of redundant to me (why not use the regular row erase command?). Also, I think the second E0 should be FF (write from 0x4000-0x8000), I'll check that once I actually get a controller to test it on.

Wow, that was way more than I thought I was going to type. Sorry!
__________________
One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs.
  #10   Spotlight this post!  
Unread 29-10-2006, 18:50
sciguy125 sciguy125 is offline
Electrical Engineer
AKA: Phil Baltar
FRC #1351
Team Role: College Student
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Sunnyvale, CA
Posts: 519
sciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond repute
Send a message via AIM to sciguy125 Send a message via MSN to sciguy125 Send a message via Yahoo to sciguy125
Re: IFI_Loader protocol?

I never used ifi_prep() because I couldn't figure out what the command did. From what I can gather, it does some sort of erase. However, just using the normal erase commands works fine.
__________________

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GE/S/P a-- e y-- r-- s:++ d+ h! X+++
t++ C+ P+ L++ E W++ w M-- V? PS+ PE+
5- R-- tv+ b+ DI+++ D- G
------END GEEK CODE BLOCK------
  #11   Spotlight this post!  
Unread 28-11-2006, 23:30
Shinigami2057 Shinigami2057 is offline
Slackware Is Your New God (Mentor)
AKA: Harry Bock
FRC #1350 (Rambots)
Team Role: Programmer
 
Join Date: Oct 2006
Rookie Year: 2006
Location: Johnston, RI
Posts: 106
Shinigami2057 is just really niceShinigami2057 is just really niceShinigami2057 is just really niceShinigami2057 is just really niceShinigami2057 is just really nice
Re: IFI_Loader protocol?

Hey all, I'm back

I've finished the entire backend interface and have been working on the terminal version on and off for a week or so. So far, everything works just fine - erasing the device, loading programs, dumping user memory, reading configuration memory, etc. all have been tested on the PIC18F8520 controller (2005).

I need some brave souls with access to the 2004 and 2006 controllers to help me out by figuring out the device ID for them using my program, since the program's configuration file relies on device IDs and I only have the 2005 ID (0x0B01). The program will run fine without the correct IDs, it just will assume the memory bounds of the PIC18F8520 which may prevent some programs from loading completely.

Here is the current source tarball: http://lights2dx.net/source/other/frcprog.tar.bz2
Compile it using the make.sh script (I'll get around to a Makefile later). To get the information needed, run it like so:
./frc -i -c --device /dev/ttyS0 (replace ttyS0 with whichever port you actually use)

I've also started building the GUI using glade. Based on this screenshot of the windows the program will use, what do you think so far? http://lights2dx.net/source/other/fr...de_prelim2.png

Thanks everyone again for your help
__________________
One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs.
  #12   Spotlight this post!  
Unread 29-11-2006, 22:57
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: IFI_Loader protocol?

Quote:
Originally Posted by Shinigami2057
I need some brave souls with access to the 2004 and 2006 controllers to help me out by figuring out the device ID for them using my program, since the program's configuration file relies on device IDs and I only have the 2005 ID (0x0B01). The program will run fine without the correct IDs, it just will assume the memory bounds of the PIC18F8520 which may prevent some programs from loading completely.
It's in Microchip's programmer documentation.

The Device ID is broken up into 2 parts. Only the first is used to identify the processor. For the 8520, it's B00h. For 8722, it's 1400h. See tty.py, VersionMask, RevisionMask, and Processors.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
IFI Loader protocol Astronouth7303 Programming 0 31-07-2006 11:52
New IFI_LOADER! Greg Ross Programming 12 09-02-2006 12:05
dashboard protocol sciguy125 Programming 9 22-08-2005 18:36
programming protocol sciguy125 Programming 6 20-06-2005 16:06
Dashboard Protocol Library archiver 2000 9 23-06-2002 22:24


All times are GMT -5. The time now is 20:50.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi