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 [Remote host closed the connection]
bonda_000 has joined ##raspberrypi-internals
<bonda_000> good morning
CompanionCube has quit [Quit: ZNC - http://znc.in]
CompanionCube has joined ##raspberrypi-internals
jn has joined ##raspberrypi-internals
jn has joined ##raspberrypi-internals
jn has quit [Changing host]
jn has quit [Ping timeout: 256 seconds]
jn_ has joined ##raspberrypi-internals
jn_ has quit [Changing host]
jn_ has joined ##raspberrypi-internals
jn has joined ##raspberrypi-internals
jn has quit [Changing host]
jn has joined ##raspberrypi-internals
jn_ has quit [Ping timeout: 255 seconds]
<bonda_000> so on Rhea
<bonda_000> where we pull our ISP register definitions from
<bonda_000> internal SRAM size is 0xC000
jn has quit [Ping timeout: 256 seconds]
jn_ has joined ##raspberrypi-internals
jn_ has quit [Changing host]
jn_ has joined ##raspberrypi-internals
<bonda_000> yo
<bonda_000> clever
<bonda_000> try this
<bonda_000> @clever
<bonda_000> becomes
bonda_000 has quit [Ping timeout: 268 seconds]
bonda_000 has joined ##raspberrypi-internals
<clever> bonda_000: oh, that could work...
<clever> bonda_000: kinda works, but you need to do that on every function
<clever> and it doesnt generate an XREF
<bonda_000> idk maybe you can ctrl+A the entire code section
<bonda_000> I've searched gp is only loaded once at the entry
<clever> yeah
<bonda_000> but yeah Minix idea I may think of it a bit more later when the camera thing is done
<bonda_000> I realized it can't Segfault without MMU/MPU so it's a very iffy OS that would be
<clever> it does have a MPU
<bonda_000> if a program can overwrite its own code section or other program's
<bonda_000> does it?
<clever> you can define a couple start/end ranges
<clever> and i think once you switch to user mode, those take effect
<clever> and stepping out of bounds will fault
<bonda_000> so then you always run your programs from the L1&L2 cached alias?
<clever> if the sandbox registers say so, yes
<clever> it can also keep one program from messing with the code of another
<bonda_000> oh then it's not that bad. I was thinking of using linked list of sorts of pages instead of a table that MMU provides
<bonda_000> like a linked list of big pages, linked list of medium pages, a linked list of small pages. If a program tries to use memory than it's current page I relocate it to a bigger page or merge but mergers seem to be a puzzle
<bonda_000> to use more memory*
<bonda_000> I tried in vc4 assembly. this is what happens when I allocate an array of 1 million ints
<bonda_000> it increments sp and there must be a way to catch if it goes past the data/memory line
<bonda_000> decrements*
<bonda_000> my bad let me add c source
<clever> that looks like its allocating on the stack
<clever> and its 4mb i think?
<clever> and you rarely have that much room in the stack, so thats a stack overflow
<bonda_000> try refresh the page again
<bonda_000> i added the c source and the disassembly is under it
<clever> yep, thats what i guessed the code was
<bonda_000> is that what MPU can also prevent from happening?
<clever> kinda
<clever> an MMU has the same problem
<clever> linux has a guard page at the end of the stack
<clever> and if you overflow the stack by a few bytes, the exception just automatically extends the stack
<clever> but if you overflow by 4mb, you can skip that guard page entirely, and land in some other memory your allowed to access
<clever> i forget the flag, but there is a thing in gcc that makes it read 1 byte out of every 4kb (page size), for that whole 4mb allocation
<clever> so it will hit the guard page on the way down
<bonda_000> wait isnt every program supposed to have its own stack rather than one big stack for all running programs?
<clever> correct
<clever> every thread has its own stack
f_ has joined ##raspberrypi-internals
<bonda_000> so the SANDBOX thing means we can have 7 protected regions?
<clever> i think its a whitelist, so 7 areas are allowed, and all others are blocked/protected
<bonda_000> so basically with 2 cores running I should use two of these
<bonda_000> in an OS.
<bonda_000> every time core switches tasks should update its whitelisted start and end addresses
<clever> yep
f_ has quit [Quit: To contact me, send a memo using MemoServ, PM f_[xmpp], or send an email. See https://vitali64.duckdns.org/.]
<bonda_000> any significance to r29 that you noticed?
<bonda_000> undefined4 _tx_event_flags_create(uint *param_1)
<bonda_000> has unaff_r29 this time
<bonda_000> and all the thread event functions refer to this unaff_r29
bonda_000 has quit [Ping timeout: 264 seconds]
bonda_000 has joined ##raspberrypi-internals
<clever> the compiler leaves that register alone, so the kernel is then free to store info about the current thread in there
<clever> so when a call comes in later, the kernel knows which thread is making the call
<bonda_000> I wonder if that's a struct somewhere
<bonda_000> I don't think I've seen a single struct so far
<clever> bonda_000: ghidra doesnt understand the debug info for structs, so you need to make every struct by hand
bonda_000 has quit [Ping timeout: 268 seconds]
bonda_000 has joined ##raspberrypi-internals
dolphinana has joined ##raspberrypi-internals
f_ has joined ##raspberrypi-internals
jn_ has quit [Ping timeout: 245 seconds]
jn has joined ##raspberrypi-internals
jn has joined ##raspberrypi-internals
jn has quit [Changing host]
<dolphinana> hi clever! o/
<dolphinana> I'd like to boot Linux kernel on my RPi 2 with lk-overlay
<clever> dolphinana: start with `make PROJECT=vc4-stage1`, rename lk.bin to bootcode.bin and drop it on a fat partition
jcea has joined ##raspberrypi-internals
<clever> dolphinana: then `make PROJECT=vc4-stage2`, take the lk.elf, and put it in /boot of an ext4 partition, it must be the 2nd partition on the card
jn has quit [Ping timeout: 240 seconds]
jn has joined ##raspberrypi-internals
jn has quit [Changing host]
jn has joined ##raspberrypi-internals
<clever> oh, and you may need to make some of the rpi-test projects, the errors will point them out
<clever> that will then try to load rpi2.dtb, zImage-v7, cmdline.txt, and initrd, all from /boot on the ext4 volume
<clever> and from there, its just normal linux stuff
<bonda_000> you can read some logs I saved
<bonda_000> we went through the process
<dolphinana> thanks clever, I'll try this...
<dolphinana> bonda_000, I'm sure I can read the archived logs
<clever> dolphinana: i can help if you get stuck somewhere along that process
<dolphinana> yeah ^^
<clever> dolphinana: the bootcode.bin part must be on sd for a pi2, but the lk.elf and /boot could be on usb if you want
Miyu has joined ##raspberrypi-internals
<bonda_000> be back soon
hackkitten has quit [Ping timeout: 268 seconds]
Miyu is now known as hackkitten
bonda_000 has quit [Ping timeout: 245 seconds]
jn has quit [Ping timeout: 246 seconds]
jn has joined ##raspberrypi-internals
jn has joined ##raspberrypi-internals
jn has quit [Changing host]
jn has quit [Ping timeout: 256 seconds]
jn has joined ##raspberrypi-internals
jn has joined ##raspberrypi-internals
jn has quit [Changing host]
jn has quit [Ping timeout: 256 seconds]
jn has joined ##raspberrypi-internals
jn has quit [Changing host]
jn has joined ##raspberrypi-internals
<dolphinana> clever, how do I deal with rpi-test projects?
<clever> dolphinana: `make PROJECT=rpi2-test` for example
<clever> the name will be in the error msg
<dolphinana> I did that
<clever> and then try vc4-stage2 again
<dolphinana> hmm... it seems like I have commented out that MODULES += platform/bcm28xx/arm in vc4-stage2.mk
<clever> *looks*
<clever> youll want to uncomment that
<dolphinana> yeah, exactly what I was thinking...
<dolphinana> okay, now I'm getting errors about rpi1-test not being found
<clever> yep, `make PROJECT=rpi1-test` as well
<dolphinana> rpi1-test compiled successfully
<dolphinana> now it wants rpi3-test
<clever> yep, just make that one as well
<dolphinana> aaand I don't have aarch64-elf-gcc...
<dolphinana> leme see if I can install it...
<clever> you can use mkdir and touch to create a 0 byte .bin file at the right path
<clever> that will fool things into going forward, it just wont work on a pi3
<clever> the 3 rpi-test builds, are each tailored to a different pi model
<clever> and at runtime, it will check which one you have, and copy the right one to the reset vector
<dolphinana> I don't have RPi 3 anyway so rpi3-test doesn't matter to me...
<clever> [nix-shell:~/apps/rpi/lk-overlay]$ touch build-rpi3-test/lk.bin
<clever> that should do the job then
<dolphinana> I did that...
<dolphinana> and then trying to compile vc4-stage2 again yields another error
<dolphinana> latform/bcm28xx/arm/payload.S: Assembler messages:
<dolphinana> platform/bcm28xx/arm/payload.S:5: Error: file not found: ../../../build-rpi1-test/lk.bin
<dolphinana> platform/bcm28xx/arm/payload.S:9: Error: file not found: ../../../build-rpi2-test/lk.bin
<dolphinana> make[1]: *** [make/compile.mk:76: build-vc4-stage2/platform/bcm28xx/arm/payload.S.o] Error 1
<dolphinana> platform/bcm28xx/arm/payload.S:13: Error: file not found: ../../../build-rpi3-test/lk.bin
<dolphinana> make[1]: Leaving directory '/home/johannes/code/lk-overlay'
<dolphinana> make: *** [makefile:34: _top] Error 2
<dolphinana> clever
<clever> what does `ls` return?
<dolphinana> johannes@e6430:~/code/lk-overlay$ ls
<dolphinana> COPYING arch build-rpi3-test default.nix external librerpi-with-text.png lk.nix 'opcode speeds' release.nix
<dolphinana> app build-rpi2-test build-vc4-stage2 docs lib lk makefile project target
<dolphinana> README.md build-rpi1-test build-vc4-stage1 dev flake.nix librerpi-without-text.png lk_inc.mk platform shell.nix
<clever> that should have worked...
<clever> try going into payload.S, and remove the ../../../ from one, and see if that changes anything?
<dolphinana> I did that and now I can compile vc4-stage2 with arm module successfully!
<clever> sounds like your .incbin search path is just being weird, its behaving differently from mine
<clever> now you can copy that stage2 lk.elf to an ext4 partition on an SD card, it should be in /boot/lk.elf
<clever> and the ext4 should be p2
<dolphinana> where's the .incbin ?
<clever> in payload.S, the lines you edited
<dolphinana> ah, I see
<dolphinana> okay...
<dolphinana> I got librerpi with arm init running... and....
<dolphinana> SP: 0x800420a0
<dolphinana> 6.313775 [LOADER:try_to_boot:149]: trying to boot from sdhostp1
<dolphinana> 6.307089 [LOADER:add_boot_target:82]: considering sdhostp1 as boot target
<dolphinana> s_log_groups_per_flex: 4
<dolphinana> group descriptors: 0x80042118
<dolphinana> starting app shell
<dolphinana> entering main console loop
<dolphinana> ] SP: 0x80042048
<dolphinana> dtb: rpi2.dtb, kernel: zImage-v7
<dolphinana> 6.687083 [LOADER:map_physical:236]: map_physical(0x1000000, 0x8002c40c, 33554432, zImage)
<dolphinana> 6.695165 [LOADER:map_physical:238]: done
<dolphinana> failed to open /root/boot/zImage-v7: -1
<dolphinana> failed to read kernel file
<dolphinana> I guess I'll have to do some file management..
<clever> yep, stage1, stage2, and rpi2-test all worked fully
<clever> now you just need a zImage-v7 in the /boot
<dolphinana> hmm... I found vmlinux* files in the /boot directory...
<dolphinana> can I simply rename it to "zImage-v7"?
<clever> if it was build for the pi2, sure
<dolphinana> (well, i'd actually copy it)
<dolphinana> hmm...
<dolphinana> where do I need the dtb file?
<dolphinana> does it also need to be in the /boot in ext partition?
<clever> yep
<dolphinana> ah, I see..
<dolphinana> okay, now I'll need initrd
bonda_000 has joined ##raspberrypi-internals
<bonda_000> Yo I'm back
<dolphinana> welcome back bonda_000 ^^
<dolphinana> hmm... still unable to get Linux booting...
<dolphinana> clever: I get the following error:
<dolphinana> ERROR: fdt_open_into() == -3
<bonda_000> is your host machine Linux?
<bonda_000> you can boot from Ethernet cable if you have a spare one at home
<dolphinana> bonda_000, yes, I'm running GNU/Linux
<bonda_000> which one exactly
<bonda_000> What kind
<dolphinana> bonda_000, booting from ethernet cable would be great, I'm thinking about doing it one day...
<bonda_000> it's easier you just need to set up two config files and not strain your sd card slot
<bonda_000> Starting TFTP / DHCP for bootcode.bin
<bonda_000> `nmtui` Activate a connection enp2s0
<bonda_000> `sudo journalctl -f` to see what's going on
<bonda_000> `/etc/init.d/xinetd start`
<bonda_000> `sudo service isr-dhcp-server start`
<dolphinana> bonda_000, I'm running PureOS, which is free from proprietary software.
<dolphinana> bonda_000, what are you running on your host machine?
<bonda_000> Debian
<dolphinana> ah, I see
<bonda_000> so
<dolphinana> I've used Debian at some point (plus PureOS is based on Debian so I'm technically using Debian :P)
<clever> dolphinana: you also need rpi2.dtb
<dolphinana> I have rpi2.dtb in the /boot directory of the ext4 partition
<dolphinana> clever, oooh, I need this particular one?
<clever> yeah, the official dtb wont work
<bonda_000> nmtui (Network manager) dhcp and xinetd may have different name for you but same usage
<clever> the official one tells linux to talk to the firmware over things i dont implement
<clever> and enables hw i dont support
<dolphinana> but clever, that file is called rpi2.dts not rpi2.dtb?
<clever> dolphinana: the dts has to be compiled, using the dtc command
<clever> i linked to the shell code i use for that
<dolphinana> ah, I see...
<bonda_000> <clever> you can also use the nix package manager to automate building everything
<bonda_000> <clever> if your on linux, it should be as simple as these 2 commands:
<bonda_000> <clever> [clever@amd-nixos:~/apps/rpi/lk-overlay]$ nix-shell
<bonda_000> <clever> [nix-shell:~/apps/rpi/lk-overlay]$ make PROJECT=rpi3-bootcode
<bonda_000> <clever> $ sh <(curl -L https://nixos.org/nix/install) --daemon
<bonda_000> <clever> [nix-shell:~/apps/rpi/lk-overlay]$ ls -lhs build-rpi3-bootcode/lk.bin
<bonda_000> lk.bin is the bootcode.bin to run
<clever> yeah
<bonda_000> I didn't need any dtb/dts in fact over Ethernet it only eats this one file
<clever> bonda_000: the dtb file is only needed when starting linux
<bonda_000> yeah for Raspbian
<dolphinana> bonda_000, I personally prefer just doing things manually
<dolphinana> but thanks for advice
<bonda_000> brb
f_ has quit [Ping timeout: 260 seconds]
<dolphinana> hmm...
<dolphinana> I got quite close now... but...
<dolphinana> nothing happened after the following line:
<dolphinana> > core 0 passing control off to linux!!!
<dolphinana> also this: kernel cmdline is: console=serial0,115200 console=tty1 root=PARTUUID=a59b06ee-02 rootfstype=ext4 fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles
<clever> dolphinana: can help debug that more when i'm not distracted, will be about 20mins
<dolphinana> hmm... okay
<dolphinana> clever, good luck with whatever you're doing ^^
<clever> my old notes on debugging all of that
<dolphinana> thanks clever
<clever> arch/arm/Kconfig.debug: config DEBUG_BCM2836
<clever> dolphinana: to start with, try building linux with that flag enabled
<clever> dolphinana: ah found it, this is the last .config i had, that was known good
<bonda_000> BACK
<bonda_000> back*
<bonda_000> any ideas why this happens? I'm trying to see my bootenv via hermanhermitage/dumpbootenv
<clever> bonda_000: what baud rate are you set to?
<bonda_000> same as for lk
<bonda_000> huh maybe it's different config there let me check
<clever> your better off just modifying LK to save that data for you
<bonda_000> what do you use? 115200 baud no parity 1 stop bit?
<clever> yes
<clever> bonda_000: this is the entry-point, you just to allocate some memory from C, and then write to it from here
<bonda_000> lk prints normally still
<bonda_000> might do that then
<bonda_000> it's the start bit I think
<clever> bonda_000: do you have access to a scope or logic analyzer?
<bonda_000> yeah
<clever> try measuring the tx pin and see what it looks like
<bonda_000> well lk still works so
<bonda_000> its that miniuart not configured like yours
<clever> it might be some issues with the baud rate settings
<bonda_000> yeah although through putty it worked fine
<bonda_000> might be minicom and however COM driver here works
<bonda_000> try one more time and do it through the lk
<bonda_000> how do I put in a text file?
<bonda_000> whatever comes in a minicom
<clever> [root@amd-nixos:~]# minicom -D /dev/ttyACM0 -b 115200 -o -C uart.log
<bonda_000> maybe it's the -b
<bonda_000> that I forgot
<clever> that would do it
<clever> it does show the baud rate at the bottom of the window
<bonda_000> CTRL-A Z for help | 115200 8N1 | NOR | Minicom 2.8 | VT102 | Offline | ttyUSB0
<clever> yep, that says 115200
<bonda_000> flow control didn't help either
<clever> gotta run for a bit, may not be back until tomorrow
<bonda_000> ok
<bonda_000> I see a lot of 9's
<bonda_000> in the %!xxd
<bonda_000> I guess that may be the program_usb_boot_mode messed up the clock
<bonda_000> yeah not the perfect result but at least readable now. I guess the system clock has changed with the USB/Ethernet boot option
<bonda_000> HA DUDE
<bonda_000> I had two minicoms open it totally ripped apart the outputs
<dolphinana> bonda_000, heh, how silly x3
<dolphinana> compiling the kernel...
<bonda_000> good night
bonda_000 has quit [Remote host closed the connection]
<dolphinana> goodnight bonda ^^
<clever> dolphinana: any progress building linux?
<dolphinana> clever, yeah... it seems like I built vmlinuz, which is probably not something I want...?
<dolphinana> I'm quite inexperienced with building Linux...
<clever> dolphinana: look in arch/arm/boot
<clever> [clever@amd-nixos:~/apps/linux]$ ls -ltrh rv32/arch/riscv/boot/
<clever> total 3.5M
<clever> -rwxr-xr-x 1 clever users 6.5M May 2 11:58 Image
<dolphinana> oooh...
<clever> thats where linux dumps the final binary
<dolphinana> I found Image and zImage
<clever> yep
<clever> you want the zImage, add a -v7 on the end, and toss it onto the SD
<clever> the vmlinux is an elf file, mainly for debug stuff
<dolphinana> mhm...
<dolphinana> I'll try it now before I go sleep...
<dolphinana> hmmm...
<dolphinana> clever, nothing happens after "core 0 passing control off to linux!!!"
<dolphinana> at least I don't see anything happening...
<dolphinana> does the kernel cmdline look correct?
<dolphinana> "kernel cmdline is: console=serial0,115200 console=tty1 root=PARTUUID=a59b06ee-02 rootfstype=ext4 fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles"
<clever> dolphinana: try with console=ttyAMA0,115200
<dolphinana> should I modify the cmdline.txt in /boot at ext4 partition?
<dolphinana> okay, I just did that...
<dolphinana> still nothing happening
<clever> probably needs some more earlycon, one minute
<dolphinana> (btw, I made my own kernel build config, with CONFIG_DEBUG_BCM2736=y)
<dolphinana> clever, sure
<clever> try something like this? earlycon=pl011,0xf0201000 or earlycon=pl011,0x3f201000
<clever> not sure which one is right, only try one at a time
<dolphinana> sure
<dolphinana> seems like earlycon=pl011,0xf0201000 didn't do anything...
<dolphinana> let me try the latter one
<dolphinana> OH MY GOSH
<clever> dolphinana: got a pastebin of it all?
<dolphinana> I'm really excited, seeing some text output from linux from librerpi!
<dolphinana> Even if it fails to boot.
<dolphinana> wait a min, I'll provide a pastebin...