374 Commits

Author SHA1 Message Date
mosu_195
a01c508c86 stop transmission when usb is suspended 2022-04-16 20:49:48 -04:00
mosu_195
5a90a192a1 Release resource on USB Resume callback
Needed for hcan->TxState to reset. In some cases when the host reboots, the TxState get locked forever and there's no way to recover other than resetting the controller.
2022-04-16 20:48:53 -04:00
mosu_195
d3c8d66aa5 Fix memory leak every time host restart
After the host reboots, the USBD_GS_CAN_Start function is called, In that
we take a pointer out of frame pool and never pushes it back, So every
time the host reboot, we leak a pointer one by one
2022-04-16 20:47:49 -04:00
fenugrec
0e1638b446 fix CI. Accidentally dropped a commit during merge 2022-03-09 11:44:41 -05:00
fenugrec
7f6418fe91 CI : build weekly instead of daily
Also rename artifact to contain build date
2022-03-09 10:30:56 -05:00
vondraussen
1149642d7f add binary download instr. to readme 2022-01-13 10:54:04 -05:00
vondraussen
0d77312544 CI: change make jobs to automatic
The github runner VM currently provides 2 cores with 7GB RAM, so we
should be fine with make -j to run unlimited parallel builds.
2022-01-13 10:54:04 -05:00
vondraussen
c03d01a2cb add matrix build for separate artifacts 2022-01-13 10:54:04 -05:00
Marc Kleine-Budde
2a1e2943d9 README: add link to Linux Automation candleLight 2022-01-13 09:28:02 +01:00
Marc Kleine-Budde
b549cb768b gs_usb.h: document GS_CAN_FEATURE_BT_CONST_EXT and GS_USB_BREQ_BT_CONST_EXT
Some CAN-FD capable controllers have different bittiming constants for
arbitration phase and data phase to reach maximum performance at
higher speeds.
2022-01-12 09:21:30 -05:00
Marc Kleine-Budde
fea8b8603f gs_usb.h: document GS_CAN_FEATURE_REQ_USB_QUIRK_LPC546XX
The documents a workaround for a NXP chip errata on LPC546xx
controllers (Errata sheet LPC546xx / USB.15).

According to the document corruption can occur when the following
conditions are met:
* A TX (IN) transfer happens after a RX (OUT) transfer.
* The RX (OUT) transfer length is 4 + N * 16 (N >= 0) bytes.

Even though the struct gs_host_frame has a size of 76 bytes for a FD
frame, which does not apply to the above rule, corruption could be
seen.

Adding a dummy byte to break the second condition also on transfer
lengths with 4 + N * 8 bytes reliably circumvents USB transfer data
corruption.

The firmware can now request this quirk by setting
GS_CAN_FEATURE_REQ_USB_QUIRK_LPC546XX.
2022-01-12 09:21:30 -05:00
Marc Kleine-Budde
41f9e7d64f gs_usb.h: introduce CAN-FD support
The CANtact FD and other devices implement a gs-usb compatible USB
protocol. The protocol has been extended to support CAN-FD and the
changes on the Linux gs_usb driver will be mainlined soon.

This patch adds the new GS_CAN_MODE_*, GS_CAN_FEATURE_*,
GS_USB_BREQ_DATA_BITTIMING, and GS_CAN_FLAG_* bits as well as struct
gs_host_frame_canfd to the candlelight driver.

This is mainly for documentation purpose, as the STM32F042 and
STM32F072 don't support CAN-FD. But there are some ports to CAN-FD
capable STM32 µC that can make use of these definitions.

[1] https://github.com/linklayer/gs_usb_fd/issues/2
2022-01-12 09:21:30 -05:00
Marc Kleine-Budde
335dc50cd6 gs_usb.h: document used GS_CAN_MODE_* bits
The bits in GS_CAN_MODE_ correspond to the bits in GS_CAN_FEATURE_*.
This means the bits 5 and 6 of GS_CAN_MODE_ are not "free", document
this by adding a comment to the corresponding GS_CAN_FEATURE_*.
2022-01-12 09:21:30 -05:00
fenugrec
6ac7632522 update README with github-actions build status 2022-01-08 19:55:58 -05:00
Marc Kleine-Budde
d89d414a3d main: clear frame->{flags,reserved} of Echo Frames before sending back to host
The Linux driver doesn't clear the flags (and reserved) value of the
struct gs_host_frame send to the device.

With the Echo Frame this value gets send back to Linux und might be
interpreted as a GS_CAN_FLAG_OVERFLOW Error Frame. Clear the flags
value before echoing back. While there clear the reserved value, too.

Since the following patch, Linux clears the flags value before sending it:

| https://lore.kernel.org/all/20220106002952.25883-1-brian.silverman@bluerivertech.com

This patch fixes https://github.com/candle-usb/candleLight_fw/issues/87
2022-01-08 19:47:28 -05:00
vondraussen
8c5a7d08e5 add github actions CI #84
remove travis ci, since Travis-CI is not a good place for opensource
projects anymore.
2022-01-08 09:22:04 -05:00
fenugrec
2df0d420e9 Simplify BOARD_XYZ macros (no more numeric values)
There is currently no reason to assign a numeric value to each BOARD_*
macro.
Fix #83 GH
2022-01-06 17:54:49 -05:00
fenugrec
f58de5e678 config.h : document CAN_S_PIN for silent mode
fix GH #81
2022-01-06 17:48:15 -05:00
fenugrec
1b1c3bb8ff usb RX_FIFO size: remove nonapplicable PMA comment
on F4 with the USB_OTG peripheral, the RX FIFO must be sized according
to different rules vs the USB_FS peripheral of the F0.
2022-01-06 17:42:50 -05:00
fenugrec
c189c45c78 CMake : HAL CMakeLists doesn't need hal_include.h
probably accidentally added with F4 support commit
2022-01-06 17:40:55 -05:00
fenugrec
6b451da2f0 CMake: clean up -mcpu=XYZ compile flags
also remove duplicate link options for F072 targets
2022-01-06 17:38:41 -05:00
fenugrec
2c4d046df5 LED : handle 32-bit tick overflow properly
32-bit milliseconds gives a 49.7-day wrap period which would break the
blinking patterns.

Fix GH #78, and hopefully makes the code cleaner / less error-prone.

Currently the sequence is specified with a uint8 but we still clamp
deltas to INT32_MAX in case the tick resolution ever changes.

Clamping the interval to INT32_MAX should ensure that for the
next (UINT32_MAX - 1) ticks, the macro SEQ_ISPASSED(now, wait_until)
produces the correct logic. Example :

now = 0
delta = INT32_MAX (7FFF....)
wait_until = now + delta = INT32_MAX (7FFF...

// 0 ticks later
(now - wait_until) == -7FFF FFFF ; SEQ_ISPASSED = false

// 1 tick later
(new_now - wait_until) == -7FFF FFFE  ; SEQ_ISPASSED = false

// 7FFF... ticks later
(new_now - wait_until) == 0; ok, now SEQ_ISPASSED is true

// new_now == UINT32_MAX - 1 == FFFF FFFE, almost rollover
(new_now - wait_until) == 7FFF FFFF ; ok, SEQ_ISPASSED is still true

// new_now == UINT32_MAX == FFFF FFFF,
(new_now - wait_until) == 8000 0000 == -7FFF FFFF; this fails because
the sign changed !
2022-01-06 12:54:41 -05:00
Ricky Lopez
d306798923 Add STM32F4 support
Specifically, the STM32F407VE.
Even more specifically, [this](https://stm32-base.org/boards/STM32F407VET6-STM32-F4VE-V2.0.html) dev board
2022-01-06 12:31:05 -05:00
fenugrec
e6b972441b Update USB stack to 1.11.2 (HAL + middleware)
Also remove some useless math/DSP headers.
The USB code really needed updating, considering the following entries from ST's
release notes (
https://raw.github.com/STMicroelectronics/STM32CubeF0/master/Release_Notes.html
) :

-Bug fix: USB_ReadPMA() and USB_WritePMA() by ensuring 16-bits access to
USB PMA memory
-Bug fix: correct USB RX count calculation
-Fix USB Bulk transfer double buffer mode
2021-04-25 19:43:55 -04:00
Brian Silverman
2225fc0290 Clean up the USB interrupt interactions
This might fix candle-usb/candleLight_fw#58. It definitely makes it
so I no longer observe similar behavior with multiple hosts running
gs_usb.
2021-04-25 19:11:29 -04:00
fenugrec
d66fda39f8 Add git version string to USB config descriptor
There was already provisions for this in the code. Tweaked CMake to
generate version.h automatically every build.
2021-04-06 12:03:13 -04:00
fenugrec
138e6cb433 Add basic assert checks
Avoid using <assert.h> because the standard assert() pulls in
fprintf and its of dependencies, as well as including __FILE__:__LINE__
strings for each assert() call. All this has an unacceptable memory
cost, as well as being useless since there is nothing to printf *to*.

Currently assert_basic() was added to check calloc() return values;
in case of failure we simply halt the core with BKPT(0). This could be
improved and refined.
2021-02-17 16:00:09 -05:00
John Whittington
1468b693a9 add Entree board to supported boards 2021-02-16 11:11:32 -05:00
John Whittington
05fe629e5c add user data section to linker scripts
This had probably been accidentally reverted in
2ebc665109887bfe95a4ad63ebe5e1d7d13c0fef ? flash_data_rom ended up on the same flash page as other unrelated data, which meant flash_flush() would've erased too much.

Also reduce nvm area to 1k and use variables to calculate area. (F042
devices only have 1kB pages vs 2k for the F072)
2021-02-16 11:08:11 -05:00
fenugrec
68df7d5448 README: add note about F042 limitations 2020-12-29 10:25:50 -05:00
fenugrec
3e556d9046 forgot to commit cmake/FindDFUSuffix.cmake 2020-12-13 10:41:07 -05:00
fenugrec
3d52db0a97 Add PR #63 comment, and __ISB() after disable_irq 2020-12-13 10:38:29 -05:00
fenugrec
031edba8ce README : more info about reflashing 2020-12-07 16:11:47 -05:00
fenugrec
9d00e884c7 cmake : forgot to specify ldscript to linker 2020-12-06 12:51:46 -05:00
Hubert Denkmair
b796282765 move USB descriptor callback table to ROM 2020-12-06 12:51:46 -05:00
Hubert Denkmair
b94a26f016 move all usb descriptors to ROM
copy to USBD_DescBuf when requested
(serving from ROM seemingly not supported?)
2020-12-06 12:51:46 -05:00
Hubert Denkmair
f380b5eafd rename USBD_StrDesc to USBD_DescBuf
(will reuse not only for strings)
2020-12-06 12:51:46 -05:00
Hubert Denkmair
c3efe48018 shink usb descriptor string buffer to save some RAM 2020-12-06 12:51:46 -05:00
Hubert Denkmair
e921aeac87 remove useless linker option 2020-12-06 12:51:46 -05:00
Hubert Denkmair
1712fecf5e enable link-time optimizations 2020-12-06 12:51:46 -05:00
Hubert Denkmair
643d64a9df fix uninitialized variable warning 2020-12-06 12:51:46 -05:00
Hubert Denkmair
0aa13404d8 since Reset_Handler is now part of the main executable, no need for a OBJECT library any more 2020-12-06 12:51:46 -05:00
Hubert Denkmair
b5cc61b331 fix critical section handling
thanks to @ndushman for pointing this out
2020-12-06 12:51:46 -05:00
Hubert Denkmair
39c3d0c52a remove old unused linker script 2020-12-06 12:51:46 -05:00
Hubert Denkmair
df9113fb6b set appropriate stack sizes 2020-12-06 12:51:46 -05:00
Hubert Denkmair
c88dc27653 call __initialize_hardware_early from reset handler for USB DFU handling 2020-12-06 12:51:46 -05:00
Hubert Denkmair
c6d180edaa add interrupt vetor table 2020-12-06 12:51:46 -05:00
Hubert Denkmair
338a0e22a0 add all header files to HAL cmake SOURCES 2020-12-06 12:51:46 -05:00
Hubert Denkmair
fef1d397b5 use startup files and linker scripts from LibreUCpp 2020-12-06 12:51:46 -05:00
Hubert Denkmair
d7332a3173 update LICENSE infos for STM32 USB library 2020-12-06 12:51:46 -05:00