Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arduino GigaR1 build settings #64

Open
EncomLab opened this issue May 14, 2024 · 57 comments
Open

Arduino GigaR1 build settings #64

EncomLab opened this issue May 14, 2024 · 57 comments

Comments

@EncomLab
Copy link

What are the build settings to be used for the Arduino GigaR1?

@slviajero
Copy link
Owner

slviajero commented May 19, 2024 via email

@easyprototype
Copy link

Hi. I am also interested in the build settings for the GigaR1.

I tried the following for BASIC 2.0:
in hardware.h
#define EEPROMSIZE 4096

in language.h
#define BASICFULL

I got the following compilation error:
In file included from C:\Projets\Arduino\ArduinoGIGA\IoTBasic\runtime.cpp:15:0:
runtime.h:739:13: error: conflicting declaration 'typedef int PinStatus'
typedef int PinStatus;
^~~~~~~~~

This error repeats itself over many files.

Thanks :)

@slviajero
Copy link
Owner

slviajero commented Feb 4, 2025 via email

@easyprototype
Copy link

uncomment?

I'm don't understand. Do you mean to put this line in comment so it is no longer compiled?

@slviajero
Copy link
Owner

slviajero commented Feb 4, 2025 via email

@easyprototype
Copy link

Ok, that works! The project has compiled, I have uploaded it into my ArduinoGigaR1 and I am talking to it using CoolTerm! I don't get the welcome message, though :(

The program is 167k (8% of available flash) and uses 49k (9% of available RAM) of RAM.

Now I need to test the I/O and Serial devices. At the moment I am trying to know how much memory BASIC sees but I don't know how. "print himem" returns 127.

One question though: what am I to do with EEPROMSIZE? The Giga doesn't have any EEPROM, just plenty of flash. Do I just define EEPROMSIZE with however space I want to save my programs?

Thanks.

@slviajero
Copy link
Owner

slviajero commented Feb 4, 2025 via email

@easyprototype
Copy link

"print himem" now returns 31999. I also uploaded and executed successfully "battle.bas". That seems to work :)

You know your code very well, thank you very much!

I can write 1s and 0s to digital 2, but writing anything to A0 eludes me...
The "led" label is also functioning. I can turn on and off the user LED.
The "delay" command works.

@slviajero
Copy link
Owner

slviajero commented Feb 7, 2025 via email

@easyprototype
Copy link

Yes, I read that A0 and up are labeled 76+. the AREAD() function works up to A7. From A8 and up it does not seems to function.

PINM, DREAD & DWRITE works for A0 to A7, but not for A8+.

Any AWRITE on pin 76 crashes big time the ArduinoGiga. The red LED starts blinking. I can tell you the exact same thing happens when I perform a analogWrite(76, xx) in the Arduino IDE. So it is not a problem in the BASIC kernel.

I enabled and tried I2C on stream &7. Looking at my scope, that seems to work :)

For the EEPROM problem, thanks for checking it.

My next test is enabling ARDUINOSD and connect a SDCard connector directly on the GIGA, no shield involved. Which pins must/should I use? I must use SPI5 (because SPI1 is 5V). After scanning the IotBasic files, I see nowhere I can specify the Pins for the SD card.

Although, I could use the USB A port with a USB flash drive instead, if that is possible with the BASIC kernel.

Have a nice skiing time :)

@slviajero
Copy link
Owner

slviajero commented Feb 7, 2025 via email

@slviajero
Copy link
Owner

slviajero commented Feb 7, 2025 via email

@slviajero
Copy link
Owner

slviajero commented Feb 7, 2025 via email

@slviajero
Copy link
Owner

slviajero commented Feb 8, 2025 via email

@easyprototype
Copy link

I tried SPI on the central header and it works fine in BASIC with a standard card adapter.

On my side I checked the ArduinoGiga schematics. All SPI lines comes directly unbuffered from the STM32. I will confirm with my scope first on monday but I will use the same SPI port as you. That will simplify things greatly, no more coding involved. Thanks!

I also created a clean code for the startup and memory heuristic. It is checked in already. This code starts the
interpreter with 64kB memory and correct settings.

Thank you for updating tinyBasic for the Giga, I really appreciate.

Although, I could use the USB A port with a USB flash drive instead, if that is possible with the BASIC kernel.

I looked at this and will play with it tomorrow.

That would be grand if it works :)

My next todo after I set up the SD card will be to look how to implement new BASIC commands. I remember I saw somewhere (in the code I believe) that we can do so. Let's face it, I am not using a Giga just for the speed. I want to use the hardware peripherals. I would like to implement a PEEKREG16, POKEREG16, PEEKREG32 and POKEREG32 command in order to access the STM32 registers, which are not 8-bit and not mapped inside BASIC memory. Naming is to be determined, I can go up to 16 characters by default, right?

@slviajero
Copy link
Owner

slviajero commented Feb 8, 2025 via email

@slviajero
Copy link
Owner

slviajero commented Feb 8, 2025 via email

@easyprototype
Copy link

You are going way too fast for me! I can only work on it on monday!

I also added a 32 kB EEPROM now on the I2C. This also works and BASIC says this at startup:

Stefan's Basic 2.0 Memory 65535 32767
print @e
8191

Do you mean you added an external EEPROM chip on the I2C bus, or are you using some EEPROM/flash available on the Giga?

Thank you for pointing me out your tutorial on extending tinyBASIC. I will read it carefully.

The GIGA USB device works now.

I can't wait to try this. If I enable GIGASBFS, I must not enable/use SD Cards, right?

The build in real rime clock of the GIGA also works

Oh, the joy!

The documentation on the GIGA website of Arduino is not that good.

Indeed, that's why I use the STM32H747 datasheets + the GIGA schematics.

Now that I think of it, I have a question: is there a BASIC command that lists all the commands available in the build? In Forth, typing "WORDS" display on screen all the words the system knows and that you can use.

@slviajero
Copy link
Owner

slviajero commented Feb 8, 2025 via email

@easyprototype
Copy link

Not an Online help, just a dump of the keyword strings from the string storage (what is listed at the beginning of ioTBasic.ino). Basically a parser that prints all the tokens instead of finding the one you just typed.

@slviajero
Copy link
Owner

slviajero commented Feb 9, 2025 via email

@easyprototype
Copy link

Hi!

I tried this morning the updated ioTBasic. To begin, I enabled BASICFULL (disabled BASICSIMPLE), ARDUINOPRT, ARDUINOWIRE, ARDUINORTC.

Compilation returned

runtime.cpp:5055:10: fatal error: SoftwareSerial.h: No such file or directory
#include <SoftwareSerial.h>

So I added a " !defined(ARDUINO_ARCH_MBED_GIGA)" to the IF before it.

Everything compiled, downloaded and booted up. Sent stuff on the &4 and &7 stream. Works fine. If I try memory size

print himem
65534

I typed HELP. Beautiful! That's exactly that. From here, you know what your system supports or not. With that you go read the online manual. No need to implement it in the program. Brilliant :)

Next I tried using the real time clock. I am unfamiliar on how to set time. I tried writing directly at @t(x) to set time but the I always read back

print @t$
45:85:85-45/25/65

So I undef ARDUINOWIRE and ARDUINOPRT but kept ARDUINORTC.

Now when I type

print @t$

Basic hangs up, the red LED starts blinking and I have to reset.

Don't know what else to do because of my lack of RTC knowledge so moving on.

Disabled RTC, enabled GIGAUSBFS. Compilation succeeded after I installed the USBHostMbed5 library. Basic now takes significantly longer to boot (show prompt on console after reset).

CATALOG, LOAD and SAVE works, but I must first boot the GIGA with my USB key inserted. That is fantastic. Is there a way to mount/unmount the key in the system without rebooting?

@easyprototype
Copy link

Just tried enabling ARDUINOSD.

On the scope the lines on the SPI port are 3.3V so I connected my SD card adapter directly on it, with D10 as CS and of course GND + 3.3V as the power supply.

Like the USB key, I must boot the Giga with the card inserted. CATALOG, LOAD and SAVE works super fine. Thanks!

@slviajero
Copy link
Owner

slviajero commented Feb 10, 2025 via email

@slviajero
Copy link
Owner

slviajero commented Feb 10, 2025 via email

@easyprototype
Copy link

Thanks for the heads up.

With ARDUINOPRT, ARDUINOWIRE and ARDUINOSD enabled (+ARDUINORTC disabled) I get

print @t$
14:16:36-2/1/72

When I set @t(0/1/2/4), the Giga seems to count time.

@t(6) seems to be the year instead of weekday.
@t(5) seems to be the day of the month instead of the year.
@t(3) is unknown.

I tried Call 1 with an SD card and indeed it works.

@slviajero
Copy link
Owner

slviajero commented Feb 10, 2025 via email

@slviajero
Copy link
Owner

slviajero commented Feb 10, 2025 via email

@easyprototype
Copy link

@t0): seconds (0-59)
@t(1): minutes (0-59)
@t(2): hours (0-23) (24 hour clock mode only is supported)
@t(3): day of week with range 0-6
@t(4): date - day (1-31)
@t(5): date - month (1-12)
@t(6): date - year (0-99)

Ok. It's just that MANUAL.MD lists @t(4) to @t(6) differently.

@slviajero
Copy link
Owner

slviajero commented Feb 11, 2025 via email

@slviajero
Copy link
Owner

slviajero commented Feb 11, 2025 via email

@easyprototype
Copy link

Thanks for clearing up the RTC variables.

Also, I noticed that load/saving files on USB uses the RTC for setting the file date/time. Super nice.

Now I must make design choices.

  1. I would like to compile in BASICFULL (float), but I need to handle unsigned 32bit integers. So I must use BASICINTEGER which is 32 bit signed, but I can live with that. Is it possible to handle 32bits integer with TinyBasic compiled in floating point?

  2. In order to access registers, I think I would make 2 commands: RDREG addr,size and WRREG addr,size,value. All arguments are 32bits and WRREG needs 3 arguments. Can I create commands with 3 arguments?

  3. Is it possible to write and display values in hexadecimal in TinyBasic?

Thanks!

@slviajero
Copy link
Owner

slviajero commented Feb 11, 2025 via email

@easyprototype
Copy link

If it is a function, this would mean that the syntax would be
X=RDREG(addr, size)
and for WRREG it would be
WRREG addr, size, X

I would make both of them functions, it mimics DWRITE, DREAD and PINM.

I like the idea of using the same keyword for reading and writing, but I think it will be confusing for me when I look at my program.

You gave me plenty of meat to digest. If I manage to make them work, I will also try to add two new operators: >> and << (logical shift)...

@slviajero
Copy link
Owner

slviajero commented Feb 11, 2025 via email

@easyprototype
Copy link

Hi again.

Following your tutorial, I managed to implement one function and one command. With the HELP command, I even see them appear with the other commands :)

I need to thoroughly test my read command first, I get weird readings depending of the address and the data size. I need to read a little about memory addressing on the STM32, like can I read 2 bytes (16 bits) when starting from an odd address?

Next, I would like to implement a decimal to hexadecimal and a hexadecimal to decimal command. Hexadecimal numbers would be text strings though. So I need to read a little on how strings are passed around in TinyBasic.

Which brings me to a question/request:

  1. can you add the available I/O streams to the HELP command?

  2. In doing so, you would update TinyBasic, forcing me to re-implement my commands into the new TinyBasic version. I am trying to find a way to do this easily. For example, I can make two .h files. One is my declarations and is included at the beginning of IoTBasic.ino like any .h file. The second is included somewhere appropriate in the middle of IoTBasic.ino and contains all my functions. Not clean but it would save me a lot of cut and paste. After that I still need to manually add stuff the the lists, statement() and factor() functions. Any idea?

Thanks,

Serge

@slviajero
Copy link
Owner

slviajero commented Feb 19, 2025 via email

@easyprototype
Copy link

In the BASIC main code I try to use 8bit and then reconstruct 32 bit values from a 8 bit dataflow.

I try not to reconstruct because of how processors store 16 and 32 bits values. On the STM32 the low address is the LSB, while on a x86 processor the low address is the MSB. So I leave it to the compiler. I declare a uint8_t pointer for reading 8 bit values, a uint16_t pointer for 16 bit values and so on. Anyway I also crashed my Giga just by reading a memory address that maybe I shouldn't have so I need to make further testing. I will also try to test it on my Mega to see if my function works on a different processor.

I was thinking of splitting BASIC into components and subsystem in the near future but haven’t made up my mind yet. It will take about 20 hours of work to split BASIC into modules and test it.

Don't do that. I made myself a walkthrough that I added as comments in my functions' file. I can re-implement my functions in a new version of TinyBasic in about 10 minutes. Much faster than 20 hours!

@slviajero
Copy link
Owner

slviajero commented Feb 20, 2025 via email

@easyprototype
Copy link

Ooooh, nice banner. Very informative.

I got to try my re-implementation procedure: less than 10 minutes and my Giga was up and running again :) I like that you added the available IO in your banner. However I don't see stream #4 (ARDUINOPRT) which I enabled in my build. Also, what is stream 0 exactly?

@slviajero
Copy link
Owner

slviajero commented Feb 20, 2025 via email

@easyprototype
Copy link

Tried a new build this morning. All streams accounted for in the new banner :)

However, the banner reports

Language set: full

even as I build using "#define BASICINTEGER". And indeed I can add floating numbers at the prompt. I find the comment in the header of language.h confusing. "NOLANGUAGEHEURISTICS" does not exist. However, by reading carefully the code, I see that by default, LANGUAGEHEURISTICS is defined and override all the following defines. So I "#undef LANGUAGEHEURISTICS" and now I am in integer mode.

@slviajero
Copy link
Owner

slviajero commented Feb 21, 2025 via email

@easyprototype
Copy link

Me again.

I am having trouble making my read memory address works. As far as I can see, I am having problems handling a true 32bit number with push() and pop(). I am compiling with BASICINTEGER.

I want to read TIM14->CCR1. It contains 9000 and the decimal address is 1073750068. I never read the correct address. So I validated that my function rdreg received the correct address. So I tried to understand the various pop() and push() functions available and came up with

address_t x,y;
// size
x=popaddress();
// address
y=popaddress2();
pushaddress2(y);

By using a address_t, popaddress(); and pushaddress2() (see previous), if I type

print rdreg(1073750068, 4)
1073750068

This is the only way I get back the exact first number typed as argument. Using pop() and push() only returns me the lowest 2 bytes of the number.

Then I tried

address_t x,y,result;
// size
x=popaddress();
// address
y=popaddress2();
// now we just ignore x and y
// perform a brutal direct memory read
result = *(uint32_t *)1073750068UL;
pushaddress2(result);

This works and returns me 9000.

address_t y, result;
y=1073750068UL;
result = *(int32_t *)y;
pushaddress2(result);

This also works. But if I do

address_t y, result;
// use address typed at the BASIC prompt
y=popaddress2();
result = *(int32_t *)y;
pushaddress2(result);

Then I get an incorrect value.

How do I correctly pass my 32bit address to my C funtion?

@slviajero
Copy link
Owner

slviajero commented Feb 22, 2025 via email

@easyprototype
Copy link

Thanks.

To me, it is not clear if the int data type is 32bits on a STM32.

I misread the size of address_t and at first, pop() and push() did not work, probably because I used address_t variables with them.

I will try again Monday using t_number variables, pop() and push().

@slviajero
Copy link
Owner

slviajero commented Feb 23, 2025 via email

@easyprototype
Copy link

Arg, I was so close and I wasted so much time!

number_t + push + pop works perfectly. I also tried to compile with MEMSIZE at 128000. Works fine too, I will probably not use it unless I need more memory. We'll see.

I also wiped out a quick and dirty direct write to register using only number_t variables and pop(). I can now change the duty cycle of my 16 bit PWMs on the fly :)

Thanks for the help. Next: accessing a string of text in a function.

@slviajero
Copy link
Owner

slviajero commented Feb 25, 2025 via email

@easyprototype
Copy link

After checking how strings are handled, I think, for making my function HEXTODEC(string), I will copy and modify factorval() and implement it the same way in factor().

My function requires a string containing a hexadecimal written in ASCII and converts it into a decimal number. This looks a lot like the behavior of the VAL command.

@slviajero
Copy link
Owner

slviajero commented Feb 27, 2025 via email

@slviajero
Copy link
Owner

slviajero commented Feb 28, 2025 via email

@easyprototype
Copy link

I just checked in a code prototype that makes VAL capable of processing strings like „0xFA“, „0o76“, „0b1001“ for hex, octal and binary data. Maybe you can use this?

Wow, I most certainly can, my next todo was implementing binary to decimal. It's very useful when working with registers.

I was thinking to add this also to STR.

Oh wow, that would be cool, another of my todo list :)

If I can help you in any capacity, please let me know!

@slviajero
Copy link
Owner

slviajero commented Feb 28, 2025 via email

@slviajero
Copy link
Owner

slviajero commented Feb 28, 2025 via email

@easyprototype
Copy link

Ok, just compiled your new kernel with BASICINTEGER + my stuff and it boots.
Quick'n'dirty test of <<, >> and BIT. It works :)
Quick'n'dirty test of VAL and STR. It works :)

STR being able to convert into any numerical base just took me back to my elementary school years, when they tried to teach me that... Now I just converted 25 in base61 for fun.

I will try to write a test program for VAL and STR. Once it is done, I will run it on my GIGA in an integer kernel and then in a float kernel. After that I will try the same on an ArduinoMega.

How do I send you my code for port access?

P.S. In manual.md, when you explain the BIT command, you wrote

If the bit is not set the answer is always 0. If the bit is not set the answer will be either -1 or 1.

I think there is a mistake is the wording. The bit is not set in both cases.

@slviajero
Copy link
Owner

slviajero commented Mar 1, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants