Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 10:09 02 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CMM2: V5.05.04b3a: CSUBs - not for the faint hearted!!!!

     Page 3 of 5    
Author Message
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1133
Posted: 09:57am 18 Aug 2020
Copy link to clipboard 
Print this post

Hi Gerry,

thank you for this contribution! Looks promising!  

BUT maybe I'm missing something?`After "Merge" or "Join" I get an error message:

  Quote  Run Batch failed with error 18. No further files available


The C-code file compiles without issues if I use the old Make-file method.

Any idea?

Kind regards
Michael
Edited 2020-08-18 20:12 by twofingers
 
GerryL
Newbie

Joined: 24/01/2019
Location: Australia
Posts: 31
Posted: 04:08am 19 Aug 2020
Copy link to clipboard 
Print this post

Hi Michael,
I think my response I sent this morning maybe got lost so I'll repeat.  

It was my bad.

I think I know what the issue is, can you place the linker script file, arm-gcc-link.ld, in the folder above the \bin folder where is currently should reside so its in same folder as CSubGen.bat (this bat file is generated by my program).

If this resolves the issue then I will fix the program so it aligns with the instructions.

Gerry
 
capsikin
Guru

Joined: 30/06/2020
Location: Australia
Posts: 341
Posted: 05:23am 19 Aug 2020
Copy link to clipboard 
Print this post

  thwill said  
  abraxas said  As long as it's possible for the CMM2 firmware to bundle in a C compiler and a linker ...


This is just idle stirring of the pot ...

Why would this have to be in the firmware? If you have the skills and tenacity then the compiler and linker could be written in BASIC with or without CSUBs as you desire. However in general people don't just knock up a C compiler overnight and as yet nobody has volunteered ... and no, I'm not looking at you Peter, you should kick-back and enjoy your laurels.

The addition of CSUBs offers other possibilities. I believe a FORTH or for that matter Z-machine interpreter could be implemented in the form of a CSUB and embedded in a BASIC program and used to run code faster than interpreted BASIC alone without the need to supply ARM machine-code.

I kind of like the idea of making programs mostly in BASIC, but having some small FORTH routines where speed is needed. The main calculation loop in a fractal program, for example.

FORTH is a simpler language than C in principle but I find it quite tricky to read large amounts of code in it. There was an old ZX81-style computer called the Jupiter Ace that had it built in instead of BASIC.

I'd probably rather just stick to BASIC rather than mix languages though, for most programs.
  Quote  
If you want something editable inline with BASIC (and you don't want a pre-processing or transcompiling step) then I would imagine it would probably need a very simple syntax and ~1:1 relationship with ARM machinecode so that the compiler/assembler could be squeezed into the firmware, i.e. either (a subset of) ARM assembler itself or some "made up assembler-like" language. Also given that MMBasic is already pushing on its design limit in terms of number of tokens and other complexity you would probably end up having to do a significant rewrite with all the problems with compatibility and adoption that would entail.

Peter if you are reading this is there any significant space left for firmware or is it tinkering room only? the answer to that might close down the conversation pretty quickly.

Regards,

Tom

I'm not so keen on using assembly language, partly because it's not portable, but it would be kind of reminiscent of 80's microcomputers. The BBC even had an assembler built in. You could have the assembler as a separate program, written in BASIC, if it's not built into the firmware.
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1133
Posted: 08:50am 19 Aug 2020
Copy link to clipboard 
Print this post

Hi Gerry,
the linker script file, arm-gcc-link.ld, was already in both folders.
There is no "CSubGen.bat".
I suspect a path issue ...
But let us wait if more users encounter problems.

Regards
Michael
 
GerryL
Newbie

Joined: 24/01/2019
Location: Australia
Posts: 31
Posted: 05:09am 20 Aug 2020
Copy link to clipboard 
Print this post

Thanks Michael, it’s a bit odd that the batch file is not in the ‘9 2020-q2-update’ folder.
When activated my debugging log file gives all the correct file paths when I run the application on my system with the batch file, CSubGen.bat, in the parent folder to the linker/compiler (i.e C:\Program Files (x86)\GNU Arm Embedded Toolchain\9 2020-q2-update).
If you selected an incorrect linker/complier path the application would flag this as it checks for arm-none-eabi-gcc.exe and arm-none-eabi-ld.exe being there. Not sure if it’s a permission issue in the program files folders.

As you say let’s leave it for the time being.

Gerry
 
chris
Regular Member

Joined: 24/08/2020
Location: United Kingdom
Posts: 54
Posted: 10:39pm 16 Sep 2020
Copy link to clipboard 
Print this post

I'm having trouble using the compiler. The code sample I put in the "main.c" file is the code sample in the first message in this thread.

I added the compiler binary path to the PATH environment variable, and restarted the command prompt window, then I executed the following with the following results:


C:\utils\cmm2ccompiler>arm-none-eabi-gcc -c -mcpu=cortex-m7 -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -Wall -ffunction-sections -O0 -fPIC -Wno-main -I. main.c -o main.o

arm-none-eabi-gcc: fatal error: cannot execute 'as': CreateProcess: No such file or directory

compilation terminated.



I searched for the error message online and found a reference to 'binutils' but I don't know if or how I should or can install this package.

https://stackoverflow.com/questions/56801179/g-gcc-9-1-0-fatal-error-cannot-execute-as-execvp-no-such-file-or-directo

I'm running Windows 10, 64-bit edition.

UPDATE - NOW RESOLVED: The problem was that I was installing the GCC ARM compiler from the zip file download, which apparently doesn't install the dependencies that the compiler requires. Be sure to install from the .exe version.
Edited 2020-09-17 09:16 by chris
 
LeoNicolas

Guru

Joined: 07/10/2020
Location: Canada
Posts: 445
Posted: 06:52am 08 Oct 2020
Copy link to clipboard 
Print this post

Hey

Thank you for this amazing thread... following these instructions I was able to create my first CSUB :D

I checked the ARMCFunctions.h and there are some functions missing, like triangle. Is there a new header file version?

I'm a Linux user, it will be nice to have tools that supports multiple plataform, maybe we can create a csub gen tool in python or other multi plataform language, what do you think?
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8592
Posted: 07:29am 08 Oct 2020
Copy link to clipboard 
Print this post

  Quote  I checked the ARMCFunctions.h and there are some functions missing, like triangle. Is there a new header file version?

Every function exposed in the header file needs code including in MMBasic to support it. It isn't as simple as just adding things to the header. I'm happy to consider things for inclusion but the shutter is just about to come down on V5.05.06 so you need to get in quickly with any requests
 
Sasquatch

Senior Member

Joined: 08/05/2020
Location: United States
Posts: 296
Posted: 03:24pm 08 Oct 2020
Copy link to clipboard 
Print this post

If you could expose the VideoColor (8,12,16 color bits) variable that would be great!
-Carl
 
LeoNicolas

Guru

Joined: 07/10/2020
Location: Canada
Posts: 445
Posted: 04:25pm 08 Oct 2020
Copy link to clipboard 
Print this post

The drawing routines are welcome. For fast drawing in my 3D API I'll use them in CSUBs routines.
Polygon, Triangle, Circle, Box, Arc  
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1133
Posted: 05:01pm 08 Oct 2020
Copy link to clipboard 
Print this post

  LeoNicolas said  The drawing routines are welcome. For fast drawing in my 3D API I'll use them in CSUBs routines.
Polygon, Triangle, Circle, Box, Arc  

I don't know if it helps, but at least you have a function DrawPixel() and the source code.

As far as I understand it, any change in "CFunctions.c" can lead to incompatibility with earlier versions and should therefore be done with care. But Peter will already know that, I am confident.

Regards
Michael
Edited 2020-10-09 03:44 by twofingers
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8592
Posted: 05:08pm 08 Oct 2020
Copy link to clipboard 
Print this post

  Quote  If you could expose the VideoColor (8,12,16 color bits) variable that would be great!

Yes

  Quote  Polygon, Triangle, Circle, Box, Arc

Drawrectangle (Box) already exists
Circle and Triangle - yes
Polygon and Arc - don't have suitable primitives and in any case there will be little advantage in calling in a CFunction as the parsing overhead is minimal
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1133
Posted: 05:45pm 08 Oct 2020
Copy link to clipboard 
Print this post

@Peter
MMBasic has only the ability to use the RUN command with a string literal (RUN "FNAME.BAS") I can't use it with a string variable (eg RUN FName$). Do you think there is a way to circumvent this restriction - by changing the firmware or a CSub? It could be useful in making a better filemanager.

BTW. The MMBasic for the Maximite 1 offers the opportunity to access the keyboard buffer with the Peek function (eg Peek (KBUF, +/- offset). There is an analog option for the CMM2?
  Quote  The input keystroke buffer is KBUF, the position of the head of the keystroke queue is KHEAD and the tail is KTAIL (the buffer is 256 bytes long).


Thanks!
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8592
Posted: 05:56pm 08 Oct 2020
Copy link to clipboard 
Print this post

  Quote  MMBasic has only the ability to use the RUN command with a string literal (RUN "FNAME.BAS") I can't use it with a string variable (eg RUN FName$). Do you think there is a way to circumvent this restriction - by changing the firmware or a CSub? It could be useful in making a better filemanager.


No see the original thread for why.

  Quote  BTW. The MMBasic for the Maximite 1 offers the opportunity to access the keyboard buffer with the Peek function (eg Peek (KBUF, +/- offset). There is an analog option for the CMM2?


No - explain a use case that can't be satisfied with other capabilites
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3848
Posted: 06:07pm 08 Oct 2020
Copy link to clipboard 
Print this post

  matherp said  
  Quote  MMBasic has only the ability to use the RUN command with a string literal (RUN "FNAME.BAS") I can't use it with a string variable (eg RUN FName$). Do you think there is a way to circumvent this restriction - by changing the firmware or a CSub? It could be useful in making a better filemanager.


No see the original thread for why.


I'm probably missing some context, but at the risk of contradicting Peter try this:
Execute("Run " + Chr$(34) + f$ + Chr$(34) + ", " + cmdline$)


Best wishes,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1133
Posted: 06:08pm 08 Oct 2020
Copy link to clipboard 
Print this post

  matherp said  No see the original thread for why.

Any clue where to find it?

  Quote  BTW. The MMBasic for the Maximite 1 offers the opportunity to access the keyboard buffer with the Peek function (eg Peek (KBUF, +/- offset). There is an analog option for the CMM2?


No - explain a use case that can't be satisfied with other capabilites
In the old days we (incorrectly) used the keyboard buffer to do actually impossible things. Eg to start a program (RUN FName$).

Michael
 
LeoNicolas

Guru

Joined: 07/10/2020
Location: Canada
Posts: 445
Posted: 07:34pm 08 Oct 2020
Copy link to clipboard 
Print this post

The idea to have the ability to call drawing routines on CSUB is because I need to perform a huge number of loops, calculations, and drawing API calls for rendering the 3D objects.
When we think on only a few calls is not a problem to do it with pure basic, but for this scenario, an entire C routine will be better.
Edited 2020-10-09 05:36 by LeoNicolas
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1133
Posted: 07:47pm 08 Oct 2020
Copy link to clipboard 
Print this post

@Tom

That's GREAT! Thanks!  
I can confirm that it works!
One step closer to a better file manager.

@Leo
  Quote  The idea to have the ability to call drawing routines on CSUB is because I need to perform a huge number of loops, calculations and drawing api calls for rendering the 3D objects.
When we think on only a few number of calls is not a problem do it with pure basic, but for this scenario an entire C routine will be better.

I think your thought is correct.

Michael

PS:
@Peter

The manual says:
  Quote  Run the program 'file$' held on the SD card. Note that 'file$' must be a string constant (ie, "MYPROG.BAS") including the quotes required around a string constant. It cannot be a variable or expression.

I suggest including Tom's proposal in the manual. Thanks!
Edited 2020-10-09 06:01 by twofingers
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3848
Posted: 04:15pm 07 Mar 2021
Copy link to clipboard 
Print this post

Hi folks,

After a couple of weeks C bashing on my "Top secret project" (boy was I rusty in "C" after 20 years) I'm finally going to see whether I can build it as a CSUB and hopefully be able to talk about it (as either a success or failure) in less than a week.

To avoid frustration, can someone (sorry Peter, that probably means you) confirm or deny:

1. The linker file I should use is still the one attached to the first post in this thread.

2. The options for converting the .elf file to CSUB are:
   * MMBasic for DOS running "armcfgenV143.bas" (included in the CMM2 firmware), or
   * @GerryL's CSUBGen.exe running on Windoze (or does this call out to the former ?)

Also IIRC was there some function that the "C" code needs to call regularly to tell the firmware that it is still "alive" otherwise the CMM2 resets (or is it locks up?)

Thanks,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1133
Posted: 04:43pm 07 Mar 2021
Copy link to clipboard 
Print this post

  thwill said  ...
Also IIRC was there some function that the "C" code needs to call regularly to tell the firmware that it is still "alive" otherwise the CMM2 resets (or is it locks up?)
...

I think what you mean is called "RoutineChecks()".

  Quote  CSUBs must call routinechecks() every millisecond or so both to keep
the USB keyboard active and also ensure the watchdog doesn't trigger.
CSUBs that run to completion within a couple of milliseconds can
ignore this.

http://geoffg.net/Downloads/Maximite/Colour_Maximite_2_User_Manual.pdf

Regards  
Michael
 
     Page 3 of 5    
Print this page
© JAQ Software 2024