Log in

View Full Version : Linux: steps to program fullsize RC robot


rwaliany
09-01-2004, 16:56
Post here if you need help and this doesn't work.
Current site: http://ryan.scv.net/x2545/pic


Documentation IFI Linux PICloader setup Fullsize RC with MCC18 compiler:

Non-root setup (advanced users):
Same steps as "root setup"
Additional steps
edit ~/picloader/code/Makefile # change user directory to yours
chmod permissions <device> # on startup
cp picloader /usr/bin # cp picloader to binary directory as root

Gentoo (root setup):
cd ~/
wget http://ryan.scv.net/x2545/picloader/ifi-picloader.0.2.tar.gz # get the file
emerge wine # installs package
wine # installs wine basic setup information
mount /dev/cdrom /mnt/cdrom # pipe the cdrom to /mnt/cdrom
cd /mnt/cdrom # change local directory to /mnt/cdrom
wine MPLAB_C18.exe # start the install, install it to default directory c:/mcc18
cd ~/ # change to home directory
(editor) ~/.wine/config # add path
@ 77
- "Path" = "c:\\Windows;c:\\Windows\\System;f:\\;h:\\;z:\\"
+ "Path" = "c:\\Windows;c:\\Windows\\System;f:\\;h:\\;z:\\;c:\ \mcc18\\bin;h:\\ifi-picloader\\code"
@ 90
- "Windows" = "win98"
+ "Windows" = "winxp"

cd ~/
tar -xzvf ifi-picloader.0.2.tar.gz # extract the file
cd ifi-picloader #
make # compile the Linux programmer for the RC
cd code # change to where all the code should be done for your robot
make # compile the code in the code directory
picloader FrcCode.hex <device> # write program to serial device, usually /dev/ttyS0 com1

# Device samples
# Com1 = "/dev/ttyS0"
# Com2 = "/dev/ttyS1"
# Com3 = "/dev/ttyS2"
# USBSerial (pl2303) = "/dev/usb/tts/0"

Thanks,
Ryan Waliany

Servo888
09-01-2004, 20:40
Hmm no luck getting the MPLAB IDE to run under Linux.

I've tried, wine version 20031212, XOffice, and WineX. And they all give me the same responce. The Microchip MPLAB IDE logo loads, and just stays there. Doesn't do anything else.

Very strange; It would be nice of Micochip to offer us a C18 compiler... They can keep the IDE, just want the compile =\.

*sigh*. Gonna keep trying to get the IDE

rwaliany
10-01-2004, 02:01
The point of this thread is to show steps to bypass the MPLAB Ide allowing you to use any IDE or editor you want, anjuta, vim, or kate for example and be able to compile code and load it to the pic in Linux. MPLAB is limited, need I say more? MPLAB requires internet explorer 5....what for? If you want MPLAB to use the simulator, you should be able to wine the simulator dll mpsim.dll.

Once your done with these steps, you can edit the source files user_routines.c in any editor you would like, then type make in console and then picloader FrcCode.hex <device>, and you would have programmed the PIC with the same functionality as in Windows, with MPLAB etc...

Servo888
10-01-2004, 18:51
Let me see if I understand this:

The MPLAB_C18.exe is just the compiler; and not the IDE? (sorry, I don't have a copy of the CD; so I'm trying to figure this out.)

rwaliany
10-01-2004, 19:18
Yes, MPLAB_C18 is the compiler.

ScottWolchok
17-01-2004, 20:06
Yes, MPLAB_C18 is the compiler.
You mean it's the installer for the IDE...mcc18.exe is the compiler =P
Note that there's a typo in the Makefile. The line that starts with MCC18DIR should read:
MCC18DIR=$(USER_DIR)/.wine/fake_windows/mcc18/

(The trailing slash after $(USER_DIR) was missing)

rwaliany
17-01-2004, 20:16
You mean it's the installer for the IDE...mcc18.exe is the compiler =P
Note that there's a typo in the Makefile. The line that starts with MCC18DIR should read:
MCC18DIR=$(USER_DIR)/.wine/fake_windows/mcc18/

(The trailing slash after $(USER_DIR) was missing)

Note how USER_DIR had a trailing slash at the end of it in the example...also it seems that what the executable for mcc18 is, is dependent on your kernel I believe. On 2.4.23 it appeared as mcc18.exe and on 2.6.1-mm2 it appeared as whatever I had in the installation documentation. Hopefully, I'll improve it this weekend, I have to fix a few things. I've received some courteous improvements for the Makefile from Michael Wu I'll have to add.

Also, the project page should be up now at http://ifi-picloader.sourceforge.net (http://ifi-picloader.sf.net) .

Thanks for your interests,
Ryan Waliany

rwaliany
19-01-2004, 17:47
New release 0.3, it should be easier to install now and more user-friendly. Lots of makefile improvements with some suggestions from others. A serial reader will be coming in 0.4 which will allow you to debug using a terminal and read data from the program port.

http://ifi-picloader.sf.net/

deltacoder1020
19-01-2004, 18:34
heh, now all we need is a PocketPC running Linux and we'll be able to have a mobile programming and download platform ;)

mikew
19-01-2004, 21:13
compiler is x86 only, so you'll need a pc emulator. dunno how well those run on pocketpc.

deltacoder1020
20-01-2004, 00:11
eh, so it's only a mobile download platform. either way, it would still be fun ;)

rwaliany
20-01-2004, 00:30
Added some more suggestions from Michael Wu, will hopefully release 0.4 tomorrow with serial reader and fixed erasing pic for multiple memory banks.http://xp.scv.net/x2545/picloader/ifi-picloader.0.4.tar.gz (http://ryan.scv.net/x2545/picloader/ifi-picloader.0.4.tar.gz) Beta release

Working on make install, and moving to /usr/share/ifi-picloader/

Jeff McCune
20-01-2004, 14:37
I'm having trouble reproducing your results. I'm running Debian Sarge (testing) on my notebook, and tried to apt-get install wine. Upon configuring wine the way you suggest, I can't get the mcc18.exe compiler to work. It keeps bombing out with this error:


F:\Code\code>mcc18 -p=18F8520 -fo user_routines.o user_routines.c /i"C:\mcc18\h" -Ou- -Ot- -Ob- -Op- -Or- -Od-
fixme:win:GetProcessWindowStation (void): stub
fixme:win32:GetUserObjectInformationW (0x1 2 (nil) 0 0x4067fb68),stub!
fixme:win:GetThreadDesktop (9): stub
fixme:win32:GetUserObjectInformationW (0x1 2 (nil) 0 0x4067fb6c),stub!
fixme:win32:GetUserObjectInformationW (0x1 2 0x4036a0a8 0 0x4067fb68),stub!
fixme:win32:GetUserObjectInformationW (0x1 2 0x4036a0a8 0 0x4067fb6c),stub!
fixme:ntdll:NtQueryInformationProcess (0xf04,0x00000000,0x4067fa40,0x00000018,(nil)),stu b!
fixme:msvcrt:_spawnve :not translating name .\cpp18 to locate program
fixme:msvcrt:msvcrt_spawn :must dup/kill streams for child process
error -1 spawning .\cpp18


I'm running this from wine by using wine cmd.exe I tried it from a bash shell with the same error message. I figured running from cmd.exe might help things, but apparently not.

This is the version of wine I'm running:
silas@frink:~$ wine --version
find: /usr/bin/../lost+found: Permission denied
Wine 20031212

Has anyone had success with the free and open version of wine? I'm not too keen on this 30 Day trial software from codeweavers, and I have issues in general with supporting the codeweaver software. Any help would be greatly appreciated.

mikew
20-01-2004, 15:24
check ~/.wine/config . you need to make sure the native, not wine, version of msvcrt is being used or mcc18 will die with some spawning error. oh, and you need a copy of msvcrt.dll too.

Jeff McCune
20-01-2004, 16:11
Thanks for the advice... One step closer in the right direction, but still not there. Hopefully if I can get this working, I can document the process and perhaps package something nice for people to easily get development up and running in Linux. Hopefully it'll help you focus on the excellent work you're doing with the clone of the IFI loader.

I copied my msvcrt.dll from my Windows XP machine (The copy in C:\Windows\System32, there were many copies) into my .../fake_windows/Windows/System32 directory in Linux. I made sure that msvcrt is trying to load native before loading the builtin. It now just refuses to load the exe with the following error:

silas@frink:/var/silas/public/first2004/Code/code$ wine -- "C:\\mcc18\\bin\\mcc18.exe" -p=18F8520 -fo "F:\\Code\\code\\main.o" "F:\\Code\\code\\main.c"
find: /usr/bin/../lost+found: Permission denied
err:module:LdrInitializeThunk Main exe initialization failed, status c0000142
Wine failed with return code 1

Any more suggestions? Are you using built-ins from a full install of Windows? I'd like not to do this, but I have Windows XP and Windwos 98 lying around that I can copy the DLL's from if need be.

Thanks again for your help with this.

Here's what my ~/.wine/config looks like:
(Deleted because it was flippin' huge. My windows version line was wrong, see below for fix)

Joe Ross
20-01-2004, 16:27
install winesetuptk and that will help you get your config file working.

Why don't you want to use the dlls in their existing location?

mikew
20-01-2004, 16:27
The ifi loader distribution comes with a copy of the dll. I think I extracted my copy from a win98 system.

Jeff McCune
20-01-2004, 16:52
The ifi loader distribution comes with a copy of the dll. I think I extracted my copy from a win98 system.
Good to know... Was this documented somewhere, and I just missed the boat? Please don't take this the wrong way or anything, but would you mind if I help you out with the documentation? Either I'm missing threads on here with regard to getting this thing to work, or documentation is just lacking at the moment. Either way, I think everyone will benefit if we can get some good docs regarding Linux as a development environment.

If all goes well, I might even be able to set up a CVS server with a repository for any team that might want one. Might be useful. Would be nice we we can reduce the code to cvs update && make && ifi_loader_clone foo.hex /dev/ttyS0 or something of that nature.

Also, again not to step on your toes regarding the great work you're doing, but are we legally allowed to distribute the two dll files you have? It might be worth it just to be "clean" to instruct people to copy them from a Windows98 install, or obtain them by some other means. Not sure what the status is, but they're probably copyrighted Microsoft property.

OK, so I copied the crt.dll and msvcrt.dll from the ifiloader tarball into my fake_windows/Windows/System (Not System32, as I did last time) and then changed the win version line in the config to:
[Version]
; Windows version to imitate (win95,win98,winme,nt351,nt40,win2k,winxp,win2k3,w in20,win30,win31)
"Windows" = "winxp"
; DOS version to imitate
; "DOS" = "6.22"
and the mcc18.exe compiler is giving me some complaints about not being able to find a header file. Looking good.

Trying to compile user_routines.c by hand, from the command line, I get this:
silas@frink:code$ wine -- mcc18.exe -p=18F8520 -fo user_routines.o user_routines.c /i"C:\mcc18\h" -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
Wine exited with a successful status
SWEET! OK, so would anyone like to comment on what content I should include in any documentation type things I'm planning on preparing? I personally run Debian GNU/Linux, so my instructions and examples will probably be from this perspective. Thoughts?

rwaliany
20-01-2004, 19:23
Aye, it should work step by step. I believe the only problem was setting winever to winxp. I'm working on it. I think I could maybe release 0.4 today with the serial reader etc...Thanks for all your support.

Just to keep everyone posted, why I'm updating so slow: I have 10 H/Ap/College classes, Robotics, community service projects im co-leading, and some other contests I'm leading with two part-time jobs of programming at eSCV and AMDI, teaching AP Compsci AB starting in a couple weeks, etc...

Thanks,
Ryan Waliany

rwaliany
20-01-2004, 19:43
Also for msvcrt.dll, I believe it would be fine if I added a disclaimer next version stating that the user should have a copy of the Windows operating system and it belongs to Microsoft. If someone could check in on how dll download places distribute msvcrt.dll please let me know. I believe a disclaimer is all.

Jeff McCune
20-01-2004, 20:39
Also for msvcrt.dll, I believe it would be fine if I added a disclaimer next version stating that the user should have a copy of the Windows operating system and it belongs to Microsoft. If someone could check in on how dll download places distribute msvcrt.dll please let me know. I believe a disclaimer is all.

A disclaimer alone isn't enough to CYA if you're distributing copyrighted works. Countless examples of this exist from the rom sites to mp3.com. msvcrt.dll is ridiculously common, so I'd just google for it and link to some places that already distribute the library (They might even have MS's permission to do so). If the Microsoft legal army gets bored and decides to harass you, it would be nice to be able to claim you're not distributing anything Microsoft has rights over. Sounds like you're already busy enough and wouldn't welcome another distraction.

The chances of this ever actually being a problem for you if you decide to keep distributing the libraries are slim to none, I realize, but I'd just hate to see you hastled over something so trivial.

rwaliany
20-01-2004, 20:46
what if I made them download it automatically with wget :-)

Jeff McCune
20-01-2004, 21:04
what if I made them download it automatically with wget :-)
Perfectly legal. Debian packages do this all the time with stuff they can't distribute. When you install the package, it just asks "Can I download and install Macromedia FlashPlayer for you?" "Uh, sure!" "Downloading..." =)

rwaliany
07-02-2004, 17:01
New release 0.4.

Fixed memory, up to ~30kbytes around, tested with Kevin and Watsons infra-red, beacon, and navigation code along with FRC default code and my own code. Ansi color support makefiles, etc... dependencies...

http://www.hartrobot.com/ifi.php
http://www.hartrobot.com/downloads/ifi-picloader.0.4.tar.gz

I will post a file upload soon, but it appears that the file upload system doesn't support .tar.gz, or im not sure why else it gave me a string error on upload.

I'm in the process of switching servers to a new connection, so if hartrobot.com doesn't work replace www.hartrobot.com with 216.112.86.9/~hartrobot/

Thanks,
Ryan Waliany

kc8tbe
11-02-2004, 16:38
Silly question, but is it possible to get feedback from the RC (i.e. via printf() calls in the program) via the picloader?

rwaliany
11-02-2004, 17:06
Yes, using the picreader program that is included, you can type picreader <device> it pipes the output to the terminal and reads the output from the serial port from "printf". This is a new feature that was added I believe in 0.3 or 0.4. This allows you to even add ANSI color standards to your debug output and make it all pretty even.

Example:
[Debug: All systems running.]
[Debug: Fatal Error bla bla bla]

If anyone is interested in ANSI color I can probably write up a quick description of how it works.

Thanks,
Ryan Waliany

kc8tbe
12-02-2004, 15:26
Thanks a bunch :p ! I knew there was some kind of easy solution...

Joe Ross
12-02-2004, 15:42
Perfectly legal. Debian packages do this all the time with stuff they can't distribute. When you install the package, it just asks "Can I download and install Macromedia FlashPlayer for you?" "Uh, sure!" "Downloading..." =)

Note that the Debian packages that do this are still in non-free.

BTW, Jeff, while doing some research on sending SMS, I found your name in some of the files of one of the packages I was looking at. What other things have you done?

kc8tbe
12-02-2004, 16:43
This is a new feature that was added I believe in 0.3 or 0.4.

Once again with my stupid questions...
I've looked in the tarball for 0.4 and 0.2 without success. This picreader doesn't seem to be in any of the Makefiles. I cannot find a tarball for 0.3 at http://ryan.scv.net/x2545/picloader. Where can I find this picreader application? Please post a link!

rwaliany
13-02-2004, 17:35
I'm sorry those are old links, please refer to http://www.hartrobot.com/ifi.php Also, I'm sorry for responding slow, my e-mail was down and I didn't know anyone responded to here. That was a beta version of 0.4.

Jeff McCune
14-02-2004, 14:18
Note that the Debian packages that do this are still in non-free.

BTW, Jeff, while doing some research on sending SMS, I found your name in some of the files of one of the packages I was looking at. What other things have you done?

Not much, really. Full time network admin at the Linguistics department at Ohio State University, developer on the xbox-linux project, developer on project193, which is more just for the engineering department at OSU, but still open source. Other than those two, I just hack scripts and do the occasionaly patch on open source software I use. Still trying to finish my undergrad degree in CIS as well, but that won't happen for a couple of more years.

Project 193 might be interesting to you guys... We're developing a robotics microcontroller targeted at educational use for first year college engineers. It's going to be much more robust than that, but the Engineering department is funding us so that's our primary goal. We're using an intel core with external modules that communicate over i2c. You can customize it however you like, adding as many motor modules, pwm modules, sensor modules, etc... as you like. Unfortunately we have a crap website now. You can look at the project page at: http://www.sf.net/projects/project193/

Actually, my SMS script broke a few weeks ago. With First and stuff, I haven't found the time to fix it, but some guy just emailed me a patch. I haven't heard back from him if he wants to maintain the script from now on or not, but I'll get that publically available soon.

rwaliany
14-02-2004, 14:45
Interesting, I think after build season we're going to use one of my laptops as a robot controller, :-P and try to get someone to give us GPS and make a REALLY big robot.