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

TAQOZ - Tachyon Forth for the P2 BOOT ROM

1242527293038

Comments

  • msrobotsmsrobots Posts: 3,701
    edited 2019-07-21 08:33
    well I have TAQOZ in RAM loaded together with my user-program via P2load, not loaded from SD so I guess I need to specify a filename for BACKUP. Then I can use that saved binary instead of _BOOT_P2.BIX which I currently link to my program as binary.

    And then AUTO EMBED would do the trick and TAQOZ starts, switches to mailbox and starts my FastSpin program, presenting itself as a virtual serial device there without using pins. Perfect.

    Another minor question. A result from TAQOZ say sending 2 3 + . <cr> results in

    --- 5 ok
    TAQOZ#

    what would I need to do to get rid of --- and ok <cr> TAQOZ#, I would like to have 5 <cr> without all the decoration?

    Anyways, almost there!

    Mike
  • oh @"Peter Jakacki" it worked.

    reformatting a SD, putting a _BOOT_P2.BIX on it, running my program entering my words adding AUTO EMBED and finally doing a BACKUP BIX created the binary I needed. Except I need to run at 115200 or have garbage on the screen, that might be solvable. Spin2Gui standard setting for terminal is 230400.

    This is absolutely cool. Thank you very much.

    Mike
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2019-07-21 10:06
    To kill the echo
    flags C~
    

    To kill the prompt (TAQOZ# )
    ' NOP uprompt W!
    

    to kill the accept ( ---)
    ' NOP uaccept W!
    

    to kill the ok response - actually sets linenumber mode
    $C9 REG W++
    

    All together - just add this as part of the mailbox switching word.

    uprompt and uaccept are user vectors which are normally zero and then use the default action.
    $C9 REG is task register $C9 = line number which is used by the default prompt routine which is now disabled but checked by OK
    bit 0 of flags is echo

    BTW, I don't use a BIX as I just use the MBR to store the file. BU by itself will do this. You can also rename the BIX file after you give yourself RW permissions on the previous line.
    RW
    RENAME _BOOT_P2.BIX _BOOT_P2.BIN
    


  • msrobotsmsrobots Posts: 3,701
    edited 2019-07-21 10:18
    oh cool, hier ein kleines demo, Terminal auf 115200

    the echo, yes, I had to catch that at TX (from my side RX for TAQOZ) to send strings. the blocking is nice, but one has to be aware of that.

    so I need

    flags C~ ' NOP uprompt W! ' NOP uaccept W! $C9 REG W++

    and would get : 5 <cr> I will try that, nice.

    Could you (or can I?) create a binary starting at 160 Mhz and using 230400 baud? That is Spin2Gui's standard.

    Mike
  • changing the output worked also perfect, now remains to change the clockfreq to 160Mhz instead of 80Mhz and the boot-console to 230400 instead of 115200.

    Then I am perfectly happy and can explore TAQOZ from my trusted and known environment.

    Mike
  • Good to hear you are having some success. I could add this as a word to the extensions as well as a word to flip it back again. Maybe something like:
    pub REMOTE		flags C~ ' NOP uprompt W! ' NOP uaccept W! $C9 REG W++ ;
    pub LOCAL		1 flags SET uprompt W~ uaccept W~ $C9 REG W~ CON ;
    

    I will try to think of something better in the meantime but I am always happy to help those who give it a go and besides, doing it this way I don't have to try to guess whether it is suitable since I am only "assisting" :)

    230400 CONBAUD changes the baud rate instantly and you could do a backup to lock it in or alternatively specify this baud rate in your startup. Same with the clock, just say 160 P2MHZ which also adjusts the console baud rate to suit the new clock. I use P2MHZ for the P2 clock since MHZ is a general smartpin function that sets the pin to NCO mode etc.

    From this definition you can see that M is the "mega" suffix that simply multiplies the value supplied by 1 million and passes the result to CLOCK.
    pub P2MHZ		M CLOCK ;
    
  • MJBMJB Posts: 1,235
    edited 2019-07-21 15:44
    msrobots wrote: »
    changing the output worked also perfect, now remains to change the clockfreq to 160Mhz instead of 80Mhz and the boot-console to 230400 instead of 115200.

    Then I am perfectly happy and can explore TAQOZ from my trusted and known environment.

    Mike

    If you provide a way to switch your serial console transparently through to Taqos (can be via the mailbox).
    By using Peters new REMOTE / LOCAL words.
    You could still develop Taqos oneliners interactively - so having best of both worlds.
  • Backup, in this context is really "application create", when we think about FORTH and how the words are defined to produce a specific outcome. It's a state save.

    Positing this realization for others wrapping their head around FORTH.

    It's a tiny OS, language and application all in one.

  • what would I need to do to replace CON by MBX thus preventing CON using the serial pins and using the mailbox instead?

    I could then replace CON with a non-blocking mailbox, start TAQOZ not touching serial (and writing garbage on the screen depending on used baud rate) and after my startup finished replace CON with a blocking Mailbox.

    my understanding of FORTH thinks that I can redefine a word thus overwriting the existing one with a new one, correct?

    This TAQOZ stuff is interesting.

    Mike
  • MJB wrote: »
    msrobots wrote: »
    changing the output worked also perfect, now remains to change the clockfreq to 160Mhz instead of 80Mhz and the boot-console to 230400 instead of 115200.

    Then I am perfectly happy and can explore TAQOZ from my trusted and known environment.

    Mike

    If you provide a way to switch your serial console transparently through to Taqos (can be via the mailbox).
    By using Peters new REMOTE / LOCAL words.
    You could still develop Taqos oneliners interactively - so having best of both worlds.

    Yes, I can do that already, but this is quite useless since you will need to write a new image to disk copy the file Back to your PC and recompile your FastSpin program. Doable but complicated.
    I think more about a static base TAQOZ and sending definitions of words or just one-liners from the user-program to TAQOZ and back.
    But one can also send a one-liner to load some extension from SD into the empty TAQOZ, I guess.

    thanks @"Peter Jakacki".

    Mike
  • MJBMJB Posts: 1,235
    msrobots wrote: »
    what would I need to do to replace CON by MBX thus preventing CON using the serial pins and using the mailbox instead?

    I could then replace CON with a non-blocking mailbox, start TAQOZ not touching serial (and writing garbage on the screen depending on used baud rate) and after my startup finished replace CON with a blocking Mailbox.

    my understanding of FORTH thinks that I can redefine a word thus overwriting the existing one with a new one, correct?

    This TAQOZ stuff is interesting.

    Mike

    Hi Mike,
    you are already so deep into it.

    Just take all the Taqos source files into an editor and search for the words you are interested in.
    Like CON
    in file TAQOZ (stable).spin2
    byte 3, "CON" ,t
    word _CON
    so the CON word is performed by wordcode _CON

    so search for _CON
    _CON word rg+uemit,CLRL,EXIT

    which is just the internal representation for
    pub CON uemit ~ ;

    which simply wipes out the uemit and ukey vectors (2 words - here as a long) that you set up with all your effort ;-)

    so you want to redefine CON to do MBX instead to restore the mailbox should it have been altered by s.o.

    no time to research more and no HW to test, but s.th. like:
    ' MBX ' CON W! before the BACKUP might do the job.
  • MJBMJB Posts: 1,235
    @msrobots
    you want a \dev0 for the startup messages?

    ' DROP uemit W! might do the job
  • here my current definitions on a empty TAQOZ 64K
    $10.000 := incon
    $10.002 := outcon
    : GETCON ( -- char ) incon W@ DUP IF incon W~ THEN >B ;
    : SENDCON ( char -- ) BEGIN outcon W@ 0= UNTIL $100 OR outcon W! ;
    : SENDNUL ( char -- ) DROP 0 outcon W! ;
    : MNB ' GETCON ukey W! ' SENDNUL uemit W! ;
    : MBX ' GETCON ukey W! ' SENDCON uemit W! ;
    : EMBED flags C~ ' NOP uprompt W! ' NOP uaccept W! $C9 REG W++ MBX ' MBX ' CON W! 63 PIN MUTE 62 PIN MUTE $10004 1 COGINIT ;
    AUTO EMBED ' MNB ' CON W! BACKUP BIX

    creates a embedded binary but still sends out TAQOZ start lines over serial at 115200.

    where do I find a source file for TAQOZ I just found the _BOOT_P2.BIX without source.

    Mike
  • MJB wrote: »
    ' MBX ' CON W! before the BACKUP might do the job.

    It does indeed and I can interactive type in CON into my FastSpin Terminal without loosing my mailbox.

    Another step done, thank you @MJB.

    Mike
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2019-07-22 06:33
    The trouble with simply overwriting the first wordcode of CON is that it still does a W~ before it exits which clears "a" 16-bit hub memory location, that is, whatever is on top of the stack, even empty, that it treats as an address. There is the REVECTOR word which does the same thing except it sets the "jump" bit b0 of the normally even wordcode before it overwrites the first wordcode of the destination. So try REVECTOR CON MBX.
    TAQOZ# SEE CON
    
    F8E3: pub CON
    126C: FE10     REG $10
    126E: 1048     ~
    1270: 004D     EXIT
          6 bytes 
     ---  ok
    TAQOZ# REVECTOR CON MBX ---  ok
    TAQOZ# SEE CON
    
    F8E3: pub CON
    126C: 2383     MBX ; 
          2 bytes 
     ---  ok
    TAQOZ#
    


    All the links to my P2 folders of which there is tons of hardware and software are mentioned in my sig. However I decided that I would unclutter it somewhat by creating a new TAQOZ folder which includes not only the P2ASM kernel but also a Forth folder. I just need to add a README yet. (DONE)
  • MJBMJB Posts: 1,235
    edited 2019-07-22 08:47
    The trouble with simply overwriting the first wordcode of CON is that it still does a W~ before it exits which clears "a" 16-bit hub memory location, that is, whatever is on top of the stack, even empty, that it treats as an address. There is the REVECTOR word which does the same thing except it sets the "jump" bit b0 of the normally even wordcode before it overwrites the first wordcode of the destination. So try REVECTOR CON MBX.
    TAQOZ# SEE CON
    
    F8E3: pub CON
    126C: FE10     REG $10
    126E: 1048     ~
    1270: 004D     EXIT
          6 bytes 
     ---  ok
    TAQOZ# REVECTOR CON MBX ---  ok
    TAQOZ# SEE CON
    
    F8E3: pub CON
    126C: 2383     MBX ; 
          2 bytes 
     ---  ok
    TAQOZ#
    


    All the links to my P2 folders of which there is tons of hardware and software are mentioned in my sig. However I decided that I would unclutter it somewhat by creating a new TAQOZ folder which includes not only the P2ASM kernel but also a Forth folder. I just need to add a README yet. (DONE)

    I knew it ;-) ... just was too late to dig deeper ...

    so
    ' MBX 1+ ' CON W!
    would do the job ? Making the CALL into a JMP

    alternatively I thought about:
    ' MBX ' CON W!
    ' CON 2 + W@ ' CON 1+ W!
    to copy an EXIT wordcode after the MBX


    and
    $FE10 ' CON W!
    then get's me the old CON back ...

    great to understand how it works inside



  • @MJB - you know you really want a P2 - you do. When are you going to stop being so busy and have some P2 fun instead?
  • MJBMJB Posts: 1,235
    @MJB - you know you really want a P2 - you do. When are you going to stop being so busy and have some P2 fun instead?

    I take this as a yes to my message above then ...

    I am waiting for the P2D2 with Dev-Board&Wiz5500&WiFi ...
    with the final P2 from this guy in downunder ... ;-)

    Still have P1 projects waiting ...

  • @MJB - Yes, I will have that with the new silicon if it all works since the chips are available around then. I will publish details of the dev board on the P2D2 thread. Please let me know if there is some features you would like, I may just include it.
  • Peter,

    I am a long time lurker and a long time Forth advocate. What you have done is amazing to me! I have been playing some with my P2ES and TAQOZ is my platform of choice.

    Please continue to share with us your updates and adventures.

    THANKS!
  • Hmm
    
    ( Entering terminal mode.  Press Ctrl-] to exit. )
    
    -------------------------------------------------------------------------------
      Parallax P2  *TAQOZ* Extensible Firmware  V2.0 'CHIP' 80MHz 190212-1700
    -------------------------------------------------------------------------------
    TAQOZ# $10.000 := incon ---  ok
    TAQOZ# $10.002 := outcon ---  ok
    TAQOZ# : GETCON ( -- char )   incon W@ DUP IF incon W~ THEN >B ; ---  ok
    TAQOZ# : SENDCON ( char -- )  BEGIN outcon W@ 0= UNTIL $100 OR outcon W! ; ---  ok
    TAQOZ# : SENDNUL ( char -- )  DROP ; ---  ok
    TAQOZ# : MNB    ' GETCON ukey W! ' SENDNUL uemit W! ; ---  ok
    TAQOZ# : MBX    ' GETCON ukey W! ' SENDCON uemit W! ; ---  ok
    TAQOZ# : EMBED flags C~ ' NOP uprompt W! ' NOP uaccept W! $C9 REG W++ REVECTOR            error in EMBED  at REVECTOR CON MBX 63 PIN MUTE 62 PIN MUTE $10004 1 COGINIT ; *error*
    
    
    -------------------------------------------------------------------------------
    TAQOZ#
    

    what is wrong with REVECTOR CON MBX ?

    Mike
  • Aah I see no REVECTOR there in 64K image where do I find the sources?

    Mike
  • msrobotsmsrobots Posts: 3,701
    edited 2019-07-22 22:15
    OK looking thru es.spin2 I see a lot of trouble for me. Right now I load and start my own program at $10000 right smack into TAQOZ buffers. Not good for coexistence.
    SDBUFS		= $10000		' allocate 4k for buffers
    '		: $11000
    rxbuffers       = $11000		' SERIAL RX buffer
      rxsize          = $1000
    datram		= $12000		' start of data memory - user variables '
    
    ' ^^^^^^^^^^ '
    ' DICTIONARY '
    ramdict         = $0F380                 ' dictionary can be moved elsewhere at runtime'
    
    bmporg		= $30000		' start of bmp header, palette, and bitmap data '
    
    flashpart	= $E0000.
    
    to me it looks like bmporg will just be used if VGA is enabled, so I might not need it without VGA pins set. But flashpart seems to be a buffer at $E0000. Not good for coexistence. I fought a lot to give TAQOZ the lower HUB RAM and now it wants even $E0000...?

    I hope I misread or can change that to some lower HUB address.

    FastSpin hicks up at line
    3866 word COGID
    and won't compile es.spin2. Not sure why. trying Pnut results in "COG label must be long aligned" at rxwr
    rxrd word 0
    rxwr word 0
    lastkey word 0
    athen word 0

    It's a ruff ride so far but we are getting farther...

    Mike
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2019-07-23 00:09
    flashpart is an area in serial Flash that I like to store an image of TAQOZ to, nothing more. Even the ROM version can use this and a ^R will restore the Flash version. BTW, SFBU will backup to Flash and SFRE or ^R will restore it.

    REVECTOR is in the TAQOZ Forth source folder (the part that is pasted in and compiled by the kernel running on the P2) and it is an immediate word which means that it executes immediately rather than compiles as regular code. So it's only good as a user command by itself although you can put it in your source code but on a line by itself outside of a definition. It's like a compiler directive.
    Forth defintiions start with : which you can use in TAQOZ but the dictionary in TAQOZ is enhanced and separate and you can define a word like we do in Spin as pub or pri. While TAQOZ compiles the word normally it marks the dictionary header so that pri word can be culled during a RECLAIM which also makes them "private" :) To mark a dictionary header as a special immediate word normally required the word IMMEDIATE in Forth but I prefer using pre in place of : or pub to indicate the preemptive nature of the word.

    BTW, the ' symbol is an immediate word too and it normally reads the next word in the input stream and compiles the code address of that. All the building words such as :/pub/pri/pre/; etc are immediate.
    pre REVECTOR ( <target> <new> -- ) [C] ' [C] ' [G] 1+ SWAP W! ;
    
    (NOTE: if you are curious about what [C] is, it is just another immediate word to force the following immediate word to compile, not execute)

    To embed the same into your code you just need to do this manually.
    ' NEW_WORD 1+ ' OLD_WORD W!
    
    The 1+ just adds one to the address to set bit0 of the address to make it a jump rather than a call. Also, 1+ is just a fast way of setting bit0 on an even address rather than a 1 OR operation.

    P.S. I'm interested with how you go with compiling all this with fastspin. I will have to have a look at it myself too.
  • msrobotsmsrobots Posts: 3,701
    edited 2019-07-23 00:39
    well I simply trick fastspin.

    Spin (even on P1) has the file:command. It simply loads a binary from file into your DAT block. So I do this
    DAT
    	ORGH	0
    	ORG	0
    	file 	"_BOOT_P2.BIX" '"taqoz.binary" '"_BOOT_P2.BIX"
    	ORGH	$10004			' $10000 is Mailbox between TAQOZ and Rest of Program
    	ORG	0
    	file 	"TQ_Test.binary"
    

    So compiling and running that will load TAQOZ first, leaves a long for the mailbox and loads my binary just behind it, waiting to be called by TAQOZ.

    if told with cmdline switch -H 0x10004 -E FastSpin creates a binary compiled for starting at HUB $10004 without all those $10004 empty bytes in front of the binary. That is what I do with my fastspin program.

    And the above trick glues them together like a linker...


    what should
    word COGINIT do in your source at line 3866, I think fastspin complains because it is a assembler instruction I guess. Pnut does not compile es.spin2 either.

    So I will go back to ' NEW_WORD 1+ ' OLD_WORD W! this did work.

    I also might need to change my MBX to something else since you already have MBX in use.

    on the other hand I may adapt to your different mailbox approach, being able to switch between blocking and nonblocking output may come in handy.

    Good to know that flashpart is not a HUB address. If I would like to use VGA also, where would the free HUB memory begin? And where without?

    I can chose my start address and don't want to clobber TAQOZ nor being destroyed by it.

    Because currently I can't compile from source and have to use one of the existing "CHIP" binaries 190212-1700 (_boot_P2.bix) or -190711_0930 (es.bin)

    Mike
  • Looks like that was a bug, it should be _COGID to distinguish it from the PASM COGID
  • msrobotsmsrobots Posts: 3,701
    edited 2019-07-23 01:24
    aah cool, will try

    still complaining

    C:/P2/test/es.spin2(255) error: Source out of range for relative branch tjnz
    C:/P2/test/es.spin2(2595) error: label athen in COG memory not on longword boundary
    C:/P2/test/es.spin2(2821) error: label athen in COG memory not on longword boundary

    But is missing rxwr also in COG memory not on longword boundary, that is what Pnut complais about

    Pnut complains too. You want to create HUB labels on word boundaries after org 0, that dies since both compiler assign HUB and COG labels inside of COG code and there word boundaries are a no go for labels in COG memory.

    trying Pnut results in "COG label must be long aligned" at rxwr does not coplain about line 255
    rxrd word 0
    rxwr word 0
    lastkey word 0
    athen word 0

    line 255 is easy to fix
                    tjnz    X,#.jmpINITSTKS ' was  tjnz    X,#@INITSTKS
    ' COG 0 CONSOLE '
    		call	#InitSerial
    .jmpINITSTKS	jmp	#@INITSTKS
    

    not sure how to fix your word boundaries
  • I've been using Dave Hein's p2asm and loadp2 which just work but I see now that PNut is not happy with the final spin2 file. It seems that some of the includes have LF line ending and other CRLF. So I have fixed them all up to CRLF so PNut doesn't go nuts. There's also the alignment thing it is complaining about with rxwr etc so I made these into an orgh and changed the res word.

    There were a few other things such as "tjnz X,#@INITSTKS" that Pnut is complaining about so I am still checking.
  • msrobotsmsrobots Posts: 3,701
    edited 2019-07-23 01:48
    orgh
    rxrd word 0
    rxwr word 0
    lastkey word 0
    athen word 0

    and moving it behind
    mbxs res 16 ' inp0 out0 inp1 out1 etc '
    seems to solve the problem with fastspin, now see if it runs...

    FastSpin seems to have no problem with line endings, it is build for Linux and Windows and @ersmith does some wonderful work

    Yes, TAQOZ copiled and run from Spin2Gui/fastspin.
    ( Entering terminal mode.  Press Ctrl-] to exit. )
    x
      Cold start
    -------------------------------------------------------------------------------
      Parallax P2  *TAQOZ* Extensible Firmware  V2.1 'CHIP' 160MHz 190711-0930
    -------------------------------------------------------------------------------
    TAQOZ#
    
    

    Enjoying,

    Mike
  • Confidence: the feeling you have before you understand the implications.

    So following @"Peter Jakacki"'s advice I tried BU a couple of days ago. Now I have some TAQOZ in the MBR and have to remove the SD all the time, else it hangs on loading from fastspin.

    The boot from MBR solution is pretty solid, it survives even formatting in Windows. :innocent:

    As for BACKUP, currently I need to HAVE a _boot_P2.BIX on SD to BACKUP into it. Is there a way to tell BACKUP to create and use some file I could specify, something like BACKUP "filename" instead of BAKUP BIX?

    And I do not have a see, this needs some work.

    fun,

    Mike
Sign In or Register to comment.