Commit Graph

287 Commits

Author SHA1 Message Date
Sylvain Munaut d108dfb9af icE1usb fw: Fix computation of received E1 frames from USB
Several issues :

 - The reported length includes the CRC so it's minus 6 and
   not minus 4. (2 for CRC, 4 for header)

 - Cast length to int to make it signed so the minus works

 - If the packet is empty, this would be negative (no header),
   underflow, and then try to submit a giant number of frames
   to the E1 hardware

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Ib754e460290fe2e1551a0090e30a51846131d07d
2022-01-09 17:21:04 +01:00
Sylvain Munaut ff44f147f6 icE1usb fw: Use the interface/endpoints #define in usb_e1.c
Avoid hardcoded ids everywhere. This also prepares a bit for
multi-port support in the future.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I89c86ac6afd52dd19e3383b38c3311276a090d50
2022-01-09 17:21:04 +01:00
Sylvain Munaut 0f40ee0e52 icE1usb fw: Vendor requests to other interface than 0 are not errors
They might be used somewhere else ... just don't handle them, but
let someone else potentially do it.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Ie1bce4565d14d6635d4a32c2a08f64728132a75e
2022-01-09 17:21:04 +01:00
Sylvain Munaut 0749d576d3 icE1usb fw: Remove useless variable in main loop
Left over from early testing code ...

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I242bbcd42ba96f56bf12bbe57537f3a72a44767b
2022-01-09 17:21:04 +01:00
Sylvain Munaut 2c0c136b7a icE1usb fw: Misc cosmetic cleanup in e1.{c,h} / usb_e1.c
Moving things around, comments, spacing, ... nothing functional.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Icc2a6ef6b03c89dd92e661a01d219e42dbf7067d
2022-01-09 17:21:04 +01:00
Sylvain Munaut 35856a1d61 icE1usb fw: Don't expose some E1 helper functions globally
Not used anywhere and really shouldn't be

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I1e339d1b8faecffba5f8d73588b376edc7a75a96
2022-01-09 17:21:04 +01:00
Sylvain Munaut 8a5a9d4dfb icE1usb fw: Use #define's in descriptors for interface/endpoints ID
This way they can be used in other parts of the code more easily.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I565d9a43bc26b99bc385b46522e7da6a207b2412
2022-01-09 17:21:04 +01:00
Sylvain Munaut 3c3ae79241 icE1usb fw: Set wDetachTimeout to 0 in DFU descriptor
It was pointed out that this should be 0 since we trigger
detach ourselves, we don't need a bus reset.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Id7051ce00863c03e3498f4bab0a7124938e197c0
2022-01-09 17:21:04 +01:00
Sylvain Munaut 9674436e2a icE1usb fw: Cleanup USB code a bit
Some of it was written before some of the helpers were provided
by the no2usb code and was never update. So instead of manually
setting up a bunch of stuff we make proper use of some of the provided
helpers.

Side effects:

 - We recall e1_init(0,0) when enabling which happens to work
   around a bug ... proper fix coming later.

 - The 'dual BD' config for EP 0x81 and 0x83 is fixed. It didn't
   matter before since we overwrote it anyway, but now it's used
   and so needs to be correct.

 - The descriptors don't have the isoc endpoints at all in the
   "OFF" alt setting.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I33c92896acfba023abe0152d63dff3afe43b53cd
2022-01-09 17:21:04 +01:00
Sylvain Munaut 7cfe017047 common fw: Add a 'panic' handler
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Ice3f338abfe3d361da875c3233b8a052bd6aa2c2
2022-01-09 17:21:04 +01:00
Sylvain Munaut 4d9aea44ef gateware/cores: Update USB core
Mostly to get firmware code improvement and fixes

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Ifacacd15f989aa51c04433cfb0bdaee7f848b658
2022-01-05 22:14:47 +01:00
Harald Welte 51baa368ce icE1usb firmware: Detect A-bit in TS0; report via USB + LED
Scan over every odd E1 frame TS0 byte to check if the A-bit is set,
indicating a remote alarm.  If so, set yellow LED and report via the
error flags communicated to the host by USB interrupt transfer.

Change-Id: Ic4f57cf79bd32cf75f81ef3073cb8d4a2d1857d8
2022-01-02 12:42:35 +01:00
Sylvain Munaut d376b2e852 fw/ice40-riscv: Remove usb_ep_boot manual declaration
It's now properly declared in the stack header

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Id2fd50c04a8d8781ad8b94e12ba9f469777482d1
2021-05-31 19:22:22 +02:00
Sylvain Munaut b9d9363d91 fw/icE1usb: Adapt the CDC descriptors to new structure from no2usb
Those are actually disabled right now, but since the submodule got
updated and the protocol struct/defines changed, this updates them
anyway so you can uncommend/enable them without causing a build
failure

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I1895702eac9c6c392f24327b12f9ba3651e3249a
2021-05-31 14:03:44 +02:00
Sylvain Munaut 348f425936 gateware: Update submodules
Not much change in e1, just a typo fix that just triggered a warning.
In usb the only relevant change is a fix in the stack code that caused
GET_INTERFACE to fail for interfaces without alt-settings

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Idfe712f7a2173e5c5f9552f35136f1d732098139
2021-05-31 14:01:39 +02:00
Harald Welte 20408d3ec0 contrib/jenkins.sh: Switch from rita -> ftp.osmocom.org
We should use service-aliases and not the primary host name, as
that makes migration between machines hard.

Change-Id: Idd49f27c9b08c6cfd077f85276a3dedc4cf117ef
2021-04-22 11:23:43 +02:00
Harald Welte b279fc3542 manual: typo fix
Change-Id: I86b682b2b4bf6415b59558b00fba1288d7db3b50
2021-03-30 15:40:13 +02:00
Harald Welte 9e2e948565 manual: Add link to DAHDI driver
Change-Id: I96c7b43fe0112c66391df8f4867c2eb60cf3005f
2021-03-30 15:40:13 +02:00
Harald Welte 0b7f8347ef maunal: update firmware filenaming
In Change-Id I319edb76dd74be6904395692ab1599fb8f1f9065 we had
changed the file naming of the firmware binaries from the somewhat
general fw_app*.bin format to icE1usb-fw*.bin, but the manual
was not updated accordingly.

Change-Id: I0cc2cd3f3f8f166b9409463fbd4b01e344cfe399
2021-03-30 15:29:04 +02:00
Harald Welte 6c8858b5db manual: clarify download locations
Change-Id: Ibfeff7cc964445565b0ba08580532fc4baf97dbf
2021-03-30 15:29:04 +02:00
Harald Welte 6101b1b938 manual: Fix USB ProductID swap between bootloader and application
Change-Id: I7adf31cb731f34834bb859f667e5edf51964ad32
2021-03-30 15:22:59 +02:00
Oliver Smith 5329dc976b Revert "contrib/jenkins.sh: ugly work-around for PATH problems"
Revert, because we don't overwrite PATH anymore. This reverts commit
5ab3bfdba4.

Related: OS#4911
Change-Id: I981511f406b80b80e2a863c94b6a60755d824fec
2021-01-13 17:08:21 +01:00
Oliver Smith d7c51ad692 contrib/jenkins: don't build osmo-gsm-manuals
Related: OS#4912
Change-Id: Ie2f193656386038872adddfbd770ea193ace92e5
2021-01-13 13:18:46 +01:00
Oliver Smith d37ed5339c doc/manuals/Makefile: fix typo in 'srcdir'
Prevent the following error (generating manuals seemed to work fine
regardless):
	realpath: missing operand
	Try 'realpath --help' for more information.
	make: Nothing to be done for 'all'.

Change-Id: I72a62b86cba0dfd710f7e1c4c01a3c10710128d8
2021-01-13 10:54:04 +01:00
Oliver Smith c121ca69ff gitignore: add files from generating manuals
Change-Id: Ibd0089978a7083fb19638d70358c8ef7d589da9c
2021-01-13 10:54:03 +01:00
Oliver Smith dac64990c6 doc/manuals: support OSMO_GSM_MANUALS_DIR
Instead of only relying on pkg-config, support the environment variable
and fallback path like in other Osmocom repositories too. The same
script is used in other Osmocom repositories where manuals are built
without autotools.

Related: OS#4912
Change-Id: Iecfbfc2a7588c316642aa37be637cf3c02f76ac4
2021-01-13 10:54:01 +01:00
Harald Welte 9e7a21ae58 osmo_e1f: Allow to transmit AIS
AIS is an all-1 bit-pattern which is used by intermediate equipment
to indicate that the link somewhere upstream is lost.

Change-Id: Icc5a16ee44ecebe802c4cca0b6cc763a88b6cc05
2021-01-05 23:25:38 +01:00
Harald Welte e6b0fe8377 icE1usb fw: un-configure E1 when altsetting 0 is selected.
So far we started on altsetting 0->1 transition, but we didn't stop
on the inverse 1->0 which typically happens when the host software
(osmo-e1d) stops.

Closes: OS#4676
Change-Id: I8e4817f68d8893ab2dc98fe93ce9a673e209ca63
2021-01-05 23:25:38 +01:00
Harald Welte 805f2cf16e icE1usb fw: Expose error conditions from E1 driver
This will allow the USB interface code to report the errors to the
host PC.

Related: OS#4674
Change-Id: Iba3e00a2b28a2fef6dbd986bfc706c1619c3a3ed
2021-01-05 23:25:34 +01:00
Harald Welte 9469e046f1 icE1usb fw: USB control request handling
This introduces a number of vendor-specific control requests for
configuration of the icE1usb from the host software.

Closes: OS#4675
Change-Id: I9d28566ba21a2a78def5e4a0ba07ecbc4a583aa9
2021-01-05 23:24:32 +01:00
Harald Welte 6add0aa3e4 icE1usb fw: Internal API for configuring E1 rx/tx config register
Related: OS#4675
Change-Id: Ib23f9b99f169ab18d730bcf67b97a7b6bf863e98
2021-01-05 23:24:28 +01:00
Harald Welte 7f74fe6e48 icE1usb fw: Don't store E1_*_CR_*_CLR in variables
Those clear bits are only set once at start-up and then later
explicitly.  They shouldn't be stored with the user configuration
in state variables.

Change-Id: If38e86aefea7f1be4e1ff5a88860f8be593eeedc
2020-12-27 15:16:19 +01:00
Harald Welte f74dad7b60 icE1usb fw: Put E1 IP core register related #defines in e1_hw.h
Related: OS#4675
Change-Id: I6783f473e6bb7dd08a5b5714bdd9b5aac0f28f0d
2020-12-27 14:09:02 +01:00
Martin Schramm 1e204b738c e1-tracer: update BOM attributes to 1st v2 prod run parts
* L2, L3 now 0805
* R6, R7 now 0402
* IC4 now ASEMB-12.000MHZ-LC-T
* RoHS state enabled again in scraper, not yet used in BOM

Change-Id: I4f1a82476ca84552efd71a47231e8b6ac02a3358
2020-12-27 13:01:44 +00:00
Harald Welte 5276567b24 icE1usb fw: Use green per-port LED to indicate alignment status
Whenever Rx is aligned, the green LED is permanently on.
Whenever Rx is not aligned, the green LED is blinking.

What's missing is to check for E1 clock ticks and turn the LED off
completely if there are no clock ticks.

Change-Id: I42d53544858dbbbae5206d9a62b08672966c9ebf
2020-12-20 23:20:21 +00:00
Harald Welte 2df1f805a6 icE1usb fw: Include E1 frame number in Rx USB header
This should enable the host to detect discontinuities, and also know
when a multiframe starts.

Related: OS#4674
Change-Id: Ie0688647c56ebfc2e08de44f8ec569e1c2cd6a28
2020-12-20 23:20:21 +00:00
Harald Welte daff4f6463 icE1usb fw: Have e1_rx_need_data() optionally return FIFO position
The position indicates where we are in terms of frame and multiframe.

The related code was ported over from e1-tracer.

Related: OS#4674
Change-Id: I9e59d86a2e8f4e85ca84c592438ad79966b49448
2020-12-20 23:20:21 +00:00
Harald Welte 175b37c42f icE1usb fw: Use register bit #define instead of magic number
Change-Id: Ic824ce5a6605c96989fefbf92f365bff618dccb2
2020-12-20 23:20:21 +00:00
Harald Welte a59ef2bb3f icE1usb fw: define e1_data_ptr() using e1_data_ofs()
It's best to compute the offset only at one place and use that
computation elsewhere.

Change-Id: I9a6cce07ea8b6eff1527215de00621da960b0472
2020-12-20 23:20:21 +00:00
Harald Welte 30fc560017 icE1usb fw: cosmetic: more comments in the code
Change-Id: I445bb2f92b6dcfe29ac20109ea2e63efb31051a1
2020-12-20 23:20:21 +00:00
Harald Welte 6360c07d91 osmo_e1f: Fix inverted logic of E bits
A value of '1' means _no_ CRC4 error observed. We got that right
in the receive side, but not in the transmit side so far

Change-Id: I5ef9ef3b9781da2f53f54253d31cdbf81957ea67
2020-12-19 12:34:40 +01:00
Harald Welte d9a8f9a07c osmo_e1f.c: Fix CRC4 insertion
When encoding the CRC bit for Frame number 0 and 8 in the multiframe,
we must first move the CRC4 into those of the last SMF.

Change-Id: I088741fc4528f33b3b989ada0e21957456deedb6
2020-12-19 12:08:17 +01:00
Harald Welte 2e7284b5be osmo_e1f: Fix use of uninitized variable
Change-Id: I42024856a58f0bd4fcc1c767688de5334994a8a8
2020-12-19 12:08:17 +01:00
Harald Welte 61a23eaf5d osmo_e1f.c: sa4..sa8 bits should be all-1 by default
From ITU-T G.704 Table 5A Note 4:

> Bits S a4 to S a8 (where these are not used) should be set to 1 on
> links crossing an international border.

Change-Id: Id55599a7152a90f85076de810db2a03ac6f3aac1
2020-12-19 12:08:17 +01:00
Harald Welte 5a45005847 osmo-e1-hardware: Fix missing PKG_CONFIG_PATH directory
otherwise we'll get:

make: Entering directory '/build/doc/manuals'
Package osmo-gsm-manuals was not found in the pkg-config search path.
Perhaps you should add the directory containing `osmo-gsm-manuals.pc'
to the PKG_CONFIG_PATH environment variable
No package 'osmo-gsm-manuals' found

Change-Id: I9f3d6e74be9e0fe31a2ee7aad9869ed7568ff6dd
2020-12-17 17:53:31 +01:00
Harald Welte 5ab3bfdba4 contrib/jenkins.sh: ugly work-around for PATH problems
For details see https://osmocom.org/issues/4911

Related: OS#4911
Change-Id: I04e9c29813f6695d0d53f7cdede34f83d24ea3fd
2020-12-17 17:44:07 +01:00
Harald Welte a624ef80d7 contrib/jenkins.sh 'publish' fixes
* don't install icE1usb files to e1-tracer directory
* don't replicate symlinks but copy

Change-Id: I6dff99dcc2ab465558ad6344ebb9cba73005cf34
2020-12-17 17:19:09 +01:00
Harald Welte a878ac8c33 add missing icE1usb-usermanual-docinfo.xml
This was missing in commit Ia04890cf3b321f8cb01e3c513a730031e76376b9

Change-Id: I4b20c38bf6ad87307c86e594cc23330d11b6303f
2020-12-17 17:19:09 +01:00
Harald Welte e7bccbac8b add contrib/jenkins.sh for build verification + manual / firmware upload
Change-Id: I70d7de4299e773b38a014e4884641712edbd45c3
2020-12-17 13:41:15 +01:00
Harald Welte 3255b74187 firmware: Build firmware files with auto-generated version numbers
This resembles what we do for other firmware targets, such as simtrace2,
osmo-ccid-firmware, etc.

As we have multiple different firmware, hardware, gateware projects in
this repository, and they each may have separate tags, we now require
that there are project specific tags.  So for example, tags with a
prefix of icE1usb-fw for the firmware versions.

symlinks for easy use by scripts etc. are generated, always pointing to
the last-built versioned filename.

Change-Id: Ia308587e36a79c27fdb285e369a9c921ee65995f
2020-12-17 13:20:51 +01:00