jubilinux / jubilinux

Issue tracking for jubilinux
http://www.jubilinux.org/
8 stars 1 forks source link

GPIO state at boot #12

Open farfromrefug opened 6 years ago

farfromrefug commented 6 years ago

I need to change the state of some GPIO at boot. Seeing this thread it appears i could build a custom kernel and set it there: https://communities.intel.com/thread/106183

Do you have any idea where this might be, or even if this is possible? I also looked at the config files but did not see anything related to it

THanks

esialb commented 6 years ago

How soon in the boot sequence do you need the GPIO configured? Could you just set them in /etc/rc.local ?

farfromrefug commented 6 years ago

@esialb That is too late. Actually we have a pump connected to a PWM. As soon as the EDison is plugged the Pump goes to 100% which is very loud. We need to make sure it goes to 0% as soon as possible. That s why i am thinking kernel...

farfromrefug commented 6 years ago

@esialb sorry to bump but this is really important to me. It even got more important since we are implementing a "pressure" power button. Thanks

esialb commented 6 years ago

@farfromrefug Have you considered using a small arduino as a realtime IO coprocessor? You can easily talk to it over I2C from an edison, and you'd get your GPIO configured within milliseconds. The alternatives you mentioned elsewhere, modifying u-boot or the kernel, sound rather brittle and difficult to reproduce later.Teensy 3.6 makes an excellent IO coprocessor, but pretty much any microcontroller that can act as an I2C slave will work. You can even re-program your microcontroller from the edison if you want to reconfigure things without physical access to the system.

farfromrefug commented 6 years ago

@esialb sadly i don't have a choice anymore, on product and its electronic can't be changed anymore. Software is my only option. In the future, we will get rid of the Edison (don't really have a choice anyway ;)) so we might do it as you mention.

So right now i will have to find how to set GPIO from the kernel or u-boot. About issue with reproducing you mean i can't clone an edison with its kernel/uboot?

Thanks @esialb for taking the time to answer

esialb commented 6 years ago

A U-Boot script is probably the best option. Rather than a custom kernel or custom u-boot image, u-boot can be used to write to system memory, and the GPIO should be memory-mapped. This is pretty much the same as using u-boot to disable the watchdog timer in case /etc/rc.local doesn't run soon enough.

esialb commented 6 years ago

I don't actually know the memory addresses of the GPIO pins, but it may be documented somewhere on the Intel forums. Failing that, examination of the kernel source would work.

farfromrefug commented 6 years ago

@esialb ok great i will look for this! (might need your help again though)

farfromrefug commented 6 years ago

@esialb i failed to find the GPIO memory mapping. And intel does seem to want to help. I found this: http://www.howtobuildsoftware.com/index.php/how-do/h9j/embedded-embedded-linux-boot-gpio-u-boot-u-boot-select-boot-partition-based-on-gpio-state http://developer.toradex.com/knowledge-base/gpio-(linux)#GPIO_UBoot

It seems that there is a gpio uboot "module". I tried getting into uboot and run gpio but the command is not there. Do you think i can add that module to uboot(sorry not that familiar with uboot dev)? Could i then use it within a uboot script?

Thanks!