Commit Graph

550 Commits

Author SHA1 Message Date
Denis 'GNUtoo' Carikli dc2983d907 firmware: Makefiles: enable changing toolchain
Without that the user was expected to either patch
the Makefiles or to get a toolchain with the arm-elf-

Change-Id: I0c362cde7afd6de025e8fe2c1e9abe3d3a1e04a6
Signed-off-by: Denis 'GNUtoo' Carikli <>
2017-10-05 09:27:29 +08:00
Harald Welte 5176342acf add
Change-Id: Ib2c4fc8b20812f698c75041f75cd0076f5354af2
2017-03-17 22:20:06 +01:00
Harald Welte 373c172ab8 convert from u_int*_t to uint*_t
Change-Id: I33f6383535c5860b833f7ccb9bea122d38f28e3f
2017-03-17 22:20:04 +01:00
Harald Welte 5a40e2fed1 Merge branch 'minxu-fixes' 2014-11-11 22:31:27 +01:00
Min Xu b6caca4b64 improve handling of spurious IRQs
rather than printing directly from the interrupt handler, just increment
the number and print it from the main loop function instead.
2014-11-11 22:30:55 +01:00
Min Xu 478c2332b7 Allow some USB interrupts to be handled during dbgu_append 2014-11-11 22:30:55 +01:00
Min Xu 8701086cac Retrieve + print previous PC from stack to debug wdog/spurious IRQ
Retrive previous PC from the stack before entering specific interrupt
handler routines.  Allow user to trace where interrupt occured: e.g.
WatchDog and Spurious interrupt

Prior to this change, spurious interrupt would occur so much (observed
via gdb/remote debug) so it appears that the board stalled.  Once a
custom spurious interrupt installed, the code continues after the
interrupt instead of re-entering the interrupt.
2014-11-11 22:30:55 +01:00
Min Xu 6bafd0cfb4 Don't split req_ctx with ATR payload
The codnition for flushing a req_ctx on UART idle is fixed to flush only
1) There has been no new data since last check, and
2) There are no req_ctx currently pending to be transmitted to USB, and
3) We did NOT just got a reset and waiting for ATR

I saw an ATR split in two different req_ctx prior, presumably flush
decided to send req_ctx after ATR but got a new character just before
sent).  If we did get a RESET, let original logic decide to send the
req_ctx -- presumably when ATR data is fully received.
2014-11-11 22:30:55 +01:00
Min Xu 7e3c9959e1 iso_uart: Print more errors, not just overruns 2014-11-11 22:30:54 +01:00
Min Xu 9662f2830a change number + qty of small/large req_ctx 2014-11-11 22:30:54 +01:00
Min Xu 4b98ba5d1c pcd_enumerate: More complete USB endpoint resetting 2014-11-11 22:30:54 +01:00
Min Xu 3cd467a8ef req_ctx: Keep statistic about number of req_ctx in given state
... and print this from a debug statement.
2014-11-11 22:30:54 +01:00
Min Xu ab325fc295 Ensure to transmit current req_ctx on RESET/VCC events
When any of the following events occur:
* nRST

we tranmsit the current req_ctx, if there is data pending.

This ensures that for any successive data, the ATR flag in the next
req_ctx containing the data, not in the previous req_ctx.  It also
ensures that the ATR is aligned at 0 offset in the new req_ctx, which is
an assumption the host software makes but the previous code didn't

Furthermore, we introduce a periodic flushing of any pending but
incomplete req_ctx.
2014-11-11 22:30:54 +01:00
Min Xu 9bd1b003a6 iso7816_uart.h: add missing #ifdef/endif to avoid multiple inclusion 2014-11-11 22:30:54 +01:00
Min Xu 04403a7c8b usbcmd_generic: Add missing \r to DEBUGP() 2014-11-11 22:30:54 +01:00
Min Xu 82cb631bf9 watchdog: print watchdog expiration even in non-debug builds 2014-11-11 22:30:54 +01:00
Min Xu e39637e1b8 pcd_enumerate: Avoid disabling interrupt during endpoint refill
The old implementation has a big local_irq_save() / restore() around the
endpoint re-fill routine.  This disables interrupts for a long time,
psossibly causing lost interrupts.

The new implementation works around this by disabling the USB (UDP)
interrupt only, rather than disabling all interrupts on the system.
2014-11-11 22:30:54 +01:00
Min Xu 7fcc62940d simtrace: Add heartbeat message to debug console 2014-11-11 22:30:54 +01:00
Min Xu ca4e80551b dbgu: make debug routines re-entrant 2014-11-11 22:30:54 +01:00
Min Xu ec975220d0 req_ctx: Change number of small / large req_ctx 2014-11-11 22:30:54 +01:00
Min Xu b6b2c7d482 req_ctx: avoid loop iterations by introducing per-state queues
In order to speed up the lookup of req_ctx, we keep per-state queues
rather than iterating over all the request contexts that exist again and
2014-11-11 22:30:54 +01:00
Min Xu 40def0ab1a change req_ctx sizes large 2048->1000; small 128->270 2014-11-11 22:30:53 +01:00
Min Xu 3b7035dcd9 req_ctx: Use consistent numeric range for REQ_CTX_STATE
... which will allow us to check for invalid states by a simple
'greater than' check later on.
2014-11-11 22:30:53 +01:00
Harald Welte 3c85f8de8d update main_factory to write version 1,4,0 instead of 1,3,0 to OTP 2014-11-11 22:26:45 +01:00
Harald Welte bb28e090cd simtrace: main_factory: Program OTP area with simtrace version 2013-11-17 20:13:13 +01:00
Harald Welte 54c248f97a simtrace: Add OTP data containing production data 2013-11-17 20:12:58 +01:00
Harald Welte 1e8df4869c spi_flash: add code for OTP read/write 2013-11-17 20:12:39 +01:00
Harald Welte 6ea973b79e iso7816_uart: Make sure ATR is separated from normal APDU in all cases
Prior to this patch, the ATR was not send in a separate USB message for
cards that are T=0 only.
2012-05-18 21:52:32 +02:00
Harald Welte 5aae62cb7b 7816_uart: add comment about f/d calculation 2012-05-18 08:41:08 +02:00
Holger Freyther f0fb308984 eabi: Remove EABI functions to fix building with EABI toolchains
These symbols are not referenced on an arm-elf gcc 4.7, they are
used when building with an arm-eabi gcc 4.7 and then cause linking
issues. The linking to libgcc can not be omitted as the irq code is
using ffs. Remove the EABI symbols. The alternative would be to
declare the EABI as weak inside the lib1funcs.

Link error:
multiple definition of `__udivsi3'
multiple definition of `__aeabi_uidiv'

Exported symbols:
nm lib/lib1funcs.o
00000000 t Ldiv0
00000010 T __div0
2012-04-08 10:01:04 +02:00
Harald Welte 868b6d0c68 simtrace: introduce statistics
the statistics count various events like overruns, parity errors,
missing rctx and can dump those stats via USB as well as on the serial
2012-03-23 00:03:45 +01:00
Harald Welte 4c0cf591b0 wdt: make sure WDT doesn't fire inadvertently
We have to set WDD and WDV to the same value to avoid watchdog errors
2012-03-22 23:33:07 +01:00
Harald Welte 4086f4cf46 simtrace: implement SIM power switching API
there is now a high-level command by which we can swithc the VCC
supply of the SIM cards.

For some reason, the _PASS variant (passing through the voltage from the
phone) doesn't seem to work reliably.  It might be that we are draining
reverse current throught the LDO once we supply SIM power that way.
2012-03-22 22:55:14 +01:00
Harald Welte 559fc68583 make VCC / card detect more reliable 2012-03-22 15:20:54 +01:00
Harald Welte 94143382bf disable logging of PIO status in PIO interrupt routine 2012-03-22 15:03:10 +01:00
Harald Welte 4f7ca20bf4 simtrace: Inform host of Fi/Di values (and flag change due to PPS) 2012-02-12 15:34:41 +01:00
Sylvain Munaut f233812722 simtrace: 7816 UART: Add missing entry in Di table
Add missing entry in Fi_table. It's apparently used as '64' in some
reader and 'unsupported' in some other. For simtrace I guess we should
consider it 64.
2012-01-26 00:53:15 +01:00
Kevin Redon 2a3d3624be Make sure we don't forward power _and_ supply SIM power at the same time
The FPF2005 has no reverse voltage blocker, this is why the 3.3V from
the LDO flows back into VCC_PHONE. It even damages the chip (so says the
datasheet) I corrected the double power source problem by disabling the
LDO (see patch), but still 1.8V does not work and 3.0-3.3V is used. I
have to look for other reasons.
2011-12-18 08:35:20 +01:00
Holger Hans Peter Freyther ebf16b4ddf usb: Do not send ZLP when we have filled the window
Only send the ZLP if we send less data than was required/asked for
by the host and it is a multiple of the bMaxPacketSize0 (which is
hardcoded to 8 right now).

This is completing the change done in fe88b83e80 to
fix SIMtrace attached to OSX and not regress on windows.

Introduce another parameter to udp_ep0_send_data to specify the window
size (wLength) or if not available the default from USB 2.0 specification.
2011-12-14 15:16:54 +01:00
Holger Hans Peter Freyther ebc2088382 dfu: Remove unused variable, mark method as not retuning 2011-11-10 07:33:56 +01:00
Holger Hans Peter Freyther 7db9f66c8b dfu: Use {} for possible empty if statement (in case debug is off)
src/dfu/dfu.c:853:23: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body]
2011-11-10 07:33:55 +01:00
Holger Hans Peter Freyther 1532eb49f4 dfu: Mark unsued variables as __unused for now 2011-11-10 07:33:55 +01:00
Holger Hans Peter Freyther c6f26629d2 dfu: udp_ep0_recv_clean is static and is not called anywhere 2011-11-10 07:33:53 +01:00
Holger Hans Peter Freyther 7ab4135217 dfu: The i variable to disable interrupts shadows the outer index
In case ram_app_entry() returns do not reset i to 32, otherwise we
will never reset the watchdog.

src/dfu/dfu.c:1077:7: warning: declaration of ‘i’ shadows a previous local [-Wshadow]
src/dfu/dfu.c:1068:6: warning: shadowed declaration is here [-Wshadow]
2011-11-10 07:33:53 +01:00
Bjoern Kerler 3d60f2e042 fix linking issue with latest binutils versions 2011-10-21 20:02:12 +02:00
Bjoern Kerler 427688677e Fix fi/di calculation for certain mobiles like GT-S770 or HTC Raphael
There were some mistakes while copying the tables from ISO 7816-3,
and also a quite old version of 7816-3 was used.
2011-10-21 20:01:01 +02:00
Harald Welte 4b27294faf Update TODO file 2011-08-16 11:49:22 +02:00
Harald Welte 9dbedc6587 SIMTRACE: ISO7816: Deal with ATR that don't have historical bytes
In case there are no historical bytes, we immediately transition from
the last TD byte into the WAIT_TCK or WAIT_APDU state.
2011-08-16 10:22:01 +02:00
Harald Welte d9930d60aa ISO7816: Properly handle T=0 only cards without TCK in ATR 2011-08-16 10:10:39 +02:00
Harald Welte fa7297b93f SIMTRACE UART: Reset error status on error related IRQ
This prevents an IRQ-flood after a parity or overrun error, which
in turn would cause a watchdog reset.
2011-08-15 22:59:24 +02:00