f_ changed the topic of ##raspberrypi-internals to: The inner workings of the Raspberry Pi (Low level VPU/HW) -- for general queries please visit #raspberrypi -- open firmware: https://librerpi.github.io/ -- VC4 VPU Programmers Manual: https://github.com/hermanhermitage/videocoreiv/wiki -- chat logs: https://libera.irclog.whitequark.org/~h~raspberrypi-internals -- bridged to matrix and discord
jcea has quit [Ping timeout: 256 seconds]
finsternis has joined ##raspberrypi-internals
Stromeko has quit [Ping timeout: 268 seconds]
Stromeko has joined ##raspberrypi-internals
Bitweasil has quit [Quit: ZNC 1.8.2+deb2build5 - https://znc.in]
Bitweasil has joined ##raspberrypi-internals
bonda_000 has joined ##raspberrypi-internals
<bonda_000> alright I got some sleep
<bonda_000> let me get Ghidra again
bonda_000 has quit [Remote host closed the connection]
bonda_000 has joined ##raspberrypi-internals
bonda_000 has quit [Ping timeout: 245 seconds]
bonda_000 has joined ##raspberrypi-internals
<bonda_000> clever u here?
<clever> bonda_000: yep
<bonda_000> did your Ghidra build go smoothly?
<bonda_000> It won't let me compile the AARCH64 language
<bonda_000> > Task :AARCH64:sleighCompile FAILED
<bonda_000> FAILURE: Build failed with an exception.
<bonda_000> On this step it keeps failing
<clever> i havent gotten around to rebuilding ghidra in years
<bonda_000> some people say its running out of heap space
<bonda_000> or its the 32 bit Java being used
<bonda_000> > Process 'command '/usr/lib/jvm/java-17-openjdk-amd64/bin/java'' finished with non-zero exit value 137
<clever> i last built ghidra in may of 2020
<clever> look further up, you should see an error on why it failed
<bonda_000> its just that
<bonda_000> with gradle --scan to get full insights
<bonda_000> * Try:
<bonda_000> > Run with --stacktrace option to get the stack trace.
<bonda_000> > Run with --info or --debug option to get more log output.
<bonda_000> > Run with --scan to get full insights.
<bonda_000> I did --scan
<clever> can you pastebin the full output?
<clever> bonda_000: anything weird at the end of dmesg?
<bonda_000> [ 2345.947342] Out of memory: Killed process 3330 (java) total-vm:4879732kB, anon-rss:1410592kB, file-rss:0kB, shmem-rss:0kB, UID:1000 pgtables:3232kB oom_score_adj:200
<clever> bingo
<clever> you ran out of memory, and linux murdered java
<clever> Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)
<clever> this line of the error is the big hint
<bonda_000> so I can't build it here because its only 4 Gigs of RAM?
<clever> add more swap or close some unused programs, and try again
<bonda_000> that was the only thing running
<clever> then add more swap
<bonda_000> ok
<clever> swap files work good for temporarily swap
<clever> c2d ~ # fallocate foo.img --length 4g
<clever> c2d ~ # mkswap ./foo.img
<clever> c2d ~ # chmod 600 foo.img
<clever> fallocate lied to me, let me start over
<clever> c2d ~ # dd if=/dev/zero of=foo.img bs=1M count=1024
<clever> c2d ~ # chmod 600 foo.img
<clever> c2d ~ # mkswap ./foo.img
<clever> c2d ~ # swapon ./foo.img
<clever> bonda_000: this would add 1gb of swap, change the count to get more
<clever> how much you want, will depend on how much free disk space you currently have
<clever> when your done, you can just `swapoff foo.img` and `rm foo.img` to get the space back
<bonda_000> Linux is on 600GB partition
<bonda_000> plenty I think
<clever> id just make a 10gig swap then, you usually dont need more then that
<clever> count=10240 would be about 10gig
<bonda_000> 1024+0 records in
<bonda_000> 1024+0 records out
<bonda_000> 1073741824 bytes (1.1 GB, 1.0 GiB) copied, 4.6264 s, 232 MB/s
<clever> thats 1gig, not 10gig
<bonda_000> bimbom@max:~/Desktop/SWAP$ dd if=/dev/zero of=foo.img bs=1M count=1024
<clever> add a 0 to the count, look at my last message
<bonda_000> rm this foo.img?
<clever> doesnt matter
<bonda_000> I dont have mkswap and swapon
<clever> did you run it as root?
<bonda_000> bimbom@max:~/Desktop/SWAP$ sudo mkswap ./foo.img
<bonda_000> mkswap: ./foo.img: insecure file owner 1000, fix with: chown 0:0 ./foo.img
<bonda_000> Setting up swapspace version 1, size = 10 GiB (10737414144 bytes)
<clever> yep, do the chown it said to do
<bonda_000> bimbom@max:~/Desktop/SWAP$ sudo mkswap ./foo.img
<bonda_000> mkswap: unable to erase bootbits sectors
<clever> what does `free -m` report?
<bonda_000> bimbom@max:~/Desktop/SWAP$ free -m
<bonda_000> total used free shared buff/cache available
<bonda_000> Swap: 10239 0 10239
<bonda_000> Mem: 3783 2054 114 21 1914 1729
<bonda_000> although it did say
<bonda_000> the mkswap
<bonda_000> Setting up swapspace version 1, size = 10 GiB (10737414144 bytes)
<bonda_000> no label, UUID=f003b381-763c-4692-8795-2a82bd1db965
<clever> you shouldnt run mkswap while swapon has the file in use
<bonda_000> even though it complained about insecure file owner
<clever> run swapoff first
<bonda_000> so what chmod are we using
<bonda_000> chmod 600 or chmod 0:0
<clever> it said to run chown, so you need to do that
<bonda_000> already says I have 10GB swap
<bonda_000> sudo swapoff ./foo.ing
<bonda_000> sudo swapoff ./foo.img
<bonda_000> Setting up swapspace version 1, size = 10 GiB (10737414144 bytes)
<bonda_000> no label, UUID=f003b381-763c-4692-8795-2a82bd1db965
<bonda_000> bimbom@max:~/Desktop/SWAP$ free -m
<bonda_000> total used free shared buff/cache available
<bonda_000> Mem: 3783 2063 110 21 1910 1720
<bonda_000> Swap: 0 0 0
<bonda_000> now no swap
<clever> now you can fix the permissions on the file, and swapon again
<bonda_000> so
<bonda_000> sudo chmod 0:0 ./foo.img?
<clever> chown
<clever> the error said chown for a reason
<bonda_000> and then sudo chmod 600 ./foo.img
<clever> yep
<bonda_000> bimbom@max:~/Desktop/SWAP$ sudo mkswap ./foo.img
<bonda_000> mkswap: ./foo.img: warning: wiping old swap signature.
<bonda_000> Setting up swapspace version 1, size = 10 GiB (10737414144 bytes)
<bonda_000> no label, UUID=e4ade729-9136-49be-baf5-c64171383c16
<clever> you dont need to mkswap again
<clever> it was already made
<bonda_000> total used free shared buff/cache available
<bonda_000> Mem: 3783 2071 122 21 1889 1712
<bonda_000> Swap: 10239 0 10239
<clever> now you can try the build again
<bonda_000> hopefully it doesn't complain at me just pulling the vc4 folder from Windows version that I was using
<bonda_000> there was Ghidra/Processors/VC4 which I made and then there was another 'VideoCore' folder which I guess it made by itself, I had Eclipse with plugins hooked up to it
<bonda_000> I mean Ghidra/Processors/VC4 I dragged and dropped in there
<clever> gonna head upstairs for a bit
<bonda_000> ok
<bonda_000> huh I didn't even need to build anything everything from that Windows works on Linux
<bonda_000> just have to decompile it all over again
<clever> thats kinda the point of java
<bonda_000> I hope its not laggy
<bonda_000> idk its a bit laggy but its doing something atm
<bonda_000> I guess I need to build if I want to write my own tools for it
<bonda_000> i really wanna see what's in that Gp area
<bonda_000> of bootrom
<bonda_000> that it always refers to
<bonda_000> I think it points at 60008000 when it steps into bootcode
<clever> thats sram
<bonda_000> like a bunch of constants maybe
<clever> and something i forgot to explain, is the .bss and .data handling
<bonda_000> from .elf?
<clever> for things like the rom, and that run directly from flash, .data is a bit weird
<clever> there is a read-only copy of .data in the rom/flash
<clever> but you need to get it into ram somehow
<clever> if you search the rom for INI case sensitive, youll find a `INI\2` string at around 7220 into the binary
<clever> do you see that?
<bonda_000> the bootrom?
<clever> yes
<bonda_000> Im currently decompiling start_elf_unstripped
<bonda_000> I haven't got to bootrom yet
<bonda_000> literally just launched
<bonda_000> plus I haven't figured out how you feed it binaries without wrapping them into .elf
<bonda_000> I have an elf I tweaked still
<bonda_000> bootrom.elf
<clever> when you import the .bin file, you have to select vc4 and then hit advanced and set the base addr
<bonda_000> ok
<bonda_000> once its done with start_x_unstripped.elf I will do that
<bonda_000> by the way
<bonda_000> about generating that patterns directory
<bonda_000> how do you do that?
<clever> tools, function id
<bonda_000> is it somewhere by default? I see ARM has it and pretty much all of the default languages have the "Patterns" folder
<bonda_000> do I do that before I decompile or after?
<clever> ah, no idea what that is
<bonda_000> I guess after
<bonda_000> well it should collect and better recognize assembly patterns
<bonda_000> not sure what that does, it already does a great job
<clever> this is the INI\2 region i was refering to
<clever> first, you have an unsigned 32bit int, the destination addr
<clever> then you have a signed int (right click, convert, if its not showing negatives right)
<clever> a positive number like 50h (50 hex), means copy the next 0x50 bytes to the destination
<clever> its then followed by another destination, size, and 0x15a bytes
<clever> then 2 nulls (padding, i guess it wants 32bit alignment)
<clever> then a destination, and a NEGATIVE size of -36, this means to just zero out 36 bytes at the specified addr
<clever> the best way to handle this, is to generate more LOAD sections in the elf header
<clever> then ghidra will just do everything correctly
<bonda_000> elf header for the bootrom?
<clever> yep
<clever> https://i.imgur.com/nBsUI2z.png but i didnt have an elf, so i just manually went into the memory window, and filled in the right numbers, using the initialized thing, you can take a chunk of the original file
<clever> the bootcode.bin files use the same INI\2 scheme, so youll get more then 4 uses out of this tool
<clever> let me have a look at creating such a tool, ive been wanting one for a while...
<bonda_000> before RAM is on, the VPU executes the bootrom code from L2 cache and it starts at 60000000
<bonda_000> it then loads the bootcode.bin also into L2 cache and branches there with r24=60008000
<clever> the L2 cache is also not usable at reset
<clever> the rom has to turn the L2 cache on first
<clever> 60000000 is rom, and 60008000 is sram
<bonda_000> so 60000000 - 60010000 is a bootrom
<bonda_000> and you say its RAM
<clever> the rom sets up L2 cache-as-ram, loads bootcode.bin to 0x80000000, and then jumps so it
<bonda_000> 60000000 - 60010000 is ROM*
<clever> 60008000 is sram
<bonda_000> oh yeah you told me
<bonda_000> where it ends
<bonda_000> where all the zeros start
<clever> when bootcode.bin is passing control off to start.elf, it will copy a small chunk of assembly from L2 cache to sram(60008000)
<clever> and then bootcode.bin jumps back to the code in sram
<clever> and that code changes L2 config settings, and then jumps to start.elf
<clever> its not safe to be using the L2 when changing L2 settings
<bonda_000> so then rom is somewhere starting at 6000000 and how big is it?
<bonda_000> like last time you pointed me that zeros start somewhere around 60003700h or so but is that an indicator that its the end of physical ROM?
<bonda_000> maybe I'm mixing things up
<clever> the pi1 rom ends at 0x47d0
<clever> and then sram starts at 8000
f_ has joined ##raspberrypi-internals
<bonda_000> ok
<bonda_000> brb
f_ has quit [Remote host closed the connection]
f_ has joined ##raspberrypi-internals
<clever> you copied the link before the upload finished
<clever> try copying it again
<clever> that looks like a normal function, hit f to tag it as one
<bonda_000> at 6000b12e there is a string u"Broadcom"
<bonda_000> I'm referring to the BCM2837 document which says 40000000-80000000 alias '4' is L2 cache coherent(non-allocating) and it's split in four parts
<clever> the rom at 0x6000_0000 and the sram at 0x6000_8000 arent covered in the docs
<clever> and they shadow the normal 4 alias
<bonda_000> SDRAM beginning at 40000000 then some blue rectangle unnamed, then I/O periph which may be the ROM
<bonda_000> then a thin slice before 80000000 also unnamed
<clever> those thin slices used to be nothing
<clever> back when there was only 256mb of ram
<clever> then the ram kept growing, and growing
<bonda_000> so bootrom brings up the L2 cache and loads bootcode.bin in there correct?
<bonda_000> RAM is still disabled
<bonda_000> until bootcode.bin turns on RAM controller
<clever> yeah
<bonda_000> so then how in my dumpbootrom I read address 6000b12e and its a unicode string u"Broadcom" how did that get into L2 cache?
<bonda_000> if you are saying ROM ends at 60004700 and its way past that
<clever> my only guess, is that some bits of the address bus are ignored
<clever> so the data is just repeating at regular intervals
<clever> that b in the addr, is 1011 binary
<bonda_000> at 6000b874 string "bootcode.bin"
<clever> bootcode.bin loads to 0x8000_0000
<clever> if your seeing a 6, you set the base addr wrong
<clever> ah wait, you mean the bootcode.bin filename, appears in the rom
<bonda_000> it does kind of
<clever> thats within the INI\2 regions i just explained
<bonda_000> at 6000a074 also string "bootcode.bin"
<clever> it gets copied during bootup
<clever> re-read what i said about INI\2
<bonda_000> then its no worries
<bonda_000> so the first thing bootROM does is enable L2 cache that gives it 128KB of memory right?
<clever> the boot rom only uses that as a buffer, to hold the bootcode.bin
<clever> the bulk of its variables go into sram at 0x6000_8000
<bonda_000> is sram and sdram not the same thing?
<clever> completely different things
<clever> sram is just a set of flip-flops, that can maintain the stored bit with just power
<bonda_000> I mean is it not the same 1GB of transistor memory
<clever> dram is a capacitor that holds some charge for a short time, and needs active refreshing
<clever> the sram is within the cpu itself, and is very small
<clever> while the sdram is an external chip and up to 1gig in size
<bonda_000> okay so its also part of the VPU like ROM is
<clever> yeah
<bonda_000> would be nice to know ROM and SRAM addresses and exact sizes
<bonda_000> both of them make 60000000 - 60010000 or its arbitrary?
<clever> its whatever the broadcom engineers decided was enough
<clever> it may not fill the entire range
<clever> ive not poked around to find the exact end of each
<bonda_000> what I meant about r24 aka gp is that there is something there like a bunch of constants/configs that the later code keeps referring to
<clever> 2024-04-30 09:43:10 < clever> re-read what i said about INI\2
<clever> those constants get copied from rom to sram
<bonda_000> and by the end of bootrom/beginning of bootcode it points at 60008000 which I now know is SRAM built into VPU
<bonda_000> okay but we don't know yet what they are
<clever> if you read what i said, it will make more sense
<bonda_000> search for string 'INI'?
<clever> yes
<bonda_000> encoded strings or just strings?
<clever> just string, hit `s` in ghidra, and select string
<clever> compare it to the screenshot i sent
<bonda_000> and then put INI as hex
<clever> , and select string
<bonda_000> yeah it decompiled it into code
<clever> its not code, its a string
<clever> 2024-04-30 09:52:17 < clever> compare it to the screenshot i sent
<bonda_000> yeah 49 4e 49 ascii 'INI' I found it
<bonda_000> its a 60007220 surrounded by a lot of zeroes
<clever> yep, now select that and hit c to clear the type
<bonda_000> at*
<clever> then select the first I, and use t to change the type to char[4]
<clever> you want it to match what is in my screenshot
<bonda_000> can I? we yesterday figured we have different bootroms
<bonda_000> slightly
<clever> while following what i said
<clever> the INI\2 section always starts with a 4 byte string, a char[4]
<clever> it is then always followed by a unsigned and signed 32bit int
<clever> so start by setting those types
<bonda_000> okay
<bonda_000> so its a bunch of data after that
<clever> and what did i say the data was?
<bonda_000> an unsigned 32 bit int that is the Destination address
<bonda_000> but you also put 49 43 49 02 and that 02 is not an ascii character
<bonda_000> so how do you know is that string 49 43 49 'INI' or 49 43 49 02 'INI '
<clever> its just a magic number the code looks for
<clever> i tag it as a char[4] because the code expects all 4 bytes to match
<bonda_000> 49 4e 49 02 is the magic number
<clever> yeah
<bonda_000> ok gotcha
<bonda_000> yeah it all looks packed into uin32_t's
<clever> 00000000 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 |.ELF............|
<clever> same reason elf has a random 7f in the start
<clever> somebody flipped a coin and decided so
<clever> so that first int32 is the destination, and the 2nd int32 is the size
<clever> the next $size bytes, need to be copied to destination
<clever> you can either do that with a LOAD header in the elf, or by creating a new region in the memory window, and setting the initialize params right
<clever> after $size bytes (rounded up to a multiple of 4), you have another addr/size pair, repeat, until the addr is 0
<bonda_000> so db[80] is which part of this INI/2 protocol
<bonda_000> data bytes?
<clever> yeah
<clever> i just hit t, and then set the type to `byte[0x50]`
<bonda_000> yeah 50h is 80 decimal
<clever> and ghidra then turned it into 80 on me
<bonda_000> nice
<bonda_000> yeah then go all the strings
<bonda_000> "bootcode.bin" "bootsig.bin"
<bonda_000> repeated twice
<bonda_000> when I try to put these strings as an array of bytes it says "Data applied from 60007284 to 600073dd conflicts with existing defined data!"
<clever> ghidra auto-detected something in that range, and tagged it as something
<clever> youll have to scroll down, find that thing, and use c to clear it
<bonda_000> well there are strings "bootcode.bin" "bootsig.bin" "bootcode.bin" "bootsig.bin" then a bunch of data 79000000 54130060 etc
<clever> yeah, thats all data that will be copied elsewhere
<bonda_000> I think its warning that I'm gonna pack these strings into a byte array and asking if I want to do that
<clever> so you can just clear it, and hide it behind the array
<bonda_000> oh okay so its the format
<bonda_000> Dest_Address Length Bytes
<clever> yes
<bonda_000> so the program that runs in the ROM is going to look up this area at 60007220 for data and instructions where to write that data
<clever> yes
f_ has quit [Remote host closed the connection]
<bonda_000> brb I'm gonna cook food
<clever> and this will initialize a bunch of variables in 0x6000_8000
f_ has joined ##raspberrypi-internals
<bonda_000> hold on
<bonda_000> wasnt there supposed to be an XREF if the program that successfully decompiled acceses this data?
<bonda_000> or rather, wrote data to this location I'm still processing this
<clever> its a gp relative reference
<clever> the function at 0x6000_1472, is taking gp, and subtracting a huge number from it
<clever> then checking for the INI\2 magic
<clever> ghidra isnt aware of what gp is, so it cant make an XREF
<clever> bonda_000: and done!, this will parse the INI\2 and add more PT_LOAD entries to the elf
bonda_000 has quit [Remote host closed the connection]
bonda_000 has joined ##raspberrypi-internals
<bonda_000> but it should be aware of what value was put into gp
<clever> i have yet to figure out how to solve that
<bonda_000> when the processor starts up all registers are 0?
<clever> all registers have random values
<bonda_000> I guess there's no way of knowing this
<bonda_000> this link that you sent is get the INI data + elf wrapper?
<clever> yeah
<clever> it converts a .bin to .elf, and it also finds the INI\2 and adds extra PT_LOAD entries
<clever> run ./elf-tool -i foo.bin -o foo.elf, and then compare the `readelf -l` between mine and your own
<bonda_000> oh I put all the bytes manually and some extra section headers that dont seem to read well
<bonda_000> its not going to be same but I will give it a try
<clever> mine is still missing section headrs, and that upsets `objdump -d`
<clever> but ghidra doesnt seem to mind
<bonda_000> like run diff on them?
<clever> just look at the program headers on both, and see the difference yourself
<bonda_000> because you get more Program Table entries?
<clever> yeah
<clever> and those entires deal with the INI\2 for you
<bonda_000> found at 0x7420
<bonda_000> 0x60008000 80
<bonda_000> 0x60008074 346
<bonda_000> 0x60008050 -36
<bonda_000> 0x600081d0 -704
<clever> yep, thats just debug, what it found when scanning the INI\2
<clever> now look at the `readelf -l` on the output
<bonda_000> when I import it to Ghidra
<bonda_000> it says
<bonda_000> Additional information
<bonda_000> Failed to markup Elf header: Address Overflow in subtract: OTHER:00000000 - 0x1
<clever> it didnt do that for me, but maybe your .bin is too big
<bonda_000> Elf file type is EXEC (Executable file)
<bonda_000> Entry point 0x60000000
<bonda_000> Program Headers:
<bonda_000> There are 5 program headers, starting at offset 64
<clever> try cutting it down in size
<bonda_000> Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
<bonda_000> LOAD 0x001000 0x60000000 0x60000000 0x10429 0x10429 R E 0
<bonda_000> LOAD 0x00842c 0x60008000 0x60008000 0x00050 0x00050 0
<bonda_000> LOAD 0x008484 0x60008074 0x60008074 0x0015a 0x0015a 0
<bonda_000> LOAD 0x000000 0x60008050 0x60008050 0x00000 0x00024 0
<bonda_000> LOAD 0x000000 0x600081d0 0x600081d0 0x00000 0x002c0 0
<clever> yeah, your .bin was way too huge
<bonda_000> yours it doesnt decompile for me
<bonda_000> its 64K
<clever> the rom isnt that big
<clever> cut it down to size!
<bonda_000> so
<bonda_000> what was the command
<bonda_000> concat?
<clever> truncate, but make sure to have a backup forst
<clever> first*
<bonda_000> I think I'm putting elf header on an elf header
<bonda_000> hold on
<bonda_000> yeah its not bin its elf
<bonda_000> mistakenly named bootrom.bin
<clever> -rw-r--r-- 1 clever users 20K Oct 28 2020 /home/clever/apps/rpi/roms/rpi1-230aad04.bin
<clever> my bin file is onyl 20kb
<bonda_000> why it says DAT_segment_0__60000000 if thats the .text
<bonda_000> thats why foo.elf doesnt decompile
<clever> because i didnt assign any section headers
<bonda_000> code is marked as data
<clever> i'm still writing that bit of code
<clever> but it does decompile fine for me
<bonda_000> so what am I looking at
<clever> open the memory window
<bonda_000> I see you have the 60008000 section
<clever> you should see 5 sections
<bonda_000> I do have 5 sections
<clever> 2 of them are things that the INI\2 says to copy, and they are now at the correct addr
<clever> and 2 are things that INI\2 says to zero out
<clever> plus the rom itself
<bonda_000> is L1 cache enabled on startup?
<clever> nope
<clever> the rom is responsible for enabling it
<bonda_000> we can just search if there are any movs or lds to r24
<bonda_000> you gotta type it binary or hex thats a bummer
<clever> where?
<clever> screenshot?
<clever> why are you using edit bytes?
<bonda_000> thats the pencil button "Enter bytes manually"
<bonda_000> from hermanhermitage/videocoreiv/tinyasm
<bonda_000> ld%s{w} r%i{d}, 0x%0x{o}(r24) 1010 1000 ww0d dddd oooo oooo oooo oooo
<clever> but why are you trying to edit the code?
<bonda_000> its Instruction Search
<bonda_000> Instruction Pattern Search
<bonda_000> look behind
<clever> just use search->program text
<clever> but youll always find it setting gp within the first few opcodes of the entry-point
<bonda_000> yeah right away at 60000014 does mov gp, 0x60008000
<bonda_000> so then why is the rest of the code not acknowledging it knows whats in gp
<clever> because ghidra doesnt understand that
<clever> ghidra assumes that r0-r5 are arguments, and everything else is local to the function
<bonda_000> if (unaff_gp != 0xc08) {
<bonda_000> also whats unaff_gp stand for
<clever> un-affliated
<bonda_000> unaffected?
<clever> ghidra is complaining that something used gp, and gp was never set
<clever> so it has no clue what it is
<clever> ive already told you how to deal with that
<clever> 2024-04-28 11:44:20< clever> down in the data type manager, under your elf file, create a new struct, call it gp_area, and make the size at least 0x2000
<clever> 2024-04-28 11:44:24< clever> and hit save
<clever> 2024-04-28 11:44:42< clever> then select that `unaff_gp`, hit ctrl+l, and set it to `gp_area*`
<clever> 2024-04-28 11:45:20< clever> and then select the new variable, and use `l` to rename it to `gp`
<clever> 2024-04-28 11:45:26< clever> it will turn into things like `*(uint*)&gp->field_0x1234`
<bonda_000> yeah but it should be around the 60008000 it can't start at 60008000 because there is clearly subtraction
<clever> ignore the subtraction stuff
<clever> thats rarely done, and the struct hack wont handle it
<bonda_000> so starts at 60008000, 0x2000 bytes long, volatile
<bonda_000> not zero initialized
<bonda_000> won't let me do it says Block Address conflict [60008000, 60009fff
<bonda_000> ]
<clever> what are you trying to do?
<bonda_000> add memory block
<bonda_000> gp_area
<clever> you dont do that
<bonda_000> my bad
<bonda_000> I see now
<bonda_000> alignment 1 or 4?
<clever> when you follow the directions correctly, you should see things like this
<clever> alignment of 1
<bonda_000> piVar4 = (int *)&unaff_gp[-1].field_0x1224;
<bonda_000> looks okay just not sure what is with [-1]
<clever> thats a negative offset, so it doesnt work with the struct hack
<bonda_000> yeah right
<clever> youll need to decode that one manually
<bonda_000> so if it's subtracting from 60008000 then maybe that's the boundary between ROM and SRAM?
<clever> its subtracting enough that it indexes into the tail end of the rom
<bonda_000> if I were to write a program to add to lk
<bonda_000> do I write it like a normal linux device driver?
<clever> bonda_000: this is an example program i wrote years back
<clever> it just sleeps for 2 minutes (adjust as needed), and then reboots
<clever> you can just clear out the body of that function, and do whatever you want in there
<clever> this will run at the end of boot, in its own thread
<clever> and you have unrestricted access to MMIO, so you can just go right to poking ISP registers
<bonda_000> I probably need to understand better how that state machine works
<bonda_000> before I go do that
<clever> you can also use this to add custom commands into the command prompt
<clever> in this case, you can run `yuv_peek 1 2`, and the 1/2 will land in x/y on lines 87/88
<bonda_000> so you said lk yet misses support for loading binaries
<clever> correct
<bonda_000> what linux interface is reponsible for that?
<clever> binfmt
<bonda_000> and APP_START is like MODULE_INSTALL in Linux kind of?
<bonda_000> or
<bonda_000> MODULE_INIT
<clever> kinda
<clever> bonda_000: at the end of booting, this file will search the whole kernel for APP_START entries, and run the .init from each of them
<clever> and once thats done, it will run the .entry from each, in its own thread
<bonda_000> whats better lk or minix?
<clever> ive never used minix
<clever> so i cant compare them
<bonda_000> so what we have on lk-overlay is rather a remote shell over UART rather than linux shell
<bonda_000> because we issue commands remotely
<clever> yeah
<clever> bbl, lunch tme
angerisagift has quit [Ping timeout: 255 seconds]
angerisagift has joined ##raspberrypi-internals
angerisagift has quit [Ping timeout: 260 seconds]
bonda_000 has quit [Ping timeout: 256 seconds]
angerisagift has joined ##raspberrypi-internals
bonda_000 has joined ##raspberrypi-internals
<bonda_000> i'm back
KimK has quit [Quit: Leaving]
<bonda_000> do you have any idea why vc4 tools are prefixed vc4-elf?
<bonda_000> as in they create .elf files not binary executables?
<bonda_000> I'm trying to figure out how to compile vc4-toolchain with itself
<clever> bonda_000: the first problem youll run into, is that you need a kernel that supports loading binaries
<bonda_000> I'm thinking building Minix 3 for that
<bonda_000> has a light weight kernel and a shell
<clever> and does minux support the VPU?
<clever> minix*
<bonda_000> just need to write arch folders for the VC4
<bonda_000> the low-level stuff
<bonda_000> the high level stuff is neat and its drivers are user-side
<clever> and does minix work in a nommu setup?
<bonda_000> kernel driver is the clock one I think thats it
<bonda_000> no clue yet but it has fs
<bonda_000> here
<bonda_000> it has a book for it by Andrew Tanenbaum Operating Systems Minix book since I'm a noob in it and that's what they use in Universities to teach OS class these days
<bonda_000> so
<bonda_000> if its a GNU toolchain it should have everything needed right?
<clever> you would still need to implement a userland, library loading, context switching, irq handling
<bonda_000> it's all in there it just need a hardware layer
<clever> context switching is part of the hardware layer
<clever> as is irq handling
<bonda_000> yup
<bonda_000> I just want to check first if vc4-toolchain compiles with itself
<clever> that wont work until you have a libc for vc4 and your kernel
<clever> so you need to build your libc first
<bonda_000> hold on there are a lot of libs being built in the vc4-toolchain
<bonda_000> binutils/libvc4
<bonda_000> thats like assembly stuff there
<bonda_000> binutils/libiberty
<bonda_000> gcc-vc4/libcc1
<bonda_000> gcc-vc4/libcpp
<bonda_000> gcc-vc4/libobjc
<bonda_000> no libc that I see but cpp should be similar
<clever> libc isnt part of the vc4-toolchain
<clever> the libc needs to support the kernel you want to use
<bonda_000> and thats like memset
<clever> yeah
<bonda_000> how did they not put libc in here or it doesnt come with gcc?
<bonda_000> oh I see I need to interface libc with system calls in Minix
<bonda_000> oh thats everything that I use daily like printf and so on
<bonda_000> stdio.h, stdlib.h, to name the few
<bonda_000> do you wanna team up on that?
<bonda_000> I'm gonna use this as a reference on what function to build
dolphinana has joined ##raspberrypi-internals
f_ has quit [Ping timeout: 260 seconds]
<bonda_000> All the machine-dependent and operating system-dependent files in the library are in the subdirectory sysdeps under the top-level library source directory. This directory contains a hierarchy of subdirectories (see Layout of the sysdeps Directory Hierarchy).
<bonda_000> so pretty much all that's required is supplying these files for VC4
juri_ has joined ##raspberrypi-internals
bonda_000 has quit [Quit: Leaving]