Commit graph

1184 commits

Author SHA1 Message Date
Michael Hope 715a63dccb Re-work the constraints on delay_us(). Ask GCC to allocate a register
instead of forcing r0.  Use the same operand as input and output to
remove the move.

Signed-off-by: Michael Hope <michael.hope@linaro.org>
2012-08-22 13:02:58 -04:00
Marti Bolivar 10a1763caa Merge branch 'reset-script'
Weed out non-Maple ttyACMs on Linux.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-22 12:50:25 -04:00
Marti Bolivar c98111eb25 reset.py: Not every Unix is Linux.
Move the sysfs tests for Maple out of unix_get_maple_path() and into a
new linux_get_maple_path(). This prevents unnecessary probing for a
nonexistent /sys on e.g. OS X.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-22 12:48:37 -04:00
David Kiliani 74266c88d6 Improve Maple device detection in reset.py on Linux
Adds a function to lookup the USB vendor & product id from
the udev info in the sysfs tree. This removes invalid choices
and reduces user queries for the correct ttyACM device.

Signed-off-by: David Kiliani <mail@davidkiliani.de>
2012-08-22 16:24:32 +02:00
Marti Bolivar 82500d7813 reset.py fixups for OS X 10.8.
As discussed on this forum thread:

http://forums.leaflabs.com/topic.php?id=2451

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-20 17:06:34 -04:00
Marti Bolivar a3a49c3ea9 Make PRIMASK set/clear functions __always_inline.
This is just to ensure that -Os doesn't prevent these from getting
inlined.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-14 11:35:01 -04:00
Marti Bolivar c3a8dfd1ca wirish/ext_interrupts.h: Doxygen
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-14 11:32:47 -04:00
Marti Bolivar f2aaed8818 stm32loader.py: replace obsolete exception catch syntax.
For Python 3 support.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-10 17:20:39 -04:00
Marti Bolivar 13935e4ac7 Makefile: Don't assume Cortex M3.
Instead, derive -march and -mcpu from the target MCU in
target-config.mk. Also (on STM32F4) add the necessary floating point
flags. The CodeSourcery toolchains don't support these, so we'll need
to prepare alternative toolchains when F4 support is official.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-05 14:40:03 -04:00
Marti Bolivar 51699a1991 fixup! Add support for ARM's GCC ARM embedded toolchain.
Oops.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-05 14:17:06 -04:00
Marti Bolivar 2424108a14 Add support for ARM's GCC ARM embedded toolchain.
Based on patches provided by Hanspeter Portner:

http://forums.leaflabs.com/topic.php?id=1717#post-11812
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-05 13:27:13 -04:00
Marti Bolivar 3feaff9754 Makefile: move flag settings after build-rules and -templates.
We'll need to mess with the linker flags to add support for ARM
toolchains other than CodeSourcery's. Since the toolchain is
determined in build-rules.mk, decisions that depend on it have to
happen after it's included.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-05 12:59:36 -04:00
Marti Bolivar 36b24f9cce usb_cdcacm.c: Fix up descriptor definitions.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-04 18:43:50 -04:00
Marti Bolivar 7ea6af61a0 usb_cdcacm.h: Add convenience for declaring device descriptor.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-04 18:43:49 -04:00
Marti Bolivar 5692b97ad0 <libmaple/usb.h>: Fix usb_descriptor_string.
uint16 is the wrong type for the bString array.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-04 18:43:48 -04:00
Marti Bolivar cf6e56ed4e Move contents of usb_descriptors.h to <libmaple/usb.h>.
These form and name of structs etc. is basically determined by the USB
spec and the libmaple style guide, so there's little reason for them
to change, and less reason for them to stay hidden.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-04 18:43:46 -04:00
Marti Bolivar 5ac380615e Prep usb_descriptors.h for removal.
Just change names and things to fit the libmaple style. Its contents
will move to the top-level <libmaple/usb.h> header next.

This API is still unstable, but we need to expose pieces of it in
order to get the Maple-specific pieces of usb_cdcacm.c into Wirish.

Adjust uses of the API appropriately.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-04 18:43:45 -04:00
Marti Bolivar 7f2b5d0112 usb_cdcacm: Remove unused/redundant variables.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-04 18:43:40 -04:00
Marti Bolivar a97e9c14ed usb_cdcacm: Expose line coding state.
This was already supported, so just move the line coding structure to
the header and add some functions for accessing the current values.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-04 01:47:22 -04:00
Marti Bolivar b642f7b095 usb_cdcacm: Set endpoint to NAK before checking byte count.
Fixes an (admittedly very unlikely) race condition.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-04 00:33:32 -04:00
Marti Bolivar 6788dff2e0 Add FIXME for usb_get_ep_tx_count().
We definitely need to mask out the high bits, as RM0008 doesn't
specify that they read as zero. Calling this function seems to crash
the board, though. I'm not sure why, especially since
usb_set_ep_tx_count(), used by usb_cdcacm.c, seems to work.

Confusing.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-04 00:18:14 -04:00
Marti Bolivar b0a9e6fda2 usb_cdcacm: various fixups.
Mark internal state static. Properly reset the RX/TX state on USB
reset. Choose better names for countTx and newBytes.

Move the exposed configuration back into the .c; this information is
not beneficial to hooks.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-04 00:18:01 -04:00
Marti Bolivar fa1b298b78 usb_cdcacm: Improve write speed.
Actually fill the TX buffer in the packet memory area, so we can send
more bytes per transaction. Using the test-session benchmark, we're
now clocking in the high 700KB/sec range via PySerial. With screen,
rate is now about 550 KB/sec.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-03 23:15:43 -04:00
Marti Bolivar c1e57e08bf usb_cdcacm: Cosmetics
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-03 23:13:32 -04:00
Marti Bolivar cac3fd3b96 test session: Add SerialUSB benchmark to 'U' command.
I'm currently measuring over 500 KB/sec with screen as my serial
monitor. If I don't display the output at all, I get over 600
KB/sec. Nice!

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-03 22:53:31 -04:00
Marti Bolivar d63d5c7fb9 usb_cdcacm: minor fixups.
Rename USB_Line_Coding to usb_line_coding, and rename its fields to
match the spec to aid searches. Alter the line_coding global to match,
fixing an incorrect comment and avoiding magic numbers.

Other minor fixups and comment improvements.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-03 22:53:31 -04:00
Marti Bolivar 69cb5c65cb usb_cdcacm: Rename "notification" -> "management".
This keeps things in line with the specification, helping readability.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-01 13:42:08 -04:00
Marti Bolivar 0cc911c4ae Move CDC ACM config. descriptor into usb_cdcacm.c.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-07-31 18:02:29 -04:00
Marti Bolivar 6126bf5919 Move bootloader details out of libmaple.h.
Finally!

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-07-31 17:27:43 -04:00
Marti Bolivar 15b8a03de9 HardwareSerial: make read() block until data arrive.
This makes the HardwareSerial behavior match that of SerialUSB, and
should help avoid confusion.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-07-31 16:49:00 -04:00
Marti Bolivar 365f45679b Move bootloader reset signal detection to Wirish.
Use usb_cdcacm hooks to move the DTR edge and "1EAF" magic packet
detection to usb_serial.cpp. We'll later be able to extend this system
to support Leonardo-style reset signalling.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-07-31 15:04:49 -04:00
Marti Bolivar ef1cc46487 usb_cdcacm: Add usb_cdcacm_peek().
We need this so the bootloader reset signal detector can look ahead in
the byte stream without stealing bytes from the user when "1EAF" isn't
received.

While we're doing this, take the time to fix a bunch of RX-related
code (dead code removal, adding volatile, etc.)

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-07-31 15:04:49 -04:00
Marti Bolivar 572633d61e usb_cdacm: Use config instead of magic numbers.
Sigh.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-07-31 15:04:49 -04:00
Marti Bolivar 496e0566fa usb_cdcacm: Add hook system.
Provide hooks so users can reach into the CDC ACM callbacks with their
own code. We'll use this to move the bootloader reset signals to
Wirish.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-07-31 15:04:49 -04:00
Marti Bolivar 84468115ec usb_cdcacm: Expose some internal configuration and values.
Mark the API as unstable so people don't rely on these too hard. (This
header is not part of the official libmaple docs). We'll need some of
this configuration elsewhere later, and it doesn't make much sense to
expose it piecemeal.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-07-31 15:04:49 -04:00
Marti Bolivar e629303f0d usb_cdcacm.c: Add another verification TODO.
Not sure what the comment above the new TODO is supposed to mean, but
it looks like something that should be checked.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-07-31 15:04:49 -04:00
Marti Bolivar 4e90c4028c usb_cdcacm.c: Resolve TODO and improve comments.
The disc pin code was copy-pasted when the CDC ACM pieces were
extracted from the rest of the USB code, and I didn't really
understand what was going on when I moved it over. Having checked the
spec, the comments can be safely improved.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-07-31 15:04:49 -04:00
Marti Bolivar 7c976e4e5d Hack: Provide a hook so Mini doesn't disable JTAG/SWD.
The nonexistence of a configuration system is starting to become kind
of a pain. Oh well; let's keep piling hacks on until things break.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-07-31 15:04:49 -04:00
Marti Bolivar 77efc209f9 usb_serial.cpp: Minor tweak.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-07-25 17:19:41 -04:00
Marti Bolivar dbb3869eda Add pin alias enums to other boards.
Repeat Anton's VLDiscovery trick on the rest of the boards. Leave out
st_stm3220g_eval since that's just a teaser to get people to play with
F2.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-07-24 19:12:29 -04:00
Marti Bolivar 2c1c5bfe6e stm32loader.py: Cosmetics.
Move the actual QUIET setting to above mdebug(); that was
confusing. Rename _wait_for_ask to _wait_for_ack.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-07-24 18:41:46 -04:00
Marti Bolivar 1631f8797d stm32loader.py: Updates for F2 and F4.
Support the extended erase memory command, which replaced the erase
memory command in the bootloader protocol as of version 3.0. This
takes a long time, so tweak _wait_for_ask to take an extra timeout for
special cases like this.

Use this under if __name__ == '__main__' to support F2 and
F4. Additionally, produce a human-readable report of the target chip
from its chip ID.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-07-24 18:35:21 -04:00
Marti Bolivar d60473d362 stm32loader.py: Improve error message on failed init.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-07-24 17:51:44 -04:00
Marti Bolivar 69f24a0d31 stm32loader.py: Use new-style classes.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-07-24 17:05:45 -04:00
Marti Bolivar a79304635a stm32loader.py: Don't use Psyco.
This script is I/O bound.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-07-24 16:59:46 -04:00
Marti Bolivar a158aa604e stm32loader.py: Use print function.
Towards py3k compatibility.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-07-24 16:59:14 -04:00
Marti Bolivar 29a69c2423 stm32loader.py: Remove unused code.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-07-24 16:53:40 -04:00
Marti Bolivar 4cd72bbd5c reset.py: Remove advisory for 64-bit Linux.
We test on that platform now, and it does work.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-07-20 17:00:15 -04:00
Marti Bolivar c6aa996912 <libmaple/scb.h>: Add FIXME to check for F2 compatibility.
Signed-off-by: Marti Bolivar <mbolivar@lozenge.(none)>
2012-07-13 03:04:27 -04:00
Marti Bolivar fcdfeb495b <libmaple/scb.h>: Don't use BIT().
Also, assert copyright LeafLabs 2012.

Signed-off-by: Marti Bolivar <mbolivar@lozenge.(none)>
2012-07-13 02:59:58 -04:00