Thursday, 2022-04-28

*** tpb <[email protected]> has joined #litex00:00
*** Degi_ <[email protected]> has joined #litex00:32
*** Degi <[email protected]> has quit IRC (Ping timeout: 240 seconds)00:33
*** Degi_ is now known as Degi00:33
swetlandIs there a way to change the main ram base address for a single board?  I'm not quite sure how/where to override mem_map["main_ram"]02:01
*** xenador77 <xenador77!~xenador77@user/xenador77> has quit IRC (Remote host closed the connection)02:24
*** TMM_ <[email protected]> has quit IRC (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.)03:25
*** TMM_ <[email protected]> has joined #litex03:25
jevinskie[m]What is the situation with Linux on LiteX and USB on the orangecrab? Do I only get a serial port? I’m wondering how I can get networking on the orangecrab Linux03:28
swetlanddaughterboard with an ethernet PHY?  10/100 shouldn't be too hard.  Gbe might be hairy03:38
cr1901_I would run a ppp connection over serial to a Pi or something w/ Ethernet personally05:39
cr1901_but I'm a bit nuts05:39
jevinskie[m]<cr1901_> "I would run a ppp connection..." <- That sounds more like it for me, I’m trying to keep it over usb. I wonder if I can have two serial endpoints or present as two CDC devices one for ppp and one for kernel logging05:59
*** FabM <FabM!~FabM@2a03:d604:103:600:55ec:b29d:7137:ac1f> has joined #litex06:06
swetlandwell if it's over usb you might as well do CDC Ethernet06:10
swetlandit's pretty simple and you're then exchanging ethernet frames over usb06:11
swetlandand should just look like another interface on the host you plug it into06:11
swetlandlikely far less painful and more plug'n'play than PPP 06:12
tntyeah, but iirc the default bitstream uses a pure CDC (like ... hw logic thing, risc-v sees it as a hw uart)06:17
swetlandah, I see06:19
tntI wonder if you can use gadget cdc/serial as a console device on linux.06:21
tnt(not that there is any support for gadget driver for the OC but ...)06:22
tntswetland: btw, I'm disappointed you didn't go for the full 16 CGA colors :D06:23
swetlandI could not get the damn intensity bit wired up right06:24
tntI think you'd pretty much have to make a LUT06:24
swetlandI realized that not only are migens bit slices BACKWARDS from verilog, they're also *range exclusive* instead of *range inclusive*06:24
tntAh well yeah, they're python semantics.06:25
tntI told you ... I hate it.06:25
swetlandI am not a python fan and this experience is not changing that06:25
swetlandIn general the shape of migen/nmigen/amarath is nice but I really think a DSL instead of just re-using python with its quirks and goddamn syntatic whitespace would be a huge improvement06:26
swetlandbuilding a system inside python is like building build systems inside gnu make06:27
swetlandyou can make a nice build system but everyone looks and says "oh I know this, it's make!" and suddenly it all goes to hell ^^06:27
amstanI agree, reusing python dsl is quite poor if you need expressions and flow control. It works a lot better if your stuff is declarative only.06:28
amstanOn the other hand it wouldn't be too hard to create a dsl and convert it to the amaranth internal datastructures06:29
swetlandthe other thing that's frustrating is you can occasionally end up deep in some python backtrace with no clear idea what caused it06:33
amstani think that's fixable, the exceptions can be rewritten06:33
swetlandhttps://github.com/enjoy-digital/litex/issues/128506:33
amstanouch, that's quite the mountful06:35
*** davebee <[email protected]> has joined #litex07:39
swetlandso here's something that is proving nonobvious -- I'd like to reconfigure vecriscv in litex for main ram at 0x8000_0000, so that it's easier to compile code to run on both it and qemu07:52
swetland(I realize I can change qemu sources as well, but since I'm customizing the "soc" anyway...)07:53
tntsee lattice_crosslink_nx_evn.py as example and look at line 6207:56
swetlandthat almost gets me there.  cores/vexriscv.py declares io region @80000000 size 80000000.  editing that to @C0000000/40000000 at least has it building, but that's ugly08:03
tntOh yeah, you might have another propblen ...08:04
tntthe Vex scala code actually defines what is considered "IO" ( which influences cachine / mmu / ... ).08:05
swetlandahhhh I was afraid of that08:07
swetlandon the plus side I've already figured out how to rebuild vexriscv from the scala08:08
tnthttps://github.com/litex-hub/pythondata-cpu-vexriscv/blob/master/pythondata_cpu_vexriscv/verilog/src/main/scala/vexriscv/GenCoreDefault.scala#L16108:09
swetlandohoho I am LUCKY08:10
swetlandI'm using the "linux" variant which defines io as 256MB @ B000_0000, E000_0000, and F000_000008:12
swetlandwell not that lucky08:14
swetlandbios does start but serial download is blowing up08:14
tntB0 is still conflict right08:14
tntoh I guess depend how much ram you have.08:15
tntwhy are you using the linux variant btw ?08:15
swetlandonly 32MB at 8000_0000, so plenty of room08:15
swetlandI want a target with full U/S/M modes and a MMU08:16
tntif you're trying to run linux, moving the ram is going to be a pain, the address is hardcoded at a bunch of places.08:16
swetlanddoing some "how to write an OS" workshops with some friends08:16
swetlanddefinitely not planning on running linux.08:16
swetlandbut it is beginning to look like it'll be simpler to move the main ram region in Qemu (was just hoping to not have people have to build a modified qemu, but such is life)08:17
swetlandI thought RISCV would be fun -- it's a "real" cpu, but not terribly complex, it runs fine in Qemu and on ECP5 platforms08:19
_florent_regarding main_ram address/linux, the address in LiteX is probably only hardcoded in the CPUs, ex: https://github.com/enjoy-digital/litex/blob/master/litex/soc/cores/cpu/vexriscv/core.py#L11609:02
_florent_For rocket, we are using 0x8000000: https://github.com/enjoy-digital/litex/blob/master/litex/soc/cores/cpu/rocket/core.py#L11309:02
_florent_But I'm not familiar enough with VexRiscv internals to say09:03
davebeeGot gdb connected to my vexriscv yesterday, thanks to tnt. I can breakpoint, but not step. But it was enough to let me work out why FreeRTOS wasn't running. Now it does, so I have an OS running on my CPU. Next : implement semaphores and queues.09:55
davebeeMy C++ library code uses std::atomic<>. Not sure if the vexriscv supports atomics. Where should I ask?13:05
tntit depends on which vex variant you're using13:11
tntonly the 'linux' variant in litex is configuted for LR/SC + AMO operations.13:13
davebeeokay, thanks. I'm using standard+debug. I'll take a look.13:31
davebeeAtomics are really handy, but the library I'm using was targetted at an STM327xx which does support them. There is probably a software fix.13:34
davebeestm32f7xx13:34
tntOTOH does std::atomic actually use the RISC-V atomic operations ?13:37
tntI mean, usually you can do atomics without hw support just disabling interrupt ...13:37
zypI think if you don't have atomic instructions, the compiler generates a software implementation that calls stubs that you can provide to disable interrupts13:37
zyptnt, yeah, if available it does13:37
*** kbeckmann1 is now known as kbeckmann13:38
xobs[m]tnt: It does, yes. Platforms that don't have arlmkxa just don't have that package. 13:38
xobs[m]* It does, yes. Platforms that don't have atomics just don't have that package. 13:39
xobs[m]The software fix is to bodge it in a machine mode handler. 13:40
pepijndevos[m]On a board without a nice usb interface, what's the best way to work with it? I have a jtag thingy to program the fpga, but then on the ulx3s I'd use litex_term --kernel to serial boot my code, so would I need a uart thingy to do that?13:41
zyphere's what gcc does with atomic instructions: https://godbolt.org/z/WMaEzdzqj and without: https://godbolt.org/z/E5sYf4eWY13:44
tpbTitle: Compiler Explorer (at godbolt.org)13:44
zypfor atomic increment, it ends up calling a stub called __atomic_fetch_add_413:44
pepijndevos[m]wait... does this mean it can serial boot over ethernet?? https://github.com/litex-hub/litex-boards/blob/master/litex_boards/targets/colorlight_5a_75x.py13:45
rowang077[m]pepijndevos: You can boot over ethernet yes or over UART. I have never done it though13:45
tntxobs[m]: yeah, I know you can use machine mode emulation, but as zyp pointed out, I expected GCC and stdc++ to have sw only solutions ot that.13:46
tntpepijndevos[m]: in theory with crossover uart and a xxxBone bridge you should be able to yes.13:49
pepijndevos[m]Does etherbone completely take over the phy, or can the SoC still do ethernet? Kinda the whole point of the colorlight board for me is the ethernet. On the other hand, if I can use etherbone to twiddle registers in my SoC such that I don't have to deal with ethernet at all... 🤔13:57
tntIIUC they can both work at the same time.14:01
_florent_pepijndevos[m]: you can do both at the same time, but we don't yet have a add_xy method for it, you have to do it manually in your target file14:03
_florent_https://github.com/litex-hub/litex-boards/blob/575d6818915b16f69279f0628b4472a007dc5106/litex_boards/targets/siglent_sds1104xe.py#L94-L13914:04
_florent_you then have two MAC/IP addresses: One for the CPU + software stack, one for the hardware stack + etherbone14:05
pepijndevos[m]https://github.com/litex-hub/litex-boards/blob/9914478854b83ec5750c07df995b2390977280c2/litex_boards/targets/colorlight_5a_75x.py#L166-L169 ahh so if you just pass both of these CLASH!14:06
_florent_yes, each of these will want to have direct connection to the PHY, which is not possible...14:27
mithro_florent_: Did you see https://wiki.f-si.org/index.php/FSiC2022 ?14:47
tpbTitle: FSiC2022 - F-Si wiki (at wiki.f-si.org)14:47
*** genpaku <[email protected]> has joined #litex15:11
davebeethanks for the comments on atomics.15:28
cr1901_tnt: What's the difference between machine mode emulation and "gcc providing a stub for you to implement atomics"?15:39
cr1901_Re: "I expected GCC and stdc++ to have sw only solutions ot that."15:39
davebeeI'm building with -march=rv32im ie no atomics. gcc creates calls to __atomic_fetch_add_4() and __atomic_fetch_sub_4(). I don't have these as Litex builds the newlib runtime and does nto include any C++ stuff. But I should be able to writes something.15:42
*** davebee <[email protected]> has quit IRC (Quit: Leaving)16:14
_florent_mithro: not yet, I'll look16:45
*** FabM <FabM!~FabM@armadeus/team/FabM> has quit IRC (Quit: Leaving)18:31
mithroIt's in Paris which seems like your neck of the woods18:42
tntcr1901_: machine mode emulation is basically you compile cod efor RV32IMA but you'd don't actually have Atomics instruction in hardware. The CPU traps as illegal instructions and you provide a "bios" that emulates them and then returns from the trap.18:51
tntcr1901_: That's actually what I did to run linux on ice40 because the hw atomics were too big to fit.18:52
*** TMM_ <[email protected]> has quit IRC (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.)19:22
*** TMM_ <[email protected]> has joined #litex19:22
swetlandfor single core platforms atomics via disabling interrupts is not horrible. multicore you need spinlocks too which gets uglier19:41
tntyeah sure, but the thing here was single core.19:56
cr1901_I don't remember the name, but I seem to vaguely recall that ARMv5 on Linux emulates atomics in a different way20:56
cr1901_("pretend the critical section is atomic, and back up/fail if it turns out another thread tried taking control")20:56
cr1901_Damn, gonna kick myself for not remembering the name of what I'm thinking of20:57
*** zjason` <zjason`[email protected]> has joined #litex21:09
*** zjason <[email protected]> has quit IRC (Ping timeout: 240 seconds)21:10
swetlandtnt: biggest problem with debugging my memory -> 8000_0000 changes... forgot to change the load address in litex term21:24
swetlandhttps://pastebin.com/wYniWwqv21:41
tpbTitle: ulx3s memory relocation - Pastebin.com (at pastebin.com)21:41
swetlandWhat I've found is that I can move memory by adjusting soc/cores/cpu/vexriscv/core.py but all my various attempts to override things from radiona_ulx3s.py have failed21:42
swetlandand the io region definitely needs to be adjusted (keeping the CSRs where they are but ensuring it doesn't overlap the higher memory window21:43
*** xenador77 <xenador77!~xenador77@user/xenador77> has joined #litex22:17
*** SpaceCoaster <SpaceCoaster!~derek@user/spacecoaster> has quit IRC (Ping timeout: 260 seconds)23:21
*** SpaceCoaster <SpaceCoaster!~derek@user/spacecoaster> has joined #litex23:23

Generated by irclog2html.py 2.17.2 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!