Commit Graph

976 Commits

Author SHA1 Message Date
Kevin Redon 4f3a0356a4 minor: fix typo in comment
Change-Id: I3edb50abe93bc8574c9c1f25b34f75dab2e8f0ce
2018-09-06 22:48:11 +02:00
Kevin Redon 7d5d011095 minor: add checks on configurations and functions
these checks prevent out of bounds access and running
unset function pointers.

Change-Id: Ida889d40b898fc1ab8b885800431833570fdaafe
2018-09-06 22:47:01 +02:00
Kevin Redon 1dbcf62295 qmod: add LED user control
this is used during board testing

Change-Id: I4ccd787f6e307f523821725de158e3c6f1508ee2
2018-09-04 16:15:15 +02:00
Kevin Redon e5f891a825 EEPROM: fix Wformat compile warning
Change-Id: I86434a46a75f2acc30e20c33edab6dd3f87e052b
2018-09-04 13:31:26 +02:00
Kevin Redon a6bd7178b5 qmod: output EEPROM data only on debug level, and add completion output
the EEPROM byte output was causing data loss on the serial output,
resulting is automatic tests failing.
instead an end text will be output to detect the end of the procedure.

Change-Id: Ib8d3cbd01d0e34432d424355f4fafb24bc5273a1
2018-09-03 21:11:44 +02:00
Kevin Redon ba15387b09 DFU: fix Wformat compile warning
Change-Id: I8c422d8a709f8311c40d37e1f1f01dcd3a199b6f
2018-09-03 21:11:44 +02:00
Kevin Redon c171112994 stdio: fix detection of malformated format strings
the error code returned by vsnprintf was ignored,
resulting in printing the string from a previous print.

Change-Id: I8506b05d56da55d1357a1234917adf341b46e1db
2018-09-03 21:10:58 +02:00
Kevin Redon 29200c6223 stdio: add void 'l' format string qualifier
Wformat requires uint32_t to be used in format string with the 'l'
qualifier (l = long = at least 32 bits).
this qualifier was not handled before.
since on ARM 32-bit int == long we can simply ignore it (stdio
already does not support 64-bit data).

Change-Id: Ib506a66f68712c6b3eeb5129a39abf47ec86a2a7
2018-08-28 19:43:37 +02:00
Kevin Redon 80d9476602 UART: switch baud rate to 921600 bps
the higher baud rate allows for more debugging (without dropping
data) and is well supported by USB for UART adapters (this
standard baud rate is 8 x 115200).
the closest matching integer value is calculated for UART CR.
no floating point calculation can be used since this would
increase the size of the resulting binary by ~ 2kB (for the
softfp). this is not possible for the DFU since it already is
close to the maximum size of 16 kB.

Change-Id: I82b74f697342d580ccb79ada4715f35f4e8cca86
2018-08-28 19:19:10 +02:00
Kevin Redon e2b0f971e5 set main clock for using UART at 921600 bps
UART baud rate is main clock (MCK) divided by CR*16.
The MCK values are chosen >= 48 MHz and <= 64 MHz to have a near
integer value CR for a baud rate of 921600 bps.
The end MCK frequency between simtrace and qmod differ slightly
but are close to 58 MHz.

Change-Id: Iaa4a97fc68494c93b9d128503515d88049de506c
2018-08-28 19:13:13 +02:00
Harald Welte e07640c35a tag debian release 0.5.1
Change-Id: Id6559b1019353815eea9f6653b6560e9a8aab23a
2018-08-26 11:51:13 +02:00
Harald Welte 82b628524f simtrace2-sniff: Fix build with released libosmocore versions
There's still no released libosmocore defining the GSMTAP_TYPE_SIM
sub-types (Change-Id: I5bd0dff5a4a90cfe96d9c4f3dec6657e1d85bf7a
dated Jul 26, 2018).

Let's make sure users don't need an unreleased version of the library
if it's only about a few #defines that we can just copy here for
backwards compatibility.

Change-Id: I2fd9e14873711d60f194bb404420bbfbb0a00f48
2018-08-26 11:43:12 +02:00
Harald Welte cb78b55c26 Revert "debian/control: Depend on libosmocore >= 0.12.1"
This reverts commit 77ff745cca.

libosmocore 0.12.1 is not recent enough, I misread the 'gitk' output.

Change-Id: I87a8e5bbb4aea0c991abe5372f840d76f17378eb
2018-08-26 11:43:11 +02:00
Harald Welte 77ff745cca debian/control: Depend on libosmocore >= 0.12.1
Only this version includes the GSMTAP_SIM_ATR and GSMTAP_SIM_APDU
definitions.

Change-Id: I988cad56aed755af416fc7f23822dcf0229dbb7d
2018-08-26 10:52:46 +02:00
Harald Welte bd9d94994d v0.5 debian package release
Change-Id: Iaf56c03f966a5dfc8b750d926f0429223aeec54e
2018-08-26 10:37:39 +02:00
Harald Welte 95fac3aeab Add Debian packaging rules
Change-Id: Iece115e4dde87bff5dc36286668f50de0abdcb9e
2018-08-26 10:20:05 +02:00
Harald Welte c17bf77ecc owhw: Fix cardem GPIO initialization pointer value
This fixes a bug, identified by the below compiler warning:

libboard/owhw/source/owhw.c: In function 'cardsim_gpio_init':
libboard/owhw/source/owhw.c:39:16: warning: passing argument 1 of 'PIO_Configure' from incompatible pointer type [-Wincompatible-pointer-types]
  PIO_Configure(&pins_cardsim, ARRAY_SIZE(pins_cardsim));
                ^
In file included from ./atmel_softpack_libraries/libchip_sam3s/chip.h:45:0,
                 from libboard/owhw/source/owhw.c:20:
./atmel_softpack_libraries/libchip_sam3s/include/pio.h:189:16: note: expected 'const Pin * {aka const struct _Pin *}' but argument is of type 'const Pin (*)[2] {aka const struct _Pin (*)[2]}'
 extern uint8_t PIO_Configure( const Pin *list, uint32_t size ) ;
                ^~~~~~~~~~~~~

Change-Id: I4c1de66c0b8475bb355b1d128f6ec88b2f2a7fcf
2018-08-26 10:20:05 +02:00
Harald Welte c394109964 firmware: Enable -Wformat and resolve all related compiler warnings
There have been tons of format-string related bugs in our code which
we never discovered due to disabling -Wformat.  Let's fix that.

Change-Id: I5ec466361bcc526fac1f4897673264ee5af3458b
2018-08-26 10:20:05 +02:00
Harald Welte 888f196595 add master Makefile to build firmware and host tools
Change-Id: I715d3fdaff9d80673bb2208ea9d56637f4e459af
2018-08-26 10:20:02 +02:00
Harald Welte f7f61cd10f Makefiles: Add "make install" target
Change-Id: Ic6835ce55930c60f909e140878c4abab8628e077
2018-08-26 10:09:43 +02:00
Harald Welte 0e95f53588 host: Fix "make clean": remove simtrace2-sniff
Change-Id: Ib233b6a4b3976286196da95036cadcf2d3382f77
2018-08-26 09:54:55 +02:00
Kevin Redon 76ef811a4e jenkins: add simtrace/trace to the builds
trace is now stable enough on simtrace to be built and uploaded.

Change-Id: I157fff9930d03a7ec52ecac4a1be0511ea66c010
2018-08-07 19:01:25 +02:00
Kevin Redon fecfa2aa51 jenkins: clean after upload
the upload failed because after the firmware were built (make),
they where removed (make clean).
now they are removed only after the upload.

Change-Id: Ie4421a6fa9207eb541107de9c14f265626f6be96
2018-08-07 17:51:48 +02:00
Kevin Redon c428516efa qmod: error on EEPROM erase fail
repeating the EEPROM erase (byte write) in case of byte write failure
could lead in an infinite loop.
log the error an return error code instead.

Change-Id: Id6f3654d877ca772ba04237da91a6e86e3f441ec
2018-08-07 15:14:37 +00:00
Kevin Redon 37e7861c4d jenkins: fix publish
the script argument was not saved in the publish variable used later
to decide if publishing/uploading is needed.

Change-Id: Ic768a8e96e5e4d72acf3979da1412d683f79ec55
2018-08-07 12:09:49 +02:00
Kevin Redon ff3d84922d USB: increase USB reset time
USB reset can be signaled by pulling low USB D+ for at least 10 ms,
according to the USB specification. This force a re-enumeration.
This time is increased to 20 ms to work with more USB HUBs.

Some SAM3S based board have external D+ pull-up mechanism (such as
SIMtrace) which needs to be used to pull D+ low.
This is a legacy mechanism from SAM7S history.
This mechanism is not required anymore on the SAM3S, and the qmod
does not use it. When the USB HAL is suspended, the transceiver is
disabled, causing D+ and D- to be pulled low. Then the HAL is activated
again. This is particularly required when DFU is started (and
enumerated), and after flashing the SAM3S switched to the main
application (without reset), so it can properly re-enumerate.

This board difference is now defined on the board header.

Change-Id: I9b58d8101c2fcf5595026b675728826af26127a3
2018-08-07 12:09:49 +02:00
Harald Welte 9547e419eb qmod: Add 'e' command for erasing the EEPROM
Change-Id: Id7cb0db568dd3e9d796829bf0019d63048612998
2018-08-07 10:00:49 +00:00
Kevin Redon 8daba9cc9a gcc: fix warning
moving the define after the header fixes the following warning:
                 from ./atmel_softpack_libraries/libchip_sam3s/source/exceptions.c:46:
libcommon/include/stdio.h:63:12: warning: redundant redeclaration of 'printf_sync' [-Wredundant-decls]
 signed int printf_sync(const char *pFormat, ...);
            ^~~~~~~~~~~
./atmel_softpack_libraries/libchip_sam3s/source/exceptions.c:45:16: note: previous declaration of 'printf_sync' was here
 #define printf printf_sync
                ^~~~~~~~~~~
libcommon/include/stdio.h:51:12: note: in expansion of macro 'printf'
 signed int printf(const char *pFormat, ...);

Change-Id: I21a8de325e8f8b91297dd157f2d6a0f64434bb28
2018-08-06 16:23:33 +02:00
Kevin Redon d5f583da60 jenkins: add build uploads
firmware binaries should be uploaded to
https://ftp.osmocom.org/binaries/simtrace2/firmware/
this directory wiki be documented in the SIMtrace 2 wiki for users
to get the latest firmware images without having to cross-compile
themselves.

Change-Id: I589531f59e54a0997b012bdd91e3bef9f847f517
2018-08-06 15:57:43 +02:00
Kevin Redon 04ccb770fd remsim: fix USB hanging USB transfer
After a couple of seconds of USB data exchange between remsim and
cardem, the USB transfer hangs.
On host side (remsim) I can see the USB BULK IN request.
On device side (cardem) I see that data has been submitted and
"sent" over USB, but on wireshark with USBmon I don't see the
corresponding USB BULK IN response.
When exiting remsim or just after powering of qmod (causing an
error in remsim) the USB BULK IN is show in wireshark. Thus it
must have been in a buffer, but not read by libusb_bulk_transfer.
By shortening the timeout a new libusb_bulk_transfer is made more
frequently, and the data gets read successfully.

T;his change also fixes the URB data display.

Change-Id: I1d124a41cc90893506933f6d76dc7331e52a74f9
2018-08-04 11:16:15 +02:00
Kevin Redon 910e6830b9 cardem (minor): trace tx data send over USB
Change-Id: I69cef43dd5a78e9f82cc045cdb90c326b03d1f68
2018-08-04 11:16:15 +02:00
Kevin Redon 9cccb2bab5 add libosmcore utilities
osmo_hexdump is particularly useful.
previously it was only defined, but not implemented.
this cause random behaviour upon call, often resulting in
memory corruption.

Change-Id: Ifd9120fa951f41693903fb657d10826959f1599f
2018-08-04 11:16:15 +02:00
Kevin Redon 8a4fba5ea2 cardem: add state name in trace
this helps reading the output while debugging quite a lot

Change-Id: Idf301e09cf14e2412e29dcb252563bc6e4e5c630
2018-08-04 11:16:15 +02:00
Kevin Redon 1b39fd31ee cardem (minor): remove to verbose log trace
Change-Id: Ie43a33af3728c0700f71527ca75d909a9ebd2529
2018-08-04 11:16:15 +02:00
Kevin Redon 0f4abf5eaa cardem: minor typo fix in comment
Change-Id: Ib1dee95e15db1c6bb3b45920d7c1a567e2ba474b
2018-08-04 11:16:15 +02:00
Kevin Redon 1836ac0761 add synchronous UART transmission and use it in exceptions
The default ISR (particularly the HardFault handler) print information,
but this information was not displayed on the console because the UART
IRQ is lower than some default blocking IRQ.
Allowing to set synchronous transfer corrects this.

The underlying Atmel exception library had to be modified to use the
synchronous output.

Making UART_PutChar always synchronous when called from an ISR is not
desired because we use TRACE_ macros is some ISR. The synchronous
output must be set explicitly.

Change-Id: I1b4ace5185cf2dc32684934ed12bf6a8682e9bad
2018-08-04 11:16:13 +02:00
Kevin Redon dd36d9b010 sniff: send incomplete TPDU when reset is asserted
Change-Id: I8d7e4d604cded535e40d27c2be872268e0f24c20
2018-08-01 10:35:55 +02:00
Kevin Redon 8b8e58b00e cardem: use TC2 as WI and update WT after ATR
Change-Id: I3e51b16d557bc664f87563e1a3dce6642de474d2
2018-07-30 18:19:11 +02:00
Kevin Redon 8f70c3eb1f remsim: fix payload overwriting
The slot number is in the header, and correctly set in st_push_hdr.
Setting the slot in st_slot_tx_msg will overwrite the payload data.
This caused bytes three of the ATR to be changed from 0x96 to 0x00,
corrupting the ATR. This corruption is caught by the ATR checksum,
and the modem would reset the card (2 additional times) to try to
get correct ATR.

Change-Id: If971699993617fc50557d20582c344ea06645a3f
2018-07-30 15:03:55 +02:00
Kevin Redon ebe672e926 cardem: use TC_ETU to trigger ATR sending
this changes how ATR is handled.
the ATR is also printed when set (as important debug information).
the test is also updated to correspond to the new mechanism (
simulating the timeout before sending the ATR)

Change-Id: I69df797e2feadffa9f5f977cb71b69386cee7cd0
2018-07-30 15:02:35 +02:00
Kevin Redon d8ebd6ab77 cardem: increase watchdog to 2 seconds
a lot of the procedures are done in ISRs, but the watchdog is only
reset in the main loop.
this causes frequent reset, particularly at the beginning were
states have to the initialized.

Change-Id: Iad364444fca9d18f9a8cf47d5e0840ccd7bac2ef
2018-07-29 09:58:31 +02:00
Kevin Redon 738a04aefb cardem: show detailed reset cause
this helps detecting when a reset was due to the watchdog

Change-Id: I2d59c2f2c8fe9e559eddfafacf25879263ef81ff
2018-07-29 09:58:31 +02:00
Kevin Redon 2a44dc598d sniff: increase debug output
Change-Id: Ife0bbcf4a25aaa445a36768c00004e6e0d9a4947
2018-07-29 09:58:28 +02:00
Kevin Redon ec396bf402 sniff: fix ATR checksum calculation
this issue also cause the sent ATR to be empty

Change-Id: I6edff7aeb3185c835656acde75886fb6c90c0582
2018-07-28 20:59:44 +02:00
Kevin Redon 697199676e sniff: ensure the checksum error flag is also printed
the firmware now also use a generic value_string array (as does the
host application)

Change-Id: I861bd8b52e8f2f2a4786bbe1cc834917119dc394
2018-07-28 20:59:41 +02:00
Kevin Redon 8e84f8125c sniff: rename reset hold/release to assert/deassert
this change is to match the nomenclature used in cardem

Change-Id: Ide99e731cad26aec949ad14d54f46fa611a0b7f8
2018-07-26 15:34:08 +02:00
Kevin Redon d1c6536154 sniff: send ATR over GSMTAP
Change-Id: Id35129883f08002a4a796b56954a128e2b533245
2018-07-26 14:51:15 +02:00
Kevin Redon 352809992c USB: print decoded USB error
In case of error it also ensures the returned value is NULL.
Else a segfault would occur because the caller (e.g. remsim)
continued on with a free handler.

Change-Id: Ie7f20e3eff03acf77eb08283747ca8e032b9b4c8
2018-07-24 09:57:23 +02:00
Kevin Redon a71a6f48cb I2C: return error after failed write
The previous mechanism of retrying a failed write could become a
infinite blocking loop (until watchdog tiemout).

Also the array size is used to know how much data to write and verify
instead of a constant.

Change-Id: I8d2d090c5f4d1195f4c7eb29b3958a7bb05f56ec
2018-07-24 09:54:18 +02:00
Kevin Redon 57b60d23cf I2C: add wait time after write to let EEPROM write
The Atmel AT24C02 defines a maximum tWR waiting time after a byte
write of 5 ms before a next write.
Enforcing this wait time also fixed the failed verification in qmod,
where it was reading 0xffff instead of the written value.

Change-Id: I42c90b8d0329e425f275067e87d584212a43a90b
2018-07-24 09:49:18 +02:00