- Added code to support _ret_ in inline assembly
- Fixed rdlong x, ptra[##BIG] instruction form
- Fixed some bugs in cog_run
- Fixed bit references in arrays like A[x].[y]
- Fixed uhex() bug where it only output 1 bit
- Fixed a serious off-by-one error in garbage collection code
Plus the 5.0.6 changes listed in the previous message. It's definitely worth updating to this version.
Completely new to the P2 and Spin. I am having an issue running flexprop on mac iOS 11.1. When I click on the flexprop.tcl I get an error that says "Wish quit unexpectedly". The following is the details that it provides.
Tk tcl (8.5.n) which comes installed on macOS 11.1 seems broken as it asks for macOS 11 or later (odd???)... So, you need to get a different version of tcl-tk (8.6.n)...
$ /System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Wish.app/Contents/MacOS/Wish
macOS 11 or later required !
[1] 15789 abort
Most macOS users use homebrew (or get sources and build from: https://www.tcl.tk) to install a version of tcl-tk that will run without problems. I'm running tcl-tk with version 8.6.9 successfully.
I've released version 5.0.8 of FlexProp. The changes are all in the compiler, and include:
- Added a warning for casting const pointers to non-const
- Added missing tan function to math.h
- Fixed Spin2 pinread to work correctly with multiple pins
- Fixed an optimizer bug that could cause corruption of small multi-word structs being returned from a C function
- Properly implemented compile time optimization of BASIC ASC("x") function
- New BASIC string functions from JRoark: improved implementations of some existing functions, and added functions CountStr, RemoveChar$, ReplaceChar$, and StrInt$
Links to the download are in my signature and in the first post on this thread.
It's missing the flash.h header file. Looking at the code the error happens on a line with offsetof(), which is supposed to be defined in <stddef.h>, but I don't see that header file included anywhere. Try adding #include <stddef.h> to spiffs_nucleus.c.
@iseries : It's the stddef.h, you need to add #include <stddef.h> to the top of the file that's throwing the error.
@arkret : No, only a subset of debug is supported. I'm hoping Chip will release a stand-alone debug window to allow other applications/compilers to access the graphical features.
intptr_t is the type of an integer that's the same size as a pointer. It's defined in <stdint.h>. For us, it's 32 bits long, which is also the size of "int" and "long". But the code really should be including <stdint.h> to get that size!
Thanks @"Ken Gracey" . For some reason the forum software was incorporating the closing parenthesis into the URL. I've added a space and now I think all is well.
Installed the latest FlexProp on the Raspberry Pi and when I switch over to P1 mode and scan for ports:
>
couldn't execute "bin/proploader": no such file or directory
while executing
"exec -ignorestderr bin/proploader$EXE -W"
(procedure "rescanPorts" line 18)
invoked from within
"rescanPorts"
invoked from within
".#mbar.#mbar#comport invoke active"
("uplevel" body line 1)
invoked from within
"uplevel #0 [list $w invoke active]"
(procedure "tk::MenuInvoke" line 50)
invoked from within
"tk::MenuInvoke .#mbar.#mbar#comport 1"
(command bound to event)
>
I have not tried this on my regular PC, I want to get this to work on my Raspberry Pi.
In order to build proploader (the P1 loader tool) you have to have openspin installed. The WiFi support in proploader depends on some funky loading stuff that doesn't seem to work with flexspin (I think they make assumptions about the format of the compiled bytecodes). You'll either have to find a pre-built package for openspin or else build it from source, which isn't too hard. To completely build openspin + flexprop on Raspberry Pi do:
mkdir src
cd src
git clone --recursive https://www.github.com/parallaxinc/openspin
cd openspin
make
sudo cp build/openspin /usr/local/bin
cd ..
git clone --recursive https://www.github.com/totalspectrum/flexprop
cd flexprop
make install
@iseries : Hmmm, it actually looks like the original code (without the _pinl) is the one with the bug, as it's putting too much stuff (including the call to _getus) into the fcache. This happens to be harmless in this particular case, but I'm guessing that the corrected version (with _pinl) exhibits different timing. _getus() is a fairly expensive operation since it involves a divide. How sensitive is your hardware to timing? How many microseconds is the pin likely to be high or low?
You'll probably have better luck capturing the system frequency timer directly (counting cycles rather than microseconds) and then converting to microseconds after the timing sensitive code.
Also note that _pinr() does *not* set the pin as an input. I guess it's defaulting to input, so it's fine, but you can force it with a _fltl(PIN).
#include <stdio.h>
#include <propeller.h>
#define PIN 15
int main(int argc, char** argv)
{
int i;
while (1)
{
i = getAngle(PIN);
printf("Value: %d\n", i);
_waitms(1000);
}
}
int getAngle(int p)
{
int i;
while (_pinr(p) == 1);
while (_pinr(p) == 0);
//_pinr(p);
i = _getus();
while (_pinr(p) == 1);
i = _getus() - i;
return i;
}
This is measuring a 360 servo input which goes from 30us to 1030us. I checked it with a scope.
When the code works it's dead on reporting 36 to 1030.
P2 running at 200MHz.
I've released FlexProp 5.1.1. The major new change is a CHAIN function in BASIC (and execve in C) to allow running another P2 binary from host or SD card. Note that the new binary will completely take over the machine when it's running and will not return to the original -- it's a one way transfer. Other restrictions:
during the load the original program has to remain resident (it's busy doing the load) so both programs must fit into HUB memory together. Once the load is finished the original program is erased (overwritten by copying the new one down to address 0).
the clock frequency is reset to RCFAST before the new program is started
COGs are not stopped, nor are pin states reset. This is deliberate, but it's dangerous because HUB RAM is being completely overwritten by the new program, so the COGs cannot rely on anything in HUB.
The new binary can be any compiled P2 program, it doesn't have to be built with flexspin or with any particular memory layout
Also of note is the "shell" sample, which I posted elsewhere on the forums, and which allows you to copy files between the host PC and the P2 board's SD card.
Comments
Plus the 5.0.6 changes listed in the previous message. It's definitely worth updating to this version.
Completely new to the P2 and Spin. I am having an issue running flexprop on mac iOS 11.1. When I click on the flexprop.tcl I get an error that says "Wish quit unexpectedly". The following is the details that it provides.
How do I go about this?
Thanks
EDIT: Try this: https://tkdocs.com/tutorial/install.html#install-mac-tcl
wish running on macOS 11.1 as installed:
Most macOS users use homebrew (or get sources and build from: https://www.tcl.tk) to install a version of tcl-tk that will run without problems. I'm running tcl-tk with version 8.6.9 successfully.
dgately
Mike
Never mind, I see that var1 is defined as 64 bits or long long which is not supported.
Links to the download are in my signature and in the first post on this thread.
Thank you for the help! Worked after I installed Wish 8.6!
I'm trying to compile this code which has the typedefs from hell in it.
Anyway I have worked through most of it and stopped with "error: syntax error, unexpected type name `spiffs_page_header'"
Can you take a peek at it and tell me what's going on.
I have attached the include files and a sample program that should compile.
Mike
Seeing this error now. I guess over defined.
warning: Preprocessor warnings:
D:/flexprop/include/simpletools.h:10: warning: The macro is redefined
#define cogstart _cogstart
from D:/Documents/My Projects/P2/moo.c: 12: #include "simpletools.h"
previously macro "cogstart" defined as: #define cogstart(func,par,stack,stacksize) __builtin_cogstart(func(par), stack) /* D:/flexprop/include/propeller.h:51 */
Mike
It's missing the flash.h header file. Looking at the code the error happens on a line with offsetof(), which is supposed to be defined in <stddef.h>, but I don't see that header file included anywhere. Try adding #include <stddef.h> to spiffs_nucleus.c.
Smile, I thought I got all of it. Well here's that file.
Mike
Ok, Now a can't read either.
Here everything you should need again....
Is the full Debug feature not supported on Flexprop? I am able to do some commands, but nothing related to the backticks (`).
@iseries : It's the stddef.h, you need to add #include <stddef.h> to the top of the file that's throwing the error.
@arkret : No, only a subset of debug is supported. I'm hoping Chip will release a stand-alone debug window to allow other applications/compilers to access the graphical features.
Seeing this verbiage in the code:
// align cand_scores on s32_t boundary
cand_scores = (s32_t*)(((intptr_t)cand_scores + sizeof(intptr_t) - 1) & ~(sizeof(intptr_t) - 1));
Does intptr_t do anything.
Mike
Getting this error: error: Expected integer type for parameter of bit operation
cand_scores is a pointer to long. If I cast it to a long it's fine.
intptr_t is the type of an integer that's the same size as a pointer. It's defined in <stdint.h>. For us, it's 32 bits long, which is also the size of "int" and "long". But the code really should be including <stdint.h> to get that size!
Almost forgot, I had to add these defs for some code for bme280, bme680 modules:
Mike
Having a issue with my SPIFFS call back code.
spiffs_read_dir_v is a function with this definitions:
In the other calls the ampersand is not need and calls the correct function. For this one item it fails to create a method pointer.
Here is the definition of the function:
Here is a test program that doesn't make sense to me. I thought it would print the address of the function but got a strange answer.
Here is a working copy of the SPIFFS file system:
Here is a program that will create a SPIFFs file system on the last 512K bytes of the P2 flash.
Mike
@ersmith the first two links shown in the first post of this forum thread are 404 errors. Could you correct them?
We're starting to feature FlexProp in Quick Bytes and I'm checking to see that the user will succeed when they follow our instructions.
Thanks,
Ken Gracey
Thanks @"Ken Gracey" . For some reason the forum software was incorporating the closing parenthesis into the URL. I've added a space and now I think all is well.
Looking good on this end now.
I've released FlexProp 5.1.0. This is a fairly big update, with some new features and many bug fixes. Among the new features are:
and of course many bug fixes.
Installed the latest FlexProp on the Raspberry Pi and when I switch over to P1 mode and scan for ports:
>
couldn't execute "bin/proploader": no such file or directory
while executing
"exec -ignorestderr bin/proploader$EXE -W"
(procedure "rescanPorts" line 18)
invoked from within
"rescanPorts"
invoked from within
".#mbar.#mbar#comport invoke active"
("uplevel" body line 1)
invoked from within
"uplevel #0 [list $w invoke active]"
(procedure "tk::MenuInvoke" line 50)
invoked from within
"tk::MenuInvoke .#mbar.#mbar#comport 1"
(command bound to event)
>
I have not tried this on my regular PC, I want to get this to work on my Raspberry Pi.
Ray
In order to build proploader (the P1 loader tool) you have to have openspin installed. The WiFi support in proploader depends on some funky loading stuff that doesn't seem to work with flexspin (I think they make assumptions about the format of the compiled bytecodes). You'll either have to find a pre-built package for openspin or else build it from source, which isn't too hard. To completely build openspin + flexprop on Raspberry Pi do:
The following C code hangs for some reason:
If I uncomment the _pinl(56) the code runs just fine.
The assembly code looks good but it may be the fache stuff.
MIke
@iseries : Hmmm, it actually looks like the original code (without the _pinl) is the one with the bug, as it's putting too much stuff (including the call to _getus) into the fcache. This happens to be harmless in this particular case, but I'm guessing that the corrected version (with _pinl) exhibits different timing. _getus() is a fairly expensive operation since it involves a divide. How sensitive is your hardware to timing? How many microseconds is the pin likely to be high or low?
You'll probably have better luck capturing the system frequency timer directly (counting cycles rather than microseconds) and then converting to microseconds after the timing sensitive code.
Also note that _pinr() does *not* set the pin as an input. I guess it's defaulting to input, so it's fine, but you can force it with a _fltl(PIN).
This code hangs or crashes as well:
This is measuring a 360 servo input which goes from 30us to 1030us. I checked it with a scope.
When the code works it's dead on reporting 36 to 1030.
P2 running at 200MHz.
Mike
Mike, I really suspect that _getus() is too slow (I can't see any other reason why that program would hang). Does it work if you change the timing to:
Also, you probably want to make the variable i in that function "unsigned" rather than "int".
I've released FlexProp 5.1.1. The major new change is a CHAIN function in BASIC (and execve in C) to allow running another P2 binary from host or SD card. Note that the new binary will completely take over the machine when it's running and will not return to the original -- it's a one way transfer. Other restrictions:
Also of note is the "shell" sample, which I posted elsewhere on the forums, and which allows you to copy files between the host PC and the P2 board's SD card.
Lame
P1 SD drivers can boot full 32k executables, P2 surely should be able to manage it, too.