linux icon indicating copy to clipboard operation
linux copied to clipboard

CONFIG_TEGRA_PARTITION with tegra132

Open MartijnBraam opened this issue 5 years ago • 5 comments
trafficstars

I'm trying to make mainline linux work on the nexus 9, continueing on the work already done on https://wiki.postmarketos.org/wiki/Google_Nexus_9_(htc-flounder)

I managed to make the eMMC recognized in the kernel by adding it to the dts but I'm having issues making it recognize the gpt partitions. It seems like the tegra partitions thing doesn't work at all yet on tegra132, the bootloader does pass the gpt and gpt_sector= but not tegraboot=sdmmc. Worked around that by manually adding tegraboot to the cmdline in boot.img

This is the changes I made so far: https://github.com/MartijnBraam/linux-grate/commit/ab0d23725b0221c863b3f602b8931f06c92a5bb8

The current issue I have is that nvidia,tegra124-sdhci doesn't have the memory address as only value so just duplicating the code doesn't work.

MartijnBraam avatar Aug 24 '20 17:08 MartijnBraam

Hello @MartijnBraam! Nice work on getting TegraPT to work on Nexus 9! I didn't even know that TegraPT is needed for Nexus 9. The code change looks good to me, I can incorporate it into grate-kernel on next update. I suppose you may add tegraboot=sdmmc to the bootargs in the device-tree in order to avoid changing cmdline of the bootimg, couldn't you? The kernel needs to know whether it's okay to check eMMC for the TegraPT and the cmdline parameter is the best option for now. It's a bit unfortunate that Tegra bootloaders are inconsistent, but that's what we have and need to deal with it :)

digetx avatar Aug 24 '20 19:08 digetx

Oh, wait! Seems you haven't got it to work yet. Could you please clarify what do you mean by the memory address as only value?

digetx avatar Aug 24 '20 19:08 digetx

Ah, I see now. Could you please try this change:

diff --git a/block/partitions/tegra.c b/block/partitions/tegra.c
index a2ccd644e377..e754159d91e8 100644
--- a/block/partitions/tegra.c
+++ b/block/partitions/tegra.c
@@ -21,6 +21,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/of.h>
+#include <linux/of_address.h>
 #include <linux/sizes.h>
 #include <linux/slab.h>
 #include <linux/string.h>
@@ -456,9 +457,9 @@ tegra_partition_table_emmc_boot_offset(struct tegra_partition_table_parser *ptp)
 	struct mmc_card *card = mmc_bdev_to_card(ptp->state->bdev);
 	const struct of_device_id *matched;
 	const u32 *sdhci_bases;
+	const __be32 *addrp;
 	u32 sdhci_base;
 	unsigned int i;
-	int err;
 
 	/* filter out unexpected/untested boot sources */
 	if (!card || card->ext_csd.rev < 3 ||
@@ -477,11 +478,12 @@ tegra_partition_table_emmc_boot_offset(struct tegra_partition_table_parser *ptp)
 	sdhci_bases = matched->data;
 
 	/* figure out SDHCI instance ID by the base address */
-	err = of_property_read_u32_index(card->host->parent->of_node,
-					 "reg", 0, &sdhci_base);
-	if (err)
+	addrp = of_get_address(card->host->parent->of_node, 0, NULL, NULL);
+	if (!addrp)
 		return -1;
 
+	sdhci_base = of_translate_address(card->host->parent->of_node, addrp);
+
 	for (i = 0; i < TEGRA_PT_SDHCI_DEVICE_INSTANCES; i++) {
 		if (sdhci_base == sdhci_bases[i])
 			break;

digetx avatar Aug 24 '20 19:08 digetx

Yep that seems to work great, combined the changes in here: https://github.com/MartijnBraam/linux-grate/commit/c87728dbb52fc35ccc44e982fe9da0a7d7e7d9f9

Now I'm out of the initramfs at least :)

This is in my kernel log with the change:

[    2.269896] Primary GPT is invalid, using alternate GPT
[    2.278858]  mmcblk0: p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 p17 p18 p19 p20 p21 p22 p23 p24 p25 p26 p27 p28 p29 p30 p31 p32 p33

MartijnBraam avatar Aug 24 '20 21:08 MartijnBraam

Awesome!

Wow, Nexus 9 has 33 partitions? Crazy :)

digetx avatar Aug 25 '20 13:08 digetx