Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate SCSI pass through, fix F1 targets again, valgrind all the goodies #29

Merged
merged 72 commits into from
Nov 15, 2011

Conversation

karlp
Copy link
Contributor

@karlp karlp commented Nov 15, 2011

The bulk of this change is in the elimination of the scsi pass through for the stlinkv1 hardware. This all seems to be working well now, after a few initial hiccups. Documentation has mostly been updated to cover this, but as always, could do with more :)

  • Logging was overhauled.
  • Command line parsing was overhauled
  • Lots of device specific code that was scattered between gdbserver, flash util and common code has been moved into the common code, but there's still much to be done here.
  • Lots of redundant calls to lookup the same information (particularly core/chip id) has been moved into a common step when the target is first opened.

I had hoped to get this merged in earlier, but the flurry of activity around the F4 support got in the way a little bit.

This branch has been tested by jnosky and csamuelson on F4 boards, myself and jpa on F1VL and F1 boards, with a mixture of stlinkv1 and stlinkv2 hardware.

UweBonnes and others added 30 commits October 14, 2011 19:28
Signed-off-by: Karl Palsson <[email protected]>
Signed-off-by: Karl Palsson <[email protected]>
Supports setting the gdb listen port
Supports setting which version of stlink to use
Supports setting the device to use (in case autoprobing doesn't work)
Less mucking around with make parameters, it's a tiny build.  Verified with a
VL and L board.

Removed the old obsolete bin file
No idea why this was added, but it's not necessary for anything I've found.
We're starting on integration from github.com/afaerber
So, instead of scanning all the usb devices, just open what we want.
Also flag out some places where code appears unused.
I needed some sanity...
%Ld works for size_t only on 64 bit, the correct conversion is %zd
Better support for F4, or anything else that appears as an stlinkv2
More bulk cleanup on the path to removing sg-utils dependencies.  Trying to make
test-sg as simple as possible so I can use it reliably to test on both master and my
killsg branch
Remove duplication of stlink version decoding, and put the decoded version information
into the stlink object itself.
Conflicts:
	src/stlink-common.c
	src/test_sg.c

Conflicts were only in changes to logging.
Very very raw, this just finds the device and opens the usb handle.
Hooray! Stage 1 complete.  The stlink version can now be read by sending the scsi
commands via libusb directly, instead of using sg-utils.  It's very very prototype code
however, but should come together from here.

Major bugs: Only works when the device has been first plugged in.  I'm clearly not
resetting some usb state somewhere.

Now that libusb is being used directly, you can use linux usb-storage quirks to
completely IGNORE the device as mass storage.  We'll just grab it via libusb when we
want it.
Before, I could a single operation (get version) after plugging in, now I can issue two at least
:)  I suspect there are two problems still.  1, I'm not using tags properly, as the original
sg-utils code seemed to skip that.  2) I'm pretty sure I need to be sending variable lengths for
the cdb field.
karlp added 18 commits November 14, 2011 02:47
These libraries IGNORE assert_param.  Maybe later.
It compiles, but I've got bugs preventing me from running this yet :(
And update some of the logging to be a bit tidier
in the top level, make clean cleans all stlink code.
in an application level, it only cleans that application
Lots of the debug code is far too verbose for anything but usb tracing.
Likewise, remove all the old scsi code that was simply ifdefd out.
Now that we're not using sg, and we've told the kernel to ignore the device in
usb-mass storage, we don't need to close and wait 5 seconds.  We can just
immediately issue the command to switch modes.
And remove dead/duplicate code that is included in the opening of the device
This branch should work for F1 and F4 devices.  It has currently been tested
with F1 value line, (a VL discovery board) programmed via gdb via both an
stlinkv1 and an stlinkv2.

F4 has _not_ yet been tested on this branch

Conflicts:
	.gitignore
	doc/tutorial/tutorial.pdf
	example/blink/main.c
	gdbserver/Makefile
	gdbserver/gdb-server.c
	src/stlink-common.c
	src/stlink-common.h
	src/stlink-usb.c
The F4 code had #ifdefd out the verification, as the page/sector size can be
too large to read in via a single transfer.  Pull the verification out to a
separate function, the flash write was getting far too large anyway.
@karlp
Copy link
Contributor Author

karlp commented Nov 15, 2011

Also, to the best of my knowledge, this pull request fixes all outstanding issues currently open on stlink.

texane added a commit that referenced this pull request Nov 15, 2011
Eliminate SCSI pass through, fix F1 targets again, valgrind all the goodies
@texane texane merged commit a9237d7 into stlink-org:master Nov 15, 2011
@texane
Copy link
Collaborator

texane commented Nov 15, 2011

Hi,

Thank for those contributions. I merge them without checking, and I will
have a look as soon as possible for the details. I agree with the commit
messages, there was redundant or even useless code here and there,
esp. regarding the chip id. Since there have been several people testing
it, I guess it works well :)

My best regards,

Fabien.

2011/11/15 Karl Palsson
[email protected]:

The bulk of this change is in the elimination of the scsi pass through for the stlinkv1 hardware.  This all seems to be working well now, after a few initial hiccups.  Documentation has mostly been updated to cover this, but as always, could do with more :)

  • Logging was overhauled.
  • Command line parsing was overhauled
  • Lots of device specific code that was scattered between gdbserver, flash util and common code has been moved into the common code, but there's still much to be done here.
  • Lots of redundant calls to lookup the same information (particularly core/chip id) has been moved into a common step when the target is first opened.

I had hoped to get this merged in earlier, but the flurry of activity around the F4 support got in the way a little bit.

This branch has been tested by jnosky and csamuelson on F4 boards, myself and jpa on F1VL and F1 boards, with a mixture of stlinkv1 and stlinkv2 hardware.

You can merge this Pull Request by running:

 git pull https://github.com/karlp/stlink future_f1plusf4

Or you can view, comment on it, or merge it online at:

 #29

-- Commit Summary --

  • Fix a signedness warning
  • Size all USB receive operations
  • Assert size only if Q_BUF_LEN is smaller UINT16_MAX
  • Remove some debug output
  • Merge branch 'master' of https://github.com/texane/stlink
  • Fix character encodings of st provided files.
  • Add debug flag by default, no need not to have it in the elf.
  • Merge upstream texane/master
  • Merge branch 'master' of https://github.com/texane/stlink
  • Add option parsing and help
  • Update netbeans project config to reflect combined makefiles
  • Make the blink example build for all platforms.
  • remove swallowing of ctrl-c
  • Remove all #ifdefs for sg-utils.
  • flag out the only scsi specific code
  • Replace all logging
  • Ignore all elf outputs. Ignore pdflatex outputs
  • Remove unneeded old files
  • Fix compilation for 32bit machines
  • More generic stlinkv2 udev naming
  • Remove sg-utils test output
  • Remove -sg's private version decoding
  • drop non shared directories from netbeans project
  • Merge branch 'master' into killsg
  • Successfully locate and open stlinkv1 by usb
  • Read stlink version info via libusb.
  • Merge branch 'killsg' of github.com:karlp/stlink into killsg
  • Use the libusb based sense and status reading from afaerber
  • Properly use tags.  Doesn't help though.
  • Duh, don't try and do a bulk read when we requested 0 bytes back.
  • Remove device names, we now just find it via USB ids.
  • Fix write_mem32.
  • write_mem8 works too.
  • blinking LEDs via stlink also works
  • Writing registers works too
  • Fix compilation error after removing devices.
  • Update netbeans project files.
  • Update documentation removing all sg-utils notes
  • Update tutorial docs and flash writing/reading
  • Include a udev rules file for v1 boards too, for permissions
  • netbeans project update for flash utility
  • Merge branch 'master' of https://github.com/texane/stlink
  • Fixed a bug that caused gdb to display wrong registers when using stlink ver 1.
  • Merge pull request Working gdb-server #1 from PetteriAimonen/master
  • Finish removing sg-utils dependencies.
  • Merge branch 'master' of github.com:karlp/stlink
  • Move all the flash size mapping from gdb server into core.
  • Read chip and core id in device param loading.
  • Fix flash writing for VL cores.
  • Don't try reading device params in bad USB modes.
  • Restructure libs source to support multi platform
  • Rename 32L specific examples
  • Rename board specific demos as appropriate
  • Fix compile error with new libraries
  • Build libraries for stm32l1xx and stm32f10x
  • Adding original source of vl factory demo
  • Fix linking with new names
  • Don't refetch the chip id on every single page erase.
  • Start to keep an uptodate list of what's been tested in what combinations
  • Remove confusing distclean/clean dichotomy
  • Note that many of these "examples" are busted
  • Remove lots of dead code and superfluous trace
  • Start up stlinkv1 faster.
  • Turn down default logging level.
  • Remove dead code and unused variables
  • Fix memory leaks closing v1 hardware.
  • Keep netbeans happy
  • Remove final reference to old sg/usb compilation flags
  • Update readme, as this is about to get messy!
  • Merge remote branch 'origin/libwork2'
  • Merge branch 'tmaster' into future
  • Fix merge problem with flash verify for F4

-- File Changes --

M .gitignore (3)
D 10-stlink.rules (43)
R 49-stlinkv1.rules (11)
A 49-stlinkv2.rules (12)
M Makefile (27)
M README (79)
M doc/tutorial/tutorial.pdf (0)
M doc/tutorial/tutorial.tex (61)
A example/32l_dac/Makefile (40)
R example/32l_dac/discover_board.h (0)
R example/32l_dac/main.c (0)
R example/32l_dac/startup_stm32l1xx_md.s (0)
R example/32l_dac/stm32_flash.ld (0)
R example/32l_dac/system_stm32l1xx.c (0)
A example/32l_lcd/Makefile (42)
R example/32l_lcd/discover_board.h (0)
R example/32l_lcd/linker_stm32l.lds (0)
R example/32l_lcd/main.c (0)
R example/32l_lcd/stm32l_discovery_lcd.c (4)
R example/32l_lcd/stm32l_discovery_lcd.h (4)
A example/32vl_factory_demo/Makefile (53)
A example/32vl_factory_demo/README (5)
A example/32vl_factory_demo/main.c (234)
A example/32vl_factory_demo/stm32f10x_conf.h (76)
A example/32vl_factory_demo/stm32f10x_it.c (160)
A example/32vl_factory_demo/stm32f10x_it.h (46)
A example/32vl_factory_demo/system_stm32f10x.c (1019)
A example/README (6)
M example/blink/Makefile (37)
D example/blink/disasm.sh (3)
M example/blink/main.c (68)
D example/dac/Makefile (43)
D example/lcd/Makefile (37)
A example/libs_stm/README (9)
A example/libs_stm/build/Makefile (10)
A example/libs_stm/build/Makefile.common (34)
A example/libs_stm/build/Makefile.f10x (5)
A example/libs_stm/build/Makefile.l1xx (5)
R example/libs_stm/inc/base/stdint.h (0)
R example/libs_stm/inc/core_support/core_cm3.c (0)
R example/libs_stm/inc/core_support/core_cm3.h (0)
A example/libs_stm/inc/device_support/stm32f10x.h (8227)
R example/libs_stm/inc/device_support/stm32l1xx.h (0)
A example/libs_stm/inc/device_support/system_stm32f10x.h (97)
R example/libs_stm/inc/device_support/system_stm32l1xx.h (0)
A example/libs_stm/inc/stm32f10x/misc.h (219)
A example/libs_stm/inc/stm32f10x/stm32f10x_adc.h (482)
A example/libs_stm/inc/stm32f10x/stm32f10x_bkp.h (194)
A example/libs_stm/inc/stm32f10x/stm32f10x_can.h (535)
A example/libs_stm/inc/stm32f10x/stm32f10x_cec.h (209)
A example/libs_stm/inc/stm32f10x/stm32f10x_crc.h (93)
A example/libs_stm/inc/stm32f10x/stm32f10x_dac.h (316)
A example/libs_stm/inc/stm32f10x/stm32f10x_dbgmcu.h (118)
A example/libs_stm/inc/stm32f10x/stm32f10x_dma.h (437)
A example/libs_stm/inc/stm32f10x/stm32f10x_exti.h (183)
A example/libs_stm/inc/stm32f10x/stm32f10x_flash.h (425)
A example/libs_stm/inc/stm32f10x/stm32f10x_fsmc.h (716)
A example/libs_stm/inc/stm32f10x/stm32f10x_gpio.h (379)
A example/libs_stm/inc/stm32f10x/stm32f10x_i2c.h (670)
A example/libs_stm/inc/stm32f10x/stm32f10x_iwdg.h (139)
A example/libs_stm/inc/stm32f10x/stm32f10x_pwr.h (155)
A example/libs_stm/inc/stm32f10x/stm32f10x_rcc.h (726)
A example/libs_stm/inc/stm32f10x/stm32f10x_rtc.h (134)
A example/libs_stm/inc/stm32f10x/stm32f10x_sdio.h (530)
A example/libs_stm/inc/stm32f10x/stm32f10x_spi.h (490)
A example/libs_stm/inc/stm32f10x/stm32f10x_tim.h (1133)
A example/libs_stm/inc/stm32f10x/stm32f10x_usart.h (411)
A example/libs_stm/inc/stm32f10x/stm32f10x_wwdg.h (114)
R example/libs_stm/inc/stm32l1xx/misc.h (0)
R example/libs_stm/inc/stm32l1xx/stm32l1xx_adc.h (0)
R example/libs_stm/inc/stm32l1xx/stm32l1xx_comp.h (0)
R example/libs_stm/inc/stm32l1xx/stm32l1xx_crc.h (0)
R example/libs_stm/inc/stm32l1xx/stm32l1xx_dac.h (0)
R example/libs_stm/inc/stm32l1xx/stm32l1xx_dbgmcu.h (0)
R example/libs_stm/inc/stm32l1xx/stm32l1xx_dma.h (0)
R example/libs_stm/inc/stm32l1xx/stm32l1xx_exti.h (0)
R example/libs_stm/inc/stm32l1xx/stm32l1xx_flash.h (0)
R example/libs_stm/inc/stm32l1xx/stm32l1xx_gpio.h (0)
R example/libs_stm/inc/stm32l1xx/stm32l1xx_i2c.h (0)
R example/libs_stm/inc/stm32l1xx/stm32l1xx_iwdg.h (0)
R example/libs_stm/inc/stm32l1xx/stm32l1xx_lcd.h (0)
R example/libs_stm/inc/stm32l1xx/stm32l1xx_pwr.h (0)
R example/libs_stm/inc/stm32l1xx/stm32l1xx_rcc.h (0)
R example/libs_stm/inc/stm32l1xx/stm32l1xx_rtc.h (0)
R example/libs_stm/inc/stm32l1xx/stm32l1xx_spi.h (0)
R example/libs_stm/inc/stm32l1xx/stm32l1xx_syscfg.h (0)
R example/libs_stm/inc/stm32l1xx/stm32l1xx_tim.h (0)
R example/libs_stm/inc/stm32l1xx/stm32l1xx_usart.h (0)
R example/libs_stm/inc/stm32l1xx/stm32l1xx_wwdg.h (0)
A example/libs_stm/src/stm32f10x/Release_Notes_for_STM32F10x_StdPeriph_Driver.html (203)
A example/libs_stm/src/stm32f10x/misc.c (223)
A example/libs_stm/src/stm32f10x/stm32f10x_adc.c (1306)
A example/libs_stm/src/stm32f10x/stm32f10x_bkp.c (311)
A example/libs_stm/src/stm32f10x/stm32f10x_can.c (990)
A example/libs_stm/src/stm32f10x/stm32f10x_cec.c (432)
A example/libs_stm/src/stm32f10x/stm32f10x_crc.c (163)
A example/libs_stm/src/stm32f10x/stm32f10x_dac.c (579)
A example/libs_stm/src/stm32f10x/stm32f10x_dbgmcu.c (161)
A example/libs_stm/src/stm32f10x/stm32f10x_dma.c (693)
A example/libs_stm/src/stm32f10x/stm32f10x_exti.c (268)
A example/libs_stm/src/stm32f10x/stm32f10x_flash.c (1735)
A example/libs_stm/src/stm32f10x/stm32f10x_fsmc.c (858)
A example/libs_stm/src/stm32f10x/stm32f10x_gpio.c (642)
A example/libs_stm/src/stm32f10x/stm32f10x_i2c.c (1285)
A example/libs_stm/src/stm32f10x/stm32f10x_iwdg.c (189)
A example/libs_stm/src/stm32f10x/stm32f10x_pwr.c (316)
A example/libs_stm/src/stm32f10x/stm32f10x_rcc.c (1477)
A example/libs_stm/src/stm32f10x/stm32f10x_rtc.c (341)
A example/libs_stm/src/stm32f10x/stm32f10x_sdio.c (798)
A example/libs_stm/src/stm32f10x/stm32f10x_spi.c (907)
A example/libs_stm/src/stm32f10x/stm32f10x_tim.c (2834)
A example/libs_stm/src/stm32f10x/stm32f10x_usart.c (1054)
A example/libs_stm/src/stm32f10x/stm32f10x_wwdg.c (223)
R example/libs_stm/src/stm32l1xx/misc.c (0)
R example/libs_stm/src/stm32l1xx/stm32l1xx_adc.c (0)
R example/libs_stm/src/stm32l1xx/stm32l1xx_comp.c (0)
R example/libs_stm/src/stm32l1xx/stm32l1xx_crc.c (0)
R example/libs_stm/src/stm32l1xx/stm32l1xx_dac.c (0)
R example/libs_stm/src/stm32l1xx/stm32l1xx_dbgmcu.c (0)
R example/libs_stm/src/stm32l1xx/stm32l1xx_dma.c (0)
R example/libs_stm/src/stm32l1xx/stm32l1xx_exti.c (0)
R example/libs_stm/src/stm32l1xx/stm32l1xx_flash.c (0)
R example/libs_stm/src/stm32l1xx/stm32l1xx_flash_ramfunc.c (0)
R example/libs_stm/src/stm32l1xx/stm32l1xx_gpio.c (0)
R example/libs_stm/src/stm32l1xx/stm32l1xx_i2c.c (0)
R example/libs_stm/src/stm32l1xx/stm32l1xx_iwdg.c (0)
R example/libs_stm/src/stm32l1xx/stm32l1xx_lcd.c (0)
R example/libs_stm/src/stm32l1xx/stm32l1xx_pwr.c (0)
R example/libs_stm/src/stm32l1xx/stm32l1xx_rcc.c (0)
R example/libs_stm/src/stm32l1xx/stm32l1xx_rtc.c (0)
R example/libs_stm/src/stm32l1xx/stm32l1xx_spi.c (0)
R example/libs_stm/src/stm32l1xx/stm32l1xx_syscfg.c (0)
R example/libs_stm/src/stm32l1xx/stm32l1xx_tim.c (0)
R example/libs_stm/src/stm32l1xx/stm32l1xx_usart.c (0)
R example/libs_stm/src/stm32l1xx/stm32l1xx_wwdg.c (0)
D example/libstm32l_discovery/build/Makefile (51)
M flash/Makefile (17)
M flash/main.c (12)
M gdbserver/Makefile (16)
M gdbserver/gdb-server.c (333)
R nbproject/Package-Default.bash (2)
R nbproject/Package-flash.bash (8)
M nbproject/configurations.xml (646)
M nbproject/project.xml (4)
M src/stlink-common.c (388)
M src/stlink-common.h (152)
M src/stlink-sg.c (736)
M src/stlink-sg.h (20)
M src/stlink-usb.c (186)
M src/stlink-usb.h (6)
M src/test_sg.c (97)
M src/test_usb.c (1)
A src/uglylogging.c (58)
A src/uglylogging.h (27)
D stlink.modprobe.conf (1)
A stlink_v1.modprobe.conf (1)

-- Patch Links --

 https://github.com/texane/stlink/pull/29.patch
 https://github.com/texane/stlink/pull/29.diff


Reply to this email directly or view it on GitHub:
#29

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants