Shop OBEX P1 Docs P2 Docs Learn Events
PropForth 4.5 on the GG Propeller Platform — Parallax Forums

PropForth 4.5 on the GG Propeller Platform

mindrobotsmindrobots Posts: 6,506
edited 2011-06-17 18:10 in Propeller 1
With the release of PropForth 4.5 (PF4.5) I've decided to jump into the PropForth pool to relax with some fun for the summer!

With my trusty GG platform in my briefcase and not wanting to do any real work toady, I set out to build a development image for the GG Propeller Platform USB.

It was relatively painless, very educational and the end result is running fine. All of the files used can be found in the PropFroth 4.5 .zip or are listed below. The steps I took:

1) From the Propeller Tool, compile and load PropForthKernal.spin to EEPROM
2) Try some forth from your terminal program to make sure it works (it does)
3)Open fs.f (found in the supplemental folder of PF4.5) into an editor, cut and paste the entire file into your terminal program
4) when you get the prompt back, try some of the EEPROM fs words: fsclear, fsls
5) if all looks good at this point, type 'saveforth' at your terminal to save a copy of what you have so far back to the EEPROM (bottom 32K) - this will make your current in RAM image the boot image.

This gves you a robust development image of PropForth with EEPROM file system support.

The next step was to add SD card support. The PF4.5 release appears to be writh the Spinneret as the main target platform (which is cool since it looks liek a good platform for allteh features added). TO make the sd_driver.f work with the GG platform, the I/O pinds need to be changed. The following changes to sd_driver.f take care of this:
\ CONFIG PARAMETERS BEGIN
\
\ definitions for io pins connecting to the sd card
\ below pin defs for Spinneret
\ 13 wconstant _sd_cs  \ Prop Pin #19
\ 14 wconstant _sd_di  \ Prop Pin #20
\ 15 wconstant _sd_clk \ Prop Pin #21
\ 10 wconstant _sd_do  \ Prop Pin #16
\
\below pin defs for GG Propeller Platform USB
3 wconstant _sd_cs
2 wconstant _sd_di
1 wconstant _sd_clk
0 wconstant _sd_do

From this point, the following will get an image with EEPROM and SD file system support (all the files are in the SD folder of the PF4.5 release):

1) cut/paste the sd_driver.f file contents into your terminal
2) cut/paste the sdfs.f file contents into your terminal
3) saveforth
4) check to make sure an SD card is in (it WILL ERASE this card)
5) cut/paste the sd-scripts.f file contents into your terminal - this builds the forth SD filesystems on the SD card and creates a handful of files.

At this point, all was well but I saw that I had lost a big chunk of memory (almost 1/2 of free dictionary space) to SD support words. Being a Forth re-learner at this point, I didn't think I'd be using the SD that much but thought the suport could be fun to have around if needed. So, how about putting it on the EEPROM so it's handy if needed?

If you are going to go the route outlined below, you need to perform the first 5 steps to get to the point where you have done a saveforth on a forth kernal with the EEPROM fs built into it.

I created two wrappers for the sd_driver.f and sdfs.f files to write them to the EEPROM with their original names. You can just build these in an editor since they are basically disposable files once the code is loaded into the EEPROM. The example is for sd-driver.f but you need to do the same for sdfs.f
\ loads sd_driver.f to EEPROM as sd_driver.f
fl
fswrite sd_driver.f
 
 
<insert code from sd_driver.f - remove the fl from line #1, it seems to work better for the fsload>
 
 
... \ this line is IMPORTANT, 3 periods and a CR is the EOF marker to fswrite

cut/paste the two wrapper files to your terminal to create the new .f files on yoru EEPROM

The last step is creating two helper files on EEPROM to make loading and unloading easier. The following code creates these files.
\ Create file load_sd.f on EEPROM to:
\ load sd_driver.f and sdfs.f from EEPROM
\ create mountpoints
\ display SD card info
\
fl
fswrite load_sd.f
fsload sd_driver.f
fsload sdfs.f
decimal
[ifndef mountsys : mountsys 0000000001 sd_mount ; ]
\ mountusr ( -- ) mount the user disk
[ifndef mountusr : mountusr 65538 sd_mount ; ]
mountsys
fread .sdcardinfo
ls
...
\ Create unload_sd.f on EEPROM to:
\ forget everything in the dictionary AFTER build_sddriver
\ ** BE CAREFUL **
\
fswrite unload_sd.f
forget build_sddriver
...

Now, when you reset your GG, you get a forth image with the development kernal plus EEPROM fs support. If you want to use the SD, you just do 'fsload load_sd.f' to load up the SD words. when you are done with the SD, you type in 'fsload unload_sd.f' and it FORGETS everything you did from the time you loaded the SD support. Make sure you have saved any words you want to keep after you loaded the SD support since they will be FORGOTTEN!

The Spinneret and multiple props are next!!

This is probably as clear as mud and of little interest to most forum readers but it's fun for me and if it's not making you money, or the wife happy, it better be fun!

Rick

Comments

  • prof_brainoprof_braino Posts: 4,313
    edited 2011-06-17 14:51
    Cool stuff! Nice write up, too.

    Did you find any documentation in the download, or did you just jump into the source code?

    How long did you spend to get EEPROM and SD working?
  • mindrobotsmindrobots Posts: 6,506
    edited 2011-06-17 18:10
    Hi Prof!

    Thanks! I tried to write it clearly and include all the steps. I had gotten lost last night some where in your testing documents (mostly my confusion and not being able to concentrate on the non-printed documents. This morning I printed things out and looked at the code (as best I can) and things made a lot more sense.

    I found the documentation in the .zip - some of the testing scripts are a bit confusing - especially with all the output created when you dump a .f file into the terminal and all the output spews forth. I did work through all the test scripts I could this morning on the GG board. You are correct, this does help you see the features and get some experience working through the environment. The non-IP test scripts I did all worked as advertised. Well done!!

    At some points I was looking through the documentation and using that as best I could - at some points, I bravely jumped into the code. My Forth is very, very rusty and was never that great to start with. It is coming back and more and more source code is starting to make sense.....but I'm a long way from feeling comfortable with anything major.

    I probably worked on the EEPROM and SD integration for 3 hours or so. I did a lot of playing around with the environment and spent another hour or two collecting information and writing things up. I find that writing things up helps to settle it in my own head - it's the next order of magnitude from jotting down your own notes as you read things. Writing and trying to explain it doubly reinforces the concepts and makes you dig a bit deeper.

    I've been playing with SPIN and the Prop since the first of the year with limited success (it wasn't clicking and seemed too much like WORK). Playing with Forth has helped a lot and made it fun! I forgot how much I enjoyed the Forth development cycle!

    I intend to start hooking sensors and such to the Prop and try to get them working with Forth code instead of SPIN and the OBEX libraries. Hopefully a good way to learn both languages.

    I'd be more than happy to help out with the project where I can. Documentation, testing, coding (some day in the future when I can). PM me if you have any assignments that I can fit into my Forth curriculum!

    Rick
Sign In or Register to comment.