*** tpb has joined #timvideos | 00:00 | |
tannewt | Mithro gonna be around sometime tonight? I can align me looking at it with you | 01:59 |
---|---|---|
mithro | tannewt: You want to use TARGET=usb CPU_VARIANT=lite FIRMWARE=tinyusb now | 02:42 |
mithro | Then | 02:42 |
tannewt | kk | 02:42 |
mithro | mkdir -p build/tinyfpga_bx_usb_lm32.lite//software/tinyusb/ | 02:42 |
mithro | ln -s $PWD/third_party/valentyusb/third_party/tinyusb/examples/device/cdc_msc_hid/build-valentyusb/valentyusb-firmware.bin build/tinyfpga_bx_usb_lm32.lite//software/tinyusb/firmware.bin | 02:43 |
tannewt | are you around for a bit now? I can get it going now | 02:43 |
mithro | tannewt: make image && make flash | 02:43 |
mithro | tannewt: Kind, we are moving buildings, so I'm slowly packing up all the shit on my desk | 02:43 |
tannewt | kk | 02:43 |
mithro | s/kind/kinda/ | 02:43 |
tannewt | yup | 02:43 |
mithro | tannewt: it should be pretty obvious what is happening, as I print out the packet contents as they come in | 02:44 |
mithro | tannewt: You should only need to build the gateware once, then just rebuild the tinyusb firmware and do a "make image && make flash" | 02:45 |
mithro | tannewt: Makes it pretty quick to develop | 02:45 |
tannewt | k, I have a beagle that I can use to sniff too | 02:45 |
tannewt | nice! | 02:45 |
mithro | tannewt: make sure you get the latest nextpnr build too | 02:47 |
cr1901_modern | mithro: Do you still want/need the BRAM reload feature? | 02:47 |
mithro | Conda install nextpnr | 02:47 |
tannewt | kk | 02:48 |
mithro | cr1901_modern: by "reload" what are you talking about - want to make sure we are talking about the same thing | 02:48 |
cr1901_modern | mithro: "For a given SoC and peripherals configuration, you create a design where the internal BRAM is loaded with a PRNG. Then you run icebram to swap out the contents with your real firmware. As long as you don't change the gateware, you avoid having to rerun synthesis." | 02:50 |
mithro | The exact process isn't important, but being able to patch the gateware to have new bram contents without having to rerun synthesis | 02:52 |
tannewt | mithro, tinyusb isn't compiling " implicit declaration of function 'usb_pullup_out_write'; did you mean 'usb_ep_0_out_head_write'?" | 03:03 |
mithro | tannewt: did you compile the gateware? | 03:03 |
tannewt | yup | 03:04 |
mithro | And check your submodules? | 03:04 |
* tannewt looks | 03:04 | |
mithro | Give me a moment and I will see what mine are | 03:06 |
tannewt | everything looks ok | 03:07 |
tannewt | it should be your litex right? | 03:08 |
mithro | Hrm... | 03:11 |
mithro | My include path seems wrong... | 03:11 |
mithro | tinyfpga_bx_usb_lm32.minimal/software/include | 03:11 |
mithro | Looks like I hard coded a path in hw/bsp/valentyusb/board.mk | 03:12 |
tannewt | litex-buildenv is abd05ee7 | 03:12 |
tannewt | k, looking | 03:12 |
mithro | tannewt: Try updating now | 03:14 |
mithro | https://www.irccloud.com/pastebin/ycRryZys/ | 03:15 |
tpb | Title: Snippet | IRCCloud (at www.irccloud.com) | 03:15 |
tannewt | making gateware... | 03:17 |
tannewt | 👍 | 03:18 |
tannewt | built | 03:18 |
tannewt | do I have to do something over uart to get it going? | 03:23 |
tannewt | I only see a reset after the firmware was loaded | 03:23 |
mithro | tannewt: You should get the bios | 03:27 |
mithro | tannewt: And then the firmware should ask you to "continue" | 03:27 |
mithro | tannewt: send any key and it'll start the USB transactions | 03:27 |
tannewt | kk what pins are the uart on? | 03:28 |
tannewt | k see 1 and 2 I think | 03:31 |
tannewt | whee! | 03:31 |
tannewt | beagle shows it naking a setup packet | 03:33 |
mithro | tannewt: It naks on an endpoint once it has received something until you rearm it | 03:35 |
tannewt | endpoint 0 can't do that | 03:35 |
tannewt | I realize I said that about most endpoints before | 03:35 |
mithro | hrm? | 03:36 |
tannewt | https://usercontent.irccloud-cdn.com/file/CIwOsCcj/IMG_2987.JPG | 03:37 |
tannewt | setup packets must be acked quickly | 03:38 |
tannewt | nrf has 8 bytes of register to store it | 03:38 |
tannewt | atmel will ack and store to the pointer it has even if its null and throws it away | 03:38 |
tannewt | most endpoints are ok with nak, 0 with setup packets is picky | 03:39 |
mithro | tannewt: Sure, so you need to ARM the setup endpoint before you get a setup packet | 03:40 |
tannewt | it should always be armed | 03:40 |
tannewt | because setup can happen at any time | 03:41 |
*** springermac has quit IRC | 03:48 | |
*** springermac has joined #timvideos | 03:55 | |
tannewt | I think there might be an endian problem as well | 03:57 |
tannewt | the response to the first packet is wrong too I think | 03:57 |
*** rohitksingh_work has joined #timvideos | 04:10 | |
mithro | tannewt: the lm32 is a big endian system.... | 04:14 |
tannewt | is there such thing as bit order? | 04:16 |
mithro | tannewt: Sure, do you shift MSB or LSB out first | 04:17 |
tannewt | I think the struct bitpacking is backwards | 04:17 |
tannewt | ep0 out got setup g:8 w:8 80 6 0 1 0 0 40 0 | 04:18 |
tannewt | bmRequestType 80 10 0 | 04:18 |
tannewt | its requesttype, recipient and type | 04:19 |
mithro | tannewt: this is what sigrok is showing me -> https://usercontent.irccloud-cdn.com/file/ZnlP8GhG/image.png | 04:19 |
tannewt | ya, thats correct | 04:19 |
tannewt | https://github.com/hathach/tinyusb/blob/develop/src/common/tusb_types.h#L356 | 04:19 |
tpb | Title: tinyusb/tusb_types.h at develop · hathach/tinyusb · GitHub (at github.com) | 04:19 |
mithro | With GCC, big endian machines lay out the bits big end first and little endian machines lay out the bits little end first. | 04:20 |
mithro | http://mjfrazer.org/mjfrazer/bitfields/ | 04:21 |
tpb | Title: How Endianness Effects Bitfield Packing (at mjfrazer.org) | 04:21 |
tannewt | bmRequestType 80 rcpt 10 type 0 dir 0 | 04:22 |
tannewt | the struct bit unpacking is wrong | 04:22 |
tannewt | rcpt should be 0 and dir 1 | 04:22 |
tannewt | for 0x80 in | 04:22 |
mithro | tannewt: Yeah, using bitfields breaks | 04:22 |
mithro | tannewt: So, the question is - how many places have you used bitfields? | 04:23 |
tannewt | I don't know why you say "you" | 04:23 |
tannewt | I didn't write this code | 04:23 |
mithro | you == tinyusb developers :-P | 04:25 |
tannewt | :-) | 04:26 |
tannewt | so is the right thing to use shifts instead? | 04:26 |
mithro | tannewt: That is what Linux does | 04:29 |
tannewt | k | 04:31 |
tannewt | are there any other cores that are big endian? arm is mostly what we'll target | 04:31 |
tannewt | and risc-v is little as well | 04:31 |
mithro | tannewt: mips can be | 04:34 |
mithro | power | 04:34 |
mithro | tannewt: This might be another solution -> https://github.com/mithro/tinyusb/commit/d966587bb4904a95691817f73a3f390533563ba9 | 04:34 |
tpb | Title: Endian fixes. · mithro/tinyusb@d966587 · GitHub (at github.com) | 04:34 |
tannewt | ya, I think that'd be my preference | 04:35 |
mithro | Bigendian is going out of style | 04:36 |
mithro | Sadly grepping for bitfields is kind of hard | 04:38 |
mithro | Looks like #pragma scalar_storage_order little-endian | 04:40 |
mithro | Might potentially work.. | 04:40 |
tannewt | I'm still not replying with a descriptor even after switching the order | 04:41 |
tannewt | without* | 04:41 |
tannewt | er, too many negatives | 04:41 |
tannewt | its failing | 04:42 |
mithro | struct __attribute__((packed, scalar_storage_order("big-endian"))) mystruct { | 04:43 |
tannewt | shouldn't it be little? | 04:45 |
tannewt | I'm confused. my dinner is hitting my brain | 04:45 |
tannewt | gonna take a break | 04:45 |
tannewt | good luck! iteration cycle is nice and quick | 04:46 |
mithro | Yes, but on my phone it was easier to copy the exisiting example | 04:47 |
mithro | tannewt: I'm very confused about how tinyusb deals with setup transactions verses other transactions | 04:49 |
tannewt | ah | 04:50 |
tannewt | regular transactions go to and from tinyusb managed buffers | 04:50 |
tannewt | setup packets are copied into the event struct when received because they can happen at any time | 04:51 |
tannewt | the samd port maintains its own setup buffer to catch these packets while nrf has a dedicated peripheral buffer | 04:52 |
mithro | tannewt: so, when you get a setup buffer, you should be arming ep0 for either a IN or OUT transaction, right? | 05:08 |
tannewt | Ideally the peripheral has a buffer for setup packet it can use whenever it gets a setup token | 05:09 |
mithro | tannewt: setup buffer == data from the setup transaction (the 8 bytes) | 05:11 |
tannewt | Right | 05:11 |
mithro | setup transaction == setup token, data0 [8 bytes], ack | 05:11 |
tannewt | Exactly | 05:11 |
mithro | control thingy == setup transaction, n * in/out transaction, status transaction | 05:12 |
mithro | tannewt: Technically half way through that you could get another setup transaction.... | 05:13 |
tannewt | Right | 05:15 |
tannewt | And the status starts with a token in the opposite direction from the earlier data phase | 05:15 |
mithro | tannewt: Yeap, and it's has an empty data phase | 05:16 |
*** springermac has quit IRC | 05:20 | |
*** samsagaz_ has joined #timvideos | 05:20 | |
*** springermac has joined #timvideos | 05:34 | |
mithro | tannewt: So, I would expect that right after the setup packet I would expect tinyusb to schedule a transfer? | 05:35 |
tannewt | Yeah it should handle the data and status phase | 05:36 |
tannewt | Not sure why the get descriptor isn’t returning anything | 05:37 |
*** rohitksingh_work has quit IRC | 05:40 | |
*** rohitksingh_work has joined #timvideos | 05:41 | |
*** rohitksingh_wor1 has joined #timvideos | 05:44 | |
*** rohitksingh_work has quit IRC | 05:45 | |
tannewt | mithro, any more progress? | 06:33 |
mithro | tannewt: No, still in the process of packing up my desk - just about to shutdown my desktop computer | 06:38 |
tannewt | kk, I'm poking a little more | 06:38 |
tannewt | progress | 06:53 |
tannewt | https://usercontent.irccloud-cdn.com/file/HUzcxaQ4/Screen%20Shot%202018-11-29%20at%2010.47.12%20PM.png | 06:54 |
tannewt | responded right to the first setup packet | 06:54 |
tannewt | mithro (if you are around) how does the peripheral handle host reset? it acks but the buffer read by tinyusb is all 0xff | 06:56 |
tannewt | https://www.irccloud.com/pastebin/8AvjPjhk/ | 06:59 |
tpb | Title: Snippet | IRCCloud (at www.irccloud.com) | 06:59 |
*** samsagaz_ has quit IRC | 07:06 | |
*** tsglove2 has joined #timvideos | 07:15 | |
*** tsglove has quit IRC | 07:18 | |
tannewt | ok a couple fixes I found | 07:35 |
mithro | It doesn't really handle resets yet | 07:35 |
tannewt | 1) tu_u16_high and tu_u16_low are little endian and need to be swapped | 07:36 |
tannewt | 2) in dcd_valenty_usb.c we shouldn't call ep0_xfer_complete for setup packets | 07:36 |
tannewt | we already queue the special setup packet for it | 07:37 |
tannewt | do we get notified correctly for zero length out packets? | 07:37 |
tannewt | I don't think it works | 07:38 |
mithro | I'm heading home now | 07:40 |
tannewt | https://www.irccloud.com/pastebin/XPNb2HS2/ | 07:40 |
tpb | Title: Snippet | IRCCloud (at www.irccloud.com) | 07:40 |
tannewt | k np just posting what I've found so you can pick it up next time you have a chance | 07:41 |
mithro | tannewt: I thought the zero length transfers where working | 07:46 |
tannewt | they transfer but I don't think the poll know when it occurs | 07:46 |
tannewt | I got through the address change! | 07:47 |
tannewt | https://usercontent.irccloud-cdn.com/file/V6omHTHc/Screen%20Shot%202018-11-29%20at%2011.40.55%20PM.png | 07:47 |
mithro | \o/ | 07:47 |
mithro | I don't actually implement address checking... | 07:47 |
tannewt | :-D | 07:47 |
tannewt | looks like IN zlp works as expected | 07:49 |
*** springermac has quit IRC | 07:52 | |
mithro | That could be right | 07:53 |
tannewt | https://github.com/tannewt/tinyusb/tree/valentyusb | 07:54 |
tpb | Title: GitHub - tannewt/tinyusb at valentyusb (at github.com) | 07:54 |
tannewt | there are the changes I made | 07:54 |
mithro | Thanks! | 07:58 |
tannewt | np! | 08:00 |
*** springermac has joined #timvideos | 08:05 | |
*** sc00bz has quit IRC | 08:20 | |
*** sc00bz has joined #timvideos | 08:28 | |
*** tsglove2 is now known as tsglove | 12:13 | |
*** rohitksingh_wor1 has quit IRC | 12:37 | |
felix_ | tannewt: using bitfield structs for accessing hardware registers is undefined behaviour in c99 (not sure about newer versions of the c standard) | 13:11 |
felix_ | and using preprocessor macros is IMHO more a hack than a proper solution... | 13:15 |
shorne | CarlFK: I know a bit about it, not so much x86, Initram write failure may mean you didnt give the VM enough memory to even load linux? | 13:17 |
*** rohitksingh has joined #timvideos | 13:17 | |
*** rohitksingh has quit IRC | 15:09 | |
*** rohitksingh has joined #timvideos | 15:31 | |
*** samsagaz_ has joined #timvideos | 19:52 | |
CarlFK | shorne: thanks - that may have been it. had -m 256, bumped to 512, works. (but I have been fiddling .. so la la la ) | 20:49 |
*** samsagaz_ has quit IRC | 21:35 | |
*** rohitksingh has quit IRC | 21:40 | |
*** waldo323_ has quit IRC | 21:57 |
Generated by irclog2html.py 2.13.1 by Marius Gedminas - find it at mg.pov.lt!