How to Build a Universal Binary for the Raspberry Pi Pico 2 - Arm & RISC-V in the Same File

Поділитися
Вставка
  • Опубліковано 24 лис 2024

КОМЕНТАРІ • 27

  • @simonbooth4888
    @simonbooth4888 2 місяці тому +23

    Good idea about CMake - would be nice if you'd do an example that use some Pimoroni libraries (as they're all chucked in the examples repo)

    • @RoboticsDIY
      @RoboticsDIY 2 місяці тому

      yes please

    • @ParabolicLabs
      @ParabolicLabs 2 місяці тому

      I concur. More specifically I'd like to see this done with the new Pico VSCode plugin. I can get the entire Pimoroni SDK to compile using cmake and the pico vscode plugin by adding the SDK as a subdirectory, but as soon as I include any Pimoroni stuff in the cmake file or in C, it all falls apart and fails. I asked in the Pimoroni discord, but no answer of yet.

    • @simonbooth4888
      @simonbooth4888 2 місяці тому +1

      @@ParabolicLabs You'd think Pimoroni would make it easier to use their products. I spent an entire day fighting to get a display pack to work with my own code outside examples

    • @ParabolicLabs
      @ParabolicLabs 2 місяці тому

      @@simonbooth4888 I completely agree. I remember getting their display pack 2.0 when it was released, and wow was it a nightmare, it was a full week until I was able to get it working in C, and the only way for me to get anything out of it was that I ended up writing my own driver for it and not even use their library. From what I understand, Pimoroni really seems to want people to use micropython. Pimoroni has seemed to prioritize micropython over C. Their C stuff is an after thought IMO. There's even a few github issues where they wouldn't / won't do anything on the C front until after the micropython stuff is done. Pretty lame imo, but I guess I understand it. The pico and pico 2 are tools for learning after all, but it feels like making C the second class citizen is a odd choice considering it's a microcontroller. I remember when there wasn't even a guide on how to use their C stuff at all and it was suggested to read their github in it's entirety and figure it out lol. Their hardware is superb no doubt, but using their C library is like pulling teeth imo.
      I got a message back btw, I think I was misremembering and adding pimoroni via subdirectory wasn't the right incantation for the cmake stuff. Instead I think your supposed to add it alongside your project. I did this by using the "include" command and adding specific .cmake files. Then you add relevant directories in the target_include_directories. Both of these are in your project's CMakeLists.txt. This got it to compile and link and I was able to use a trackball over a multiplexer.
      Actually I was right originally, and just tested it again with subdirectory and you can add Pimoroni Library via subdirectory, you just need the right paths added to target_include_directories.
      # Pimoroni Subdirectory
      set(PIMORONI_PICO_PATH "${CMAKE_CURRENT_LIST_DIR}/pimoroni_pico") # Adjust the path to match the actual location
      add_subdirectory(${PIMORONI_PICO_PATH})
      # Target Include Directories
      target_include_directories(degallo PRIVATE
      ${CMAKE_CURRENT_LIST_DIR}
      ${CMAKE_CURRENT_LIST_DIR}/.. # for our common lwipopts or any other standard includes, if required
      ${PIMORONI_PICO_PATH}
      ${PIMORONI_PICO_PATH}/common
      ${PIMORONI_PICO_PATH}/drivers
      ${PIMORONI_PICO_PATH}/libraries
      )
      Seems to work fine after this. Not sure why I couldn't get it to work before, I'm sure I had this exactly setup before. Maybe I forgot to use the configure cmake option in the pico vscode plugin originally. CMake is definitely not my strong suit, but after enough messing around I generally can get it to work lol.

  • @tlberglund
    @tlberglund 2 місяці тому +17

    Would love to see a no-nonsense CMake tutorial! I used regular old Unix make in days of your, and CMake is...not that. :)

    • @ssl3546
      @ssl3546 2 місяці тому +2

      Agree, using cmake for Hello World is ridiculous, it completely obscures whatever point this guy is making. We're not building a multi-million LOC cross platform project here

    • @tlberglund
      @tlberglund 2 місяці тому

      Well, CMake is the build tool in this toolchain. It feels heavyweight to me too, but I think pivoting to something else would make more work long-term. I’m grateful for the offer of the free tutorial!

    • @GaryExplains
      @GaryExplains  2 місяці тому +4

      CMake is the official build tool for the Pico, for small and large projects, it isn't something I have chosen for this video specifically, it is how the tools work for the Pico.

  • @ElongTimeago
    @ElongTimeago 2 місяці тому +18

    Hi Gary, CMake tutorial would be great, please

  • @gregholloway2656
    @gregholloway2656 2 місяці тому +2

    Thanks for the video Gary. I’m interested in a cmake tutorial as well. I’ve been using the Pico since the beginning and I’m still clumsy with cmake. I guess using “make” since the 90’s has warped my mind.

  • @keithstandiford3761
    @keithstandiford3761 2 місяці тому

    Love to see your take on CMake. I got fairly into it for awhile, but I always learn something from you!

  • @bertblankenstein3738
    @bertblankenstein3738 2 місяці тому

    Ok, i can now use this info to make the risc binaries. I will try this out at some time. Thank you.

  • @autohmae
    @autohmae 2 місяці тому +1

    Cool, thanks !

  • @FrankHoedemakers
    @FrankHoedemakers 2 місяці тому +2

    I did not looked into this in detail, but i think you had cmake already installed via apt. cmake is also installed in ~/.pico-sdk with the vscode plugin. But it is not in the PATH variable when using a terminal outside vscode. So the command cmake .. will not be found on a system on which cmake is not installed with apt.

    • @GaryExplains
      @GaryExplains  2 місяці тому +2

      Good catch. Thanks for sharing.

  • @IamTheHolypumpkin
    @IamTheHolypumpkin 2 місяці тому +1

    I would love a cake tutorial, even after a year if developing for the pico, I still go about crake with a very time consuming trial and error approach

  • @percival477
    @percival477 2 місяці тому +3

    Are we going to see some pico 2 rust videos?

  • @paulthomas4917
    @paulthomas4917 2 місяці тому +1

    This may seem a stupid question but why don't Rasberry's experts just provide us with a UF2 file? i.e. if the result of what you did was to produce a UF2 file, why would that file not work on any pipico.

    • @GaryExplains
      @GaryExplains  2 місяці тому +5

      Sorry I don't really understand the question. You expect a program compiled with a RISC-V compiler to work on the Arm based Pico 1?

    • @simonbooth4888
      @simonbooth4888 2 місяці тому

      3x+ uf2 file

    • @velho6298
      @velho6298 2 місяці тому +2

      It is architecture specific hence why Gary showed how to combine the architecture binaries into one uf2 file

    • @paulthomas4917
      @paulthomas4917 2 місяці тому

      ​@@GaryExplains Ok, I better say you are communicating with someone who is more at home with a soldering iron than a UF2 file.
      I was assuming rightly or wrongly we live in a world where there are only pipico boards and thonny running micropython.
      My son assured me this is the best setup, he is only software oriented (yes I failed him).
      I had to load a UF2 file on my pico. I have no idea why, why can't things work like they did with the 6502, you just had assembler, switches and 7 segment displays?
      Anyway, all that I was asking, (obviously I thought you guys were like me, but not as good) is why can't you give me your updated UF2 file as it will work with anything including the sack of pipico boards I have.
      I am a little unsure what would be gained by using your UF2 file, but my son would be impressed by my- 'self created purpose UF2 file'.

    • @paulthomas4917
      @paulthomas4917 2 місяці тому

      @@velho6298 I think its sinking in. I just thought Gary's UF2 file would just replace the one I originally loaded into my pi pico.
      That UF2 file I was given to me.
      I am not in any sense a software guy so as I was watched Gary explain the inner workings of Nasa's AI space computers that seemed to produce a UF2 file, I was wondering why I had to climb the mountain when Gary could just copy his new UF2 file.
      It's all very confusing, like when I am explaining why I needed so many Goto's and go subs to my son who would get on very well with Gary.
      Thank you so much for responding.