RobertCNelson / bb-kernel

MIT License
130 stars 102 forks source link

Using SPI onBeagleBone 4.4.110-bone21 #57

Closed AnneBruner closed 4 years ago

AnneBruner commented 4 years ago

We are using a BeagleBone Black that started w/ Debian 8.6 2016 11-06 . The uEnv.txt was modified to include: cape_enable=bone_capemgr.enable_partno=BB-SPIDEV1 After rebooting, I am able to see my SPI pins in pingroups I then updated the kernel to 4.4.110-bone21 After rebooting, my SPI pins no longer show up in my pingroups. We have been using this version for a project that now requires use of the SPI bus and would like to do minimal changes to get it working. Is there another version of the BB kernel that would make sense to upgrade to that would use the same cape implementation (cape_enable-bone_capemgr.enable_partno...)?

RobertCNelson commented 4 years ago

@AnneBruner , the whole kernel based "bone_capemgr" has been ripped out and is no longer supported. Please run this command, and we can walk you thru transitioning to u-boot based overlays.

sudo /opt/scripts/tools/version.sh

https://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_Overlays

Regards,

AnneBruner commented 4 years ago

Thanks so much for responding! Not sure why but I don’t have the version.sh script on my BB. Here’s some info:

root@beaglebone:/opt/scripts/tools# uname -r 4.4.110-bone21 root@beaglebone:/opt/scripts/tools# uname -a Linux beaglebone 4.4.110-bone21 #2 Thu Mar 15 12:48:24 EDT 2018 armv7l GNU/Linux root@beaglebone:/opt/scripts/tools# cat /proc/version Linux version 4.4.110-bone21 (root@deb964vm) (gcc version 5.5.0 (Linaro GCC 5.5-2017.10) ) #2 Thu Mar 15 12:48:24 EDT 2018

BTW - we are using a custom cape. I have attached our dts file. Is there a known problem using the SPI bus on the bone21 kernel? I was aware all the bone_capemgr business had changed and was not sure how hard it would be to try to upgrade what we have.

Thanks, Anne Bruner

From: Robert Nelson notifications@github.com Sent: Friday, January 10, 2020 9:45 PM To: RobertCNelson/bb-kernel bb-kernel@noreply.github.com Cc: Anne Bruner anne.bruner@ndc.com; Mention mention@noreply.github.com Subject: [EXTERNAL] - Re: [RobertCNelson/bb-kernel] Using SPI onBeagleBone 4.4.110-bone21 (#57)

@AnneBrunerhttps://github.com/AnneBruner , the whole kernel based "bone_capemgr" has been ripped out and is no longer supported. Please run this command, and we can walk you thru transitioning to u-boot based overlays.

sudo /opt/scripts/tools/version.sh

https://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_Overlayshttps://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_Overlays

Regards,

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/RobertCNelson/bb-kernel/issues/57?email_source=notifications&email_token=AOHYTH2INL4HX3NARN43AZ3Q5EXEDA5CNFSM4KFNTWL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIVXEQY#issuecomment-573272643, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AOHYTH535MK5HRHALT3WTW3Q5EXEDANCNFSM4KFNTWLQ.

WARNING: This email originated from outside of the NDC Technologies, Inc. Do not click links or open attachments unless you recognize the sender and know the content is safe.

Disclaimer

Confidentiality: This e-mail and its attachments are intended for the above named only and may be confidential. If they have come to you in error you must take no action based on them, nor must you copy or show them to anyone; please reply to this e- mail and highlight the error. Security Warning: Please note that this e-mail has been created in the knowledge that Internet e-mail is not a 100% secure communications medium. We advise that you understand and observe this lack of security when e-mailing us. Viruses: Although we have taken steps to ensure that this e-mail and attachments are free from any virus, we advise that in keeping with good computing practice the recipient should ensure they are actually virus free.

AnneBruner commented 4 years ago

Sorry so delayed but am finally try to upgrade from using bone_capemgr to the u-boot based overlays. We have a custom cape enabled in uEnv.txt and I'm not sure how to incorporate this into a new BeagleBone image. I have created an SD card using the info found here: https://www.digikey.com/eewiki/display/linuxonarm/BeagleBone+Black (used Debian 10.2 and kernel 4.19.94-bone44)

Originally our BB didn't have a version.sh but used 'git pull' to update /opt/scripts. Here's the results from version.sh from our current setup. Any assistance would be greatly appreciated!

root@beaglebone:/opt/scripts/tools# ./version.sh git:/opt/scripts/:[e457c010efc76c4e6fecccb7a5f7ff9b0597c4c0] eeprom:[A335BNLT000A2616NDCT0002] model:[TI_AM335x_BeagleBone_Black] dogtag:[BeagleBoard.org Debian Image 2016-11-06] bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2016.11-rc3-00002-g73df7f]:[location: dd MBR] kernel:[4.4.110-bone21] nodejs:[v0.12.18] device-tree-override:[dtb=am335x-boneblack-emmc-overlay.dtb] /boot/uEnv.txt Settings: pkg check: to individually upgrade run: [sudo apt install --only-upgrade ] pkg:[bb-cape-overlays]:[4.4.20180307.0-0rcnee0~jessie+20180307] pkg:[bb-wl18xx-firmware]:[1.20161020-0rcnee1~bpo80+20161020+1] pkg:[kmod]:[18-3rcnee1~jessie+20171005] WARNING:pkg:[librobotcontrol]:[NOT_INSTALLED] WARNING:pkg:[firmware-ti-connectivity]:[NOT_INSTALLED] groups:[debian : debian adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal netdev i2c admin spi tisdk weston-launch xenomai] cmdline:[console=ttyO0,115200n8 bone_capemgr.enable_partno=NDCT-HMI root=UUID=696cf592-ae79-4155-8a7f-feec9de3d38f ro rootfstype=ext4 rootwait coherent_pool=1M] dmesg | grep remote [ 5.114639] remoteproc0: wkup_m3 is available [ 5.119123] remoteproc0: Note: remoteproc is still under development and considered experimental. [ 5.128142] remoteproc0: THE BINARY FORMAT IS NOT YET FINALIZED, and backward compatibility isn't yet guaranteed. dmesg | grep pru dmesg | grep pinctrl-single [ 3.859963] pinctrl-single 44e10800.pinmux: 142 pins at pa f9e10800 size 568 dmesg | grep gpio-of-helper lsusb Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub END

RobertCNelson commented 4 years ago

@AnneBruner I'm now confused, you "version.sh" output doesn't match what you stated in your first paragraph... Please don't jump between images.. ;)

So starting again, with your "current" image please run:

sudo /opt/scripts/tools/version.sh

Regards,

AnneBruner commented 4 years ago

My apologies. The version.sh that I ran is for our 'original' image (4.4.110-bone21) I am trying to upgrade to a newer version because we can't seem to get the SPI bus working on the original image. I am not sure which Debian and Kernel to use for a new version so I just picked Debian 10.2 and 4.19.94-bone44. Is this a good choice and is it that image you want me to run version.sh on?

RobertCNelson commented 4 years ago

@AnneBruner SPI will work on all images, so just pick one and we will go over what your missing for u-boot overlays to work..

Regards,

AnneBruner commented 4 years ago

Here is version.sh from my new image. root@arm:/opt/scripts/tools# ./version.sh git:/opt/scripts/:[41b446ab04774981ab5c2cccc8160b8b4e4f36e7] eeprom:[A335BNLT000A2616NDCT0002] model:[TI_AM335x_BeagleBone_Black] bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2019.04-dirty]:[location: dd MBR] bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2016.11-rc3-00002-g73df7f]:[location: dd MBR] UBOOT: Booted Device-Tree:[am335x-boneblack.dts] kernel:[4.19.94-bone44] /boot/uEnv.txt Settings: pkg check: to individually upgrade run: [sudo apt install --only-upgrade ] pkg:[bb-cape-overlays]:[4.14.20200129.0-0rcnee0~buster+20200129] WARNING:pkg:[bb-wl18xx-firmware]:[NOT_INSTALLED] pkg:[kmod]:[26-1] WARNING:pkg:[librobotcontrol]:[NOT_INSTALLED] pkg:[firmware-ti-connectivity]:[20190114-2] groups:[debian : debian adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal netdev i2c gpio pwm eqep remoteproc admin spi tisdk weston-launch xenomai bluetooth cloud9ide] cmdline:[console=ttyO0,115200n8 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait] dmesg | grep remote [ 1.643035] remoteproc remoteproc0: wkup_m3 is available [ 2.247960] remoteproc remoteproc0: powering up wkup_m3 [ 2.253314] remoteproc remoteproc0: Booting fw image am335x-pm-firmware.elf, size 217168 [ 2.269560] remoteproc remoteproc0: remote processor wkup_m3 is now up dmesg | grep pru dmesg | grep pinctrl-single [ 0.486663] pinctrl-single 44e10800.pinmux: 142 pins, size 568 dmesg | grep gpio-of-helper lsusb Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub END

RobertCNelson commented 4 years ago

@AnneBruner Okay, so things are looking better.

bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2019.04-dirty]:[location: dd MBR]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2016.11-rc3-00002-g73df7f]:[location: dd MBR]

First, let's remove u-boot on the eMMC, it's blocking the version of the microSD from working..

sudo dd if=/dev/zero of=/dev/mmcblk1 bs=1M count=10

Then in /boot/uEnv.txt add this line:

enable_uboot_overlays=1

Now let's reboot and rerun "./version.sh" just to double check things..

Next, which spidev pins do you need to enable..

Regards,

AnneBruner commented 4 years ago

Here is the updated version info. I have an existing dts file that was used in the original bone-capemgr system. Can I reuse that?

root@arm:/opt/scripts/tools# ./version.sh git:/opt/scripts/:[41b446ab04774981ab5c2cccc8160b8b4e4f36e7] eeprom:[A335BNLT000A2616NDCT0002] model:[TI_AM335x_BeagleBone_Black] bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2019.04-dirty]:[location: dd MBR] UBOOT: Booted Device-Tree:[am335x-boneblack-uboot.dts] UBOOT: Loaded Overlay:[BB-ADC-00A0] UBOOT: Loaded Overlay:[BB-BONE-eMMC1-01-00A0] UBOOT: Loaded Overlay:[BB-HDMI-TDA998x-00A0] kernel:[4.19.94-bone44] /boot/uEnv.txt Settings: uboot_overlay_options:[enable_uboot_overlays=1] pkg check: to individually upgrade run: [sudo apt install --only-upgrade ] pkg:[bb-cape-overlays]:[4.14.20200129.0-0rcnee0~buster+20200129] WARNING:pkg:[bb-wl18xx-firmware]:[NOT_INSTALLED] pkg:[kmod]:[26-1] WARNING:pkg:[librobotcontrol]:[NOT_INSTALLED] pkg:[firmware-ti-connectivity]:[20190114-2] groups:[debian : debian adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal netdev i2c gpio pwm eqep remoteproc admin spi tisdk weston-launch xenomai bluetooth cloud9ide] cmdline:[console=ttyO0,115200n8 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait] dmesg | grep remote [ 1.637258] remoteproc remoteproc0: wkup_m3 is available [ 2.238075] remoteproc remoteproc0: powering up wkup_m3 [ 2.243428] remoteproc remoteproc0: Booting fw image am335x-pm-firmware.elf, size 217168 [ 2.259658] remoteproc remoteproc0: remote processor wkup_m3 is now up dmesg | grep pru dmesg | grep pinctrl-single [ 0.480817] pinctrl-single 44e10800.pinmux: 142 pins, size 568 dmesg | grep gpio-of-helper lsusb Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub END

RobertCNelson commented 4 years ago

@AnneBruner Okay, now in /boot/uENv.txt add:

disable_uboot_overlay_audio=1
uboot_overlay_addr0=/lib/firmware/BB-SPIDEV1-00A0.dtbo

and the spi pins of P9_28, P9_29, P9_30, and P3_31 will now be enabled..

Regards,

AnneBruner commented 4 years ago

OK - that booted fine. We have a custom dts file that includes configuration for our lcd screen, I2C, spi... Should I just be able to replace the BB-SPIDEV1-00A0.dtbo with our compiled dtbo file? Wasn't sure if I should use addr0 or a different slot. And do I need to specifically turn off HDMI?

RobertCNelson commented 4 years ago

@AnneBruner you might want to post your custom dts on gist.github.com so i can take a look at it.. Some things have changed, other's haven't..

In your first message, you had "cape_enable=bone_capemgr.enable_partno=BB-SPIDEV1", so i just assumed you were using BB-SPIDEV1-00A0.dtbo, as that needs HDMI audio disabled..

Regards,

AnneBruner commented 4 years ago

Hopefully I did that right :) https://gist.github.com/AnneBruner/597e44a37d909b2d15f12920a1724a33

AnneBruner commented 4 years ago

Well I tried using the dts file as-is and it doesn't seem to be functioning correctly. We have a 24-bit lcd and the colors are wrong. Also, the aomod detection pins don't seem to be working. Hopefully you can provide some insight into what I would need to change in our dts file. Thanks much.

AnneBruner commented 4 years ago

I was finally able to get the 24-bit display functioning correctly. Found that I needed to add: blue-and-red-wiring="crossed"; to my lcdc section of the dts file. However, I am still struggling trying to get the gpio's working correctly. I am currently trying to get the ao_mod_detection pins working. Do you have any working examples of a dts file configured for gpio support?

RobertCNelson commented 4 years ago

Awesome, well there are a lot of examples here: https://github.com/beagleboard/bb.org-overlays

If your gpio are output only use the led sub-system, if they are input only, use the gpio-key sub-system

Input: https://github.com/beagleboard/bb.org-overlays/blob/master/src/arm/BB-GPIO-GROVE-BUTTON.dts#L89-L118

Ouput: https://github.com/beagleboard/bb.org-overlays/blob/master/src/arm/BB-GPIO-GROVE-LED.dts#L92-L98

If it's both, don't define them in the overlay, but instead use gpiod.

Your existing, bone-pinmux-helper is broken on mainline... (and broken in general, thus don't use it)

          uart_fieldbus_helper{
          compatible="bone-pinmux-helper";
                pinctrl-names = "default";
                pinctrl-0 = <&uart_fieldbus_reset>;                        
          status = "okay";
        };

Regards,

AnneBruner commented 4 years ago

Robert, I am trying really hard to understand how to convert our existing dts to one that works with the new BB image - but this is all Greek to me. And I can't seem to find any info on the web that can dummy it down for me. I am trying to just re-work the ao_mod_detection part of the dts. If we are interfacing to these pins using C code that writes to the file system (eg export, cat)...

Do I need to change my lines defining direction, mode... ? ao_mod_detection: pinmux_ao_mod_detection { pinctrl-single,pins = < 0x090 0x27 / Timer4.GPIO2_2, INPUT_PULLDOWN | MODE7 / 0x094 0x27 / Timer7.GPIO2_3, INPUT_PULLDOWN | MODE7 / 0x09c 0x27 / Timer5.GPIO2_5, INPUT_PULLDOWN | MODE7 / 0x098 0x27 / Timer6.GPIO2_4, INPUT_PULLDOWN | MODE7 /

; };

Or should I use AM33XX_IOPAD as your example does?

You mentioned I should not use bone-pinmux-helper. So to rewrite the fragment part, Should I use: target-path="/"; rather than target = <&ocp>; as your BB-GPIO-GROVE-BUTTON example does?

And use compatible="gpio_keys" rather than compatible="bone-pinmux-helper"?

And can I use = <&ao_mod_detection> or do I need to use something like: grove_button_1057_0@0 {...} for each pin?

When I try running my test app, all 4 inputs are returning a value of '1' which is not correct.

RobertCNelson commented 4 years ago

@AnneBruner, if your going to do the whole export, cat, etc.. Just enable them by default:

    fragment@0 {
        target = <&am33xx_pinmux>;
        __overlay__ {

to:

    fragment@0 {
        target = <&am33xx_pinmux>;
        __overlay__ {
            pinctrl-names = "default";
            pinctrl-0 = <&ao_mod_detection>;

Then rip out..

fragment@9 {
        target = <&ocp>;    
        __overlay__ {
      ao_mod_detection_helper{
          compatible="bone-pinmux-helper";
                pinctrl-names = "default";
                pinctrl-0 = <&ao_mod_detection>;
          status = "okay";
        };

Regards,