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

Is SPI ported? #68

Open
crystalthoughts opened this issue Dec 9, 2024 · 13 comments
Open

Is SPI ported? #68

crystalthoughts opened this issue Dec 9, 2024 · 13 comments

Comments

@crystalthoughts
Copy link

Hello, is SPI part of the GPIO library ( I see a function mode referring to it) or is this not yet ported?
Thanks for the library!

@Martinix75
Copy link
Contributor

No! It hadn't been implemented, but in fact it would not be a bad thing to do it! It could be very useful.

@crystalthoughts
Copy link
Author

Yess I think that's a key piece needed to get most projects with a screen going :)
Have you tried using Futhark to speed up the porting process?
I'm not really experienced enough in embedded to do a good job contributing to this unfortunately, otherwise I would try!

@crystalthoughts
Copy link
Author

#62

It looks like this pull request has it covered (seemed also to use Futhark)

@Martinix75
Copy link
Contributor

Martinix75 commented Dec 10, 2024

Yes, I tried Daniel's project, but I always fail in compilation !!! I don't know why but I'm not a programmer too and goes beyond my skills.
For now (and for work) I use the I2C screens. And for now they are more than enough (sh1106 and ssd1306)

@crystalthoughts
Copy link
Author

crystalthoughts commented Dec 12, 2024

@daniel-j there are some downstream dependencies that aren't handled by the nimble file (pico-vfs -> littlefs)
edit: And the tests fail at test-mock.nim for me

@crystalthoughts
Copy link
Author

image
I also get this when I try the examples

@daniel-j
Copy link

@Martinix75 Hello! Can you describe or show the error that occur?

@crystalthoughts Hmm, not sure what may be the issue. What are the error messages from the compilation or configuration? The screenshot only shows cmake failed but it doesn't show what cmake error it was. LittleFS is now loaded from within pico-vfs. Make sure to clone picostdlib recursively!

@Martinix75
Copy link
Contributor

Martinix75 commented Dec 19, 2024

@daniel-j
Hi Daneil, sorry for the delay for the answer, but I was not at work!
I am attaching you below the error that brings me back (everything).
But I would say that the certain is "Fatal: 'sys/time.h' file not found ".
I use OpenSUSE SLOWROLL/TW
GCC-13 (GCC-13 Cross Arm None)
Clang 19.x
Nim 2.2.0
Maybe only a few files/package is missing? I would not know.

  Success:  futhark installed successfully.
   Building picostdlib/piconim using c backend
Setting up build/futharkgen
>> cmake -DPICO_SDK_FETCH_FROM_GIT=on -DPICO_BOARD=pico_w -S src/picostdlib/build_utils/futharkgen -B build/futharkgen
Using master as default value for PICO_SDK_FETCH_FROM_GIT_TAG
Downloading Raspberry Pi Pico SDK
CMake Warning (dev) at /usr/share/cmake/Modules/FetchContent.cmake:1953 (message):
  Calling FetchContent_Populate(pico_sdk) is deprecated, call
  FetchContent_MakeAvailable(pico_sdk) instead.  Policy CMP0169 can be set to
  OLD to allow FetchContent_Populate(pico_sdk) to be called directly for now,
  but the ability to call it with declared details will be removed completely
  in a future version.
Call Stack (most recent call first):
  /tmp/nimble_28735/githubcom_danieljpicostdlibgit/src/picostdlib/cmake/pico_sdk_import.cmake:61 (FetchContent_Populate)
  CMakeLists.txt:31 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

PICO_SDK_PATH is /tmp/nimble_28735/githubcom_danieljpicostdlibgit/build/futharkgen/_deps/pico_sdk-src
Target board (PICO_BOARD) is 'pico_w'.
Using board configuration from /tmp/nimble_28735/githubcom_danieljpicostdlibgit/build/futharkgen/_deps/pico_sdk-src/src/boards/include/boards/pico_w.h
Defaulting platform (PICO_PLATFORM) to 'rp2040' based on PICO_BOARD setting.
Defaulting compiler (PICO_COMPILER) to 'pico_arm_cortex_m0plus_gcc' since not specified.
Configuring toolchain based on PICO_COMPILER 'pico_arm_cortex_m0plus_gcc'
Defaulting PICO_GCC_TRIPLE to 'arm-none-eabi'
-- The C compiler identification is GNU 13.3.1
-- The CXX compiler identification is GNU 13.3.1
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/arm-none-eabi-gcc
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/arm-none-eabi-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/arm-none-eabi-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Build type is Release
-- Found Python3: /usr/bin/python3.11 (found version "3.11.11") found components: Interpreter
TinyUSB available at /tmp/nimble_28735/githubcom_danieljpicostdlibgit/build/futharkgen/_deps/pico_sdk-src/lib/tinyusb/src/portable/raspberrypi/rp2040; enabling build support for USB.
BTstack available at /tmp/nimble_28735/githubcom_danieljpicostdlibgit/build/futharkgen/_deps/pico_sdk-src/lib/btstack
cyw43-driver available at /tmp/nimble_28735/githubcom_danieljpicostdlibgit/build/futharkgen/_deps/pico_sdk-src/lib/cyw43-driver
Pico W Bluetooth build support available.
lwIP available at /tmp/nimble_28735/githubcom_danieljpicostdlibgit/build/futharkgen/_deps/pico_sdk-src/lib/lwip
Pico W Wi-Fi build support available.
mbedtls available at /tmp/nimble_28735/githubcom_danieljpicostdlibgit/build/futharkgen/_deps/pico_sdk-src/lib/mbedtls
-- Configuring done (42.9s)
-- Generating done (0.0s)
-- Build files have been written to: /tmp/nimble_28735/githubcom_danieljpicostdlibgit/build/futharkgen
Building futharkgen in build/futharkgen
>> nim c -d:cmakeBinaryDir:/tmp/nimble_28735/githubcom_danieljpicostdlibgit/build/futharkgen -d:cmakeTarget:futharkgen --nimcache:build/futharkgen/futharkgen/nimcache src/picostdlib/build_utils/futharkgen/futharkgen
/tmp/nimble_28735/githubcom_danieljpicostdlibgit/src/picostdlib
Hint: used config file '/home/andrea/bin/nim/config/nim.cfg' [Conf]
Hint: used config file '/home/andrea/bin/nim/config/config.nims' [Conf]
Hint: used config file 'src/picostdlib/build_utils/futharkgen/futharkgen.nims' [Conf]
..............................................................................................................................................
stack trace: (most recent call last)
futhark.nim(846, 9)      importcImpl
/tmp/nimble_28735/githubcom_danieljpicostdlibgit/src/picostdlib/lib/lwip.nim(46, 3) template/generic instantiation of `importc` from here
/home/andrea/.nimble/pkgs2/futhark-0.13.7-1283941b3dffffd978858122e052ab6bb135359b/futhark.nim(716, 14) template/generic instantiation of `importcImpl` from here
/home/andrea/.nimble/pkgs2/futhark-0.13.7-1283941b3dffffd978858122e052ab6bb135359b/futhark.nim(846, 9) Error: Opir exited with non-zero exit code 255.
Opir output:
Fatal: 'sys/time.h' file not found /tmp/nimble_28735/githubcom_danieljpicostdlibgit/build/futharkgen/_deps/pico_sdk-src/src/rp2_common/pico_lwip/include/arch/cc.h:35:10 1638
Tried to parse: /tmp/nimble_28735/githubcom_danieljpicostdlibgit/build/futharkgen/futharkgen/nimcache/futhark-includes.h
With arguments: -I/tmp/nimble_28735/githubcom_danieljpicostdlibgit/build/futharkgen/_deps/pico_sdk-src/lib/mbedtls/library -I/tmp/nimble_28735/githubcom_danieljpicostdlibgit/template/csource -I/tmp/nimble_28735/githubcom_danieljpicostdlibgit/build/futharkgen/_deps/pico_sdk-src/src/rp2040/hardware_regs/include -I/tmp/nimble_28735/githubcom_danieljpicostdlibgit/build/futharkgen/_deps/pico_sdk-src/lib/lwip/src/include -I/tmp/nimble_28735/githubcom_danieljpicostdlibgit/build/futharkgen/futharkgen/nimcache -fsigned-char -fshort-enums -I/tmp/nimble_28735/githubcom_danieljpicostdlibgit/build/futharkgen/_deps/pico_sdk-src/lib/mbedtls/include -I/tmp/nimble_28735/githubcom_danieljpicostdlibgit/build/futharkgen/_deps/pico_sdk-src/src/common/pico_base_headers/include -I/tmp/nimble_28735/githubcom_danieljpicostdlibgit/build/futharkgen/_deps/pico_sdk-src/src/rp2_common/pico_platform_panic/include -I/tmp/nimble_28735/githubcom_danieljpicostdlibgit/src/picostdlib/build_utils/futharkgen -I/tmp/nimble_28735/githubcom_danieljpicostdlibgit/build/futharkgen/_deps/pico_sdk-src/src/rp2_common/pico_platform_compiler/include -I/tmp/nimble_28735/githubcom_danieljpicostdlibgit/build/futharkgen/_deps/pico_sdk-src/src/rp2_common/pico_lwip/include -I/tmp/nimble_28735/githubcom_danieljpicostdlibgit/build/futharkgen/generated/pico_base -I/usr/lib64/clang/19/include -I/usr/lib64/gcc/arm-none-eabi/13/include -I/tmp/nimble_28735/githubcom_danieljpicostdlibgit/build/futharkgen/_deps/pico_sdk-src/src/rp2_common/pico_platform_sections/include -I/tmp/nimble_28735/githubcom_danieljpicostdlibgit/build/futharkgen/_deps/pico_sdk-src/src/rp2_common/pico_cyw43_driver/include -mcpu=cortex-m0plus -I/tmp/nimble_28735/githubcom_danieljpicostdlibgit/build/futharkgen/_deps/pico_sdk-src/lib/lwip/contrib/ports/freertos/include --target=arm-none-eabi -I/tmp/nimble_28735/githubcom_danieljpicostdlibgit/build/futharkgen/_deps/pico_sdk-src/src/rp2_common/pico_rand/include -mthumb -I/tmp/nimble_28735/githubcom_danieljpicostdlibgit/build/futharkgen/_deps/pico_sdk-src/src/rp2040/pico_platform/include
Unable to parse translation unit succesfully. Quitting
/tmp/nimble_28735/githubcom_danieljpicostdlibgit/src/picostdlib/build_utils/piconim.nim(270) piconim
/tmp/nimble_28735/githubcom_danieljpicostdlibgit/src/picostdlib/build_utils/piconim.nim(179) doBuild
Error: unhandled exception: unable to compile the provided nim program: src/picostdlib/build_utils/futharkgen/futharkgen [PicoSetupError]
stack trace: (most recent call last)
/tmp/nimblecache-2166255073401123403/nimscriptapi_4720534257189356232.nim(224, 29)
/tmp/nimble_28735/githubcom_danieljpicostdlibgit/picostdlib.nimble(30, 17) installBefore
/tmp/nimble_28735/githubcom_danieljpicostdlibgit/picostdlib.nimble(25, 3) futharkgenTask
/home/andrea/bin/nim/lib/system/nimscript.nim(264, 7) exec
/home/andrea/bin/nim/lib/system/nimscript.nim(264, 7) Error: unhandled exception: FAILED: ./piconim build --project futharkgen src/picostdlib/build_utils/futharkgen/futharkgen --compileOnly [OSError]
       Tip: 3 messages have been suppressed, use --verbose to show them.
nimscriptwrapper.nim(161) execScript

    Error:  Exception raised during nimble script execution
andrea@tec-martin-d:~>

Thanks for the help from Martin A.
p.s. If you need more information, he tried to provide you as soon as possible (even if at Christmas it will be difficult)

I have the doubt that I stay making a stupid error from something else!
SDK type is downloaded automatically or do you have to indicate where it is ??? What if yes? (I have this terrible doubt)

For completeness of information I give the command:
nimble install https://github.com/daniel-j/picostdlib.git

in /home/andrea
am I doing correctly?

@daniel-j
Copy link

daniel-j commented Dec 19, 2024 via email

@Martinix75
Copy link
Contributor

Martinix75 commented Dec 20, 2024

Yes! The "cross-arm-none-newlib-devel (version 4.4.0.xxx)" pachet is installed.
And the file is in "/usr/arm-none-eobi/includa/sys/time.h"

I can't understand that file does not find it here:
Fatal: 'sys/time.h' file not found /tmp/nimble_6188/githubcom_danieljpicostdlibgit/build/futharkgen/_deps/pico_sdk-src/src/rp2_common/pico_lwip/include/arch/cc.h:35:10 1638

What is wrong in the installation of your nimble package?
I am really afraid to make some stupid installment error of your package!
bye by MArtin A

@daniel-j
Copy link

Sorry for the delay. What does arm-none-eabi-gcc -print-sysroot print? I pushed an update now to use /usr/arm-none-eabi/include as fallback if it exists.

@Martinix75
Copy link
Contributor

Martinix75 commented Jan 7, 2025

Hi @daniel, sorry for the delay of the answer (and the test) but the Christmas holidays are a nightmare.
This morning I copied your library and after the Commit it works, or at least it is completed without errors! Thank you.
In these days I will try to make a plan and see if everything works. But for now thanks !!!

I disturbed you (maybe) if I find other problems!

tank's by Martin A.

@Martinix75
Copy link
Contributor

Hi @daniel-j
In these days I am a little playing with "spi.nim"
I noticed two things:
1 - The names are not consistent, while for i2c the names of the functions begin for i2c (eg i2csetu, i2cwritebloking ...) while for spi no (would be perhaps better if you start for spi?)
2- The function (SPI) write16Blocking does not work well (and on oscilloscope) by very strange results that are not read well from the SPI device that I have (MCP42050). I have allowed myself to write a nim procedure that seems to work well (for the writing of 16 continuous bit) but needs a particular setup (procedure) that I have written anyway.
When I try it well if you want I send it to you.

Hello from martinix

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