-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SAMx7x (E70, S70, V70, V71) DCD Support #693
Conversation
630509d
to
d8acce7
Compare
great PR, I will help and test it out whenever I could. Please keep it updated 👍 👍 |
With DMA and Dual Bank the throughput is quite good.
I got 126us for 4096 bytes OUT transfer, that's 32.5MB/s ! Even without DMA & Dual Bank I got about 12.5MB/s. Unfortunately I can't run |
@HiFiPhile though are pretty good number, and we haven't got into the speed optimization of development stage just yet 😄 |
whats missing on this PR? I have a device that will end up using this driver, and it would be convenient for me to have it merged, can i help in any way? |
Hi, at the moment this PR is tested on bulk transfer but other types of transfer remain untested (should work) I've done some more work about fifo support but also remain untested. |
Getting cdc_msc and hid_composite running is good enough for PR to merge. The rest can be done as follow up PRs. It is not easy to get everything right for the 1st pr. |
I'll push all works, could you test BSP integration and build with gcc ? Since I'm developing with IAR and my own BSP layer. |
I can build with GCC, but the only board i have with this device is custom, so Ill have to use my own BSP as well |
Signed-off-by: HiFiPhile <admin@hifiphile.com>
- Add DMA support - Add Dual bank support Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: Rafael Silva <perigoso@riseup.net>
Signed-off-by: Rafael Silva <perigoso@riseup.net>
Signed-off-by: Rafael Silva <perigoso@riseup.net>
Signed-off-by: Rafael Silva <perigoso@riseup.net>
Signed-off-by: Rafael Silva <perigoso@riseup.net>
Got it to compile fine on gcc, just needed to swap some macros that are deprecated in the sam cmsis, i guess it doesnt error in IAR, as for actually testing in hardware I can't do it just yet, |
Today I've tested MSC also works, maybe this weekend I'll test more examples. On Cortex-M7 cache coherence is something need to be take care of. I use 128KB ITCM + 128KB DTCM + 128KB SRAM, code section on ITCM, readwrite section on DTCM, SRAM is only for DMA buffer. So I can set SRAM region to non-cached in MPU so no need to Clean/Invalidate cache. |
a2dc16e
to
b18262d
Compare
Try change only I've no problem running high speed with my AMD Arch pc, could you try my compiled
I've a GL3520 hub who doesn't work in FS mode, no setup packet received after bus reset. But HS mode works ! |
@HiFiPhile with latest push the cdc_msc now work great, yeah !!! For analyzer, you are right about the cable, it only works with very short cable (0.3m length), while other 0.5-1m doesn't, even that those cables all work with other HS board such as lpc18xx. I guess same7x PHY is more peaky than lpc. Finally it works, though I go further to test with net lwip example, but it failed that one. Look like setup is still missing, it is probably overrun or race condition. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Superb work !! Thank you very much for your PR and effort to troubleshoot the issue with the PR. I have tested cdc_msc, hid_composite example both work greats. There is still issue with net_lwip_webserver and webusb examle, it is probably due to race condition and/or the missing setup etc ... Which we could definitely fix later with followup PRs. The race condition is more severe with HS since bus is much faster and so does the mcu.
PS: @HiFiPhile I am about to merge just now, do you have any pending code or thing that want to push.
I'll take a look of net_lwip_webserver if I can make a quick fix, otherwise we can come back later. |
It's simply because SAME70 need different EP for IN and OUT. Now WebUSB echo works but I can't see |
Ah thanks, I didn't notice that. Great, merge now, #975 will make it easier for cross-platform application to detect these requirement |
I managed to get tinyusb/CDC workin on a SAMS70, but had to adapt the code to |
Hi @fjgpereira ,
So with Harmony3 the register defines are different ?
In the DCD driver I haven't included cache clean/invalidate since it's configuration dependant. For example in my case I use DTCM/ITCM and set normal sram to non-cached. I can add a define to enable them when needed. |
maybe you could add an PR for cache, it is typically required on M7 mcu. I did something similar for rt10xx |
Hi, The include files i found on the Harmony3 project seem to have suffered a few changes, but for the most part the symbols are the same. In case it has any use, I placed a patch/diff file with the changes at [http://inocam.com/~fjp/dcd_samx7x_H3.diff] Regarding cache, everything looked to be working fine with ICache enabled and DCache disabled, but to enable DCache I did not investigate the reason why, but It was also necessary to add a __DSB() barrier |
I think it's better to add a on/off switch, also for dcd_transdimension. Clean/invalidate cache will cause hardfault in case of it is not enabled. How I edited your comment :D |
I didn't see any issue with rt10xx so far, I don't remember caching within stock example. If it is an issue on other MCU, it is better to detect if cached is enabled or not. Adding an macro is easy, but that config file is growing and already complicated to user (than I would like it to). @fjgpereira so Microchip has different naming for the Harmony than the asf4, that is a pain, though if there is a macro to detect which framework is used, we could have macro to pick up correct one. I am not familiar with Harmony, do you know if Microchip plan to replace existing asf4 entirely with it. |
Don't know about Microchip plans, but I looked into the include files supplied with XC32 compiler and found that it also uses the new naming conventions. I didn't check if there are any standard macros to detect the Microchip tools/versions, but as the registers pointer names are different, maybe you can use something like this: #ifdef USBHS_REGS and then add |
@hathach I think it's also possible to include register defines in tinyUSB, like dcd_transdimension. |
It is possible, but (transdimention) tdi is a bit extreme since all naming and register address and mapping is totally different between lpc and rt10xx. It is probably needed if we also bundle sam3u etc into the same dcd. However, it will depend on actual register naming/mapping from microchip. The naming here is not that bad, it seems only take an extra argument for some macros. Anyway, I would prefer to review actual code before making any decision at all. |
How did you configure the MPU regions ? |
I'm making changes in #985 . |
Actually most of the CPU initialization code and peripheral libraries is generated automatically by Harmony3 and I usually only look inside that code when I find some bug or hardware feature not implemented by the default code generated automatically, so I probably am not able to help. However, MPU is disabled in the Harmony3 graphical tool, but I didn't check if it applies any default configuration. Regarding that problem on dcd_evfent_setup_received(), I initially noticed that the TU_LOG2_VAR() debug messages were displaying wrong bmRequestType/direction bits on GetStatus requests. Then I noticed the problem did not happen when some log message was inserted after the memcpy(), that lead to conclude that any code that caused "delay" in that spot would solve the problem, so I guess it can be related to cache coherency issues. |
That's strange... so basically Harmony3 enable cache without prior MPU region configuration ? But by default the memory type of USB FIFO is 'Device Memory' so it's not cached... |
I think that is the default Harmony3 settings for new projects. When the MPU is enabled, it does offer a recommended configuration with 6 regions, ITCM, DTCM, SRAM, EBI_SMC, EBI_SRAM and QSPI, ranging from 0x0 to 0x8ffffffff, but I don't know what applies to 0xA0100000 without specifically defining another region. |
And that is why Harmony is not used |
So far I've found a few bugs in the auto-generated code, specially with unusual device configurations, but all in all, I think it has saved me a lot of time. However, I almost only use CPU and peripheral initialization code, avoiding other libraries and RTOS. |
I think it's ture for every MCU companion software I've used (STM32Cube, MCUXpresso, Simplicity studio, etc.) while pin tool is practical for PCB planning, their generated code is very pathetic. I always ended with direct register access. |
Sure you can save a lot of time, and if you're lucky you can have a good experience with it. But you run the risk of having a veeery bad time, it's just not reliable. |
I suspected that and decided to use just a minimal set of features. |
Describe the PR
Implementation of the SAM70 DCD driver.
Additional context
Tested with
cdc_dual_ports
,hid_composite
,uac2_headset
.TODO:
Any help is appreciated :)