Giter Club home page Giter Club logo

Comments (20)

makermelissa avatar makermelissa commented on September 25, 2024

That seems like a good solution. You could also place something in /etc instead of /boot. If no file is found, it can default to the Pi CM4.

from adafruit_python_platformdetect.

makermelissa avatar makermelissa commented on September 25, 2024

I'm thinking about how armbian has a /etc/armbian-release, we could do something like /etc/cm4-release

from adafruit_python_platformdetect.

ladyada avatar ladyada commented on September 25, 2024

the only reason i'd say look at an EEPROM is there may some way to auto-load device tree overlays via eeprom (i may be mistake) which could load your DTS required for hardware

from adafruit_python_platformdetect.

timonsku avatar timonsku commented on September 25, 2024

I'm thinking about how armbian has a /etc/armbian-release, we could do something like /etc/cm4-release

Yea that is also a sensible place! Boot just seemed like a nice place as other important settings are usually there like the config.txt so it might be a more familiar place for users (and the accessibility via a computer when mounting the image but that is not a terribly important thing to have)

from adafruit_python_platformdetect.

timonsku avatar timonsku commented on September 25, 2024

the only reason i'd say look at an EEPROM is there may some way to auto-load device tree overlays via eeprom (i may be mistake) which could load your DTS required for hardware

I was thinking about this but I was kinda scared of the scenario of wanting to make changes to the device tree definition later on and then having either a binary or string pointer hard coded in my hardware that will take precedence unless specifically disabled in config.txt. So I foresee a lot of confusion and user errors be possible that way, I'd rather be sure that the latest version of my install process guarantees that every user will work with the latest version. Of course I could just add the disable into that install process but then the EEPROM also becomes kinda pointless after the first change anyway.

The CM4 also comes with its own EEPROM but this thinks of a scenario where you sell hardware bundled with the CM4 that you flashed during manufacturing and the user not using their own.

from adafruit_python_platformdetect.

tannewt avatar tannewt commented on September 25, 2024

This is a similar problem to SparkFun's micromod and I think the right answer is for the board level to be at the module boundary. The board module would map between the module pinout and the IC's pinout. Then, you'd have a library for the carrier board that maps the module pinout to the board's pinout. This separation ensures that the carrier board mapping works for any module.

So, I don't think Blinka should detect Piunora, it should only know it's a CM4 and what variant. Then, have a library for Piunora that folks use.

from adafruit_python_platformdetect.

timonsku avatar timonsku commented on September 25, 2024

That is a good point!
Makes maintenance of variants easier as well. The only problem I would see it the module board could already make assumptions about peripherals and assigns them a different use/config than the carrier library would. It would be important to ensure that the module board has no such assumptions and leaves everything unconfigured so that no conflicts arise.
The question that comes up for me there then is whether it should all just be convention or if the concept of module and carrier should be introduced explicitly. Which could be handy to also handle things like compatibility checking. Maybe a future version of that module form factor is not 100% compatible with my carrier due to a quirk.

Another reason for maybe introducing these concepts is for boards that are in this in-between state of being a dev board and being a module. The Pi Pico is a good example. It is a dev board but is also sold in reels of tape for pick and placing.
That would mean you would likely see carriers using the pico as an implementation of the controller and not as a dev board. In this case you might want to have some defaults pre-configured though, not so if it is used as a module instead.

from adafruit_python_platformdetect.

tannewt avatar tannewt commented on September 25, 2024

A module's software should only make assumptions that are dictated by the module spec. I don't know where to formalize the carrier idea. Maybe circuitpython.org can have another grid for carriers that link to the corresponding library.

One existing example is our featherwing library: https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing

from adafruit_python_platformdetect.

timonsku avatar timonsku commented on September 25, 2024

Well in the case of something like the CM4 that is a completely open ended piece of hardware and wholly defined by the carrier. Other things like MicroMod might be more specific here but I would not say this is not the norm. SoM are intended to be a light abstraction layer on top of a SoC and not define an application in any way (e.g. a full board).
The issue comes if you treat a module also as board, like it can be the case with the Pi Pico. In that case the board might want to setup standard peripherals on certain pins when you view it as a dev board but this would be problematic if I implement it as a module as I then stand in conflict with my carrier specific library.
If that differentiation can't be made then I'm not sure we can then treat carriers any different from boards and rather as any other implementations of the specific SoC/MCU e.g. a board.

I can see how that can get problematic at scale with such a massive system like MicroMod where everything is supposed to work in any combination of SoMs and carriers and having lots of each.
But then again we also have a massive amount of boards that are a SAMD21 implementations with just differing peripherals usages and I'm not sure if they really are that different from that just because there is an added interconnect.

from adafruit_python_platformdetect.

tannewt avatar tannewt commented on September 25, 2024

Well in the case of something like the CM4 that is a completely open ended piece of hardware and wholly defined by the carrier.

The CM4 defines things like flash, ram and connectivity though too. Do we have one build for each carrier and CM4 variant combination?

But then again we also have a massive amount of boards that are a SAMD21 implementations with just differing peripherals usages and I'm not sure if they really are that different from that just because there is an added interconnect.

I'm not sure what the right thing is. The library approach has a nice clean separation of concerns but could limit what the software could auto-init.

from adafruit_python_platformdetect.

timonsku avatar timonsku commented on September 25, 2024

The CM4 defines things like flash, ram and connectivity though too. Do we have one build for each carrier and CM4 variant combination?

I guess here is where the difference between Blinka and CPY comes in as storage and RAM is handled by the OS so blinka does not have to care about such differences as CPY has to. If it were not for the different HW ID there is no difference between a CM4 and a Raspberry Pi 4 SBC. The only thing that needs to be supported is the SoC.

It would not work out for me if I could not rely on the fact that I'm free to use peripherals as I wish. E.g. if the underlying board inits some pins as SPI by default even though I want to use them for I2C.
I do appreciate the library approach and it would make it a lot easier to update for me than if it were bundled with Blinka / CPY.

We might not need to explicitly have the concept of a carrier (the way to handle them on cpy.org can be separate I think) but maybe its enough if a library can ask for the board to not initialize any peripherals when importing?
Here my lack of Python skill shows as I don't know if that is possible with Python modules or the way that the board object works, which is probably also quite different between Blinka and CPY?

But my idea is that a user would not import the board at all when using a carrier but only import the carrier library and the library takes care of importing everything correctly and exposing its own pin aliases and default peripherals.

In that case another option could be a function call to the board object to de-initialize/free everything that the board might have created, if that can't be specified on import to not happen to begin with.

from adafruit_python_platformdetect.

makermelissa avatar makermelissa commented on September 25, 2024

The way it is now is it uses the chip like we have defined for the Pi 4 and the board is a combination of the SoM and IO Carrier board which work for many people, especially since Raspberry Pi provides a schematic of this and expects you to just remove what you won't use for custom carrier boards. If there is a custom carrier board that differs significantly, I think it makes sense to add it as a new "board" and I think the easiest way to tell the platformdetect that it's different is to create some kind of ID file like mentioned earlier in this issue. This is a very similar approach to the one that many boards using the popular AllWinner H3 have taken with Armbian.

from adafruit_python_platformdetect.

timonsku avatar timonsku commented on September 25, 2024

Yea makes sense. I'm open to both approaches really, as long as I can provide an easy solution to users :)

from adafruit_python_platformdetect.

tannewt avatar tannewt commented on September 25, 2024

I guess here is where the difference between Blinka and CPY comes in as storage and RAM is handled by the OS so blinka does not have to care about such differences as CPY has to.

Yup, I'm thinking ahead to how we'd put CircuitPython on it. :-)

I'm still not sure we want board to equal carrier though. It'll break whenever we have a difference in modules that require a different build. This is more obvious now with MicroMod but I wouldn't be surprised to find CM4 compatible modules that aren't broadcom based in the future.

But my idea is that a user would not import the board at all when using a carrier but only import the carrier library and the library takes care of importing everything correctly and exposing its own pin aliases and default peripherals.

Yup, that'd be my expectation to. Just like we have microcontroller.pin now in CPU but no one uses it afaik.

from adafruit_python_platformdetect.

timonsku avatar timonsku commented on September 25, 2024

Yup, I'm thinking ahead to how we'd put CircuitPython on it. :-)

oh I see :)

I'm still not sure we want board to equal carrier though. It'll break whenever we have a difference in modules that require a different build. This is more obvious now with MicroMod but I wouldn't be surprised to find CM4 compatible modules that aren't broadcom based in the future.

Yea thats fair. Again as long as I can ensure that I can have a clean slate for my library without the user taking specific action in their code I'm good (other than me dictating what your default import should look like). Can gladly handle this via libraries. Asynchronous maintenance is kinda good here as a carrier will likely be more feature rich than a plain board and might need updates more frequently than CPY releases.

Yup, that'd be my expectation to. Just like we have microcontroller.pin now in CPU but no one uses it afaik.

ah what is this microcontroller.pin feature? I don't think I have seen that

from adafruit_python_platformdetect.

makermelissa avatar makermelissa commented on September 25, 2024

ah what is this microcontroller.pin feature? I don't think I have seen that

It's related to the original MicroPython support.

from adafruit_python_platformdetect.

tannewt avatar tannewt commented on September 25, 2024

ah what is this microcontroller.pin feature? I don't think I have seen that

It's related to the original MicroPython support.

I don't think MicroPython has it. We present pins with their chip level names in addition to the board names:

Adafruit CircuitPython 6.2.0-beta.1-66-g7f5d8b8ac-dirty on 2021-02-04; Adafruit Feather RP2040 with rp2040
>>> import microcontroller.pin
>>> print(dir(microcontroller.pin))
['__class__', 'GPIO0', 'GPIO1', 'GPIO10', 'GPIO11', 'GPIO12', 'GPIO13', 'GPIO14', 'GPIO15', 'GPIO16',
'GPIO17', 'GPIO18', 'GPIO19', 'GPIO2', 'GPIO20', 'GPIO21', 'GPIO22', 'GPIO23', 'GPIO24', 'GPIO25',
'GPIO26', 'GPIO27', 'GPIO28', 'GPIO29', 'GPIO3', 'GPIO4', 'GPIO5', 'GPIO6', 'GPIO7', 'GPIO8', 'GPIO9']
>>> import board
>>> print(dir(board))
['__class__', 'A0', 'A1', 'A2', 'A3', 'D0', 'D1', 'D10', 'D11', 'D12', 'D13', 'D24', 'D25', 'D4', 'D5', 'D6',
'D9', 'I2C', 'MISO', 'MOSI', 'NEOPIXEL', 'NEOPIXEL_POWER', 'RX', 'SCK', 'SCL', 'SDA', 'SPI', 'TX']

The names refer to the same objects under the hood.

from adafruit_python_platformdetect.

makermelissa avatar makermelissa commented on September 25, 2024

Ah, I did not know this. :)

from adafruit_python_platformdetect.

timonsku avatar timonsku commented on September 25, 2024

I don't think MicroPython has it. We present pins with their chip level names in addition to the board names:
The names refer to the same objects under the hood.

Oh thats a great feature!

from adafruit_python_platformdetect.

makermelissa avatar makermelissa commented on September 25, 2024

Transferring to Platform Detect as this is more of a detection issue.

from adafruit_python_platformdetect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.