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: 268 seconds]
Lightsword has quit [Quit: ZNC]
Lightsword has joined ##raspberrypi-internals
Stromeko has quit [Quit: Going… gone.]
Stromeko has joined ##raspberrypi-internals
jcea has joined ##raspberrypi-internals
jcea1 has joined ##raspberrypi-internals
jcea has quit [Read error: Connection reset by peer]
jcea1 is now known as jcea
ungeskriptet1 has joined ##raspberrypi-internals
ungeskriptet has quit [Ping timeout: 264 seconds]
ungeskriptet1 is now known as ungeskriptet
ungeskriptet0 has joined ##raspberrypi-internals
bonda_000 has joined ##raspberrypi-internals
ungeskriptet has quit [Ping timeout: 256 seconds]
ungeskriptet0 is now known as ungeskriptet
bonda_000 has quit [Quit: Leaving]
jcea has quit [Ping timeout: 268 seconds]
jcea has joined ##raspberrypi-internals
jcea has quit [Ping timeout: 268 seconds]
<f_ridge> <x​2x6_/D> Hi, Clever, I went back to the message history to find where you looked up debug information in linux kernel. Can you tell me if this is output is from raspberrypi ?
<f_ridge> <x​2x6_/D> Because as far as I understand raspberry can not support 1.8 voltage.
<f_ridge> <x​2x6_/D> Also I am not sure i understand I see two mmc devices in my own output in linux - mmc0, mmc1, and they are different. mmc1 is in high-speed mode.
<f_ridge> <x​2x6_/D> There is only 1 sd card on the system, I could imagine mmc0, mmc1 are partitions but this is not the case,
<f_ridge> <c​lever___/D> `system76` is an x86 laptop i have
<f_ridge> <c​lever___/D> its got a native mmc interface, so i can get the same debug as an rpi
<f_ridge> <x​2x6_/D> ok
<f_ridge> <x​2x6_/D> But now I installed raspbian on my rpi3 and observe 2 mmcs.
<f_ridge> <c​lever___/D> wifi is sdio
<f_ridge> <x​2x6_/D> pi@pi:~ $ dmesg | grep mmc
<f_ridge> <x​2x6_/D> [ 2.792649] mmc-bcm2835 3f300000.mmcnr: mmc_debug:0 mmc_debug2:0
<f_ridge> <x​2x6_/D> [ 2.792669] mmc-bcm2835 3f300000.mmcnr: DMA channel allocated
<f_ridge> <x​2x6_/D> [ 2.868861] mmc0: sdhost-bcm2835 loaded - DMA enabled (>1)
<f_ridge> <x​2x6_/D> [ 2.903502] mmc0: host does not support reading read-only switch, assuming write-enable
<f_ridge> <x​2x6_/D> [ 2.905431] mmc0: Problem switching card into high-speed mode!
<f_ridge> <x​2x6_/D> [ 2.907211] mmc0: Host Software Queue enabled
<f_ridge> <x​2x6_/D> [ 2.907250] mmc0: new SDXC card at address 0001
<f_ridge> <x​2x6_/D> [ 2.908742] mmcblk0: mmc0:0001 SD64G 58.2 GiB
<f_ridge> <x​2x6_/D> [ 2.912997] mmc1: new high speed SDIO card at address 0001
<f_ridge> <x​2x6_/D> [ 2.915967] mmcblk0: p1 p2
<f_ridge> <x​2x6_/D> [ 2.916917] mmcblk0: mmc0:0001 SD64G 58.2 GiB
<f_ridge> <x​2x6_/D> So mmc1 is wifi?
<f_ridge> <c​lever___/D> yep
<f_ridge> <x​2x6_/D> pi@pi:~ $ sudo cat /sys/kernel/debug/mmc0/ios
<f_ridge> <x​2x6_/D> clock: 25000000 Hz
<f_ridge> <x​2x6_/D> actual clock: 25000000 Hz
<f_ridge> <x​2x6_/D> vdd: 21 (3.3 ~ 3.4 V)
<f_ridge> <x​2x6_/D> bus mode: 2 (push-pull)
<f_ridge> <x​2x6_/D> chip select: 0 (don't care)
<f_ridge> <x​2x6_/D> power mode: 2 (on)
<f_ridge> <x​2x6_/D> bus width: 2 (4 bits)
<f_ridge> <x​2x6_/D> timing spec: 0 (legacy)
<f_ridge> <x​2x6_/D> signal voltage: 0 (3.30 V)
<f_ridge> <x​2x6_/D> driver type: 0 (driver type B)
<f_ridge> <x​2x6_/D> pi@pi:~ $ sudo cat /sys/kernel/debug/mmc1/ios
<f_ridge> <x​2x6_/D> clock: 50000000 Hz
<f_ridge> <x​2x6_/D> actual clock: 50000000 Hz
<f_ridge> <x​2x6_/D> vdd: 21 (3.3 ~ 3.4 V)
<f_ridge> <x​2x6_/D> bus mode: 2 (push-pull)
<f_ridge> <x​2x6_/D> chip select: 0 (don't care)
<f_ridge> <x​2x6_/D> power mode: 2 (on)
<f_ridge> <x​2x6_/D> bus width: 2 (4 bits)
<f_ridge> <x​2x6_/D> timing spec: 2 (sd high-speed)
<f_ridge> <x​2x6_/D> signal voltage: 0 (3.30 V)
<f_ridge> <x​2x6_/D> driver type: 0 (driver type B)
<f_ridge> <x​2x6_/D> So even the linux kernel failed to run high-speed on my crappy sdcard, I'll check the other one, If it has same result perhaps this will be solved by shopping
<f_ridge> <c​lever___/D> i think the CSD register also gives you the max clock rate
<f_ridge> <x​2x6_/D> Where can I see it in linux
<f_ridge> <c​lever___/D> `find /sys -name csd` i believe
<f_ridge> <x​2x6_/D> Do you know from where kernel sources are taken to compile for bookworm?
<f_ridge> <c​lever___/D> <https://github.com/raspberrypi/linux> probably
Ad0 has quit [Ping timeout: 252 seconds]
Ad0 has joined ##raspberrypi-internals
Stromeko has quit [Quit: Going… gone.]
Stromeko has joined ##raspberrypi-internals
bonda_000 has joined ##raspberrypi-internals
<bonda_000> clever: took some rest. decided to ditch the videocore. gonna do it from scratch on FPGA
<clever> bonda_000: what was your project again?
<bonda_000> it is too big and unknown for right now to poke at it and hope for an instant hit
<bonda_000> videocamera for starters. I was hoping to make a night vision goggles
<clever> ah
<bonda_000> but I read that CCD sensor itself can see in near-IR spectrum
<bonda_000> so maybe it won't even need a special lens and would be able to see something by itself
<clever> a lot of cameras can see near-ir, and that often messes up the color of things
<clever> my toaster oven is purple
<clever> so they tend to have an IR filter to block the IR
<clever> the noir camera lacks that filter
<bonda_000> camera yes. the raw sensor only has a bayer mosaic on it
<bonda_000> I did take apart a webcam and seen the filter
<f_ridge> <x​2x6_/D> Haha)
<bonda_000> the good thing I realized. FPGA will let me do multiple-port memory
<bonda_000> so I won't have multiple parts of the logic competing for the bus
<bonda_000> at least it's what it sounds like
<clever> multi-port memory can get costly i hear
<bonda_000> yeah
<bonda_000> it is on the FPGA chip
<f_ridge> <x​2x6_/D> Can you share more details on the FPGA part?
<f_ridge> <x​2x6_/D> Do you have some architecture on mind?
<bonda_000> this says with XC7A200T I can have 13Mib of dual-port block ram
<f_ridge> <x​2x6_/D> ))) чип дип)
<bonda_000> so my sensor is 0.4 mp
<bonda_000> 460K pixels
<f_ridge> <x​2x6_/D> лол
<f_ridge> <x​2x6_/D> So you tried some custom sensor that you tried to connect to raspberry over CSI?
<bonda_000> sensor also from Chip Dip
<bonda_000> sony icx415aq
<bonda_000> it is raw sensor there is no CSI nowhere near
<f_ridge> <x​2x6_/D> How did you connect it to raspberry?
<bonda_000> we tried hacking into Raspberry but that was frustrating
<bonda_000> I didn't that's why I said I'm doing it on FPGA)
<clever> bonda_000: what interface does the sensor have?
<f_ridge> <x​2x6_/D> But you did a lot of research? I saw on forum
<f_ridge> <x​2x6_/D> I thought you already passed the part where you soldered it over some interface to pi
<bonda_000> ccd has a horizontal and vertical clock that gonna push out 0-1V values to the ADC
<bonda_000> f_ridge: me and clever dug into videocore firmware and how the camera module operates
<bonda_000> f_ridge: we lost track at cdi struct and some values that were written into it that were later used to initialize UNICAM block
<bonda_000> because there was a potential that there was a "CPI" camera parallel interface
<bonda_000> that even has one mention throughout the code
<bonda_000> reset_cpi I think the function was called
<bonda_000> that's always called when unicam_rx_start() function is called when a certain flag is set within the cdi control struct
<bonda_000> so UNICAM talks directly to the peripheral and its control values are within the cdi struct
<f_ridge> <x​2x6_/D> so how many hours do you think you've ruined on raspberry pi before taking decision to go with FPGA?)
<f_ridge> <x​2x6_/D> I just think now about my project and and try to understand is it too late for me to start over on some open-source hardware
<clever> i thats part of why RPF is moving towards things like DRM and v4l, your code is portable between different linux SBC's
<clever> but baremetal breaks all of that
<bonda_000> it's not Linux or ARM code, it is the VC4 firmware
<bonda_000> VC4 assembly that we decompile with ghidra to get C pseudocode
<f_ridge> <x​2x6_/D> What exactly is the purpose of your project? Night vision?
<f_ridge> <x​2x6_/D> What exactly is the purpose of your project? Some night vision camera?(edited)
<bonda_000> I want to see if I can make a head-mounted display aka VR goggles whether with night vision option or not
<bonda_000> good enough and fast enough with spectroscopic view that hopefully doesn't give user a motion sickness
<bonda_000> or too much eye strain
<bonda_000> because it's not a lens, you are staring at a display
<bonda_000> essentially you present a slightly shifted picture separately to each eye
<bonda_000> you unfocus your vision and they combine, giving an illusion of depth
<bonda_000> so the feed from the camera goes to two displays
<bonda_000> or one display split in two, one for each eye
<bonda_000> but that's close to user's face so it has to be some good lcd display with high pixel density so that they don't notice individual pixels
<bonda_000> you need the spectroscopic view because if you just stare at a display that puts strain on your eyes and has no depth
<bonda_000> i made spectroscopic binocular with two rolls of toilet paper
<bonda_000> it is a fun thing, that was an entertainment in middle ages
<f_ridge> <x​2x6_/D> Wow, sound very cool and ambitious, neets cross domain skills
<f_ridge> <x​2x6_/D> tonns of time.
<f_ridge> <x​2x6_/D> tonns of time. (probably)(edited)
<f_ridge> <x​2x6_/D> How do you want to feed rays to the sensor? There should be some lens solution
<bonda_000> yes. both optical and electrical device
<bonda_000> not sure, I am new to this. I guess it does need some lens to concentrate the rays on the ccd array
<f_ridge> <x​2x6_/D> )
<f_ridge> <x​2x6_/D> I am pretty sure that this is even gives some amazing optical result , like real presence in forest?
<bonda_000> yeah once you get it right its funny to see how they merge into one sort of 3D picture
<bonda_000> you have to un-focus both eyes
<bonda_000> and move left and right pictures until the overall view sharpens
<bonda_000> since, you know, nobody really knows science behind this
<bonda_000> its perception-based
<f_ridge> <x​2x6_/D> )
<f_ridge> <x​2x6_/D> so you will do this until you have an optics expert help you make it further?
<bonda_000> I'm doing it all by myself right now
<bonda_000> my IRL friend coined the idea but he is more of an artist than an engineer so I picked it up
<bonda_000> plus, some videogame influence
<bonda_000> what are you working on?
<bonda_000> clever: I haven't realized that was two people replying simultaneously
<clever> bonda_000: f_ridge is a bridge bot, connecting discord, matrix, and irc together, youve been talking to x^2^x6^
<clever> but the ^'s break the bot and it turns into x2x6_
<bonda_000> so some sort of math equation? :)
<f_ridge> <x​2x6_/D> )
<f_ridge> <x​2x6_/D> Haven't came up with anything smarter than a bunch of symbols when had to create a nickname
<f_ridge> <x​2x6_/D> Sorry, yes, that's me the thrid person. I though its obvious
<f_ridge> <x​2x6_/D> I am from discord, because I don't have anough brain power now to memorize or automate IRC.
<f_ridge> <x​2x6_/D> all gone into new job and current raspberry project with camera on baremetal)
<bonda_000> oh cool
<bonda_000> like one of the stock cameras they provide or a raw sensor like I'm trying to do?
<f_ridge> <x​2x6_/D> I am doing a camera application on baremetal from the stock camera (imx219 or anything you can buy)
<bonda_000> I see
<bonda_000> so do you have one already?
<bonda_000> that's what we actually needed earlier to see what log messages the VC4 produces as it runs through the camera code
<bonda_000> because I don't have access nor clever has one of the Pi cameras
<clever> i have one of the old rpi cameras
<clever> i forget which one
<bonda_000> huh, openocd. that had a bug in the source code I had to fix manually
<bonda_000> the core frequency is hard coded and is not for Pi 3B
<bonda_000> I wasn't able to push that back to them though
<bonda_000> at least it wasn't working for me and TI MSP432 I was trying to flash until I fixed those numbers by hand
<bonda_000> clever: so can we run an experiment and record what is going on when the camera boots?
<f_ridge> <x​2x6_/D> What exactly? Can you drop me a patch?
<bonda_000> sure
<bonda_000> one sec I will start the Pi
<clever> bonda_000: maybe, i'll have to hook the camera up again and get that pi booting
<f_ridge> <x​2x6_/D> This is my best result
<f_ridge> <x​2x6_/D> https://youtu.be/KOxSWKIKeBI
<f_ridge> <x​2x6_/D> I am receiving H264 compressed video frames from VideoCore ISP , but having troubles with storing them on SD card. Clever tried to help me , but I am stuck for now.
<f_ridge> <x​2x6_/D> So when SD card can not write new frames quickly VideoCore fw just skips the frames and gives me the latest instead, thats why video looks like some bug
<f_ridge> <x​2x6_/D> Looks like in H264 does there is no timestamp bound to each frame, so when frame is skipped - this is invisible to video player it just plays back all the frames it detects with the set framerate
<bonda_000> so how do I address you so that you get a notification
<bonda_000> since you are talking through the bridge
<bonda_000> with a f_ridge:?
<bonda_000> or what
<f_ridge> <x​2x6_/D> You have discord?
<f_ridge> <x​2x6_/D> telegram
<f_ridge> <x​2x6_/D> ?
<bonda_000> no only here
<bonda_000> if I type here
<bonda_000> can you get a notification there?
<f_ridge> <x​2x6_/D> 1 sec
<bonda_000> anyway
<clever> bonda_000: depends on how discord is configured, it has several options
<bonda_000> openocd-code/src/jtag/drivers/bcm2835gpio.c
<bonda_000> that source file needs a fix
<clever> bonda_000: what fix did it need?
<bonda_000> for Pi 3B
<bonda_000> clever: look at peri_base
<bonda_000> should be a 0x3F000000 for Pi 3B
user_user has joined ##raspberrypi-internals
<bonda_000> I think that was it
<f_ridge> <x​2x6_/D> how do you set nick on irc?
<clever> bonda_000: this command also allows you to change it from config files
<clever> with the /nick command
user_user is now known as x^2^x6^
<x^2^x6^> Ok, I've joined over irc client
<x^2^x6^> Hmm, ok. I'll try this one, thanks.
<bonda_000> clever: thanks, that's useful. didn't know that
<x^2^x6^> Not today , I need first to buy a JTAG, I've left my JTAG when relocated
<f_[xmpp]> bonda_000: you ping someone on Discord with e.g. @x2x6_
<clever> bonda_000: also, if you open /dev/gpiomem instead of /dev/mem, it will always have the right offset for the gpio
<f_[xmpp]> @<username> basically. To ping people on IRC you just do "<username>" eg f_
<bonda_000> x^2^x6^: how did you power your pi on that walk?
<x^2^x6^> heh) On the side there is a cardbox section that holds a 6.3volt battery or something like that. Actually rechargable.
<x^2^x6^> on the video with demonstration of the device you can hear a click
<bonda_000> the only reason I'm not giving up on BCM2835 is the low power they claim
<x^2^x6^> Yes, this battery was enough for 1 week of testing
<bonda_000> how much mAh in that battery?
<x^2^x6^> Emm, I can tell you some time later. Now its all in duct tape and I really don't remember
<f_ridge> <x​2x6_/D> thats the block I've bought, chosen randomly
<x^2^x6^> My powering design was to use it as videoregistrator in car then it uses just usb cable to car power socket. And then you take it out of the car and press the power switch that connects the power line to battery
<x^2^x6^> But I did not dig much into it, because I'm in sw part right now
<clever> x^2^x6^: have you tried just reducing the target bitrate in the encoder some more, to a level where the card can always keep up?
<x^2^x6^> I've done experiments to reduce the target bitrate, and this actually helps to even out the speeds so that no frameloss happens. I can also reduce the image size to smaller values like 800x600 and this will give no skipped frames
<x^2^x6^> 1280x1024 gives almost no bugs.
<x^2^x6^> Currently I try to figure out what is max possible frame size and quality. But I am stuck on getting SD card work on 50MHz as you know.
<x^2^x6^> I can not continue, because suddenly many things about sdcard work bad. Like for example I don't get a proper CSD register values as in my post above - its shifted 1 byte, then there are problems with CMD58, etc.
<bonda_000> what makes you think it is the videocore firmware side issue?
<x^2^x6^> So I go for a workaround, today I am building whole raspberry pi image including kernel with yocto, to be able to add more logging in kernel to see values that kernel sees in emmc peripheral
<x^2^x6^> I did not say vidoecore firmware is the issue. To me the issue is that I do not schedule write out part of frame data correctly, mainly - I ask too much from currnet SDcard configuration.
<x^2^x6^> I want to increase write speed to sdcard x2
<x^2^x6^> and then see what is the maximum possible image quality without dropped frames
<x^2^x6^> And then just clean up the IO scheduling and so on
<bonda_000> if there is Linux working it does mess a lot with videocore activities
<bonda_000> occupying the data bus
jcea has joined ##raspberrypi-internals
<x^2^x6^> I only care about linux to the point to see how it initializes EMMC controller on rpi in order to boost it to 50MHz clock (High Speed mode). I am not able to do this correctly.
<bonda_000> on the videocore side I see
<bonda_000> int __stdcall filesys_init(void)
<x^2^x6^> There is a high speed bit in one of the control registers in bcm2835 emmc peripheral. But also you have to send specific command to sdcard before setting this bit. But after that sdcard does not work reliably especially on writes
<bonda_000> creates the sd control struct uVar3 = rtos_malloc_priority(0x8000,0x20,0x40000000,0);
<clever> ah right, this only runs when certain errors occur
<bonda_000> this is what filesys_init looks for me
<bonda_000> that starts the sd card
<bonda_000> that's the videocore side
<bonda_000> moslty writes to global variables and sets off other init functions
<clever> bonda_000: i suspect the videocore side may be less optimized, because linux is dealing with all of the high IO stuff now
<bonda_000> puVar6 = media_storage + iVar1 * 0xcdc;
<bonda_000> this says they left an option for multiple sd cards in the future and each sd control block is of 0xCDC bytes size
<bonda_000> because
<bonda_000> everything in videocore is ran as a "ril" interface layer component
<x^2^x6^> Note that I am using emmc directly from my baremetal code, so I am responsible for writes, videocore only has to provide compressed video frames
<bonda_000> and you use all that vchiq stuff?
<x^2^x6^> Yes,
<x^2^x6^> It seems to do the job
<x^2^x6^> I have a h264 writeout but also SPI display to where I have to draw a preview picture, so that we could see what is written, in smaller form -320x240
<x^2^x6^> So MMAL is configured to output image and then shrink it in one of the splitted streams
<x^2^x6^> So i manage two image streams - one to DMA to spi display, one to sdcard
<x^2^x6^> one steam is encoded , one is raw
<bonda_000> try to do the logging on the videocore side
<bonda_000> the camera code is full of logging inserts
<bonda_000> when it's not able to do something
<bonda_000> have you tried this
<clever> bonda_000: the problem is more that the h264 encoder is generating data too fast, and x^2^x6^'s MMC code cant write it to the card fast enough
<clever> so its less a problem with the firmware not working right, and more with the MMC not being fast enough
<x^2^x6^> exactly
<bonda_000> can you hook up your setup with the uart and show what debug messages the videocore reports
<bonda_000> start_debug=1
<bonda_000> enable_2ndstage_uart=1
<clever> that 2nd one doesnt sound right
<x^2^x6^> Yes, I'll post results tomorrow.
<clever> uart_2ndstage=1 is the 2nd one
bonda_000 has quit [Quit: Leaving]
Ad0 has quit [Ping timeout: 252 seconds]
jcea has quit [Quit: jcea]
jcea has joined ##raspberrypi-internals
Ad0 has joined ##raspberrypi-internals
jcea has quit [Quit: jcea]
jcea has joined ##raspberrypi-internals