Friday, 2018-11-30

*** tpb has joined #timvideos00:00
tannewtMithro gonna be around sometime tonight? I can align me looking at it with you01:59
mithrotannewt: You want to use TARGET=usb CPU_VARIANT=lite FIRMWARE=tinyusb now02:42
mithromkdir -p build/tinyfpga_bx_usb_lm32.lite//software/tinyusb/02:42
mithroln -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.bin02:43
tannewtare you around for a bit now? I can get it going now02:43
mithrotannewt: make image && make flash02:43
mithrotannewt: Kind, we are moving buildings, so I'm slowly packing up all the shit on my desk02:43
mithrotannewt: it should be pretty obvious what is happening, as I print out the packet contents as they come in02:44
mithrotannewt: You should only need to build the gateware once, then just rebuild the tinyusb firmware and do a "make image && make flash"02:45
mithrotannewt: Makes it pretty quick to develop02:45
tannewtk, I have a beagle that I can use to sniff too02:45
mithrotannewt: make sure you get the latest nextpnr build too02:47
cr1901_modernmithro: Do you still want/need the BRAM reload feature?02:47
mithroConda install nextpnr02:47
mithrocr1901_modern: by "reload" what are you talking about - want to make sure we are talking about the same thing02:48
cr1901_modernmithro: "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
mithroThe exact process isn't important, but being able to patch the gateware to have new bram contents without having to rerun synthesis02:52
tannewtmithro, tinyusb isn't compiling " implicit declaration of function 'usb_pullup_out_write'; did you mean 'usb_ep_0_out_head_write'?"03:03
mithrotannewt: did you compile the gateware?03:03
mithroAnd check your submodules?03:04
* tannewt looks03:04
mithroGive me a moment and I will see what mine are03:06
tannewteverything looks ok03:07
tannewtit should be your litex right?03:08
mithroMy include path seems wrong...03:11
mithroLooks like I hard coded a path in hw/bsp/valentyusb/board.mk03:12
tannewtlitex-buildenv is abd05ee703:12
tannewtk, looking03:12
mithrotannewt: Try updating now03:14
tpbTitle: Snippet | IRCCloud (at
tannewtmaking gateware...03:17
tannewtdo I have to do something over uart to get it going?03:23
tannewtI only see a reset after the firmware was loaded03:23
mithrotannewt: You should get the bios03:27
mithrotannewt: And then the firmware should ask you to "continue"03:27
mithrotannewt: send any key and it'll start the USB transactions03:27
tannewtkk what pins are the uart on?03:28
tannewtk see 1 and 2 I think03:31
tannewtbeagle shows it naking a setup packet03:33
mithrotannewt: It naks on an endpoint once it has received something until you rearm it03:35
tannewtendpoint 0 can't do that03:35
tannewtI realize I said that about most endpoints before03:35
tannewtsetup packets must be acked quickly03:38
tannewtnrf has 8 bytes of register to store it03:38
tannewtatmel will ack and store to the pointer it has even if its null and throws it away03:38
tannewtmost endpoints are ok with nak, 0 with setup packets is picky03:39
mithrotannewt: Sure, so you need to ARM the setup endpoint before you get a setup packet03:40
tannewtit should always be armed03:40
tannewtbecause setup can happen at any time03:41
*** springermac has quit IRC03:48
*** springermac has joined #timvideos03:55
tannewtI think there might be an endian problem as well03:57
tannewtthe response to the first packet is wrong too I think03:57
*** rohitksingh_work has joined #timvideos04:10
mithrotannewt: the lm32 is a big endian system....04:14
tannewtis there such thing as bit order?04:16
mithrotannewt: Sure, do you shift MSB or LSB out first04:17
tannewtI think the struct bitpacking is backwards04:17
tannewtep0 out got setup g:8 w:8 80 6 0 1 0 0 40 004:18
tannewtbmRequestType 80 10 004:18
tannewtits requesttype, recipient and type04:19
mithrotannewt: this is what sigrok is showing me ->
tannewtya, thats correct04:19
tpbTitle: tinyusb/tusb_types.h at develop · hathach/tinyusb · GitHub (at
mithroWith GCC, big endian machines lay out the bits big end first and little endian machines lay out the bits little end first.04:20
tpbTitle: How Endianness Effects Bitfield Packing (at
tannewtbmRequestType 80 rcpt 10 type 0 dir 004:22
tannewtthe struct bit unpacking is wrong04:22
tannewtrcpt should be 0 and dir 104:22
tannewtfor 0x80 in04:22
mithrotannewt: Yeah, using bitfields breaks04:22
mithrotannewt: So, the question is - how many places have you used bitfields?04:23
tannewtI don't know why you say "you"04:23
tannewtI didn't write this code04:23
mithroyou == tinyusb developers :-P04:25
tannewtso is the right thing to use shifts instead?04:26
mithrotannewt: That is what Linux does04:29
tannewtare there any other cores that are big endian? arm is mostly what we'll target04:31
tannewtand risc-v is little as well04:31
mithrotannewt: mips can be04:34
mithrotannewt: This might be another solution ->
tpbTitle: Endian fixes. · mithro/[email protected] · GitHub (at
tannewtya, I think that'd be my preference04:35
mithroBigendian is going out of style04:36
mithroSadly grepping for bitfields is kind of hard04:38
mithroLooks like #pragma scalar_storage_order little-endian04:40
mithroMight potentially work..04:40
tannewtI'm still not replying with a descriptor even after switching the order04:41
tannewter, too many negatives04:41
tannewtits failing04:42
mithrostruct __attribute__((packed, scalar_storage_order("big-endian"))) mystruct {04:43
tannewtshouldn't it be little?04:45
tannewtI'm confused. my dinner is hitting my brain04:45
tannewtgonna take a break04:45
tannewtgood luck! iteration cycle is nice and quick04:46
mithroYes, but on my phone it was easier to copy the exisiting example04:47
mithrotannewt: I'm very confused about how tinyusb deals with setup transactions verses other transactions04:49
tannewtregular transactions go to and from tinyusb managed buffers04:50
tannewtsetup packets are copied into the event struct when received because they can happen at any time04:51
tannewtthe samd port maintains its own setup buffer to catch these packets while nrf has a dedicated peripheral buffer04:52
mithrotannewt: so, when you get a setup buffer, you should be arming ep0 for either a IN or OUT transaction, right?05:08
tannewtIdeally the peripheral has a buffer for setup packet it can use whenever it gets a setup token05:09
mithrotannewt: setup buffer == data from the setup transaction (the 8 bytes)05:11
mithrosetup transaction == setup token, data0 [8 bytes], ack05:11
mithrocontrol thingy == setup transaction, n * in/out transaction, status transaction05:12
mithrotannewt: Technically half way through that you could get another setup transaction....05:13
tannewtAnd the status starts with a token in the opposite direction from the earlier data phase05:15
mithrotannewt: Yeap, and it's has an empty data phase05:16
*** springermac has quit IRC05:20
*** samsagaz_ has joined #timvideos05:20
*** springermac has joined #timvideos05:34
mithrotannewt: So, I would expect that right after the setup packet I would expect tinyusb to schedule a transfer?05:35
tannewtYeah it should handle the data and status phase05:36
tannewtNot sure why the get descriptor isn’t returning anything05:37
*** rohitksingh_work has quit IRC05:40
*** rohitksingh_work has joined #timvideos05:41
*** rohitksingh_wor1 has joined #timvideos05:44
*** rohitksingh_work has quit IRC05:45
tannewtmithro, any more progress?06:33
mithrotannewt: No, still in the process of packing up my desk - just about to shutdown my desktop computer06:38
tannewtkk, I'm poking a little more06:38
tannewtresponded right to the first setup packet06:54
tannewtmithro (if you are around) how does the peripheral handle host reset? it acks but the buffer read by tinyusb is all 0xff06:56
tpbTitle: Snippet | IRCCloud (at
*** samsagaz_ has quit IRC07:06
*** tsglove2 has joined #timvideos07:15
*** tsglove has quit IRC07:18
tannewtok a couple fixes I found07:35
mithroIt doesn't really handle resets yet07:35
tannewt1) tu_u16_high and tu_u16_low are little endian and need to be swapped07:36
tannewt2) in dcd_valenty_usb.c we shouldn't call ep0_xfer_complete for setup packets07:36
tannewtwe already queue the special setup packet for it07:37
tannewtdo we get notified correctly for zero length out packets?07:37
tannewtI don't think it works07:38
mithroI'm heading home now07:40
tpbTitle: Snippet | IRCCloud (at
tannewtk np just posting what I've found so you can pick it up next time you have a chance07:41
mithrotannewt: I thought the zero length transfers where working07:46
tannewtthey transfer but I don't think the poll know when it occurs07:46
tannewtI got through the address change!07:47
mithroI don't actually implement address checking...07:47
tannewtlooks like IN zlp works as expected07:49
*** springermac has quit IRC07:52
mithroThat could be right07:53
tpbTitle: GitHub - tannewt/tinyusb at valentyusb (at
tannewtthere are the changes I made07:54
*** springermac has joined #timvideos08:05
*** sc00bz has quit IRC08:20
*** sc00bz has joined #timvideos08:28
*** tsglove2 is now known as tsglove12:13
*** rohitksingh_wor1 has quit IRC12: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
shorneCarlFK: 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 #timvideos13:17
*** rohitksingh has quit IRC15:09
*** rohitksingh has joined #timvideos15:31
*** samsagaz_ has joined #timvideos19:52
CarlFKshorne: 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 IRC21:35
*** rohitksingh has quit IRC21:40
*** waldo323_ has quit IRC21:57

Generated by 2.13.1 by Marius Gedminas - find it at!