aarch64-mainline odroid-c2 device tree

Discussion about U-Boot and the kernel.

aarch64-mainline odroid-c2 device tree

Postby uncarvedblock » Thu Apr 11, 2019 8:09 pm

I was reading the odroid wiki over at hardkernel, and was interested in adding a gpio power key to my c2 running the mainline kernel. (relevant wiki page: Power Off and Wake Up using GPIO Key Button) However, the mainline dtb doesn't seem to have the necessary entry "gpio_keypad"

Modifying, the dtb or creating an overlay is new territory for me, does anyone have any suggested references to go about this?

On a related note, the switch I would like to use has an LED ring, I would like to modify the heartbeat LED gpios (re: HK wiki:Alternative Heartbeat LED) which may be a bit easier since the heartbeat gpio is in the mainline device tree.

When I run ftdget on /leds/blue/gpios, it returns different numbers than the hk wiki states. Since the &gpio_ao number is different in mainline, I am unsure how to go about finding the &gpio number(s) used by the 40-pin header, which i assume are also different from the hk kernel.

Would any of this work in an overlay rather than modifying the mainline dtb, and if so would that make future upgrades easier?

Any assistance would be much appreciated. Thanks!
uncarvedblock
 
Posts: 3
Joined: Mon Mar 18, 2019 3:40 pm

Re: aarch64-mainline odroid-c2 device tree

Postby pigiron » Tue Apr 16, 2019 4:26 pm

Since others with perhaps more knowledge seem to have gone mute, I took a look at this. But fair warning, I'm still getting my head shaped around the device tree and embedded Linux myself. So you should verify the info below, or someone else could jump in.
$this->bbcode_second_pass_quote('', 'H')owever, the mainline dtb doesn't seem to have the necessary entry "gpio_keypad"

As far as I can tell, the mainline kernel doesn't have a "gpio_keypad". But it seems to have something similar called "gpio-keys", and Arch builds a mainline kernel module for it. However, it has a different device tree node format:

https://www.mjmwired.net/kernel/Documen ... o-keys.txt
$this->bbcode_second_pass_quote('', 'M')odifying, the dtb or creating an overlay is new territory for me, does anyone have any suggested references to go about this?

I've been using the spec itself (and it's not that bad) along with the device tree bindings documentation for the Linux kernel:

https://github.com/devicetree-org/devic ... s/tag/v0.2
https://www.mjmwired.net/kernel/Documen ... /bindings/

While changing the device tree source itself is certainly possible, I simply disassemble the shipped /boot/dtbs/amlogic/meson-gxbb-odroidc2.dtb file (after making a backup copy):

dtc -o <some-filename> -I dtb -O dts meson-gxbb-odroidc2.dtb

Then edit <some-filename>, and recompile it:

dtc -o meson-gxbb-odroidc2.dtb -I dts -O dtb <some-filename>

I have to do that after most upgrades to get my realtime clock from Ameridroid to work on my C2.
$this->bbcode_second_pass_quote('', 'S')ince the &gpio_ao number is different in mainline, I am unsure how to go about finding the &gpio number(s) used by the 40-pin header, which i assume are also different from the hk kernel.

Yea, the mainline seems to be different in this area. Using the DT documentation (see above) and a disassembled dtb file, my best guess is that the header GPIO pins in the mainline use a 26 (hex 0x1a) bank number. For example:
$this->bbcode_second_pass_code('', '$ fdtget meson-gxbb-odroidc2.dtb /regulator-tflash_vdd gpio
26 87 0')
Which is "gpio = <&gpio GPIOY_12 GPIO_ACTIVE_HIGH>;" in the device tree source. See include/dt-bindings/gpio/meson-gxbb-gpio.h in the kernel source for the pin numbers.

Verify all of the above, and good luck!
pigiron
 
Posts: 7
Joined: Fri Apr 05, 2019 3:48 pm
Top

Re: aarch64-mainline odroid-c2 device tree

Postby summers » Tue Apr 16, 2019 8:24 pm

To my mind whats easiest is to first examine $this->bbcode_second_pass_code('', '/proc/device-tree') and decide what you want to have.

Then edit $this->bbcode_second_pass_code('', '/boot/boot.txt')

and change $this->bbcode_second_pass_code('', ' if load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} /boot/dtbs/${fdtfile}; then
if load ${devtype} ${devnum}:${distro_bootpart} ${ramdisk_addr_r} /boot/initramfs-linux.img; then
')

To something like

$this->bbcode_second_pass_code('', ' if load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} /boot/dtbs/${fdtfile}; then
fdt addr ${fdt_addr_r}
fdt resize 4096
fdt set /soc/apb@d0000000/mmc@74000 max-frequency <0x08f0d180>
ftd resize
if load ${devtype} ${devnum}:${distro_bootpart} ${ramdisk_addr_r} /boot/initramfs-linux.img; then
')

Then run $this->bbcode_second_pass_code('', './mkscr')

This is both easier, and safer than changing the raw device tree - especially if done on a sd card. If you get it wong, you just pull the sd card and correct ...

Probably also worth adding, rather than decompiling the dtb, its easier to browse the source, as its arranged better: https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
summers
 
Posts: 984
Joined: Sat Sep 06, 2014 12:56 pm

Re: aarch64-mainline odroid-c2 device tree

Postby uncarvedblock » Thu Apr 18, 2019 6:29 pm

@pigiron, @summers

Thanks both of you, the info will get me going in the right direction hopefully. I like the idea of modifying the boot.txt rather than the dtb if possible, I think it will be easier to maintain than recompiling the dtb every upgrade.

Maybe a simple pacman hook with some ftdput commands will accomplish what I'm aiming for too, will keep you posted on progress when I have some time to experiment.

thanks again!
uncarvedblock
 
Posts: 3
Joined: Mon Mar 18, 2019 3:40 pm


Return to U-Boot/Kernel

Who is online

Users browsing this forum: No registered users and 5 guests