Shop OBEX P1 Docs P2 Docs Learn Events
TAQOZ - Tachyon Forth for the P2 BOOT ROM - Page 16 — Parallax Forums

TAQOZ - Tachyon Forth for the P2 BOOT ROM

1131416181938

Comments

  • Hey Peter, please explain the period above.

    Thanks.
  • msrobotsmsrobots Posts: 3,709
    edited 2018-12-29 21:36
    Somehow @"Peter Jakacki" is wiggling around the idea that someone does not want to program in TAQOZ but just use it as helper.

    The example was nice, but the question remains, how to define a word calling a assembly stub sitting somewhere in HUB, loaded by some other COG outside from TAQOZ running on COG 0. And how to call into TAQOZ from another Process running on another COG not using TAQOZ.

    @Cluso99 has done this with his debugger, monitor, serial and sd routines, so using this from your own program is possible, but sparely documented yet. But 100% useful.

    It would be very nice if one could use TAQOZ the same way, being able to run software in the language of your choice, using @Cluso99's ROM routines and using TAQOZ as a subsystem, running in COG 0 to call TAQOZ oneliners from programs running in COG 1-7.

    How does TAQOZ uses the HUB-Memory?

    What I guess right now is that it gets loaded into the ROM area and then copies itself into the lower RAM up to 8K or something.

    Does TAQOZ then still need the ROM area or is it independent of that and the ROM/RAM is up to grabs for own code?

    What other Memory areas are used by a running TAQOZ and @Cluso99's Monitor/Debugger?

    And more important what areas are NOT used by the above and free to grab and use in a system running on COG 1-7 while having TAQOZ and Monitor/Debugger just nicely running on COG 0, able to look at and tweak your stuff while it is running.

    curious

    Mike
  • Cluso99Cluso99 Posts: 18,069
    edited 2018-12-29 21:44
    TAQOZ is about 12KB and is loaded into the top 12KB of HUB RAM from ROM. Chips boot code is in the first ~1.2KB and then the SD and monitor take about 1.2KB each. When TAQOZ starts it copies itself to HUB $0 before executing.
    Chips boot code copies itself to COG and LUT and executes there.
    The Monitor and SD execute in place in hubexec, but use overwrite Chips HUB boot code as a serial read buffer. Both need COG space for variables - SD uses COG $1C0-$1DF and Monitor uses COG $1E0-$1EF.
    Not sure what the next ROM will be yet.
  • msrobotsmsrobots Posts: 3,709
    edited 2018-12-29 22:03
    Thanks @Cluso99,

    Do you now what other memory areas are needed by TAQOZ and if there is a way to find out what area of the HUB is free to use while TAQOZ and your monitor are running in COG 0?

    My basic Idea is to load my program, leaving enough space for TAQOZ, start my own process in COG1 and then let COG 0 jump into the ROM and start TAQOZ in COG 0 while my program is already running.

    So if we could somehow put TAQOZ in a memory box (or our program) and give it COG 0 then we have 64 smart pins and one smart script sub-system accessible from all languages.

    If I can convince @"Peter Jakacki" to build some simple mailbox interface into TAQOZ, say not just checking serial, but also some mailbox in his own lower ram. And if input comes from there he needs to output to another mailbox. Both need to be fixed Addresses in ROM

    Mike
  • Peter,
    I am trying to figure out how to "load" the extend.fth file that is linked in the documentation. The docs don't mention it anywhere other than the linkat the top.
    I've tried pasting the text, and using teraterm's send file feature. All I get in response is a bunch of ???'s and then it appears to hang, and I have to reset.

    Maybe the docs could have a section explaining how to load the extend.fth file?
  • Roy,
    I downloaded the file and initially opened it in notepad, but since the CR/LF didn't show, I reopened it in wordpad and copy/pasted it to notepad.

    I got into TAQOZ and copy/pasted the entire file (copy, switch to TeraTerm, right clicked where I wanted to paste it and clicked on "ok". The file loaded only showing line numbers and an ok. I checked a couple of extend words and they worked. But I wanted to see the actual loading of the test, so I redid the copy paste (after a cold boot back to TAQOZ) and only copied the file from the first { to the line before the "END". That showed each line being loaded. Each line loaded ok. One thing to check is that your Teraterm is showing a few msec per LINE transmit delay (I use 10msec, Peter uses less.)

    Tom
  • twm47099twm47099 Posts: 867
    edited 2018-12-30 01:03
    potatohead wrote: »
    Hey Peter, please explain the period above.

    Thanks.

    The period pops the top value off the stack and prints it on the terminal (square root of 12345678 squared)

    .S prints all the values on the stack, but leaves them on the stack

  • evanhevanh Posts: 16,023
    edited 2018-12-29 23:57
    Looks like there is also a convention of making print like commands (dictionary words) have a prefixed dot. Like .S above.

    Just been doing some reading and I've discovered that () brackets contain only comments. And those comments are often notes on stacking actions, such that -- is used as a convention within those comments to separate pre-execution unstacking actions from post-execution restacking actions.

  • Thanks twm47099,
    The file, as downloaded from the link in the docs, has only LF line endings, however, you need CR's in the line endings to get things to work right. I loaded the file into WordPad and then copy/pasted from there and everything worked, because Wordpad converts the line endings to be CR+LF. My text editor of choice is notepad++, and it shows the file fine, since it works with either CR or LF or CR+LF line endings, however it doesn't convert the line-endings, so copy/paste from it left things as just LF line endings.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2018-12-30 01:36
    In the next version I will have more memory to have verbose names such as PRINT as an alias for the . symbol which I might find convenient from the terminal but these tiny symbols disappear in source code and make it hard to read. The trick to reading Forth code is more to do with not thinking, that is not thinking you are a compiler parsing a line of code looking for symbols and rules etc. Just read left to right a word at a time where any group of symbols, digits, and characters that are delimited by whitespace is a "word".

    So take this common example which is crammed onto one line although you could spread it over several if you prefer:
    10 FOR CRLF ." HELLO WORLD!" NEXT
    
    If you were typing this in character by character TAQOZ will only assemble a word until it encounters whitespace or a CR. Either way, as soon as has a fully assembled word it will check first to see if it could be a number, as long as it starts with a digit or prefix and ends in a hex digit. So $DEADBEEF is a number but DEADBEEF or $DEADBEEFS is not.
    If it is a number it will convert it in the current radix or prefix and pushes the value onto the data stack.
    In this case it is the default decimal value 10. (It actually compiles this numeric literal but when it runs it pushes the value onto the stack)*

    Next it assembles the FOR word and fails the number test so it searches its dictionary for a match. Once it finds a match it checks the attributes for that entry and in this case compiles the 16-bit code address found in the header, into the next location in code memory.

    Here's a glimpse of a dictionary entry using NFA' to find the name field address of FOR and then dump that, along with the code field address using the ' symbol.
    TAQOZ# NFA' FOR 10 DUMP 
    0001_435D: 03 46 4F 52  18 01 04 4E  45 58 54 31  01 05 3F 4E     '.FOR...NEXT1..?N' ok
    TAQOZ# ' FOR .W $0118 ok
    

    The same happens with CRLF but the ." dictionary attributes indicate that this should be executed immediately rather than compiled, which is usually the case with any words that need to control compilation, much like a directive. The ." executes and compiles the runtime address of a word that will print a literal inline null terminated string which ." continues to compile character by character until it encounters the matching " symbol. That is why ." has a space after it and before the first character since otherwise TAQOZ will throw ."HELLO WORLD" as an error since there is no such "word" in the dictionary.

    Simple so far?
    The NEXT is compiled and since it is the end of the line there is an implicit EXIT or return that is also compiled and then the code that has just been compiled as an open one-liner will execute from the beginning.
    10 onto the stack
    FOR accepts the 10 from the stack as a loop count for NEXT but also saves the address of the next instruction as the address that NEXT will branch to if the count is still not zero. This is equivalent to a DJNZ.
    CRLF generates the CR and LF for a newline (CR only ever returns the "carriage" to the left margin but LF performs a line feed down)
    The runtime word for ." executes printing out the inline characters until the null after which it updates the instruction pointer and continues executing code from after string which is NEXT.
    Using its own loop/branch stack NEXT decrements the count and if not zero takes the branch left by FOR otherwise it will pop the loop stack and continue on to the next instruction which is the implicit EXIT and this returns control back to the CLI.


    Now we can make our code into a new word that becomes part of TAQOZ and we can even see what the compiled code looks like, it's almost like assembly code in that each 16-bit word corresponds to an instruction word.
    TAQOZ# : HELLO  10 FOR CRLF ." HELLO WORLD!" NEXT ;  ok
    TAQOZ#   ok
    TAQOZ# ' HELLO $30 DUMPW 
    02478: F80A 0118 8A62 8F2A  4548 4C4C 204F 4F57     '....b.*.HELLO WO'
    02488: 4C52 2144 0000 0131  0063 014A 2478 F840     'RLD!..1.c.J.x$@.'
    02498: 9202 0063 0063 0000  0000 0000 0000 0000     '..c.c...........' ok
    TAQOZ# ' EXIT .W $0063 ok
    TAQOZ# HELLO 
    HELLO WORLD!
    HELLO WORLD!
    HELLO WORLD!
    HELLO WORLD!
    HELLO WORLD!
    HELLO WORLD!
    HELLO WORLD!
    HELLO WORLD!
    HELLO WORLD!
    HELLO WORLD! ok
    TAQOZ#
    

    EDIT: Here is the dictionary entry for HELLO:
    TAQOZ# NFA' HELLO QD 
    0001_32F8: 05 48 45 4C  4C 4F 78 24  04 73 6B 74  24 72 24 04     '.HELLOx$.skt$r$.'
    0001_3308: 48 54 54 50  6C 24 06 54  45 4C 4E 45  54 66 24 06     'HTTPl$.TELNETf$.' ok
    
    Notice the 78 24 which the $2478 address for the code. Since the dictionary builds downwards the following entries where previously the latest.

    *NOTE: Unlike traditional Forth CLIs, TAQOZ will always compile the line before executing it, which is why we can have loops and conditionals etc that traditional Forths cannot. It also means that it runs the line of code exactly the way it would run within a definition.
  • Roy Eltham wrote: »
    Thanks twm47099,
    The file, as downloaded from the link in the docs, has only LF line endings, however, you need CR's in the line endings to get things to work right. I loaded the file into WordPad and then copy/pasted from there and everything worked, because Wordpad converts the line endings to be CR+LF. My text editor of choice is notepad++, and it shows the file fine, since it works with either CR or LF or CR+LF line endings, however it doesn't convert the line-endings, so copy/paste from it left things as just LF line endings.

    - fixed the end of line.
    I use ATOM editor as it supports projects and folders and is easy enough to create your own syntax highlighting and I even have Sublime style packages added plus vertical tabs since I have so many of them.
  • Thanks Peter,
    After I posted that I found that notepad++ does have the option to convert line endings, it just doesn't do it automatically. It has similar stuff to what you described ATOM as having, only downside is that it's a Windows app (it probably runs under wine though).

    Anyway, been trying out some of your examples from the threads here and such. It's very cool that we can test things out with nothing more than a serial connection and TAQOZ. You've made things easy for us, thanks!
  • evanhevanh Posts: 16,023
    CRLF prints those two end-of-line characters.
    ." prints the following string, excluding the first space as explained.

  • evanhevanh Posts: 16,023
    putchar() equivalent is EMIT
  • I'm having some trouble getting the board to 180 MHz using TAQOZ.
    I paste in the EXTEND file ok and type CRUISE and get this:

    TAQOZ# CRUISE @˚Yi».©†°yÀi$.

    I can no longer send text to TAQOZ.
    Any suggestions?

    J
  • Cluso99Cluso99 Posts: 18,069
    edited 2018-12-30 07:16
    IIRC you need to change the serial baud since the clock change does not change the serial. Peter will need to say how as it's written down and my notes are ~1300km away ;)

    Love how you can use TAQOZ to check out the P2 with only a serial connection :)
  • That's what I was thinking it was.
    Does anyone know how to do this? I've been scouring the forum and making notes but did not find that tidbit.
    j
  • jmgjmg Posts: 15,175
    thej wrote: »
    That's what I was thinking it was.
    Does anyone know how to do this? I've been scouring the forum and making notes but did not find that tidbit.
    j

    Any time you change SysClk you need to re-sync Autobaud.
    In the bootloader that is "> ", not sure if TAQOZ uses the same, but that would make sense.
  • The default baud rate in extend is set to 115200 so if you autobauded into TAQOZ with another baud rate then just let EXTEND know just before you change the clock rate. That way when it sets the new clock rate it will also calculate your desired baud rate. You only need to do this the first time.

    BTW, there is no information passed to TAQOZ about the baud rate, it just leaves it the way it was but sets up its own serial receive ISR. Whatever value that was doesn't tell the baud rate either because RCFAST varies, although you could probably narrow it down to a standard rate.

    So if you connected at 921600 then do this
    921600 CONBAUD CRUISE
    

    I routinely connect at 3M so I do this:
    3 M CONBAUD CRUISE
    
  • Hmmm... Something is still not quite right.
    Pasted EXTEND and got this:

    TAQOZ# 115200 CONBAUD CRUISE –.ö1ò˚.˝˙

    ..and typing doesn't do anything.
    I have my terminal set to 115200.
    I also have DTR and RTS turned ON and no Flow Control set. Should I change any of those?

    j
  • thej wrote: »
    Hmmm... Something is still not quite right.
    Pasted EXTEND and got this:

    TAQOZ# 115200 CONBAUD CRUISE –.ö1ò˚.˝˙

    ..and typing doesn't do anything.
    I have my terminal set to 115200.
    I also have DTR and RTS turned ON and no Flow Control set. Should I change any of those?

    j

    I forgot something I have mentioned a few times already, that is to type P2-ES so that the clock setting routines know to use a 20MHz crystal instead of a 12MHz oscillator.
    In your case if you already have 115200 baud then there is no need to specify this, just the P2-ES part.
    P2-ES CRUISE
    


  • Fantastic !!
    Just to test it all I set my terminal to 230400 and did this:

    TAQOZ# 230400 conbaud p2-es cruise ok

    Works great !!
    Thanks again Peter !!

    J
  • Interesting note, I get a very quiet high pitch squeal from my board when running at 180 MHz (made it easy to know when it was running faster than 20KHz :-)

    Anyone else getting this? Just curious.

    j
  • If the inductor is cracked then this might happen due to harmonics but otherwise it should be very quiet since the switcher runs in the MHz region. Make sure your USB supply isn't dipping too low either as the regulator needs some headroom.
  • I have a binary image for the P2D2 that includes many more extensions and VGA (VGA 256 color) + PS/2 as well as Ethernet. I will see if I can test it out on a P2-ES.
  • I noticed that I had problems with trying to load the P2-ES with a new version of TAQOZ. I am using p2asm and loadp2 which work fine on my P2D2 and while loadp2 seems to work on the ES, I can never get anything to appear. So i thought maybe it's to do with the reset circuit, so I disconnected the cap from the DTR and simply hit the reset button just before I download new code. Works perfectly! I don't think I will connect the reset cap back up as the P2 booter is happy with a manual reset.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2018-12-30 15:59
    Here are a couple of boot images for TAQOZ V1.1 to suit either the P2D2 or the P2-ES. Just rename the file by removing the extra suffix so that you end up with _BOOT_P2.BIX and then just copy it to your SD card and it will boot straight into TAQOZ with the last settings. If you add anything or change the speed from 200MHz or baud rate you can MAKEBOOT to update this file.

    _BOOT_P2.BIX-P2D2
    _BOOT_P2.BIX-P2ES

    If you connect a VGA to P0..4 and a PS/2 to P7=KBDAT then you can type P2PC and work from the VGA and keyboard instead. I will be adding an autorun function to TAQOZ as well. I already have it, to autorun a function such as P2PC for instance:
    AUTO P2PC
    MAKEBOOT
    
  • Peter,
    I want to send a string of 1 and 0's to the pins (in not_Smart mode). I know I can "pin_number HIGH" or "pin_number LOW", but I'd like to do something like "mask pin_number" and just have a bit in the mask = 1 or 0. Reading through the list of words in TAQOZ I can't see if there is a word or words that do that.
    I would appreciate any recommendations.
    Thanks
    Tom
  • twm47099 wrote: »
    Peter,
    I want to send a string of 1 and 0's to the pins (in not_Smart mode). I know I can "pin_number HIGH" or "pin_number LOW", but I'd like to do something like "mask pin_number" and just have a bit in the mask = 1 or 0. Reading through the list of words in TAQOZ I can't see if there is a word or words that do that.
    I would appreciate any recommendations.
    Thanks
    Tom

    Hi Tom, could you be more specific about the serial data. What speed? How many bits? Is it clocked or asynchronous? Is it a defined protocol etc?


  • Peter,
    I am going to experiment with an MCP3202 ADC. While I intend to eventually use the Smart Pin SPI mode, I wanted to first bit bang it as a way learn some more about forth and the P2ES. It is something I've done with other languages and the P1.

    I hope to eventually use the ADC Smart pin mode instead of the 3204.

    Tom
Sign In or Register to comment.