narmstrong changed the topic of #linux-amlogic to: Amlogic mainline kernel development discussion - our wiki http://linux-meson.com/ - ml linux-amlogic@lists.infradead.org - official channel moved from Freenode - publicly logged on https://libera.irclog.whitequark.org/linux-amlogic
shoragan has quit [Quit: quit]
shoragan has joined #linux-amlogic
shoragan has quit [Read error: Connection reset by peer]
shoragan has joined #linux-amlogic
jacobk has joined #linux-amlogic
jacobk has quit [Ping timeout: 240 seconds]
camus has joined #linux-amlogic
_whitelogger has joined #linux-amlogic
f_ has joined #linux-amlogic
<narmstrong> minute: I pushed a new branch with all the fix I made you do + a possible Vsync/Hsync fix that could probably help https://github.com/superna9999/linux/tree/amlogic/v6.4/upstream/dsi-ccf-vim3
<narmstrong> f_: looks good, anyway there's no magic in ddr init anyway
<f_> Thanks!
<f_> I'm trying to make it compile.
<f_> And got this error:
<f_> drivers/amlogic/ddr/timing.c:350:65: error: result of '1 << 31' requires 33 bits to represent, but 'int' only has 32 bits [-Werror=shift-overflow=]
<f_> ¯\_(ツ)_/¯
<f_> Amlogic RAM "juju" then
camus has quit [Ping timeout: 246 seconds]
camus has joined #linux-amlogic
<f_> AARGH
<f_> drivers/amlogic/ddr/pll.c:91:42: error: result of '1 << 31' requires 33 bits to represent, but 'int' only has 32 bits [-Werror=shift-overflow=]
<f_> Don't tell me they wrote the exact same undefined behaviour everywhere else!!!
<f_> narmstrong: I'm doing all this because when trying to load an image there's an assertion error where fip_dev_handle is NULL. I highly suspect that's because of missing RAM init.
<f_> fip_dev_handle is a uintptr_t.
<narmstrong> I’m pretty sure they build with warning disabled like every vendor code out there :-p
<f_> Me too :P
<f_> There's a lot of missing #includes.
<f_> Like: They use stuff in a C file that's defined in a header file they don't even #include.
<f_> Also
<f_> I've never seen #include used for including......C files.
<f_> Also..TF-A is built with -Werr
<f_> I can really tell Amlogic *loooooves* undefined behaviour.
<f_> drivers/amlogic/ddr/ddr.h:23:14: error: redundant redeclaration of 'ddr_init' [-Werror=redundant-decls]
<f_> Lots of redundant declarations, too.
<f_> Oh well. They forgot:
<f_> #ifndef DDR_H
<f_> #define DDR_H
<f_> #endif /* DDR_H */
<f_> FINALLY......LINKING ERRORS!
<f_> Built /home/thelinuxmacbook/Desktop/gitcodestolenfromothers/u-boot-aml/arm-trusted-firmware/build/gxbb/debug/bl2.bin successfully
<f_> Got it to compile!
camus has quit [Remote host closed the connection]
camus has joined #linux-amlogic
JohnnyonFlame has quit [Ping timeout: 240 seconds]
elastic_dog has quit [Ping timeout: 240 seconds]
elastic_dog has joined #linux-amlogic
<f_> So
<f_> It compiles, but when running, it seems to be stuck at ddr_init_pctl.
<f_> Will push soon.
<f_> Well. It isn't stuck, but it resets.
<f_> Testers welcome.
<f_> Just.......
<f_> $ make CFLAGS=-w CROSS_COMPILE=aarch64-linux-gnu- PLAT=gxbb DEBUG=1 bl2
<f_> Preferably test this on a NanoPi-K2
<f_> :S
<f_> Sometimes it passes and then resets at
<f_> ddr_print_info
<f_> Well. It resets at ddr_size_detect
<f_> I need to figure out where it fails exactly.
minute has quit [Ping timeout: 248 seconds]
minute has joined #linux-amlogic
<f_> Now that I think about it, what they're mostly doing with wr_reg and rd_reg would probably be equivalent to using MOV and friends, in assembly.
<f_> Ok
<f_> It seems that RAM init actually works, BUT it is not that reliable.
<f_> And it doesn't work very well.
<f_> It thinks it has 4096 MB + 1024 MB
<f_> Still need to troubleshoot that.
<narmstrong> f_: wr_reg is a memory mapped register write, tf-a must have a function/macro that does that so no need to use a custom macro
<narmstrong> f_: the ddr init code is very old so somehow you would miss some optimization and tuning
<narmstrong> Reversing the modern bl2 would help figuring what changed since
<f_> Yeah, but I ain't an expert on reverse-engineering.
<f_> Disassembling the modern BL2 may help, however.
<f_> (if we exclude everything not related to DDR init)
<narmstrong> f_: at some point perhaps is should be simpler to add this platform init and ddr setup code in u-boot and use the SPL as bl2 loading the scp and bl301, look at https://github.com/u-boot/u-boot/blob/master/common/spl/spl_atf.c
<narmstrong> And we could ditch the shitty aml fip packaging and use FIT image for everything
<narmstrong> But for that we should reverse all the platforms…
<f_> Yeah
<f_> I highly suspect that the BL2 codebase hasn't changed much since 2015 however.
<f_> But still
<narmstrong> For the last est (g12a) they ship loadable binaries for ddr init
<f_> I see...IIRC they are briefly documented in the U-Boot wiki.
<f_> So, for G12A, there's no acs.bin
<f_> I'm curious about how Antonio reverse-engineered BL31.
<narmstrong> There is an acs.bin like before
<narmstrong> Bl31 isn’t encrypted so it’s easy
<narmstrong> For bl2 you need to dump it somehow
<f_> Dump what?
<f_> But wait a second..is BL2 encrypted?
<f_> narmstrong: I highly doubt it is encrypted. On gxbb it's just signed is it?
<narmstrong> Wait I thought is was encrypted, perhaps it’s only on the newer socs
<narmstrong> Honestly I never looked
<f_> I highly doubt it's encrypted on gxbb:
<f_> $ strings emmc_1b0.img | grep U-Boot
<f_> U-Boot 2015.01-g3fb479f-dirty (Jul 15 2016 - 13:06:58)
<f_> <...>
<f_> This is from a dump of the eMMC on my set-top box before I wiped it.
<f_> Doesn't look like it's encrypted.
<f_> And fun fact: I can see where acs.bin got inserted as well.
<f_> And I can see that it's different from the WeTek Play2's ACS.
<f_> (which works fine. meh)
<f_> narmstrong: But, even when RAM init """succeeds""", I still get that assertion error:
<f_> ASSERT: drivers/io/io_storage.c:174
<f_> Looking at io_storage.c, I see this:
<f_> int io_dev_init(uintptr_t dev_handle, const uintptr_t init_params)
<f_> <...>
<f_> assert(dev_handle != (uintptr_t)NULL);
<f_> So yeah, fip_dev_handle is still NULL.
* narmstrong hates rolling releases distro like Arch, I didn't boot on my Asahi install for 3months, now I need to update 900packages and download 2GiBs... anyway it's always surprising how asahi on my MacBook Air M2 works well
<narmstrong> and I hate KDE, I always hated KDE for the last 20years
<f_> I love Arch/Artix.
<narmstrong> I'm too old for this :-p
<narmstrong> for me Arch is Gentoo with pre-builds, in the old days we didn't have prebuilds and had to rebuild everything
<f_> Anyways, a little off-topic here :P
<narmstrong> yep, sorry for that^^
<f_> No problem. It happens =)
<f_> Even with channel operators.
<narmstrong> f_: who's supposed to init dev_handle for io_dev_init ?
* f_ looks that up.
<f_> plat_get_image_source()
vagrantc has joined #linux-amlogic
<f_> Let's stick in a INFO() at the top.
<f_> >INFO("hello plat_get_image_source\n")
<f_> Perfect.
<f_> At some point my logging style will be as bad as Amlogic's
<narmstrong> at least at some point you'll clean it up
<f_> Yup.
<f_> I always do that sort of stuff with my software.
<f_> Did it break? Just stick in a thousand printf()s! :P
<narmstrong> we all do
<f_> Glad I'm not the only person doing that. :P
<narmstrong> I always do, to lazy to get a debugger running if a set a print does the work
<f_> Nowadays, I more often use gdb..but TF-A doesn't have gdb..so...
<f_> Damn, forgot a `;`.
<f_> UART says INFO: hello plat_get_image_source
<f_> So it IS being ran before the assertion error.
<f_> In fact, it's JUST before the assertion error.
<f_> Digging further.
<f_> >INFO("hello io_open o/ how are you doing today?\n");
<f_> >io_result = io_open(dev_handle, image_spec, &image_handle);
<f_> I *highly* suspect io_open is causing this assertion error.
<f_> Huh?
<f_> This message didn't get printed at all...
<f_> Ok.
<f_> result = policy->check(policy->image_spec);
<f_> I'm 100% sure this is causing a problem.
<f_> Anything after it doesn't get ran.
<f_> I've put 2 INFO()s: one before and one after.
<f_> Guess what? only the one before got ran.
<narmstrong> what does policy->check() ?
<f_> narmstrong: Let's find out!
<f_> I ran a `git grep`.
<f_> Just to see where it's (supposed to be) defined.
<f_> int (*check)(const uintptr_t spec);
<f_> No idea what it does..
<f_> It isn't defined anywhere else.
<narmstrong> it is, it's either open_memmap or open_fip
<f_> Where is it defined? Just curious
<f_> I'm dumb.
<f_> But I now realise that check() is inside the plat_io_policy struct.
<f_> So it tries to open_fip().
<narmstrong> the name "check" is confusing since it only opens the file... and does no policy check
<f_> Yeah.
<f_> And we're back!
<f_> This should be precisely what we're looking for.
<f_> It does fail at io_dev_init.
<f_> Because, again, fip_dev_handle isn't defined..
<f_> And we said earlier that plat_get_image_source is supposed to define fip_dev_handle, right?
<f_> But itself runs io_dev_init which requires fip_dev_handle to be defined.......
<f_> well
<f_> At this point I'm stuck..
<f_> Most likely.
<f_> I guessed the offset. Now is the time to find the correct one.
<f_> It's supposed to be equal to PLAT_GXBB_FIP_BASE
<f_> The problem is: it doesn't exist in Amlogic's old BL2 tree.
<f_> git[master] ~thelinuxmacbook:amlogic-bl2 -mksh$ git grep FIP_BASE
<f_> git[master] ~thelinuxmacbook:amlogic-bl2 -mksh$
<f_> (off-topic: this isn't a macbook)
<narmstrong> you'll need to guess it!
<f_> I don't have much choice on that lol
<f_> First, I need to know what they meant by "fip_block_spec" :P
<f_> And then I open xxd with a random dump and look for that.
<f_> Well..fip_block_spec is the table.
<narmstrong> it should be loaded in ram at the same time as the bl2
* f_ remembers that BL2 and fip.bin are concatenated to create one file
<f_> So the FIP table should be after BL2, right?
<narmstrong> yup
<f_> 0000c000: 0100 64aa 7856 3412 0000 0000 0000 0000 ..d.xV4.........
<f_> Here's where it starts!
<f_> I can recognise the "name" of the ToC.
<f_> narmstrong: So...offset c000=
<f_> *?
<f_> < narmstrong> it should be loaded in ram at the same time as the bl2
<f_> Is BL1 supposed to do that?
<f_> I thought it only loaded BL2 if it found it.
<narmstrong> it should load the first 64k or something, so it should include the table
<narmstrong> then it should load the rest from the storage
<f_> Yeah it seems to include the table.
<f_> (if it loads the first 64K)
<f_> narmstrong: Hm. Same problem even with .offset=0x0000C000 and .length=0x00000080
<f_> Are those even the right values?
<f_> Where is fip_dev_handle defined. . .
<f_> Let's fire up Elixir.
JohnnyonFlame has joined #linux-amlogic
<f_> plat_gxbb_io_setup()!?
<f_> Ohh
<f_> I literally forgot to run that function!!
<f_> It must be ran in bl2_early_platform_setup2, but it isn't.
<f_> Let's see if it works now.
<f_> Well.
<f_> At the very least I don't get an assertion error :P
<f_> bam https://git.vitali64.duckdns.org/misc/trustedfirmware-a.git/commit/?h=wip/gxbb&id=82215ccd6721bd1e73cdb185ed739595b7016e4c :P
<f_> But it still doesn't seem to want to load anything.
<f_> I think that's because of the not-very-reliable-and-functional DDR init.
<f_> But I might be wrong.
f_ has quit [Quit: disconnecting ·_·]
gabes has quit [Quit: The Lounge - https://thelounge.chat]
gabes has joined #linux-amlogic
psydroid has joined #linux-amlogic
paddymahoney has joined #linux-amlogic
naoki has joined #linux-amlogic