agg23 / openfpga-litex

A RISC-V software platform, exposing Analogue Pocket capabilities in a simple way
MIT License
36 stars 2 forks source link

Sample C app "Fungus" #4

Closed mcclure closed 9 months ago

mcclure commented 9 months ago

I think the repo should have (or at least: there should exist for this platform somewhere) at least one Rust example and at least one C example that utilize the CSR features such as audio, video, and controls. I had this idea of having a bunch of little pixel-sized agents scribbling colors to make a growing-fungus screensaver.

Then I got carried away >_>

Anyway, here's a probably overly complicated sample. It might be that the ideal version of this to actually add to the repro would be commit 29150307; this commit is easier to understand because the features are more minimal (it draws, it makes sound, you can pause with select, you can fudge the colors with L and R), so it does a better job of actually being sample code. The final version, every button on the pocket does something and there's a variety of modes. I could release the full version elsewhere.

Problems with this:

Let me know if you want (1) this version (2) 29150307 or (3) neither and this will tell me which version to start commenting.


Controls: Select: Pause. Start: Reboot. L and R: rotate colors. D-pad: shift fungus. X: Toggle "aggressive" growth. A: Toggle fast color cycling. Y: Toggle BRAMBLY vs SOLID looks. B: Cycle between 3 growth speeds.

Things I like doing: Turn it on and then immediately hit X and A at once; leave it running until the fungus starts eating the pillars (it eventually will)

mcclure commented 9 months ago

Screenshots

boot_20231129_010804 boot_20231129_020442 boot_20231129_020631 boot_20231129_021851 boot_20231128_232800

It also makes a sound like the matmos

agg23 commented 9 months ago

I played with it some, and it's specifically the .data assignment that's causing printf to fail. As expected, directly writing to UART does work (uart_rxtx_write('f')), but obviously that is not what we want.

The program correctly runs and prints with the following data segment:

.data :
{
    . = ALIGN(8);
    _fdata = .;
    *(.data .data.* .gnu.linkonce.d.*)
    *(.data1)
    _gp = ALIGN(16);
    *(.sdata .sdata.* .gnu.linkonce.s.*)
    . = ALIGN(8);
    _edata = .;
} > sram AT > main_ram

No other mention of sram exists in the file. However, I do not understand what AT means, and I was having trouble understanding this when I was building the first, pre-LiteX version of the core.

mcclure commented 9 months ago

Ready to merge