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
vagrantc has joined #linux-amlogic
dlan has quit [Ping timeout: 252 seconds]
llu_ has quit [Ping timeout: 252 seconds]
llu has joined #linux-amlogic
dlan has joined #linux-amlogic
vagrantc has quit [Quit: leaving]
naoki has joined #linux-amlogic
hexdump0815 has quit [Ping timeout: 252 seconds]
hexdump0815 has joined #linux-amlogic
buzzmarshall has quit [Quit: Konversation terminated!]
chewitt has joined #linux-amlogic
naoki has quit [Quit: naoki]
jacobk has quit [Ping timeout: 260 seconds]
jacobk has joined #linux-amlogic
GNUtoo has quit [Ping timeout: 260 seconds]
GNUtoo has joined #linux-amlogic
chewitt has quit [Quit: Zzz..]
<f_> phh: yep, it was completely encrypted
<f_> I've been hard at work reversing and inspecting the bootROM for clues lately
<f_> There is a function "auth_image()" which takes care of running other functions that check the @AML header.
<f_> There is an fip_check() function, which is being ran, which checks if the header is valid. I concluded that function runs on decrypted data as it straight looks for e.g. the "@AML" magic.
<f_> In the end, this is what I found (simplified):
<f_> if (readl(0xc8100228) & 0x10000000) { decrypt(...) }
<f_> a dump of 0xc8100228 is printed over UART on bootup, it's that "FEAT:..." thing. And indeed, on the TV stick, it is not == 0.
chewitt has joined #linux-amlogic
<f_> Now. I can run unsigned code in Secure World thanks to amlogic-usbdl, so I could've just tried reading that BL2 and decrypting, all by running the bootROM's functions.. But TBH I'm a bit skeptical about running random functions I have not completely figured out.
<f_> anyway, tl;dr BL2 is encrypted with AES-256-CBC to no one's surprise, and also to no one's surprise the key and IV are stored in OTP memory
<f_> (there is a copy of the OTP memory also, stored at 0xd9013c00)
<f_> Btw while I was reversing the bootROM I also started writing some notes, could be useful for troubleshooting boot or something
chewitt has quit [Read error: Connection reset by peer]
chewitt has joined #linux-amlogic
<chewitt> f_ nice findings :)
<f_> chewitt: heh, I'm probably not the first one :p
<chewitt> no, but you're more likely to do something useful with them
<f_> ;)
<f_> and there we go, managed to dump acs
djrscally has joined #linux-amlogic
<f_> Once the BL2 image is decrypted things become easy :p
<f_> > .ddr_set_version = 2,
<f_> o.O
<f_> > NOTICE: BL3-1: Built : 17:28:39, Apr 1 2021 < happy april 1st all
<f_> 🤣
<f_> Now in my dump I see some stuff I've never seen before, @KEY?? @KMX?? second @AML before BL2??
<f_> still I call that progress :p
<f_> Oh also it looks like BL3* are encrypted too
<f_> and apparently not with the same kay
<f_> Will require more digging ^^
<f_> But at least I now have a decrypted BL2.. the rest I don't really care all that much about
<f_> (and when I say "BL3* are encrypted" I mean also the AMLC header is encrypted - not even gxlimg can recognise them)
zsoltiv_ has joined #linux-amlogic
<exkc> f_:
<exkc> what is AML_RES
<f_> "resources"?
<exkc> it is from rsv.img
<f_> where?
<exkc> rsv.img
<f_> Yes, where did you fetch it?
<exkc> newer 9 ota zip
<exkc> or older a9
<exkc> idk which a9
<exkc> i did that a while ago
<exkc> yeah it is lastest a9
<exkc> i sisnt change file name of the zip
<exkc> *didnt
<exkc> it is the latest one
chewitt has quit [Read error: Connection reset by peer]
chewitt has joined #linux-amlogic
ungeskriptet has quit [Remote host closed the connection]
ungeskriptet has joined #linux-amlogic
<f_> The blogpost says it affects S905D3[G], but it actually also affects most older 64-bit Amlogic SoCs, so GXBB, GXL, are affected and G12A/B and SM1 should also be affected (although I did not test). No idea about AXG though.
<f_> Well. S905D3 *is* SM1..
<f_> Maybe I should probably work on the DTS instead of trying to run funny stuff in secure world on a secureboot-enabled device
<f_> "dc:~$ cat /proc/cmdline" => "console=tty0 console=ttyAML0,115200n8 reboot_mode=cold_boot <...> androidboot.veritymode=enforcing androidboot.verifiedbootstate=green" :D
chewitt has quit [Quit: Zzz..]
GNUtoo has quit [Ping timeout: 252 seconds]
ldevulder has quit [Quit: Leaving]
GNUtoo has joined #linux-amlogic
<CyReVolt> <f_> "Daniel aka CyReVolt 🐢: gentle..." <- I think I'd seen it, yea. :)
<f_> CyReVolt: nice
<CyReVolt> I'm currently on other platforms again... SG200x (DRAM hates me...), BL808 (we have PSRAM up and working), and K230 (works well now :))
naoki has joined #linux-amlogic
<f_> CyReVolt: gotta boot them all
<CyReVolt> haha x)
<CyReVolt> btw I moved all my *_loader tools over to
<f_> Awesome
vagrantc has joined #linux-amlogic
<f_> CyReVolt: I know on GXL (and I think GXBB too) a copy of the OTP data is available at 0xd9013c00
<f_> I know it's the efuse because that's where the bootROM fetches stuff related to it and also where I found xiaomi's AES key x)
<f_> Some GPL sources also mention 0xd9013c00 as "efuse mirror" or something
<f_> CyReVolt: Actually, I think I remember seeing the exact same thing on the newer S905D2's bootROM. One second.
<f_> yep. It's 0xfffe7c00 on S905D2+
<f_> Though if I were you I wouldn't try writing to them
<f_> doing so is pretty risky Imo
<f_> CyReVolt: Finally, I remember seeing stuff related to efuses in the amlogic u-boot source code. Registers and such.
<f_> specifically in this repo https://github.com/libre-computer-project/libretech-amlogic-boot but there's no reason why it wouldn't be in the other amlogic-u-boot repos
<f_> But from what I saw the bootROM usually seems to work with that copy of the OTP instead of the OTP directly. But there might be places I overlooked in the bootROM.
<f_> (the one at 0xd9013c00 or 0xfffe7c00)
djrscally has quit [Ping timeout: 248 seconds]
naoki has quit [Quit: naoki]
naoki has joined #linux-amlogic